diff --git a/OrangeFormsOpen-MybatisFlex/.DS_Store b/OrangeFormsOpen-MybatisFlex/.DS_Store new file mode 100644 index 00000000..5542a459 Binary files /dev/null and b/OrangeFormsOpen-MybatisFlex/.DS_Store differ diff --git a/OrangeFormsOpen-MybatisFlex/.gitignore b/OrangeFormsOpen-MybatisFlex/.gitignore new file mode 100644 index 00000000..e3fa94cd --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/.gitignore @@ -0,0 +1,26 @@ +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/ \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/README.md b/OrangeFormsOpen-MybatisFlex/README.md new file mode 100644 index 00000000..980a205f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/README.md @@ -0,0 +1,21 @@ +### 服务接口文档 +--- +- 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) +- Minio + - 版本:8.4.5 + - 控制台URL:需要配置Nginx,将请求导入到我们缺省设置的19000端口,之后可通过浏览器操作minio。 + - 缺省用户名密码:admin/admin123456 diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/pom.xml b/OrangeFormsOpen-MybatisFlex/application-webadmin/pom.xml new file mode 100644 index 00000000..a78c5df9 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/pom.xml @@ -0,0 +1,91 @@ + + + + com.orangeforms + OrangeFormsOpen + 1.0.0 + + 4.0.0 + + application-webadmin + 1.0.0 + application-webadmin + jar + + + + + com.orangeforms + common-satoken + 1.0.0 + + + com.orangeforms + common-ext + 1.0.0 + + + com.orangeforms + common-redis + 1.0.0 + + + com.orangeforms + common-online + 1.0.0 + + + com.orangeforms + common-flow-online + 1.0.0 + + + com.orangeforms + common-log + 1.0.0 + + + com.orangeforms + common-minio + 1.0.0 + + + com.orangeforms + common-sequence + 1.0.0 + + + com.orangeforms + common-datafilter + 1.0.0 + + + com.orangeforms + common-swagger + 1.0.0 + + + com.orangeforms + common-dict + 1.0.0 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + + + repackage + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/WebAdminApplication.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/WebAdminApplication.java new file mode 100644 index 00000000..86a9458a --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/WebAdminApplication.java @@ -0,0 +1,23 @@ +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 2024-07-02 + */ +@EnableAsync +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) +@ComponentScan("com.orangeforms") +public class WebAdminApplication { + + public static void main(String[] args) { + SpringApplication.run(WebAdminApplication.class, args); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/app/util/FlowIdentityExtHelper.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/app/util/FlowIdentityExtHelper.java new file mode 100644 index 00000000..d5198b82 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/app/util/FlowIdentityExtHelper.java @@ -0,0 +1,244 @@ +package com.orangeforms.webadmin.app.util; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import com.orangeforms.common.flow.util.BaseFlowIdentityExtHelper; +import com.orangeforms.common.flow.util.FlowCustomExtFactory; +import com.orangeforms.common.flow.vo.FlowUserInfoVo; +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 jakarta.annotation.PostConstruct; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 为流程提供所需的用户身份相关的等扩展信息的帮助类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@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 deptPostIdList = sysDeptService.getLeaderDeptPostIdList(deptId); + return CollUtil.isEmpty(deptPostIdList) ? null : deptPostIdList.get(0); + } + + @Override + public Long getUpLeaderDeptPostId(Long deptId) { + List deptPostIdList = sysDeptService.getUpLeaderDeptPostIdList(deptId); + return CollUtil.isEmpty(deptPostIdList) ? null : deptPostIdList.get(0); + } + + @Override + public Map getDeptPostIdMap(Long deptId, Set postIdSet) { + Set postIdSet2 = postIdSet.stream().map(Long::valueOf).collect(Collectors.toSet()); + List deptPostList = sysDeptService.getSysDeptPostList(deptId, postIdSet2); + if (CollUtil.isEmpty(deptPostList)) { + return null; + } + Map resultMap = new HashMap<>(deptPostList.size()); + deptPostList.forEach(sysDeptPost -> + resultMap.put(sysDeptPost.getPostId().toString(), sysDeptPost.getDeptPostId().toString())); + return resultMap; + } + + @Override + public Map getSiblingDeptPostIdMap(Long deptId, Set postIdSet) { + Set postIdSet2 = postIdSet.stream().map(Long::valueOf).collect(Collectors.toSet()); + List deptPostList = sysDeptService.getSiblingSysDeptPostList(deptId, postIdSet2); + if (CollUtil.isEmpty(deptPostList)) { + return null; + } + Map resultMap = new HashMap<>(deptPostList.size()); + for (SysDeptPost deptPost : deptPostList) { + String deptPostId = resultMap.get(deptPost.getPostId().toString()); + if (deptPostId != null) { + deptPostId = deptPostId + "," + deptPost.getDeptPostId(); + } else { + deptPostId = deptPost.getDeptPostId().toString(); + } + resultMap.put(deptPost.getPostId().toString(), deptPostId); + } + return resultMap; + } + + @Override + public Map getUpDeptPostIdMap(Long deptId, Set postIdSet) { + SysDept sysDept = sysDeptService.getById(deptId); + if (sysDept == null || sysDept.getParentId() == null) { + return null; + } + return getDeptPostIdMap(sysDept.getParentId(), postIdSet); + } + + @Override + public Set getUsernameListByRoleIds(Set roleIdSet) { + Set usernameSet = new HashSet<>(); + Set roleIdSet2 = roleIdSet.stream().map(Long::valueOf).collect(Collectors.toSet()); + SysUser filter = new SysUser(); + filter.setUserStatus(SysUserStatus.STATUS_NORMAL); + for (Long roleId : roleIdSet2) { + List userList = sysUserService.getSysUserListByRoleId(roleId, filter, null); + this.extractAndAppendUsernameList(usernameSet, userList); + } + return usernameSet; + } + + @Override + public List getUserInfoListByRoleIds(Set roleIdSet) { + List resultList = new LinkedList<>(); + Set roleIdSet2 = roleIdSet.stream().map(Long::valueOf).collect(Collectors.toSet()); + SysUser filter = new SysUser(); + filter.setUserStatus(SysUserStatus.STATUS_NORMAL); + for (Long roleId : roleIdSet2) { + List userList = sysUserService.getSysUserListByRoleId(roleId, filter, null); + if (CollUtil.isNotEmpty(userList)) { + resultList.addAll(BeanUtil.copyToList(userList, FlowUserInfoVo.class)); + } + } + return resultList; + } + + @Override + public Set getUsernameListByDeptIds(Set deptIdSet) { + Set usernameSet = new HashSet<>(); + Set 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 userList = sysUserService.getSysUserList(filter, null); + this.extractAndAppendUsernameList(usernameSet, userList); + } + return usernameSet; + } + + @Override + public List getUserInfoListByDeptIds(Set deptIdSet) { + List resultList = new LinkedList<>(); + Set 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 userList = sysUserService.getSysUserList(filter, null); + if (CollUtil.isNotEmpty(userList)) { + resultList.addAll(BeanUtil.copyToList(userList, FlowUserInfoVo.class)); + } + } + return resultList; + } + + @Override + public Set getUsernameListByPostIds(Set postIdSet) { + Set usernameSet = new HashSet<>(); + Set postIdSet2 = postIdSet.stream().map(Long::valueOf).collect(Collectors.toSet()); + SysUser filter = new SysUser(); + filter.setUserStatus(SysUserStatus.STATUS_NORMAL); + for (Long postId : postIdSet2) { + List userList = sysUserService.getSysUserListByPostId(postId, filter, null); + this.extractAndAppendUsernameList(usernameSet, userList); + } + return usernameSet; + } + + @Override + public List getUserInfoListByPostIds(Set postIdSet) { + List resultList = new LinkedList<>(); + Set postIdSet2 = postIdSet.stream().map(Long::valueOf).collect(Collectors.toSet()); + SysUser filter = new SysUser(); + filter.setUserStatus(SysUserStatus.STATUS_NORMAL); + for (Long postId : postIdSet2) { + List userList = sysUserService.getSysUserListByPostId(postId, filter, null); + if (CollUtil.isNotEmpty(userList)) { + resultList.addAll(BeanUtil.copyToList(userList, FlowUserInfoVo.class)); + } + } + return resultList; + } + + @Override + public Set getUsernameListByDeptPostIds(Set deptPostIdSet) { + Set usernameSet = new HashSet<>(); + Set deptPostIdSet2 = deptPostIdSet.stream().map(Long::valueOf).collect(Collectors.toSet()); + SysUser filter = new SysUser(); + filter.setUserStatus(SysUserStatus.STATUS_NORMAL); + for (Long deptPostId : deptPostIdSet2) { + List userList = sysUserService.getSysUserListByDeptPostId(deptPostId, filter, null); + this.extractAndAppendUsernameList(usernameSet, userList); + } + return usernameSet; + } + + @Override + public List getUserInfoListByDeptPostIds(Set deptPostIdSet) { + List resultList = new LinkedList<>(); + Set deptPostIdSet2 = deptPostIdSet.stream().map(Long::valueOf).collect(Collectors.toSet()); + SysUser filter = new SysUser(); + filter.setUserStatus(SysUserStatus.STATUS_NORMAL); + for (Long deptPostId : deptPostIdSet2) { + List userList = sysUserService.getSysUserListByDeptPostId(deptPostId, filter, null); + if (CollUtil.isNotEmpty(userList)) { + resultList.addAll(BeanUtil.copyToList(userList, FlowUserInfoVo.class)); + } + } + return resultList; + } + + @Override + public List getUserInfoListByUsernameSet(Set usernameSet) { + List resultList = null; + List userList = sysUserService.getInList("loginName", usernameSet); + if (CollUtil.isNotEmpty(userList)) { + resultList = BeanUtil.copyToList(userList, FlowUserInfoVo.class); + } + return resultList; + } + + @Override + public Boolean supprtDataPerm() { + return true; + } + + @Override + public Map mapUserShowNameByLoginName(Set loginNameSet) { + if (CollUtil.isEmpty(loginNameSet)) { + return new HashMap<>(1); + } + Map resultMap = new HashMap<>(loginNameSet.size()); + List userList = sysUserService.getInList("loginName", loginNameSet); + userList.forEach(user -> resultMap.put(user.getLoginName(), user.getShowName())); + return resultMap; + } + + private void extractAndAppendUsernameList(Set resultUsernameList, List userList) { + List usernameList = userList.stream().map(SysUser::getLoginName).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(usernameList)) { + resultUsernameList.addAll(usernameList); + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/config/ApplicationConfig.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/config/ApplicationConfig.java new file mode 100644 index 00000000..dd028f9d --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/config/ApplicationConfig.java @@ -0,0 +1,38 @@ +package com.orangeforms.webadmin.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +/** + * 应用程序自定义的程序属性配置文件。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Configuration +@ConfigurationProperties(prefix = "application") +public class ApplicationConfig { + /** + * 用户密码被重置之后的缺省密码 + */ + 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中的过期时间(秒)。一定要和sa-token.timeout + * 缺省值是 one day + */ + private int sessionExpiredSeconds = 86400; + /** + * 是否排他登录。 + */ + private Boolean excludeLogin = false; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/config/DataSourceType.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/config/DataSourceType.java new file mode 100644 index 00000000..4820bda3 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/config/DataSourceType.java @@ -0,0 +1,47 @@ +package com.orangeforms.webadmin.config; + +import com.orangeforms.common.core.constant.ApplicationConstant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 表示数据源类型的常量对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class DataSourceType { + + public static final int MAIN = 0; + /** + * 以下所有数据源的类都型是固定值。如果有冲突,请修改上面定义的业务服务的数据源类型值。 + */ + public static final int OPERATION_LOG = ApplicationConstant.OPERATION_LOG_DATASOURCE_TYPE; + public static final int GLOBAL_DICT = ApplicationConstant.COMMON_GLOBAL_DICT_TYPE; + public static final int COMMON_FLOW_AND_ONLINE = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE; + + private static final Map TYPE_MAP = new HashMap<>(8); + static { + TYPE_MAP.put("main", MAIN); + TYPE_MAP.put("operation-log", OPERATION_LOG); + TYPE_MAP.put("global-dict", GLOBAL_DICT); + TYPE_MAP.put("common-flow-online", COMMON_FLOW_AND_ONLINE); + } + + /** + * 根据名称获取字典类型。 + * + * @param name 数据源在配置中的名称。 + * @return 返回可用于多数据源切换的数据源类型。 + */ + public static Integer getDataSourceTypeByName(String name) { + return TYPE_MAP.get(name); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private DataSourceType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/config/FilterConfig.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/config/FilterConfig.java new file mode 100644 index 00000000..350602db --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/config/FilterConfig.java @@ -0,0 +1,60 @@ +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 jakarta.servlet.Filter; +import java.nio.charset.StandardCharsets; + +/** + * 这里主要配置Web的各种过滤器和监听器等Servlet容器组件。 + * + * @author Jerry + * @date 2024-07-02 + */ +@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.setAllowCredentials(true); + configSource.registerCorsConfiguration("/**", corsConfiguration); + } + return new CorsFilter(configSource); + } + + @Bean + public FilterRegistrationBean characterEncodingFilterRegistration() { + FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean<>( + new org.springframework.web.filter.CharacterEncodingFilter()); + filterRegistrationBean.addUrlPatterns("/*"); + filterRegistrationBean.addInitParameter("encoding", StandardCharsets.UTF_8.name()); + // forceEncoding强制response也被编码,另外即使request中已经设置encoding,forceEncoding也会重新设置 + filterRegistrationBean.addInitParameter("forceEncoding", "true"); + filterRegistrationBean.setAsyncSupported(true); + return filterRegistrationBean; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/config/InterceptorConfig.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/config/InterceptorConfig.java new file mode 100644 index 00000000..1d75ac6d --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/config/InterceptorConfig.java @@ -0,0 +1,21 @@ +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 2024-07-02 + */ +@Configuration +public class InterceptorConfig implements WebMvcConfigurer { + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(new AuthenticationInterceptor()).addPathPatterns("/admin/**"); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/config/MultiDataSourceConfig.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/config/MultiDataSourceConfig.java new file mode 100644 index 00000000..bb09bf79 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/config/MultiDataSourceConfig.java @@ -0,0 +1,77 @@ +package com.orangeforms.webadmin.config; + +import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder; +import com.orangeforms.common.core.config.BaseMultiDataSourceConfig; +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 2024-07-02 + */ +@Configuration +@EnableTransactionManagement +@MapperScan(value = {"com.orangeforms.webadmin.*.dao", "com.orangeforms.common.*.dao"}) +public class MultiDataSourceConfig extends BaseMultiDataSourceConfig { + + @Bean(initMethod = "init", destroyMethod = "close") + @ConfigurationProperties(prefix = "spring.datasource.druid.main") + public DataSource mainDataSource() { + return super.applyCommonProps(DruidDataSourceBuilder.create().build()); + } + + /** + * 默认生成的用于保存操作日志的数据源,可根据需求修改。 + * 这里我们还是非常推荐给操作日志使用独立的数据源,这样便于今后的数据迁移。 + */ + @Bean(initMethod = "init", destroyMethod = "close") + @ConfigurationProperties(prefix = "spring.datasource.druid.operation-log") + public DataSource operationLogDataSource() { + return super.applyCommonProps(DruidDataSourceBuilder.create().build()); + } + + /** + * 默认生成的用于全局编码字典的数据源,可根据需求修改。 + */ + @Bean(initMethod = "init", destroyMethod = "close") + @ConfigurationProperties(prefix = "spring.datasource.druid.global-dict") + public DataSource globalDictDataSource() { + return super.applyCommonProps(DruidDataSourceBuilder.create().build()); + } + + /** + * 默认生成的用于在线表单内部表的数据源,可根据需求修改。 + * 这里我们还是非常推荐使用独立数据源,这样便于今后的服务拆分。 + */ + @Bean(initMethod = "init", destroyMethod = "close") + @ConfigurationProperties(prefix = "spring.datasource.druid.common-flow-online") + public DataSource commonFlowAndOnlineDataSource() { + return super.applyCommonProps(DruidDataSourceBuilder.create().build()); + } + + @Bean + @Primary + public DynamicDataSource dataSource() { + Map targetDataSources = new HashMap<>(1); + targetDataSources.put(DataSourceType.MAIN, mainDataSource()); + targetDataSources.put(DataSourceType.OPERATION_LOG, operationLogDataSource()); + targetDataSources.put(DataSourceType.GLOBAL_DICT, globalDictDataSource()); + targetDataSources.put(DataSourceType.COMMON_FLOW_AND_ONLINE, commonFlowAndOnlineDataSource()); + // 如果当前工程支持在线表单,这里请务必保证upms数据表所在数据库为缺省数据源。 + DynamicDataSource dynamicDataSource = new DynamicDataSource(); + dynamicDataSource.setTargetDataSources(targetDataSources); + dynamicDataSource.setDefaultTargetDataSource(mainDataSource()); + return dynamicDataSource; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/config/ThirdPartyAuthConfig.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/config/ThirdPartyAuthConfig.java new file mode 100644 index 00000000..e827057a --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/config/ThirdPartyAuthConfig.java @@ -0,0 +1,66 @@ +package com.orangeforms.webadmin.config; + +import cn.hutool.core.collection.CollUtil; +import lombok.Data; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 第三方应用鉴权配置。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Configuration +@ConfigurationProperties(prefix = "third-party") +public class ThirdPartyAuthConfig implements InitializingBean { + + private List auth; + + private Map applicationMap; + + @Override + public void afterPropertiesSet() throws Exception { + if (CollUtil.isEmpty(auth)) { + applicationMap = new HashMap<>(1); + } else { + applicationMap = auth.stream().collect(Collectors.toMap(AuthProperties::getAppCode, c -> c)); + } + } + + @Data + public static class AuthProperties { + /** + * 应用Id。 + */ + private String appCode; + /** + * 身份验证相关url的base地址。 + */ + private String baseUrl; + /** + * 是否为橙单框架。 + */ + private Boolean orangeFramework = true; + /** + * token的Http Request Header的key + */ + private String tokenHeaderKey; + /** + * 数据权限和用户操作权限缓存过期时间,单位秒。 + */ + private Integer permExpiredSeconds = 86400; + /** + * 用户Token缓存过期时间,单位秒。 + * 如果为0,则每次都要去第三方服务进行验证。 + */ + private Integer tokenExpiredSeconds = 0; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/interceptor/AuthenticationInterceptor.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/interceptor/AuthenticationInterceptor.java new file mode 100644 index 00000000..f2329ff6 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/interceptor/AuthenticationInterceptor.java @@ -0,0 +1,281 @@ +package com.orangeforms.webadmin.interceptor; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.text.StrFormatter; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpResponse; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.orangeforms.common.core.cache.CacheConfig; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.constant.DataPermRuleType; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.exception.MyRuntimeException; +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.RedisKeyUtil; +import com.orangeforms.common.satoken.util.SaTokenUtil; +import com.orangeforms.webadmin.config.ThirdPartyAuthConfig; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.redisson.api.RBucket; +import org.redisson.api.RSet; +import org.redisson.api.RedissonClient; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.util.Assert; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +/** + * 登录用户Token验证、生成和权限验证的拦截器。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class AuthenticationInterceptor implements HandlerInterceptor { + + private final ThirdPartyAuthConfig thirdPartyAuthConfig = + ApplicationContextHolder.getBean("thirdPartyAuthConfig"); + + private final RedissonClient redissonClient = ApplicationContextHolder.getBean(RedissonClient.class); + private final CacheManager cacheManager = ApplicationContextHolder.getBean("caffeineCacheManager"); + + private final SaTokenUtil saTokenUtil = + ApplicationContextHolder.getBean("saTokenUtil"); + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) + throws Exception { + String appCode = this.getAppCodeFromRequest(request); + if (StrUtil.isNotBlank(appCode)) { + return this.handleThirdPartyRequest(appCode, request); + } + ResponseResult result = saTokenUtil.handleAuthIntercept(request, handler); + if (!result.isSuccess()) { + ResponseResult.output(result.getHttpStatus(), result); + return false; + } + 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 String getTokenFromRequest(HttpServletRequest request, String appCode) { + ThirdPartyAuthConfig.AuthProperties prop = thirdPartyAuthConfig.getApplicationMap().get(appCode); + String token = request.getHeader(prop.getTokenHeaderKey()); + if (StrUtil.isBlank(token)) { + token = request.getParameter(prop.getTokenHeaderKey()); + } + if (StrUtil.isBlank(token)) { + token = request.getHeader(ApplicationConstant.HTTP_HEADER_INTERNAL_TOKEN); + } + return token; + } + + private String getAppCodeFromRequest(HttpServletRequest request) { + String appCode = request.getHeader("AppCode"); + if (StrUtil.isBlank(appCode)) { + appCode = request.getParameter("AppCode"); + } + return appCode; + } + + private boolean handleThirdPartyRequest(String appCode, HttpServletRequest request) throws IOException { + String token = this.getTokenFromRequest(request, appCode); + ThirdPartyAuthConfig.AuthProperties authProps = thirdPartyAuthConfig.getApplicationMap().get(appCode); + if (authProps == null) { + String msg = StrFormatter.format("请求的 appCode[{}] 信息,在当前服务中尚未配置!", appCode); + ResponseResult.output(ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, msg)); + return false; + } + ResponseResult result = this.getAndCacheThirdPartyTokenData(authProps, token); + if (!result.isSuccess()) { + ResponseResult.output(result.getHttpStatus(), + ResponseResult.error(ErrorCodeEnum.UNAUTHORIZED_LOGIN, result.getErrorMessage())); + return false; + } + TokenData tokenData = result.getData(); + tokenData.setAppCode(appCode); + tokenData.setSessionId(this.prependAppCode(authProps.getAppCode(), tokenData.getSessionId())); + TokenData.addToRequest(tokenData); + String url = request.getRequestURI(); + if (Boolean.FALSE.equals(tokenData.getIsAdmin()) + && !this.hasThirdPartyPermission(authProps, tokenData, url)) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, ResponseResult.error(ErrorCodeEnum.NO_OPERATION_PERMISSION)); + return false; + } + return true; + } + + private ResponseResult getAndCacheThirdPartyTokenData( + ThirdPartyAuthConfig.AuthProperties authProps, String token) { + if (authProps.getTokenExpiredSeconds() == 0) { + return this.getThirdPartyTokenData(authProps, token); + } + String tokeKey = this.prependAppCode(authProps.getAppCode(), RedisKeyUtil.makeSessionIdKey(token)); + RBucket sessionData = redissonClient.getBucket(tokeKey); + if (sessionData.isExists()) { + return ResponseResult.success(JSON.parseObject(sessionData.get(), TokenData.class)); + } + ResponseResult responseResult = this.getThirdPartyTokenData(authProps, token); + if (responseResult.isSuccess()) { + sessionData.set(JSON.toJSONString(responseResult.getData()), authProps.getTokenExpiredSeconds(), TimeUnit.SECONDS); + } + return responseResult; + } + + private String prependAppCode(String appCode, String key) { + return appCode.toUpperCase() + ":" + key; + } + + private ResponseResult getThirdPartyTokenData( + ThirdPartyAuthConfig.AuthProperties authProps, String token) { + try { + String resultData = this.invokeThirdPartyUrl(authProps.getBaseUrl() + "/getTokenData", token); + return JSON.parseObject(resultData, new TypeReference>() {}); + } catch (MyRuntimeException ex) { + return ResponseResult.error(ErrorCodeEnum.FAILED_TO_INVOKE_THIRDPARTY_URL, ex.getMessage()); + } + } + + private ResponseResult getThirdPartyPermData( + ThirdPartyAuthConfig.AuthProperties authProps, String token) { + try { + String resultData = this.invokeThirdPartyUrl(authProps.getBaseUrl() + "/getPermData", token); + return JSON.parseObject(resultData, new TypeReference>() {}); + } catch (MyRuntimeException ex) { + return ResponseResult.error(ErrorCodeEnum.FAILED_TO_INVOKE_THIRDPARTY_URL, ex.getMessage()); + } + } + + private String invokeThirdPartyUrl(String url, String token) { + Map headerMap = new HashMap<>(1); + headerMap.put("Authorization", token); + StringBuilder fullUrl = new StringBuilder(128); + fullUrl.append(url).append("?token=").append(token); + HttpResponse httpResponse = HttpUtil.createGet(fullUrl.toString()).addHeaders(headerMap).execute(); + if (!httpResponse.isOk()) { + String msg = StrFormatter.format( + "Failed to call [{}] with ERROR HTTP Status [{}] and [{}].", + url, httpResponse.getStatus(), httpResponse.body()); + log.error(msg); + throw new MyRuntimeException(msg); + } + return httpResponse.body(); + } + + @SuppressWarnings("unchecked") + private boolean hasThirdPartyPermission( + ThirdPartyAuthConfig.AuthProperties authProps, TokenData tokenData, String url) { + // 为了提升效率,先检索Caffeine的一级缓存,如果不存在,再检索Redis的二级缓存,并将结果存入一级缓存。 + String permKey = RedisKeyUtil.makeSessionPermIdKey(tokenData.getSessionId()); + Cache cache = cacheManager.getCache(CacheConfig.CacheEnum.USER_PERMISSION_CACHE.name()); + Assert.notNull(cache, "Cache USER_PERMISSION_CACHE can't be NULL"); + Cache.ValueWrapper wrapper = cache.get(permKey); + if (wrapper != null) { + Object cachedData = wrapper.get(); + if (cachedData != null) { + return ((Set) cachedData).contains(url); + } + } + Set localPermSet; + RSet permSet = redissonClient.getSet(permKey); + if (permSet.isExists()) { + localPermSet = permSet.readAll(); + cache.put(permKey, localPermSet); + return localPermSet.contains(url); + } + ResponseResult responseResult = this.getThirdPartyPermData(authProps, tokenData.getToken()); + this.cacheThirdPartyDataPermData(authProps, tokenData, responseResult.getData().getDataPerms()); + if (CollUtil.isEmpty(responseResult.getData().urlPerms)) { + return false; + } + permSet.addAll(responseResult.getData().urlPerms); + permSet.expire(authProps.getPermExpiredSeconds(), TimeUnit.SECONDS); + localPermSet = new HashSet<>(responseResult.getData().urlPerms); + cache.put(permKey, localPermSet); + return localPermSet.contains(url); + } + + private void cacheThirdPartyDataPermData( + ThirdPartyAuthConfig.AuthProperties authProps, TokenData tokenData, List dataPerms) { + if (CollUtil.isEmpty(dataPerms)) { + return; + } + Map> dataPermMap = + dataPerms.stream().collect(Collectors.groupingBy(ThirdPartyAppDataPermData::getRuleType)); + Map> normalizedDataPermMap = new HashMap<>(dataPermMap.size()); + for (Map.Entry> entry : dataPermMap.entrySet()) { + List ruleTypeDataPermDataList; + if (entry.getKey().equals(DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT)) { + ruleTypeDataPermDataList = + normalizedDataPermMap.computeIfAbsent(DataPermRuleType.TYPE_CUSTOM_DEPT_LIST, k -> new LinkedList<>()); + } else { + ruleTypeDataPermDataList = + normalizedDataPermMap.computeIfAbsent(entry.getKey(), k -> new LinkedList<>()); + } + ruleTypeDataPermDataList.addAll(entry.getValue()); + } + Map resultDataPermMap = new HashMap<>(normalizedDataPermMap.size()); + for (Map.Entry> entry : normalizedDataPermMap.entrySet()) { + if (entry.getKey().equals(DataPermRuleType.TYPE_CUSTOM_DEPT_LIST)) { + String deptIds = entry.getValue().stream() + .map(ThirdPartyAppDataPermData::getDeptIds).collect(Collectors.joining(",")); + resultDataPermMap.put(entry.getKey(), deptIds); + } else { + resultDataPermMap.put(entry.getKey(), "null"); + } + } + Map> menuDataPermMap = new HashMap<>(1); + menuDataPermMap.put(ApplicationConstant.DATA_PERM_ALL_MENU_ID, resultDataPermMap); + String dataPermSessionKey = RedisKeyUtil.makeSessionDataPermIdKey(tokenData.getSessionId()); + RBucket bucket = redissonClient.getBucket(dataPermSessionKey); + bucket.set(JSON.toJSONString(menuDataPermMap), authProps.getPermExpiredSeconds(), TimeUnit.SECONDS); + } + + @Data + public static class ThirdPartyAppPermData { + /** + * 当前用户会话可访问的url接口地址列表。 + */ + private List urlPerms; + /** + * 当前用户会话的数据权限列表。 + */ + private List dataPerms; + } + + @Data + public static class ThirdPartyAppDataPermData { + /** + * 数据权限的规则类型。需要按照橙单的约定返回。具体值可参考DataPermRuleType常量类。 + */ + private Integer ruleType; + /** + * 部门Id集合,多个部门Id之间逗号分隔。 + * 注意:仅当ruleType为3、4、5时需要包含该字段值。 + */ + private String deptIds; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/bo/SysMenuExtraData.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/bo/SysMenuExtraData.java new file mode 100644 index 00000000..dbca8a5b --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/bo/SysMenuExtraData.java @@ -0,0 +1,55 @@ +package com.orangeforms.webadmin.upms.bo; + +import lombok.Data; + +import java.util.List; + +/** + * 菜单扩展数据对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class SysMenuExtraData { + + /** + * 路由名称。 + */ + private String formRouterName; + + /** + * 在线表单。 + */ + private Long onlineFormId; + + /** + * 报表页面。 + */ + private Long reportPageId; + + /** + * 流程。 + */ + private Long onlineFlowEntryId; + + /** + * 目标url。 + */ + private String targetUrl; + + /** + * 绑定类型。 + */ + private Integer bindType; + + /** + * 前端使用的菜单编码。仅当选择satoken权限框架时使用。 + */ + private String menuCode; + + /** + * 菜单关联的后台使用的权限字列表。仅当选择satoken权限框架时使用。 + */ + private List permCodeList; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/bo/SysMenuPerm.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/bo/SysMenuPerm.java new file mode 100644 index 00000000..8c429d37 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/bo/SysMenuPerm.java @@ -0,0 +1,66 @@ +package com.orangeforms.webadmin.upms.bo; + +import lombok.Data; + +import java.util.HashSet; +import java.util.Set; + +/** + * 菜单相关的业务对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class SysMenuPerm { + + /** + * 菜单Id。 + */ + private Long menuId; + + /** + * 父菜单Id,目录菜单的父菜单为null + */ + private Long parentId; + + /** + * 菜单显示名称。 + */ + private String menuName; + + /** + * 菜单类型 (0: 目录 1: 菜单 2: 按钮 3: UI片段)。 + */ + private Integer menuType; + + /** + * 在线表单主键Id,仅用于在线表单绑定的菜单。 + */ + private Long onlineFormId; + + /** + * 在线表单菜单的权限控制类型,具体值可参考SysOnlineMenuPermType常量对象。 + */ + private Integer onlineMenuPermType; + + /** + * 统计页面主键Id,仅用于统计页面绑定的菜单。 + */ + private Long reportPageId; + + /** + * 仅用于在线表单的流程Id。 + */ + private Long onlineFlowEntryId; + + /** + * 关联权限URL集合。 + */ + Set permUrlSet = new HashSet<>(); + + /** + * 关联的某一个url。 + */ + String url; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/GlobalDictController.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/GlobalDictController.java new file mode 100644 index 00000000..df90d312 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/GlobalDictController.java @@ -0,0 +1,340 @@ +package com.orangeforms.webadmin.upms.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.MyOrderParam; +import com.orangeforms.common.core.object.MyPageData; +import com.orangeforms.common.core.object.MyPageParam; +import com.orangeforms.common.core.object.ResponseResult; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.dict.dto.GlobalDictDto; +import com.orangeforms.common.dict.dto.GlobalDictItemDto; +import com.orangeforms.common.dict.model.GlobalDict; +import com.orangeforms.common.dict.model.GlobalDictItem; +import com.orangeforms.common.dict.service.GlobalDictItemService; +import com.orangeforms.common.dict.service.GlobalDictService; +import com.orangeforms.common.dict.util.GlobalDictOperationHelper; +import com.orangeforms.common.dict.vo.GlobalDictVo; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.github.pagehelper.Page; +import com.github.pagehelper.page.PageMethod; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 全局通用字典操作接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "全局字典管理接口") +@Slf4j +@RestController +@RequestMapping("/admin/upms/globalDict") +public class GlobalDictController { + + @Autowired + private GlobalDictService globalDictService; + @Autowired + private GlobalDictItemService globalDictItemService; + @Autowired + private GlobalDictOperationHelper globalDictOperationHelper; + + /** + * 新增全局字典接口。 + * + * @param globalDictDto 新增字典对象。 + * @return 保存后的字典对象。 + */ + @ApiOperationSupport(ignoreParameters = {"globalDictDto.dictId"}) + @SaCheckPermission("globalDict.update") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody GlobalDictDto globalDictDto) { + String errorMessage = MyCommonUtil.getModelValidationError(globalDictDto); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + // 这里必须手动校验字典编码是否存在,因为我们缺省的实现是逻辑删除,所以字典编码字段没有设置为唯一索引。 + if (globalDictService.existDictCode(globalDictDto.getDictCode())) { + errorMessage = "数据验证失败,字典编码已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + GlobalDict globalDict = MyModelUtil.copyTo(globalDictDto, GlobalDict.class); + globalDictService.saveNew(globalDict); + return ResponseResult.success(globalDict.getDictId()); + } + + /** + * 更新全局字典操作。 + * + * @param globalDictDto 更新全局字典对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("globalDict.update") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody GlobalDictDto globalDictDto) { + String errorMessage = MyCommonUtil.getModelValidationError(globalDictDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + GlobalDict originalGlobalDict = globalDictService.getById(globalDictDto.getDictId()); + if (originalGlobalDict == null) { + errorMessage = "数据验证失败,当前全局字典并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + GlobalDict globalDict = MyModelUtil.copyTo(globalDictDto, GlobalDict.class); + if (ObjectUtil.notEqual(globalDict.getDictCode(), originalGlobalDict.getDictCode()) + && globalDictService.existDictCode(globalDict.getDictCode())) { + errorMessage = "数据验证失败,字典编码已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!globalDictService.update(globalDict, originalGlobalDict)) { + errorMessage = "更新失败,数据不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 删除指定的全局字典。 + * + * @param dictId 指定全局字典主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("globalDict.update") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody(required = true) Long dictId) { + if (!globalDictService.remove(dictId)) { + String errorMessage = "数据操作失败,全局字典Id不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 查看全局字典列表。 + * + * @param globalDictDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含角色列表。 + */ + @SaCheckPermission("globalDict.view") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody GlobalDictDto globalDictDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + GlobalDict filter = MyModelUtil.copyTo(globalDictDtoFilter, GlobalDict.class); + List globalDictList = + globalDictService.getGlobalDictList(filter, MyOrderParam.buildOrderBy(orderParam, GlobalDict.class)); + List globalDictVoList = + MyModelUtil.copyCollectionTo(globalDictList, GlobalDictVo.class); + long totalCount = 0L; + if (globalDictList instanceof Page) { + totalCount = ((Page) globalDictList).getTotal(); + } + return ResponseResult.success(MyPageUtil.makeResponseData(globalDictVoList, totalCount)); + } + + /** + * 新增全局字典项目接口。 + * + * @param globalDictItemDto 新增字典项目对象。 + * @return 保存后的字典对象。 + */ + @SaCheckPermission("globalDict.update") + @ApiOperationSupport(ignoreParameters = {"globalDictItemDto.id"}) + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/addItem") + public ResponseResult addItem(@MyRequestBody GlobalDictItemDto globalDictItemDto) { + String errorMessage = MyCommonUtil.getModelValidationError(globalDictItemDto); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!globalDictService.existDictCode(globalDictItemDto.getDictCode())) { + errorMessage = "数据验证失败,字典编码不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (globalDictItemService.existDictCodeAndItemId( + globalDictItemDto.getDictCode(), globalDictItemDto.getItemId())) { + errorMessage = "数据验证失败,该字典编码的项目Id已存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + GlobalDictItem globalDictItem = MyModelUtil.copyTo(globalDictItemDto, GlobalDictItem.class); + globalDictItemService.saveNew(globalDictItem); + return ResponseResult.success(globalDictItem.getId()); + } + + /** + * 更新全局字典项目。 + * + * @param globalDictItemDto 更新全局字典项目对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("globalDict.update") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/updateItem") + public ResponseResult updateItem(@MyRequestBody GlobalDictItemDto globalDictItemDto) { + String errorMessage = MyCommonUtil.getModelValidationError(globalDictItemDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + GlobalDictItem originalGlobalDictItem = globalDictItemService.getById(globalDictItemDto.getId()); + if (originalGlobalDictItem == null) { + errorMessage = "数据验证失败,当前全局字典项目并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + GlobalDictItem globalDictItem = MyModelUtil.copyTo(globalDictItemDto, GlobalDictItem.class); + if (ObjectUtil.notEqual(globalDictItem.getDictCode(), originalGlobalDictItem.getDictCode())) { + errorMessage = "数据验证失败,字典项目的字典编码不能修改!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (ObjectUtil.notEqual(globalDictItem.getItemId(), originalGlobalDictItem.getItemId()) + && globalDictItemService.existDictCodeAndItemId(globalDictItem.getDictCode(), globalDictItem.getItemId())) { + errorMessage = "数据验证失败,该字典编码已经包含了该项目Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!globalDictItemService.update(globalDictItem, originalGlobalDictItem)) { + errorMessage = "更新失败,数据不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 更新全局字典项目的状态。 + * + * @param id 更新全局字典项目主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("globalDict.update") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/updateItemStatus") + public ResponseResult updateItemStatus( + @MyRequestBody(required = true) Long id, @MyRequestBody(required = true) Integer status) { + String errorMessage; + GlobalDictItem dictItem = globalDictItemService.getById(id); + if (dictItem == null) { + errorMessage = "数据操作失败,全局字典项目Id不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (ObjectUtil.notEqual(dictItem.getStatus(), status)) { + globalDictItemService.updateStatus(dictItem, status); + } + return ResponseResult.success(); + } + + /** + * 删除指定编码的全局字典项目。 + * + * @param id 主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("globalDict.update") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/deleteItem") + public ResponseResult deleteItem(@MyRequestBody(required = true) Long id) { + String errorMessage; + GlobalDictItem dictItem = globalDictItemService.getById(id); + if (dictItem == null) { + errorMessage = "数据操作失败,全局字典项目Id不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!globalDictItemService.remove(dictItem)) { + errorMessage = "数据操作失败,全局字典项目Id不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 将当前字典表的数据重新加载到缓存中。 + * 由于缓存的数据更新,在add/update/delete等接口均有同步处理。因此该接口仅当同步过程中出现问题时, + * 可手工调用,或者每天晚上定时同步一次。 + */ + @SaCheckPermission("globalDict.view") + @OperationLog(type = SysOperationLogType.RELOAD_CACHE) + @GetMapping("/reloadCachedData") + public ResponseResult reloadCachedData(@RequestParam String dictCode) { + globalDictService.reloadCachedData(dictCode); + return ResponseResult.success(true); + } + + /** + * 获取指定字典编码的全局字典项目。字典的键值为[itemId, itemName]。 + * NOTE: 白名单接口。 + * + * @param dictCode 字典编码。 + * @param itemIdType 字典项目的ItemId值转换到的目标类型。可能值为Integer或Long。 + * @return 应答结果对象。 + */ + @GetMapping("/listDict") + public ResponseResult>> listDict( + @RequestParam String dictCode, @RequestParam(required = false) String itemIdType) { + List resultList = + globalDictService.getGlobalDictItemListFromCache(dictCode, null); + resultList = resultList.stream() + .sorted(Comparator.comparing(GlobalDictItem::getStatus)) + .sorted(Comparator.comparing(GlobalDictItem::getShowOrder)) + .collect(Collectors.toList()); + return ResponseResult.success(globalDictOperationHelper.toDictDataList(resultList, itemIdType)); + } + + /** + * 根据字典Id集合,获取查询后的字典数据。 + * NOTE: 白名单接口。 + * + * @param dictCode 字典编码。 + * @param itemIds 字典项目Id集合。 + * @param itemIdType 字典项目的ItemId值转换到的目标类型。可能值为Integer或Long。 + * @return 应答结果对象,包含字典形式的数据集合。 + */ + @GetMapping("/listDictByIds") + public ResponseResult>> listDictByIds( + @RequestParam String dictCode, + @RequestParam List itemIds, + @RequestParam(required = false) String itemIdType) { + List resultList = + globalDictService.getGlobalDictItemListFromCache(dictCode, new HashSet<>(itemIds)); + return ResponseResult.success(globalDictOperationHelper.toDictDataList(resultList, itemIdType)); + } + + /** + * 白名单接口,登录用户均可访问。以字典形式返回全部字典数据集合。 + * fullResultList中的字典列表全部取自于数据库,而cachedResultList全部取自于缓存,前端负责比对。 + * + * @return 应答结果对象,包含字典形式的数据集合。 + */ + @GetMapping("/listAll") + public ResponseResult listAll(@RequestParam String dictCode) { + List fullResultList = + globalDictItemService.getGlobalDictItemListByDictCode(dictCode); + List cachedList = + globalDictService.getGlobalDictItemListFromCache(dictCode, null); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("fullResultList", globalDictOperationHelper.toDictDataList2(fullResultList)); + jsonObject.put("cachedResultList", globalDictOperationHelper.toDictDataList2(cachedList)); + return ResponseResult.success(jsonObject); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/LoginController.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/LoginController.java new file mode 100644 index 00000000..656c9a38 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/LoginController.java @@ -0,0 +1,475 @@ +package com.orangeforms.webadmin.upms.controller; + +import cn.dev33.satoken.annotation.SaIgnore; +import cn.dev33.satoken.session.SaSession; +import cn.dev33.satoken.stp.StpUtil; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.JSONArray; +import com.github.xiaoymin.knife4j.annotations.ApiSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import com.orangeforms.webadmin.config.ApplicationConfig; +import com.orangeforms.webadmin.upms.bo.SysMenuExtraData; +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.flow.online.service.FlowOnlineOperationService; +import com.orangeforms.common.online.service.OnlineOperationService; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.annotation.DisableDataFilter; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.*; +import com.orangeforms.common.core.upload.*; +import com.orangeforms.common.redis.cache.SessionCacheHelper; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.satoken.util.SaTokenUtil; +import org.redisson.api.RSet; +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 jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +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 2024-07-02 + */ +@ApiSupport(order = 1) +@Tag(name = "用户登录接口") +@DisableDataFilter +@Slf4j +@RestController +@RequestMapping("/admin/upms/login") +public class LoginController { + + @Autowired + private SysUserService sysUserService; + @Autowired + private SysDeptService sysDeptService; + @Autowired + private SysMenuService sysMenuService; + @Autowired + private SysPostService sysPostService; + @Autowired + private SysRoleService sysRoleService; + @Autowired + private SysDataPermService sysDataPermService; + @Autowired + private SysPermWhitelistService sysPermWhitelistService; + @Autowired + private OnlineOperationService onlineOperationService; + @Autowired + private FlowOnlineOperationService flowOnlineOperationService; + @Autowired + private ApplicationConfig appConfig; + @Autowired + private RedissonClient redissonClient; + @Autowired + private SessionCacheHelper cacheHelper; + @Autowired + private PasswordEncoder passwordEncoder; + @Autowired + private UpDownloaderFactory upDownloaderFactory; + @Autowired + private SaTokenUtil saTokenUtil; + + private static final String IS_ADMIN = "isAdmin"; + private static final String SHOW_NAME_FIELD = "showName"; + private static final String SHOW_ORDER_FIELD = "showOrder"; + private static final String HEAD_IMAGE_URL_FIELD = "headImageUrl"; + + /** + * 登录接口。 + * + * @param loginName 登录名。 + * @param password 密码。 + * @return 应答结果对象,其中包括Token数据,以及菜单列表。 + */ + @Parameter(name = "loginName", example = "admin") + @Parameter(name = "password", example = "IP3ccke3GhH45iGHB5qP9p7iZw6xUyj28Ju10rnBiPKOI35sc%2BjI7%2FdsjOkHWMfUwGYGfz8ik31HC2Ruk%2Fhkd9f6RPULTHj7VpFdNdde2P9M4mQQnFBAiPM7VT9iW3RyCtPlJexQ3nAiA09OqG%2F0sIf1kcyveSrulxembARDbDo%3D") + @SaIgnore + @OperationLog(type = SysOperationLogType.LOGIN, saveResponse = false) + @PostMapping("/doLogin") + public ResponseResult doLogin( + @MyRequestBody String loginName, + @MyRequestBody String password) throws UnsupportedEncodingException { + if (MyCommonUtil.existBlankArgument(loginName, password)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + ResponseResult verifyResult = this.verifyAndHandleLoginUser(loginName, password); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + JSONObject jsonData = this.buildLoginDataAndLogin(verifyResult.getData()); + return ResponseResult.success(jsonData); + } + + /** + * 登出操作。同时将Session相关的信息从缓存中删除。 + * + * @return 应答结果对象。 + */ + @OperationLog(type = SysOperationLogType.LOGOUT) + @PostMapping("/doLogout") + public ResponseResult doLogout() { + String sessionId = TokenData.takeFromRequest().getSessionId(); + redissonClient.getBucket(TokenData.takeFromRequest().getMySessionId()).deleteAsync(); + redissonClient.getBucket(RedisKeyUtil.makeSessionPermCodeKey(sessionId)).deleteAsync(); + redissonClient.getBucket(RedisKeyUtil.makeSessionPermIdKey(sessionId)).deleteAsync(); + sysDataPermService.removeDataPermCache(sessionId); + cacheHelper.removeAllSessionCache(sessionId); + StpUtil.logout(); + return ResponseResult.success(); + } + + /** + * 在登录之后,通过token再次获取登录信息。 + * 用于在当前浏览器登录系统后,在新tab页中可以免密登录。 + * + * @return 应答结果对象,其中包括JWT的Token数据,以及菜单列表。 + */ + @GetMapping("/getLoginInfo") + public ResponseResult getLoginInfo() { + TokenData tokenData = TokenData.takeFromRequest(); + JSONObject jsonData = new JSONObject(); + jsonData.put(SHOW_NAME_FIELD, tokenData.getShowName()); + jsonData.put(IS_ADMIN, tokenData.getIsAdmin()); + if (StrUtil.isNotBlank(tokenData.getHeadImageUrl())) { + jsonData.put(HEAD_IMAGE_URL_FIELD, tokenData.getHeadImageUrl()); + } + Collection allMenuList; + if (BooleanUtil.isTrue(tokenData.getIsAdmin())) { + allMenuList = sysMenuService.getAllListByOrder(SHOW_ORDER_FIELD); + } else { + allMenuList = sysMenuService.getMenuListByRoleIds(tokenData.getRoleIds()); + } + List menuCodeList = new LinkedList<>(); + OnlinePermData onlinePermData = this.getOnlineMenuPermData(allMenuList); + CollUtil.addAll(menuCodeList, onlinePermData.permCodeSet); + OnlinePermData onlineFlowPermData = this.getFlowOnlineMenuPermData(allMenuList); + CollUtil.addAll(menuCodeList, onlineFlowPermData.permCodeSet); + allMenuList.stream().filter(m -> m.getExtraData() != null) + .forEach(m -> m.setExtraObject(JSON.parseObject(m.getExtraData(), SysMenuExtraData.class))); + this.appendResponseMenuAndPermCodeData(jsonData, allMenuList, menuCodeList); + return ResponseResult.success(jsonData); + } + + /** + * 返回所有可用的权限字列表。 + * + * @return 整个系统所有可用的权限字列表。 + */ + @GetMapping("/getAllPermCodes") + public ResponseResult> getAllPermCodes() { + List permCodes = saTokenUtil.getAllPermCodes(); + return ResponseResult.success(permCodes); + } + + /** + * 用户修改自己的密码。 + * + * @param oldPass 原有密码。 + * @param newPass 新密码。 + * @return 应答结果对象。 + */ + @PostMapping("/changePassword") + public ResponseResult changePassword( + @MyRequestBody String oldPass, @MyRequestBody String newPass) throws UnsupportedEncodingException { + 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 IOException { + UploadStoreInfo storeInfo = MyModelUtil.getUploadStoreInfo(SysUser.class, HEAD_IMAGE_URL_FIELD); + BaseUpDownloader upDownloader = upDownloaderFactory.get(storeInfo.getStoreType()); + UploadResponseInfo responseInfo = upDownloader.doUpload(null, + appConfig.getUploadFileBaseDir(), SysUser.class.getSimpleName(), HEAD_IMAGE_URL_FIELD, true, uploadFile); + if (BooleanUtil.isTrue(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 { + UploadStoreInfo storeInfo = MyModelUtil.getUploadStoreInfo(SysUser.class, HEAD_IMAGE_URL_FIELD); + BaseUpDownloader upDownloader = upDownloaderFactory.get(storeInfo.getStoreType()); + upDownloader.doDownload(appConfig.getUploadFileBaseDir(), + SysUser.class.getSimpleName(), HEAD_IMAGE_URL_FIELD, filename, true, response); + } catch (Exception e) { + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + log.error(e.getMessage(), e); + } + } + + private ResponseResult verifyAndHandleLoginUser( + String loginName, String password) throws UnsupportedEncodingException { + String 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); + } + if (BooleanUtil.isTrue(appConfig.getExcludeLogin())) { + String deviceType = MyCommonUtil.getDeviceTypeWithString(); + LoginUserInfo userInfo = BeanUtil.copyProperties(user, LoginUserInfo.class); + String loginId = SaTokenUtil.makeLoginId(userInfo); + StpUtil.kickout(loginId, deviceType); + } + return ResponseResult.success(user); + } + + private JSONObject buildLoginDataAndLogin(SysUser user) { + TokenData tokenData = this.loginAndCreateToken(user); + // 这里手动将TokenData存入request,便于OperationLogAspect统一处理操作日志。 + TokenData.addToRequest(tokenData); + JSONObject jsonData = this.createResponseData(user); + Collection allMenuList; + boolean isAdmin = user.getUserType() == SysUserType.TYPE_ADMIN; + if (isAdmin) { + allMenuList = sysMenuService.getAllListByOrder(SHOW_ORDER_FIELD); + } else { + allMenuList = sysMenuService.getMenuListByRoleIds(tokenData.getRoleIds()); + } + allMenuList.stream().filter(m -> m.getExtraData() != null) + .forEach(m -> m.setExtraObject(JSON.parseObject(m.getExtraData(), SysMenuExtraData.class))); + Collection permCodeList = new LinkedList<>(); + allMenuList.stream().filter(m -> m.getExtraObject() != null) + .forEach(m -> CollUtil.addAll(permCodeList, m.getExtraObject().getPermCodeList())); + Set permSet = new HashSet<>(); + if (!isAdmin) { + // 所有登录用户都有白名单接口的访问权限。 + CollUtil.addAll(permSet, sysPermWhitelistService.getWhitelistPermList()); + } + List menuCodeList = new LinkedList<>(); + OnlinePermData onlinePermData = this.getOnlineMenuPermData(allMenuList); + CollUtil.addAll(menuCodeList, onlinePermData.permCodeSet); + OnlinePermData onlineFlowPermData = this.getFlowOnlineMenuPermData(allMenuList); + CollUtil.addAll(menuCodeList, onlineFlowPermData.permCodeSet); + if (!isAdmin) { + permSet.addAll(onlinePermData.permUrlSet); + permSet.addAll(onlineFlowPermData.permUrlSet); + String sessionId = tokenData.getSessionId(); + // 缓存用户的权限资源,这里缓存的是基于URL验证的权限资源,比如在线表单、工作流和数据表中的白名单资源。 + this.putUserSysPermCache(sessionId, permSet); + // 缓存权限字字段,StpInterfaceImpl中会从缓存中读取,并交给satoken进行接口权限的验证。 + this.putUserSysPermCodeCache(sessionId, permCodeList); + sysDataPermService.putDataPermCache(sessionId, user.getUserId(), user.getDeptId()); + } + this.appendResponseMenuAndPermCodeData(jsonData, allMenuList, menuCodeList); + return jsonData; + } + + private TokenData loginAndCreateToken(SysUser user) { + String deviceType = MyCommonUtil.getDeviceTypeWithString(); + LoginUserInfo userInfo = BeanUtil.copyProperties(user, LoginUserInfo.class); + String loginId = SaTokenUtil.makeLoginId(userInfo); + StpUtil.login(loginId, deviceType); + SaSession session = StpUtil.getTokenSession(); + TokenData tokenData = this.buildTokenData(user, session.getId(), StpUtil.getLoginDevice()); + String mySessionId = RedisKeyUtil.getSessionIdPrefix(tokenData, user.getLoginName()) + MyCommonUtil.generateUuid(); + tokenData.setMySessionId(mySessionId); + tokenData.setToken(session.getToken()); + redissonClient.getBucket(mySessionId) + .set(JSON.toJSONString(tokenData), appConfig.getSessionExpiredSeconds(), TimeUnit.SECONDS); + session.set(TokenData.REQUEST_ATTRIBUTE_NAME, tokenData); + return tokenData; + } + + private JSONObject createResponseData(SysUser user) { + JSONObject jsonData = new JSONObject(); + jsonData.put(TokenData.REQUEST_ATTRIBUTE_NAME, StpUtil.getTokenValue()); + jsonData.put(SHOW_NAME_FIELD, user.getShowName()); + jsonData.put(IS_ADMIN, user.getUserType() == SysUserType.TYPE_ADMIN); + if (user.getDeptId() != null) { + SysDept dept = sysDeptService.getById(user.getDeptId()); + jsonData.put("deptName", dept.getDeptName()); + } + if (StrUtil.isNotBlank(user.getHeadImageUrl())) { + jsonData.put(HEAD_IMAGE_URL_FIELD, user.getHeadImageUrl()); + } + return jsonData; + } + + private void appendResponseMenuAndPermCodeData( + JSONObject responseData, Collection allMenuList, Collection menuCodeList) { + allMenuList.stream() + .filter(m -> m.getExtraObject() != null && StrUtil.isNotBlank(m.getExtraObject().getMenuCode())) + .forEach(m -> CollUtil.addAll(menuCodeList, m.getExtraObject().getMenuCode())); + List menuList = allMenuList.stream() + .filter(m -> m.getMenuType() <= SysMenuType.TYPE_MENU).collect(Collectors.toList()); + responseData.put("menuList", menuList); + responseData.put("permCodeList", menuCodeList); + } + + private TokenData buildTokenData(SysUser user, String sessionId, String deviceType) { + 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(user.getUserType().equals(SysUserType.TYPE_ADMIN)); + tokenData.setLoginIp(IpUtil.getRemoteIpAddress(ContextUtil.getHttpRequest())); + tokenData.setLoginTime(new Date()); + tokenData.setDeviceType(deviceType); + tokenData.setHeadImageUrl(user.getHeadImageUrl()); + List userPostList = sysPostService.getSysUserPostListByUserId(user.getUserId()); + if (CollUtil.isNotEmpty(userPostList)) { + Set deptPostIdSet = userPostList.stream().map(SysUserPost::getDeptPostId).collect(Collectors.toSet()); + tokenData.setDeptPostIds(StrUtil.join(",", deptPostIdSet)); + Set postIdSet = userPostList.stream().map(SysUserPost::getPostId).collect(Collectors.toSet()); + tokenData.setPostIds(StrUtil.join(",", postIdSet)); + } + List userRoleList = sysRoleService.getSysUserRoleListByUserId(user.getUserId()); + if (CollUtil.isNotEmpty(userRoleList)) { + Set userRoleIdSet = userRoleList.stream().map(SysUserRole::getRoleId).collect(Collectors.toSet()); + tokenData.setRoleIds(StrUtil.join(",", userRoleIdSet)); + } + return tokenData; + } + + private void putUserSysPermCache(String sessionId, Collection permUrlSet) { + if (CollUtil.isEmpty(permUrlSet)) { + return; + } + String sessionPermKey = RedisKeyUtil.makeSessionPermIdKey(sessionId); + RSet redisPermSet = redissonClient.getSet(sessionPermKey); + redisPermSet.addAll(permUrlSet); + redisPermSet.expire(appConfig.getSessionExpiredSeconds(), TimeUnit.SECONDS); + } + + private void putUserSysPermCodeCache(String sessionId, Collection permCodeSet) { + if (CollUtil.isEmpty(permCodeSet)) { + return; + } + String sessionPermCodeKey = RedisKeyUtil.makeSessionPermCodeKey(sessionId); + RSet redisPermSet = redissonClient.getSet(sessionPermCodeKey); + redisPermSet.addAll(permCodeSet); + redisPermSet.expire(appConfig.getSessionExpiredSeconds(), TimeUnit.SECONDS); + } + + private OnlinePermData getOnlineMenuPermData(Collection allMenuList) { + List onlineMenuList = allMenuList.stream() + .filter(m -> m.getOnlineFormId() != null && m.getMenuType().equals(SysMenuType.TYPE_BUTTON)) + .collect(Collectors.toList()); + if (CollUtil.isEmpty(onlineMenuList)) { + return new OnlinePermData(); + } + Set formIds = allMenuList.stream() + .filter(m -> m.getOnlineFormId() != null + && m.getOnlineFlowEntryId() == null + && m.getMenuType().equals(SysMenuType.TYPE_MENU)) + .map(SysMenu::getOnlineFormId) + .collect(Collectors.toSet()); + Set viewFormIds = onlineMenuList.stream() + .filter(m -> m.getOnlineMenuPermType() == SysOnlineMenuPermType.TYPE_VIEW) + .map(SysMenu::getOnlineFormId) + .collect(Collectors.toSet()); + Set editFormIds = onlineMenuList.stream() + .filter(m -> m.getOnlineMenuPermType() == SysOnlineMenuPermType.TYPE_EDIT) + .map(SysMenu::getOnlineFormId) + .collect(Collectors.toSet()); + Map permDataMap = + onlineOperationService.calculatePermData(formIds, viewFormIds, editFormIds); + OnlinePermData permData = BeanUtil.mapToBean(permDataMap, OnlinePermData.class, false, null); + permData.permUrlSet.addAll(permData.onlineWhitelistUrls); + return permData; + } + + private OnlinePermData getFlowOnlineMenuPermData(Collection allMenuList) { + List flowOnlineMenuList = allMenuList.stream() + .filter(m -> m.getOnlineFlowEntryId() != null).collect(Collectors.toList()); + Set entryIds = flowOnlineMenuList.stream() + .map(SysMenu::getOnlineFlowEntryId).collect(Collectors.toSet()); + List> flowPermDataList = flowOnlineOperationService.calculatePermData(entryIds); + List flowOnlinePermDataList = + MyModelUtil.mapToBeanList(flowPermDataList, OnlineFlowPermData.class); + OnlinePermData permData = new OnlinePermData(); + flowOnlinePermDataList.forEach(perm -> { + permData.permCodeSet.addAll(perm.getPermCodeList()); + permData.permUrlSet.addAll(perm.getPermList()); + }); + return permData; + } + + static class OnlinePermData { + public final Set permCodeSet = new HashSet<>(); + public final Set permUrlSet = new HashSet<>(); + public final List onlineWhitelistUrls = new LinkedList<>(); + } + + @Data + static class OnlineFlowPermData { + private List permCodeList; + private List permList; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/LoginUserController.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/LoginUserController.java new file mode 100644 index 00000000..6e57c15d --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/LoginUserController.java @@ -0,0 +1,89 @@ +package com.orangeforms.webadmin.upms.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.dev33.satoken.stp.StpUtil; +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.v3.oas.annotations.tags.Tag; +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 2024-07-02 + */ +@Tag(name = "在线用户接口") +@Slf4j +@RestController +@RequestMapping("/admin/upms/loginUser") +public class LoginUserController { + + @Autowired + private RedissonClient redissonClient; + + /** + * 显示在线用户列表。 + * + * @param loginName 登录名过滤。 + * @param pageParam 分页参数。 + * @return 登录用户信息列表。 + */ + @SaCheckPermission("loginUser.view") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody String loginName, @MyRequestBody MyPageParam pageParam) { + int skipCount = (pageParam.getPageNum() - 1) * pageParam.getPageSize(); + String patternKey; + if (StrUtil.isBlank(loginName)) { + patternKey = RedisKeyUtil.getSessionIdPrefix() + "*"; + } else { + patternKey = RedisKeyUtil.getSessionIdPrefix(loginName) + "*"; + } + List loginUserInfoList = new LinkedList<>(); + Iterable 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 resultList = loginUserInfoList.subList(skipCount, toIndex); + return ResponseResult.success(new MyPageData<>(resultList, (long) loginUserInfoList.size())); + } + + /** + * 强制下线指定登录会话。 + * + * @param sessionId 待强制下线的SessionId。 + * @return 应答结果对象。 + */ + @SaCheckPermission("loginUser.delete") + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody String sessionId) { + RBucket sessionData = redissonClient.getBucket(sessionId); + TokenData tokenData = JSON.parseObject(sessionData.get(), TokenData.class); + StpUtil.kickoutByTokenValue(tokenData.getToken()); + sessionData.delete(); + return ResponseResult.success(); + } + + private LoginUserInfo buildTokenDataByRedisKey(String key) { + RBucket sessionData = redissonClient.getBucket(key); + TokenData tokenData = JSON.parseObject(sessionData.get(), TokenData.class); + LoginUserInfo userInfo = BeanUtil.copyProperties(tokenData, LoginUserInfo.class); + userInfo.setSessionId(tokenData.getMySessionId()); + return userInfo; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysDataPermController.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysDataPermController.java new file mode 100644 index 00000000..e389b0e7 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysDataPermController.java @@ -0,0 +1,337 @@ +package com.orangeforms.webadmin.upms.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import com.alibaba.fastjson.TypeReference; +import com.github.pagehelper.Page; +import com.github.pagehelper.page.PageMethod; +import lombok.extern.slf4j.Slf4j; +import com.orangeforms.webadmin.upms.dto.SysDataPermDto; +import com.orangeforms.webadmin.upms.dto.SysUserDto; +import com.orangeforms.webadmin.upms.vo.SysDataPermVo; +import com.orangeforms.webadmin.upms.vo.SysUserVo; +import com.orangeforms.webadmin.upms.model.SysDataPerm; +import com.orangeforms.webadmin.upms.model.SysUser; +import com.orangeforms.webadmin.upms.service.SysDataPermService; +import com.orangeforms.webadmin.upms.service.SysUserService; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.*; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 数据权限接口控制器对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "数据权限管理接口") +@Slf4j +@RestController +@RequestMapping("/admin/upms/sysDataPerm") +public class SysDataPermController { + + @Autowired + private SysDataPermService sysDataPermService; + @Autowired + private SysUserService sysUserService; + + /** + * 添加新数据权限操作。 + * + * @param sysDataPermDto 新增对象。 + * @param deptIdListString 数据权限关联的部门Id列表,多个之间逗号分隔。 + * @param menuIdListString 数据权限关联的菜单Id列表,多个之间逗号分隔。 + * @return 应答结果对象。包含新增数据权限对象的主键Id。 + */ + @ApiOperationSupport(ignoreParameters = { + "sysDataPermDto.dataPermId", + "sysDataPermDto.createTimeStart", + "sysDataPermDto.createTimeEnd", + "sysDataPermDto.searchString"}) + @SaCheckPermission("sysDataPerm.add") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add( + @MyRequestBody SysDataPermDto sysDataPermDto, + @MyRequestBody String deptIdListString, + @MyRequestBody String menuIdListString) { + 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, menuIdListString); + if (!result.isSuccess()) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage()); + } + Set menuIdSet = null; + if (result.getData() != null) { + menuIdSet = result.getData().getObject("menuIdSet", new TypeReference>(){}); + } + Set deptIdSet = null; + if (result.getData() != null) { + deptIdSet = result.getData().getObject("deptIdSet", new TypeReference>(){}); + } + sysDataPermService.saveNew(sysDataPerm, deptIdSet, menuIdSet); + return ResponseResult.success(sysDataPerm.getDataPermId()); + } + + /** + * 更新数据权限操作。 + * + * @param sysDataPermDto 更新的数据权限对象。 + * @param deptIdListString 数据权限关联的部门Id列表,多个之间逗号分隔。 + * @param menuIdListString 数据权限关联的菜单Id列表,多个之间逗号分隔。 + * @return 应答结果对象。 + */ + @ApiOperationSupport(ignoreParameters = { + "sysDataPermDto.createTimeStart", + "sysDataPermDto.createTimeEnd", + "sysDataPermDto.searchString"}) + @SaCheckPermission("sysDataPerm.update") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update( + @MyRequestBody SysDataPermDto sysDataPermDto, + @MyRequestBody String deptIdListString, + @MyRequestBody String menuIdListString) { + 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, menuIdListString); + if (!result.isSuccess()) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage()); + } + Set deptIdSet = null; + if (result.getData() != null) { + deptIdSet = result.getData().getObject("deptIdSet", new TypeReference>(){}); + } + Set menuIdSet = null; + if (result.getData() != null) { + menuIdSet = result.getData().getObject("menuIdSet", new TypeReference>(){}); + } + if (!sysDataPermService.update(sysDataPerm, originalSysDataPerm, deptIdSet, menuIdSet)) { + errorMessage = "更新失败,数据不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 删除数据权限操作。 + * + * @param dataPermId 待删除数据权限主键Id。 + * @return 应答数据结果。 + */ + @SaCheckPermission("sysDataPerm.delete") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult 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 应答结果对象。包含数据权限列表。 + */ + @SaCheckPermission("sysDataPerm.view") + @PostMapping("/list") + public ResponseResult> 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 dataPermList = sysDataPermService.getSysDataPermListWithRelation(filter, orderBy); + List dataPermVoList = MyModelUtil.copyCollectionTo(dataPermList, SysDataPermVo.class); + long totalCount = 0L; + if (dataPermList instanceof Page) { + totalCount = ((Page) dataPermList).getTotal(); + } + return ResponseResult.success(MyPageUtil.makeResponseData(dataPermVoList, totalCount)); + } + + /** + * 查看单条数据权限详情。 + * + * @param dataPermId 数据权限的主键Id。 + * @return 应答结果对象,包含数据权限的详情。 + */ + @SaCheckPermission("sysDataPerm.view") + @GetMapping("/view") + public ResponseResult 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); + } + + /** + * 拥有指定数据权限的用户列表。 + * + * @param dataPermId 数据权限Id。 + * @param sysUserDtoFilter 用户过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含用户列表数据。 + */ + @SaCheckPermission("sysDataPerm.view") + @PostMapping("/listDataPermUser") + public ResponseResult> listDataPermUser( + @MyRequestBody Long dataPermId, + @MyRequestBody SysUserDto sysUserDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + ResponseResult 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 userList = sysUserService.getSysUserListByDataPermId(dataPermId, filter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(userList, SysUserVo.class)); + } + + /** + * 获取不包含指定数据权限Id的用户列表。 + * 用户和数据权限是多对多关系,当前接口将返回没有赋值指定DataPermId的用户列表。可用于给数据权限添加新用户。 + * + * @param dataPermId 数据权限主键Id。 + * @param sysUserDtoFilter 用户数据的过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含用户列表数据。 + */ + @SaCheckPermission("sysDataPerm.update") + @PostMapping("/listNotInDataPermUser") + public ResponseResult> listNotInDataPermUser( + @MyRequestBody Long dataPermId, + @MyRequestBody SysUserDto sysUserDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + ResponseResult 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 userList = + sysUserService.getNotInSysUserListByDataPermId(dataPermId, filter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(userList, SysUserVo.class)); + } + + /** + * 为指定数据权限添加用户列表。该操作可同时给一批用户赋值数据权限,并在同一事务内完成。 + * + * @param dataPermId 数据权限主键Id。 + * @param userIdListString 逗号分隔的用户Id列表。 + * @return 应答结果对象。 + */ + @SaCheckPermission("sysDataPerm.update") + @OperationLog(type = SysOperationLogType.ADD_M2M) + @PostMapping("/addDataPermUser") + public ResponseResult addDataPermUser( + @MyRequestBody Long dataPermId, @MyRequestBody String userIdListString) { + if (MyCommonUtil.existBlankArgument(dataPermId, userIdListString)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + Set 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 应答数据结果。 + */ + @SaCheckPermission("sysDataPerm.update") + @OperationLog(type = SysOperationLogType.DELETE_M2M) + @PostMapping("/deleteDataPermUser") + public ResponseResult 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(); + } + + /** + * 以字典形式返回全部数据权限管理数据集合。字典的键值为[dataPermId, dataPermName]。 + * 白名单接口,登录用户均可访问。 + * + * @param filter 过滤对象。 + * @return 应答结果对象,包含的数据为 List>,map中包含两条记录,key的值分别是id和name,value对应具体数据。 + */ + @GetMapping("/listDict") + public ResponseResult>> listDict(@ParameterObject SysDataPermDto filter) { + List resultList = + sysDataPermService.getListByFilter(MyModelUtil.copyTo(filter, SysDataPerm.class)); + return ResponseResult.success( + MyCommonUtil.toDictDataList(resultList, SysDataPerm::getDataPermId, SysDataPerm::getDataPermName)); + } + + private ResponseResult 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(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysDeptController.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysDeptController.java new file mode 100644 index 00000000..3c1fb0f8 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysDeptController.java @@ -0,0 +1,428 @@ +package com.orangeforms.webadmin.upms.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.hutool.core.util.StrUtil; +import cn.hutool.core.util.ObjectUtil; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.webadmin.upms.vo.*; +import com.orangeforms.webadmin.upms.dto.*; +import com.orangeforms.webadmin.upms.model.*; +import com.orangeforms.webadmin.upms.service.*; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.*; +import com.orangeforms.common.core.constant.*; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.slf4j.Slf4j; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 部门管理操作控制器类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "部门管理管理接口") +@Slf4j +@RestController +@RequestMapping("/admin/upms/sysDept") +public class SysDeptController { + + @Autowired + private SysPostService sysPostService; + @Autowired + private SysDeptService sysDeptService; + + /** + * 新增部门管理数据。 + * + * @param sysDeptDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"sysDeptDto.deptId"}) + @SaCheckPermission("sysDept.add") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult 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 应答结果对象。 + */ + @SaCheckPermission("sysDept.update") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult 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()) + && ObjectUtil.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 应答结果对象。 + */ + @SaCheckPermission("sysDept.delete") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long deptId) { + if (MyCommonUtil.existBlankArgument(deptId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + return this.doDelete(deptId); + } + + /** + * 批量删除部门管理数据。 + * + * @param deptIdList 待删除对象的主键Id列表。 + * @return 应答结果对象。 + */ + @SaCheckPermission("sysDept.delete") + @OperationLog(type = SysOperationLogType.DELETE_BATCH) + @PostMapping("/deleteBatch") + public ResponseResult deleteBatch(@MyRequestBody List deptIdList) { + if (MyCommonUtil.existBlankArgument(deptIdList)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + for (Long deptId : deptIdList) { + ResponseResult responseResult = this.doDelete(deptId); + if (!responseResult.isSuccess()) { + return responseResult; + } + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的部门管理列表。 + * + * @param sysDeptDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("sysDept.view") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody SysDeptDto sysDeptDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount()); + } + SysDept sysDeptFilter = MyModelUtil.copyTo(sysDeptDtoFilter, SysDept.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, SysDept.class); + List sysDeptList = sysDeptService.getSysDeptListWithRelation(sysDeptFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(sysDeptList, SysDeptVo.class)); + } + + /** + * 查看指定部门管理对象详情。 + * + * @param deptId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("sysDept.view") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long deptId) { + SysDept sysDept = sysDeptService.getByIdWithRelation(deptId, MyRelationParam.full()); + if (sysDept == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + SysDeptVo sysDeptVo = MyModelUtil.copyTo(sysDept, SysDeptVo.class); + return ResponseResult.success(sysDeptVo); + } + + /** + * 列出不与指定部门管理存在多对多关系的 [岗位管理] 列表数据。通常用于查看添加新 [岗位管理] 对象的候选列表。 + * + * @param deptId 主表关联字段。 + * @param sysPostDtoFilter [岗位管理] 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,返回符合条件的数据列表。 + */ + @SaCheckPermission("sysDept.update") + @PostMapping("/listNotInSysDeptPost") + public ResponseResult> 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 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, SysPostVo.class)); + } + + /** + * 列出与指定部门管理存在多对多关系的 [岗位管理] 列表数据。 + * + * @param deptId 主表关联字段。 + * @param sysPostDtoFilter [岗位管理] 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,返回符合条件的数据列表。 + */ + @SaCheckPermission("sysDept.view") + @PostMapping("/listSysDeptPost") + public ResponseResult> 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 sysPostList = sysPostService.getSysPostListByDeptId(deptId, filter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(sysPostList, SysPostVo.class)); + } + + /** + * 批量添加部门管理和 [岗位管理] 对象的多对多关联关系数据。 + * + * @param deptId 主表主键Id。 + * @param sysDeptPostDtoList 关联对象列表。 + * @return 应答结果对象。 + */ + @SaCheckPermission("sysDept.update") + @PostMapping("/addSysDeptPost") + public ResponseResult addSysDeptPost( + @MyRequestBody Long deptId, + @MyRequestBody List 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 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 sysDeptPostList = MyModelUtil.copyCollectionTo(sysDeptPostDtoList, SysDeptPost.class); + sysDeptService.addSysDeptPostList(sysDeptPostList, deptId); + return ResponseResult.success(); + } + + /** + * 更新指定部门管理和指定 [岗位管理] 的多对多关联数据。 + * + * @param sysDeptPostDto 对多对中间表对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("sysDept.update") + @PostMapping("/updateSysDeptPost") + public ResponseResult 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 应答结果对象,包括中间表详情。 + */ + @SaCheckPermission("sysDept.update") + @GetMapping("/viewSysDeptPost") + public ResponseResult viewSysDeptPost(@RequestParam Long deptId, @RequestParam Long postId) { + 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 应答结果对象。 + */ + @SaCheckPermission("sysDept.update") + @PostMapping("/deleteSysDeptPost") + public ResponseResult 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>> listSysDeptPostWithRelation( + @RequestParam(required = false) Long deptId) { + return ResponseResult.success(sysDeptService.getSysDeptPostListWithRelationByDeptId(deptId)); + } + + /** + * 以字典形式返回全部部门管理数据集合。字典的键值为[deptId, deptName]。 + * 白名单接口,登录用户均可访问。 + * + * @param filter 过滤对象。 + * @return 应答结果对象,包含的数据为 List>,map中包含两条记录,key的值分别是id和name,value对应具体数据。 + */ + @GetMapping("/listDict") + public ResponseResult>> listDict(@ParameterObject SysDeptDto filter) { + List resultList = + sysDeptService.getListByFilter(MyModelUtil.copyTo(filter, SysDept.class)); + return ResponseResult.success(MyCommonUtil.toDictDataList( + resultList, SysDept::getDeptId, SysDept::getDeptName, SysDept::getParentId)); + } + + /** + * 根据字典Id集合,获取查询后的字典数据。 + * + * @param dictIds 字典Id集合。 + * @return 应答结果对象,包含字典形式的数据集合。 + */ + @GetMapping("/listDictByIds") + public ResponseResult>> listDictByIds(@RequestParam List dictIds) { + List resultList = sysDeptService.getInList(new HashSet<>(dictIds)); + return ResponseResult.success(MyCommonUtil.toDictDataList( + resultList, SysDept::getDeptId, SysDept::getDeptName, SysDept::getParentId)); + } + + /** + * 根据父主键Id,以字典的形式返回其下级数据列表。 + * 白名单接口,登录用户均可访问。 + * + * @param parentId 父主键Id。 + * @return 按照字典的形式返回下级数据列表。 + */ + @GetMapping("/listDictByParentId") + public ResponseResult>> listDictByParentId(@RequestParam(required = false) Long parentId) { + List resultList = sysDeptService.getListByParentId("parentId", parentId); + return ResponseResult.success(MyCommonUtil.toDictDataList( + resultList, SysDept::getDeptId, SysDept::getDeptName, SysDept::getParentId)); + } + + /** + * 根据父主键Id列表,获取当前部门Id及其所有下级部门Id列表。 + * 白名单接口,登录用户均可访问。 + * + * @param parentIds 父主键Id列表,多个Id之间逗号分隔。 + * @return 获取当前部门Id及其所有下级部门Id列表。 + */ + @GetMapping("/listAllChildDeptIdByParentIds") + public ResponseResult> listAllChildDeptIdByParentIds( + @RequestParam(required = false) String parentIds) { + List parentIdList = StrUtil.split(parentIds, ',') + .stream().map(Long::valueOf).collect(Collectors.toList()); + return ResponseResult.success(sysDeptService.getAllChildDeptIdByParentIds(parentIdList)); + } + + private ResponseResult 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(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysMenuController.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysMenuController.java new file mode 100644 index 00000000..0ea5f339 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysMenuController.java @@ -0,0 +1,231 @@ +package com.orangeforms.webadmin.upms.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +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.SysDataPerm; +import com.orangeforms.webadmin.upms.model.constant.SysMenuType; +import com.orangeforms.webadmin.upms.service.SysMenuService; +import com.orangeforms.webadmin.upms.service.SysDataPermService; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.*; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 菜单管理接口控制器类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "菜单管理接口") +@Slf4j +@RestController +@RequestMapping("/admin/upms/sysMenu") +public class SysMenuController { + + @Autowired + private SysMenuService sysMenuService; + @Autowired + private SysDataPermService sysDataPermService; + + /** + * 添加新菜单操作。 + * + * @param sysMenuDto 新菜单对象。 + * @return 应答结果对象,包含新增菜单的主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"sysMenuDto.menuId"}) + @SaCheckPermission("sysMenu.add") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody SysMenuDto sysMenuDto) { + 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); + if (!result.isSuccess()) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage()); + } + sysMenuService.saveNew(sysMenu); + return ResponseResult.success(sysMenu.getMenuId()); + } + + /** + * 更新菜单数据操作。 + * + * @param sysMenuDto 新菜单对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("sysMenu.update") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody SysMenuDto sysMenuDto) { + 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); + if (!result.isSuccess()) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage()); + } + if (!sysMenuService.update(sysMenu, originalSysMenu)) { + errorMessage = "数据验证失败,当前权限字并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 删除指定菜单操作。 + * + * @param menuId 指定菜单主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("sysMenu.delete") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult 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); + } + List dataPermList = sysDataPermService.getSysDataPermListByMenuId(menuId); + if (CollUtil.isNotEmpty(dataPermList)) { + SysDataPerm dataPerm = dataPermList.get(0); + errorMessage = "数据验证失败,当前菜单正在被数据权限 [" + dataPerm.getDataPermName() + "] 引用,不能直接删除!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!sysMenuService.remove(menu)) { + errorMessage = "数据操作失败,菜单不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 获取全部菜单列表。 + * + * @return 应答结果对象,包含全部菜单数据列表。 + */ + @SaCheckPermission("sysMenu.view") + @PostMapping("/list") + public ResponseResult> list() { + List resultList = this.getAllMenuListByShowOrder(); + return ResponseResult.success(MyModelUtil.copyCollectionTo(resultList, SysMenuVo.class)); + } + + /** + * 查看指定菜单数据详情。 + * + * @param menuId 指定菜单主键Id。 + * @return 应答结果对象,包含菜单详情。 + */ + @SaCheckPermission("sysMenu.view") + @GetMapping("/view") + public ResponseResult 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); + } + + /** + * 以字典形式返回目录和菜单类型的菜单管理数据集合。字典的键值为[menuId, menuName]。 + * 白名单接口,登录用户均可访问。 + * + * @return 应答结果对象,包含的数据为 List>,map中包含两条记录,key的值分别是id和name,value对应具体数据。 + */ + @GetMapping("/listMenuDict") + public ResponseResult>> listMenuDict() { + List resultList = this.getAllMenuListByShowOrder(); + resultList = resultList.stream() + .filter(m -> m.getMenuType() <= SysMenuType.TYPE_MENU).collect(Collectors.toList()); + return ResponseResult.success( + MyCommonUtil.toDictDataList(resultList, SysMenu::getMenuId, SysMenu::getMenuName, SysMenu::getParentId)); + } + + /** + * 以字典形式返回全部的菜单管理数据集合。字典的键值为[menuId, menuName]。 + * 白名单接口,登录用户均可访问。 + * + * @return 应答结果对象,包含的数据为 List>,map中包含两条记录,key的值分别是id和name,value对应具体数据。 + */ + @GetMapping("/listDict") + public ResponseResult>> listDict() { + List resultList = this.getAllMenuListByShowOrder(); + return ResponseResult.success( + MyCommonUtil.toDictDataList(resultList, SysMenu::getMenuId, SysMenu::getMenuName, SysMenu::getParentId)); + } + + private List getAllMenuListByShowOrder() { + return sysMenuService.getAllListByOrder("showOrder"); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysOperationLogController.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysOperationLogController.java new file mode 100644 index 00000000..d7ec940f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysOperationLogController.java @@ -0,0 +1,63 @@ +package com.orangeforms.webadmin.upms.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.pagehelper.Page; +import com.github.pagehelper.page.PageMethod; +import io.swagger.v3.oas.annotations.tags.Tag; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.log.model.SysOperationLog; +import com.orangeforms.common.log.service.SysOperationLogService; +import com.orangeforms.common.log.dto.SysOperationLogDto; +import com.orangeforms.common.log.vo.SysOperationLogVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 操作日志接口控制器对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "操作日志接口") +@Slf4j +@RestController +@RequestMapping("/admin/upms/sysOperationLog") +public class SysOperationLogController { + + @Autowired + private SysOperationLogService operationLogService; + + /** + * 数据权限列表。 + * + * @param sysOperationLogDtoFilter 操作日志查询过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象。包含操作日志列表。 + */ + @SaCheckPermission("sysOperationLog.view") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody SysOperationLogDto sysOperationLogDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + SysOperationLog filter = MyModelUtil.copyTo(sysOperationLogDtoFilter, SysOperationLog.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, SysOperationLog.class); + List operationLogList = operationLogService.getSysOperationLogList(filter, orderBy); + List operationLogVoList = MyModelUtil.copyCollectionTo(operationLogList, SysOperationLogVo.class); + long totalCount = 0L; + if (operationLogList instanceof Page) { + totalCount = ((Page) operationLogList).getTotal(); + } + return ResponseResult.success(MyPageUtil.makeResponseData(operationLogVoList, totalCount)); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysPostController.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysPostController.java new file mode 100644 index 00000000..9f4dcec4 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysPostController.java @@ -0,0 +1,183 @@ +package com.orangeforms.webadmin.upms.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +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 com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import lombok.extern.slf4j.Slf4j; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.*; +import jakarta.validation.groups.Default; + +/** + * 岗位管理操作控制器类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "岗位管理操作管理接口") +@Slf4j +@RestController +@RequestMapping("/admin/upms/sysPost") +public class SysPostController { + + @Autowired + private SysPostService sysPostService; + + /** + * 新增岗位管理数据。 + * + * @param sysPostDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"sysPostDto.postId"}) + @SaCheckPermission("sysPost.add") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult 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 应答结果对象。 + */ + @SaCheckPermission("sysPost.update") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult 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 应答结果对象。 + */ + @SaCheckPermission("sysPost.delete") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult 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 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("sysPost.view") + @PostMapping("/list") + public ResponseResult> 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 sysPostList = sysPostService.getSysPostListWithRelation(sysPostFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(sysPostList, SysPostVo.class)); + } + + /** + * 查看指定岗位管理对象详情。 + * + * @param postId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("sysPost.view") + @GetMapping("/view") + public ResponseResult 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 = MyModelUtil.copyTo(sysPost, SysPostVo.class); + return ResponseResult.success(sysPostVo); + } + + /** + * 以字典形式返回全部岗位管理数据集合。字典的键值为[postId, postName]。 + * 白名单接口,登录用户均可访问。 + * + * @param filter 过滤对象。 + * @return 应答结果对象,包含的数据为 List>,map中包含两条记录,key的值分别是id和name,value对应具体数据。 + */ + @GetMapping("/listDict") + public ResponseResult>> listDict(@ParameterObject SysPostDto filter) { + List resultList = sysPostService.getListByFilter(MyModelUtil.copyTo(filter, SysPost.class)); + return ResponseResult.success(MyCommonUtil.toDictDataList(resultList, SysPost::getPostId, SysPost::getPostName)); + } + + /** + * 根据字典Id集合,获取查询后的字典数据。 + * + * @param postIds 字典Id集合。 + * @return 应答结果对象,包含字典形式的数据集合。 + */ + @GetMapping("/listDictByIds") + public ResponseResult>> listDictByIds(@RequestParam List postIds) { + List resultList = sysPostService.getInList(new HashSet<>(postIds)); + return ResponseResult.success(MyCommonUtil.toDictDataList(resultList, SysPost::getPostId, SysPost::getPostName)); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysRoleController.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysRoleController.java new file mode 100644 index 00000000..25e5c51f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysRoleController.java @@ -0,0 +1,331 @@ +package com.orangeforms.webadmin.upms.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import com.alibaba.fastjson.TypeReference; +import com.github.pagehelper.Page; +import com.github.pagehelper.page.PageMethod; +import lombok.extern.slf4j.Slf4j; +import com.orangeforms.webadmin.upms.dto.SysRoleDto; +import com.orangeforms.webadmin.upms.dto.SysUserDto; +import com.orangeforms.webadmin.upms.vo.SysRoleVo; +import com.orangeforms.webadmin.upms.vo.SysUserVo; +import com.orangeforms.webadmin.upms.model.SysRole; +import com.orangeforms.webadmin.upms.model.SysUser; +import com.orangeforms.webadmin.upms.model.SysUserRole; +import com.orangeforms.webadmin.upms.service.SysRoleService; +import com.orangeforms.webadmin.upms.service.SysUserService; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.*; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 角色管理接口控制器类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "角色管理接口") +@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"}) + @SaCheckPermission("sysRole.add") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult 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 menuIdSet = null; + if (result.getData() != null) { + menuIdSet = result.getData().getObject("menuIdSet", new TypeReference>(){}); + } + sysRoleService.saveNew(sysRole, menuIdSet); + return ResponseResult.success(sysRole.getRoleId()); + } + + /** + * 更新角色操作。 + * + * @param sysRoleDto 更新角色对象。 + * @param menuIdListString 与当前角色Id绑定的menuId列表,多个menuId之间逗号分隔。 + * @return 应答结果对象。 + */ + @ApiOperationSupport(ignoreParameters = {"sysRoleDto.createTimeStart", "sysRoleDto.createTimeEnd"}) + @SaCheckPermission("sysRole.update") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult 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 menuIdSet = null; + if (result.getData() != null) { + menuIdSet = result.getData().getObject("menuIdSet", new TypeReference>(){}); + } + if (!sysRoleService.update(sysRole, originalSysRole, menuIdSet)) { + errorMessage = "更新失败,数据不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 删除指定角色操作。 + * + * @param roleId 指定角色主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("sysRole.delete") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult 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 应答结果对象,包含角色列表。 + */ + @SaCheckPermission("sysRole.view") + @PostMapping("/list") + public ResponseResult> 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 roleList = sysRoleService.getSysRoleList( + filter, MyOrderParam.buildOrderBy(orderParam, SysRole.class)); + List roleVoList = MyModelUtil.copyCollectionTo(roleList, SysRoleVo.class); + long totalCount = 0L; + if (roleList instanceof Page) { + totalCount = ((Page) roleList).getTotal(); + } + return ResponseResult.success(MyPageUtil.makeResponseData(roleVoList, totalCount)); + } + + /** + * 查看角色详情。 + * + * @param roleId 指定角色主键Id。 + * @return 应答结果对象,包含角色详情对象。 + */ + @SaCheckPermission("sysRole.view") + @GetMapping("/view") + public ResponseResult 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); + } + + /** + * 拥有指定角色的用户列表。 + * + * @param roleId 角色主键Id。 + * @param sysUserDtoFilter 用户过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含用户列表数据。 + */ + @SaCheckPermission("sysRole.view") + @PostMapping("/listUserRole") + public ResponseResult> listUserRole( + @MyRequestBody Long roleId, + @MyRequestBody SysUserDto sysUserDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + ResponseResult 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 userList = sysUserService.getSysUserListByRoleId(roleId, filter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(userList, SysUserVo.class)); + } + + /** + * 获取不包含指定角色Id的用户列表。 + * 用户和角色是多对多关系,当前接口将返回没有赋值指定RoleId的用户列表。可用于给角色添加新用户。 + * + * @param roleId 角色主键Id。 + * @param sysUserDtoFilter 用户过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含用户列表数据。 + */ + @SaCheckPermission("sysRole.update") + @PostMapping("/listNotInUserRole") + public ResponseResult> listNotInUserRole( + @MyRequestBody Long roleId, + @MyRequestBody SysUserDto sysUserDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + ResponseResult 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 userList = sysUserService.getNotInSysUserListByRoleId(roleId, filter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(userList, SysUserVo.class)); + } + + /** + * 为指定角色添加用户列表。该操作可同时给一批用户赋值角色,并在同一事务内完成。 + * + * @param roleId 角色主键Id。 + * @param userIdListString 逗号分隔的用户Id列表。 + * @return 应答结果对象。 + */ + @SaCheckPermission("sysRole.update") + @OperationLog(type = SysOperationLogType.ADD_M2M) + @PostMapping("/addUserRole") + public ResponseResult addUserRole(@MyRequestBody Long roleId, @MyRequestBody String userIdListString) { + if (MyCommonUtil.existBlankArgument(roleId, userIdListString)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + Set 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 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 应答数据结果。 + */ + @SaCheckPermission("sysRole.update") + @OperationLog(type = SysOperationLogType.DELETE_M2M) + @PostMapping("/deleteUserRole") + public ResponseResult 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中包含两条记录,key的值分别是id和name,value对应具体数据。 + */ + @GetMapping("/listDict") + public ResponseResult>> listDict(@ParameterObject SysRoleDto filter) { + List resultList = sysRoleService.getListByFilter(MyModelUtil.copyTo(filter, SysRole.class)); + return ResponseResult.success(MyCommonUtil.toDictDataList(resultList, SysRole::getRoleId, SysRole::getRoleName)); + } + + /** + * 根据字典Id集合,获取查询后的字典数据。 + * + * @param dictIds 字典Id集合。 + * @return 应答结果对象,包含字典形式的数据集合。 + */ + @GetMapping("/listDictByIds") + public ResponseResult>> listDictByIds(@RequestParam List dictIds) { + List resultList = sysRoleService.getInList(new HashSet<>(dictIds)); + return ResponseResult.success(MyCommonUtil.toDictDataList(resultList, SysRole::getRoleId, SysRole::getRoleName)); + } + + private ResponseResult 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(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysUserController.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysUserController.java new file mode 100644 index 00000000..406898d2 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysUserController.java @@ -0,0 +1,378 @@ +package com.orangeforms.webadmin.upms.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.alibaba.fastjson.TypeReference; +import cn.hutool.core.util.ReflectUtil; +import com.orangeforms.common.core.upload.BaseUpDownloader; +import com.orangeforms.common.core.upload.UpDownloaderFactory; +import com.orangeforms.common.core.upload.UploadResponseInfo; +import com.orangeforms.common.core.upload.UploadStoreInfo; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.webadmin.upms.vo.*; +import com.orangeforms.webadmin.upms.dto.*; +import com.orangeforms.webadmin.upms.model.*; +import com.orangeforms.webadmin.upms.service.*; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.*; +import com.orangeforms.common.core.constant.*; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.redis.cache.SessionCacheHelper; +import com.orangeforms.webadmin.config.ApplicationConfig; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.slf4j.Slf4j; +import org.springdoc.core.annotations.ParameterObject; +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 jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.*; + +/** + * 用户管理操作控制器类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "用户管理管理接口") +@Slf4j +@RestController +@RequestMapping("/admin/upms/sysUser") +public class SysUserController { + + @Autowired + private PasswordEncoder passwordEncoder; + @Autowired + private ApplicationConfig appConfig; + @Autowired + private SessionCacheHelper cacheHelper; + @Autowired + private UpDownloaderFactory upDownloaderFactory; + @Autowired + private SysUserService sysUserService; + + /** + * 新增用户操作。 + * + * @param sysUserDto 新增用户对象。 + * @param deptPostIdListString 逗号分隔的部门岗位Id列表。 + * @param dataPermIdListString 逗号分隔的数据权限Id列表。 + * @param roleIdListString 逗号分隔的角色Id列表。 + * @return 应答结果对象,包含新增用户的主键Id。 + */ + @ApiOperationSupport(ignoreParameters = { + "sysUserDto.userId", + "sysUserDto.createTimeStart", + "sysUserDto.createTimeEnd"}) + @SaCheckPermission("sysUser.add") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult 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 deptPostIdSet = result.getData().getObject("deptPostIdSet", new TypeReference>() {}); + Set roleIdSet = result.getData().getObject("roleIdSet", new TypeReference>() {}); + Set dataPermIdSet = result.getData().getObject("dataPermIdSet", new TypeReference>() {}); + 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"}) + @SaCheckPermission("sysUser.update") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult 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 roleIdSet = result.getData().getObject("roleIdSet", new TypeReference>() {}); + Set deptPostIdSet = result.getData().getObject("deptPostIdSet", new TypeReference>() {}); + Set dataPermIdSet = result.getData().getObject("dataPermIdSet", new TypeReference>() {}); + if (!sysUserService.update(sysUser, originalUser, roleIdSet, deptPostIdSet, dataPermIdSet)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 重置密码操作。 + * + * @param userId 指定用户主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("sysUser.resetPassword") + @PostMapping("/resetPassword") + public ResponseResult 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 应答结果对象。 + */ + @SaCheckPermission("sysUser.delete") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long userId) { + if (MyCommonUtil.existBlankArgument(userId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + return this.doDelete(userId); + } + + /** + * 批量删除用户管理数据。 + * + * @param userIdList 待删除对象的主键Id列表。 + * @return 应答结果对象。 + */ + @SaCheckPermission("sysUser.delete") + @OperationLog(type = SysOperationLogType.DELETE_BATCH) + @PostMapping("/deleteBatch") + public ResponseResult deleteBatch(@MyRequestBody List userIdList) { + if (MyCommonUtil.existBlankArgument(userIdList)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + for (Long userId : userIdList) { + ResponseResult responseResult = this.doDelete(userId); + if (!responseResult.isSuccess()) { + return responseResult; + } + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的用户管理列表。 + * + * @param sysUserDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("sysUser.view") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody SysUserDto sysUserDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount()); + } + SysUser sysUserFilter = MyModelUtil.copyTo(sysUserDtoFilter, SysUser.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, SysUser.class); + List sysUserList = sysUserService.getSysUserListWithRelation(sysUserFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(sysUserList, SysUserVo.class)); + } + + /** + * 查看指定用户管理对象详情。 + * + * @param userId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("sysUser.view") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long userId) { + // 这里查看用户数据时候,需要把用户多对多关联的角色和数据权限Id一并查出。 + SysUser sysUser = sysUserService.getByIdWithRelation(userId, MyRelationParam.full()); + if (sysUser == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + SysUserVo sysUserVo = MyModelUtil.copyTo(sysUser, SysUserVo.class); + return ResponseResult.success(sysUserVo); + } + + /** + * 附件文件下载。 + * 这里将图片和其他类型的附件文件放到不同的父目录下,主要为了便于今后图片文件的迁移。 + * + * @param userId 附件所在记录的主键Id。 + * @param fieldName 附件所属的字段名。 + * @param filename 文件名。如果没有提供该参数,就从当前记录的指定字段中读取。 + * @param asImage 下载文件是否为图片。 + * @param response Http 应答对象。 + */ + @SaCheckPermission("sysUser.view") + @OperationLog(type = SysOperationLogType.DOWNLOAD, saveResponse = false) + @GetMapping("/download") + public void download( + @RequestParam(required = false) Long userId, + @RequestParam String fieldName, + @RequestParam String filename, + @RequestParam Boolean asImage, + HttpServletResponse response) { + if (MyCommonUtil.existBlankArgument(fieldName, filename, asImage)) { + response.setStatus(HttpServletResponse.SC_BAD_REQUEST); + return; + } + // 使用try来捕获异常,是为了保证一旦出现异常可以返回500的错误状态,便于调试。 + // 否则有可能给前端返回的是200的错误码。 + try { + // 如果请求参数中没有包含主键Id,就判断该文件是否为当前session上传的。 + if (userId == null) { + if (!cacheHelper.existSessionUploadFile(filename)) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN); + return; + } + } else { + SysUser sysUser = sysUserService.getById(userId); + if (sysUser == null) { + ResponseResult.output(HttpServletResponse.SC_NOT_FOUND); + return; + } + String fieldJsonData = (String) ReflectUtil.getFieldValue(sysUser, fieldName); + if (fieldJsonData == null && !cacheHelper.existSessionUploadFile(filename)) { + ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST); + return; + } + if (!BaseUpDownloader.containFile(fieldJsonData, filename) + && !cacheHelper.existSessionUploadFile(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 上传文件对象。 + */ + @SaCheckPermission("sysUser.view") + @OperationLog(type = SysOperationLogType.UPLOAD, saveResponse = false) + @PostMapping("/upload") + public void upload( + @RequestParam String fieldName, + @RequestParam Boolean asImage, + @RequestParam("uploadFile") MultipartFile uploadFile) throws IOException { + 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 (Boolean.TRUE.equals(responseInfo.getUploadFailed())) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, + ResponseResult.error(ErrorCodeEnum.UPLOAD_FAILED, responseInfo.getErrorMessage())); + return; + } + cacheHelper.putSessionUploadFile(responseInfo.getFilename()); + ResponseResult.output(ResponseResult.success(responseInfo)); + } + + /** + * 以字典形式返回全部用户管理数据集合。字典的键值为[userId, showName]。 + * 白名单接口,登录用户均可访问。 + * + * @param filter 过滤对象。 + * @return 应答结果对象,包含的数据为 List>,map中包含两条记录,key的值分别是id和name,value对应具体数据。 + */ + @GetMapping("/listDict") + public ResponseResult>> listDict(@ParameterObject SysUserDto filter) { + List resultList = + sysUserService.getListByFilter(MyModelUtil.copyTo(filter, SysUser.class)); + return ResponseResult.success( + MyCommonUtil.toDictDataList(resultList, SysUser::getUserId, SysUser::getShowName)); + } + + /** + * 根据字典Id集合,获取查询后的字典数据。 + * + * @param dictIds 字典Id集合。 + * @return 应答结果对象,包含字典形式的数据集合。 + */ + @GetMapping("/listDictByIds") + public ResponseResult>> listDictByIds(@RequestParam List dictIds) { + List resultList = sysUserService.getInList(new HashSet<>(dictIds)); + return ResponseResult.success( + MyCommonUtil.toDictDataList(resultList, SysUser::getUserId, SysUser::getShowName)); + } + + private ResponseResult 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(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermDeptMapper.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermDeptMapper.java new file mode 100644 index 00000000..db58a68f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermDeptMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.webadmin.upms.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.webadmin.upms.model.SysDataPermDept; + +/** + * 数据权限与部门关系数据访问操作接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysDataPermDeptMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermMapper.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermMapper.java new file mode 100644 index 00000000..9483f952 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermMapper.java @@ -0,0 +1,43 @@ +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 2024-07-02 + */ +public interface SysDataPermMapper extends BaseDaoMapper { + + /** + * 获取数据权限列表。 + * + * @param sysDataPermFilter 过滤对象。 + * @param orderBy 排序字符串。 + * @return 过滤后的数据权限列表。 + */ + List getSysDataPermList( + @Param("sysDataPermFilter") SysDataPerm sysDataPermFilter, @Param("orderBy") String orderBy); + + /** + * 获取指定用户的数据权限列表。 + * + * @param userId 用户Id。 + * @return 数据权限列表。 + */ + List getSysDataPermListByUserId(@Param("userId") Long userId); + + /** + * 查询与指定菜单关联的数据权限列表。 + * + * @param menuId 菜单Id。 + * @return 与菜单Id关联的数据权限列表。 + */ + List getSysDataPermListByMenuId(@Param("menuId") Long menuId); +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermMenuMapper.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermMenuMapper.java new file mode 100644 index 00000000..37fa8274 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermMenuMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.webadmin.upms.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.webadmin.upms.model.SysDataPermMenu; + +/** + * 数据权限与菜单关系数据访问操作接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysDataPermMenuMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermUserMapper.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermUserMapper.java new file mode 100644 index 00000000..1ca7d6d3 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermUserMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.webadmin.upms.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.webadmin.upms.model.SysDataPermUser; + +/** + * 数据权限与用户关系数据访问操作接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysDataPermUserMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDeptMapper.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDeptMapper.java new file mode 100644 index 00000000..9f0dc2c2 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDeptMapper.java @@ -0,0 +1,33 @@ +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 2024-07-02 + */ +public interface SysDeptMapper extends BaseDaoMapper { + + /** + * 批量插入对象列表。 + * + * @param sysDeptList 新增对象列表。 + */ + void insertList(List sysDeptList); + + /** + * 获取过滤后的对象列表。 + * + * @param sysDeptFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getSysDeptList( + @Param("sysDeptFilter") SysDept sysDeptFilter, @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDeptPostMapper.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDeptPostMapper.java new file mode 100644 index 00000000..93eb328a --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDeptPostMapper.java @@ -0,0 +1,33 @@ +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 2024-07-02 + */ +public interface SysDeptPostMapper extends BaseDaoMapper { + + /** + * 获取指定部门Id的部门岗位多对多关联数据列表,以及关联的部门和岗位数据。 + * + * @param deptId 部门Id。如果参数为空则返回全部数据。 + * @return 部门岗位多对多数据列表。 + */ + List> getSysDeptPostListWithRelationByDeptId(@Param("deptId") Long deptId); + + /** + * 获取指定部门Id的领导部门岗位列表。 + * + * @param deptId 部门Id。 + * @return 指定部门Id的领导部门岗位列表 + */ + List getLeaderDeptPostList(@Param("deptId") Long deptId); +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDeptRelationMapper.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDeptRelationMapper.java new file mode 100644 index 00000000..a0f66281 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDeptRelationMapper.java @@ -0,0 +1,42 @@ +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 2024-07-02 + */ +public interface SysDeptRelationMapper extends BaseDaoMapper { + + /** + * 将myDeptId的所有子部门,与其父部门parentDeptId解除关联关系。 + * + * @param parentDeptIds myDeptId的父部门Id列表。 + * @param myDeptId 当前部门。 + */ + void removeBetweenChildrenAndParents( + @Param("parentDeptIds") List parentDeptIds, @Param("myDeptId") Long myDeptId); + + /** + * 批量插入部门关联数据。 + * 由于目前版本(3.4.1)的Mybatis Plus没有提供真正的批量插入,为了保证效率需要自己实现。 + * 目前我们仅仅给出MySQL和PostgresSQL的insert list实现作为参考,其他数据库需要自行修改。 + * + * @param deptRelationList 部门关联关系数据列表。 + */ + void insertList(List deptRelationList); + + /** + * 批量插入当前部门的所有父部门列表,包括自己和自己的关系。 + * + * @param parentDeptId myDeptId的父部门Id。 + * @param myDeptId 当前部门。 + */ + void insertParentList(@Param("parentDeptId") Long parentDeptId, @Param("myDeptId") Long myDeptId); +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysMenuMapper.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysMenuMapper.java new file mode 100644 index 00000000..da04a33c --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysMenuMapper.java @@ -0,0 +1,40 @@ +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 2024-07-02 + */ +public interface SysMenuMapper extends BaseDaoMapper { + + /** + * 获取登录用户的菜单列表。 + * + * @param userId 登录用户。 + * @return 菜单列表。 + */ + List getMenuListByUserId(@Param("userId") Long userId); + + /** + * 获取指定角色Id集合的菜单列表。 + * + * @param roleIds 角色Id集合。 + * @return 菜单列表。 + */ + List getMenuListByRoleIds(@Param("roleIds") Set roleIds); + + /** + * 查询包含指定菜单编码的菜单数量,目前仅用于satoken的权限框架。 + * + * @param menuCode 菜单编码。 + * @return 查询数量 + */ + int countMenuCode(@Param("menuCode") String menuCode); +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysPermWhitelistMapper.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysPermWhitelistMapper.java new file mode 100644 index 00000000..52a78fbf --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysPermWhitelistMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.webadmin.upms.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.webadmin.upms.model.SysPermWhitelist; + +/** + * 权限资源白名单数据访问操作接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysPermWhitelistMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysPostMapper.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysPostMapper.java new file mode 100644 index 00000000..4d17cc24 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysPostMapper.java @@ -0,0 +1,52 @@ +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 2024-07-02 + */ +public interface SysPostMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param sysPostFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getSysPostList( + @Param("sysPostFilter") SysPost sysPostFilter, @Param("orderBy") String orderBy); + + /** + * 获取指定部门的岗位列表。 + * + * @param deptId 部门Id。 + * @param sysPostFilter 从表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 岗位数据列表。 + */ + List 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 getNotInSysPostListByDeptId( + @Param("deptId") Long deptId, + @Param("sysPostFilter") SysPost sysPostFilter, + @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysRoleMapper.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysRoleMapper.java new file mode 100644 index 00000000..9187244e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysRoleMapper.java @@ -0,0 +1,25 @@ +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 2024-07-02 + */ +public interface SysRoleMapper extends BaseDaoMapper { + + /** + * 获取对象列表,过滤条件中包含like和between条件。 + * + * @param sysRoleFilter 过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getSysRoleList(@Param("sysRoleFilter") SysRole sysRoleFilter, @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysRoleMenuMapper.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysRoleMenuMapper.java new file mode 100644 index 00000000..38e63912 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysRoleMenuMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.webadmin.upms.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.webadmin.upms.model.SysRoleMenu; + +/** + * 角色与菜单操作关联关系数据访问操作接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysRoleMenuMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysUserMapper.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysUserMapper.java new file mode 100644 index 00000000..055985d9 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysUserMapper.java @@ -0,0 +1,188 @@ +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 2024-07-02 + */ +public interface SysUserMapper extends BaseDaoMapper { + + /** + * 批量插入对象列表。 + * + * @param sysUserList 新增对象列表。 + */ + void insertList(List sysUserList); + + /** + * 获取过滤后的对象列表。 + * + * @param sysUserFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getSysUserList( + @Param("sysUserFilter") SysUser sysUserFilter, @Param("orderBy") String orderBy); + + /** + * 根据部门Id集合,获取关联的用户列表。 + * + * @param deptIds 关联的部门Id集合。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和部门Id集合关联的用户列表。 + */ + List getSysUserListByDeptIds( + @Param("deptIds") Set deptIds, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); + + /** + * 根据登录名集合,获取关联的用户列表。 + * @param loginNames 登录名集合。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和登录名集合关联的用户列表。 + */ + List getSysUserListByLoginNames( + @Param("loginNames") List loginNames, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); + + /** + * 根据角色Id,获取关联的用户列表。 + * + * @param roleId 关联的角色Id。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和角色Id关联的用户列表。 + */ + List getSysUserListByRoleId( + @Param("roleId") Long roleId, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); + + /** + * 根据角色Id集合,获取去重后的用户Id列表。 + * + * @param roleIds 关联的角色Id集合。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和角色Id集合关联的去重后的用户Id列表。 + */ + List getUserIdListByRoleIds( + @Param("roleIds") Set roleIds, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); + + /** + * 根据角色Id,获取和当前角色Id没有建立多对多关联关系的用户列表。 + * + * @param roleId 关联的角色Id。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和RoleId没有建立关联关系的用户列表。 + */ + List getNotInSysUserListByRoleId( + @Param("roleId") Long roleId, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); + + /** + * 根据数据权限Id,获取关联的用户列表。 + * + * @param dataPermId 关联的数据权限Id。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和DataPermId关联的用户列表。 + */ + List getSysUserListByDataPermId( + @Param("dataPermId") Long dataPermId, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); + + /** + * 根据数据权限Id,获取和当前数据权限Id没有建立多对多关联关系的用户列表。 + * + * @param dataPermId 关联的数据权限Id。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和DataPermId没有建立关联关系的用户列表。 + */ + List getNotInSysUserListByDataPermId( + @Param("dataPermId") Long dataPermId, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); + + /** + * 根据部门岗位Id集合,获取关联的去重后的用户Id列表。 + * + * @param deptPostIds 关联的部门岗位Id集合。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和部门岗位Id集合关联的去重后的用户Id列表。 + */ + List getUserIdListByDeptPostIds( + @Param("deptPostIds") Set deptPostIds, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); + + /** + * 根据部门岗位Id,获取关联的用户列表。 + * + * @param deptPostId 关联的部门岗位Id。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和部门岗位Id关联的用户列表。 + */ + List getSysUserListByDeptPostId( + @Param("deptPostId") Long deptPostId, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); + + /** + * 根据部门岗位Id,获取和当前部门岗位Id没有建立多对多关联关系的用户列表。 + * + * @param deptPostId 关联的部门岗位Id。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和deptPostId没有建立关联关系的用户列表。 + */ + List getNotInSysUserListByDeptPostId( + @Param("deptPostId") Long deptPostId, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); + + /** + * 根据岗位Id集合,获取关联的去重后的用户Id列表。 + * + * @param postIds 关联的岗位Id集合。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和岗位Id集合关联的去重后的用户Id列表。 + */ + List getUserIdListByPostIds( + @Param("postIds") Set postIds, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); + + /** + * 根据岗位Id,获取关联的用户列表。 + * + * @param postId 关联的岗位Id。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和岗位Id关联的用户列表。 + */ + List getSysUserListByPostId( + @Param("postId") Long postId, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysUserPostMapper.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysUserPostMapper.java new file mode 100644 index 00000000..6da64992 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysUserPostMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.webadmin.upms.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.webadmin.upms.model.SysUserPost; + +/** + * 用户岗位数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysUserPostMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysUserRoleMapper.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysUserRoleMapper.java new file mode 100644 index 00000000..bf6dcfb8 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysUserRoleMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.webadmin.upms.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.webadmin.upms.model.SysUserRole; + +/** + * 用户与角色关联关系数据访问操作接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysUserRoleMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermDeptMapper.xml b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermDeptMapper.xml new file mode 100644 index 00000000..d3b228e6 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermDeptMapper.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermMapper.xml b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermMapper.xml new file mode 100644 index 00000000..02c2e688 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermMapper.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + AND zz_sys_data_perm.rule_type = #{sysDataPermFilter.ruleType} + + + + AND IFNULL(zz_sys_data_perm.data_perm_name, '') LIKE #{safeSearchString} + + + + + + + + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermMenuMapper.xml b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermMenuMapper.xml new file mode 100644 index 00000000..c668302f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermMenuMapper.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermUserMapper.xml b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermUserMapper.xml new file mode 100644 index 00000000..2530c39f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermUserMapper.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDeptMapper.xml b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDeptMapper.xml new file mode 100644 index 00000000..ef63bdc9 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDeptMapper.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + 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 + + (#{item.deptId}, + #{item.deptName}, + #{item.showOrder}, + #{item.parentId}, + #{item.deletedFlag}, + #{item.createUserId}, + #{item.updateUserId}, + #{item.createTime}, + #{item.updateTime}) + + + + + + + + AND zz_sys_dept.deleted_flag = ${@com.orangeforms.common.core.constant.GlobalDeletedFlag@NORMAL} + + + + + + + + AND zz_sys_dept.dept_name LIKE #{safeSysDeptDeptName} + + + AND zz_sys_dept.parent_id = #{sysDeptFilter.parentId} + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDeptPostMapper.xml b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDeptPostMapper.xml new file mode 100644 index 00000000..5d03d88b --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDeptPostMapper.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDeptRelationMapper.xml b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDeptRelationMapper.xml new file mode 100644 index 00000000..37ebd397 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDeptRelationMapper.xml @@ -0,0 +1,32 @@ + + + + + + + + + + DELETE a FROM zz_sys_dept_relation a + INNER JOIN zz_sys_dept_relation b ON a.dept_id = b.dept_id + WHERE b.parent_dept_id = #{myDeptId} AND a.parent_dept_id IN + + #{item} + + + + + INSERT INTO zz_sys_dept_relation(parent_dept_id, dept_id) VALUES + + (#{item.parentDeptId}, #{item.deptId}) + + + + + 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} + + diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysMenuMapper.xml b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysMenuMapper.xml new file mode 100644 index 00000000..d9ba9e7b --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysMenuMapper.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysPermWhitelistMapper.xml b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysPermWhitelistMapper.xml new file mode 100644 index 00000000..00d0c6d4 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysPermWhitelistMapper.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysPostMapper.xml b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysPostMapper.xml new file mode 100644 index 00000000..50765655 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysPostMapper.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_sys_post.post_name LIKE #{safeSysPostPostName} + + + AND zz_sys_post.leader_post = #{sysPostFilter.leaderPost} + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysRoleMapper.xml b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysRoleMapper.xml new file mode 100644 index 00000000..26b8e587 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysRoleMapper.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + AND role_name LIKE #{safeRoleName} + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysRoleMenuMapper.xml b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysRoleMenuMapper.xml new file mode 100644 index 00000000..6bf30195 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysRoleMenuMapper.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysUserMapper.xml b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysUserMapper.xml new file mode 100644 index 00000000..162d6b2d --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysUserMapper.xml @@ -0,0 +1,294 @@ + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO zz_sys_user + (user_id, + login_name, + password, + dept_id, + show_name, + user_type, + head_image_url, + user_status, + email, + mobile, + create_user_id, + update_user_id, + create_time, + update_time, + deleted_flag) + VALUES + + (#{item.userId}, + #{item.loginName}, + #{item.password}, + #{item.deptId}, + #{item.showName}, + #{item.userType}, + #{item.headImageUrl}, + #{item.userStatus}, + #{item.email}, + #{item.mobile}, + #{item.createUserId}, + #{item.updateUserId}, + #{item.createTime}, + #{item.updateTime}, + #{item.deletedFlag}) + + + + + + + + AND zz_sys_user.deleted_flag = ${@com.orangeforms.common.core.constant.GlobalDeletedFlag@NORMAL} + + + + + + + + AND zz_sys_user.login_name LIKE #{safeSysUserLoginName} + + + AND (EXISTS (SELECT 1 FROM zz_sys_dept_relation WHERE + zz_sys_dept_relation.parent_dept_id = #{sysUserFilter.deptId} + AND zz_sys_user.dept_id = zz_sys_dept_relation.dept_id)) + + + + AND zz_sys_user.show_name LIKE #{safeSysUserShowName} + + + AND zz_sys_user.user_status = #{sysUserFilter.userStatus} + + + AND zz_sys_user.create_time >= #{sysUserFilter.createTimeStart} + + + AND zz_sys_user.create_time <= #{sysUserFilter.createTimeEnd} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysUserPostMapper.xml b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysUserPostMapper.xml new file mode 100644 index 00000000..b846ba04 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysUserPostMapper.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysUserRoleMapper.xml b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysUserRoleMapper.xml new file mode 100644 index 00000000..c4993db0 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysUserRoleMapper.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDataPermDeptDto.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDataPermDeptDto.java new file mode 100644 index 00000000..69aa2867 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDataPermDeptDto.java @@ -0,0 +1,27 @@ +package com.orangeforms.webadmin.upms.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 数据权限与部门关联Dto。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "数据权限与部门关联Dto") +@Data +public class SysDataPermDeptDto { + + /** + * 数据权限Id。 + */ + @Schema(description = "数据权限Id", requiredMode = Schema.RequiredMode.REQUIRED) + private Long dataPermId; + + /** + * 关联部门Id。 + */ + @Schema(description = "关联部门Id", requiredMode = Schema.RequiredMode.REQUIRED) + private Long deptId; +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDataPermDto.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDataPermDto.java new file mode 100644 index 00000000..725c8068 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDataPermDto.java @@ -0,0 +1,55 @@ +package com.orangeforms.webadmin.upms.dto; + +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.core.validator.ConstDictRef; +import com.orangeforms.common.core.constant.DataPermRuleType; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.*; + +/** + * 数据权限Dto。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "数据权限Dto") +@Data +public class SysDataPermDto { + + /** + * 数据权限Id。 + */ + @Schema(description = "数据权限Id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据权限Id不能为空!", groups = {UpdateGroup.class}) + private Long dataPermId; + + /** + * 显示名称。 + */ + @Schema(description = "显示名称", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "数据权限名称不能为空!") + private String dataPermName; + + /** + * 数据权限规则类型(0: 全部可见 1: 只看自己 2: 只看本部门 3: 本部门及子部门 4: 多部门及子部门 5: 自定义部门列表)。 + */ + @Schema(description = "数据权限规则类型", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据权限规则类型不能为空!") + @ConstDictRef(constDictClass = DataPermRuleType.class) + private Integer ruleType; + + /** + * 部门Id列表(逗号分隔)。 + */ + @Schema(hidden = true) + private String deptIdListString; + + /** + * 搜索字符串。 + */ + @Schema(description = "LIKE 模糊搜索字符串") + private String searchString; +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDataPermMenuDto.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDataPermMenuDto.java new file mode 100644 index 00000000..763e9ddc --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDataPermMenuDto.java @@ -0,0 +1,27 @@ +package com.orangeforms.webadmin.upms.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 数据权限与菜单关联Dto。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "数据权限与菜单关联Dto") +@Data +public class SysDataPermMenuDto { + + /** + * 数据权限Id。 + */ + @Schema(description = "数据权限Id", requiredMode = Schema.RequiredMode.REQUIRED) + private Long dataPermId; + + /** + * 关联菜单Id。 + */ + @Schema(description = "关联菜单Id", requiredMode = Schema.RequiredMode.REQUIRED) + private Long menuId; +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDeptDto.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDeptDto.java new file mode 100644 index 00000000..335f1607 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDeptDto.java @@ -0,0 +1,48 @@ +package com.orangeforms.webadmin.upms.dto; + +import com.orangeforms.common.core.validator.UpdateGroup; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.*; + +/** + * 部门管理Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "SysDeptDto对象") +@Data +public class SysDeptDto { + + /** + * 部门Id。 + */ + @Schema(description = "部门Id。", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,部门Id不能为空!", groups = {UpdateGroup.class}) + private Long deptId; + + /** + * 部门名称。 + * NOTE: 可支持等于操作符的列表数据过滤。 + */ + @Schema(description = "部门名称。可支持等于操作符的列表数据过滤。", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "数据验证失败,部门名称不能为空!") + private String deptName; + + /** + * 显示顺序。 + */ + @Schema(description = "显示顺序。", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,显示顺序不能为空!") + private Integer showOrder; + + /** + * 父部门Id。 + * NOTE: 可支持等于操作符的列表数据过滤。 + */ + @Schema(description = "父部门Id。可支持等于操作符的列表数据过滤。") + private Long parentId; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDeptPostDto.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDeptPostDto.java new file mode 100644 index 00000000..6362ebe8 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDeptPostDto.java @@ -0,0 +1,47 @@ +package com.orangeforms.webadmin.upms.dto; + +import com.orangeforms.common.core.validator.UpdateGroup; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.*; + +/** + * 部门岗位Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "部门岗位Dto") +@Data +public class SysDeptPostDto { + + /** + * 部门岗位Id。 + */ + @Schema(description = "部门岗位Id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,部门岗位Id不能为空!", groups = {UpdateGroup.class}) + private Long deptPostId; + + /** + * 部门Id。 + */ + @Schema(description = "部门Id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,部门Id不能为空!", groups = {UpdateGroup.class}) + private Long deptId; + + /** + * 岗位Id。 + */ + @Schema(description = "岗位Id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,岗位Id不能为空!", groups = {UpdateGroup.class}) + private Long postId; + + /** + * 部门岗位显示名称。 + */ + @Schema(description = "部门岗位显示名称", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "数据验证失败,部门岗位显示名称不能为空!") + private String postShowName; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysMenuDto.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysMenuDto.java new file mode 100644 index 00000000..986f8dae --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysMenuDto.java @@ -0,0 +1,92 @@ +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.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 菜单Dto。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "菜单Dto") +@Data +public class SysMenuDto { + + /** + * 菜单Id。 + */ + @Schema(description = "菜单Id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "菜单Id不能为空!", groups = {UpdateGroup.class}) + private Long menuId; + + /** + * 父菜单Id,目录菜单的父菜单为null + */ + @Schema(description = "父菜单Id") + private Long parentId; + + /** + * 菜单显示名称。 + */ + @Schema(description = "菜单显示名称", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "菜单显示名称不能为空!") + private String menuName; + + /** + * 菜单类型 (0: 目录 1: 菜单 2: 按钮 3: UI片段)。 + */ + @Schema(description = "菜单类型", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "菜单类型不能为空!") + @ConstDictRef(constDictClass = SysMenuType.class, message = "数据验证失败,菜单类型为无效值!") + private Integer menuType; + + /** + * 前端表单路由名称,仅用于menu_type为1的菜单类型。 + */ + @Schema(description = "前端表单路由名称") + private String formRouterName; + + /** + * 在线表单主键Id,仅用于在线表单绑定的菜单。 + */ + @Schema(description = "在线表单主键Id") + private Long onlineFormId; + + /** + * 统计页面主键Id,仅用于统计页面绑定的菜单。 + */ + @Schema(description = "统计页面主键Id") + private Long reportPageId; + + /** + * 仅用于在线表单的流程Id。 + */ + @Schema(description = "仅用于在线表单的流程Id") + private Long onlineFlowEntryId; + + /** + * 菜单显示顺序 (值越小,排序越靠前)。 + */ + @Schema(description = "菜单显示顺序", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "菜单显示顺序不能为空!") + private Integer showOrder; + + /** + * 菜单图标。 + */ + @Schema(description = "菜单显示图标") + private String icon; + + /** + * 附加信息。 + */ + @Schema(description = "附加信息") + private String extraData; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysPostDto.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysPostDto.java new file mode 100644 index 00000000..c9bef765 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysPostDto.java @@ -0,0 +1,47 @@ +package com.orangeforms.webadmin.upms.dto; + +import com.orangeforms.common.core.validator.UpdateGroup; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.*; + +/** + * 岗位Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "岗位Dto") +@Data +public class SysPostDto { + + /** + * 岗位Id。 + */ + @Schema(description = "岗位Id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,岗位Id不能为空!", groups = {UpdateGroup.class}) + private Long postId; + + /** + * 岗位名称。 + */ + @Schema(description = "岗位名称", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "数据验证失败,岗位名称不能为空!") + private String postName; + + /** + * 岗位层级,数值越小级别越高。 + */ + @Schema(description = "岗位层级", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,岗位层级不能为空!") + private Integer postLevel; + + /** + * 是否领导岗位。 + */ + @Schema(description = "是否领导岗位", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,领导岗位不能为空!", groups = {UpdateGroup.class}) + private Boolean leaderPost; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysRoleDto.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysRoleDto.java new file mode 100644 index 00000000..3a567acd --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysRoleDto.java @@ -0,0 +1,32 @@ +package com.orangeforms.webadmin.upms.dto; + +import com.orangeforms.common.core.validator.UpdateGroup; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.*; + +/** + * 角色Dto。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "角色Dto") +@Data +public class SysRoleDto { + + /** + * 角色Id。 + */ + @Schema(description = "角色Id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "角色Id不能为空!", groups = {UpdateGroup.class}) + private Long roleId; + + /** + * 角色名称。 + */ + @Schema(description = "角色名称", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "角色名称不能为空!") + private String roleName; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysUserDto.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysUserDto.java new file mode 100644 index 00000000..4a993689 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysUserDto.java @@ -0,0 +1,110 @@ +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.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.*; + +/** + * 用户管理Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "SysUserDto对象") +@Data +public class SysUserDto { + + /** + * 用户Id。 + */ + @Schema(description = "用户Id。", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,用户Id不能为空!", groups = {UpdateGroup.class}) + private Long userId; + + /** + * 登录用户名。 + * NOTE: 可支持等于操作符的列表数据过滤。 + */ + @Schema(description = "登录用户名。可支持等于操作符的列表数据过滤。", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "数据验证失败,登录用户名不能为空!") + private String loginName; + + /** + * 用户密码。 + */ + @Schema(description = "用户密码。", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "数据验证失败,用户密码不能为空!", groups = {AddGroup.class}) + private String password; + + /** + * 用户部门Id。 + * NOTE: 可支持等于操作符的列表数据过滤。 + */ + @Schema(description = "用户部门Id。可支持等于操作符的列表数据过滤。", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,用户部门Id不能为空!") + private Long deptId; + + /** + * 用户显示名称。 + * NOTE: 可支持等于操作符的列表数据过滤。 + */ + @Schema(description = "用户显示名称。可支持等于操作符的列表数据过滤。", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "数据验证失败,用户显示名称不能为空!") + private String showName; + + /** + * 用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)。 + */ + @Schema(description = "用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)。", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)不能为空!") + @ConstDictRef(constDictClass = SysUserType.class, message = "数据验证失败,用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)为无效值!") + private Integer userType; + + /** + * 用户头像的Url。 + */ + @Schema(description = "用户头像的Url。") + private String headImageUrl; + + /** + * 用户状态(0: 正常 1: 锁定)。 + * NOTE: 可支持等于操作符的列表数据过滤。 + */ + @Schema(description = "用户状态(0: 正常 1: 锁定)。可支持等于操作符的列表数据过滤。", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,用户状态(0: 正常 1: 锁定)不能为空!") + @ConstDictRef(constDictClass = SysUserStatus.class, message = "数据验证失败,用户状态(0: 正常 1: 锁定)为无效值!") + private Integer userStatus; + + /** + * 用户邮箱。 + */ + @Schema(description = "用户邮箱。") + private String email; + + /** + * 用户手机。 + */ + @Schema(description = "用户手机。") + private String mobile; + + /** + * createTime 范围过滤起始值(>=)。 + * NOTE: 可支持范围操作符的列表数据过滤。 + */ + @Schema(description = "createTime 范围过滤起始值(>=)。可支持范围操作符的列表数据过滤。") + private String createTimeStart; + + /** + * createTime 范围过滤结束值(<=)。 + * NOTE: 可支持范围操作符的列表数据过滤。 + */ + @Schema(description = "createTime 范围过滤结束值(<=)。可支持范围操作符的列表数据过滤。") + private String createTimeEnd; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPerm.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPerm.java new file mode 100644 index 00000000..8f71c696 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPerm.java @@ -0,0 +1,62 @@ +package com.orangeforms.webadmin.upms.model; + +import com.mybatisflex.annotation.*; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.annotation.RelationManyToMany; +import com.orangeforms.common.core.base.model.BaseModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.*; + +/** + * 数据权限实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Table(value = "zz_sys_data_perm") +public class SysDataPerm extends BaseModel { + + /** + * 主键Id。 + */ + @Id(value = "data_perm_id") + private Long dataPermId; + + /** + * 显示名称。 + */ + @Column(value = "data_perm_name") + private String dataPermName; + + /** + * 数据权限规则类型(0: 全部可见 1: 只看自己 2: 只看本部门 3: 本部门及子部门 4: 多部门及子部门 5: 自定义部门列表)。 + */ + @Column(value = "rule_type") + private Integer ruleType; + + @Column(ignore = true) + private String deptIdListString; + + @RelationManyToMany( + relationMasterIdField = "dataPermId", + relationModelClass = SysDataPermDept.class) + @Column(ignore = true) + private List dataPermDeptList; + + @RelationManyToMany( + relationMasterIdField = "dataPermId", + relationModelClass = SysDataPermMenu.class) + @Column(ignore = true) + private List dataPermMenuList; + + @Column(ignore = true) + private String searchString; + + public void setSearchString(String searchString) { + this.searchString = MyCommonUtil.replaceSqlWildcard(searchString); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPermDept.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPermDept.java new file mode 100644 index 00000000..43b91b2a --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPermDept.java @@ -0,0 +1,29 @@ +package com.orangeforms.webadmin.upms.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; +import lombok.ToString; + +/** + * 数据权限与部门关联实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ToString(of = {"deptId"}) +@Table(value = "zz_sys_data_perm_dept") +public class SysDataPermDept { + + /** + * 数据权限Id。 + */ + @Column(value = "data_perm_id") + private Long dataPermId; + + /** + * 关联部门Id。 + */ + @Column(value = "dept_id") + private Long deptId; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPermMenu.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPermMenu.java new file mode 100644 index 00000000..4976f769 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPermMenu.java @@ -0,0 +1,29 @@ +package com.orangeforms.webadmin.upms.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; +import lombok.ToString; + +/** + * 数据权限与菜单关联实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ToString(of = {"menuId"}) +@Table(value = "zz_sys_data_perm_menu") +public class SysDataPermMenu { + + /** + * 数据权限Id。 + */ + @Column(value = "data_perm_id") + private Long dataPermId; + + /** + * 关联菜单Id。 + */ + @Column(value = "menu_id") + private Long menuId; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPermUser.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPermUser.java new file mode 100644 index 00000000..1f1e9f58 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPermUser.java @@ -0,0 +1,27 @@ +package com.orangeforms.webadmin.upms.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; + +/** + * 数据权限与用户关联实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_sys_data_perm_user") +public class SysDataPermUser { + + /** + * 数据权限Id。 + */ + @Column(value = "data_perm_id") + private Long dataPermId; + + /** + * 用户Id。 + */ + @Column(value = "user_id") + private Long userId; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDept.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDept.java new file mode 100644 index 00000000..c50e4438 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDept.java @@ -0,0 +1,73 @@ +package com.orangeforms.webadmin.upms.model; + +import com.mybatisflex.annotation.Column; +import com.mybatisflex.annotation.Id; +import com.mybatisflex.annotation.Table; +import lombok.Data; + +import java.util.Date; + +/** + * 部门管理实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_sys_dept") +public class SysDept { + + /** + * 部门Id。 + */ + @Id(value = "dept_id") + private Long deptId; + + /** + * 部门名称。 + */ + @Column(value = "dept_name") + private String deptName; + + /** + * 显示顺序。 + */ + @Column(value = "show_order") + private Integer showOrder; + + /** + * 父部门Id。 + */ + @Column(value = "parent_id") + private Long parentId; + + /** + * 逻辑删除标记字段(1: 正常 -1: 已删除)。 + */ + @Column(value = "deleted_flag", isLogicDelete = true) + private Integer deletedFlag; + + /** + * 创建者Id。 + */ + @Column(value = "create_user_id") + private Long createUserId; + + /** + * 更新者Id。 + */ + @Column(value = "update_user_id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @Column(value = "create_time") + private Date createTime; + + /** + * 更新时间。 + */ + @Column(value = "update_time") + private Date updateTime; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDeptPost.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDeptPost.java new file mode 100644 index 00000000..615ec2b1 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDeptPost.java @@ -0,0 +1,39 @@ +package com.orangeforms.webadmin.upms.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; + +/** + * 部门岗位多对多关联实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_sys_dept_post") +public class SysDeptPost { + + /** + * 部门岗位Id。 + */ + @Id(value = "dept_post_id") + private Long deptPostId; + + /** + * 部门Id。 + */ + @Column(value = "dept_id") + private Long deptId; + + /** + * 岗位Id。 + */ + @Column(value = "post_id") + private Long postId; + + /** + * 部门岗位显示名称。 + */ + @Column(value = "post_show_name") + private String postShowName; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDeptRelation.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDeptRelation.java new file mode 100644 index 00000000..038daba0 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDeptRelation.java @@ -0,0 +1,31 @@ +package com.orangeforms.webadmin.upms.model; + +import com.mybatisflex.annotation.*; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 部门关联实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Table(value = "zz_sys_dept_relation") +public class SysDeptRelation { + + /** + * 上级部门Id。 + */ + @Column(value = "parent_dept_id") + private Long parentDeptId; + + /** + * 部门Id。 + */ + @Column(value = "dept_id") + private Long deptId; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysMenu.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysMenu.java new file mode 100644 index 00000000..1797fc20 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysMenu.java @@ -0,0 +1,96 @@ +package com.orangeforms.webadmin.upms.model; + +import com.mybatisflex.annotation.*; +import com.orangeforms.common.core.base.model.BaseModel; +import com.orangeforms.webadmin.upms.bo.SysMenuExtraData; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 菜单实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Table(value = "zz_sys_menu") +public class SysMenu extends BaseModel { + + /** + * 菜单Id。 + */ + @Id(value = "menu_id") + private Long menuId; + + /** + * 父菜单Id,目录菜单的父菜单为null。 + */ + @Column(value = "parent_id") + private Long parentId; + + /** + * 菜单显示名称。 + */ + @Column(value = "menu_name") + private String menuName; + + /** + * 菜单类型(0: 目录 1: 菜单 2: 按钮 3: UI片段)。 + */ + @Column(value = "menu_type") + private Integer menuType; + + /** + * 前端表单路由名称,仅用于menu_type为1的菜单类型。 + */ + @Column(value = "form_router_name") + private String formRouterName; + + /** + * 在线表单主键Id,仅用于在线表单绑定的菜单。 + */ + @Column(value = "online_form_id") + private Long onlineFormId; + + /** + * 在线表单菜单的权限控制类型,具体值可参考SysOnlineMenuPermType常量对象。 + */ + @Column(value = "online_menu_perm_type") + private Integer onlineMenuPermType; + + /** + * 统计页面主键Id,仅用于统计页面绑定的菜单。 + */ + @Column(value = "report_page_id") + private Long reportPageId; + + /** + * 仅用于在线表单的流程Id。 + */ + @Column(value = "online_flow_entry_id") + private Long onlineFlowEntryId; + + /** + * 菜单显示顺序 (值越小,排序越靠前)。 + */ + @Column(value = "show_order") + private Integer showOrder; + + /** + * 菜单图标。 + */ + private String icon; + + /** + * 附加信息。 + */ + @Column(value = "extra_data") + private String extraData; + + /** + * extraData字段解析后的对象数据。 + */ + @Column(ignore = true) + private SysMenuExtraData extraObject; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysPermWhitelist.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysPermWhitelist.java new file mode 100644 index 00000000..05c4457b --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysPermWhitelist.java @@ -0,0 +1,33 @@ +package com.orangeforms.webadmin.upms.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; + +/** + * 白名单实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_sys_perm_whitelist") +public class SysPermWhitelist { + + /** + * 权限资源的URL。 + */ + @Id(value = "perm_url") + private String permUrl; + + /** + * 权限资源所属模块名字(通常是Controller的名字)。 + */ + @Column(value = "module_name") + private String moduleName; + + /** + * 权限的名称。 + */ + @Column(value = "perm_name") + private String permName; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysPost.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysPost.java new file mode 100644 index 00000000..57368f0e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysPost.java @@ -0,0 +1,48 @@ +package com.orangeforms.webadmin.upms.model; + +import com.mybatisflex.annotation.*; +import com.orangeforms.common.core.base.model.BaseModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 岗位实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Table(value = "zz_sys_post") +public class SysPost extends BaseModel { + + /** + * 岗位Id。 + */ + @Id(value = "post_id") + private Long postId; + + /** + * 岗位名称。 + */ + @Column(value = "post_name") + private String postName; + + /** + * 岗位层级,数值越小级别越高。 + */ + @Column(value = "post_level") + private Integer postLevel; + + /** + * 是否领导岗位。 + */ + @Column(value = "leader_post") + private Boolean leaderPost; + + /** + * postId 的多对多关联表数据对象。 + */ + @Column(ignore = true) + private SysDeptPost sysDeptPost; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysRole.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysRole.java new file mode 100644 index 00000000..62d94183 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysRole.java @@ -0,0 +1,39 @@ +package com.orangeforms.webadmin.upms.model; + +import com.mybatisflex.annotation.*; +import com.orangeforms.common.core.annotation.RelationManyToMany; +import com.orangeforms.common.core.base.model.BaseModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.*; + +/** + * 角色实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Table(value = "zz_sys_role") +public class SysRole extends BaseModel { + + /** + * 角色Id。 + */ + @Id(value = "role_id") + private Long roleId; + + /** + * 角色名称。 + */ + @Column(value = "role_name") + private String roleName; + + @RelationManyToMany( + relationMasterIdField = "roleId", + relationModelClass = SysRoleMenu.class) + @Column(ignore = true) + private List sysRoleMenuList; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysRoleMenu.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysRoleMenu.java new file mode 100644 index 00000000..5fcc9065 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysRoleMenu.java @@ -0,0 +1,27 @@ +package com.orangeforms.webadmin.upms.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; + +/** + * 角色菜单实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_sys_role_menu") +public class SysRoleMenu { + + /** + * 角色Id。 + */ + @Column(value = "role_id") + private Long roleId; + + /** + * 菜单Id。 + */ + @Column(value = "menu_id") + private Long menuId; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysUser.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysUser.java new file mode 100644 index 00000000..fe3e132f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysUser.java @@ -0,0 +1,172 @@ +package com.orangeforms.webadmin.upms.model; + +import com.mybatisflex.annotation.Column; +import com.mybatisflex.annotation.Id; +import com.mybatisflex.annotation.Table; +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 lombok.Data; + +import java.util.Date; +import java.util.Map; +import java.util.List; + +/** + * 用户管理实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_sys_user") +public class SysUser { + + /** + * 用户Id。 + */ + @Id(value = "user_id") + private Long userId; + + /** + * 登录用户名。 + */ + @Column(value = "login_name") + private String loginName; + + /** + * 用户密码。 + */ + private String password; + + /** + * 用户部门Id。 + */ + @Column(value = "dept_id") + private Long deptId; + + /** + * 用户显示名称。 + */ + @Column(value = "show_name") + private String showName; + + /** + * 用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)。 + */ + @Column(value = "user_type") + private Integer userType; + + /** + * 用户头像的Url。 + */ + @UploadFlagColumn(storeType = UploadStoreTypeEnum.LOCAL_SYSTEM) + @Column(value = "head_image_url") + private String headImageUrl; + + /** + * 用户状态(0: 正常 1: 锁定)。 + */ + @Column(value = "user_status") + private Integer userStatus; + + /** + * 用户邮箱。 + */ + private String email; + + /** + * 用户手机。 + */ + private String mobile; + + /** + * 创建者Id。 + */ + @Column(value = "create_user_id") + private Long createUserId; + + /** + * 更新者Id。 + */ + @Column(value = "update_user_id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @Column(value = "create_time") + private Date createTime; + + /** + * 更新时间。 + */ + @Column(value = "update_time") + private Date updateTime; + + /** + * 逻辑删除标记字段(1: 正常 -1: 已删除)。 + */ + @Column(value = "deleted_flag", isLogicDelete = true) + private Integer deletedFlag; + + /** + * createTime 范围过滤起始值(>=)。 + */ + @Column(ignore = true) + private String createTimeStart; + + /** + * createTime 范围过滤结束值(<=)。 + */ + @Column(ignore = true) + private String createTimeEnd; + + /** + * 多对多用户部门岗位数据集合。 + */ + @RelationManyToMany( + relationMasterIdField = "userId", + relationModelClass = SysUserPost.class) + @Column(ignore = true) + private List sysUserPostList; + + /** + * 多对多用户角色数据集合。 + */ + @RelationManyToMany( + relationMasterIdField = "userId", + relationModelClass = SysUserRole.class) + @Column(ignore = true) + private List sysUserRoleList; + + /** + * 多对多用户数据权限数据集合。 + */ + @RelationManyToMany( + relationMasterIdField = "userId", + relationModelClass = SysDataPermUser.class) + @Column(ignore = true) + private List sysDataPermUserList; + + @RelationDict( + masterIdField = "deptId", + slaveModelClass = SysDept.class, + slaveIdField = "deptId", + slaveNameField = "deptName") + @Column(ignore = true) + private Map deptIdDictMap; + + @RelationConstDict( + masterIdField = "userType", + constantDictClass = SysUserType.class) + @Column(ignore = true) + private Map userTypeDictMap; + + @RelationConstDict( + masterIdField = "userStatus", + constantDictClass = SysUserStatus.class) + @Column(ignore = true) + private Map userStatusDictMap; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysUserPost.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysUserPost.java new file mode 100644 index 00000000..449e156e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysUserPost.java @@ -0,0 +1,33 @@ +package com.orangeforms.webadmin.upms.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; + +/** + * 用户岗位多对多关系实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_sys_user_post") +public class SysUserPost { + + /** + * 用户Id。 + */ + @Column(value = "user_id") + private Long userId; + + /** + * 部门岗位Id。 + */ + @Column(value = "dept_post_id") + private Long deptPostId; + + /** + * 岗位Id。 + */ + @Column(value = "post_id") + private Long postId; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysUserRole.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysUserRole.java new file mode 100644 index 00000000..c0ec2622 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysUserRole.java @@ -0,0 +1,27 @@ +package com.orangeforms.webadmin.upms.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; + +/** + * 用户角色实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_sys_user_role") +public class SysUserRole { + + /** + * 用户Id。 + */ + @Column(value = "user_id") + private Long userId; + + /** + * 角色Id。 + */ + @Column(value = "role_id") + private Long roleId; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysMenuType.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysMenuType.java new file mode 100644 index 00000000..6108183d --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysMenuType.java @@ -0,0 +1,54 @@ +package com.orangeforms.webadmin.upms.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 菜单类型常量对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +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 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() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysOnlineMenuPermType.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysOnlineMenuPermType.java new file mode 100644 index 00000000..752ce7dd --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysOnlineMenuPermType.java @@ -0,0 +1,44 @@ +package com.orangeforms.webadmin.upms.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 菜单关联在线表单的控制权限类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class SysOnlineMenuPermType { + + /** + * 查看。 + */ + public static final int TYPE_VIEW = 0; + /** + * 编辑。 + */ + public static final int TYPE_EDIT = 1; + + private static final Map 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() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysUserStatus.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysUserStatus.java new file mode 100644 index 00000000..b71dd0aa --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysUserStatus.java @@ -0,0 +1,44 @@ +package com.orangeforms.webadmin.upms.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 用户状态常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class SysUserStatus { + + /** + * 正常状态。 + */ + public static final int STATUS_NORMAL = 0; + /** + * 锁定状态。 + */ + public static final int STATUS_LOCKED = 1; + + private static final Map DICT_MAP = new HashMap<>(2); + static { + DICT_MAP.put(STATUS_NORMAL, "正常状态"); + DICT_MAP.put(STATUS_LOCKED, "锁定状态"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private SysUserStatus() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysUserType.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysUserType.java new file mode 100644 index 00000000..ee6fa852 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysUserType.java @@ -0,0 +1,49 @@ +package com.orangeforms.webadmin.upms.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 用户类型常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class SysUserType { + + /** + * 管理员。 + */ + public static final int TYPE_ADMIN = 0; + /** + * 系统操作员。 + */ + public static final int TYPE_SYSTEM = 1; + /** + * 普通操作员。 + */ + public static final int TYPE_OPERATOR = 2; + + private static final Map DICT_MAP = new HashMap<>(3); + static { + DICT_MAP.put(TYPE_ADMIN, "管理员"); + DICT_MAP.put(TYPE_SYSTEM, "系统操作员"); + DICT_MAP.put(TYPE_OPERATOR, "普通操作员"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private SysUserType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysDataPermService.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysDataPermService.java new file mode 100644 index 00000000..0dff4fa6 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysDataPermService.java @@ -0,0 +1,114 @@ +package com.orangeforms.webadmin.upms.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.webadmin.upms.model.*; + +import java.util.*; + +/** + * 数据权限数据服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysDataPermService extends IBaseService { + + /** + * 保存新增的数据权限对象。 + * + * @param dataPerm 新增的数据权限对象。 + * @param deptIdSet 关联的部门Id列表。 + * @param menuIdSet 关联的菜单Id列表。 + * @return 新增后的数据权限对象。 + */ + SysDataPerm saveNew(SysDataPerm dataPerm, Set deptIdSet, Set menuIdSet); + + /** + * 更新数据权限对象。 + * + * @param dataPerm 更新的数据权限对象。 + * @param originalDataPerm 原有的数据权限对象。 + * @param deptIdSet 关联的部门Id列表。 + * @param menuIdSet 关联的菜单Id列表。 + * @return 更新成功返回true,否则false。 + */ + boolean update(SysDataPerm dataPerm, SysDataPerm originalDataPerm, Set deptIdSet, Set menuIdSet); + + /** + * 删除指定数据权限。 + * + * @param dataPermId 数据权限主键Id。 + * @return 删除成功返回true,否则false。 + */ + boolean remove(Long dataPermId); + + /** + * 获取数据权限列表及其关联数据。 + * + * @param filter 数据权限过滤对象。 + * @param orderBy 排序参数。 + * @return 数据权限查询列表。 + */ + List getSysDataPermListWithRelation(SysDataPerm filter, String orderBy); + + /** + * 将指定用户的指定会话的数据权限集合存入缓存。 + * + * @param sessionId 会话Id。 + * @param userId 用户主键Id。 + * @param deptId 用户所属部门主键Id。 + */ + void putDataPermCache(String sessionId, Long userId, Long deptId); + + /** + * 将指定会话的数据权限集合从缓存中移除。 + * + * @param sessionId 会话Id。 + */ + void removeDataPermCache(String sessionId); + + /** + * 获取指定用户Id的数据权限列表。并基于menuId和权限规则类型进行了一级分组。 + * + * @param userId 指定的用户Id。 + * @param deptId 用户所属部门主键Id。 + * @return 合并优化后的数据权限列表。返回格式为,Map>。 + */ + Map> getSysDataPermListByUserId(Long userId, Long deptId); + + /** + * 查询与指定菜单关联的数据权限列表。 + * + * @param menuId 菜单Id。 + * @return 与菜单Id关联的数据权限列表。 + */ + List getSysDataPermListByMenuId(Long menuId); + + /** + * 添加用户和数据权限之间的多对多关联关系。 + * + * @param dataPermId 数据权限Id。 + * @param userIdSet 关联的用户Id列表。 + */ + void addDataPermUserList(Long dataPermId, Set userIdSet); + + /** + * 移除用户和数据权限之间的多对多关联关系。 + * + * @param dataPermId 数据权限主键Id。 + * @param userId 用户主键Id。 + * @return true移除成功,否则false。 + */ + boolean removeDataPermUser(Long dataPermId, Long userId); + + /** + * 验证数据权限对象关联菜单数据是否都合法。 + * + * @param dataPerm 数据权限关对象。 + * @param deptIdListString 与数据权限关联的部门Id列表。 + * @param menuIdListString 与数据权限关联的菜单Id列表。 + * @return 验证结果。 + */ + CallResult verifyRelatedData(SysDataPerm dataPerm, String deptIdListString, String menuIdListString); +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysDeptService.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysDeptService.java new file mode 100644 index 00000000..2a485df5 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysDeptService.java @@ -0,0 +1,170 @@ +package com.orangeforms.webadmin.upms.service; + +import com.orangeforms.webadmin.upms.model.*; +import com.orangeforms.common.core.base.service.IBaseService; + +import java.util.*; + +/** + * 部门管理数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysDeptService extends IBaseService { + + /** + * 保存新增的部门对象。 + * + * @param sysDept 新增的部门对象。 + * @param parentSysDept 上级部门对象。 + * @return 新增后的部门对象。 + */ + SysDept saveNew(SysDept sysDept, SysDept parentSysDept); + + /** + * 更新部门对象。 + * + * @param sysDept 更新的部门对象。 + * @param originalSysDept 原有的部门对象。 + * @return 更新成功返回true,否则false。 + */ + boolean update(SysDept sysDept, SysDept originalSysDept); + + /** + * 删除指定数据。 + * + * @param deptId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long deptId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getSysDeptListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getSysDeptList(SysDept filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getSysDeptList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getSysDeptListWithRelation(SysDept filter, String orderBy); + + /** + * 判断指定对象是否包含下级对象。 + * + * @param deptId 主键Id。 + * @return 存在返回true,否则false。 + */ + boolean hasChildren(Long deptId); + + /** + * 判断指定部门Id是否包含用户对象。 + * + * @param deptId 部门主键Id。 + * @return 存在返回true,否则false。 + */ + boolean hasChildrenUser(Long deptId); + + /** + * 批量添加多对多关联关系。 + * + * @param sysDeptPostList 多对多关联表对象集合。 + * @param deptId 主表Id。 + */ + void addSysDeptPostList(List sysDeptPostList, Long deptId); + + /** + * 更新中间表数据。 + * + * @param sysDeptPost 中间表对象。 + * @return 更新成功与否。 + */ + boolean updateSysDeptPost(SysDeptPost sysDeptPost); + + /** + * 移除单条多对多关系。 + * + * @param deptId 主表Id。 + * @param postId 从表Id。 + * @return 成功返回true,否则false。 + */ + boolean removeSysDeptPost(Long deptId, Long postId); + + /** + * 获取中间表数据。 + * + * @param deptId 主表Id。 + * @param postId 从表Id。 + * @return 中间表对象。 + */ + SysDeptPost getSysDeptPost(Long deptId, Long postId); + + /** + * 根据部门岗位Id获取部门岗位关联对象。 + * + * @param deptPostId 部门岗位Id。 + * @return 部门岗位对象。 + */ + SysDeptPost getSysDeptPost(Long deptPostId); + + /** + * 获取指定部门Id的部门岗位多对多关联数据列表,以及关联的部门和岗位数据。 + * + * @param deptId 部门Id。如果参数为空则返回全部数据。 + * @return 部门岗位多对多数据列表。 + */ + List> getSysDeptPostListWithRelationByDeptId(Long deptId); + + /** + * 获取指定部门Id和岗位Id集合的部门岗位多对多关联数据列表。 + * + * @param deptId 部门Id。 + * @param postIdSet 指定的岗位Id集合。 + * @return 部门岗位多对多数据列表。 + */ + List getSysDeptPostList(Long deptId, Set postIdSet); + + /** + * 获取与指定部门Id同级部门和岗位Id集合的部门岗位多对多关联数据列表。 + * + * @param deptId 部门Id。 + * @param postIdSet 指定的岗位Id集合。 + * @return 部门岗位多对多数据列表。 + */ + List getSiblingSysDeptPostList(Long deptId, Set postIdSet); + + /** + * 根据部门Id获取该部门领导岗位的部门岗位Id集合。 + * + * @param deptId 部门Id。 + * @return 部门领导岗位的部门岗位Id集合。 + */ + List getLeaderDeptPostIdList(Long deptId); + + /** + * 根据部门Id获取上级部门领导岗位的部门岗位Id集合。 + * + * @param deptId 部门Id。 + * @return 上级部门领导岗位的部门岗位Id集合。 + */ + List getUpLeaderDeptPostIdList(Long deptId); + + /** + * 根据父主键Id列表,获取当前部门Id及其所有下级部门Id列表。 + * + * @param parentIds 父主键Id列表。 + * @return 获取当前部门Id及其所有下级部门Id列表。 + */ + List getAllChildDeptIdByParentIds(List parentIds); +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysMenuService.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysMenuService.java new file mode 100644 index 00000000..7c39d7e8 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysMenuService.java @@ -0,0 +1,72 @@ +package com.orangeforms.webadmin.upms.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.webadmin.upms.model.SysMenu; + +import java.util.*; + +/** + * 菜单数据服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysMenuService extends IBaseService { + + /** + * 保存新增的菜单对象。 + * + * @param sysMenu 新增的菜单对象。 + * @return 新增后的菜单对象。 + */ + SysMenu saveNew(SysMenu sysMenu); + + /** + * 更新菜单对象。 + * + * @param sysMenu 更新的菜单对象。 + * @param originalSysMenu 原有的菜单对象。 + * @return 更新成功返回true,否则false。 + */ + boolean update(SysMenu sysMenu, SysMenu originalSysMenu); + + /** + * 删除指定的菜单。 + * + * @param menu 菜单对象。 + * @return 删除成功返回true,否则false。 + */ + boolean remove(SysMenu menu); + + /** + * 获取指定用户Id的菜单列表,已去重。 + * + * @param userId 用户主键Id。 + * @return 用户关联的菜单列表。 + */ + Collection getMenuListByUserId(Long userId); + + /** + * 根据角色Id集合获取菜单对象列表。 + * + * @param roleIds 逗号分隔的角色Id集合。 + * @return 菜单对象列表。 + */ + Collection getMenuListByRoleIds(String roleIds); + + /** + * 判断当前菜单是否存在子菜单。 + * + * @param menuId 菜单主键Id。 + * @return 存在返回true,否则false。 + */ + boolean hasChildren(Long menuId); + + /** + * 获取指定类型的所有在线表单的菜单。 + * + * @param menuType 菜单类型,NULL则返回全部类型。 + * @return 在线表单关联的菜单列表。 + */ + List getAllOnlineMenuList(Integer menuType); +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysPermWhitelistService.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysPermWhitelistService.java new file mode 100644 index 00000000..84dab9fa --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysPermWhitelistService.java @@ -0,0 +1,23 @@ +package com.orangeforms.webadmin.upms.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.webadmin.upms.model.SysPermWhitelist; + +import java.util.List; + +/** + * 权限资源白名单数据服务接口。 + * 白名单中的权限资源,可以不受权限控制,任何用户皆可访问,一般用于常用的字典数据列表接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysPermWhitelistService extends IBaseService { + + /** + * 获取白名单权限资源的列表。 + * + * @return 白名单权限资源地址列表。 + */ + List getWhitelistPermList(); +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysPostService.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysPostService.java new file mode 100644 index 00000000..71165759 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysPostService.java @@ -0,0 +1,99 @@ +package com.orangeforms.webadmin.upms.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.webadmin.upms.model.SysPost; +import com.orangeforms.webadmin.upms.model.SysUserPost; + +import java.util.*; + +/** + * 岗位管理数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysPostService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param sysPost 新增对象。 + * @return 返回新增对象。 + */ + SysPost saveNew(SysPost sysPost); + + /** + * 更新数据对象。 + * + * @param sysPost 更新的对象。 + * @param originalSysPost 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(SysPost sysPost, SysPost originalSysPost); + + /** + * 删除指定数据。 + * + * @param postId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long postId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getSysPostListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getSysPostList(SysPost filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getSysPostList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getSysPostListWithRelation(SysPost filter, String orderBy); + + /** + * 在多对多关系中,当前Service的数据表为从表,返回不与指定主表主键Id存在对多对关系的列表。 + * + * @param deptId 主表主键Id。 + * @param filter 从表的过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getNotInSysPostListByDeptId(Long deptId, SysPost filter, String orderBy); + + /** + * 获取指定部门的岗位列表。 + * + * @param deptId 部门Id。 + * @param filter 从表的过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getSysPostListByDeptId(Long deptId, SysPost filter, String orderBy); + + /** + * 获取指定用户的用户岗位多对多关联数据列表。 + * + * @param userId 用户Id。 + * @return 用户岗位多对多关联数据列表。 + */ + List getSysUserPostListByUserId(Long userId); + + /** + * 判断指定的部门岗位Id集合是否都属于指定的部门Id。 + * + * @param deptPostIdSet 部门岗位Id集合。 + * @param deptId 部门Id。 + * @return 全部是返回true,否则false。 + */ + boolean existAllPrimaryKeys(Set deptPostIdSet, Long deptId); +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysRoleService.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysRoleService.java new file mode 100644 index 00000000..1f6762d7 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysRoleService.java @@ -0,0 +1,87 @@ +package com.orangeforms.webadmin.upms.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.webadmin.upms.model.SysRole; +import com.orangeforms.webadmin.upms.model.SysUserRole; + +import java.util.*; + +/** + * 角色数据服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysRoleService extends IBaseService { + + /** + * 保存新增的角色对象。 + * + * @param role 新增的角色对象。 + * @param menuIdSet 菜单Id列表。 + * @return 新增后的角色对象。 + */ + SysRole saveNew(SysRole role, Set menuIdSet); + + /** + * 更新角色对象。 + * + * @param role 更新的角色对象。 + * @param originalRole 原有的角色对象。 + * @param menuIdSet 菜单Id列表。 + * @return 更新成功返回true,否则false。 + */ + boolean update(SysRole role, SysRole originalRole, Set menuIdSet); + + /** + * 删除指定角色。 + * + * @param roleId 角色主键Id。 + * @return 删除成功返回true,否则false。 + */ + boolean remove(Long roleId); + + /** + * 获取角色列表。 + * + * @param filter 角色过滤对象。 + * @param orderBy 排序参数。 + * @return 角色列表。 + */ + List getSysRoleList(SysRole filter, String orderBy); + + /** + * 获取用户的用户角色对象列表。 + * + * @param userId 用户Id。 + * @return 用户角色对象列表。 + */ + List getSysUserRoleListByUserId(Long userId); + + /** + * 批量新增用户角色关联。 + * + * @param userRoleList 用户角色关系数据列表。 + */ + void addUserRoleList(List userRoleList); + + /** + * 移除指定用户和指定角色的关联关系。 + * + * @param roleId 角色主键Id。 + * @param userId 用户主键Id。 + * @return 移除成功返回true,否则false。 + */ + boolean removeUserRole(Long roleId, Long userId); + + /** + * 验证角色对象关联的数据是否都合法。 + * + * @param sysRole 当前操作的对象。 + * @param originalSysRole 原有对象。 + * @param menuIdListString 逗号分隔的menuId列表。 + * @return 验证结果。 + */ + CallResult verifyRelatedData(SysRole sysRole, SysRole originalSysRole, String menuIdListString); +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysUserService.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysUserService.java new file mode 100644 index 00000000..15fa2ea2 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysUserService.java @@ -0,0 +1,176 @@ +package com.orangeforms.webadmin.upms.service; + +import com.orangeforms.webadmin.upms.model.*; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.base.service.IBaseService; + +import java.util.*; + +/** + * 用户管理数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysUserService extends IBaseService { + + /** + * 获取指定登录名的用户对象。 + * + * @param loginName 指定登录用户名。 + * @return 用户对象。 + */ + SysUser getSysUserByLoginName(String loginName); + + /** + * 保存新增的用户对象。 + * + * @param user 新增的用户对象。 + * @param roleIdSet 用户角色Id集合。 + * @param deptPostIdSet 部门岗位Id集合。 + * @param dataPermIdSet 数据权限Id集合。 + * @return 新增后的用户对象。 + */ + SysUser saveNew(SysUser user, Set roleIdSet, Set deptPostIdSet, Set dataPermIdSet); + + /** + * 更新用户对象。 + * + * @param user 更新的用户对象。 + * @param originalUser 原有的用户对象。 + * @param roleIdSet 用户角色Id列表。 + * @param deptPostIdSet 部门岗位Id集合。 + * @param dataPermIdSet 数据权限Id集合。 + * @return 更新成功返回true,否则false。 + */ + boolean update(SysUser user, SysUser originalUser, Set roleIdSet, Set deptPostIdSet, Set dataPermIdSet); + + /** + * 修改用户密码。 + * @param userId 用户主键Id。 + * @param newPass 新密码。 + * @return 成功返回true,否则false。 + */ + boolean changePassword(Long userId, String newPass); + + /** + * 修改用户头像。 + * + * @param userId 用户主键Id。 + * @param newHeadImage 新的头像信息。 + * @return 成功返回true,否则false。 + */ + boolean changeHeadImage(Long userId, String newHeadImage); + + /** + * 删除指定数据。 + * + * @param userId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long userId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getSysUserListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getSysUserList(SysUser filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getSysUserList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getSysUserListWithRelation(SysUser filter, String orderBy); + + /** + * 获取指定角色的用户列表。 + * + * @param roleId 角色主键Id。 + * @param filter 用户过滤对象。 + * @param orderBy 排序参数。 + * @return 用户列表。 + */ + List getSysUserListByRoleId(Long roleId, SysUser filter, String orderBy); + + /** + * 获取不属于指定角色的用户列表。 + * + * @param roleId 角色主键Id。 + * @param filter 用户过滤对象。 + * @param orderBy 排序参数。 + * @return 用户列表。 + */ + List getNotInSysUserListByRoleId(Long roleId, SysUser filter, String orderBy); + + /** + * 获取指定数据权限的用户列表。 + * + * @param dataPermId 数据权限主键Id。 + * @param filter 用户过滤对象。 + * @param orderBy 排序参数。 + * @return 用户列表。 + */ + List getSysUserListByDataPermId(Long dataPermId, SysUser filter, String orderBy); + + /** + * 获取不属于指定数据权限的用户列表。 + * + * @param dataPermId 数据权限主键Id。 + * @param filter 用户过滤对象。 + * @param orderBy 排序参数。 + * @return 用户列表。 + */ + List getNotInSysUserListByDataPermId(Long dataPermId, SysUser filter, String orderBy); + + /** + * 获取指定部门岗位的用户列表。 + * + * @param deptPostId 部门岗位主键Id。 + * @param filter 用户过滤对象。 + * @param orderBy 排序参数。 + * @return 用户列表。 + */ + List getSysUserListByDeptPostId(Long deptPostId, SysUser filter, String orderBy); + + /** + * 获取不属于指定部门岗位的用户列表。 + * + * @param deptPostId 部门岗位主键Id。 + * @param filter 用户过滤对象。 + * @param orderBy 排序参数。 + * @return 用户列表。 + */ + List getNotInSysUserListByDeptPostId(Long deptPostId, SysUser filter, String orderBy); + + /** + * 获取指定岗位的用户列表。 + * + * @param postId 岗位主键Id。 + * @param filter 用户过滤对象。 + * @param orderBy 排序参数。 + * @return 用户列表。 + */ + List getSysUserListByPostId(Long postId, SysUser filter, String orderBy); + + /** + * 验证用户对象关联的数据是否都合法。 + * + * @param sysUser 当前操作的对象。 + * @param originalSysUser 原有对象。 + * @param roleIds 逗号分隔的角色Id列表字符串。 + * @param deptPostIds 逗号分隔的部门岗位Id列表字符串。 + * @param dataPermIds 逗号分隔的数据权限Id列表字符串。 + * @return 验证结果。 + */ + CallResult verifyRelatedData( + SysUser sysUser, SysUser originalSysUser, String roleIds, String deptPostIds, String dataPermIds); +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysDataPermServiceImpl.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysDataPermServiceImpl.java new file mode 100644 index 00000000..425a5606 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysDataPermServiceImpl.java @@ -0,0 +1,335 @@ +package com.orangeforms.webadmin.upms.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.mybatisflex.core.query.QueryWrapper; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.core.constant.DataPermRuleType; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.RedisKeyUtil; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.webadmin.config.ApplicationConfig; +import com.orangeforms.webadmin.upms.dao.SysDataPermDeptMapper; +import com.orangeforms.webadmin.upms.dao.SysDataPermMapper; +import com.orangeforms.webadmin.upms.dao.SysDataPermUserMapper; +import com.orangeforms.webadmin.upms.dao.SysDataPermMenuMapper; +import com.orangeforms.webadmin.upms.model.*; +import com.orangeforms.webadmin.upms.service.SysDataPermService; +import com.orangeforms.webadmin.upms.service.SysDeptService; +import com.orangeforms.webadmin.upms.service.SysMenuService; +import com.orangeforms.webadmin.upms.service.SysUserService; +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.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +/** + * 数据权限数据服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Service("sysDataPermService") +public class SysDataPermServiceImpl extends BaseService implements SysDataPermService { + + @Autowired + private SysDataPermMapper sysDataPermMapper; + @Autowired + private SysDataPermDeptMapper sysDataPermDeptMapper; + @Autowired + private SysDataPermUserMapper sysDataPermUserMapper; + @Autowired + private SysDataPermMenuMapper sysDataPermMenuMapper; + @Autowired + private SysUserService sysUserService; + @Autowired + private SysDeptService sysDeptService; + @Autowired + private SysMenuService sysMenuService; + @Autowired + private RedissonClient redissonClient; + @Autowired + private ApplicationConfig applicationConfig; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回主对象的Mapper对象。 + * + * @return 主对象的Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return sysDataPermMapper; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public SysDataPerm saveNew(SysDataPerm dataPerm, Set deptIdSet, Set menuIdSet) { + dataPerm.setDataPermId(idGenerator.nextLongId()); + MyModelUtil.fillCommonsForInsert(dataPerm); + sysDataPermMapper.insert(dataPerm); + this.insertRelationData(dataPerm, deptIdSet, menuIdSet); + return dataPerm; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update( + SysDataPerm dataPerm, SysDataPerm originalDataPerm, Set deptIdSet, Set menuIdSet) { + MyModelUtil.fillCommonsForUpdate(dataPerm, originalDataPerm); + if (sysDataPermMapper.update(dataPerm, false) != 1) { + return false; + } + sysDataPermDeptMapper.deleteByQuery( + new QueryWrapper().eq(SysDataPermDept::getDataPermId, dataPerm.getDataPermId())); + sysDataPermMenuMapper.deleteByQuery( + new QueryWrapper().eq(SysDataPermMenu::getDataPermId, dataPerm.getDataPermId())); + this.insertRelationData(dataPerm, deptIdSet, menuIdSet); + return true; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long dataPermId) { + if (sysDataPermMapper.deleteById(dataPermId) != 1) { + return false; + } + sysDataPermDeptMapper.deleteByQuery(new QueryWrapper().eq(SysDataPermDept::getDataPermId, dataPermId)); + sysDataPermUserMapper.deleteByQuery(new QueryWrapper().eq(SysDataPermUser::getDataPermId, dataPermId)); + sysDataPermMenuMapper.deleteByQuery(new QueryWrapper().eq(SysDataPermMenu::getDataPermId, dataPermId)); + return true; + } + + @Override + public List getSysDataPermListWithRelation(SysDataPerm filter, String orderBy) { + List resultList = sysDataPermMapper.getSysDataPermList(filter, orderBy); + buildRelationForDataList(resultList, MyRelationParam.full(), CollUtil.newHashSet("dataPermDeptList")); + return resultList; + } + + @Override + public void putDataPermCache(String sessionId, Long userId, Long deptId) { + Map> menuDataPermMap = getSysDataPermListByUserId(userId, deptId); + if (menuDataPermMap.size() > 0) { + String dataPermSessionKey = RedisKeyUtil.makeSessionDataPermIdKey(sessionId); + RBucket bucket = redissonClient.getBucket(dataPermSessionKey); + bucket.set(JSON.toJSONString(menuDataPermMap), + applicationConfig.getSessionExpiredSeconds(), TimeUnit.SECONDS); + } + } + + @Override + public void removeDataPermCache(String sessionId) { + String sessionPermKey = RedisKeyUtil.makeSessionDataPermIdKey(sessionId); + redissonClient.getBucket(sessionPermKey).deleteAsync(); + } + + @Override + public Map> getSysDataPermListByUserId(Long userId, Long deptId) { + List dataPermList = sysDataPermMapper.getSysDataPermListByUserId(userId); + dataPermList.forEach(dataPerm -> { + if (CollUtil.isNotEmpty(dataPerm.getDataPermDeptList())) { + Set deptIdSet = dataPerm.getDataPermDeptList().stream() + .map(SysDataPermDept::getDeptId).collect(Collectors.toSet()); + dataPerm.setDeptIdListString(StrUtil.join(",", deptIdSet)); + } + }); + Map> menuIdMap = new HashMap<>(4); + for (SysDataPerm dataPerm : dataPermList) { + if (CollUtil.isNotEmpty(dataPerm.getDataPermMenuList())) { + for (SysDataPermMenu dataPermMenu : dataPerm.getDataPermMenuList()) { + menuIdMap.computeIfAbsent( + dataPermMenu.getMenuId().toString(), k -> new LinkedList<>()).add(dataPerm); + } + } else { + menuIdMap.computeIfAbsent( + ApplicationConstant.DATA_PERM_ALL_MENU_ID, k -> new LinkedList<>()).add(dataPerm); + } + } + Map> menuResultMap = new HashMap<>(menuIdMap.size()); + for (Map.Entry> entry : menuIdMap.entrySet()) { + Map resultMap = this.mergeAndOptimizeDataPermRule(entry.getValue(), deptId); + menuResultMap.put(entry.getKey(), resultMap); + } + return menuResultMap; + } + + @Override + public List getSysDataPermListByMenuId(Long menuId) { + return sysDataPermMapper.getSysDataPermListByMenuId(menuId); + } + + private Map mergeAndOptimizeDataPermRule(List dataPermList, Long deptId) { + // 为了更方便进行后续的合并优化处理,这里再基于菜单Id和规则类型进行分组。ruleMap的key是规则类型。 + Map> ruleMap = + dataPermList.stream().collect(Collectors.groupingBy(SysDataPerm::getRuleType)); + Map resultMap = new HashMap<>(ruleMap.size()); + // 如有有ALL存在,就可以直接退出了,没有必要在处理后续的规则了。 + if (ruleMap.containsKey(DataPermRuleType.TYPE_ALL)) { + resultMap.put(DataPermRuleType.TYPE_ALL, "null"); + return resultMap; + } + // 这里优先合并最复杂的多部门及子部门场景。 + String deptIds = processMultiDeptAndChildren(ruleMap, deptId); + if (deptIds != null) { + resultMap.put(DataPermRuleType.TYPE_MULTI_DEPT_AND_CHILD_DEPT, deptIds); + } + // 合并当前部门及子部门的优化 + if (ruleMap.get(DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT) != null) { + // 需要与仅仅当前部门规则进行合并。 + ruleMap.remove(DataPermRuleType.TYPE_DEPT_ONLY); + resultMap.put(DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT, "null"); + } + // 合并自定义部门了。 + deptIds = processMultiDept(ruleMap, deptId); + if (deptIds != null) { + resultMap.put(DataPermRuleType.TYPE_CUSTOM_DEPT_LIST, deptIds); + } + // 最后处理当前部门和当前用户。 + if (ruleMap.get(DataPermRuleType.TYPE_DEPT_ONLY) != null) { + resultMap.put(DataPermRuleType.TYPE_DEPT_ONLY, "null"); + } + if (ruleMap.get(DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT_USERS) != null) { + // 合并当前部门用户和当前用户 + ruleMap.remove(DataPermRuleType.TYPE_USER_ONLY); + ruleMap.remove(DataPermRuleType.TYPE_DEPT_USERS); + SysUser filter = new SysUser(); + filter.setDeptId(deptId); + List userList = sysUserService.getSysUserList(filter, null); + Set userIdSet = userList.stream().map(SysUser::getUserId).collect(Collectors.toSet()); + resultMap.put(DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT_USERS, CollUtil.join(userIdSet, ",")); + } + if (ruleMap.get(DataPermRuleType.TYPE_DEPT_USERS) != null) { + SysUser filter = new SysUser(); + filter.setDeptId(deptId); + List userList = sysUserService.getListByFilter(filter); + Set userIdSet = userList.stream().map(SysUser::getUserId).collect(Collectors.toSet()); + // 合并仅当前用户 + ruleMap.remove(DataPermRuleType.TYPE_USER_ONLY); + resultMap.put(DataPermRuleType.TYPE_DEPT_USERS, CollUtil.join(userIdSet, ",")); + } + if (ruleMap.get(DataPermRuleType.TYPE_USER_ONLY) != null) { + resultMap.put(DataPermRuleType.TYPE_USER_ONLY, "null"); + } + return resultMap; + } + + private String processMultiDeptAndChildren(Map> ruleMap, Long deptId) { + List parentDeptList = ruleMap.get(DataPermRuleType.TYPE_MULTI_DEPT_AND_CHILD_DEPT); + if (parentDeptList == null) { + return null; + } + Set deptIdSet = new HashSet<>(); + for (SysDataPerm parentDept : parentDeptList) { + deptIdSet.addAll(StrUtil.split(parentDept.getDeptIdListString(), ',') + .stream().map(Long::valueOf).collect(Collectors.toSet())); + } + // 在合并所有的多父部门Id之后,需要判断是否有本部门及子部门的规则。如果有,就继续合并。 + if (ruleMap.containsKey(DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT)) { + // 如果多父部门列表中包含当前部门,那么可以直接删除该规则了,如果没包含,就加入到多部门的DEPT_ID的IN LIST中。 + deptIdSet.add(deptId); + ruleMap.remove(DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT); + } + // 需要与仅仅当前部门规则进行合并。 + if (ruleMap.containsKey(DataPermRuleType.TYPE_DEPT_ONLY) && deptIdSet.contains(deptId)) { + ruleMap.remove(DataPermRuleType.TYPE_DEPT_ONLY); + } + return StrUtil.join(",", deptIdSet); + } + + private String processMultiDept(Map> ruleMap, Long deptId) { + List customDeptList = ruleMap.get(DataPermRuleType.TYPE_CUSTOM_DEPT_LIST); + if (customDeptList == null) { + return null; + } + Set deptIdSet = new HashSet<>(); + for (SysDataPerm customDept : customDeptList) { + deptIdSet.addAll(StrUtil.split(customDept.getDeptIdListString(), ',') + .stream().map(Long::valueOf).collect(Collectors.toSet())); + } + if (ruleMap.containsKey(DataPermRuleType.TYPE_DEPT_ONLY)) { + deptIdSet.add(deptId); + ruleMap.remove(DataPermRuleType.TYPE_DEPT_ONLY); + } + return StrUtil.join(",", deptIdSet); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void addDataPermUserList(Long dataPermId, Set userIdSet) { + for (Long userId : userIdSet) { + SysDataPermUser dataPermUser = new SysDataPermUser(); + dataPermUser.setDataPermId(dataPermId); + dataPermUser.setUserId(userId); + sysDataPermUserMapper.insert(dataPermUser); + } + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean removeDataPermUser(Long dataPermId, Long userId) { + SysDataPermUser dataPermUser = new SysDataPermUser(); + dataPermUser.setDataPermId(dataPermId); + dataPermUser.setUserId(userId); + return sysDataPermUserMapper.deleteByQuery(QueryWrapper.create(dataPermUser)) == 1; + } + + @Override + public CallResult verifyRelatedData(SysDataPerm dataPerm, String deptIdListString, String menuIdListString) { + JSONObject jsonObject = new JSONObject(); + if (dataPerm.getRuleType() == DataPermRuleType.TYPE_MULTI_DEPT_AND_CHILD_DEPT + || dataPerm.getRuleType() == DataPermRuleType.TYPE_CUSTOM_DEPT_LIST) { + if (StrUtil.isBlank(deptIdListString)) { + return CallResult.error("数据验证失败,部门列表不能为空!"); + } + Set deptIdSet = StrUtil.split( + deptIdListString, ",").stream().map(Long::valueOf).collect(Collectors.toSet()); + if (!sysDeptService.existAllPrimaryKeys(deptIdSet)) { + return CallResult.error("数据验证失败,存在不合法的部门数据,请刷新后重试!"); + } + jsonObject.put("deptIdSet", deptIdSet); + } + if (StrUtil.isNotBlank(menuIdListString)) { + Set menuIdSet = StrUtil.split( + menuIdListString, ",").stream().map(Long::valueOf).collect(Collectors.toSet()); + if (!sysMenuService.existAllPrimaryKeys(menuIdSet)) { + return CallResult.error("数据验证失败,存在不合法的菜单数据,请刷新后重试!"); + } + jsonObject.put("menuIdSet", menuIdSet); + } + return CallResult.ok(jsonObject); + } + + private void insertRelationData(SysDataPerm dataPerm, Set deptIdSet, Set menuIdSet) { + if (CollUtil.isNotEmpty(deptIdSet)) { + for (Long deptId : deptIdSet) { + SysDataPermDept dataPermDept = new SysDataPermDept(); + dataPermDept.setDataPermId(dataPerm.getDataPermId()); + dataPermDept.setDeptId(deptId); + sysDataPermDeptMapper.insert(dataPermDept); + } + } + if (CollUtil.isNotEmpty(menuIdSet)) { + for (Long menuId : menuIdSet) { + SysDataPermMenu dataPermMenu = new SysDataPermMenu(); + dataPermMenu.setDataPermId(dataPerm.getDataPermId()); + dataPermMenu.setMenuId(menuId); + sysDataPermMenuMapper.insert(dataPermMenu); + } + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysDeptServiceImpl.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysDeptServiceImpl.java new file mode 100644 index 00000000..3f30f41d --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysDeptServiceImpl.java @@ -0,0 +1,312 @@ +package com.orangeforms.webadmin.upms.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.core.util.ObjectUtil; +import com.mybatisflex.core.query.QueryWrapper; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.webadmin.upms.service.*; +import com.orangeforms.webadmin.upms.dao.*; +import com.orangeforms.webadmin.upms.model.*; +import com.orangeforms.common.ext.util.BizWidgetDatasourceExtHelper; +import com.orangeforms.common.ext.base.BizWidgetDatasource; +import com.orangeforms.common.ext.constant.BizWidgetDatasourceType; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.constant.GlobalDeletedFlag; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.github.pagehelper.Page; +import lombok.extern.slf4j.Slf4j; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import jakarta.annotation.PostConstruct; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 部门管理数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Service("sysDeptService") +public class SysDeptServiceImpl extends BaseService implements SysDeptService, BizWidgetDatasource { + + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private SysDeptMapper sysDeptMapper; + @Autowired + private SysDeptRelationMapper sysDeptRelationMapper; + @Autowired + private SysUserService sysUserService; + @Autowired + private SysDeptPostMapper sysDeptPostMapper; + @Autowired + private SysDataPermDeptMapper sysDataPermDeptMapper; + @Autowired + private BizWidgetDatasourceExtHelper bizWidgetDatasourceExtHelper; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return sysDeptMapper; + } + + @PostConstruct + private void registerBizWidgetDatasource() { + bizWidgetDatasourceExtHelper.registerDatasource(BizWidgetDatasourceType.UPMS_DEPT_TYPE, this); + } + + @Override + public MyPageData> getDataList( + String type, Map filter, MyOrderParam orderParam, MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount()); + } + String orderBy = orderParam == null ? null : MyOrderParam.buildOrderBy(orderParam, SysDept.class); + SysDept deptFilter = filter == null ? null : BeanUtil.toBean(filter, SysDept.class); + List deptList = this.getSysDeptList(deptFilter, orderBy); + this.buildRelationForDataList(deptList, MyRelationParam.dictOnly()); + return MyPageUtil.makeResponseData(deptList, BeanUtil::beanToMap); + } + + @Override + public List> getDataListWithInList(String type, String fieldName, List fieldValues) { + List deptList; + if (StrUtil.isBlank(fieldName)) { + deptList = this.getInList(fieldValues.stream().map(Long::valueOf).collect(Collectors.toSet())); + } else { + deptList = this.getInList(fieldName, MyModelUtil.convertToTypeValues(SysDept.class, fieldName, fieldValues)); + } + this.buildRelationForDataList(deptList, MyRelationParam.dictOnly()); + return MyModelUtil.beanToMapList(deptList); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public SysDept saveNew(SysDept sysDept, SysDept parentSysDept) { + sysDept.setDeptId(idGenerator.nextLongId()); + sysDept.setDeletedFlag(GlobalDeletedFlag.NORMAL); + MyModelUtil.fillCommonsForInsert(sysDept); + sysDeptMapper.insert(sysDept); + // 同步插入部门关联关系数据 + if (parentSysDept == null) { + sysDeptRelationMapper.insert(new SysDeptRelation(sysDept.getDeptId(), sysDept.getDeptId())); + } else { + sysDeptRelationMapper.insertParentList(parentSysDept.getDeptId(), sysDept.getDeptId()); + } + return sysDept; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(SysDept sysDept, SysDept originalSysDept) { + MyModelUtil.fillCommonsForUpdate(sysDept, originalSysDept); + sysDept.setDeletedFlag(GlobalDeletedFlag.NORMAL); + if (sysDeptMapper.update(sysDept, false) == 0) { + return false; + } + if (ObjectUtil.notEqual(sysDept.getParentId(), originalSysDept.getParentId())) { + this.updateParentRelation(sysDept, originalSysDept); + } + return true; + } + + private void updateParentRelation(SysDept sysDept, SysDept originalSysDept) { + List originalParentIdList = null; + // 1. 因为层级关系变化了,所以要先遍历出,当前部门的原有父部门Id列表。 + if (originalSysDept.getParentId() != null) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(SysDeptRelation::getDeptId, sysDept.getDeptId()); + List relationList = sysDeptRelationMapper.selectListByQuery(queryWrapper); + originalParentIdList = relationList.stream() + .filter(c -> !c.getParentDeptId().equals(sysDept.getDeptId())) + .map(SysDeptRelation::getParentDeptId).collect(Collectors.toList()); + } + // 2. 毕竟当前部门的上级部门变化了,所以当前部门和他的所有子部门,与当前部门的原有所有上级部门 + // 之间的关联关系就要被移除。 + // 这里先移除当前部门的所有子部门,与当前部门的所有原有上级部门之间的关联关系。 + if (CollUtil.isNotEmpty(originalParentIdList)) { + sysDeptRelationMapper.removeBetweenChildrenAndParents(originalParentIdList, sysDept.getDeptId()); + } + // 这里更进一步,将当前部门Id与其原有所有上级部门Id之间的关联关系删除。 + SysDeptRelation filter = new SysDeptRelation(); + filter.setDeptId(sysDept.getDeptId()); + sysDeptRelationMapper.deleteByQuery(QueryWrapper.create(filter)); + // 3. 重新计算当前部门的新上级部门列表。 + List newParentIdList = new LinkedList<>(); + // 这里要重新计算出当前部门所有新的上级部门Id列表。 + if (sysDept.getParentId() != null) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(SysDeptRelation::getDeptId, sysDept.getParentId()); + List relationList = sysDeptRelationMapper.selectListByQuery(queryWrapper); + newParentIdList = relationList.stream() + .map(SysDeptRelation::getParentDeptId).collect(Collectors.toList()); + } + // 4. 先查询出当前部门的所有下级子部门Id列表。 + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(SysDeptRelation::getParentDeptId, sysDept.getDeptId()); + List childRelationList = sysDeptRelationMapper.selectListByQuery(queryWrapper); + // 5. 将当前部门及其所有子部门Id与其新的所有上级部门Id之间,建立关联关系。 + List deptRelationList = new LinkedList<>(); + deptRelationList.add(new SysDeptRelation(sysDept.getDeptId(), sysDept.getDeptId())); + for (Long newParentId : newParentIdList) { + deptRelationList.add(new SysDeptRelation(newParentId, sysDept.getDeptId())); + for (SysDeptRelation childDeptRelation : childRelationList) { + deptRelationList.add(new SysDeptRelation(newParentId, childDeptRelation.getDeptId())); + } + } + // 6. 执行批量插入SQL语句,插入当前部门Id及其所有下级子部门Id,与所有新上级部门Id之间的关联关系。 + sysDeptRelationMapper.insertList(deptRelationList); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long deptId) { + if (sysDeptMapper.deleteById(deptId) == 0) { + return false; + } + // 这里删除当前部门及其父部门的关联关系。 + // 当前部门和子部门的关系无需在这里删除,因为包含子部门时不能删除父部门。 + SysDeptRelation deptRelation = new SysDeptRelation(); + deptRelation.setDeptId(deptId); + sysDeptRelationMapper.deleteByQuery(QueryWrapper.create(deptRelation)); + SysDataPermDept dataPermDept = new SysDataPermDept(); + dataPermDept.setDeptId(deptId); + sysDataPermDeptMapper.deleteByQuery(QueryWrapper.create(dataPermDept)); + return true; + } + + @Override + public List getSysDeptList(SysDept filter, String orderBy) { + return sysDeptMapper.getSysDeptList(filter, orderBy); + } + + @Override + public List getSysDeptListWithRelation(SysDept filter, String orderBy) { + List resultList = sysDeptMapper.getSysDeptList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + @Override + public boolean hasChildren(Long deptId) { + SysDept filter = new SysDept(); + filter.setParentId(deptId); + return getCountByFilter(filter) > 0; + } + + @Override + public boolean hasChildrenUser(Long deptId) { + SysUser sysUser = new SysUser(); + sysUser.setDeptId(deptId); + return sysUserService.getCountByFilter(sysUser) > 0; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void addSysDeptPostList(List sysDeptPostList, Long deptId) { + for (SysDeptPost sysDeptPost : sysDeptPostList) { + sysDeptPost.setDeptPostId(idGenerator.nextLongId()); + sysDeptPost.setDeptId(deptId); + sysDeptPostMapper.insert(sysDeptPost); + } + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean updateSysDeptPost(SysDeptPost sysDeptPost) { + SysDeptPost filter = new SysDeptPost(); + filter.setDeptPostId(sysDeptPost.getDeptPostId()); + filter.setDeptId(sysDeptPost.getDeptId()); + filter.setPostId(sysDeptPost.getPostId()); + return sysDeptPostMapper.updateByQuery(sysDeptPost, false, QueryWrapper.create(filter)) > 0; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean removeSysDeptPost(Long deptId, Long postId) { + SysDeptPost filter = new SysDeptPost(); + filter.setDeptId(deptId); + filter.setPostId(postId); + return sysDeptPostMapper.deleteByQuery(QueryWrapper.create(filter)) > 0; + } + + @Override + public SysDeptPost getSysDeptPost(Long deptId, Long postId) { + SysDeptPost filter = new SysDeptPost(); + filter.setDeptId(deptId); + filter.setPostId(postId); + return sysDeptPostMapper.selectOneByQuery(QueryWrapper.create(filter)); + } + + @Override + public SysDeptPost getSysDeptPost(Long deptPostId) { + return sysDeptPostMapper.selectOneById(deptPostId); + } + + @Override + public List> getSysDeptPostListWithRelationByDeptId(Long deptId) { + return sysDeptPostMapper.getSysDeptPostListWithRelationByDeptId(deptId); + } + + @Override + public List getSysDeptPostList(Long deptId, Set postIdSet) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(SysDeptPost::getDeptId, deptId); + queryWrapper.in(SysDeptPost::getPostId, postIdSet); + return sysDeptPostMapper.selectListByQuery(queryWrapper); + } + + @Override + public List getSiblingSysDeptPostList(Long deptId, Set postIdSet) { + SysDept sysDept = this.getById(deptId); + if (sysDept == null) { + return new LinkedList<>(); + } + List deptList = this.getListByParentId("parentId", sysDept.getParentId()); + Set deptIdSet = deptList.stream().map(SysDept::getDeptId).collect(Collectors.toSet()); + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.in(SysDeptPost::getDeptId, deptIdSet); + queryWrapper.in(SysDeptPost::getPostId, postIdSet); + return sysDeptPostMapper.selectListByQuery(queryWrapper); + } + + @Override + public List getLeaderDeptPostIdList(Long deptId) { + List resultList = sysDeptPostMapper.getLeaderDeptPostList(deptId); + return resultList.stream().map(SysDeptPost::getDeptPostId).collect(Collectors.toList()); + } + + @Override + public List getUpLeaderDeptPostIdList(Long deptId) { + SysDept sysDept = this.getById(deptId); + if (sysDept.getParentId() == null) { + return new LinkedList<>(); + } + return this.getLeaderDeptPostIdList(sysDept.getParentId()); + } + + @Override + public List getAllChildDeptIdByParentIds(List parentIds) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.in(SysDeptRelation::getParentDeptId, parentIds); + return sysDeptRelationMapper.selectListByQuery(queryWrapper) + .stream().map(SysDeptRelation::getDeptId).collect(Collectors.toList()); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysMenuServiceImpl.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysMenuServiceImpl.java new file mode 100644 index 00000000..de7f99d3 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysMenuServiceImpl.java @@ -0,0 +1,233 @@ +package com.orangeforms.webadmin.upms.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.mybatisflex.core.query.QueryWrapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.webadmin.upms.bo.SysMenuExtraData; +import com.orangeforms.webadmin.upms.dao.SysMenuMapper; +import com.orangeforms.webadmin.upms.dao.SysRoleMenuMapper; +import com.orangeforms.webadmin.upms.model.SysMenu; +import com.orangeforms.webadmin.upms.model.SysRoleMenu; +import com.orangeforms.webadmin.upms.model.constant.SysMenuType; +import com.orangeforms.webadmin.upms.model.constant.SysOnlineMenuPermType; +import com.orangeforms.webadmin.upms.service.SysMenuService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 菜单数据服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Service("sysMenuService") +public class SysMenuServiceImpl extends BaseService implements SysMenuService { + + @Autowired + private SysMenuMapper sysMenuMapper; + @Autowired + private SysRoleMenuMapper sysRoleMenuMapper; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回主对象的Mapper对象。 + * + * @return 主对象的Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return sysMenuMapper; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public SysMenu saveNew(SysMenu sysMenu) { + sysMenu.setMenuId(idGenerator.nextLongId()); + MyModelUtil.fillCommonsForInsert(sysMenu); + sysMenuMapper.insert(sysMenu); + // 判断当前菜单是否为指向在线表单的菜单,并将根据约定,动态插入两个子菜单。 + if (sysMenu.getOnlineFormId() != null && sysMenu.getOnlineFlowEntryId() == null) { + SysMenu viewSubMenu = new SysMenu(); + viewSubMenu.setMenuId(idGenerator.nextLongId()); + viewSubMenu.setParentId(sysMenu.getMenuId()); + viewSubMenu.setMenuType(SysMenuType.TYPE_BUTTON); + viewSubMenu.setMenuName("查看"); + viewSubMenu.setShowOrder(0); + viewSubMenu.setOnlineFormId(sysMenu.getOnlineFormId()); + viewSubMenu.setOnlineMenuPermType(SysOnlineMenuPermType.TYPE_VIEW); + MyModelUtil.fillCommonsForInsert(viewSubMenu); + sysMenuMapper.insert(viewSubMenu); + SysMenu editSubMenu = new SysMenu(); + editSubMenu.setMenuId(idGenerator.nextLongId()); + editSubMenu.setParentId(sysMenu.getMenuId()); + editSubMenu.setMenuType(SysMenuType.TYPE_BUTTON); + editSubMenu.setMenuName("编辑"); + editSubMenu.setShowOrder(1); + editSubMenu.setOnlineFormId(sysMenu.getOnlineFormId()); + editSubMenu.setOnlineMenuPermType(SysOnlineMenuPermType.TYPE_EDIT); + MyModelUtil.fillCommonsForInsert(editSubMenu); + sysMenuMapper.insert(editSubMenu); + } + return sysMenu; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(SysMenu sysMenu, SysMenu originalSysMenu) { + MyModelUtil.fillCommonsForUpdate(sysMenu, originalSysMenu); + sysMenu.setMenuType(originalSysMenu.getMenuType()); + if (sysMenuMapper.update(sysMenu, false) != 1) { + return false; + } + // 如果当前菜单的在线表单Id变化了,就需要同步更新他的内置子菜单也同步更新。 + if (ObjectUtil.notEqual(originalSysMenu.getOnlineFormId(), sysMenu.getOnlineFormId())) { + SysMenu onlineSubMenu = new SysMenu(); + onlineSubMenu.setOnlineFormId(sysMenu.getOnlineFormId()); + sysMenuMapper.updateByQuery(onlineSubMenu, + new QueryWrapper().eq(SysMenu::getParentId, sysMenu.getMenuId())); + } + return true; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(SysMenu menu) { + Long menuId = menu.getMenuId(); + if (sysMenuMapper.deleteByQuery(new QueryWrapper().eq(SysMenu::getMenuId, menuId)) != 1) { + return false; + } + SysRoleMenu roleMenu = new SysRoleMenu(); + roleMenu.setMenuId(menuId); + sysRoleMenuMapper.deleteByQuery(QueryWrapper.create(roleMenu)); + // 如果为指向在线表单的菜单,则连同删除子菜单 + if (menu.getOnlineFormId() != null) { + SysMenu filter = new SysMenu(); + filter.setParentId(menuId); + List childMenus = sysMenuMapper.selectListByQuery(QueryWrapper.create(filter)); + sysMenuMapper.deleteByQuery(new QueryWrapper().eq(SysMenu::getParentId, menuId)); + if (CollUtil.isNotEmpty(childMenus)) { + List childMenuIds = childMenus.stream().map(SysMenu::getMenuId).collect(Collectors.toList()); + sysRoleMenuMapper.deleteByQuery(new QueryWrapper().in(SysRoleMenu::getMenuId, childMenuIds)); + } + } + return true; + } + + @Override + public Collection getMenuListByUserId(Long userId) { + List menuList = sysMenuMapper.getMenuListByUserId(userId); + return this.distinctMenuList(menuList); + } + + @Override + public Collection getMenuListByRoleIds(String roleIds) { + if (StrUtil.isBlank(roleIds)) { + return CollUtil.empty(Long.class); + } + Set roleIdSet = StrUtil.split(roleIds, ",").stream().map(Long::valueOf).collect(Collectors.toSet()); + List menuList = sysMenuMapper.getMenuListByRoleIds(roleIdSet); + return this.distinctMenuList(menuList); + } + + @Override + public boolean hasChildren(Long menuId) { + SysMenu menu = new SysMenu(); + menu.setParentId(menuId); + return this.getCountByFilter(menu) > 0; + } + + @Override + public CallResult verifyRelatedData(SysMenu sysMenu, SysMenu originalSysMenu) { + // menu、ui fragment和button类型的menu不能没有parentId + if (sysMenu.getParentId() == null && sysMenu.getMenuType() != SysMenuType.TYPE_DIRECTORY) { + return CallResult.error("数据验证失败,当前类型菜单项的上级菜单不能为空!"); + } + if (this.needToVerify(sysMenu, originalSysMenu, SysMenu::getParentId)) { + String errorMessage = checkErrorOfNonDirectoryMenu(sysMenu); + if (errorMessage != null) { + return CallResult.error(errorMessage); + } + } + if (!this.verifyMenuCode(sysMenu, originalSysMenu)) { + return CallResult.error("数据验证失败,菜单编码已存在,不能重复使用!"); + } + return CallResult.ok(); + } + + @Override + public List getAllOnlineMenuList(Integer menuType) { + QueryWrapper queryWrapper = new QueryWrapper().isNotNull(SysMenu::getOnlineFormId); + if (menuType != null) { + queryWrapper.eq(SysMenu::getMenuType, menuType); + } + return sysMenuMapper.selectListByQuery(queryWrapper); + } + + private boolean verifyMenuCode(SysMenu sysMenu, SysMenu originalSysMenu) { + if (sysMenu.getExtraData() == null) { + return true; + } + String menuCode = JSON.parseObject(sysMenu.getExtraData(), SysMenuExtraData.class).getMenuCode(); + if (StrUtil.isBlank(menuCode)) { + return true; + } + String originalMenuCode = ""; + if (originalSysMenu != null && originalSysMenu.getExtraData() != null) { + originalMenuCode = JSON.parseObject(originalSysMenu.getExtraData(), SysMenuExtraData.class).getMenuCode(); + } + return StrUtil.equals(menuCode, originalMenuCode) + || sysMenuMapper.countMenuCode("\"menuCode\":\"" + menuCode + "\"") == 0; + } + + private String checkErrorOfNonDirectoryMenu(SysMenu sysMenu) { + // 判断父节点是否存在 + SysMenu parentSysMenu = getById(sysMenu.getParentId()); + if (parentSysMenu == null) { + return "数据验证失败,关联的上级菜单并不存在,请刷新后重试!"; + } + // 逐个判断每种类型的菜单,他的父菜单的合法性,先从目录类型和菜单类型开始 + if (sysMenu.getMenuType() == SysMenuType.TYPE_DIRECTORY + || sysMenu.getMenuType() == SysMenuType.TYPE_MENU) { + // 他们的上级只能是目录 + if (parentSysMenu.getMenuType() != SysMenuType.TYPE_DIRECTORY) { + return "数据验证失败,当前类型菜单项的上级菜单只能是目录类型!"; + } + } else if (sysMenu.getMenuType() == SysMenuType.TYPE_UI_FRAGMENT) { + // ui fragment的上级只能是menu类型 + if (parentSysMenu.getMenuType() != SysMenuType.TYPE_MENU) { + return "数据验证失败,当前类型菜单项的上级菜单只能是菜单类型和按钮类型!"; + } + } else if (sysMenu.getMenuType() == SysMenuType.TYPE_BUTTON) { + // button的上级只能是menu和ui fragment + if (parentSysMenu.getMenuType() != SysMenuType.TYPE_MENU + && parentSysMenu.getMenuType() != SysMenuType.TYPE_UI_FRAGMENT) { + return "数据验证失败,当前类型菜单项的上级菜单只能是菜单类型和UI片段类型!"; + } + } else { + return "数据验证失败,不支持的菜单类型!"; + } + return null; + } + + private Collection distinctMenuList(List menuList) { + LinkedHashMap menuMap = new LinkedHashMap<>(); + for (SysMenu menu : menuList) { + menuMap.put(menu.getMenuId(), menu); + } + return menuMap.values(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysPermWhitelistServiceImpl.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysPermWhitelistServiceImpl.java new file mode 100644 index 00000000..69c4abb6 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysPermWhitelistServiceImpl.java @@ -0,0 +1,47 @@ +package com.orangeforms.webadmin.upms.service.impl; + +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.webadmin.upms.dao.SysPermWhitelistMapper; +import com.orangeforms.webadmin.upms.model.SysPermWhitelist; +import com.orangeforms.webadmin.upms.service.SysPermWhitelistService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 权限资源白名单数据服务类。 + * 白名单中的权限资源,可以不受权限控制,任何用户皆可访问,一般用于常用的字典数据列表接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Service("sysPermWhitelistService") +public class SysPermWhitelistServiceImpl extends BaseService implements SysPermWhitelistService { + + @Autowired + private SysPermWhitelistMapper sysPermWhitelistMapper; + + /** + * 返回主对象的Mapper对象。 + * + * @return 主对象的Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return sysPermWhitelistMapper; + } + + @Override + public List getWhitelistPermList() { + List dataList = this.getAllList(); + Function getterFunc = SysPermWhitelist::getPermUrl; + return dataList.stream() + .filter(x -> getterFunc.apply(x) != null).map(getterFunc).collect(Collectors.toList()); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysPostServiceImpl.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysPostServiceImpl.java new file mode 100644 index 00000000..67ce78a7 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysPostServiceImpl.java @@ -0,0 +1,177 @@ +package com.orangeforms.webadmin.upms.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.StrUtil; +import com.mybatisflex.core.query.QueryWrapper; +import com.github.pagehelper.Page; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.object.MyOrderParam; +import com.orangeforms.common.core.object.MyPageData; +import com.orangeforms.common.core.object.MyPageParam; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.ext.base.BizWidgetDatasource; +import com.orangeforms.common.ext.constant.BizWidgetDatasourceType; +import com.orangeforms.common.ext.util.BizWidgetDatasourceExtHelper; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.webadmin.upms.dao.SysDeptPostMapper; +import com.orangeforms.webadmin.upms.dao.SysPostMapper; +import com.orangeforms.webadmin.upms.dao.SysUserPostMapper; +import com.orangeforms.webadmin.upms.model.SysDeptPost; +import com.orangeforms.webadmin.upms.model.SysPost; +import com.orangeforms.webadmin.upms.model.SysUserPost; +import com.orangeforms.webadmin.upms.service.SysDeptService; +import com.orangeforms.webadmin.upms.service.SysPostService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.Assert; + +import jakarta.annotation.PostConstruct; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 岗位管理数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Service("sysPostService") +public class SysPostServiceImpl extends BaseService implements SysPostService, BizWidgetDatasource { + + @Autowired + private SysPostMapper sysPostMapper; + @Autowired + private SysUserPostMapper sysUserPostMapper; + @Autowired + private SysDeptPostMapper sysDeptPostMapper; + @Autowired + private SysDeptService sysDeptService; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private BizWidgetDatasourceExtHelper bizWidgetDatasourceExtHelper; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return sysPostMapper; + } + + @PostConstruct + private void registerBizWidgetDatasource() { + bizWidgetDatasourceExtHelper.registerDatasource(BizWidgetDatasourceType.UPMS_POST_TYPE, this); + bizWidgetDatasourceExtHelper.registerDatasource(BizWidgetDatasourceType.UPMS_DEPT_POST_TYPE, this); + } + + @Override + public MyPageData> getDataList( + String type, Map filter, MyOrderParam orderParam, MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount()); + } + String orderBy = orderParam == null ? null : MyOrderParam.buildOrderBy(orderParam, SysPost.class); + SysPost postFilter = filter == null ? null : BeanUtil.toBean(filter, SysPost.class); + if (StrUtil.equals(type, BizWidgetDatasourceType.UPMS_POST_TYPE)) { + List postList = this.getSysPostList(postFilter, orderBy); + return MyPageUtil.makeResponseData(postList, BeanUtil::beanToMap); + } + Assert.notNull(filter, "filter can't be NULL."); + Long deptId = (Long) filter.get("deptId"); + List> dataList = sysDeptService.getSysDeptPostListWithRelationByDeptId(deptId); + return MyPageUtil.makeResponseData(dataList); + } + + @Override + public List> getDataListWithInList(String type, String fieldName, List fieldValues) { + List postList; + if (StrUtil.isBlank(fieldName)) { + postList = this.getInList(fieldValues.stream().map(Long::valueOf).collect(Collectors.toSet())); + } else { + postList = this.getInList(fieldName, MyModelUtil.convertToTypeValues(SysPost.class, fieldName, fieldValues)); + } + return MyModelUtil.beanToMapList(postList); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public SysPost saveNew(SysPost sysPost) { + sysPost.setPostId(idGenerator.nextLongId()); + MyModelUtil.fillCommonsForInsert(sysPost); + MyModelUtil.setDefaultValue(sysPost, "leaderPost", false); + sysPostMapper.insert(sysPost); + return sysPost; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(SysPost sysPost, SysPost originalSysPost) { + MyModelUtil.fillCommonsForUpdate(sysPost, originalSysPost); + // 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。 + return sysPostMapper.update(sysPost, false) == 1; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long postId) { + if (sysPostMapper.deleteById(postId) != 1) { + return false; + } + // 开始删除多对多父表的关联 + sysUserPostMapper.deleteByQuery(new QueryWrapper().eq(SysUserPost::getPostId, postId)); + sysDeptPostMapper.deleteByQuery(new QueryWrapper().eq(SysDeptPost::getPostId, postId)); + return true; + } + + @Override + public List getSysPostList(SysPost filter, String orderBy) { + return sysPostMapper.getSysPostList(filter, orderBy); + } + + @Override + public List getSysPostListWithRelation(SysPost filter, String orderBy) { + List resultList = sysPostMapper.getSysPostList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + @Override + public List getNotInSysPostListByDeptId(Long deptId, SysPost filter, String orderBy) { + List resultList = sysPostMapper.getNotInSysPostListByDeptId(deptId, filter, orderBy); + this.buildRelationForDataList(resultList, MyRelationParam.dictOnly()); + return resultList; + } + + @Override + public List getSysPostListByDeptId(Long deptId, SysPost filter, String orderBy) { + List resultList = sysPostMapper.getSysPostListByDeptId(deptId, filter, orderBy); + this.buildRelationForDataList(resultList, MyRelationParam.dictOnly()); + return resultList; + } + + @Override + public List getSysUserPostListByUserId(Long userId) { + return sysUserPostMapper.selectListByQuery(new QueryWrapper().eq(SysUserPost::getUserId, userId)); + } + + @Override + public boolean existAllPrimaryKeys(Set deptPostIdSet, Long deptId) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(SysDeptPost::getDeptId, deptId); + queryWrapper.in(SysDeptPost::getDeptPostId, deptPostIdSet); + return sysDeptPostMapper.selectCountByQuery(queryWrapper) == deptPostIdSet.size(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysRoleServiceImpl.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysRoleServiceImpl.java new file mode 100644 index 00000000..fc0d25b0 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysRoleServiceImpl.java @@ -0,0 +1,188 @@ +package com.orangeforms.webadmin.upms.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.StrUtil; +import com.mybatisflex.core.query.QueryWrapper; +import com.alibaba.fastjson.JSONObject; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.ext.base.BizWidgetDatasource; +import com.orangeforms.common.ext.constant.BizWidgetDatasourceType; +import com.orangeforms.common.ext.util.BizWidgetDatasourceExtHelper; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.webadmin.upms.dao.SysRoleMapper; +import com.orangeforms.webadmin.upms.dao.SysRoleMenuMapper; +import com.orangeforms.webadmin.upms.dao.SysUserRoleMapper; +import com.orangeforms.webadmin.upms.model.SysRole; +import com.orangeforms.webadmin.upms.model.SysRoleMenu; +import com.orangeforms.webadmin.upms.model.SysUserRole; +import com.orangeforms.webadmin.upms.service.SysMenuService; +import com.orangeforms.webadmin.upms.service.SysRoleService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import jakarta.annotation.PostConstruct; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 角色数据服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Service("sysRoleService") +public class SysRoleServiceImpl extends BaseService implements SysRoleService, BizWidgetDatasource { + + @Autowired + private SysRoleMapper sysRoleMapper; + @Autowired + private SysRoleMenuMapper sysRoleMenuMapper; + @Autowired + private SysUserRoleMapper sysUserRoleMapper; + @Autowired + private SysMenuService sysMenuService; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private BizWidgetDatasourceExtHelper bizWidgetDatasourceExtHelper; + + /** + * 返回主对象的Mapper对象。 + * + * @return 主对象的Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return sysRoleMapper; + } + + @PostConstruct + private void registerBizWidgetDatasource() { + bizWidgetDatasourceExtHelper.registerDatasource(BizWidgetDatasourceType.UPMS_ROLE_TYPE, this); + } + + @Override + public MyPageData> getDataList( + String type, Map filter, MyOrderParam orderParam, MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount()); + } + String orderBy = orderParam == null ? null : MyOrderParam.buildOrderBy(orderParam, SysRole.class); + SysRole roleFilter = filter == null ? null : BeanUtil.toBean(filter, SysRole.class); + List roleList = this.getSysRoleList(roleFilter, orderBy); + return MyPageUtil.makeResponseData(roleList, BeanUtil::beanToMap); + } + + @Override + public List> getDataListWithInList(String type, String fieldName, List fieldValues) { + List roleList; + if (StrUtil.isBlank(fieldName)) { + roleList = this.getInList(fieldValues.stream().map(Long::valueOf).collect(Collectors.toSet())); + } else { + roleList = this.getInList(fieldName, MyModelUtil.convertToTypeValues(SysRole.class, fieldName, fieldValues)); + } + return MyModelUtil.beanToMapList(roleList); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public SysRole saveNew(SysRole role, Set menuIdSet) { + role.setRoleId(idGenerator.nextLongId()); + MyModelUtil.fillCommonsForInsert(role); + sysRoleMapper.insert(role); + if (menuIdSet != null) { + for (Long menuId : menuIdSet) { + SysRoleMenu roleMenu = new SysRoleMenu(); + roleMenu.setRoleId(role.getRoleId()); + roleMenu.setMenuId(menuId); + sysRoleMenuMapper.insert(roleMenu); + } + } + return role; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(SysRole role, SysRole originalRole, Set menuIdSet) { + MyModelUtil.fillCommonsForUpdate(role, originalRole); + if (sysRoleMapper.update(role) != 1) { + return false; + } + SysRoleMenu deletedRoleMenu = new SysRoleMenu(); + deletedRoleMenu.setRoleId(role.getRoleId()); + sysRoleMenuMapper.deleteByQuery(QueryWrapper.create(deletedRoleMenu)); + if (menuIdSet != null) { + for (Long menuId : menuIdSet) { + SysRoleMenu roleMenu = new SysRoleMenu(); + roleMenu.setRoleId(role.getRoleId()); + roleMenu.setMenuId(menuId); + sysRoleMenuMapper.insert(roleMenu); + } + } + return true; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long roleId) { + if (sysRoleMapper.deleteById(roleId) != 1) { + return false; + } + sysRoleMenuMapper.deleteByQuery(new QueryWrapper().eq(SysRoleMenu::getRoleId, roleId)); + sysUserRoleMapper.deleteByQuery(new QueryWrapper().eq(SysUserRole::getRoleId, roleId)); + return true; + } + + @Override + public List getSysRoleList(SysRole filter, String orderBy) { + return sysRoleMapper.getSysRoleList(filter, orderBy); + } + + @Override + public List getSysUserRoleListByUserId(Long userId) { + SysUserRole filter = new SysUserRole(); + filter.setUserId(userId); + return sysUserRoleMapper.selectListByQuery(new QueryWrapper().eq(SysUserRole::getUserId, userId)); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void addUserRoleList(List userRoleList) { + for (SysUserRole userRole : userRoleList) { + sysUserRoleMapper.insert(userRole); + } + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean removeUserRole(Long roleId, Long userId) { + SysUserRole userRole = new SysUserRole(); + userRole.setRoleId(roleId); + userRole.setUserId(userId); + return sysUserRoleMapper.deleteByQuery(QueryWrapper.create(userRole)) == 1; + } + + @Override + public CallResult verifyRelatedData(SysRole sysRole, SysRole originalSysRole, String menuIdListString) { + JSONObject jsonObject = null; + if (StringUtils.isNotBlank(menuIdListString)) { + Set menuIdSet = Arrays.stream( + menuIdListString.split(",")).map(Long::valueOf).collect(Collectors.toSet()); + if (!sysMenuService.existAllPrimaryKeys(menuIdSet)) { + return CallResult.error("数据验证失败,存在不合法的菜单权限,请刷新后重试!"); + } + jsonObject = new JSONObject(); + jsonObject.put("menuIdSet", menuIdSet); + } + return CallResult.ok(jsonObject); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysUserServiceImpl.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysUserServiceImpl.java new file mode 100644 index 00000000..d4ccbd20 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysUserServiceImpl.java @@ -0,0 +1,383 @@ +package com.orangeforms.webadmin.upms.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.mybatisflex.core.query.QueryWrapper; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.webadmin.upms.service.*; +import com.orangeforms.webadmin.upms.dao.*; +import com.orangeforms.webadmin.upms.model.*; +import com.orangeforms.webadmin.upms.model.constant.SysUserStatus; +import com.orangeforms.common.ext.util.BizWidgetDatasourceExtHelper; +import com.orangeforms.common.ext.base.BizWidgetDatasource; +import com.orangeforms.common.ext.constant.BizWidgetDatasourceType; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.constant.UserFilterGroup; +import com.orangeforms.common.core.constant.GlobalDeletedFlag; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.github.pagehelper.Page; +import lombok.extern.slf4j.Slf4j; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import jakarta.annotation.PostConstruct; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 用户管理数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Service("sysUserService") +public class SysUserServiceImpl extends BaseService implements SysUserService, BizWidgetDatasource { + + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private SysUserMapper sysUserMapper; + @Autowired + private SysUserRoleMapper sysUserRoleMapper; + @Autowired + private SysUserPostMapper sysUserPostMapper; + @Autowired + private SysDataPermUserMapper sysDataPermUserMapper; + @Autowired + private SysDeptService sysDeptService; + @Autowired + private SysRoleService sysRoleService; + @Autowired + private SysDataPermService sysDataPermService; + @Autowired + private SysPostService sysPostService; + @Autowired + private PasswordEncoder passwordEncoder; + @Autowired + private BizWidgetDatasourceExtHelper bizWidgetDatasourceExtHelper; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return sysUserMapper; + } + + @PostConstruct + private void registerBizWidgetDatasource() { + bizWidgetDatasourceExtHelper.registerDatasource(BizWidgetDatasourceType.UPMS_USER_TYPE, this); + } + + @Override + public MyPageData> getDataList( + String type, Map filter, MyOrderParam orderParam, MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount()); + } + List userList = null; + String orderBy = MyOrderParam.buildOrderBy(orderParam, SysUser.class, false); + SysUser userFilter = BeanUtil.toBean(filter, SysUser.class); + if (filter != null) { + Object group = filter.get("USER_FILTER_GROUP"); + if (group != null) { + JSONObject filterGroupJson = JSON.parseObject(group.toString()); + String groupType = filterGroupJson.getString("type"); + String values = filterGroupJson.getString("values"); + if (UserFilterGroup.USER.equals(groupType)) { + List loginNames = StrUtil.splitTrim(values, ","); + userList = sysUserMapper.getSysUserListByLoginNames(loginNames, userFilter, orderBy); + } else { + Set groupIds = StrUtil.splitTrim(values, ",") + .stream().map(Long::valueOf).collect(Collectors.toSet()); + userList = this.getUserListByGroupIds(groupType, groupIds, userFilter, orderBy); + } + } + } + if (userList == null) { + userList = this.getSysUserList(userFilter, orderBy); + } + this.buildRelationForDataList(userList, MyRelationParam.dictOnly()); + return MyPageUtil.makeResponseData(userList, BeanUtil::beanToMap); + } + + private List getUserListByGroupIds(String groupType, Set groupIds, SysUser filter, String orderBy) { + if (groupType.equals(UserFilterGroup.DEPT)) { + return sysUserMapper.getSysUserListByDeptIds(groupIds, filter, orderBy); + } + List userIds = null; + switch (groupType) { + case UserFilterGroup.ROLE: + userIds = sysUserMapper.getUserIdListByRoleIds(groupIds, filter, orderBy); + break; + case UserFilterGroup.POST: + userIds = sysUserMapper.getUserIdListByPostIds(groupIds, filter, orderBy); + break; + case UserFilterGroup.DEPT_POST: + userIds = sysUserMapper.getUserIdListByDeptPostIds(groupIds, filter, orderBy); + break; + default: + break; + } + if (CollUtil.isEmpty(userIds)) { + return CollUtil.empty(SysUser.class); + } + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.in(SysUser::getUserId, userIds); + if (StrUtil.isNotBlank(orderBy)) { + queryWrapper.orderBy(orderBy); + } + return sysUserMapper.selectListByQuery(queryWrapper); + } + + @Override + public List> getDataListWithInList(String type, String fieldName, List fieldValues) { + List userList; + if (StrUtil.isBlank(fieldName)) { + userList = this.getInList(fieldValues.stream().map(Long::valueOf).collect(Collectors.toSet())); + } else { + userList = this.getInList(fieldName, MyModelUtil.convertToTypeValues(SysUser.class, fieldName, fieldValues)); + } + this.buildRelationForDataList(userList, MyRelationParam.dictOnly()); + return MyModelUtil.beanToMapList(userList); + } + + /** + * 获取指定登录名的用户对象。 + * + * @param loginName 指定登录用户名。 + * @return 用户对象。 + */ + @Override + public SysUser getSysUserByLoginName(String loginName) { + SysUser filter = new SysUser(); + filter.setLoginName(loginName); + return sysUserMapper.selectOneByQuery(QueryWrapper.create(filter)); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public SysUser saveNew(SysUser user, Set roleIdSet, Set deptPostIdSet, Set dataPermIdSet) { + user.setUserId(idGenerator.nextLongId()); + user.setPassword(passwordEncoder.encode(user.getPassword())); + user.setUserStatus(SysUserStatus.STATUS_NORMAL); + user.setDeletedFlag(GlobalDeletedFlag.NORMAL); + MyModelUtil.fillCommonsForInsert(user); + sysUserMapper.insert(user); + if (CollUtil.isNotEmpty(deptPostIdSet)) { + for (Long deptPostId : deptPostIdSet) { + SysDeptPost deptPost = sysDeptService.getSysDeptPost(deptPostId); + SysUserPost userPost = new SysUserPost(); + userPost.setUserId(user.getUserId()); + userPost.setDeptPostId(deptPostId); + userPost.setPostId(deptPost.getPostId()); + sysUserPostMapper.insert(userPost); + } + } + if (CollUtil.isNotEmpty(roleIdSet)) { + for (Long roleId : roleIdSet) { + SysUserRole userRole = new SysUserRole(); + userRole.setUserId(user.getUserId()); + userRole.setRoleId(roleId); + sysUserRoleMapper.insert(userRole); + } + } + if (CollUtil.isNotEmpty(dataPermIdSet)) { + for (Long dataPermId : dataPermIdSet) { + SysDataPermUser dataPermUser = new SysDataPermUser(); + dataPermUser.setDataPermId(dataPermId); + dataPermUser.setUserId(user.getUserId()); + sysDataPermUserMapper.insert(dataPermUser); + } + } + return user; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(SysUser user, SysUser originalUser, Set roleIdSet, Set deptPostIdSet, Set dataPermIdSet) { + user.setLoginName(originalUser.getLoginName()); + user.setPassword(originalUser.getPassword()); + user.setDeletedFlag(GlobalDeletedFlag.NORMAL); + MyModelUtil.fillCommonsForUpdate(user, originalUser); + if (sysUserMapper.update(user, false) != 1) { + return false; + } + // 先删除原有的User-Post关联关系,再重新插入新的关联关系 + SysUserPost deletedUserPost = new SysUserPost(); + deletedUserPost.setUserId(user.getUserId()); + sysUserPostMapper.deleteByQuery(QueryWrapper.create(deletedUserPost)); + if (CollUtil.isNotEmpty(deptPostIdSet)) { + for (Long deptPostId : deptPostIdSet) { + SysDeptPost deptPost = sysDeptService.getSysDeptPost(deptPostId); + SysUserPost userPost = new SysUserPost(); + userPost.setUserId(user.getUserId()); + userPost.setDeptPostId(deptPostId); + userPost.setPostId(deptPost.getPostId()); + sysUserPostMapper.insert(userPost); + } + } + // 先删除原有的User-Role关联关系,再重新插入新的关联关系 + SysUserRole deletedUserRole = new SysUserRole(); + deletedUserRole.setUserId(user.getUserId()); + sysUserRoleMapper.deleteByQuery(QueryWrapper.create(deletedUserRole)); + if (CollUtil.isNotEmpty(roleIdSet)) { + for (Long roleId : roleIdSet) { + SysUserRole userRole = new SysUserRole(); + userRole.setUserId(user.getUserId()); + userRole.setRoleId(roleId); + sysUserRoleMapper.insert(userRole); + } + } + // 先删除原有的DataPerm-User关联关系,在重新插入新的关联关系 + SysDataPermUser deletedDataPermUser = new SysDataPermUser(); + deletedDataPermUser.setUserId(user.getUserId()); + sysDataPermUserMapper.deleteByQuery(QueryWrapper.create(deletedDataPermUser)); + if (CollUtil.isNotEmpty(dataPermIdSet)) { + for (Long dataPermId : dataPermIdSet) { + SysDataPermUser dataPermUser = new SysDataPermUser(); + dataPermUser.setDataPermId(dataPermId); + dataPermUser.setUserId(user.getUserId()); + sysDataPermUserMapper.insert(dataPermUser); + } + } + return true; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean changePassword(Long userId, String newPass) { + SysUser updatedUser = new SysUser(); + updatedUser.setUserId(userId); + updatedUser.setPassword(passwordEncoder.encode(newPass)); + return sysUserMapper.update(updatedUser) == 1; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean changeHeadImage(Long userId, String newHeadImage) { + SysUser updatedUser = new SysUser(); + updatedUser.setUserId(userId); + updatedUser.setHeadImageUrl(newHeadImage); + return sysUserMapper.update(updatedUser) == 1; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long userId) { + if (sysUserMapper.deleteById(userId) == 0) { + return false; + } + SysUserRole userRole = new SysUserRole(); + userRole.setUserId(userId); + sysUserRoleMapper.deleteByQuery(QueryWrapper.create(userRole)); + SysUserPost userPost = new SysUserPost(); + userPost.setUserId(userId); + sysUserPostMapper.deleteByQuery(QueryWrapper.create(userPost)); + SysDataPermUser dataPermUser = new SysDataPermUser(); + dataPermUser.setUserId(userId); + sysDataPermUserMapper.deleteByQuery(QueryWrapper.create(dataPermUser)); + return true; + } + + @Override + public List getSysUserList(SysUser filter, String orderBy) { + return sysUserMapper.getSysUserList(filter, orderBy); + } + + @Override + public List getSysUserListWithRelation(SysUser filter, String orderBy) { + List resultList = sysUserMapper.getSysUserList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + @Override + public List getSysUserListByRoleId(Long roleId, SysUser filter, String orderBy) { + return sysUserMapper.getSysUserListByRoleId(roleId, filter, orderBy); + } + + @Override + public List getNotInSysUserListByRoleId(Long roleId, SysUser filter, String orderBy) { + return sysUserMapper.getNotInSysUserListByRoleId(roleId, filter, orderBy); + } + + @Override + public List getSysUserListByDataPermId(Long dataPermId, SysUser filter, String orderBy) { + return sysUserMapper.getSysUserListByDataPermId(dataPermId, filter, orderBy); + } + + @Override + public List getNotInSysUserListByDataPermId(Long dataPermId, SysUser filter, String orderBy) { + return sysUserMapper.getNotInSysUserListByDataPermId(dataPermId, filter, orderBy); + } + + @Override + public List getSysUserListByDeptPostId(Long deptPostId, SysUser filter, String orderBy) { + return sysUserMapper.getSysUserListByDeptPostId(deptPostId, filter, orderBy); + } + + @Override + public List getNotInSysUserListByDeptPostId(Long deptPostId, SysUser filter, String orderBy) { + return sysUserMapper.getNotInSysUserListByDeptPostId(deptPostId, filter, orderBy); + } + + @Override + public List getSysUserListByPostId(Long postId, SysUser filter, String orderBy) { + return sysUserMapper.getSysUserListByPostId(postId, filter, orderBy); + } + + @Override + public CallResult verifyRelatedData( + SysUser sysUser, SysUser originalSysUser, String roleIds, String deptPostIds, String dataPermIds) { + JSONObject jsonObject = new JSONObject(); + if (StrUtil.isBlank(deptPostIds)) { + return CallResult.error("数据验证失败,用户的部门岗位数据不能为空!"); + } + Set deptPostIdSet = + Arrays.stream(deptPostIds.split(",")).map(Long::valueOf).collect(Collectors.toSet()); + if (!sysPostService.existAllPrimaryKeys(deptPostIdSet, sysUser.getDeptId())) { + return CallResult.error("数据验证失败,存在不合法的用户岗位,请刷新后重试!"); + } + jsonObject.put("deptPostIdSet", deptPostIdSet); + if (StrUtil.isBlank(roleIds)) { + return CallResult.error("数据验证失败,用户的角色数据不能为空!"); + } + Set roleIdSet = Arrays.stream( + roleIds.split(",")).map(Long::valueOf).collect(Collectors.toSet()); + if (!sysRoleService.existAllPrimaryKeys(roleIdSet)) { + return CallResult.error("数据验证失败,存在不合法的用户角色,请刷新后重试!"); + } + jsonObject.put("roleIdSet", roleIdSet); + if (StrUtil.isBlank(dataPermIds)) { + return CallResult.error("数据验证失败,用户的数据权限不能为空!"); + } + Set dataPermIdSet = Arrays.stream( + dataPermIds.split(",")).map(Long::valueOf).collect(Collectors.toSet()); + if (!sysDataPermService.existAllPrimaryKeys(dataPermIdSet)) { + return CallResult.error("数据验证失败,存在不合法的数据权限,请刷新后重试!"); + } + jsonObject.put("dataPermIdSet", dataPermIdSet); + //这里是基于字典的验证。 + if (this.needToVerify(sysUser, originalSysUser, SysUser::getDeptId) + && !sysDeptService.existId(sysUser.getDeptId())) { + return CallResult.error("数据验证失败,关联的用户部门Id并不存在,请刷新后重试!"); + } + return CallResult.ok(jsonObject); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDataPermDeptVo.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDataPermDeptVo.java new file mode 100644 index 00000000..601dc7c2 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDataPermDeptVo.java @@ -0,0 +1,27 @@ +package com.orangeforms.webadmin.upms.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 数据权限与部门关联VO。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "数据权限与部门关联VO") +@Data +public class SysDataPermDeptVo { + + /** + * 数据权限Id。 + */ + @Schema(description = "数据权限Id") + private Long dataPermId; + + /** + * 关联部门Id。 + */ + @Schema(description = "关联部门Id") + private Long deptId; +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDataPermMenuVo.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDataPermMenuVo.java new file mode 100644 index 00000000..7e4bc12c --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDataPermMenuVo.java @@ -0,0 +1,27 @@ +package com.orangeforms.webadmin.upms.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 数据权限与菜单关联VO。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "数据权限与菜单关联VO") +@Data +public class SysDataPermMenuVo { + + /** + * 数据权限Id。 + */ + @Schema(description = "数据权限Id") + private Long dataPermId; + + /** + * 关联菜单Id。 + */ + @Schema(description = "关联菜单Id") + private Long menuId; +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDataPermVo.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDataPermVo.java new file mode 100644 index 00000000..e07af624 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDataPermVo.java @@ -0,0 +1,57 @@ +package com.orangeforms.webadmin.upms.vo; + +import com.orangeforms.common.core.base.vo.BaseVo; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; +import java.util.Map; + +/** + * 数据权限VO。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "数据权限VO") +@Data +@EqualsAndHashCode(callSuper = true) +public class SysDataPermVo extends BaseVo { + + /** + * 数据权限Id。 + */ + @Schema(description = "数据权限Id") + private Long dataPermId; + + /** + * 显示名称。 + */ + @Schema(description = "显示名称") + private String dataPermName; + + /** + * 数据权限规则类型(0: 全部可见 1: 只看自己 2: 只看本部门 3: 本部门及子部门 4: 多部门及子部门 5: 自定义部门列表)。 + */ + @Schema(description = "数据权限规则类型") + private Integer ruleType; + + /** + * 部门Id列表(逗号分隔)。 + */ + @Schema(description = "部门Id列表") + private String deptIdListString; + + /** + * 数据权限与部门关联对象列表。 + */ + @Schema(description = "数据权限与部门关联对象列表") + private List> dataPermDeptList; + + /** + * 数据权限与菜单关联对象列表。 + */ + @Schema(description = "数据权限与菜单关联对象列表") + private List> dataPermMenuList; +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDeptPostVo.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDeptPostVo.java new file mode 100644 index 00000000..6e502095 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDeptPostVo.java @@ -0,0 +1,39 @@ +package com.orangeforms.webadmin.upms.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 部门岗位VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "部门岗位VO") +@Data +public class SysDeptPostVo { + + /** + * 部门岗位Id。 + */ + @Schema(description = "部门岗位Id") + private Long deptPostId; + + /** + * 部门Id。 + */ + @Schema(description = "部门Id") + private Long deptId; + + /** + * 岗位Id。 + */ + @Schema(description = "岗位Id") + private Long postId; + + /** + * 部门岗位显示名称。 + */ + @Schema(description = "部门岗位显示名称") + private String postShowName; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDeptVo.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDeptVo.java new file mode 100644 index 00000000..1f08901f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDeptVo.java @@ -0,0 +1,65 @@ +package com.orangeforms.webadmin.upms.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 部门管理VO视图对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "SysDeptVO视图对象") +@Data +public class SysDeptVo { + + /** + * 部门Id。 + */ + @Schema(description = "部门Id") + private Long deptId; + + /** + * 部门名称。 + */ + @Schema(description = "部门名称") + private String deptName; + + /** + * 显示顺序。 + */ + @Schema(description = "显示顺序") + private Integer showOrder; + + /** + * 父部门Id。 + */ + @Schema(description = "父部门Id") + private Long parentId; + + /** + * 创建者Id。 + */ + @Schema(description = "创建者Id") + private Long createUserId; + + /** + * 更新者Id。 + */ + @Schema(description = "更新者Id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysMenuVo.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysMenuVo.java new file mode 100644 index 00000000..e278c859 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysMenuVo.java @@ -0,0 +1,90 @@ +package com.orangeforms.webadmin.upms.vo; + +import com.orangeforms.common.core.base.vo.BaseVo; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 菜单VO。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "菜单VO") +@Data +@EqualsAndHashCode(callSuper = true) +public class SysMenuVo extends BaseVo { + + /** + * 菜单Id。 + */ + @Schema(description = "菜单Id") + private Long menuId; + + /** + * 父菜单Id,目录菜单的父菜单为null + */ + @Schema(description = "父菜单Id") + private Long parentId; + + /** + * 菜单显示名称。 + */ + @Schema(description = "菜单显示名称") + private String menuName; + + /** + * 菜单类型 (0: 目录 1: 菜单 2: 按钮 3: UI片段)。 + */ + @Schema(description = "菜单类型") + private Integer menuType; + + /** + * 前端表单路由名称,仅用于menu_type为1的菜单类型。 + */ + @Schema(description = "前端表单路由名称") + private String formRouterName; + + /** + * 在线表单主键Id,仅用于在线表单绑定的菜单。 + */ + @Schema(description = "在线表单主键Id") + private Long onlineFormId; + + /** + * 在线表单菜单的权限控制类型,具体值可参考SysOnlineMenuPermType常量对象。 + */ + @Schema(description = "在线表单菜单的权限控制类型") + private Integer onlineMenuPermType; + + /** + * 统计页面主键Id,仅用于统计页面绑定的菜单。 + */ + @Schema(description = "统计页面主键Id") + private Long reportPageId; + + /** + * 仅用于在线表单的流程Id。 + */ + @Schema(description = "仅用于在线表单的流程Id") + private Long onlineFlowEntryId; + + /** + * 菜单显示顺序 (值越小,排序越靠前)。 + */ + @Schema(description = "菜单显示顺序") + private Integer showOrder; + + /** + * 菜单图标。 + */ + @Schema(description = "菜单显示图标") + private String icon; + + /** + * 附加信息。 + */ + @Schema(description = "附加信息") + private String extraData; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysPostVo.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysPostVo.java new file mode 100644 index 00000000..15a5f2c7 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysPostVo.java @@ -0,0 +1,50 @@ +package com.orangeforms.webadmin.upms.vo; + +import com.orangeforms.common.core.base.vo.BaseVo; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Map; + +/** + * 岗位VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "岗位VO") +@Data +@EqualsAndHashCode(callSuper = true) +public class SysPostVo extends BaseVo { + + /** + * 岗位Id。 + */ + @Schema(description = "岗位Id") + private Long postId; + + /** + * 岗位名称。 + */ + @Schema(description = "岗位名称") + private String postName; + + /** + * 岗位层级,数值越小级别越高。 + */ + @Schema(description = "岗位层级,数值越小级别越高") + private Integer postLevel; + + /** + * 是否领导岗位。 + */ + @Schema(description = "是否领导岗位") + private Boolean leaderPost; + + /** + * postId 的多对多关联表数据对象,数据对应类型为SysDeptPostVo。 + */ + @Schema(description = "postId 的多对多关联表数据对象") + private Map sysDeptPost; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysRoleVo.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysRoleVo.java new file mode 100644 index 00000000..0aaf0358 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysRoleVo.java @@ -0,0 +1,39 @@ +package com.orangeforms.webadmin.upms.vo; + +import com.orangeforms.common.core.base.vo.BaseVo; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; +import java.util.Map; + +/** + * 角色VO。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "角色VO") +@Data +@EqualsAndHashCode(callSuper = true) +public class SysRoleVo extends BaseVo { + + /** + * 角色Id。 + */ + @Schema(description = "角色Id") + private Long roleId; + + /** + * 角色名称。 + */ + @Schema(description = "角色名称") + private String roleName; + + /** + * 角色与菜单关联对象列表。 + */ + @Schema(description = "角色与菜单关联对象列表") + private List> sysRoleMenuList; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysUserVo.java b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysUserVo.java new file mode 100644 index 00000000..194e8d86 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysUserVo.java @@ -0,0 +1,133 @@ +package com.orangeforms.webadmin.upms.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; +import java.util.Map; +import java.util.List; + +/** + * 用户管理VO视图对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "SysUserVO视图对象") +@Data +public class SysUserVo { + + /** + * 用户Id。 + */ + @Schema(description = "用户Id") + private Long userId; + + /** + * 登录用户名。 + */ + @Schema(description = "登录用户名") + private String loginName; + + /** + * 用户部门Id。 + */ + @Schema(description = "用户部门Id") + private Long deptId; + + /** + * 用户显示名称。 + */ + @Schema(description = "用户显示名称") + private String showName; + + /** + * 用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)。 + */ + @Schema(description = "用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)") + private Integer userType; + + /** + * 用户头像的Url。 + */ + @Schema(description = "用户头像的Url") + private String headImageUrl; + + /** + * 用户状态(0: 正常 1: 锁定)。 + */ + @Schema(description = "用户状态(0: 正常 1: 锁定)") + private Integer userStatus; + + /** + * 用户邮箱。 + */ + @Schema(description = "用户邮箱") + private String email; + + /** + * 用户手机。 + */ + @Schema(description = "用户手机") + private String mobile; + + /** + * 创建者Id。 + */ + @Schema(description = "创建者Id") + private Long createUserId; + + /** + * 更新者Id。 + */ + @Schema(description = "更新者Id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 多对多用户岗位数据集合。 + */ + @Schema(description = "多对多用户岗位数据集合") + private List> sysUserPostList; + + /** + * 多对多用户角色数据集合。 + */ + @Schema(description = "多对多用户角色数据集合") + private List> sysUserRoleList; + + /** + * 多对多用户数据权限数据集合。 + */ + @Schema(description = "多对多用户数据权限数据集合") + private List> sysDataPermUserList; + + /** + * deptId 字典关联数据。 + */ + @Schema(description = "deptId 字典关联数据") + private Map deptIdDictMap; + + /** + * userType 常量字典关联数据。 + */ + @Schema(description = "userType 常量字典关联数据") + private Map userTypeDictMap; + + /** + * userStatus 常量字典关联数据。 + */ + @Schema(description = "userStatus 常量字典关联数据") + private Map userStatusDictMap; +} diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/resources/application-dev.yml b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/resources/application-dev.yml new file mode 100644 index 00000000..47f2c1d5 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/resources/application-dev.yml @@ -0,0 +1,171 @@ +spring: + datasource: + type: com.alibaba.druid.pool.DruidDataSource + druid: + # 数据库链接 [主数据源] + main: + url: jdbc:mysql://localhost:3306/zzdemo-online-open?characterEncoding=utf8&useSSL=true&serverTimezone=Asia/Shanghai + username: root + password: 123456 + # 默认生成的操作日志数据源配置。 + operation-log: + url: jdbc:mysql://localhost:3306/zzdemo-online-open?characterEncoding=utf8&useSSL=true&serverTimezone=Asia/Shanghai + username: root + password: 123456 + # 默认生成的全局编码字典数据源配置。 + global-dict: + url: jdbc:mysql://localhost:3306/zzdemo-online-open?characterEncoding=utf8&useSSL=true&serverTimezone=Asia/Shanghai + username: root + password: 123456 + # 默认生成的工作流及在线表单数据源配置。 + common-flow-online: + url: jdbc:mysql://localhost:3306/zzdemo-online-open?characterEncoding=utf8&useSSL=true&serverTimezone=Asia/Shanghai + username: root + password: 123456 + driverClassName: com.mysql.cj.jdbc.Driver + name: application-webadmin + initialSize: 10 + minIdle: 10 + maxActive: 50 + maxWait: 60000 + timeBetweenEvictionRunsMillis: 60000 + minEvictableIdleTimeMillis: 300000 + poolPreparedStatements: true + maxPoolPreparedStatementPerConnectionSize: 20 + maxOpenPreparedStatements: 20 + validationQuery: SELECT 'x' + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 + filters: stat,wall + useGlobalDataSourceStat: true + web-stat-filter: + enabled: true + url-pattern: /* + exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*,/actuator/*" + stat-view-servlet: + enabled: true + urlPattern: /druid/* + resetEnable: true + +application: + # 初始化密码。 + defaultUserPassword: 123456 + # 缺省的文件上传根目录。 + uploadFileBaseDir: ./zz-resource/upload-files/app + # 跨域的IP(http://192.168.10.10:8086)白名单列表,多个IP之间逗号分隔(* 表示全部信任,空白表示禁用跨域信任)。 + credentialIpList: "*" + # Session的用户和数据权限在Redis中的过期时间(秒)。一定要和sa-token.timeout + sessionExpiredSeconds: 86400 + # 是否排他登录。 + excludeLogin: false + +# 这里仅仅是一个第三方配置的示例,如果没有接入斯三方系统, +# 这里的配置项也不会影响到系统的行为,如果觉得多余,也可以手动删除。 +third-party: + # 第三方系统接入的用户鉴权配置。 + auth: + - appCode: orange-forms-default + # 访问第三方系统接口的URL前缀,橙单会根据功能添加接口路径的其余部分, + # 比如获取用户Token的接口 http://localhost:8083/orangePluginTest/getTokenData + baseUrl: http://localhost:8083/orangePlugin + # 第三方应用鉴权的HTTP请求令牌头的KEY。 + tokenHeaderKey: Authorization + # 第三方返回的用户Token数据的缓存过期时长,单位秒。 + # 如果为0,则不缓存,每次涉及第三方的请求,都会发出http请求,交由第三方验证,这样对系统性能会有影响。 + tokenExpiredSeconds: 60 + # 第三方返回的权限数据的缓存过期时长,单位秒。 + permExpiredSeconds: 86400 + +# 这里仅仅是一个第三方配置的示例,如果没有接入斯三方系统, +# 这里的配置项也不会影响到系统的行为,如果觉得多余,也可以手动删除。 +common-ext: + urlPrefix: /admin/commonext + # 这里可以配置多个第三方应用,这里的应用数量,通常会和上面third-party.auth的配置数量一致。 + apps: + # 应用唯一编码,尽量不要使用中文。 + - appCode: orange-forms-default + # 业务组件的数据源配置。 + bizWidgetDatasources: + # 组件的类型,多个类型之间可以逗号分隔。 + - types: upms_user,upms_dept + # 组件获取列表数据的接口地址。 + listUrl: http://localhost:8083/orangePlugin/listBizWidgetData + # 组件获取详情数据的接口地址。 + viewUrl: http://localhost:8083/orangePlugin/viewBizWidgetData + +common-sequence: + # Snowflake 分布式Id生成算法所需的WorkNode参数值。 + snowflakeWorkNode: 1 + +# 存储session数据的Redis,所有服务均需要,因此放到公共配置中。 +# 根据实际情况,该Redis也可以用于存储其他数据。 +common-redis: + # redisson的配置。每个服务可以自己的配置文件中覆盖此选项。 + redisson: + # 如果该值为false,系统将不会创建RedissionClient的bean。 + enabled: true + # mode的可用值为,single/cluster/sentinel/master-slave + mode: single + # single: 单机模式 + # address: redis://localhost:6379 + # cluster: 集群模式 + # 每个节点逗号分隔,同时每个节点前必须以redis://开头。 + # address: redis://localhost:6379,redis://localhost:6378,... + # sentinel: + # 每个节点逗号分隔,同时每个节点前必须以redis://开头。 + # address: redis://localhost:6379,redis://localhost:6378,... + # master-slave: + # 每个节点逗号分隔,第一个为主节点,其余为从节点。同时每个节点前必须以redis://开头。 + # address: redis://localhost:6379,redis://localhost:6378,... + address: redis://localhost:6379 + # 链接超时,单位毫秒。 + timeout: 6000 + # 单位毫秒。分布式锁的超时检测时长。 + # 如果一次锁内操作超该毫秒数,或在释放锁之前异常退出,Redis会在该时长之后主动删除该锁使用的key。 + lockWatchdogTimeout: 60000 + # redis 密码,空可以不填。 + password: + pool: + # 连接池数量。 + poolSize: 20 + # 连接池中最小空闲数量。 + minIdle: 5 + +minio: + enabled: false + endpoint: http://localhost:19000 + accessKey: admin + secretKey: admin123456 + bucketName: application + +sa-token: + # token 名称(同时也是 cookie 名称) + token-name: Authorization + # token 有效期(单位:秒) 默认30天,-1 代表永久有效 + timeout: ${application.sessionExpiredSeconds} + # token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结 + active-timeout: -1 + # 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录) + is-concurrent: true + # 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token) + is-share: false + # token 风格(默认可取值:uuid、simple-uuid、random-32、random-64、random-128、tik) + token-style: uuid + # 是否输出操作日志 + is-log: true + # 配置 Sa-Token 单独使用的 Redis 连接 + alone-redis: + # Redis数据库索引(默认为0) + database: 0 + # Redis服务器地址 + host: localhost + # Redis服务器连接端口 + port: 6379 + # Redis服务器连接密码(默认为空) + password: + # 连接超时时间 + timeout: 10s + is-read-header: true + is-read-cookie: false diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/resources/application.yml b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/resources/application.yml new file mode 100644 index 00000000..b3bd45c1 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/resources/application.yml @@ -0,0 +1,164 @@ +logging: + level: + # 这里设置的日志级别优先于logback-spring.xml文件Loggers中的日志级别。 + com.orangeforms: info + config: classpath:logback-spring.xml + +server: + port: 8082 + tomcat: + uri-encoding: UTF-8 + threads: + max: 100 + min-spare: 10 + servlet: + encoding: + force: true + charset: UTF-8 + enabled: true + +# spring相关配置 +spring: + application: + name: application-webadmin + profiles: + active: dev + servlet: + multipart: + max-file-size: 50MB + max-request-size: 50MB + mvc: + converters: + preferred-json-mapper: fastjson + main: + allow-circular-references: true + groovy: + template: + check-template-location: false + +flowable: + async-executor-activate: false + database-schema-update: false + +mybatis-flex: + mapper-locations: classpath:com/orangeforms/webadmin/*/dao/mapper/*Mapper.xml,com/orangeforms/common/log/dao/mapper/*Mapper.xml,com/orangeforms/common/online/dao/mapper/*Mapper.xml,com/orangeforms/common/flow/dao/mapper/*Mapper.xml + type-aliases-package: com.orangeforms.webadmin.*.model,com.orangeforms.common.log.model,com.orangeforms.common.online.model,com.orangeforms.common.flow.model + global-config: + deleted-value-of-logic-delete: -1 + normal-value-of-logic-delete: 1 + +# 自动分页的配置 +pagehelper: + helperDialect: mysql + reasonable: true + supportMethodsArguments: false + params: count=countSql + +common-core: + # 可选值为 mysql / postgresql / oracle / dm8 / kingbase / opengauss + databaseType: mysql + +common-online: + # 注意不要以反斜杠(/)结尾。 + urlPrefix: /admin/online + # 打印接口的路径,不要以反斜杠(/)结尾。 + printUrlPath: /admin/report/reportPrint/print + # 在线表单业务数据上传资源路径 + uploadFileBaseDir: ./zz-resource/upload-files/online + # 如果为false,在线表单模块中所有Controller接口将不能使用。 + operationEnabled: true + # 1: minio 2: aliyun-oss 3: qcloud-cos。 + distributeStoreType: 1 + # 调用render接口时候,是否打开一级缓存加速。 + enableRenderCache: false + # 业务表和在线表单内置表是否跨库。 + enabledMultiDatabaseWrite: true + # 脱敏字段的掩码字符,只能为单个字符。 + maskChar: '*' + # 下面的url列表,请保持反斜杠(/)结尾。 + viewUrlList: + - ${common-online.urlPrefix}/onlineOperation/viewByDatasourceId/ + - ${common-online.urlPrefix}/onlineOperation/viewByOneToManyRelationId/ + - ${common-online.urlPrefix}/onlineOperation/listByDatasourceId/ + - ${common-online.urlPrefix}/onlineOperation/listByOneToManyRelationId/ + - ${common-online.urlPrefix}/onlineOperation/exportByDatasourceId/ + - ${common-online.urlPrefix}/onlineOperation/exportByOneToManyRelationId/ + - ${common-online.urlPrefix}/onlineOperation/downloadDatasource/ + - ${common-online.urlPrefix}/onlineOperation/downloadOneToManyRelation/ + - ${common-online.urlPrefix}/onlineOperation/print/ + editUrlList: + - ${common-online.urlPrefix}/onlineOperation/addDatasource/ + - ${common-online.urlPrefix}/onlineOperation/addOneToManyRelation/ + - ${common-online.urlPrefix}/onlineOperation/updateDatasource/ + - ${common-online.urlPrefix}/onlineOperation/updateOneToManyRelation/ + - ${common-online.urlPrefix}/onlineOperation/deleteDatasource/ + - ${common-online.urlPrefix}/onlineOperation/deleteOneToManyRelation/ + - ${common-online.urlPrefix}/onlineOperation/deleteBatchDatasource/ + - ${common-online.urlPrefix}/onlineOperation/deleteBatchOneToManyRelation/ + - ${common-online.urlPrefix}/onlineOperation/uploadDatasource/ + - ${common-online.urlPrefix}/onlineOperation/uploadOneToManyRelation/ + - ${common-online.urlPrefix}/onlineOperation/importDatasource/ + +common-flow: + # 请慎重修改urlPrefix的缺省配置,注意不要以反斜杠(/)结尾。如必须修改其他路径,请同步修改数据库脚本。 + urlPrefix: /admin/flow + # 如果为false,流程模块的所有Controller中的接口将不能使用。 + operationEnabled: true + +common-swagger: + # 当enabled为false的时候,则可禁用swagger。 + enabled: true + # 工程的基础包名。 + basePackage: com.orangeforms + # 工程服务的基础包名。 + serviceBasePackage: com.orangeforms.webadmin + title: 橙单单体服务工程 + description: 橙单单体服务工程详情 + version: 1.0 + +springdoc: + swagger-ui: + path: /swagger-ui.html + tags-sorter: alpha + #operations-sorter: order + api-docs: + path: /v3/api-docs + default-flat-param-object: false + +common-datafilter: + tenant: + # 对于单体服务,该值始终为false。 + enabled: false + dataperm: + enabled: true + # 在拼接数据权限过滤的SQL时,我们会用到sys_dept_relation表,该表的前缀由此配置项指定。 + # 如果没有前缀,请使用 "" 。 + deptRelationTablePrefix: zz_ + # 是否在每次执行数据权限查询过滤时,都要进行菜单Id和URL之间的越权验证。如果使用SaToken权限框架,该参数必须为false。 + enableMenuPermVerify: false + +# 暴露监控端点 +management: + endpoints: + web: + exposure: + include: '*' + jmx: + exposure: + include: '*' + endpoint: + # 与中间件相关的健康详情也会被展示 + health: + show-details: always + configprops: + # 在/actuator/configprops中,所有包含password的配置,将用 * 隐藏。 + # 如果不想隐藏任何配置项的值,可以直接使用如下被注释的空值。 + # keys-to-sanitize: + keys-to-sanitize: password + server: + base-path: "/" + +common-log: + # 操作日志配置,对应配置文件common-log/OperationLogProperties.java + operation-log: + enabled: true diff --git a/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/resources/logback-spring.xml b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/resources/logback-spring.xml new file mode 100644 index 00000000..6bc0eafb --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/application-webadmin/src/main/resources/logback-spring.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + ${LOG_PATTERN} + + + + + + + ${LOG_HOME}/${LOG_NAME}.log + true + + + ${LOG_HOME}/${LOG_NAME}-%d{yyyy-MM-dd}-%i.log + + + 31 + + + 20MB + + + + + ${LOG_PATTERN_EX} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/.DS_Store b/OrangeFormsOpen-MybatisFlex/common/.DS_Store new file mode 100644 index 00000000..7772dea2 Binary files /dev/null and b/OrangeFormsOpen-MybatisFlex/common/.DS_Store differ diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/pom.xml b/OrangeFormsOpen-MybatisFlex/common/common-core/pom.xml new file mode 100644 index 00000000..91e75e71 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/pom.xml @@ -0,0 +1,115 @@ + + + + com.orangeforms + common + 1.0.0 + + 4.0.0 + + common-core + 1.0.0 + common-core + jar + + + + + com.google.guava + guava + ${guava.version} + + + org.apache.commons + commons-lang3 + + + commons-io + commons-io + ${commons-io.version} + + + org.apache.httpcomponents.client5 + httpclient5 + ${httpclient5.version} + + + joda-time + joda-time + ${joda-time.version} + + + org.apache.commons + commons-collections4 + ${commons-collections4.version} + + + org.apache.commons + commons-csv + ${common-csv.version} + + + cn.hutool + hutool-all + ${hutool.version} + + + io.jsonwebtoken + jjwt + ${jjwt.version} + + + com.alibaba + fastjson + ${fastjson.version} + + + com.github.ben-manes.caffeine + caffeine + ${caffeine.version} + + + cn.jimmyshi + bean-query + ${bean.query.version} + + + + org.apache.poi + poi-ooxml + ${poi-ooxml.version} + + + + mysql + mysql-connector-java + 8.0.22 + + + com.alibaba + druid-spring-boot-starter + ${druid.version} + + + com.sun + jconsole + + + com.sun + tools + + + + + com.mybatis-flex + mybatis-flex-spring-boot-starter + ${mybatisflex.version} + + + com.github.pagehelper + pagehelper + ${pagehelper.version} + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/advice/MyControllerAdvice.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/advice/MyControllerAdvice.java new file mode 100644 index 00000000..8d781115 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/advice/MyControllerAdvice.java @@ -0,0 +1,31 @@ +package com.orangeforms.common.core.advice; + +import com.orangeforms.common.core.util.MyDateUtil; +import org.springframework.beans.propertyeditors.CustomDateEditor; +import org.springframework.web.bind.WebDataBinder; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.InitBinder; + +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * Controller的环绕拦截类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@ControllerAdvice +public class MyControllerAdvice { + + /** + * 转换前端传入的日期变量参数为指定格式。 + * + * @param binder 数据绑定参数。 + */ + @InitBinder + public void initBinder(WebDataBinder binder) { + binder.registerCustomEditor(Date.class, + new CustomDateEditor(new SimpleDateFormat(MyDateUtil.COMMON_SHORT_DATETIME_FORMAT), false)); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/advice/MyExceptionHandler.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/advice/MyExceptionHandler.java new file mode 100644 index 00000000..c39771f7 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/advice/MyExceptionHandler.java @@ -0,0 +1,167 @@ +package com.orangeforms.common.core.advice; + +import com.orangeforms.common.core.exception.*; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.ResponseResult; +import com.orangeforms.common.core.util.ContextUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.ibatis.exceptions.PersistenceException; +import org.springframework.dao.DataAccessException; +import org.springframework.dao.DuplicateKeyException; +import org.springframework.dao.PermissionDeniedDataAccessException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import java.util.concurrent.TimeoutException; + +/** + * 业务层的异常处理类,这里只是给出最通用的Exception的捕捉,今后可以根据业务需要, + * 用不同的函数,处理不同类型的异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@RestControllerAdvice("com.orangeforms") +public class MyExceptionHandler { + + /** + * 通用异常处理方法。 + * + * @param ex 异常对象。 + * @param request http请求。 + * @return 应答对象。 + */ + @ExceptionHandler(value = Exception.class) + public ResponseResult exceptionHandle(Exception ex, HttpServletRequest request) { + log.error("Unhandled exception from URL [" + request.getRequestURI() + "]", ex); + ContextUtil.getHttpResponse().setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + return ResponseResult.error(ErrorCodeEnum.UNHANDLED_EXCEPTION, ex.getMessage()); + } + + /** + * 无效的实体对象异常。 + * + * @param ex 异常对象。 + * @param request http请求。 + * @return 应答对象。 + */ + @ExceptionHandler(value = InvalidDataModelException.class) + public ResponseResult invalidDataModelExceptionHandle(Exception ex, HttpServletRequest request) { + log.error("InvalidDataModelException exception from URL [" + request.getRequestURI() + "]", ex); + return ResponseResult.error(ErrorCodeEnum.INVALID_DATA_MODEL); + } + + /** + * 无效的实体对象字段异常。 + * + * @param ex 异常对象。 + * @param request http请求。 + * @return 应答对象。 + */ + @ExceptionHandler(value = InvalidDataFieldException.class) + public ResponseResult invalidDataFieldExceptionHandle(Exception ex, HttpServletRequest request) { + log.error("InvalidDataFieldException exception from URL [" + request.getRequestURI() + "]", ex); + return ResponseResult.error(ErrorCodeEnum.INVALID_DATA_FIELD); + } + + /** + * 无效类字段异常。 + * + * @param ex 异常对象。 + * @param request http请求。 + * @return 应答对象。 + */ + @ExceptionHandler(value = InvalidClassFieldException.class) + public ResponseResult invalidClassFieldExceptionHandle(Exception ex, HttpServletRequest request) { + log.error("InvalidClassFieldException exception from URL [" + request.getRequestURI() + "]", ex); + return ResponseResult.error(ErrorCodeEnum.INVALID_CLASS_FIELD); + } + + /** + * 重复键异常处理方法。 + * + * @param ex 异常对象。 + * @param request http请求。 + * @return 应答对象。 + */ + @ExceptionHandler(value = DuplicateKeyException.class) + public ResponseResult duplicateKeyExceptionHandle(Exception ex, HttpServletRequest request) { + log.error("DuplicateKeyException exception from URL [" + request.getRequestURI() + "]", ex); + return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY); + } + + /** + * 数据访问失败异常处理方法。 + * + * @param ex 异常对象。 + * @param request http请求。 + * @return 应答对象。 + */ + @ExceptionHandler(value = DataAccessException.class) + public ResponseResult dataAccessExceptionHandle(Exception ex, HttpServletRequest request) { + log.error("DataAccessException exception from URL [" + request.getRequestURI() + "]", ex); + if (ex.getCause() instanceof PersistenceException + && ex.getCause().getCause() instanceof PermissionDeniedDataAccessException) { + return ResponseResult.error(ErrorCodeEnum.DATA_PERM_ACCESS_FAILED); + } + return ResponseResult.error(ErrorCodeEnum.DATA_ACCESS_FAILED); + } + + /** + * 操作不存在或已逻辑删除数据的异常处理方法。 + * + * @param ex 异常对象。 + * @param request http请求。 + * @return 应答对象。 + */ + @ExceptionHandler(value = NoDataAffectException.class) + public ResponseResult noDataEffectExceptionHandle(Exception ex, HttpServletRequest request) { + log.error("NoDataAffectException exception from URL [" + request.getRequestURI() + "]", ex); + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + + /** + * 数据权限异常。 + * + * @param ex 异常对象。 + * @param request http请求。 + * @return 应答对象。 + */ + @ExceptionHandler(value = NoDataPermException.class) + public ResponseResult noDataPermExceptionHandle(Exception ex, HttpServletRequest request) { + log.error("NoDataPermException exception from URL [" + request.getRequestURI() + "]", ex); + return ResponseResult.error(ErrorCodeEnum.DATA_PERM_ACCESS_FAILED, ex.getMessage()); + } + + /** + * 自定义运行时异常。 + * + * @param ex 异常对象。 + * @param request http请求。 + * @return 应答对象。 + */ + @ExceptionHandler(value = MyRuntimeException.class) + public ResponseResult myRuntimeExceptionHandle(Exception ex, HttpServletRequest request) { + log.error("MyRuntimeException exception from URL [" + request.getRequestURI() + "]", ex); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, ex.getMessage()); + } + + /** + * Redis缓存访问异常处理方法。 + * + * @param ex 异常对象。 + * @param request http请求。 + * @return 应答对象。 + */ + @ExceptionHandler(value = RedisCacheAccessException.class) + public ResponseResult redisCacheAccessExceptionHandle(Exception ex, HttpServletRequest request) { + log.error("RedisCacheAccessException exception from URL [" + request.getRequestURI() + "]", ex); + if (ex.getCause() instanceof TimeoutException) { + return ResponseResult.error(ErrorCodeEnum.REDIS_CACHE_ACCESS_TIMEOUT); + } + return ResponseResult.error(ErrorCodeEnum.REDIS_CACHE_ACCESS_STATE_ERROR); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/DeptFilterColumn.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/DeptFilterColumn.java new file mode 100644 index 00000000..595e6463 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/DeptFilterColumn.java @@ -0,0 +1,16 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 主要用于标记数据权限中基于DeptId进行过滤的字段。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface DeptFilterColumn { + +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/DisableDataFilter.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/DisableDataFilter.java new file mode 100644 index 00000000..a2f5f028 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/DisableDataFilter.java @@ -0,0 +1,17 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 作为DisableDataFilterAspect的切点。 + * 该注解标记的方法内所有的查询语句,均不会被Mybatis拦截器过滤数据。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface DisableDataFilter { + +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/DisableTenantFilter.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/DisableTenantFilter.java new file mode 100644 index 00000000..f9a89810 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/DisableTenantFilter.java @@ -0,0 +1,28 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 仅用于微服务的多租户项目。 + * 用于注解DAO层Mapper对象的租户过滤规则。被包含的方法将不会进行租户Id的过滤。 + * 对于tk mapper和mybatis plus中的内置方法,可以直接指定方法名即可,如:selectOne。 + * 需要说明的是,在大多数场景下,只要在实体对象中指定了租户Id字段,基于该主表的绝大部分增删改操作, + * 都需要经过租户Id过滤,仅当查询非常复杂,或者主表不在SQL语句之中的时候,可以通过该注解禁用该SQL, + * 并根据需求通过手动的方式实现租户过滤。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface DisableTenantFilter { + + /** + * 包含的方法名称数组。该值不能为空,因为如想取消所有方法的租户过滤, + * 可以通过在实体对象中不指定租户Id字段注解的方式实现。 + * + * @return 被包括的方法名称数组。 + */ + String[] includeMethodName(); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/EnableDataPerm.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/EnableDataPerm.java new file mode 100644 index 00000000..cd2f6a36 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/EnableDataPerm.java @@ -0,0 +1,35 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 用于注解DAO层Mapper对象的数据权限规则。 + * 由于框架使用了tk.mapper,所以并非所有的Mapper接口均在当前Mapper对象中定义,有一部分被tk.mapper封装,如selectAll等。 + * 如果需要排除tk.mapper中的方法,可以直接使用tk.mapper基类所声明的方法名称即可。 + * 另外,比较特殊的场景是,因为tk.mapper是通用框架,所以同样的selectAll方法,可以获取不同的数据集合,因此在service中如果 + * 出现两个不同的方法调用Mapper的selectAll方法,但是一个需要参与过滤,另外一个不需要参与,那么就需要修改当前类的Mapper方法, + * 将其中一个方法重新定义一个具体的接口方法,并重新设定其是否参与数据过滤。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface EnableDataPerm { + + /** + * 排除的方法名称数组。如果为空,所有的方法均会被Mybaits拦截注入权限过滤条件。 + * + * @return 被排序的方法名称数据。 + */ + String[] excluseMethodName() default {}; + + /** + * 必须包含能看用户自己数据的数据过滤条件,如果当前用户的数据过滤中,没有DataPermRuleType.TYPE_USER_ONLY, + * 在进行数据权限过滤时,会自动包含该权限。 + * + * @return 是否必须包含DataPermRuleType.TYPE_USER_ONLY类型的数据权限。 + */ + boolean mustIncludeUserRule() default false; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/FlowLatestApprovalStatusColumn.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/FlowLatestApprovalStatusColumn.java new file mode 100644 index 00000000..6132c47a --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/FlowLatestApprovalStatusColumn.java @@ -0,0 +1,16 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 业务表中记录流程最后审批状态标记的字段。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface FlowLatestApprovalStatusColumn { + +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/FlowStatusColumn.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/FlowStatusColumn.java new file mode 100644 index 00000000..670a9083 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/FlowStatusColumn.java @@ -0,0 +1,16 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 业务表中记录流程实例结束标记的字段。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface FlowStatusColumn { + +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/JobUpdateTimeColumn.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/JobUpdateTimeColumn.java new file mode 100644 index 00000000..5546fa00 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/JobUpdateTimeColumn.java @@ -0,0 +1,16 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 主要用于标记Job实体对象的更新时间字段。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface JobUpdateTimeColumn { + +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MaskField.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MaskField.java new file mode 100644 index 00000000..301d5427 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MaskField.java @@ -0,0 +1,50 @@ +package com.orangeforms.common.core.annotation; + +import com.orangeforms.common.core.constant.MaskFieldTypeEnum; +import com.orangeforms.common.core.util.MaskFieldHandler; + +import java.lang.annotation.*; + +/** + * 脱敏字段注解。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface MaskField { + + /** + * 脱敏类型。 + * + * @return 脱敏类型。 + */ + MaskFieldTypeEnum maskType(); + /** + * 掩码符号。 + * + * @return 掩码符号。 + */ + char maskChar() default '*'; + /** + * 前面noMaskPrefix数量的字符不被掩码。 + * 掩码类型为MaskFieldTypeEnum.ID_CARD时可用。 + * + * @return 从1开始计算,前面不被掩码的字符数。 + */ + int noMaskPrefix() default 1; + /** + * 末尾noMaskSuffix数量的字符不被掩码。 + * 掩码类型为MaskFieldTypeEnum.ID_CARD时可用。 + * + * @return 从1开始计算,末尾不被掩码的字符数。 + */ + int noMaskSuffix() default 1; + /** + * 自定义脱敏处理器接口的Class。 + * @return 自定义脱敏处理器接口的Class。 + */ + Class handler() default MaskFieldHandler.class; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MultiDatabaseWriteMethod.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MultiDatabaseWriteMethod.java new file mode 100644 index 00000000..f12218e7 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MultiDatabaseWriteMethod.java @@ -0,0 +1,18 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 该注解通常标记于Service中的事务方法,并且会和@Transactional注解同时存在。 + * 被注解标注的方法内代码,通常通过mybatis,并在同一个事务内访问数据库。与此同时还会存在基于 + * JDBC的跨库操作。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface MultiDatabaseWriteMethod { + +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MyDataSource.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MyDataSource.java new file mode 100644 index 00000000..6d516240 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MyDataSource.java @@ -0,0 +1,21 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 主要用于标记Service所依赖的数据源类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface MyDataSource { + + /** + * 标注的数据源类型 + * @return 当前标注的数据源类型。 + */ + int value(); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MyDataSourceResolver.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MyDataSourceResolver.java new file mode 100644 index 00000000..41b80f8a --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MyDataSourceResolver.java @@ -0,0 +1,35 @@ +package com.orangeforms.common.core.annotation; + +import com.orangeforms.common.core.util.DataSourceResolver; + +import java.lang.annotation.*; + +/** + * 基于自定义解析规则的多数据源注解。主要用于标注Service的实现类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface MyDataSourceResolver { + + /** + * 多数据源路由键解析接口的Class。 + * @return 多数据源路由键解析接口的Class。 + */ + Class resolver(); + + /** + * DataSourceResolver.resovle方法的入参。 + * @return DataSourceResolver.resovle方法的入参。 + */ + String arg() default ""; + + /** + * 数值型参数。 + * @return DataSourceResolver.resovle方法的入参。 + */ + int intArg() default -1; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MyRequestBody.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MyRequestBody.java new file mode 100644 index 00000000..4aa12b98 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MyRequestBody.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 标记Controller中的方法参数,参数解析器会根据该注解将请求中的JSON数据,映射到参数中的绑定字段。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +public @interface MyRequestBody { + + /** + * 是否必须出现的参数。 + */ + boolean required() default false; + /** + * 解析时用到的JSON的key。 + */ + String value() default ""; +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/NoAuthInterface.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/NoAuthInterface.java new file mode 100644 index 00000000..1c832ac2 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/NoAuthInterface.java @@ -0,0 +1,15 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 主要用于标记无需Token验证的接口 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface NoAuthInterface { +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationConstDict.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationConstDict.java new file mode 100644 index 00000000..5b695fb0 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationConstDict.java @@ -0,0 +1,29 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 标识Model和常量字典之间的关联关系。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RelationConstDict { + + /** + * 当前对象的关联Id字段名称。 + * + * @return 当前对象的关联Id字段名称。 + */ + String masterIdField(); + + /** + * 被关联的常量字典的Class对象。 + * + * @return 关联的常量字典的Class对象。 + */ + Class constantDictClass(); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationDict.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationDict.java new file mode 100644 index 00000000..7b592496 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationDict.java @@ -0,0 +1,71 @@ +package com.orangeforms.common.core.annotation; + +import com.orangeforms.common.core.object.DummyClass; + +import java.lang.annotation.*; + +/** + * 标识Model之间的字典关联关系。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RelationDict { + + /** + * 当前对象的关联Id字段名称。 + * + * @return 当前对象的关联Id字段名称。 + */ + String masterIdField(); + + /** + * 被关联Model对象的Class对象。 + * + * @return 被关联Model对象的Class对象。 + */ + Class slaveModelClass(); + + /** + * 被关联Model对象的关联Id字段名称。 + * + * @return 被关联Model对象的关联Id字段名称。 + */ + String slaveIdField(); + + /** + * 被关联Model对象的关联Name字段名称。 + * + * @return 被关联Model对象的关联Name字段名称。 + */ + String slaveNameField(); + + /** + * 被关联的本地Service对象名称。 + * 该参数的优先级低于 slaveServiceClass(), + * 如果是空字符串,BaseService会自动拼接为 slaveModelClass().getSimpleName() + "Service"。 + * + * @return 被关联的本地Service对象名称。 + */ + String slaveServiceName() default ""; + + /** + * 被关联的本地Service对象CLass类型。 + * + * @return 被关联的本地Service对象CLass类型。 + */ + Class slaveServiceClass() default DummyClass.class; + + /** + * 在同一个实体对象中,如果有一对一关联和字典关联,都是基于相同的主表字段,并关联到 + * 相同关联表的同一关联字段时,可以在字典关联的注解中引用被一对一注解标准的对象属性。 + * 从而在数据整合时,当前字典的数据可以直接取自"equalOneToOneRelationField"指定 + * 的字段,从而避免一次没必要的数据库查询操作,提升了加载显示的效率。 + * + * @return 与该字典字段引用关系完全相同的一对一关联属性名称。 + */ + String equalOneToOneRelationField() default ""; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationGlobalDict.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationGlobalDict.java new file mode 100644 index 00000000..65ab2a5a --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationGlobalDict.java @@ -0,0 +1,29 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 全局字典关联。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RelationGlobalDict { + + /** + * 当前对象的关联Id字段名称。 + * + * @return 当前对象的关联Id字段名称。 + */ + String masterIdField(); + + /** + * 全局字典编码。 + * + * @return 全局字典编码。空表示为不使用全局字典。 + */ + String dictCode(); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationManyToMany.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationManyToMany.java new file mode 100644 index 00000000..bee48192 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationManyToMany.java @@ -0,0 +1,39 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 标注多对多的Model关系。 + * 重要提示:由于多对多关联表数据,很多时候都不需要跟随主表数据返回,所以该注解不会在 + * 生成的时候自动添加到实体类字段上,需要的时候,用户可自行手动添加。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RelationManyToMany { + + /** + * 多对多中间表的Mapper对象名称。 + * 如果是空字符串,BaseService会自动拼接为 relationModelClass().getSimpleName() + "Mapper"。 + * + * @return 被关联的本地Service对象名称。 + */ + String relationMapperName() default ""; + + /** + * 多对多关联表Model对象的Class对象。 + * + * @return 被关联Model对象的Class对象。 + */ + Class relationModelClass(); + + /** + * 多对多关联表Model对象中与主表关联的Id字段名称。 + * + * @return 被关联Model对象的关联Id字段名称。 + */ + String relationMasterIdField(); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationManyToManyAggregation.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationManyToManyAggregation.java new file mode 100644 index 00000000..cfa48e2f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationManyToManyAggregation.java @@ -0,0 +1,96 @@ +package com.orangeforms.common.core.annotation; + +import com.orangeforms.common.core.object.DummyClass; + +import java.lang.annotation.*; + +/** + * 主要用于多对多的Model关系。标注通过从表关联字段或者关联表关联字段计算主表聚合计算字段的规则。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RelationManyToManyAggregation { + + /** + * 当前对象的关联Id字段名称。 + * + * @return 当前对象的关联Id字段名称。 + */ + String masterIdField(); + + /** + * 被关联的本地Service对象名称。 + * 该参数的优先级低于 slaveServiceClass(), + * 如果是空字符串,BaseService会自动拼接为 slaveModelClass().getSimpleName() + "Service"。 + * + * @return 被关联的本地Service对象名称。 + */ + String slaveServiceName() default ""; + + /** + * 被关联的本地Service对象CLass类型。 + * + * @return 被关联的本地Service对象CLass类型。 + */ + Class slaveServiceClass() default DummyClass.class; + + /** + * 多对多从表Model对象的Class对象。 + * + * @return 被关联Model对象的Class对象。 + */ + Class slaveModelClass(); + + /** + * 多对多从表Model对象的关联Id字段名称。 + * + * @return 被关联Model对象的关联Id字段名称。 + */ + String slaveIdField(); + + /** + * 多对多关联表Model对象的Class对象。 + * + * @return 被关联Model对象的Class对象。 + */ + Class relationModelClass(); + + /** + * 多对多关联表Model对象中与主表关联的Id字段名称。 + * + * @return 被关联Model对象的关联Id字段名称。 + */ + String relationMasterIdField(); + + /** + * 多对多关联表Model对象中与从表关联的Id字段名称。 + * + * @return 被关联Model对象的关联Id字段名称。 + */ + String relationSlaveIdField(); + + /** + * 聚合计算所在的Model。 + * + * @return 聚合计算所在Model的Class。 + */ + Class aggregationModelClass(); + + /** + * 聚合类型。具体数值参考AggregationType对象。 + * + * @return 聚合类型。 + */ + int aggregationType(); + + /** + * 聚合计算所在Model的字段名称。 + * + * @return 聚合计算所在Model的字段名称。 + */ + String aggregationField(); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationOneToMany.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationOneToMany.java new file mode 100644 index 00000000..5a5d6e16 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationOneToMany.java @@ -0,0 +1,54 @@ +package com.orangeforms.common.core.annotation; + +import com.orangeforms.common.core.object.DummyClass; + +import java.lang.annotation.*; + +/** + * 标识Model之间的一对多关联关系。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RelationOneToMany { + + /** + * 当前对象的关联Id字段名称。 + * + * @return 当前对象的关联Id字段名称。 + */ + String masterIdField(); + + /** + * 被关联Model对象的Class对象。 + * + * @return 被关联Model对象的Class对象。 + */ + Class slaveModelClass(); + + /** + * 被关联Model对象的关联Id字段名称。 + * + * @return 被关联Model对象的关联Id字段名称。 + */ + String slaveIdField(); + + /** + * 被关联的本地Service对象名称。 + * 该参数的优先级低于 slaveServiceClass(), + * 如果是空字符串,BaseService会自动拼接为 slaveModelClass().getSimpleName() + "Service"。 + * + * @return 被关联的本地Service对象名称。 + */ + String slaveServiceName() default ""; + + /** + * 被关联的本地Service对象CLass类型。 + * + * @return 被关联的本地Service对象CLass类型。 + */ + Class slaveServiceClass() default DummyClass.class; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationOneToManyAggregation.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationOneToManyAggregation.java new file mode 100644 index 00000000..61befd73 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationOneToManyAggregation.java @@ -0,0 +1,68 @@ +package com.orangeforms.common.core.annotation; + +import com.orangeforms.common.core.object.DummyClass; + +import java.lang.annotation.*; + +/** + * 主要用于一对多的Model关系。标注通过从表关联字段计算主表聚合计算字段的规则。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RelationOneToManyAggregation { + + /** + * 当前对象的关联Id字段名称。 + * + * @return 当前对象的关联Id字段名称。 + */ + String masterIdField(); + + /** + * 被关联的本地Service对象名称。 + * 该参数的优先级低于 slaveServiceClass(), + * 如果是空字符串,BaseService会自动拼接为 slaveModelClass().getSimpleName() + "Service"。 + * + * @return 被关联的本地Service对象名称。 + */ + String slaveServiceName() default ""; + + /** + * 被关联的本地Service对象CLass类型。 + * + * @return 被关联的本地Service对象CLass类型。 + */ + Class slaveServiceClass() default DummyClass.class; + + /** + * 被关联Model对象的Class对象。 + * + * @return 被关联Model对象的Class对象。 + */ + Class slaveModelClass(); + + /** + * 被关联Model对象的关联Id字段名称。 + * + * @return 被关联Model对象的关联Id字段名称。 + */ + String slaveIdField(); + + /** + * 被关联Model对象中参与计算的聚合类型。具体数值参考AggregationType对象。 + * + * @return 被关联Model对象中参与计算的聚合类型。 + */ + int aggregationType(); + + /** + * 被关联Model对象中参与聚合计算的字段名称。 + * + * @return 被关联Model对象中参与计算字段的名称。 + */ + String aggregationField(); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationOneToOne.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationOneToOne.java new file mode 100644 index 00000000..fd38ca49 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationOneToOne.java @@ -0,0 +1,61 @@ +package com.orangeforms.common.core.annotation; + +import com.orangeforms.common.core.object.DummyClass; + +import java.lang.annotation.*; + +/** + * 标识Model之间的一对一关联关系。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RelationOneToOne { + + /** + * 当前对象的关联Id字段名称。 + * + * @return 当前对象的关联Id字段名称。 + */ + String masterIdField(); + + /** + * 被关联Model对象的Class对象。 + * + * @return 被关联Model对象的Class对象。 + */ + Class slaveModelClass(); + + /** + * 被关联Model对象的关联Id字段名称。 + * + * @return 被关联Model对象的关联Id字段名称。 + */ + String slaveIdField(); + + /** + * 被关联的本地Service对象名称。 + * 该参数的优先级低于 slaveServiceClass(), + * 如果是空字符串,BaseService会自动拼接为 slaveModelClass().getSimpleName() + "Service"。 + * + * @return 被关联的本地Service对象名称。 + */ + String slaveServiceName() default ""; + + /** + * 被关联的本地Service对象CLass类型。 + * + * @return 被关联的本地Service对象CLass类型。 + */ + Class slaveServiceClass() default DummyClass.class; + + /** + * 在一对一关联时,是否加载从表的字典关联。 + * + * @return 是否加载从表的字典关联。true关联,false则只返回从表自身数据。 + */ + boolean loadSlaveDict() default true; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/TenantFilterColumn.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/TenantFilterColumn.java new file mode 100644 index 00000000..368a9ea2 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/TenantFilterColumn.java @@ -0,0 +1,16 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 主要用于标记通过租户Id进行过滤的字段。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface TenantFilterColumn { + +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/UploadFlagColumn.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/UploadFlagColumn.java new file mode 100644 index 00000000..c01e6a16 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/UploadFlagColumn.java @@ -0,0 +1,24 @@ +package com.orangeforms.common.core.annotation; + +import com.orangeforms.common.core.upload.UploadStoreTypeEnum; + +import java.lang.annotation.*; + +/** + * 用于标记支持数据上传和下载的字段。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface UploadFlagColumn { + + /** + * 上传数据存储类型。 + * + * @return 上传数据存储类型。 + */ + UploadStoreTypeEnum storeType(); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/UserFilterColumn.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/UserFilterColumn.java new file mode 100644 index 00000000..af9275e2 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/annotation/UserFilterColumn.java @@ -0,0 +1,16 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 主要用于标记数据权限中基于UserId进行过滤的字段。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface UserFilterColumn { + +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/aop/DataSourceAspect.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/aop/DataSourceAspect.java new file mode 100644 index 00000000..5acff1a2 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/aop/DataSourceAspect.java @@ -0,0 +1,48 @@ +package com.orangeforms.common.core.aop; + +import com.orangeforms.common.core.annotation.MyDataSource; +import com.orangeforms.common.core.config.DataSourceContextHolder; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +/** + * 多数据源AOP切面处理类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Aspect +@Component +@Order(1) +@Slf4j +public class DataSourceAspect { + + /** + * 所有配置MyDataSource注解的Service实现类。 + */ + @Pointcut("execution(public * com.orangeforms..service..*(..)) " + + "&& @target(com.orangeforms.common.core.annotation.MyDataSource)") + public void datasourcePointCut() { + // 空注释,避免sonar警告 + } + + @Around("datasourcePointCut()") + public Object around(ProceedingJoinPoint point) throws Throwable { + Class clazz = point.getTarget().getClass(); + MyDataSource ds = clazz.getAnnotation(MyDataSource.class); + // 通过判断 DataSource 中的值来判断当前方法应用哪个数据源 + Integer originalType = DataSourceContextHolder.setDataSourceType(ds.value()); + log.debug("set datasource is " + ds.value()); + try { + return point.proceed(); + } finally { + DataSourceContextHolder.unset(originalType); + log.debug("unset datasource is " + originalType); + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/aop/DataSourceResolveAspect.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/aop/DataSourceResolveAspect.java new file mode 100644 index 00000000..f2697a64 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/aop/DataSourceResolveAspect.java @@ -0,0 +1,73 @@ +package com.orangeforms.common.core.aop; + +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.util.DataSourceResolver; +import com.orangeforms.common.core.config.DataSourceContextHolder; +import com.orangeforms.common.core.util.ApplicationContextHolder; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.Signature; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * 基于自定义解析规则的多数据源AOP切面处理类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Aspect +@Component +@Order(1) +@Slf4j +public class DataSourceResolveAspect { + + private final Map, DataSourceResolver> resolverMap = new ConcurrentHashMap<>(); + + /** + * 所有配置MyDataSourceResovler注解的Service实现类。 + */ + @Pointcut("execution(public * com.orangeforms..service..*(..)) " + + "&& @target(com.orangeforms.common.core.annotation.MyDataSourceResolver)") + public void datasourceResolverPointCut() { + // 空注释,避免sonar警告 + } + + @Around("datasourceResolverPointCut()") + public Object around(ProceedingJoinPoint point) throws Throwable { + Class clazz = point.getTarget().getClass(); + MyDataSourceResolver dsr = clazz.getAnnotation(MyDataSourceResolver.class); + Class resolverClass = dsr.resolver(); + DataSourceResolver resolver = + resolverMap.computeIfAbsent(resolverClass, ApplicationContextHolder::getBean); + Integer type = resolver.resolve(dsr.arg(), dsr.intArg(), this.getMethodName(point), point.getArgs()); + Integer originalType = null; + if (type != null) { + // 通过判断 DataSource 中的值来判断当前方法应用哪个数据源 + originalType = DataSourceContextHolder.setDataSourceType(type); + log.debug("set datasource is " + type); + } + try { + return point.proceed(); + } finally { + if (type != null) { + DataSourceContextHolder.unset(originalType); + log.debug("unset datasource is " + originalType); + } + } + } + + private String getMethodName(JoinPoint joinPoint) { + Signature signature = joinPoint.getSignature(); + MethodSignature methodSignature = (MethodSignature) signature; + return methodSignature.getMethod().getName(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/dao/BaseDaoMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/dao/BaseDaoMapper.java new file mode 100644 index 00000000..940e3367 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/dao/BaseDaoMapper.java @@ -0,0 +1,87 @@ +package com.orangeforms.common.core.base.dao; + +import com.mybatisflex.core.BaseMapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; +import java.util.Map; + +/** + * 数据访问对象的基类。 + * + * @param 主Model实体对象。 + * @author Jerry + * @date 2024-07-02 + */ +public interface BaseDaoMapper extends BaseMapper { + + /** + * 根据指定的表名、显示字段列表、过滤条件字符串和分组字段,返回聚合计算后的查询结果。 + * + * @param selectTable 表名称。 + * @param selectFields 返回字段列表,逗号分隔。 + * @param whereClause SQL常量形式的条件从句。 + * @param groupBy 分组字段列表,逗号分隔。 + * @return 对象可选字段Map列表。 + */ + @Select("") + List> getGroupedListByCondition( + @Param("selectTable") String selectTable, + @Param("selectFields") String selectFields, + @Param("whereClause") String whereClause, + @Param("groupBy") String groupBy); + + /** + * 根据指定的表名、显示字段列表、过滤条件字符串和排序字符串,返回查询结果。 + * + * @param selectTable 表名称。 + * @param selectFields 选择的字段列表。 + * @param whereClause 过滤字符串。 + * @param orderBy 排序字符串。 + * @return 查询结果。 + */ + @Select("") + List> getListByCondition( + @Param("selectTable") String selectTable, + @Param("selectFields") String selectFields, + @Param("whereClause") String whereClause, + @Param("orderBy") String orderBy); + + /** + * 用指定过滤条件,计算记录数量。 + * + * @param selectTable 表名称。 + * @param whereClause 过滤字符串。 + * @return 返回过滤后的数据数量。 + */ + @Select("") + int getCountByCondition(@Param("selectTable") String selectTable, @Param("whereClause") String whereClause); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/mapper/BaseModelMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/mapper/BaseModelMapper.java new file mode 100644 index 00000000..0713d5e4 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/mapper/BaseModelMapper.java @@ -0,0 +1,124 @@ +package com.orangeforms.common.core.base.mapper; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * Model对象到Domain类型对象的相互转换。实现类通常声明在Model实体类中。 + * + * @param Domain域对象类型。 + * @param Model实体对象类型。 + * @author Jerry + * @date 2024-07-02 + */ +public interface BaseModelMapper { + + /** + * 转换Model实体对象到Domain域对象。 + * + * @param model Model实体对象。 + * @return Domain域对象。 + */ + D fromModel(M model); + + /** + * 转换Model实体对象列表到Domain域对象列表。 + * + * @param modelList Model实体对象列表。 + * @return Domain域对象列表。 + */ + List fromModelList(List modelList); + + /** + * 转换Domain域对象到Model实体对象。 + * + * @param domain Domain域对象。 + * @return Model实体对象。 + */ + M toModel(D domain); + + /** + * 转换Domain域对象列表到Model实体对象列表。 + * + * @param domainList Domain域对象列表。 + * @return Model实体对象列表。 + */ + List toModelList(List domainList); + + /** + * 转换bean到map + * + * @param bean bean对象。 + * @param ignoreNullValue 值为null的字段是否转换到Map。 + * @param bean类型。 + * @return 转换后的map对象。 + */ + default Map beanToMap(T bean, boolean ignoreNullValue) { + return BeanUtil.beanToMap(bean, false, ignoreNullValue); + } + + /** + * 转换bean集合到map集合 + * + * @param dataList bean对象集合。 + * @param ignoreNullValue 值为null的字段是否转换到Map。 + * @param bean类型。 + * @return 转换后的map对象集合。 + */ + default List> beanToMap(List dataList, boolean ignoreNullValue) { + if (CollUtil.isEmpty(dataList)) { + return new LinkedList<>(); + } + return dataList.stream() + .map(o -> BeanUtil.beanToMap(o, false, ignoreNullValue)) + .collect(Collectors.toList()); + } + + /** + * 转换map到bean。 + * + * @param map map对象。 + * @param beanClazz bean的Class对象。 + * @param bean类型。 + * @return 转换后的bean对象。 + */ + default T mapToBean(Map map, Class beanClazz) { + return BeanUtil.toBeanIgnoreError(map, beanClazz); + } + + /** + * 转换map集合到bean集合。 + * + * @param mapList map对象集合。 + * @param beanClazz bean的Class对象。 + * @param bean类型。 + * @return 转换后的bean对象集合。 + */ + default List mapToBean(List> mapList, Class beanClazz) { + if (CollUtil.isEmpty(mapList)) { + return new LinkedList<>(); + } + return mapList.stream() + .map(m -> BeanUtil.toBeanIgnoreError(m, beanClazz)) + .collect(Collectors.toList()); + } + + /** + * 对于Map字段到Map字段的映射场景,MapStruct会根据方法签名自动选择该函数 + * 作为对象copy的函数。由于该函数是直接返回的,因此没有对象copy,效率更高。 + * 如果没有该函数,MapStruct会生成如下代码: + * Map map = courseDto.getTeacherIdDictMap(); + * if ( map != null ) { + * course.setTeacherIdDictMap( new HashMap( map ) ); + * } + * + * @param map map对象。 + * @return 直接返回的map。 + */ + default Map mapToMap(Map map) { + return map; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/mapper/DummyModelMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/mapper/DummyModelMapper.java new file mode 100644 index 00000000..3052c396 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/mapper/DummyModelMapper.java @@ -0,0 +1,58 @@ +package com.orangeforms.common.core.base.mapper; + +import java.util.List; + +/** + * 哑元占位对象。Model实体对象和Domain域对象相同的场景下使用。 + * 由于没有实际的数据转换,因此同时保证了代码统一和执行效率。 + * + * @param 数据类型。 + * @author Jerry + * @date 2024-07-02 + */ +public class DummyModelMapper implements BaseModelMapper { + + /** + * 不转换直接返回。 + * + * @param model Model实体对象。 + * @return Domain域对象。 + */ + @Override + public M fromModel(M model) { + return model; + } + + /** + * 不转换直接返回。 + * + * @param modelList Model实体对象列表。 + * @return Domain域对象列表。 + */ + @Override + public List fromModelList(List modelList) { + return modelList; + } + + /** + * 不转换直接返回。 + * + * @param domain Domain域对象。 + * @return Model实体对象。 + */ + @Override + public M toModel(M domain) { + return domain; + } + + /** + * 不转换直接返回。 + * + * @param domainList Domain域对象列表。 + * @return Model实体对象列表。 + */ + @Override + public List toModelList(List domainList) { + return domainList; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/model/BaseModel.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/model/BaseModel.java new file mode 100644 index 00000000..4235189a --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/model/BaseModel.java @@ -0,0 +1,40 @@ +package com.orangeforms.common.core.base.model; + +import com.mybatisflex.annotation.Column; +import lombok.Data; + +import java.util.Date; + +/** + * 实体对象的公共基类,所有子类均必须包含基类定义的数据表字段和实体对象字段。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class BaseModel { + + /** + * 创建者Id。 + */ + @Column(value = "create_user_id") + private Long createUserId; + + /** + * 创建时间。 + */ + @Column(value = "create_time") + private Date createTime; + + /** + * 更新者Id。 + */ + @Column(value = "update_user_id") + private Long updateUserId; + + /** + * 更新时间。 + */ + @Column(value = "update_time") + private Date updateTime; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/service/BaseDictService.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/service/BaseDictService.java new file mode 100644 index 00000000..c5ce2703 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/service/BaseDictService.java @@ -0,0 +1,229 @@ +package com.orangeforms.common.core.base.service; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ReflectUtil; +import com.mybatisflex.core.query.QueryWrapper; +import com.orangeforms.common.core.constant.GlobalDeletedFlag; +import com.orangeforms.common.core.cache.DictionaryCache; +import com.orangeforms.common.core.object.TokenData; +import lombok.extern.slf4j.Slf4j; +import org.springframework.transaction.annotation.Transactional; + +import java.io.Serializable; +import java.util.*; + +/** + * 带有缓存功能的字典Service基类,需要留意的是,由于缓存基于Key/Value方式存储, + * 目前仅支持基于主键字段的缓存查找,其他条件的查找仍然从数据源获取。 + * + * @param Model实体对象的类型。 + * @param Model对象主键的类型。 + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public abstract class BaseDictService + extends BaseService implements IBaseDictService { + + /** + * 缓存池对象。 + */ + protected DictionaryCache dictionaryCache; + + /** + * 构造函数使用缺省缓存池对象。 + */ + protected BaseDictService() { + super(); + } + + /** + * 重新加载数据库中所有当前表数据到系统内存。 + * + * @param force true则强制刷新,如果false,当缓存中存在数据时不刷新。 + */ + @Override + public void reloadCachedData(boolean force) { + // 在非强制刷新情况下。 + // 先行判断缓存中是否存在数据,如果有就不加载了。 + if (!force && dictionaryCache.getCount() > 0) { + return; + } + List allList = super.getAllList(); + dictionaryCache.reload(allList, force); + } + + /** + * 保存新增对象。 + * + * @param data 新增对象。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public M saveNew(M data) { + // 清空全部缓存 + dictionaryCache.invalidateAll(); + if (deletedFlagFieldName != null) { + ReflectUtil.setFieldValue(data, deletedFlagFieldName, GlobalDeletedFlag.NORMAL); + } + if (tenantIdField != null) { + ReflectUtil.setFieldValue(data, tenantIdField, TokenData.takeFromRequest().getTenantId()); + } + mapper().insert(data); + return data; + } + + /** + * 更新数据对象。 + * + * @param data 更新的对象。 + * @param originalData 原有数据对象。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(M data, M originalData) { + dictionaryCache.invalidateAll(); + if (tenantIdField != null) { + ReflectUtil.setFieldValue(data, tenantIdField, TokenData.takeFromRequest().getTenantId()); + } + return mapper().update(data) == 1; + } + + /** + * 删除指定数据。 + * + * @param id 主键Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(K id) { + dictionaryCache.invalidateAll(); + return mapper().deleteById(id) == 1; + } + + /** + * 直接从缓存池中获取主键Id关联的数据。如果缓存中不存在,再从数据库中取出并回写到缓存。 + * + * @param id 主键Id。 + * @return 主键关联的数据,不存在返回null。 + */ + @SuppressWarnings("unchecked") + @Override + public M getById(Serializable id) { + M data = dictionaryCache.get((K) id); + if (data != null) { + return data; + } + if (dictionaryCache.getCount() != 0) { + return data; + } + this.reloadCachedData(true); + return dictionaryCache.get((K) id); + } + + /** + * 直接从缓存池中获取所有数据。 + * + * @return 返回所有数据。 + */ + @Override + public List getAllListFromCache() { + List resultList = dictionaryCache.getAll(); + if (CollUtil.isNotEmpty(resultList)) { + return resultList; + } + this.reloadCachedData(true); + return dictionaryCache.getAll(); + } + + /** + * 直接从缓存池中返回符合主键 in (idValues) 条件的所有数据。 + * 对于缓存中不存在的数据,从数据库中获取并回写入缓存。 + * + * @param idValues 主键值列表。 + * @return 检索后的数据列表。 + */ + @Override + public List getInList(Set idValues) { + List resultList = dictionaryCache.getInList(idValues); + // 如果从缓存中获取与请求的id完全相同就直接返回。 + if (resultList.size() == idValues.size()) { + return resultList; + } + // 如果此时缓存中存在数据,说明有部分id是不存在的。也可以直接返回了。 + if (dictionaryCache.getCount() != 0) { + return resultList; + } + // 执行到这里,说明缓存是空的,所有需要重新加载并再次从缓存中读取并返回。 + this.reloadCachedData(true); + return dictionaryCache.getInList(idValues); + } + + @Override + public List getListByParentId(K parentId) { + List resultList = dictionaryCache.getListByParentId(parentId); + // 如果包含数据就直接返回了 + if (CollUtil.isNotEmpty(resultList)) { + return resultList; + } + // 如果缓存中存在该字典数据,说明该parentId下子对象列表为空,也可以直接返回了。 + if (this.getCachedCount() != 0) { + return resultList; + } + // 执行到这里就需要重新加载全部缓存了。 + this.reloadCachedData(true); + return dictionaryCache.getListByParentId(parentId); + } + + /** + * 返回符合 inFilterField in (inFilterValues) 条件的所有数据。属性property是主键,则从缓存中读取。 + * + * @param inFilterField 参与(In-list)过滤的Java字段。 + * @param inFilterValues 参与(In-list)过滤的Java字段值集合。 + * @return 检索后的数据列表。 + */ + @SuppressWarnings("unchecked") + @Override + public List getInList(String inFilterField, Set inFilterValues) { + if (inFilterField.equals(this.idFieldName)) { + return this.getInList((Set) inFilterValues); + } + return super.getInList(inFilterField, inFilterValues); + } + + /** + * 判断参数值列表中的所有数据,是否全部存在。另外,keyName字段在数据表中必须是唯一键值,否则返回结果会出现误判。 + * + * @param inFilterField 待校验的数据字段,这里使用Java对象中的属性,如courseId,而不是数据字段名course_id。 + * @param inFilterValues 数据值集合。 + * @return 全部存在返回true,否则false。 + */ + @SuppressWarnings("unchecked") + @Override + public boolean existUniqueKeyList(String inFilterField, Set inFilterValues) { + if (CollUtil.isEmpty(inFilterValues)) { + return true; + } + if (inFilterField.equals(this.idFieldName)) { + List dataList = this.getInList((Set) inFilterValues); + return dataList.size() == inFilterValues.size(); + } + String columnName = this.safeMapToColumnName(inFilterField); + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.in(columnName, inFilterValues); + return mapper().selectCountByQuery(queryWrapper) == inFilterValues.size(); + } + + /** + * 获取缓存中的数据数量。 + * + * @return 缓存中的数据总量。 + */ + @Override + public int getCachedCount() { + return dictionaryCache.getCount(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/service/BaseService.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/service/BaseService.java new file mode 100644 index 00000000..83513dcc --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/service/BaseService.java @@ -0,0 +1,2278 @@ +package com.orangeforms.common.core.base.service; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.text.StrFormatter; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.core.util.ReflectUtil; +import com.mybatisflex.annotation.Column; +import com.mybatisflex.annotation.Id; +import com.mybatisflex.annotation.Table; +import com.mybatisflex.core.query.QueryWrapper; +import com.mybatisflex.spring.service.impl.ServiceImpl; +import com.orangeforms.common.core.annotation.*; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.constant.AggregationType; +import com.orangeforms.common.core.constant.GlobalDeletedFlag; +import com.orangeforms.common.core.constant.MaskFieldTypeEnum; +import com.orangeforms.common.core.exception.InvalidDataFieldException; +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.*; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.Assert; + +import java.io.Serializable; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import java.util.function.Function; + +import static java.util.stream.Collectors.*; + +/** + * 所有Service的基类。 + * + * @param Model对象的类型。 + * @param Model对象主键的类型。 + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public abstract class BaseService extends ServiceImpl, M> implements IBaseService { + + /** + * 当前Service关联的主Model实体对象的Class。 + */ + protected final Class modelClass; + /** + * 当前Service关联的主Model实体对象主键字段的Class。 + */ + protected final Class idFieldClass; + /** + * 当前Service关联的主Model实体对象的实际表名称。 + */ + protected final String tableName; + /** + * 当前Service关联的主Model对象主键字段名称。 + */ + protected String idFieldName; + /** + * 当前Service关联的主数据表中主键列名称。 + */ + protected String idColumnName; + /** + * 当前Service关联的主Model对象逻辑删除字段名称。 + */ + protected String deletedFlagFieldName; + /** + * 当前Service关联的主数据表中逻辑删除字段名称。 + */ + protected String deletedFlagColumnName; + /** + * 当前Service关联的主Model对象租户Id字段。 + */ + protected Field tenantIdField; + /** + * 流程实例状态字段。 + */ + protected Field flowStatusField; + /** + * 流程最后审批状态字段 + */ + protected Field flowLatestApprovalStatusField; + /** + * 脱敏字段列表。 + */ + protected List maskFieldList; + /** + * 当前Service关联的主Model对象租户Id字段名称。 + */ + protected String tenantIdFieldName; + /** + * 当前Service关联的主数据表中租户Id列名称。 + */ + protected String tenantIdColumnName; + /** + * 当前Job服务源主表Model对象最后更新时间字段名称。 + */ + protected String jobUpdateTimeFieldName; + /** + * 当前Job服务源主表Model对象最后更新时间列名称。 + */ + protected String jobUpdateTimeColumnName; + /** + * 当前业务服务源主表Model对象最后更新时间字段名称。 + */ + protected String updateTimeFieldName; + /** + * 当前业务服务源主表Model对象最后更新时间列名称。 + */ + protected String updateTimeColumnName; + /** + * 当前业务服务源主表Model对象最后更新用户Id字段名称。 + */ + protected String updateUserIdFieldName; + /** + * 当前业务服务源主表Model对象最后更新用户Id列名称。 + */ + protected String updateUserIdColumnName; + /** + * 当前Service关联的主Model对象主键字段赋值方法的反射对象。 + */ + protected Method setIdFieldMethod; + /** + * 当前Service关联的主Model对象主键字段访问方法的反射对象。 + */ + protected Method getIdFieldMethod; + /** + * 当前Service关联的主Model对象逻辑删除字段赋值方法的反射对象。 + */ + protected Method setDeletedFlagMethod; + /** + * 当前Service关联的全局字典对象的结构列表,该字段在系统启动阶段一次性预加载,提升运行时效率。 + */ + protected final List relationGlobalDictStructList = new LinkedList<>(); + /** + * 当前Service关联的主Model对象的所有常量字典关联的结构列表,该字段在系统启动阶段一次性预加载,提升运行时效率。 + */ + protected final List relationConstDictStructList = new LinkedList<>(); + /** + * 当前Service关联的主Model对象的所有字典关联的结构列表,该字段在系统启动阶段一次性预加载,提升运行时效率。 + */ + protected final List localRelationDictStructList = new LinkedList<>(); + /** + * 当前Service关联的主Model对象的所有一对一关联的结构列表,该字段在系统启动阶段一次性预加载,提升运行时效率。 + */ + protected final List localRelationOneToOneStructList = new LinkedList<>(); + /** + * 当前Service关联的主Model对象的所有一对多关联的结构列表,该字段在系统启动阶段一次性预加载,提升运行时效率。 + */ + protected final List localRelationOneToManyStructList = new LinkedList<>(); + /** + * 当前Service关联的主Model对象的所有多对多关联的结构列表,该字段在系统启动阶段一次性预加载,提升运行时效率。 + */ + protected final List localRelationManyToManyStructList = new LinkedList<>(); + /** + * 当前Service关联的主Model对象的所有一对多聚合关联的结构列表,该字段在系统启动阶段一次性预加载,提升运行时效率。 + */ + protected final List localRelationOneToManyAggrStructList = new LinkedList<>(); + /** + * 当前Service关联的主Model对象的所有多对多聚合关联的结构列表,该字段在系统启动阶段一次性预加载,提升运行时效率。 + */ + protected final List localRelationManyToManyAggrStructList = new LinkedList<>(); + /** + * 基础表的实体对象及表信息。 + */ + protected final TableModelInfo tableModelInfo = new TableModelInfo(); + private final Map, MaskFieldHandler> maskFieldHandlerMap = new ConcurrentHashMap<>(); + + private static final String GROUPED_KEY = "GROUPED_KEY"; + private static final String AGGREGATED_VALUE = "AGGREGATED_VALUE"; + private static final String AND_OP = " AND "; + + @Override + public BaseDaoMapper getMapper() { + return mapper(); + } + + /** + * 构造函数,在实例化的时候,一次性完成所有有关主Model对象信息的加载。 + */ + @SuppressWarnings("unchecked") + protected BaseService() { + Class type = getClass(); + while (!(type.getGenericSuperclass() instanceof ParameterizedType)) { + type = type.getSuperclass(); + } + modelClass = (Class) ((ParameterizedType) type.getGenericSuperclass()).getActualTypeArguments()[0]; + idFieldClass = (Class) ((ParameterizedType) type.getGenericSuperclass()).getActualTypeArguments()[1]; + this.tableName = modelClass.getAnnotation(Table.class).value(); + Field[] fields = ReflectUtil.getFields(modelClass); + for (Field field : fields) { + initializeField(field); + } + tableModelInfo.setModelName(modelClass.getSimpleName()); + tableModelInfo.setTableName(this.tableName); + tableModelInfo.setKeyFieldName(idFieldName); + tableModelInfo.setKeyColumnName(idColumnName); + } + + @Override + public TableModelInfo getTableModelInfo() { + return this.tableModelInfo; + } + + private void initializeField(Field field) { + if (idFieldName == null && null != field.getAnnotation(Id.class)) { + idFieldName = field.getName(); + Id c = field.getAnnotation(Id.class); + idColumnName = c == null ? idFieldName : c.value(); + setIdFieldMethod = ReflectUtil.getMethod( + modelClass, "set" + StrUtil.upperFirst(idFieldName), idFieldClass); + getIdFieldMethod = ReflectUtil.getMethod( + modelClass, "get" + StrUtil.upperFirst(idFieldName)); + } + if (null != field.getAnnotation(JobUpdateTimeColumn.class)) { + jobUpdateTimeFieldName = field.getName(); + jobUpdateTimeColumnName = this.safeMapToColumnName(jobUpdateTimeFieldName); + } + Column logicDeleteColumn = field.getAnnotation(Column.class); + if (null != logicDeleteColumn && logicDeleteColumn.isLogicDelete()) { + deletedFlagFieldName = field.getName(); + deletedFlagColumnName = this.safeMapToColumnName(deletedFlagFieldName); + setDeletedFlagMethod = ReflectUtil.getMethod( + modelClass, "set" + StrUtil.upperFirst(deletedFlagFieldName), Integer.class); + } + if (null != field.getAnnotation(TenantFilterColumn.class)) { + tenantIdField = field; + tenantIdFieldName = field.getName(); + tenantIdColumnName = this.safeMapToColumnName(tenantIdFieldName); + } + if (null != field.getAnnotation(FlowStatusColumn.class)) { + flowStatusField = field; + } + if (null != field.getAnnotation(FlowLatestApprovalStatusColumn.class)) { + flowLatestApprovalStatusField = field; + } + if (null != field.getAnnotation(MaskField.class)) { + if (maskFieldList == null) { + maskFieldList = new LinkedList<>(); + } + maskFieldList.add(field); + } + } + + /** + * 获取子类中注入的Mapper类。 + * + * @return 子类中注入的Mapper类。 + */ + protected abstract BaseDaoMapper mapper(); + + @SuppressWarnings("unchecked") + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNewOrUpdate(M data, Consumer saveNew, BiConsumer update) { + if (data == null) { + return; + } + K id = (K) ReflectUtil.getFieldValue(data, idFieldName); + if (id == null) { + saveNew.accept(data); + } else { + update.accept(data, this.getById(id)); + } + } + + @SuppressWarnings("unchecked") + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNewOrUpdateBatch(List dataList, Consumer> saveNewBatch, BiConsumer update) { + if (CollUtil.isEmpty(dataList)) { + return; + } + List saveNewDataList = dataList.stream() + .filter(c -> ReflectUtil.getFieldValue(c, idFieldName) == null).collect(toList()); + if (CollUtil.isNotEmpty(saveNewDataList)) { + saveNewBatch.accept(saveNewDataList); + } + List updateDataList = dataList.stream() + .filter(c -> ReflectUtil.getFieldValue(c, idFieldName) != null).collect(toList()); + if (CollUtil.isNotEmpty(updateDataList)) { + for (M data : updateDataList) { + K id = (K) ReflectUtil.getFieldValue(data, idFieldName); + update.accept(data, this.getById(id)); + } + } + } + + /** + * 根据过滤条件删除数据。 + * + * @param filter 过滤对象。 + * @return 删除数量。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public Integer removeBy(M filter) { + return mapper().deleteByQuery(QueryWrapper.create(filter)); + } + + @Transactional(rollbackFor = Exception.class) + public boolean remove(K id) { + return mapper().deleteById(id) > 0; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void updateBatchOneToManyRelation( + String relationFieldName, + Object relationFieldValue, + String updateUserIdFieldName, + String updateTimeFieldName, + List dataList, + Consumer> batchInserter) { + // 删除在现有数据列表dataList中不存在的从表数据。 + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(this.safeMapToColumnName(relationFieldName), relationFieldName); + if (CollUtil.isNotEmpty(dataList)) { + Set keptIdSet = dataList.stream() + .filter(c -> ReflectUtil.getFieldValue(c, idFieldName) != null) + .map(c -> ReflectUtil.getFieldValue(c, idFieldName)).collect(toSet()); + if (CollUtil.isNotEmpty(keptIdSet)) { + queryWrapper.notIn(idColumnName, keptIdSet); + } + } + mapper.deleteByQuery(queryWrapper); + if (CollUtil.isEmpty(dataList)) { + return; + } + // 没有包含主键的对象被视为新对象,为了效率最优化,这里执行批量插入。 + List newDataList = dataList.stream() + .filter(c -> ReflectUtil.getFieldValue(c, idFieldName) == null).collect(toList()); + if (CollUtil.isNotEmpty(newDataList)) { + newDataList.forEach(o -> ReflectUtil.setFieldValue(o, relationFieldName, relationFieldValue)); + batchInserter.accept(newDataList); + } + // 对于主键已经存在的数据,我们视为已存在数据,这里执行逐条更新操作。 + List updateDataList = + dataList.stream().filter(c -> ReflectUtil.getFieldValue(c, idFieldName) != null).toList(); + for (M updateData : updateDataList) { + // 如果前端将更新用户Id置空,这里使用当前用户更新该字段。 + if (updateUserIdFieldName != null) { + ReflectUtil.setFieldValue(updateData, updateUserIdFieldName, TokenData.takeFromRequest().getUserId()); + } + // 如果前端将更新时间置空,这里使用当前时间更新该字段。 + if (updateTimeFieldName != null) { + ReflectUtil.setFieldValue(updateData, updateTimeFieldName, new Date()); + } + if (this.tenantIdField != null) { + ReflectUtil.setFieldValue(updateData, tenantIdField, TokenData.takeFromRequest().getTenantId()); + } + if (this.deletedFlagFieldName != null) { + ReflectUtil.setFieldValue(updateData, deletedFlagFieldName, GlobalDeletedFlag.NORMAL); + } + @SuppressWarnings("unchecked") + K id = (K) ReflectUtil.getFieldValue(updateData, idFieldName); + this.compareAndSetMaskFieldData(updateData, id); + mapper().update(updateData); + } + } + + /** + * 判断指定字段的数据是否存在,且仅仅存在一条记录。 + * 如果是基于主键的过滤,会直接调用existId过滤函数,提升性能。在有缓存的场景下,也可以利用缓存。 + * + * @param fieldName 待过滤的字段名(Java 字段)。 + * @param fieldValue 字段值。 + * @return 存在且仅存在一条返回true,否则false。 + */ + @SuppressWarnings("unchecked") + @Override + public boolean existOne(String fieldName, Object fieldValue) { + if (fieldName.equals(this.idFieldName)) { + return this.existId((K) fieldValue); + } + String columnName = MyModelUtil.mapToColumnName(fieldName, modelClass); + return mapper().selectCountByQuery(new QueryWrapper().eq(columnName, fieldValue)) == 1; + } + + /** + * 判断主键Id关联的数据是否存在。 + * + * @param id 主键Id。 + * @return 存在返回true,否则false。 + */ + @Override + public boolean existId(K id) { + return getById(id) != null; + } + + @Override + public M getOne(M filter) { + return mapper().selectOneByQuery(QueryWrapper.create(filter)); + } + + /** + * 返回符合 filterField = filterValue 条件的一条数据。 + * + * @param filterField 过滤的Java字段。 + * @param filterValue 过滤的Java字段值。 + * @return 查询后的数据对象。 + */ + @SuppressWarnings("unchecked") + @Override + public M getOne(String filterField, Object filterValue) { + if (filterField.equals(idFieldName)) { + return this.getById((K) filterValue); + } + String columnName = this.safeMapToColumnName(filterField); + QueryWrapper queryWrapper = new QueryWrapper().eq(columnName, filterValue); + return mapper().selectOneByQuery(queryWrapper); + } + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * + * @param id 主表主键Id。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @return 查询结果对象。 + */ + @Override + public M getByIdWithRelation(K id, MyRelationParam relationParam) { + M dataObject = this.getById(id); + this.buildRelationForData(dataObject, relationParam); + return dataObject; + } + + /** + * 获取所有数据。 + * + * @return 返回所有数据。 + */ + @Override + public List getAllList() { + return mapper().selectAll(); + } + + /** + * 获取排序后所有数据。 + * + * @param orderByProperties 需要排序的字段属性,这里使用Java对象中的属性名,而不是数据库字段名。 + * @return 返回排序后所有数据。 + */ + @Override + public List getAllListByOrder(String... orderByProperties) { + String[] columns = new String[orderByProperties.length]; + for (int i = 0; i <= orderByProperties.length - 1; i++) { + columns[i] = this.safeMapToColumnName(orderByProperties[i]); + } + return mapper().selectListByQuery(new QueryWrapper().orderBy(columns)); + } + + /** + * 判断参数值主键集合中的所有数据,是否全部存在 + * + * @param idSet 待校验的主键集合。 + * @return 全部存在返回true,否则false。 + */ + @Override + public boolean existAllPrimaryKeys(Set idSet) { + if (CollUtil.isEmpty(idSet)) { + return true; + } + return this.existUniqueKeyList(idFieldName, idSet); + } + + /** + * 判断参数值列表中的所有数据,是否全部存在。另外,keyName字段在数据表中必须是唯一键值,否则返回结果会出现误判。 + * + * @param inFilterField 待校验的数据字段,这里使用Java对象中的属性,如courseId,而不是数据字段名course_id + * @param inFilterValues 数据值列表。 + * @return 全部存在返回true,否则false。 + */ + @Override + public boolean existUniqueKeyList(String inFilterField, Set inFilterValues) { + if (CollUtil.isEmpty(inFilterValues)) { + return true; + } + String column = this.safeMapToColumnName(inFilterField); + return mapper().selectCountByQuery(new QueryWrapper().in(column, inFilterValues)) == inFilterValues.size(); + } + + @Override + public List notExist(String filterField, Set filterSet, boolean findFirst) { + List notExistIdList = new LinkedList<>(); + int start = 0; + int count = 1000; + if (filterSet.size() > count) { + do { + int end = Math.min(filterSet.size(), start + count); + List subFilterList = CollUtil.sub(filterSet, start, end); + doNotExistQuery(filterField, subFilterList, findFirst, notExistIdList); + if ((findFirst && CollUtil.isNotEmpty(notExistIdList)) || end == filterSet.size()) { + break; + } + start += count; + } while (true); + } else { + doNotExistQuery(filterField, filterSet, findFirst, notExistIdList); + } + return notExistIdList; + } + + private void doNotExistQuery( + String filterField, Collection filterSet, boolean findFirst, List notExistIdList) { + String columnName = this.safeMapToColumnName(filterField); + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.in(columnName, filterSet); + queryWrapper.select(columnName); + Set existIdSet = mapper().selectListByQuery(queryWrapper).stream() + .map(c -> ReflectUtil.getFieldValue(c, filterField)).collect(toSet()); + for (R filterData : filterSet) { + if (!existIdSet.contains(filterData)) { + notExistIdList.add(filterData); + if (findFirst) { + break; + } + } + } + } + + @Override + public List getInList(Set idValues) { + return this.getInList(idFieldName, idValues, null); + } + + @Override + public List getInList(String inFilterField, Set inFilterValues) { + return this.getInList(inFilterField, inFilterValues, null); + } + + @Override + public List getInList(String inFilterField, Set inFilterValues, String orderBy) { + if (CollUtil.isEmpty(inFilterValues)) { + return new LinkedList<>(); + } + String column = this.safeMapToColumnName(inFilterField); + QueryWrapper queryWrapper = new QueryWrapper().in(column, inFilterValues); + if (StrUtil.isNotBlank(orderBy)) { + queryWrapper.orderBy(orderBy); + } + return mapper().selectListByQuery(queryWrapper); + } + + @Override + public List getInListWithRelation(Set idValues, MyRelationParam relationParam) { + List resultList = this.getInList(idValues); + this.buildRelationForDataList(resultList, relationParam); + return resultList; + } + + @Override + public List getInListWithRelation(String inFilterField, Set inFilterValues, MyRelationParam relationParam) { + List resultList = this.getInList(inFilterField, inFilterValues); + this.buildRelationForDataList(resultList, relationParam); + return resultList; + } + + @Override + public List getInListWithRelation( + String inFilterField, Set inFilterValues, String orderBy, MyRelationParam relationParam) { + List resultList = this.getInList(inFilterField, inFilterValues, orderBy); + this.buildRelationForDataList(resultList, relationParam); + return resultList; + } + + @Override + public List getNotInList(Set idValues) { + return this.getNotInList(idFieldName, idValues, null); + } + + @Override + public List getNotInList(String inFilterField, Set inFilterValues) { + return this.getNotInList(inFilterField, inFilterValues, null); + } + + @Override + public List getNotInList(String inFilterField, Set inFilterValues, String orderBy) { + QueryWrapper queryWrapper; + if (CollUtil.isEmpty(inFilterValues)) { + queryWrapper = new QueryWrapper(); + } else { + String column = this.safeMapToColumnName(inFilterField); + queryWrapper = new QueryWrapper().notIn(column, inFilterValues); + } + if (StrUtil.isNotBlank(orderBy)) { + queryWrapper.orderBy(orderBy); + } + return mapper().selectListByQuery(queryWrapper); + } + + @Override + public List getNotInListWithRelation(Set idValues, MyRelationParam relationParam) { + List resultList = this.getNotInList(idValues); + this.buildRelationForDataList(resultList, relationParam); + return resultList; + } + + @Override + public List getNotInListWithRelation( + String inFilterField, Set inFilterValues, MyRelationParam relationParam) { + List resultList = this.getNotInList(inFilterField, inFilterValues); + this.buildRelationForDataList(resultList, relationParam); + return resultList; + } + + @Override + public List getNotInListWithRelation( + String inFilterField, Set inFilterValues, String orderBy, MyRelationParam relationParam) { + List resultList = this.getNotInList(inFilterField, inFilterValues, orderBy); + this.buildRelationForDataList(resultList, relationParam); + return resultList; + } + + @Override + public long getCountByFilter(M filter) { + return mapper().selectCountByQuery(QueryWrapper.create(filter)); + } + + @Override + public boolean existByFilter(M filter) { + return this.getCountByFilter(filter) > 0; + } + + @Override + public List getListByFilter(M filter) { + return mapper().selectListByQuery(QueryWrapper.create(filter)); + } + + @Override + public List getListWithRelationByFilter(M filter, String orderBy, MyRelationParam relationParam) { + QueryWrapper queryWrapper = filter == null ? QueryWrapper.create() : QueryWrapper.create(filter); + if (StrUtil.isNotBlank(orderBy)) { + queryWrapper.orderBy(orderBy); + } + List resultList = mapper().selectListByQuery(queryWrapper); + this.buildRelationForDataList(resultList, relationParam); + return resultList; + } + + /** + * 获取父主键Id下的所有子数据列表。 + * + * @param parentIdFieldName 父主键字段名字,如"courseId"。 + * @param parentId 父主键的值。 + * @return 父主键Id下的所有子数据列表。 + */ + @Override + public List getListByParentId(String parentIdFieldName, K parentId) { + QueryWrapper queryWrapper = new QueryWrapper(); + String parentIdColumn = this.safeMapToColumnName(parentIdFieldName); + if (parentId != null) { + queryWrapper.eq(parentIdColumn, parentId); + } else { + queryWrapper.isNull(parentIdColumn); + } + return mapper().selectListByQuery(queryWrapper); + } + + /** + * 根据指定的显示字段列表、过滤条件字符串和分组字符串,返回聚合计算后的查询结果。(基本是内部框架使用,不建议外部接口直接使用)。 + * + * @param selectFields 选择的字段列表,多个字段逗号分隔。 + * NOTE: 如果数据表字段和Java对象字段名字不同,Java对象字段应该以别名的形式出现。 + * 如: table_column_name modelFieldName。否则无法被反射回Bean对象。 + * @param whereClause SQL常量形式的条件从句。 + * @param groupBy SQL常量形式分组字段列表,逗号分隔。 + * @return 聚合计算后的数据结果集。 + */ + @Override + public List> getGroupedListByCondition( + String selectFields, String whereClause, String groupBy) { + return mapper().getGroupedListByCondition(tableName, selectFields, whereClause, groupBy); + } + + /** + * 根据指定的显示字段列表、过滤条件字符串和排序字符串,返回查询结果。(基本是内部框架使用,不建议外部接口直接使用)。 + * + * @param selectList 选择的Java字段列表。如果为空表示返回全部字段。 + * @param filter 过滤对象。 + * @param whereClause SQL常量形式的条件从句。 + * @param orderBy SQL常量形式排序字段列表,逗号分隔。 + * @return 查询结果。 + */ + @Override + public List getListByCondition(List selectList, M filter, String whereClause, String orderBy) { + QueryWrapper queryWrapper = filter == null ? QueryWrapper.create() : QueryWrapper.create(filter); + if (CollUtil.isNotEmpty(selectList)) { + String[] columns = new String[selectList.size()]; + for (int i = 0; i < selectList.size(); i++) { + columns[i] = this.safeMapToColumnName(selectList.get(i)); + } + queryWrapper.select(columns); + } + if (StrUtil.isNotBlank(whereClause)) { + queryWrapper.and(whereClause); + } + if (StrUtil.isNotBlank(orderBy)) { + queryWrapper.orderBy(orderBy); + } + return mapper().selectListByQuery(queryWrapper); + } + + /** + * 用指定过滤条件,计算记录数量。(基本是内部框架使用,不建议外部接口直接使用)。 + * + * @param whereClause SQL常量形式的条件从句。 + * @return 返回过滤后的数据数量。 + */ + @Override + public Integer getCountByCondition(String whereClause) { + return mapper().getCountByCondition(this.tableName, whereClause); + } + + @Override + public void maskFieldData(M data, Set ignoreFieldSet) { + if (data != null) { + this.maskFieldDataList(CollUtil.newArrayList(data), ignoreFieldSet); + } + } + + @Override + public void maskFieldDataList(List dataList, Set ignoreFieldSet) { + if (CollUtil.isEmpty(maskFieldList)) { + return; + } + for (Field maskField : maskFieldList) { + if (!CollUtil.contains(ignoreFieldSet, maskField.getName())) { + MaskField anno = maskField.getAnnotation(MaskField.class); + for (M data : dataList) { + Object maskedValue = this.doMaskFieldData(data, maskField, anno); + ReflectUtil.setFieldValue(data, maskField, maskedValue); + } + } + } + } + + @Override + public void compareAndSetMaskFieldData(M data, M originalData) { + if (CollUtil.isEmpty(maskFieldList)) { + return; + } + for (Field maskField : maskFieldList) { + Object value = ReflectUtil.getFieldValue(data, maskField); + if (value == null) { + continue; + } + MaskField anno = maskField.getAnnotation(MaskField.class); + String maskChar = String.valueOf(anno.maskChar()); + // 如果此时包含了掩码字符,说明数据没有变化,就要和原字段值脱敏后的结果比对。 + // 如果一致就用脱敏前的原值,覆盖当前提交的(包含掩码的)值,否则说明进行了部分 + // 修改,但是字段值中仍然含有掩码字符,这是不允许的。 + if (value.toString().contains(maskChar)) { + Object maskedOriginalValue = this.doMaskFieldData(originalData, maskField, anno); + if (ObjectUtil.notEqual(value, maskedOriginalValue)) { + throw new MyRuntimeException("数据验证失败,不能仅修改部分脱敏数据!"); + } + Object originalValue = ReflectUtil.getFieldValue(originalData, maskField); + ReflectUtil.setFieldValue(data, maskField, originalValue); + } + } + } + + @Override + public void verifyMaskFieldData(M data) { + if (CollUtil.isEmpty(maskFieldList)) { + return; + } + for (Field field : maskFieldList) { + Object value = ReflectUtil.getFieldValue(data, field); + if (value != null) { + String maskChar = String.valueOf(field.getAnnotation(MaskField.class).maskChar()); + if (value.toString().contains(maskChar)) { + throw new MyRuntimeException("数据验证失败,字段 [" + field.getName() + "] 数据存在脱敏掩码字符!"); + } + } + } + } + + @Override + public CallResult verifyRelatedData(M data, M originalData) { + return CallResult.ok(); + } + + @SuppressWarnings("unchecked") + @Override + public CallResult verifyRelatedData(M data) { + if (data == null) { + return CallResult.ok(); + } + Object id = ReflectUtil.getFieldValue(data, idFieldName); + if (id == null) { + return this.verifyRelatedData(data, null); + } + M originalData = this.getById((K) id); + if (originalData == null) { + return CallResult.error("数据验证失败,源数据不存在!"); + } + return this.verifyRelatedData(data, originalData); + } + + @SuppressWarnings("unchecked") + @Override + public CallResult verifyRelatedData(List dataList) { + if (CollUtil.isEmpty(dataList)) { + return CallResult.ok(); + } + // 1. 先过滤出数据列表中的主键Id集合。 + Set idList = dataList.stream() + .filter(c -> ReflectUtil.getFieldValue(c, idFieldName) != null) + .map(c -> (K) ReflectUtil.getFieldValue(c, idFieldName)).collect(toSet()); + // 2. 列表中,我们目前仅支持全部是更新数据,或全部新增数据,不能混着。如果有主键值,说明当前全是更新数据。 + if (CollUtil.isNotEmpty(idList)) { + // 3. 这里是批量读取的优化,用一个主键值得in list查询,一步获取全部原有数据。然后再在内存中基于Map排序。 + List originalList = this.getInList(idList); + Map originalMap = originalList.stream() + .collect(toMap(c -> ReflectUtil.getFieldValue(c, idFieldName), c2 -> c2)); + // 迭代列表,传入当前最新数据和更新前数据进行比对,如果关联数据变化了,就对新数据进行合法性验证。 + for (M data : dataList) { + CallResult result = this.verifyRelatedData( + data, originalMap.get(ReflectUtil.getFieldValue(data, idFieldName))); + if (!result.isSuccess()) { + return result; + } + } + } else { + // 4. 迭代列表,传入当前最新数据,对关联数据进行合法性验证。 + for (M data : dataList) { + CallResult result = this.verifyRelatedData(data, null); + if (!result.isSuccess()) { + return result; + } + } + } + return CallResult.ok(); + } + + @Override + public CallResult verifyImportForConstDict(List dataList, String fieldName, Function idGetter) { + if (CollUtil.isEmpty(dataList)) { + return CallResult.ok(); + } + // 这里均为内部调用方法,因此出现任何错误均为代码BUG,所以我们会及时抛出异常。 + Field field = ReflectUtil.getField(modelClass, fieldName); + if (field == null) { + String errorMessage = StrFormatter.format("FieldName [{}] doesn't exist", fieldName); + throw new MyRuntimeException(errorMessage); + } + RelationConstDict relationConstDict = field.getAnnotation(RelationConstDict.class); + if (relationConstDict == null) { + String errorMessage = StrFormatter.format("FieldName [{}] doesn't have RelationConstDict.", fieldName); + throw new MyRuntimeException(errorMessage); + } + Method m = ReflectUtil.getMethodByName(relationConstDict.constantDictClass(), "isValid"); + for (M data : dataList) { + R id = idGetter.apply(data); + if (id != null) { + boolean ok = ReflectUtil.invokeStatic(m, id); + if (!ok) { + String errorMessage = String.format("数据验证失败,字段 [%s] 存在无效的常量字典值 [%s]!", + relationConstDict.masterIdField(), id); + return CallResult.error(errorMessage, data); + } + } + } + return CallResult.ok(); + } + + @Override + public CallResult verifyImportForGlobalDict(List dataList, String fieldName, Function idGetter) { + if (CollUtil.isEmpty(dataList)) { + return CallResult.ok(); + } + // 这里均为内部调用方法,因此出现任何错误均为代码BUG,所以我们会及时抛出异常。 + Field field = ReflectUtil.getField(modelClass, fieldName); + if (field == null) { + throw new MyRuntimeException(StrFormatter.format("FieldName [{}] does not exist.", fieldName)); + } + RelationGlobalDict relationGlobalDict = field.getAnnotation(RelationGlobalDict.class); + if (relationGlobalDict == null) { + throw new MyRuntimeException( + StrFormatter.format("FieldName [{}] doesn't have RelationGlobalDict.", fieldName)); + } + RelationStruct relationStruct = this.relationGlobalDictStructList.stream() + .filter(c -> c.relationField.getName().equals(fieldName)).findFirst().orElse(null); + Assert.notNull(relationStruct, "GlobalDictRelationStruct for [" + fieldName + "] can't be NULL"); + Map dictMap = ReflectUtil.invoke( + relationStruct.service, + relationStruct.globalDictMethd, + relationStruct.relationGlobalDict.dictCode(), null); + for (M data : dataList) { + R id = idGetter.apply(data); + if (id != null && !dictMap.containsKey(id.toString())) { + String errorMessage = String.format("数据验证失败,字段 [%s] 存在无效的全局编码字典值 [%s]!", + relationGlobalDict.masterIdField(), id); + return CallResult.error(errorMessage, data); + } + } + return CallResult.ok(); + } + + @Override + public CallResult verifyImportForDict(List dataList, String fieldName, Function idGetter) { + if (CollUtil.isEmpty(dataList)) { + return CallResult.ok(); + } + // 这里均为内部调用方法,因此出现任何错误均为代码BUG,所以我们会及时抛出异常。 + Field field = ReflectUtil.getField(modelClass, fieldName); + if (field == null) { + throw new MyRuntimeException(StrFormatter.format("FieldName [{}] does not exist.", fieldName)); + } + RelationDict relationDict = field.getAnnotation(RelationDict.class); + if (relationDict == null) { + throw new MyRuntimeException( + StrFormatter.format("FieldName [{}] doesn't have RelationDict.", fieldName)); + } + BaseService service = ApplicationContextHolder.getBean( + this.getNormalizedSlaveServiceName(relationDict.slaveServiceName(), relationDict.slaveModelClass())); + Set dictIdSet = service.getAllList().stream() + .map(c -> ReflectUtil.getFieldValue(c, relationDict.slaveIdField())).collect(toSet()); + for (M data : dataList) { + R id = idGetter.apply(data); + if (id != null && !dictIdSet.contains(id)) { + String errorMessage = String.format("数据验证失败,字段 [%s] 存在无效的字典表字典值 [%s]!", + relationDict.masterIdField(), id); + return CallResult.error(errorMessage, data); + } + } + return CallResult.ok(); + } + + @Override + public CallResult verifyImportForDatasourceDict(List dataList, String fieldName, Function idGetter) { + if (CollUtil.isEmpty(dataList)) { + return CallResult.ok(); + } + // 这里均为内部调用方法,因此出现任何错误均为代码BUG,所以我们会及时抛出异常。 + Field field = ReflectUtil.getField(modelClass, fieldName); + if (field == null) { + throw new MyRuntimeException(StrFormatter.format("FieldName [{}] doesn't exist.", fieldName)); + } + RelationDict relationDict = field.getAnnotation(RelationDict.class); + if (relationDict == null) { + throw new MyRuntimeException( + StrFormatter.format("FieldName [{}] doesn't have RelationDict.", fieldName)); + } + // 验证数据源字典Id,由于被依赖的数据表,可能包含大量业务数据,因此还是分批做存在性比对更为高效。 + Set idSet = dataList.stream() + .filter(c -> idGetter.apply(c) != null).map(idGetter).collect(toSet()); + if (CollUtil.isNotEmpty(idSet)) { + if (idSet.iterator().next() instanceof String) { + idSet = idSet.stream().filter(c -> StrUtil.isNotBlank((String) c)).collect(toSet()); + } + BaseService slaveService = ApplicationContextHolder.getBean( + this.getNormalizedSlaveServiceName(relationDict.slaveServiceName(), relationDict.slaveModelClass())); + List notExistIdList = slaveService.notExist(relationDict.slaveIdField(), idSet, true); + if (CollUtil.isNotEmpty(notExistIdList)) { + R notExistId = notExistIdList.get(0); + String errorMessage = String.format("数据验证失败,字段 [%s] 存在无效的数据源表字典值 [%s]!", + relationDict.masterIdField(), notExistId); + M data = dataList.stream() + .filter(c -> ObjectUtil.equals(idGetter.apply(c), notExistId)).findFirst().orElse(null); + return CallResult.error(errorMessage, data); + } + } + return CallResult.ok(); + } + + @Override + public CallResult verifyImportForOneToOneRelation(List dataList, String fieldName, Function idGetter) { + if (CollUtil.isEmpty(dataList)) { + return CallResult.ok(); + } + // 这里均为内部调用方法,因此出现任何错误均为代码BUG,所以我们会及时抛出异常。 + Field field = ReflectUtil.getField(modelClass, fieldName); + if (field == null) { + throw new MyRuntimeException(StrFormatter.format("FieldName [{}] doesn't exist", fieldName)); + } + RelationOneToOne relationOneToOne = field.getAnnotation(RelationOneToOne.class); + if (relationOneToOne == null) { + throw new MyRuntimeException( + StrFormatter.format("FieldName [{}] doesn't have RelationOneToOne.", fieldName)); + } + // 验证一对一关联Id,由于被依赖的数据表,可能包含大量业务数据,因此还是分批做存在性比对更为高效。 + Set idSet = dataList.stream() + .filter(c -> idGetter.apply(c) != null).map(idGetter).collect(toSet()); + if (CollUtil.isNotEmpty(idSet)) { + BaseService slaveService = ApplicationContextHolder.getBean( + this.getNormalizedSlaveServiceName(relationOneToOne.slaveServiceName(), relationOneToOne.slaveModelClass())); + List notExistIdList = slaveService.notExist(relationOneToOne.slaveIdField(), idSet, true); + if (CollUtil.isNotEmpty(notExistIdList)) { + R notExistId = notExistIdList.get(0); + String errorMessage = String.format("数据验证失败,字段 [%s] 存在无效的一对一关联值 [%s]!", + relationOneToOne.masterIdField(), notExistId); + M data = dataList.stream() + .filter(c -> ObjectUtil.equals(idGetter.apply(c), notExistId)).findFirst().orElse(null); + return CallResult.error(errorMessage, data); + } + } + return CallResult.ok(); + } + + /** + * 集成所有与主表实体对象相关的关联数据列表。包括本地和远程服务的一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param resultList 主表实体对象列表。数据集成将直接作用于该对象列表。 + * @param relationParam 实体对象数据组装的参数构建器。 + */ + @Override + public void buildRelationForDataList(List resultList, MyRelationParam relationParam) { + this.buildRelationForDataList(resultList, relationParam, null); + } + + /** + * 集成所有与主表实体对象相关的关联数据列表。包括一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param resultList 主表实体对象列表。数据集成将直接作用于该对象列表。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + @Override + public void buildRelationForDataList( + List resultList, MyRelationParam relationParam, Set ignoreFields) { + if (relationParam == null || CollUtil.isEmpty(resultList)) { + return; + } + boolean dataFilterValue = GlobalThreadLocal.setDataFilter(false); + try { + // 集成本地一对一和字段级别的数据关联。 + boolean buildOneToOne = relationParam.isBuildOneToOne() || relationParam.isBuildOneToOneWithDict(); + // 这里集成一对一关联。 + if (buildOneToOne) { + this.buildOneToOneForDataList(resultList, relationParam, ignoreFields); + } + // 集成一对多关联 + if (relationParam.isBuildOneToMany()) { + this.buildOneToManyForDataList(resultList, relationParam, ignoreFields); + } + // 这里集成多对多关联。 + if (relationParam.isBuildRelationManyToMany()) { + this.buildManyToManyForDataList(resultList, ignoreFields); + } + // 这里集成字典关联 + if (relationParam.isBuildDict()) { + // 构建全局字典关联关系 + this.buildGlobalDictForDataList(resultList, ignoreFields); + // 构建常量字典关联关系 + this.buildConstDictForDataList(resultList, ignoreFields); + this.buildDictForDataList(resultList, buildOneToOne, ignoreFields); + } + // 组装本地聚合计算关联数据 + if (relationParam.isBuildRelationAggregation()) { + // 处理多对多场景下,根据主表的结果,进行从表聚合数据的计算。 + this.buildManyToManyAggregationForDataList(resultList, buildAggregationAdditionalWhereCriteria(), ignoreFields); + // 处理多一多场景下,根据主表的结果,进行从表聚合数据的计算。 + this.buildOneToManyAggregationForDataList(resultList, buildAggregationAdditionalWhereCriteria(), ignoreFields); + } + } finally { + GlobalThreadLocal.setDataFilter(dataFilterValue); + } + } + + /** + * 该函数主要用于对查询结果的批量导出。不同于支持分页的列表查询,批量导出没有分页机制, + * 因此在导出数据量较大的情况下,很容易给数据库的内存、CPU和IO带来较大的压力。而通过 + * 我们的分批处理,可以极大的规避该问题的出现几率。调整batchSize的大小,也可以有效的 + * 改善运行效率。 + * 我们目前的处理机制是,先从主表取出所有符合条件的主表数据,这样可以避免分批处理时, + * 后面几批数据,因为skip过多而带来的效率问题。因为是单表过滤,不会给数据库带来过大的压力。 + * 之后再在主表结果集数据上进行分批级联处理。 + * 集成所有与主表实体对象相关的关联数据列表。包括一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param resultList 主表实体对象列表。数据集成将直接作用于该对象列表。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @param batchSize 每批集成的记录数量。小于等于0时将不做分批处理。 + */ + @Override + public void buildRelationForDataList(List resultList, MyRelationParam relationParam, int batchSize) { + this.buildRelationForDataList(resultList, relationParam, batchSize, null); + } + + /** + * 该函数主要用于对查询结果的批量导出。不同于支持分页的列表查询,批量导出没有分页机制, + * 因此在导出数据量较大的情况下,很容易给数据库的内存、CPU和IO带来较大的压力。而通过 + * 我们的分批处理,可以极大的规避该问题的出现几率。调整batchSize的大小,也可以有效的 + * 改善运行效率。 + * 我们目前的处理机制是,先从主表取出所有符合条件的主表数据,这样可以避免分批处理时, + * 后面几批数据,因为skip过多而带来的效率问题。因为是单表过滤,不会给数据库带来过大的压力。 + * 之后再在主表结果集数据上进行分批级联处理。 + * 集成所有与主表实体对象相关的关联数据列表。包括一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param resultList 主表实体对象列表。数据集成将直接作用于该对象列表。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @param batchSize 每批集成的记录数量。小于等于0时将不做分批处理。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + @Override + public void buildRelationForDataList( + List resultList, MyRelationParam relationParam, int batchSize, Set ignoreFields) { + if (CollUtil.isEmpty(resultList)) { + return; + } + if (batchSize <= 0) { + this.buildRelationForDataList(resultList, relationParam); + return; + } + int totalCount = resultList.size(); + int fromIndex = 0; + int toIndex = Math.min(batchSize, totalCount); + while (toIndex > fromIndex) { + List subResultList = resultList.subList(fromIndex, toIndex); + this.buildRelationForDataList(subResultList, relationParam, ignoreFields); + fromIndex = toIndex; + toIndex = Math.min(batchSize + fromIndex, totalCount); + } + } + + /** + * 集成所有与主表实体对象相关的关联数据对象。包括本地和远程服务的一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param dataObject 主表实体对象。数据集成将直接作用于该对象。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @param 实体对象类型。 + */ + @Override + public void buildRelationForData(T dataObject, MyRelationParam relationParam) { + this.buildRelationForData(dataObject, relationParam, null); + } + + /** + * 集成所有与主表实体对象相关的关联数据对象。包括一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param dataObject 主表实体对象。数据集成将直接作用于该对象。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + * @param 实体对象类型。 + */ + @Override + public void buildRelationForData(T dataObject, MyRelationParam relationParam, Set ignoreFields) { + if (dataObject == null || relationParam == null) { + return; + } + boolean dataFilterValue = GlobalThreadLocal.setDataFilter(false); + try { + // 集成本地一对一和字段级别的数据关联。 + boolean buildOneToOne = relationParam.isBuildOneToOne() || relationParam.isBuildOneToOneWithDict(); + if (buildOneToOne) { + this.buildOneToOneForData(dataObject, relationParam, ignoreFields); + } + // 集成一对多关联 + if (relationParam.isBuildOneToMany()) { + this.buildOneToManyForData(dataObject, relationParam, ignoreFields); + } + if (relationParam.isBuildDict()) { + // 构建全局字典关联关系 + this.buildGlobalDictForData(dataObject, ignoreFields); + // 构建常量字典关联关系 + this.buildConstDictForData(dataObject, ignoreFields); + // 构建本地数据字典关联关系。 + this.buildDictForData(dataObject, buildOneToOne, ignoreFields); + } + // 组装本地聚合计算关联数据 + if (relationParam.isBuildRelationAggregation()) { + // 开始处理多对多场景。 + buildManyToManyAggregationForData(dataObject, buildAggregationAdditionalWhereCriteria(), ignoreFields); + // 构建一对多场景 + buildOneToManyAggregationForData(dataObject, buildAggregationAdditionalWhereCriteria(), ignoreFields); + } + if (relationParam.isBuildRelationManyToMany()) { + this.buildRelationManyToMany(dataObject, ignoreFields); + } + } finally { + GlobalThreadLocal.setDataFilter(dataFilterValue); + } + } + + protected void buildLocalOneToOneDictOnly(T dataObject) { + if (dataObject == null || CollUtil.isEmpty(this.localRelationOneToOneStructList)) { + return; + } + for (RelationStruct relationStruct : this.localRelationOneToOneStructList) { + BaseService relationService = relationStruct.service; + Object relationObject = ReflectUtil.getFieldValue(dataObject, relationStruct.relationField); + if (relationObject != null) { + @SuppressWarnings("unchecked") + BaseService proxyTarget = + (BaseService) AopTargetUtil.getTarget(relationService); + // 关联本地字典 + proxyTarget.buildDictForData(relationObject, false, null); + // 关联全局字典 + proxyTarget.buildGlobalDictForData(relationObject, null); + // 关联常量字典 + proxyTarget.buildConstDictForData(relationObject, null); + } + } + } + + /** + * 集成主表和多对多中间表之间的关联关系。 + * + * @param dataObject 关联后的主表数据对象。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildRelationManyToMany(T dataObject, Set ignoreFields) { + if (dataObject == null || CollUtil.isEmpty(this.localRelationManyToManyStructList)) { + return; + } + for (RelationStruct relationStruct : this.localRelationManyToManyStructList) { + if (ignoreFields != null && ignoreFields.contains(relationStruct.relationField.getName())) { + continue; + } + RelationManyToMany r = relationStruct.relationManyToMany; + String masterIdColumn = MyModelUtil.safeMapToColumnName(r.relationMasterIdField(), r.relationModelClass()); + Object masterIdValue = ReflectUtil.getFieldValue(dataObject, idFieldName); + Map filterMap = new HashMap<>(1); + filterMap.put(masterIdColumn, masterIdValue); + List manyToManyList = relationStruct.manyToManyMapper.selectListByMap(filterMap); + ReflectUtil.setFieldValue(dataObject, relationStruct.relationField, manyToManyList); + } + } + + /** + * 为实体对象参数列表数据集成本地静态字典关联数据。 + * + * @param resultList 主表数据列表。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildConstDictForDataList(List resultList, Set ignoreFields) { + if (CollUtil.isEmpty(this.relationConstDictStructList) || CollUtil.isEmpty(resultList)) { + return; + } + for (RelationStruct relationStruct : this.relationConstDictStructList) { + if (ignoreFields != null && ignoreFields.contains(relationStruct.relationField.getName())) { + continue; + } + for (M dataObject : resultList) { + Object id = ReflectUtil.getFieldValue(dataObject, relationStruct.masterIdField); + if (id != null) { + String name = MapUtil.get(relationStruct.dictMap, id, String.class); + if (name != null) { + Map dictMap = new HashMap<>(2); + dictMap.put("id", id); + dictMap.put("name", name); + ReflectUtil.setFieldValue(dataObject, relationStruct.relationField, dictMap); + } + } + } + } + } + + /** + * 为实体对象参数列表数据集成全局字典关联数据。 + * + * @param resultList 主表数据列表。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildGlobalDictForDataList(List resultList, Set ignoreFields) { + if (CollUtil.isEmpty(this.relationGlobalDictStructList) || CollUtil.isEmpty(resultList)) { + return; + } + for (RelationStruct relationStruct : this.relationGlobalDictStructList) { + if (ignoreFields != null && ignoreFields.contains(relationStruct.relationField.getName())) { + continue; + } + Set masterIdSet = resultList.stream() + .map(obj -> ReflectUtil.getFieldValue(obj, relationStruct.masterIdField)) + .filter(Objects::nonNull) + .collect(toSet()); + if (CollUtil.isNotEmpty(masterIdSet)) { + Map dictMap = ReflectUtil.invoke( + relationStruct.service, + relationStruct.globalDictMethd, + relationStruct.relationGlobalDict.dictCode(), masterIdSet); + MyModelUtil.makeGlobalDictRelation( + modelClass, resultList, dictMap, relationStruct.relationField.getName()); + } + } + } + + /** + * 为参数实体对象数据集成本地静态字典关联数据。 + * + * @param dataObject 实体对象。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildConstDictForData(T dataObject, Set ignoreFields) { + if (dataObject == null || CollUtil.isEmpty(this.relationConstDictStructList)) { + return; + } + for (RelationStruct relationStruct : this.relationConstDictStructList) { + if (ignoreFields != null && ignoreFields.contains(relationStruct.relationField.getName())) { + continue; + } + Object id = ReflectUtil.getFieldValue(dataObject, relationStruct.masterIdField); + if (id != null) { + String name = MapUtil.get(relationStruct.dictMap, id, String.class); + if (name != null) { + Map dictMap = new HashMap<>(2); + dictMap.put("id", id); + dictMap.put("name", name); + ReflectUtil.setFieldValue(dataObject, relationStruct.relationField, dictMap); + } + } + } + } + + /** + * 为参数实体对象数据集成全局字典关联数据。 + * + * @param dataObject 实体对象。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildGlobalDictForData(T dataObject, Set ignoreFields) { + if (dataObject == null || CollUtil.isEmpty(this.relationGlobalDictStructList)) { + return; + } + for (RelationStruct relationStruct : this.relationGlobalDictStructList) { + if (ignoreFields != null && ignoreFields.contains(relationStruct.relationField.getName())) { + continue; + } + Object id = ReflectUtil.getFieldValue(dataObject, relationStruct.masterIdField); + if (id != null) { + Map dictMap = ReflectUtil.invoke( + relationStruct.service, + relationStruct.globalDictMethd, + relationStruct.relationGlobalDict.dictCode(), CollUtil.newHashSet(id)); + String name = dictMap.get(id.toString()); + if (name != null) { + Map reulstDictMap = new HashMap<>(2); + reulstDictMap.put("id", id); + reulstDictMap.put("name", name); + ReflectUtil.setFieldValue(dataObject, relationStruct.relationField, reulstDictMap); + } + } + } + } + + /** + * 为实体对象参数列表数据集成本地字典关联数据。 + * + * @param resultList 实体对象数据列表。 + * @param hasBuiltOneToOne 性能优化参数。如果该值为true,同时注解参数RelationDict.equalOneToOneRelationField + * 不为空,则直接从已经完成一对一数据关联的从表对象中获取数据,减少一次数据库交互。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildDictForDataList(List resultList, boolean hasBuiltOneToOne, Set ignoreFields) { + if (CollUtil.isEmpty(this.localRelationDictStructList) || CollUtil.isEmpty(resultList)) { + return; + } + for (RelationStruct relationStruct : this.localRelationDictStructList) { + if (ignoreFields != null && ignoreFields.contains(relationStruct.relationField.getName())) { + continue; + } + List relationList = null; + if (hasBuiltOneToOne && relationStruct.equalOneToOneRelationField != null) { + relationList = resultList.stream() + .map(obj -> ReflectUtil.getFieldValue(obj, relationStruct.equalOneToOneRelationField)) + .filter(Objects::nonNull) + .collect(toList()); + } else { + String slaveId = relationStruct.relationDict.slaveIdField(); + Set masterIdSet = resultList.stream() + .map(obj -> ReflectUtil.getFieldValue(obj, relationStruct.masterIdField)) + .filter(Objects::nonNull) + .collect(toSet()); + if (CollUtil.isNotEmpty(masterIdSet)) { + relationList = relationStruct.service.getInList(slaveId, masterIdSet); + } + } + MyModelUtil.makeDictRelation( + modelClass, resultList, relationList, relationStruct.relationField.getName()); + } + } + + /** + * 为实体对象数据集成本地数据字典关联数据。 + * + * @param dataObject 实体对象。 + * @param hasBuiltOneToOne 性能优化参数。如果该值为true,同时注解参数RelationDict.equalOneToOneRelationField + * 不为空,则直接从已经完成一对一数据关联的从表对象中获取数据,减少一次数据库交互。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildDictForData(T dataObject, boolean hasBuiltOneToOne, Set ignoreFields) { + if (dataObject == null || CollUtil.isEmpty(this.localRelationDictStructList)) { + return; + } + for (RelationStruct relationStruct : this.localRelationDictStructList) { + if (ignoreFields != null && ignoreFields.contains(relationStruct.relationField.getName())) { + continue; + } + Object relationObject = null; + if (hasBuiltOneToOne && relationStruct.equalOneToOneRelationField != null) { + relationObject = ReflectUtil.getFieldValue(dataObject, relationStruct.equalOneToOneRelationField); + } else { + Object id = ReflectUtil.getFieldValue(dataObject, relationStruct.masterIdField); + if (id != null) { + relationObject = relationStruct.service.getOne(relationStruct.relationDict.slaveIdField(), id); + } + } + MyModelUtil.makeDictRelation( + modelClass, dataObject, relationObject, relationStruct.relationField.getName()); + } + } + + /** + * 为实体对象参数列表数据集成本地一对一关联数据。 + * + * @param resultList 实体对象数据列表。 + * @param relationParam 关联从参数对象。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildOneToOneForDataList(List resultList, MyRelationParam relationParam, Set ignoreFields) { + if (CollUtil.isEmpty(this.localRelationOneToOneStructList) || CollUtil.isEmpty(resultList)) { + return; + } + boolean withDict = relationParam.isBuildOneToOneWithDict(); + for (RelationStruct relationStruct : this.localRelationOneToOneStructList) { + if (CollUtil.contains(ignoreFields, relationStruct.relationField.getName())) { + continue; + } + Set masterIdSet = resultList.stream() + .map(obj -> ReflectUtil.getFieldValue(obj, relationStruct.masterIdField)) + .filter(Objects::nonNull) + .collect(toSet()); + // 从主表集合中,抽取主表关联字段的集合,再以in list形式去从表中查询。 + if (CollUtil.isNotEmpty(masterIdSet)) { + BaseService relationService = relationStruct.service; + List relationList = + relationService.getInList(relationStruct.relationOneToOne.slaveIdField(), masterIdSet); + Set igoreMaskFieldSet = null; + if (relationParam.getIgnoreMaskFieldMap() != null) { + igoreMaskFieldSet = relationParam.getIgnoreMaskFieldMap() + .get(relationStruct.relationOneToOne.slaveModelClass().getSimpleName()); + } + relationService.maskFieldDataList(relationList, igoreMaskFieldSet); + MyModelUtil.makeOneToOneRelation( + modelClass, resultList, relationList, relationStruct.relationField.getName()); + // 仅仅当需要加载从表字典关联时,才去加载。 + if (withDict && relationStruct.relationOneToOne.loadSlaveDict() && CollUtil.isNotEmpty(relationList)) { + @SuppressWarnings("unchecked") + BaseService proxyTarget = + (BaseService) AopTargetUtil.getTarget(relationService); + // 关联本地字典。 + proxyTarget.buildDictForDataList(relationList, false, ignoreFields); + // 关联全局字典 + proxyTarget.buildGlobalDictForDataList(relationList, ignoreFields); + // 关联常量字典 + proxyTarget.buildConstDictForDataList(relationList, ignoreFields); + } + } + } + } + + /** + * 为实体对象数据集成本地一对一关联数据。 + * + * @param dataObject 实体对象。 + * @param relationParam 从表数据关联参数对象。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildOneToOneForData(M dataObject, MyRelationParam relationParam, Set ignoreFields) { + if (dataObject == null || CollUtil.isEmpty(this.localRelationOneToOneStructList)) { + return; + } + boolean withDict = relationParam.isBuildOneToOneWithDict(); + for (RelationStruct relationStruct : this.localRelationOneToOneStructList) { + if (ignoreFields != null && ignoreFields.contains(relationStruct.relationField.getName())) { + continue; + } + Object id = ReflectUtil.getFieldValue(dataObject, relationStruct.masterIdField); + if (id != null) { + BaseService relationService = relationStruct.service; + Object relationObject = relationService.getOne(relationStruct.relationOneToOne.slaveIdField(), id); + Set ignoreMaskFieldSet = null; + if (relationParam.getIgnoreMaskFieldMap() != null) { + ignoreMaskFieldSet = relationParam.getIgnoreMaskFieldMap() + .get(relationStruct.relationOneToOne.slaveModelClass().getSimpleName()); + } + relationService.maskFieldData(relationObject, ignoreMaskFieldSet); + ReflectUtil.setFieldValue(dataObject, relationStruct.relationField, relationObject); + // 仅仅当需要加载从表字典关联时,才去加载。 + if (withDict && relationStruct.relationOneToOne.loadSlaveDict() && relationObject != null) { + @SuppressWarnings("unchecked") + BaseService proxyTarget = + (BaseService) AopTargetUtil.getTarget(relationService); + // 关联本地字典 + proxyTarget.buildDictForData(relationObject, false, ignoreFields); + // 关联全局字典 + proxyTarget.buildGlobalDictForData(relationObject, ignoreFields); + // 关联常量字典 + proxyTarget.buildConstDictForData(relationObject, ignoreFields); + } + } + } + } + + private void buildOneToManyForDataList(List resultList, MyRelationParam relationParam, Set ignoreFields) { + if (CollUtil.isEmpty(this.localRelationOneToManyStructList) || CollUtil.isEmpty(resultList)) { + return; + } + for (RelationStruct relationStruct : this.localRelationOneToManyStructList) { + if (ignoreFields != null && ignoreFields.contains(relationStruct.relationField.getName())) { + continue; + } + Set masterIdSet = resultList.stream() + .map(obj -> ReflectUtil.getFieldValue(obj, relationStruct.masterIdField)) + .filter(Objects::nonNull) + .collect(toSet()); + // 从主表集合中,抽取主表关联字段的集合,再以in list形式去从表中查询。 + if (CollUtil.isNotEmpty(masterIdSet)) { + BaseService relationService = relationStruct.service; + List relationList = relationService.getInListWithRelation( + relationStruct.relationOneToMany.slaveIdField(), masterIdSet, MyRelationParam.dictOnly()); + MyModelUtil.makeOneToManyRelation( + modelClass, resultList, relationList, relationStruct.relationField.getName()); + Set ignoreMaskFieldSet = null; + if (relationParam.getIgnoreMaskFieldMap() != null) { + ignoreMaskFieldSet = relationParam.getIgnoreMaskFieldMap() + .get(relationStruct.relationOneToMany.slaveModelClass().getSimpleName()); + } + for (M data : resultList) { + @SuppressWarnings("unchecked") + List relationDataList = + (List) ReflectUtil.getFieldValue(data, relationStruct.relationField.getName()); + relationService.maskFieldDataList(relationDataList, ignoreMaskFieldSet); + } + } + } + } + + private void buildOneToManyForData(M dataObject, MyRelationParam relationParam, Set ignoreFields) { + if (dataObject == null || CollUtil.isEmpty(this.localRelationOneToManyStructList)) { + return; + } + for (RelationStruct relationStruct : this.localRelationOneToManyStructList) { + if (ignoreFields != null && ignoreFields.contains(relationStruct.relationField.getName())) { + continue; + } + Object id = ReflectUtil.getFieldValue(dataObject, relationStruct.masterIdField); + if (id != null) { + BaseService relationService = relationStruct.service; + Set masterIdSet = new HashSet<>(1); + masterIdSet.add(id); + List relationObject = relationService.getInListWithRelation( + relationStruct.relationOneToMany.slaveIdField(), masterIdSet, MyRelationParam.dictOnly()); + Set ignoreMaskFieldSet = null; + if (relationParam.getIgnoreMaskFieldMap() != null) { + ignoreMaskFieldSet = relationParam.getIgnoreMaskFieldMap() + .get(relationStruct.relationOneToMany.slaveModelClass().getSimpleName()); + } + relationService.maskFieldDataList(relationObject, ignoreMaskFieldSet); + ReflectUtil.setFieldValue(dataObject, relationStruct.relationField, relationObject); + } + } + } + + private void buildManyToManyForDataList(List resultList, Set ignoreFields) { + if (CollUtil.isEmpty(this.localRelationManyToManyStructList) || CollUtil.isEmpty(resultList)) { + return; + } + for (RelationStruct relationStruct : this.localRelationManyToManyStructList) { + if (ignoreFields != null && ignoreFields.contains(relationStruct.relationField.getName())) { + continue; + } + Set masterIdSet = resultList.stream() + .map(obj -> ReflectUtil.getFieldValue(obj, idFieldName)) + .filter(Objects::nonNull) + .collect(toSet()); + // 从主表集合中,抽取主表关联字段的集合,再以in list形式去从表中查询。 + if (CollUtil.isNotEmpty(masterIdSet)) { + RelationManyToMany r = relationStruct.relationManyToMany; + String masterIdColumn = MyModelUtil.safeMapToColumnName(r.relationMasterIdField(), r.relationModelClass()); + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.in(masterIdColumn, masterIdSet); + List relationList = relationStruct.manyToManyMapper.selectListByQuery(queryWrapper); + MyModelUtil.makeManyToManyRelation( + modelClass, idFieldName, resultList, relationList, relationStruct.relationField.getName()); + } + } + } + + /** + * 根据实体对象参数列表和过滤条件,集成本地多对多关联聚合计算数据。 + * + * @param resultList 实体对象数据列表。 + * @param criteriaListMap 过滤参数。key为主表字段名称,value是过滤条件列表。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildManyToManyAggregationForDataList( + List resultList, Map> criteriaListMap, Set ignoreFields) { + if (CollUtil.isEmpty(this.localRelationManyToManyAggrStructList) || CollUtil.isEmpty(resultList)) { + return; + } + if (criteriaListMap == null) { + criteriaListMap = new HashMap<>(this.localRelationManyToManyAggrStructList.size()); + } + for (RelationStruct relationStruct : this.localRelationManyToManyAggrStructList) { + if (!CollUtil.contains(ignoreFields, relationStruct.relationField.getName())) { + this.doBuildManyToManyAggregationForDataList(resultList, criteriaListMap, relationStruct); + } + } + } + + private void doBuildManyToManyAggregationForDataList( + List resultList, Map> criteriaListMap, RelationStruct relationStruct) { + Set masterIdSet = resultList.stream() + .map(obj -> ReflectUtil.getFieldValue(obj, relationStruct.masterIdField)) + .filter(Objects::nonNull) + .collect(toSet()); + if (CollUtil.isEmpty(masterIdSet)) { + return; + } + RelationManyToManyAggregation relation = relationStruct.relationManyToManyAggregation; + // 提取关联中用到的各种字段和表数据。 + BasicAggregationRelationInfo basicRelationInfo = + this.parseBasicAggregationRelationInfo(relationStruct, criteriaListMap); + // 构建多表关联的where语句 + StringBuilder whereClause = new StringBuilder(256); + // 如果需要从表聚合计算或参与过滤,则需要把中间表和从表之间的关联条件加上。 + if (!basicRelationInfo.onlySelectRelationTable) { + whereClause.append(basicRelationInfo.relationTable) + .append(".") + .append(basicRelationInfo.relationSlaveColumn) + .append(" = ") + .append(basicRelationInfo.slaveTable) + .append(".") + .append(basicRelationInfo.slaveColumn); + } else { + whereClause.append("1 = 1"); + } + List criteriaList = criteriaListMap.get(relationStruct.relationField.getName()); + if (criteriaList == null) { + criteriaList = new LinkedList<>(); + } + MyWhereCriteria inlistFilter = new MyWhereCriteria(); + inlistFilter.setCriteria(relation.relationModelClass(), + relation.relationMasterIdField(), MyWhereCriteria.OPERATOR_IN, masterIdSet); + criteriaList.add(inlistFilter); + if (StrUtil.isNotBlank(relationStruct.service.deletedFlagFieldName)) { + MyWhereCriteria deleteFilter = new MyWhereCriteria(); + deleteFilter.setCriteria( + relation.slaveModelClass(), + relationStruct.service.deletedFlagFieldName, + MyWhereCriteria.OPERATOR_EQUAL, + GlobalDeletedFlag.NORMAL); + criteriaList.add(deleteFilter); + } + String criteriaString = MyWhereCriteria.makeCriteriaString(criteriaList); + whereClause.append(AND_OP).append(criteriaString); + StringBuilder tableNames = new StringBuilder(64); + tableNames.append(basicRelationInfo.relationTable); + if (!basicRelationInfo.onlySelectRelationTable) { + tableNames.append(", ").append(basicRelationInfo.slaveTable); + } + List> aggregationMapList = + mapper().getGroupedListByCondition(tableNames.toString(), + basicRelationInfo.selectList, whereClause.toString(), basicRelationInfo.groupBy); + doMakeLocalAggregationData(aggregationMapList, resultList, relationStruct); + } + + /** + * 根据实体对象和过滤条件,集成本地多对多关联聚合计算数据。 + * + * @param dataObject 实体对象。 + * @param criteriaListMap 过滤参数。key为主表字段名称,value是过滤条件列表。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildManyToManyAggregationForData( + T dataObject, Map> criteriaListMap, Set ignoreFields) { + if (dataObject == null || CollUtil.isEmpty(this.localRelationManyToManyAggrStructList)) { + return; + } + if (criteriaListMap == null) { + criteriaListMap = new HashMap<>(localRelationManyToManyAggrStructList.size()); + } + for (RelationStruct relationStruct : this.localRelationManyToManyAggrStructList) { + Object masterIdValue = ReflectUtil.getFieldValue(dataObject, relationStruct.masterIdField); + if (masterIdValue == null || CollUtil.contains(ignoreFields, relationStruct.relationField.getName())) { + continue; + } + BasicAggregationRelationInfo basicRelationInfo = + this.parseBasicAggregationRelationInfo(relationStruct, criteriaListMap); + // 组装过滤条件 + String whereClause = this.makeManyToManyWhereClause( + relationStruct, masterIdValue, basicRelationInfo, criteriaListMap); + StringBuilder tableNames = new StringBuilder(64); + tableNames.append(basicRelationInfo.relationTable); + if (!basicRelationInfo.onlySelectRelationTable) { + tableNames.append(", ").append(basicRelationInfo.slaveTable); + } + List> aggregationMapList = + mapper().getGroupedListByCondition(tableNames.toString(), + basicRelationInfo.selectList, whereClause, basicRelationInfo.groupBy); + // 将查询后的结果回填到主表数据中。 + if (CollUtil.isNotEmpty(aggregationMapList)) { + Object value = aggregationMapList.get(0).get(AGGREGATED_VALUE); + if (value != null) { + ReflectUtil.setFieldValue(dataObject, relationStruct.relationField, value); + } + } + } + } + + /** + * 根据实体对象参数列表和过滤条件,集成本地一对多关联聚合计算数据。 + * + * @param resultList 实体对象数据列表。 + * @param criteriaListMap 过滤参数。key为主表字段名称,value是过滤条件列表。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildOneToManyAggregationForDataList( + List resultList, Map> criteriaListMap, Set ignoreFields) { + // 处理多一多场景下,根据主表的结果,进行从表聚合数据的计算。 + if (CollUtil.isEmpty(this.localRelationOneToManyAggrStructList) || CollUtil.isEmpty(resultList)) { + return; + } + if (criteriaListMap == null) { + criteriaListMap = new HashMap<>(localRelationOneToManyAggrStructList.size()); + } + for (RelationStruct relationStruct : this.localRelationOneToManyAggrStructList) { + if (CollUtil.contains(ignoreFields, relationStruct.relationField.getName())) { + continue; + } + Set masterIdSet = resultList.stream() + .map(obj -> ReflectUtil.getFieldValue(obj, relationStruct.masterIdField)) + .filter(Objects::nonNull) + .collect(toSet()); + if (CollUtil.isNotEmpty(masterIdSet)) { + RelationOneToManyAggregation relation = relationStruct.relationOneToManyAggregation; + // 开始获取后面所需的各种关联数据。此部分今后可以移植到缓存中,无需每次计算。 + String slaveTable = MyModelUtil.mapToTableName(relation.slaveModelClass()); + String slaveColumnName = MyModelUtil.mapToColumnName(relation.slaveIdField(), relation.slaveModelClass()); + Tuple2 selectAndGroupByTuple = makeSelectListAndGroupByClause( + slaveTable, slaveColumnName, relation.slaveModelClass(), + slaveTable, relation.aggregationField(), relation.aggregationType()); + String selectList = selectAndGroupByTuple.getFirst(); + String groupBy = selectAndGroupByTuple.getSecond(); + List criteriaList = criteriaListMap.get(relationStruct.relationField.getName()); + if (criteriaList == null) { + criteriaList = new LinkedList<>(); + } + MyWhereCriteria inlistFilter = new MyWhereCriteria(); + inlistFilter.setCriteria(relation.slaveModelClass(), + relation.slaveIdField(), MyWhereCriteria.OPERATOR_IN, masterIdSet); + criteriaList.add(inlistFilter); + if (StrUtil.isNotBlank(relationStruct.service.deletedFlagFieldName)) { + MyWhereCriteria deleteFilter = new MyWhereCriteria(); + deleteFilter.setCriteria( + relation.slaveModelClass(), + relationStruct.service.deletedFlagFieldName, + MyWhereCriteria.OPERATOR_EQUAL, + GlobalDeletedFlag.NORMAL); + criteriaList.add(deleteFilter); + } + String criteriaString = MyWhereCriteria.makeCriteriaString(criteriaList); + List> aggregationMapList = + mapper().getGroupedListByCondition(slaveTable, selectList, criteriaString, groupBy); + doMakeLocalAggregationData(aggregationMapList, resultList, relationStruct); + } + } + } + + /** + * 根据实体对象和过滤条件,集成本地一对多关联聚合计算数据。 + * + * @param dataObject 实体对象。 + * @param criteriaListMap 过滤参数。key为主表字段名称,value是过滤条件列表。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildOneToManyAggregationForData( + T dataObject, Map> criteriaListMap, Set ignoreFields) { + if (dataObject == null || CollUtil.isEmpty(this.localRelationOneToManyAggrStructList)) { + return; + } + if (criteriaListMap == null) { + criteriaListMap = new HashMap<>(localRelationOneToManyAggrStructList.size()); + } + for (RelationStruct relationStruct : this.localRelationOneToManyAggrStructList) { + if (CollUtil.contains(ignoreFields, relationStruct.relationField.getName())) { + continue; + } + Object masterIdValue = ReflectUtil.getFieldValue(dataObject, relationStruct.masterIdField); + if (masterIdValue != null) { + RelationOneToManyAggregation relation = relationStruct.relationOneToManyAggregation; + String slaveTable = MyModelUtil.mapToTableName(relation.slaveModelClass()); + String slaveColumnName = + MyModelUtil.mapToColumnName(relation.slaveIdField(), relation.slaveModelClass()); + Tuple2 selectAndGroupByTuple = makeSelectListAndGroupByClause( + slaveTable, slaveColumnName, relation.slaveModelClass(), + slaveTable, relation.aggregationField(), relation.aggregationType()); + String selectList = selectAndGroupByTuple.getFirst(); + String groupBy = selectAndGroupByTuple.getSecond(); + String whereClause = this.makeOneToManyWhereClause( + relationStruct, masterIdValue, slaveColumnName, criteriaListMap); + // 获取分组聚合计算结果 + List> aggregationMapList = + mapper().getGroupedListByCondition(slaveTable, selectList, whereClause, groupBy); + // 将计算结果回填到主表关联字段 + if (CollUtil.isNotEmpty(aggregationMapList)) { + Object value = aggregationMapList.get(0).get(AGGREGATED_VALUE); + if (value != null) { + ReflectUtil.setFieldValue(dataObject, relationStruct.relationField, value); + } + } + } + } + } + + /** + * 仅仅在spring boot 启动后的监听器事件中调用,缓存所有service的关联关系,加速后续的数据绑定效率。 + */ + @Override + public void loadRelationStruct() { + Field[] fields = ReflectUtil.getFields(modelClass); + for (Field f : fields) { + initializeRelationDictStruct(f); + initializeRelationStruct(f); + initializeRelationAggregationStruct(f); + } + } + + /** + * 缺省实现返回null,在进行一对多和多对多聚合计算时,没有额外的自定义过滤条件。如有需要,需子类自行实现。 + * + * @return 自定义过滤条件列表。 + */ + protected Map> buildAggregationAdditionalWhereCriteria() { + return null; + } + + /** + * 判断当前对象的关联字段数据是否需要被验证,如果原有对象为null,表示新对象第一次插入,则必须验证。 + * + * @param object 新对象。 + * @param originalObject 原有对象。 + * @param fieldGetter 获取需要验证字段的函数对象。 + * @param 需要验证字段的类型。 + * @return 需要关联验证返回true,否则false。 + */ + protected boolean needToVerify(M object, M originalObject, Function fieldGetter) { + if (object == null) { + return false; + } + T data = fieldGetter.apply(object); + if (data == null) { + return false; + } + if (data instanceof String stringData) { + if (stringData.isEmpty()) { + return false; + } + } + if (originalObject == null) { + return true; + } + T originalData = fieldGetter.apply(originalObject); + return !data.equals(originalData); + } + + /** + * 因为Mybatis Plus中QueryWrapper的条件方法都要求传入数据表字段名,因此提供该函数将 + * Java实体对象的字段名转换为数据表字段名,如果不存在会抛出异常。 + * 另外在MyModelUtil.mapToColumnName有一级缓存,对于查询过的对象字段都会放到缓存中, + * 下次映射转换的时候,会直接从缓存获取。 + * + * @param fieldName Java实体对象的字段名。 + * @return 对应的数据表字段名。 + */ + protected String safeMapToColumnName(String fieldName) { + String columnName = MyModelUtil.mapToColumnName(fieldName, modelClass); + if (columnName == null) { + throw new InvalidDataFieldException(modelClass.getSimpleName(), fieldName); + } + return columnName; + } + + @SuppressWarnings("unchecked") + private void initializeRelationStruct(Field f) { + RelationOneToOne relationOneToOne = f.getAnnotation(RelationOneToOne.class); + if (relationOneToOne != null) { + RelationStruct relationStruct = new RelationStruct(); + relationStruct.relationField = f; + relationStruct.masterIdField = ReflectUtil.getField(modelClass, relationOneToOne.masterIdField()); + relationStruct.relationOneToOne = relationOneToOne; + if (!relationOneToOne.slaveServiceClass().equals(DummyClass.class)) { + relationStruct.service = (BaseService) + ApplicationContextHolder.getBean(relationOneToOne.slaveServiceClass()); + } else { + relationStruct.service = ApplicationContextHolder.getBean( + this.getNormalizedSlaveServiceName(relationOneToOne.slaveServiceName(), relationOneToOne.slaveModelClass())); + } + localRelationOneToOneStructList.add(relationStruct); + return; + } + RelationOneToMany relationOneToMany = f.getAnnotation(RelationOneToMany.class); + if (relationOneToMany != null) { + RelationStruct relationStruct = new RelationStruct(); + relationStruct.relationField = f; + relationStruct.masterIdField = ReflectUtil.getField(modelClass, relationOneToMany.masterIdField()); + relationStruct.relationOneToMany = relationOneToMany; + if (!relationOneToMany.slaveServiceClass().equals(DummyClass.class)) { + relationStruct.service = (BaseService) + ApplicationContextHolder.getBean(relationOneToMany.slaveServiceClass()); + } else { + relationStruct.service = ApplicationContextHolder.getBean( + this.getNormalizedSlaveServiceName(relationOneToMany.slaveServiceName(), relationOneToMany.slaveModelClass())); + } + localRelationOneToManyStructList.add(relationStruct); + return; + } + RelationManyToMany relationManyToMany = f.getAnnotation(RelationManyToMany.class); + if (relationManyToMany != null) { + RelationStruct relationStruct = new RelationStruct(); + relationStruct.relationField = f; + relationStruct.masterIdField = ReflectUtil.getField(modelClass, relationManyToMany.relationMasterIdField()); + relationStruct.relationManyToMany = relationManyToMany; + String relationMapperName = relationManyToMany.relationMapperName(); + if (StrUtil.isBlank(relationMapperName)) { + relationMapperName = relationManyToMany.relationModelClass().getSimpleName() + "Mapper"; + } + relationStruct.manyToManyMapper = ApplicationContextHolder.getBean(StrUtil.lowerFirst(relationMapperName)); + localRelationManyToManyStructList.add(relationStruct); + } + } + + @SuppressWarnings("unchecked") + private void initializeRelationAggregationStruct(Field f) { + RelationOneToManyAggregation relationOneToManyAggregation = f.getAnnotation(RelationOneToManyAggregation.class); + if (relationOneToManyAggregation != null) { + RelationStruct relationStruct = new RelationStruct(); + relationStruct.relationField = f; + relationStruct.masterIdField = ReflectUtil.getField(modelClass, relationOneToManyAggregation.masterIdField()); + relationStruct.relationOneToManyAggregation = relationOneToManyAggregation; + if (!relationOneToManyAggregation.slaveServiceClass().equals(DummyClass.class)) { + relationStruct.service = (BaseService) + ApplicationContextHolder.getBean(relationOneToManyAggregation.slaveServiceClass()); + } else { + relationStruct.service = ApplicationContextHolder.getBean(this.getNormalizedSlaveServiceName( + relationOneToManyAggregation.slaveServiceName(), relationOneToManyAggregation.slaveModelClass())); + } + localRelationOneToManyAggrStructList.add(relationStruct); + return; + } + RelationManyToManyAggregation relationManyToManyAggregation = f.getAnnotation(RelationManyToManyAggregation.class); + if (relationManyToManyAggregation != null) { + RelationStruct relationStruct = new RelationStruct(); + relationStruct.relationField = f; + relationStruct.masterIdField = ReflectUtil.getField(modelClass, relationManyToManyAggregation.masterIdField()); + relationStruct.relationManyToManyAggregation = relationManyToManyAggregation; + if (!relationManyToManyAggregation.slaveServiceClass().equals(DummyClass.class)) { + relationStruct.service = (BaseService) + ApplicationContextHolder.getBean(relationManyToManyAggregation.slaveServiceClass()); + } else { + relationStruct.service = ApplicationContextHolder.getBean(this.getNormalizedSlaveServiceName( + relationManyToManyAggregation.slaveServiceName(), relationManyToManyAggregation.slaveModelClass())); + } + localRelationManyToManyAggrStructList.add(relationStruct); + } + } + + @SuppressWarnings("unchecked") + private void initializeRelationDictStruct(Field f) { + RelationConstDict relationConstDict = f.getAnnotation(RelationConstDict.class); + if (relationConstDict != null) { + RelationStruct relationStruct = new RelationStruct(); + relationStruct.relationConstDict = relationConstDict; + relationStruct.relationField = f; + relationStruct.masterIdField = ReflectUtil.getField(modelClass, relationConstDict.masterIdField()); + Field dictMapField = ReflectUtil.getField(relationConstDict.constantDictClass(), "DICT_MAP"); + relationStruct.dictMap = (Map) ReflectUtil.getStaticFieldValue(dictMapField); + relationConstDictStructList.add(relationStruct); + return; + } + RelationGlobalDict relationGlobalDict = f.getAnnotation(RelationGlobalDict.class); + if (relationGlobalDict != null) { + RelationStruct relationStruct = new RelationStruct(); + relationStruct.relationGlobalDict = relationGlobalDict; + relationStruct.relationField = f; + relationStruct.masterIdField = ReflectUtil.getField(modelClass, relationGlobalDict.masterIdField()); + relationStruct.service = ApplicationContextHolder.getBean("globalDictService"); + relationStruct.globalDictMethd = ReflectUtil.getMethodByName( + relationStruct.service.getClass(), "getGlobalDictItemDictMapFromCache"); + relationGlobalDictStructList.add(relationStruct); + return; + } + RelationDict relationDict = f.getAnnotation(RelationDict.class); + if (relationDict != null) { + RelationStruct relationStruct = new RelationStruct(); + relationStruct.relationField = f; + relationStruct.masterIdField = ReflectUtil.getField(modelClass, relationDict.masterIdField()); + relationStruct.relationDict = relationDict; + if (StrUtil.isNotBlank(relationDict.equalOneToOneRelationField())) { + relationStruct.equalOneToOneRelationField = + ReflectUtil.getField(modelClass, relationDict.equalOneToOneRelationField()); + } + if (!relationDict.slaveServiceClass().equals(DummyClass.class)) { + relationStruct.service = (BaseService) + ApplicationContextHolder.getBean(relationDict.slaveServiceClass()); + } else { + relationStruct.service = ApplicationContextHolder.getBean( + this.getNormalizedSlaveServiceName(relationDict.slaveServiceName(), relationDict.slaveModelClass())); + } + localRelationDictStructList.add(relationStruct); + } + } + + private BasicAggregationRelationInfo parseBasicAggregationRelationInfo( + RelationStruct relationStruct, Map> criteriaListMap) { + RelationManyToManyAggregation relation = relationStruct.relationManyToManyAggregation; + BasicAggregationRelationInfo relationInfo = new BasicAggregationRelationInfo(); + // 提取关联中用到的各种字段和表数据。 + relationInfo.slaveTable = MyModelUtil.mapToTableName(relation.slaveModelClass()); + relationInfo.relationTable = MyModelUtil.mapToTableName(relation.relationModelClass()); + relationInfo.relationMasterColumn = + MyModelUtil.mapToColumnName(relation.relationMasterIdField(), relation.relationModelClass()); + relationInfo.relationSlaveColumn = + MyModelUtil.mapToColumnName(relation.relationSlaveIdField(), relation.relationModelClass()); + relationInfo.slaveColumn = MyModelUtil.mapToColumnName(relation.slaveIdField(), relation.slaveModelClass()); + // 判断是否只需要关联中间表即可,从而提升查询统计的效率。 + // 1. 统计字段为中间表字段。2. 自定义过滤条件中没有基于从表字段的过滤条件。 + relationInfo.onlySelectRelationTable = + relation.aggregationModelClass().equals(relation.relationModelClass()); + if (relationInfo.onlySelectRelationTable && MapUtil.isNotEmpty(criteriaListMap)) { + List criteriaList = + criteriaListMap.get(relationStruct.relationField.getName()); + if (CollUtil.isNotEmpty(criteriaList)) { + for (MyWhereCriteria whereCriteria : criteriaList) { + if (whereCriteria.getModelClazz().equals(relation.slaveModelClass())) { + relationInfo.onlySelectRelationTable = false; + break; + } + } + } + } + String aggregationTable = relation.aggregationModelClass().equals(relation.relationModelClass()) + ? relationInfo.relationTable : relationInfo.slaveTable; + Tuple2 selectAndGroupByTuple = makeSelectListAndGroupByClause( + relationInfo.relationTable, relationInfo.relationMasterColumn, relation.aggregationModelClass(), + aggregationTable, relation.aggregationField(), relation.aggregationType()); + relationInfo.selectList = selectAndGroupByTuple.getFirst(); + relationInfo.groupBy = selectAndGroupByTuple.getSecond(); + return relationInfo; + } + + private String makeManyToManyWhereClause( + RelationStruct relationStruct, + Object masterIdValue, + BasicAggregationRelationInfo basicRelationInfo, + Map> criteriaListMap) { + StringBuilder whereClause = new StringBuilder(256); + whereClause.append(basicRelationInfo.relationTable) + .append(".").append(basicRelationInfo.relationMasterColumn); + if (masterIdValue instanceof Number) { + whereClause.append(" = ").append(masterIdValue); + } else { + whereClause.append(" = '").append(masterIdValue).append("'"); + } + // 如果需要从表聚合计算或参与过滤,则需要把中间表和从表之间的关联条件加上。 + if (!basicRelationInfo.onlySelectRelationTable) { + whereClause.append(AND_OP) + .append(basicRelationInfo.relationTable) + .append(".") + .append(basicRelationInfo.relationSlaveColumn) + .append(" = ") + .append(basicRelationInfo.slaveTable) + .append(".") + .append(basicRelationInfo.slaveColumn); + } + List criteriaList = criteriaListMap.get(relationStruct.relationField.getName()); + if (criteriaList == null) { + criteriaList = new LinkedList<>(); + } + if (StrUtil.isNotBlank(relationStruct.service.deletedFlagFieldName)) { + MyWhereCriteria deleteFilter = new MyWhereCriteria(); + deleteFilter.setCriteria( + relationStruct.relationManyToManyAggregation.slaveModelClass(), + relationStruct.service.deletedFlagFieldName, + MyWhereCriteria.OPERATOR_EQUAL, + GlobalDeletedFlag.NORMAL); + criteriaList.add(deleteFilter); + } + if (CollUtil.isNotEmpty(criteriaList)) { + String criteriaString = MyWhereCriteria.makeCriteriaString(criteriaList); + whereClause.append(AND_OP).append(criteriaString); + } + return whereClause.toString(); + } + + private String makeOneToManyWhereClause( + RelationStruct relationStruct, + Object masterIdValue, + String slaveColumnName, + Map> criteriaListMap) { + StringBuilder whereClause = new StringBuilder(64); + if (masterIdValue instanceof Number) { + whereClause.append(slaveColumnName).append(" = ").append(masterIdValue); + } else { + whereClause.append(slaveColumnName).append(" = '").append(masterIdValue).append("'"); + } + List criteriaList = criteriaListMap.get(relationStruct.relationField.getName()); + if (criteriaList == null) { + criteriaList = new LinkedList<>(); + } + if (StrUtil.isNotBlank(relationStruct.service.deletedFlagFieldName)) { + MyWhereCriteria deleteFilter = new MyWhereCriteria(); + deleteFilter.setCriteria( + relationStruct.relationOneToManyAggregation.slaveModelClass(), + relationStruct.service.deletedFlagFieldName, + MyWhereCriteria.OPERATOR_EQUAL, + GlobalDeletedFlag.NORMAL); + criteriaList.add(deleteFilter); + } + if (CollUtil.isNotEmpty(criteriaList)) { + String criteriaString = MyWhereCriteria.makeCriteriaString(criteriaList); + whereClause.append(AND_OP).append(criteriaString); + } + return whereClause.toString(); + } + + private static class BasicAggregationRelationInfo { + private String slaveTable; + private String slaveColumn; + private String relationTable; + private String relationMasterColumn; + private String relationSlaveColumn; + private String selectList; + private String groupBy; + private boolean onlySelectRelationTable; + } + + private void doMakeLocalAggregationData( + List> aggregationMapList, List resultList, RelationStruct relationStruct) { + if (CollUtil.isEmpty(resultList)) { + return; + } + // 根据获取的分组聚合结果集,绑定到主表总的关联字段。 + if (CollUtil.isNotEmpty(aggregationMapList)) { + Map relatedMap = new HashMap<>(aggregationMapList.size()); + String groupedKey = GROUPED_KEY; + String aggregatedValue = AGGREGATED_VALUE; + if (!aggregationMapList.get(0).containsKey(groupedKey)) { + groupedKey = groupedKey.toLowerCase(); + aggregatedValue = aggregatedValue.toLowerCase(); + } + for (Map map : aggregationMapList) { + relatedMap.put(map.get(groupedKey).toString(), map.get(aggregatedValue)); + } + for (M dataObject : resultList) { + Object masterIdValue = ReflectUtil.getFieldValue(dataObject, relationStruct.masterIdField); + if (masterIdValue != null) { + Object value = relatedMap.get(masterIdValue.toString()); + if (value != null) { + ReflectUtil.setFieldValue(dataObject, relationStruct.relationField, value); + } + } + } + } + } + + private Tuple2 makeSelectListAndGroupByClause( + String groupTableName, + String groupColumnName, + Class aggregationModel, + String aggregationTableName, + String aggregationField, + Integer aggregationType) { + if (!AggregationType.isValid(aggregationType)) { + throw new IllegalArgumentException("Invalid AggregationType Value [" + + aggregationType + "] in Model [" + aggregationModel.getName() + "]."); + } + String aggregationFunc = AggregationType.getAggregationFunction(aggregationType); + String aggregationColumn = MyModelUtil.mapToColumnName(aggregationField, aggregationModel); + if (StrUtil.isBlank(aggregationColumn)) { + throw new IllegalArgumentException("Invalid AggregationField [" + + aggregationField + "] in Model [" + aggregationModel.getName() + "]."); + } + // 构建Select List + // 如:r_table.master_id groupedKey, SUM(r_table.aggr_column) aggregated_value + StringBuilder groupedSelectList = new StringBuilder(128); + groupedSelectList.append(groupTableName) + .append(".") + .append(groupColumnName) + .append(" ") + .append(GROUPED_KEY) + .append(", ") + .append(aggregationFunc) + .append("(") + .append(aggregationTableName) + .append(".") + .append(aggregationColumn) + .append(") ") + .append(AGGREGATED_VALUE) + .append(" "); + StringBuilder groupBy = new StringBuilder(64); + groupBy.append(groupTableName).append(".").append(groupColumnName); + return new Tuple2<>(groupedSelectList.toString(), groupBy.toString()); + } + + private Object doMaskFieldData(M data, Field maskField, MaskField anno) { + Object value = ReflectUtil.getFieldValue(data, maskField); + if (value == null) { + return value; + } + if (anno.maskType().equals(MaskFieldTypeEnum.NAME)) { + value = MaskFieldUtil.chineseName(value.toString(), anno.maskChar()); + } else if (anno.maskType().equals(MaskFieldTypeEnum.MOBILE_PHONE)) { + value = MaskFieldUtil.mobilePhone(value.toString(), anno.maskChar()); + } else if (anno.maskType().equals(MaskFieldTypeEnum.FIXED_PHONE)) { + value = MaskFieldUtil.fixedPhone(value.toString(), anno.maskChar()); + } else if (anno.maskType().equals(MaskFieldTypeEnum.EMAIL)) { + value = MaskFieldUtil.email(value.toString(), anno.maskChar()); + } else if (anno.maskType().equals(MaskFieldTypeEnum.ID_CARD)) { + value = MaskFieldUtil.idCardNum(value.toString(), anno.noMaskPrefix(), anno.noMaskSuffix(), anno.maskChar()); + } else if (anno.maskType().equals(MaskFieldTypeEnum.BANK_CARD)) { + value = MaskFieldUtil.bankCard(value.toString(), anno.maskChar()); + } else if (anno.maskType().equals(MaskFieldTypeEnum.CAR_LICENSE)) { + value = MaskFieldUtil.carLicense(value.toString(), anno.maskChar()); + } else if (anno.maskType().equals(MaskFieldTypeEnum.CUSTOM)) { + MaskFieldHandler handler = + maskFieldHandlerMap.computeIfAbsent(anno.handler(), ApplicationContextHolder::getBean); + value = handler.handleMask(modelClass.getSimpleName(), maskField.getName(), value.toString(), anno.maskChar()); + } + return value; + } + + private void compareAndSetMaskFieldData(M data, K id) { + if (CollUtil.isNotEmpty(maskFieldList)) { + M originalData = this.getById(id); + this.compareAndSetMaskFieldData(data, originalData); + } + } + + private String getNormalizedSlaveServiceName(String slaveServiceName, Class slaveModelClass) { + if (StrUtil.isBlank(slaveServiceName)) { + slaveServiceName = slaveModelClass.getSimpleName() + "Service"; + } + return StrUtil.lowerFirst(slaveServiceName); + } + + @Data + public static class RelationStruct { + private Field relationField; + private Field masterIdField; + private Field equalOneToOneRelationField; + private Method globalDictMethd; + private BaseService service; + private BaseDaoMapper manyToManyMapper; + private Map dictMap; + private RelationConstDict relationConstDict; + private RelationGlobalDict relationGlobalDict; + private RelationDict relationDict; + private RelationOneToOne relationOneToOne; + private RelationOneToMany relationOneToMany; + private RelationManyToMany relationManyToMany; + private RelationOneToManyAggregation relationOneToManyAggregation; + private RelationManyToManyAggregation relationManyToManyAggregation; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/service/IBaseDictService.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/service/IBaseDictService.java new file mode 100644 index 00000000..556b70b5 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/service/IBaseDictService.java @@ -0,0 +1,69 @@ +package com.orangeforms.common.core.base.service; + +import java.io.Serializable; +import java.util.List; + +/** + * 带有缓存功能的字典Service接口。 + * + * @param Model实体对象的类型。 + * @param Model对象主键的类型。 + * @author Jerry + * @date 2024-07-02 + */ +public interface IBaseDictService extends IBaseService { + + /** + * 重新加载数据库中所有当前表数据到系统内存。 + * + * @param force true则强制刷新,如果false,当缓存中存在数据时不刷新。 + */ + void reloadCachedData(boolean force); + + /** + * 保存新增对象。 + * + * @param data 新增对象。 + * @return 返回新增对象。 + */ + M saveNew(M data); + + /** + * 更新数据对象。 + * + * @param data 更新的对象。 + * @param originalData 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(M data, M originalData); + + /** + * 删除指定数据。 + * + * @param id 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(K id); + + /** + * 直接从缓存池中获取所有数据。 + * + * @return 返回所有数据。 + */ + List getAllListFromCache(); + + /** + * 根据父主键Id,获取子对象列表。 + * + * @param parentId 上级行政区划Id。 + * @return 下级行政区划列表。 + */ + List getListByParentId(K parentId); + + /** + * 获取缓存中的数据数量。 + * + * @return 缓存中的数据总量。 + */ + int getCachedCount(); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/service/IBaseService.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/service/IBaseService.java new file mode 100644 index 00000000..37bcdf56 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/service/IBaseService.java @@ -0,0 +1,559 @@ +package com.orangeforms.common.core.base.service; + +import com.mybatisflex.core.service.IService; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TableModelInfo; + +import java.io.Serializable; +import java.util.*; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import java.util.function.Function; + +/** + * 所有Service的接口。 + * + * @param Model对象的类型。 + * @param Model对象主键的类型。 + * @author Jerry + * @date 2024-07-02 + */ +public interface IBaseService extends IService { + + /** + * 如果主键存在则更新,否则新增保存实体对象。 + * + * @param data 实体对象数据。 + * @param saveNew 新增实体对象方法。 + * @param update 更新实体对象方法。 + */ + void saveNewOrUpdate(M data, Consumer saveNew, BiConsumer update); + + /** + * 如果主键存在的则更新,否则批量新增保存实体对象。 + * + * @param dataList 实体对象数据列表。 + * @param saveNewBatch 批量新增实体对象方法。 + * @param update 更新实体对象方法。 + */ + void saveNewOrUpdateBatch(List dataList, Consumer> saveNewBatch, BiConsumer update); + + /** + * 根据过滤条件删除数据。 + * + * @param filter 过滤对象。 + * @return 删除数量。 + */ + Integer removeBy(M filter); + + /** + * 基于主从表之间的关联字段,批量改更新一对多从表数据。 + * 该操作会覆盖增、删、改三个操作,具体如下: + * 1. 先删除。从表中relationFieldName字段的值为relationFieldValue, 同时主键Id不在dataList中的。 + * 2. 再批量插入。遍历dataList中没有主键Id的对象,视为新对象批量插入。 + * 3. 最后逐条更新,遍历dataList中有主键Id的对象,视为已存在对象并逐条更新。 + * 4. 如果更新时间和更新用户Id为空,我们将视当前记录为变化数据,因此使用当前时间和用户分别填充这两个字段。 + * + * @param relationFieldName 主从表关联中,从表的Java字段名。 + * @param relationFieldValue 主从表关联中,与从表关联的主表字段值。该值会被赋值给从表关联字段。 + * @param updateUserIdFieldName 一对多从表的更新用户Id字段名。 + * @param updateTimeFieldName 一对多从表的更新时间字段名 + * @param dataList 批量更新的从表数据列表。 + * @param batchInserter 从表批量插入方法。 + */ + void updateBatchOneToManyRelation( + String relationFieldName, + Object relationFieldValue, + String updateUserIdFieldName, + String updateTimeFieldName, + List dataList, + Consumer> batchInserter); + + /** + * 判断指定字段的数据是否存在,且仅仅存在一条记录。 + * 如果是基于主键的过滤,会直接调用existId过滤函数,提升性能。在有缓存的场景下,也可以利用缓存。 + * + * @param fieldName 待过滤的字段名(Java 字段)。 + * @param fieldValue 字段值。 + * @return 存在且仅存在一条返回true,否则false。 + */ + boolean existOne(String fieldName, Object fieldValue); + + /** + * 判断主键Id关联的数据是否存在。 + * + * @param id 主键Id。 + * @return 存在返回true,否则false。 + */ + boolean existId(K id); + + /** + * 返回符合过滤条件的一条数据。 + * + * @param filter 过滤的Java对象。 + * @return 查询后的数据对象。 + */ + M getOne(M filter); + + /** + * 返回符合 filterField = filterValue 条件的一条数据。 + * + * @param filterField 过滤的Java字段。 + * @param filterValue 过滤的Java字段值。 + * @return 查询后的数据对象。 + */ + M getOne(String filterField, Object filterValue); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * + * @param id 主表主键Id。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @return 查询结果对象。 + */ + M getByIdWithRelation(K id, MyRelationParam relationParam); + + /** + * 获取所有数据。 + * + * @return 返回所有数据。 + */ + List getAllList(); + + /** + * 获取排序后所有数据。 + * + * @param orderByProperties 需要排序的字段属性,这里使用Java对象中的属性名,而不是数据库字段名。 + * @return 返回排序后所有数据。 + */ + List getAllListByOrder(String... orderByProperties); + + /** + * 判断参数值主键集合中的所有数据,是否全部存在 + * + * @param idSet 待校验的主键集合。 + * @return 全部存在返回true,否则false。 + */ + boolean existAllPrimaryKeys(Set idSet); + + /** + * 判断参数值列表中的所有数据,是否全部存在。另外,keyName字段在数据表中必须是唯一键值,否则返回结果会出现误判。 + * + * @param inFilterField 待校验的数据字段,这里使用Java对象中的属性,如courseId,而不是数据字段名course_id + * @param inFilterValues 数据值列表。 + * @return 全部存在返回true,否则false。 + */ + boolean existUniqueKeyList(String inFilterField, Set inFilterValues); + + /** + * 根据过滤字段和过滤集合,返回不存在的数据。 + * + * @param filterField 过滤的Java字段。 + * @param filterSet 过滤字段数据集合。 + * @param findFirst 是否找到第一个就返回。 + * @param 过滤字段类型。 + * @return filterSet中,在从表中不存在的数据集合。 + */ + List notExist(String filterField, Set filterSet, boolean findFirst); + + /** + * 返回符合主键 IN (idValues) 条件的所有数据。 + * + * @param idValues 主键值集合。 + * @return 检索后的数据列表。 + */ + List getInList(Set idValues); + + /** + * 返回符合 inFilterField IN (inFilterValues) 条件的所有数据。 + * + * @param inFilterField 参与(IN-list)过滤的Java字段。 + * @param inFilterValues 参与(IN-list)过滤的Java字段值集合。 + * @return 检索后的数据列表。 + */ + List getInList(String inFilterField, Set inFilterValues); + + /** + * 返回符合 inFilterField IN (inFilterValues) 条件的所有数据,并根据orderBy字段排序。 + * + * @param inFilterField 参与(IN-list)过滤的Java字段。 + * @param inFilterValues 参与(IN-list)过滤的Java字段值集合。 + * @param orderBy 排序字段。 + * @return 检索后的数据列表。 + */ + List getInList(String inFilterField, Set inFilterValues, String orderBy); + + /** + * 返回符合主键 IN (idValues) 条件的所有数据。同时返回关联数据。 + * + * @param idValues 主键值集合。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @return 检索后的数据列表。 + */ + List getInListWithRelation(Set idValues, MyRelationParam relationParam); + + /** + * 返回符合 inFilterField IN (inFilterValues) 条件的所有数据。同时返回关联数据。 + * + * @param inFilterField 参与(IN-list)过滤的Java字段。 + * @param inFilterValues 参与(IN-list)过滤的Java字段值集合。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @return 检索后的数据列表。 + */ + List getInListWithRelation(String inFilterField, Set inFilterValues, MyRelationParam relationParam); + + /** + * 返回符合 inFilterField IN (inFilterValues) 条件的所有数据,并根据orderBy字段排序。同时返回关联数据。 + * + * @param inFilterField 参与(IN-list)过滤的Java字段。 + * @param inFilterValues 参与(IN-list)过滤的Java字段值集合。 + * @param orderBy 排序字段。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @return 检索后的数据列表。 + */ + List getInListWithRelation( + String inFilterField, Set inFilterValues, String orderBy, MyRelationParam relationParam); + + /** + * 返回符合主键 NOT IN (idValues) 条件的所有数据。 + * + * @param idValues 主键值集合。 + * @return 检索后的数据列表。 + */ + List getNotInList(Set idValues); + + /** + * 返回符合 inFilterField NOT IN (inFilterValues) 条件的所有数据。 + * + * @param inFilterField 参与(NOT IN-list)过滤的Java字段。 + * @param inFilterValues 参与(NOT IN-list)过滤的Java字段值集合。 + * @return 检索后的数据列表。 + */ + List getNotInList(String inFilterField, Set inFilterValues); + + /** + * 返回符合 inFilterField NOT IN (inFilterValues) 条件的所有数据,并根据orderBy字段排序。 + * + * @param inFilterField 参与(NOT IN-list)过滤的Java字段。 + * @param inFilterValues 参与(NOT IN-list)过滤的Java字段值集合。 + * @param orderBy 排序字段。 + * @return 检索后的数据列表。 + */ + List getNotInList(String inFilterField, Set inFilterValues, String orderBy); + + /** + * 返回符合主键 NOT IN (idValues) 条件的所有数据。同时返回关联数据。 + * + * @param idValues 主键值集合。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @return 检索后的数据列表。 + */ + List getNotInListWithRelation(Set idValues, MyRelationParam relationParam); + + /** + * 返回符合 inFilterField NOT IN (inFilterValues) 条件的所有数据。同时返回关联数据。 + * + * @param inFilterField 参与(NOT IN-list)过滤的Java字段。 + * @param inFilterValues 参与(NOT IN-list)过滤的Java字段值集合。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @return 检索后的数据列表。 + */ + List getNotInListWithRelation(String inFilterField, Set inFilterValues, MyRelationParam relationParam); + + /** + * 返回符合 inFilterField NOT IN (inFilterValues) 条件的所有数据,并根据orderBy字段排序。同时返回关联数据。 + * + * @param inFilterField 参与(NOT IN-list)过滤的Java字段。 + * @param inFilterValues 参与(NOT IN-list)过滤的Java字段值集合。 + * @param orderBy 排序字段。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @return 检索后的数据列表。 + */ + List getNotInListWithRelation( + String inFilterField, Set inFilterValues, String orderBy, MyRelationParam relationParam); + + /** + * 用参数对象作为过滤条件,获取数据数量。 + * + * @param filter 过滤对象中,只有被赋值的字段,才会成为where中的条件。 + * @return 返回过滤后的数据数量。 + */ + long getCountByFilter(M filter); + + /** + * 用参数对象作为过滤条件,判断是否存在过滤数据。 + * + * @param filter 过滤对象中,只有被赋值的字段,才会成为where中的条件。 + * @return 存在返回true,否则false。 + */ + boolean existByFilter(M filter); + + /** + * 用参数对象作为过滤条件,获取查询结果。 + * + * @param filter 过滤对象中,只有被赋值的字段,才会成为where中的条件。如果参数为null,则返回全部数据。 + * @return 返回过滤后的数据。 + */ + List getListByFilter(M filter); + + /** + * 用参数对象作为过滤条件,获取查询结果。同时查询并绑定关联数据。 + * + * @param filter 该方法基于mybatis的通用mapper。如果参数为null,则返回全部数据。 + * @param orderBy 排序字段。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @return 返回过滤后的数据。 + */ + List getListWithRelationByFilter(M filter, String orderBy, MyRelationParam relationParam); + + /** + * 获取父主键Id下的所有子数据列表。 + * + * @param parentIdFieldName 父主键字段名字,如"courseId"。 + * @param parentId 父主键的值。 + * @return 父主键Id下的所有子数据列表。 + */ + List getListByParentId(String parentIdFieldName, K parentId); + + /** + * 根据指定的显示字段列表、过滤条件字符串和分组字符串,返回聚合计算后的查询结果。(基本是内部框架使用,不建议外部接口直接使用)。 + * + * @param selectFields 选择的字段列表,多个字段逗号分隔。 + * NOTE: 如果数据表字段和Java对象字段名字不同,Java对象字段应该以别名的形式出现。 + * 如: table_column_name modelFieldName。否则无法被反射回Bean对象。 + * @param whereClause SQL常量形式的条件从句。 + * @param groupBy SQL常量形式分组字段列表,逗号分隔。 + * @return 聚合计算后的数据结果集。 + */ + List> getGroupedListByCondition(String selectFields, String whereClause, String groupBy); + + /** + * 根据指定的显示字段列表、过滤条件字符串和排序字符串,返回查询结果。(基本是内部框架使用,不建议外部接口直接使用)。 + * + * @param selectList 选择的Java字段列表。如果为空表示返回全部字段。 + * @param filter 过滤对象。 + * @param whereClause SQL常量形式的条件从句。 + * @param orderBy SQL常量形式排序字段列表,逗号分隔。 + * @return 查询结果。 + */ + List getListByCondition(List selectList, M filter, String whereClause, String orderBy); + + /** + * 用指定过滤条件,计算记录数量。(基本是内部框架使用,不建议外部接口直接使用)。 + * + * @param whereClause SQL常量形式的条件从句。 + * @return 返回过滤后的数据数量。 + */ + Integer getCountByCondition(String whereClause); + + /** + * 仅对标记MaskField注解的字段数据进行脱敏。 + * + * @param data 实体对象。 + * @param ignoreFieldSet 忽略字段集合。如果为null,则对所有标记MaskField注解的字段数据进行脱敏处理。 + */ + void maskFieldData(M data, Set ignoreFieldSet); + + /** + * 仅对标记MaskField注解的字段数据进行脱敏。 + * + * @param dataList 实体对象列表。 + * @param ignoreFieldSet 忽略字段集合。如果为null,则对所有标记MaskField注解的字段数据进行脱敏处理。 + */ + void maskFieldDataList(List dataList, Set ignoreFieldSet); + + /** + * 比较并处理脱敏字段的数据变化。 + * 如果data对象中的脱敏字段值和originalData字段的脱敏后值相同,表示当前data对象的脱敏字段数据没有变化, + * 因此需要使用数据库中的原有字段值,覆盖当前实体对象中的该字段值,以保证数据库表字段中始终存储的是未脱敏数据。 + * + * @param data 当前数据对象。 + * @param originalData 原数据对象。 + */ + void compareAndSetMaskFieldData(M data, M originalData); + + /** + * 对标记MaskField注解的脱敏字段进行判断。字段数据中不能包含脱敏掩码字符。 + * + * @param data 实体对象。 + */ + void verifyMaskFieldData(M data); + + /** + * 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。 + * NOTE: BaseService中会给出返回CallResult.ok()的缺省实现。每个业务服务实现类在需要的时候可以重载该方法。 + * + * @param data 数据对象。 + * @param originalData 原有数据对象,null表示data为新增对象。 + * @return 应答结果对象。 + */ + CallResult verifyRelatedData(M data, M originalData); + + /** + * 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。 + * 如果data对象中包含主键值,方法内部会获取原有对象值,并进行更新方式的关联数据比对,否则视为新增数据关联对象比对。 + * + * @param data 数据对象。 + * @return 应答结果对象。 + */ + CallResult verifyRelatedData(M data); + + /** + * 根据最新对象列表和原有对象列表的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。 + * 如果dataList列表中的对象包含主键值,方法内部会获取原有对象值,并进行更新方式的关联数据比对,否则视为新增数据关联对象比对。 + * + * @param dataList 数据对象列表。 + * @return 应答结果对象。 + */ + CallResult verifyRelatedData(List dataList); + + /** + * 批量导入数据列表,对依赖全局字典的数据进行验证。 + * + * @param dataList 批量导入数据列表。 + * @param fieldName 业务主表中依赖全局字典的字段名,包含RelationGlobalDict注解的字段。 + * @param idGetter 获取业务主表中依赖全局字典字段值的Function对象。 + * @param 业务主表中依全局字典的字段类型。 + * @return 验证结果,如果失败,在data中包含具体的错误对象。 + */ + CallResult verifyImportForGlobalDict(List dataList, String fieldName, Function idGetter); + + /** + * 批量导入数据列表,对依赖常量字典的数据进行验证。 + * + * @param dataList 批量导入数据列表。 + * @param fieldName 业务主表中依赖常量字典的字段名,包含RelationConstDict注解的字段。 + * @param idGetter 获取业务主表中依赖常量字典字段值的Function对象。 + * @param 业务主表中依赖常量字典的字段类型。 + * @return 验证结果,如果失败,在data中包含具体的错误对象。 + */ + CallResult verifyImportForConstDict(List dataList, String fieldName, Function idGetter); + + /** + * 批量导入数据列表,对依赖字典表字典的数据进行验证。 + * + * @param dataList 批量导入数据列表。 + * @param fieldName 业务主表中依赖字典表字典的字段名,包含RelationDict注解的字段。 + * @param idGetter 获取业务主表中依赖字典表字典字段值的Function对象。 + * @param 业务主表中依赖字典表字典的字段类型。 + * @return 验证结果,如果失败,在data中包含具体的错误对象。 + */ + CallResult verifyImportForDict(List dataList, String fieldName, Function idGetter); + + /** + * 批量导入数据列表,对依赖数据源字典的数据进行验证。 + * + * @param dataList 批量导入数据列表。 + * @param fieldName 业务主表中依赖数据源字典的字段名,包含RelationDict注解的字段的数据源字典。 + * @param idGetter 获取业务主表中依赖数据源字典字段值的Function对象。 + * @param 业务主表中依赖数据源字典的字段类型。 + * @return 验证结果,如果失败,在data中包含具体的错误对象。 + */ + CallResult verifyImportForDatasourceDict(List dataList, String fieldName, Function idGetter); + + /** + * 批量导入数据列表,对存在一对一关联的数据进行验证。 + * + * @param dataList 批量导入数据列表。 + * @param fieldName 业务主表中存在一对一关联的字段名,包含RelationOneToOne注解的字段。 + * @param idGetter 获取业务主表中一对一关联字段值的Function对象。 + * @param 业务主表中存在一对一关联的字段类型。 + * @return 验证结果,如果失败,在data中包含具体的错误对象。 + */ + CallResult verifyImportForOneToOneRelation(List dataList, String fieldName, Function idGetter); + + /** + * 集成所有与主表实体对象相关的关联数据列表。包括一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param resultList 主表实体对象列表。数据集成将直接作用于该对象列表。 + * @param relationParam 实体对象数据组装的参数构建器。 + */ + void buildRelationForDataList(List resultList, MyRelationParam relationParam); + + /** + * 集成所有与主表实体对象相关的关联数据列表。包括本地和远程服务的一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param resultList 主表实体对象列表。数据集成将直接作用于该对象列表。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + void buildRelationForDataList(List resultList, MyRelationParam relationParam, Set ignoreFields); + + /** + * 该函数主要用于对查询结果的批量导出。不同于支持分页的列表查询,批量导出没有分页机制, + * 因此在导出数据量较大的情况下,很容易给数据库的内存、CPU和IO带来较大的压力。而通过 + * 我们的分批处理,可以极大的规避该问题的出现几率。调整batchSize的大小,也可以有效的 + * 改善运行效率。 + * 我们目前的处理机制是,先从主表取出所有符合条件的主表数据,这样可以避免分批处理时, + * 后面几批数据,因为skip过多而带来的效率问题。因为是单表过滤,不会给数据库带来过大的压力。 + * 之后再在主表结果集数据上进行分批级联处理。 + * 集成所有与主表实体对象相关的关联数据列表。包括一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param resultList 主表实体对象列表。数据集成将直接作用于该对象列表。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @param batchSize 每批集成的记录数量。小于等于0时将不做分批处理。 + */ + void buildRelationForDataList(List resultList, MyRelationParam relationParam, int batchSize); + + /** + * 该函数主要用于对查询结果的批量导出。不同于支持分页的列表查询,批量导出没有分页机制, + * 因此在导出数据量较大的情况下,很容易给数据库的内存、CPU和IO带来较大的压力。而通过 + * 我们的分批处理,可以极大的规避该问题的出现几率。调整batchSize的大小,也可以有效的 + * 改善运行效率。 + * 我们目前的处理机制是,先从主表取出所有符合条件的主表数据,这样可以避免分批处理时, + * 后面几批数据,因为skip过多而带来的效率问题。因为是单表过滤,不会给数据库带来过大的压力。 + * 之后再在主表结果集数据上进行分批级联处理。 + * 集成所有与主表实体对象相关的关联数据列表。包括一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param resultList 主表实体对象列表。数据集成将直接作用于该对象列表。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @param batchSize 每批集成的记录数量。小于等于0时将不做分批处理。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + void buildRelationForDataList( + List resultList, MyRelationParam relationParam, int batchSize, Set ignoreFields); + + /** + * 集成所有与主表实体对象相关的关联数据对象。包括一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param dataObject 主表实体对象。数据集成将直接作用于该对象。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @param 实体对象类型。 + */ + void buildRelationForData(T dataObject, MyRelationParam relationParam); + + /** + * 集成所有与主表实体对象相关的关联数据对象。包括本地和远程服务的一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param dataObject 主表实体对象。数据集成将直接作用于该对象。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + * @param 实体对象类型。 + */ + void buildRelationForData(T dataObject, MyRelationParam relationParam, Set ignoreFields); + + /** + * 仅仅在spring boot 启动后的监听器事件中调用,缓存所有service的关联关系,加速后续的数据绑定效率。 + */ + void loadRelationStruct(); + + /** + * 获取当前服务引用的实体对象及表信息。 + * + * @return 实体对象及表信息。 + */ + TableModelInfo getTableModelInfo(); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/vo/BaseVo.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/vo/BaseVo.java new file mode 100644 index 00000000..a4313a53 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/base/vo/BaseVo.java @@ -0,0 +1,35 @@ +package com.orangeforms.common.core.base.vo; + +import lombok.Data; + +import java.util.Date; + +/** + * VO对象的公共基类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class BaseVo { + + /** + * 创建者Id。 + */ + private Long createUserId; + + /** + * 创建时间。 + */ + private Date createTime; + + /** + * 更新者Id。 + */ + private Long updateUserId; + + /** + * 更新时间。 + */ + private Date updateTime; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/cache/CacheConfig.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/cache/CacheConfig.java new file mode 100644 index 00000000..203eafd1 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/cache/CacheConfig.java @@ -0,0 +1,110 @@ +package com.orangeforms.common.core.cache; + +import com.github.benmanes.caffeine.cache.Caffeine; +import org.springframework.cache.CacheManager; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.cache.caffeine.CaffeineCache; +import org.springframework.cache.support.SimpleCacheManager; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.ArrayList; +import java.util.concurrent.TimeUnit; + +/** + * 使用Caffeine作为本地缓存库 + * + * @author Jerry + * @date 2024-07-02 + */ +@Configuration +@EnableCaching +public class CacheConfig { + + private static final int DEFAULT_MAXSIZE = 10000; + private static final int DEFAULT_TTL = 3600; + + /** + * 定义cache名称、超时时长秒、最大个数 + * 每个cache缺省3600秒过期,最大个数1000 + */ + public enum CacheEnum { + /** + * 专门存储用户权限的缓存(600秒)。 + */ + USER_PERMISSION_CACHE(600, 10000), + /** + * 专门存储用户权限字的缓存(600秒)。仅当使用satoken权限框架时可用。 + */ + USER_PERM_CODE_CACHE(600, 10000), + /** + * 专门存储用户数据权限的缓存(600秒)。 + */ + DATA_PERMISSION_CACHE(600, 10000), + /** + * 专门存储用户菜单关联权限的缓存(600秒)。 + */ + MENU_PERM_CACHE(600, 10000), + /** + * 存储指定部门Id集合的所有子部门Id集合。 + */ + CHILDREN_DEPT_ID_CACHE(1800, 10000), + /** + * 在线表单组件渲染数据缓存。 + */ + ONLINE_FORM_RENDER_CACCHE(300, 100), + /** + * 报表表单组件渲染数据缓存。 + */ + REPORT_FORM_RENDER_CACCHE(300, 100), + /** + * 缺省全局缓存(时间是24小时)。 + */ + GLOBAL_CACHE(86400, 20000); + + CacheEnum() { + } + + CacheEnum(int ttl, int maxSize) { + this.ttl = ttl; + this.maxSize = maxSize; + } + + /** + * 缓存的最大数量。 + */ + private int maxSize = DEFAULT_MAXSIZE; + /** + * 缓存的时长(单位:秒) + */ + private int ttl = DEFAULT_TTL; + + public int getMaxSize() { + return maxSize; + } + + public int getTtl() { + return ttl; + } + } + + /** + * 初始化缓存配置。这里为了有别于Redisson的缓存。 + */ + @Bean("caffeineCacheManager") + public CacheManager cacheManager() { + SimpleCacheManager manager = new SimpleCacheManager(); + // 把各个cache注册到cacheManager中,CaffeineCache实现了org.springframework.cache.Cache接口 + ArrayList caches = new ArrayList<>(); + for (CacheEnum c : CacheEnum.values()) { + caches.add(new CaffeineCache(c.name(), + Caffeine.newBuilder().recordStats() + .expireAfterWrite(c.getTtl(), TimeUnit.SECONDS) + .maximumSize(c.getMaxSize()) + .build()) + ); + } + manager.setCaches(caches); + return manager; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/cache/DictionaryCache.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/cache/DictionaryCache.java new file mode 100644 index 00000000..14fe0391 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/cache/DictionaryCache.java @@ -0,0 +1,89 @@ +package com.orangeforms.common.core.cache; + +import java.util.List; +import java.util.Set; + +/** + * 主要用于完整缓存字典表数据的接口对象。 + * + * @param 字典表主键类型。 + * @param 字典表对象类型。 + * @author Jerry + * @date 2024-07-02 + */ +public interface DictionaryCache { + + /** + * 按照数据插入的顺序返回全部字典对象的列表。 + * + * @return 全部字段数据列表。 + */ + List getAll(); + + /** + * 获取缓存中与键列表对应的对象列表。 + * + * @param keys 主键集合。 + * @return 对象列表。 + */ + List getInList(Set keys); + + /** + * 重新加载。如果数据列表为空,则会清空原有缓存数据。 + * + * @param dataList 待缓存的数据列表。 + * @param force true则强制刷新,如果false,当缓存中存在数据时不刷新。 + */ + void reload(List dataList, boolean force); + + /** + * 从缓存中获取指定的数据。 + * + * @param key 数据的key。 + * @return 获取到的数据,如果没有返回null。 + */ + V get(K key); + + /** + * 将数据存入缓存。 + * + * @param key 通常为字典数据的主键。 + * @param object 字典数据对象。 + */ + void put(K key, V object); + + /** + * 获取缓存中数据条目的数量。 + * + * @return 返回缓存的数据数量。 + */ + int getCount(); + + /** + * 删除缓存中指定的键。 + * + * @param key 待删除数据的主键。 + * @return 返回被删除的对象,如果主键不存在,返回null。 + */ + V invalidate(K key); + + /** + * 删除缓存中,参数列表中包含的键。 + * + * @param keys 待删除数据的主键集合。 + */ + void invalidateSet(Set keys); + + /** + * 清空缓存。 + */ + void invalidateAll(); + + /** + * 根据父主键Id获取所有子对象的列表。 + * + * @param parentId 父主键Id。如果parentId为null,则返回所有一级节点数据。 + * @return 所有子对象的列表。 + */ + default List getListByParentId(K parentId) { throw new UnsupportedOperationException(); } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/cache/MapDictionaryCache.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/cache/MapDictionaryCache.java new file mode 100644 index 00000000..7f238801 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/cache/MapDictionaryCache.java @@ -0,0 +1,200 @@ +package com.orangeforms.common.core.cache; + +import cn.hutool.core.map.MapUtil; +import com.orangeforms.common.core.exception.MapCacheAccessException; +import lombok.extern.slf4j.Slf4j; + +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import java.util.function.Function; +import java.util.function.Supplier; + +/** + * 字典数据内存缓存对象。 + * + * @param 字典表主键类型。 + * @param 字典表对象类型。 + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class MapDictionaryCache implements DictionaryCache { + + /** + * 存储字典数据的Map。 + */ + protected final LinkedHashMap dataMap = new LinkedHashMap<>(); + /** + * 获取字典主键数据的函数对象。 + */ + protected final Function idGetter; + /** + * 由于大部分场景是读取操作,所以使用读写锁提高并发的伸缩性。 + */ + protected final ReadWriteLock lock = new ReentrantReadWriteLock(); + /** + * 超时时长。单位毫秒。 + */ + protected static final long TIMEOUT = 2000L; + + /** + * 当前对象的构造器函数。 + * + * @param idGetter 获取当前类主键字段值的函数对象。 + * @param 字典主键类型。 + * @param 字典对象类型 + * @return 实例化后的字典内存缓存对象。 + */ + public static MapDictionaryCache create(Function idGetter) { + if (idGetter == null) { + throw new IllegalArgumentException("IdGetter can't be NULL."); + } + return new MapDictionaryCache<>(idGetter); + } + + /** + * 构造函数。 + * + * @param idGetter 主键Id的获取函数对象。 + */ + public MapDictionaryCache(Function idGetter) { + this.idGetter = idGetter; + } + + @Override + public List getAll() { + return this.safeRead("getAll", () -> { + List resultList = new LinkedList<>(); + if (MapUtil.isNotEmpty(dataMap)) { + resultList.addAll(dataMap.values()); + } + return resultList; + }); + } + + @Override + public List getInList(Set keys) { + return this.safeRead("getInList", () -> { + List resultList = new LinkedList<>(); + keys.forEach(key -> { + V object = dataMap.get(key); + if (object != null) { + resultList.add(object); + } + }); + return resultList; + }); + } + + @Override + public V get(K id) { + if (id == null) { + return null; + } + return this.safeRead("get", () -> dataMap.get(id)); + } + + @Override + public void reload(List dataList, boolean force) { + if (!force && this.getCount() > 0) { + return; + } + this.safeWrite("reload", () -> { + dataMap.clear(); + dataList.forEach(dataObj -> { + K id = idGetter.apply(dataObj); + dataMap.put(id, dataObj); + }); + return null; + }); + } + + @Override + public void put(K id, V object) { + this.safeWrite("put", () -> dataMap.put(id, object)); + } + + @Override + public int getCount() { + return dataMap.size(); + } + + @Override + public V invalidate(K id) { + if (id == null) { + return null; + } + return this.safeWrite("invalidate", () -> dataMap.remove(id)); + } + + @Override + public void invalidateSet(Set keys) { + this.safeWrite("invalidateSet", () -> { + keys.forEach(id -> { + if (id != null) { + dataMap.remove(id); + } + }); + return null; + }); + } + + @Override + public void invalidateAll() { + this.safeWrite("invalidateAll", () -> { + dataMap.clear(); + return null; + }); + } + + protected T safeRead(String functionName, Supplier supplier) { + String exceptionMessage; + try { + if (lock.readLock().tryLock(TIMEOUT, TimeUnit.MILLISECONDS)) { + try { + return supplier.get(); + } finally { + lock.readLock().unlock(); + } + } else { + throw new TimeoutException(); + } + } catch (Exception e) { + if (e instanceof InterruptedException) { + Thread.currentThread().interrupt(); + } + exceptionMessage = String.format( + "LOCK Operation of [MapDictionaryCache::%s] encountered EXCEPTION [%s] for DICT.", + functionName, e.getClass().getSimpleName()); + log.warn(exceptionMessage); + throw new MapCacheAccessException(exceptionMessage, e); + } + } + + protected T safeWrite(String functionName, Supplier supplier) { + String exceptionMessage; + try { + if (lock.writeLock().tryLock(TIMEOUT, TimeUnit.MILLISECONDS)) { + try { + return supplier.get(); + } finally { + lock.writeLock().unlock(); + } + } else { + throw new TimeoutException(); + } + } catch (Exception e) { + if (e instanceof InterruptedException) { + Thread.currentThread().interrupt(); + } + exceptionMessage = String.format( + "LOCK Operation of [MapDictionaryCache::%s] encountered EXCEPTION [%s] for DICT.", + functionName, e.getClass().getSimpleName()); + log.warn(exceptionMessage); + throw new MapCacheAccessException(exceptionMessage, e); + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/cache/MapTreeDictionaryCache.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/cache/MapTreeDictionaryCache.java new file mode 100644 index 00000000..b492ebe2 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/cache/MapTreeDictionaryCache.java @@ -0,0 +1,138 @@ +package com.orangeforms.common.core.cache; + +import cn.hutool.core.collection.CollUtil; +import com.google.common.collect.LinkedHashMultimap; +import com.google.common.collect.Multimap; +import lombok.extern.slf4j.Slf4j; + +import java.util.*; +import java.util.function.Function; + +/** + * 树形字典数据内存缓存对象。 + * + * @param 字典表主键类型。 + * @param 字典表对象类型。 + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class MapTreeDictionaryCache extends MapDictionaryCache { + + /** + * 树形数据存储对象。 + */ + private final Multimap allTreeMap = LinkedHashMultimap.create(); + /** + * 获取字典父主键数据的函数对象。 + */ + protected final Function parentIdGetter; + + /** + * 当前对象的构造器函数。 + * + * @param idGetter 获取当前类主键字段值的函数对象。 + * @param parentIdGetter 获取当前类父主键字段值的函数对象。 + * @param 字典主键类型。 + * @param 字典对象类型 + * @return 实例化后的树形字典内存缓存对象。 + */ + public static MapTreeDictionaryCache create(Function idGetter, Function parentIdGetter) { + if (idGetter == null) { + throw new IllegalArgumentException("IdGetter can't be NULL."); + } + if (parentIdGetter == null) { + throw new IllegalArgumentException("ParentIdGetter can't be NULL."); + } + return new MapTreeDictionaryCache<>(idGetter, parentIdGetter); + } + + /** + * 构造函数。 + * + * @param idGetter 获取当前类主键字段值的函数对象。 + * @param parentIdGetter 获取当前类父主键字段值的函数对象。 + */ + public MapTreeDictionaryCache(Function idGetter, Function parentIdGetter) { + super(idGetter); + this.parentIdGetter = parentIdGetter; + } + + @Override + public void reload(List dataList, boolean force) { + if (!force && this.getCount() > 0) { + return; + } + this.safeWrite("reload", () -> { + dataMap.clear(); + allTreeMap.clear(); + dataList.forEach(data -> { + K id = idGetter.apply(data); + dataMap.put(id, data); + K parentId = parentIdGetter.apply(data); + allTreeMap.put(parentId, data); + }); + return null; + }); + } + + @Override + public List getListByParentId(K parentId) { + return this.safeRead("getListByParentId", () -> { + List resultList = new LinkedList<>(); + Collection children = allTreeMap.get(parentId); + if (CollUtil.isNotEmpty(children)) { + resultList.addAll(children); + } + return resultList; + }); + } + + @Override + public void put(K id, V data) { + this.safeWrite("put", () -> { + dataMap.put(id, data); + K parentId = parentIdGetter.apply(data); + allTreeMap.remove(parentId, data); + allTreeMap.put(parentId, data); + return null; + }); + } + + @Override + public V invalidate(K id) { + return this.safeWrite("invalidate", () -> { + V v = dataMap.remove(id); + if (v != null) { + K parentId = parentIdGetter.apply(v); + allTreeMap.remove(parentId, v); + } + return v; + }); + } + + @Override + public void invalidateSet(Set keys) { + this.safeWrite("invalidateSet", () -> { + keys.forEach(id -> { + if (id != null) { + V data = dataMap.remove(id); + if (data != null) { + K parentId = parentIdGetter.apply(data); + allTreeMap.remove(parentId, data); + } + } + }); + return null; + }); + } + + @Override + public void invalidateAll() { + this.safeWrite("invalidateAll", () -> { + dataMap.clear(); + allTreeMap.clear(); + return null; + }); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/BaseMultiDataSourceConfig.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/BaseMultiDataSourceConfig.java new file mode 100644 index 00000000..369fcf33 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/BaseMultiDataSourceConfig.java @@ -0,0 +1,60 @@ +package com.orangeforms.common.core.config; + +import com.alibaba.druid.pool.DruidDataSource; +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +/** + * 基于Druid的数据源配置的基类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Configuration +@ConfigurationProperties(prefix = "spring.datasource.druid") +public class BaseMultiDataSourceConfig { + + private String driverClassName; + private String name; + private Integer initialSize; + private Integer minIdle; + private Integer maxActive; + private Integer maxWait; + private Integer timeBetweenEvictionRunsMillis; + private Integer minEvictableIdleTimeMillis; + private Boolean poolPreparedStatements; + private Integer maxPoolPreparedStatementPerConnectionSize; + private Integer maxOpenPreparedStatements; + private String validationQuery; + private Boolean testWhileIdle; + private Boolean testOnBorrow; + private Boolean testOnReturn; + + /** + * 将连接池的通用配置应用到数据源对象上。 + * + * @param druidDataSource Druid的数据源。 + * @return 应用后的Druid数据源。 + */ + protected DruidDataSource applyCommonProps(DruidDataSource druidDataSource) { + druidDataSource.setConnectionErrorRetryAttempts(5); + druidDataSource.setDriverClassName(driverClassName); + druidDataSource.setName(name); + druidDataSource.setInitialSize(initialSize); + druidDataSource.setMinIdle(minIdle); + druidDataSource.setMaxActive(maxActive); + druidDataSource.setMaxWait(maxWait); + druidDataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); + druidDataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); + druidDataSource.setPoolPreparedStatements(poolPreparedStatements); + druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize); + druidDataSource.setMaxOpenPreparedStatements(maxOpenPreparedStatements); + druidDataSource.setValidationQuery(validationQuery); + druidDataSource.setTestWhileIdle(testWhileIdle); + druidDataSource.setTestOnBorrow(testOnBorrow); + druidDataSource.setTestOnReturn(testOnReturn); + return druidDataSource; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/CommonWebMvcConfig.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/CommonWebMvcConfig.java new file mode 100644 index 00000000..e621b784 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/CommonWebMvcConfig.java @@ -0,0 +1,87 @@ +package com.orangeforms.common.core.config; + +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.alibaba.fastjson.support.config.FastJsonConfig; +import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; +import com.orangeforms.common.core.interceptor.MyRequestArgumentResolver; +import com.orangeforms.common.core.util.ContextUtil; +import com.orangeforms.common.core.util.MyDateUtil; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.http.converter.ByteArrayHttpMessageConverter; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.StringHttpMessageConverter; +import org.springframework.validation.beanvalidation.MethodValidationPostProcessor; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import jakarta.servlet.http.HttpServletRequest; +import java.lang.reflect.Type; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; + +/** + * 所有的项目拦截器、参数解析器、消息对象转换器都在这里集中配置。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Configuration +public class CommonWebMvcConfig implements WebMvcConfigurer { + + @Bean + public MethodValidationPostProcessor methodValidationPostProcessor() { + return new MethodValidationPostProcessor(); + } + + @Override + public void addArgumentResolvers(List argumentResolvers) { + // 添加MyRequestBody参数解析器 + argumentResolvers.add(new MyRequestArgumentResolver()); + } + + private HttpMessageConverter responseBodyConverter() { + return new StringHttpMessageConverter(StandardCharsets.UTF_8); + } + + @Bean + public FastJsonHttpMessageConverter fastJsonHttpMessageConverter() { + FastJsonHttpMessageConverter fastConverter = new MyFastJsonHttpMessageConverter(); + List supportedMediaTypes = new ArrayList<>(); + supportedMediaTypes.add(MediaType.APPLICATION_JSON); + supportedMediaTypes.add(MediaType.APPLICATION_FORM_URLENCODED); + fastConverter.setSupportedMediaTypes(supportedMediaTypes); + FastJsonConfig fastJsonConfig = new FastJsonConfig(); + fastJsonConfig.setSerializerFeatures( + SerializerFeature.PrettyFormat, + SerializerFeature.DisableCircularReferenceDetect, + SerializerFeature.IgnoreNonFieldGetter); + fastJsonConfig.setDateFormat(MyDateUtil.COMMON_SHORT_DATETIME_FORMAT); + fastConverter.setFastJsonConfig(fastJsonConfig); + return fastConverter; + } + + @Override + public void configureMessageConverters(List> converters) { + converters.add(responseBodyConverter()); + converters.add(new ByteArrayHttpMessageConverter()); + converters.add(fastJsonHttpMessageConverter()); + } + + public static class MyFastJsonHttpMessageConverter extends FastJsonHttpMessageConverter { + + @Override + public boolean canWrite(Type type, Class clazz, MediaType mediaType) { + HttpServletRequest request = ContextUtil.getHttpRequest(); + if (request == null) { + return super.canWrite(type, clazz, mediaType); + } + if (request.getRequestURI().contains("/v3/api-docs")) { + return false; + } + return super.canWrite(type, clazz, mediaType); + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/CoreProperties.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/CoreProperties.java new file mode 100644 index 00000000..b2bcabe2 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/CoreProperties.java @@ -0,0 +1,83 @@ +package com.orangeforms.common.core.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +/** + * common-core的配置属性类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Configuration +@ConfigurationProperties(prefix = "common-core") +public class CoreProperties { + + public static final String MYSQL_TYPE = "mysql"; + public static final String POSTGRESQL_TYPE = "postgresql"; + public static final String ORACLE_TYPE = "oracle"; + public static final String DM_TYPE = "dm8"; + public static final String KINGBASE_TYPE = "kingbase"; + public static final String OPENGAUSS_TYPE = "opengauss"; + + /** + * 数据库类型。 + */ + private String databaseType = MYSQL_TYPE; + + /** + * 是否为MySQL。 + * + * @return 是返回true,否则false。 + */ + public boolean isMySql() { + return this.databaseType.equals(MYSQL_TYPE); + } + + /** + * 是否为PostgreSQl。 + * + * @return 是返回true,否则false。 + */ + public boolean isPostgresql() { + return this.databaseType.equals(POSTGRESQL_TYPE); + } + + /** + * 是否为Oracle。 + * + * @return 是返回true,否则false。 + */ + public boolean isOracle() { + return this.databaseType.equals(ORACLE_TYPE); + } + + /** + * 是否为达梦8。 + * + * @return 是返回true,否则false。 + */ + public boolean isDm() { + return this.databaseType.equals(DM_TYPE); + } + + /** + * 是否为人大金仓。 + * + * @return 是返回true,否则false。 + */ + public boolean isKingbase() { + return this.databaseType.equals(KINGBASE_TYPE); + } + + /** + * 是否为华为高斯。 + * + * @return 是返回true,否则false。 + */ + public boolean isOpenGauss() { + return this.databaseType.equals(OPENGAUSS_TYPE); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/DataSourceContextHolder.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/DataSourceContextHolder.java new file mode 100644 index 00000000..534443d7 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/DataSourceContextHolder.java @@ -0,0 +1,52 @@ +package com.orangeforms.common.core.config; + +/** + * 通过线程本地存储的方式,保存当前数据库操作所需的数据源类型,动态数据源会根据该值,进行动态切换。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class DataSourceContextHolder { + + private static final ThreadLocal CONTEXT_HOLDER = new ThreadLocal<>(); + + /** + * 设置数据源类型。 + * + * @param type 数据源类型 + * @return 原有数据源类型,如果第一次设置则返回null。 + */ + public static Integer setDataSourceType(Integer type) { + Integer datasourceType = CONTEXT_HOLDER.get(); + CONTEXT_HOLDER.set(type); + return datasourceType; + } + + /** + * 获取当前数据库操作执行线程的数据源类型,同时由动态数据源的路由函数调用。 + * + * @return 数据源类型。 + */ + public static Integer getDataSourceType() { + return CONTEXT_HOLDER.get(); + } + + /** + * 清除线程本地变量,以免内存泄漏。 + + * @param originalType 原有的数据源类型,如果该值为null,则情况本地化变量。 + */ + public static void unset(Integer originalType) { + if (originalType == null) { + CONTEXT_HOLDER.remove(); + } else { + CONTEXT_HOLDER.set(originalType); + } + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private DataSourceContextHolder() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/DataSourceInfo.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/DataSourceInfo.java new file mode 100644 index 00000000..8e03fcc2 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/DataSourceInfo.java @@ -0,0 +1,41 @@ +package com.orangeforms.common.core.config; + +import lombok.Data; + +/** + * 主要用户动态多数据源使用的配置数据。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class DataSourceInfo { + /** + * 用于多数据源切换的数据源类型。 + */ + private Integer datasourceType; + /** + * 用户名。 + */ + private String username; + /** + * 密码。 + */ + private String password; + /** + * 数据库主机。 + */ + private String databaseHost; + /** + * 端口号。 + */ + private Integer port; + /** + * 模式名。 + */ + private String schemaName; + /** + * 数据库名称。 + */ + private String databaseName; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/DynamicDataSource.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/DynamicDataSource.java new file mode 100644 index 00000000..1508412d --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/DynamicDataSource.java @@ -0,0 +1,170 @@ +package com.orangeforms.common.core.config; + +import cn.hutool.core.util.StrUtil; +import com.alibaba.druid.pool.DruidDataSource; +import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; +import org.springframework.util.Assert; + +import java.util.*; + +/** + * 动态数据源对象。当存在多个数据连接时使用。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class DynamicDataSource extends AbstractRoutingDataSource { + + @Autowired + private BaseMultiDataSourceConfig baseMultiDataSourceConfig; + @Autowired + private CoreProperties properties; + + private Set dynamicDatasourceTypeSet = new HashSet<>(); + private static final String ASSERT_MSG = "defaultTargetDatasource can't be null."; + + @Override + protected Object determineCurrentLookupKey() { + return DataSourceContextHolder.getDataSourceType(); + } + + /** + * 重新加载动态添加的数据源。既清空之前动态添加的数据源,同时添加参数中的新数据源列表。 + * + * @param dataSourceInfoList 新动态数据源列表。 + */ + public synchronized void reloadAll(List dataSourceInfoList) { + Map dataSourceMap = new HashMap<>(this.getResolvedDataSources()); + dynamicDatasourceTypeSet.forEach(dataSourceMap::remove); + dynamicDatasourceTypeSet.clear(); + for (DataSourceInfo dataSourceInfo : dataSourceInfoList) { + dynamicDatasourceTypeSet.add(dataSourceInfo.getDatasourceType()); + DruidDataSource dataSource = this.doConvert(dataSourceInfo); + baseMultiDataSourceConfig.applyCommonProps(dataSource); + dataSourceMap.put(dataSourceInfo.getDatasourceType(), dataSource); + } + Object defaultTargetDatasource = this.getResolvedDefaultDataSource(); + Assert.notNull(defaultTargetDatasource, ASSERT_MSG); + this.setTargetDataSources(dataSourceMap); + this.setDefaultTargetDataSource(defaultTargetDatasource); + super.afterPropertiesSet(); + } + + /** + * 添加动态添加数据源。 + * + * 动态添加数据源。 + */ + public synchronized void addDataSource(DataSourceInfo dataSourceInfo) { + if (dynamicDatasourceTypeSet.contains(dataSourceInfo.getDatasourceType())) { + return; + } + dynamicDatasourceTypeSet.add(dataSourceInfo.getDatasourceType()); + Map dataSourceMap = new HashMap<>(this.getResolvedDataSources()); + DruidDataSource dataSource = this.doConvert(dataSourceInfo); + baseMultiDataSourceConfig.applyCommonProps(dataSource); + dataSourceMap.put(dataSourceInfo.getDatasourceType(), dataSource); + Object defaultTargetDatasource = this.getResolvedDefaultDataSource(); + Assert.notNull(defaultTargetDatasource, ASSERT_MSG); + this.setTargetDataSources(dataSourceMap); + this.setDefaultTargetDataSource(defaultTargetDatasource); + super.afterPropertiesSet(); + } + + /** + * 添加动态添加数据源列表。 + * + * @param dataSourceInfoList 数据源信息列表。 + */ + public synchronized void addDataSources(List dataSourceInfoList) { + Map dataSourceMap = new HashMap<>(this.getResolvedDataSources()); + for (DataSourceInfo dataSourceInfo : dataSourceInfoList) { + if (!dynamicDatasourceTypeSet.contains(dataSourceInfo.getDatasourceType())) { + dynamicDatasourceTypeSet.add(dataSourceInfo.getDatasourceType()); + DruidDataSource dataSource = this.doConvert(dataSourceInfo); + baseMultiDataSourceConfig.applyCommonProps(dataSource); + dataSourceMap.put(dataSourceInfo.getDatasourceType(), dataSource); + } + } + Object defaultTargetDatasource = this.getResolvedDefaultDataSource(); + Assert.notNull(defaultTargetDatasource, ASSERT_MSG); + this.setTargetDataSources(dataSourceMap); + this.setDefaultTargetDataSource(defaultTargetDatasource); + super.afterPropertiesSet(); + } + + /** + * 动态移除数据源。 + * + * @param datasourceType 数据源类型。 + */ + public synchronized void removeDataSource(int datasourceType) { + if (!dynamicDatasourceTypeSet.remove(datasourceType)) { + return; + } + Map dataSourceMap = new HashMap<>(this.getResolvedDataSources()); + dataSourceMap.remove(datasourceType); + Object defaultTargetDatasource = this.getResolvedDefaultDataSource(); + Assert.notNull(defaultTargetDatasource, ASSERT_MSG); + this.setTargetDataSources(dataSourceMap); + this.setDefaultTargetDataSource(defaultTargetDatasource); + super.afterPropertiesSet(); + } + + private DruidDataSource doConvert(DataSourceInfo dataSourceInfo) { + DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); + dataSource.setUsername(dataSourceInfo.getUsername()); + dataSource.setPassword(dataSourceInfo.getPassword()); + StringBuilder urlBuilder = new StringBuilder(256); + String hostAndPort = dataSourceInfo.getDatabaseHost() + ":" + dataSourceInfo.getPort(); + if (properties.isMySql()) { + urlBuilder.append("jdbc:mysql://") + .append(hostAndPort) + .append("/") + .append(dataSourceInfo.getDatabaseName()) + .append("?characterEncoding=utf8&useSSL=true&serverTimezone=Asia/Shanghai"); + } else if (properties.isOracle()) { + urlBuilder.append("jdbc:oracle:thin:@") + .append(hostAndPort) + .append(":") + .append(dataSourceInfo.getDatabaseName()); + } else if (properties.isPostgresql()) { + urlBuilder.append("jdbc:postgresql://") + .append(hostAndPort) + .append("/") + .append(dataSourceInfo.getDatabaseName()); + if (StrUtil.isBlank(dataSourceInfo.getSchemaName())) { + urlBuilder.append("?currentSchema=public"); + } else { + urlBuilder.append("?currentSchema=").append(dataSourceInfo.getSchemaName()); + } + urlBuilder.append("&TimeZone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8"); + } else if (properties.isDm()) { + urlBuilder.append("jdbc:dm://") + .append(hostAndPort) + .append("?schema=") + .append(dataSourceInfo.getDatabaseName()) + .append("&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=true&characterEncoding=UTF-8"); + } else if (properties.isKingbase()) { + urlBuilder.append("jdbc:kingbase8://") + .append(hostAndPort) + .append("/") + .append(dataSourceInfo.getDatabaseName()) + .append("?useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=true&characterEncoding=UTF-8"); + } else if (properties.isOpenGauss()) { + urlBuilder.append("jdbc:opengauss://") + .append(hostAndPort) + .append("/") + .append(dataSourceInfo.getDatabaseName()); + if (StrUtil.isBlank(dataSourceInfo.getSchemaName())) { + urlBuilder.append("?currentSchema=public"); + } else { + urlBuilder.append("?currentSchema=").append(dataSourceInfo.getSchemaName()); + } + } + dataSource.setUrl(urlBuilder.toString()); + return dataSource; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/EncryptConfig.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/EncryptConfig.java new file mode 100644 index 00000000..830199b7 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/EncryptConfig.java @@ -0,0 +1,20 @@ +package com.orangeforms.common.core.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; + +/** + * 目前用于用户密码加密,UAA接入应用客户端的client_secret加密。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Configuration +public class EncryptConfig { + + @Bean + public BCryptPasswordEncoder passwordEncoder() { + return new BCryptPasswordEncoder(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/PageHelperConfig.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/PageHelperConfig.java new file mode 100644 index 00000000..6f46bc4e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/PageHelperConfig.java @@ -0,0 +1,38 @@ +package com.orangeforms.common.core.config; + +import com.github.pagehelper.PageInterceptor; +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.Properties; + +/** + * pagehelper的配置对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Configuration +@ConfigurationProperties(prefix = "pagehelper") +public class PageHelperConfig { + + private String helperDialect; + private String reasonable; + private String supportMethodsArguments; + private String params; + + @Bean + public PageInterceptor pageInterceptor() { + PageInterceptor interceptor = new PageInterceptor(); + Properties p = new Properties(); + p.setProperty("helperDialect", helperDialect); + p.setProperty("reasonable", reasonable); + p.setProperty("supportMethodsArguments", supportMethodsArguments); + p.setProperty("params", params); + interceptor.setProperties(p); + return interceptor; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/RestTemplateConfig.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/RestTemplateConfig.java new file mode 100644 index 00000000..d8deb0ad --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/RestTemplateConfig.java @@ -0,0 +1,71 @@ +package com.orangeforms.common.core.config; + +import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; +import org.apache.hc.client5.http.classic.HttpClient; +import org.apache.hc.client5.http.config.RequestConfig; +import org.apache.hc.client5.http.impl.classic.HttpClientBuilder; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.client.ClientHttpRequestFactory; +import org.springframework.http.client.ClientHttpResponse; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.StringHttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.client.DefaultResponseErrorHandler; +import org.springframework.web.client.RestOperations; +import org.springframework.web.client.RestTemplate; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * RestTemplate连接池配置对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Configuration +public class RestTemplateConfig { + private static final int MAX_TOTAL_CONNECTION = 50; + private static final int MAX_CONNECTION_PER_ROUTE = 20; + private static final int CONNECTION_TIMEOUT = 20000; + private static final int READ_TIMEOUT = 30000; + + @Bean + @ConditionalOnMissingBean({RestOperations.class, RestTemplate.class}) + public RestTemplate restTemplate() { + RestTemplate restTemplate = new RestTemplate(createFactory()); + List> messageConverters = restTemplate.getMessageConverters(); + messageConverters.removeIf( + c -> c instanceof StringHttpMessageConverter || c instanceof MappingJackson2HttpMessageConverter); + messageConverters.add(1, new StringHttpMessageConverter(StandardCharsets.UTF_8)); + messageConverters.add(new FastJsonHttpMessageConverter()); + restTemplate.setErrorHandler(new DefaultResponseErrorHandler() { + @Override + public void handleError(ClientHttpResponse response) throws IOException { + // 防止400+和500等错误被直接抛出异常,这里避开了缺省处理方式,所有的错误均交给业务代码处理。 + } + }); + return restTemplate; + } + + private ClientHttpRequestFactory createFactory() { + PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(); + connectionManager.setMaxTotal(MAX_TOTAL_CONNECTION); + connectionManager.setDefaultMaxPerRoute(MAX_CONNECTION_PER_ROUTE); + RequestConfig requestConfig = RequestConfig.custom() + .setConnectionRequestTimeout(CONNECTION_TIMEOUT, TimeUnit.MICROSECONDS) + .setResponseTimeout(READ_TIMEOUT, TimeUnit.MICROSECONDS) + .build(); + HttpClient httpClient = HttpClientBuilder.create() + .setDefaultRequestConfig(requestConfig) + .setConnectionManager(connectionManager) + .build(); + return new HttpComponentsClientHttpRequestFactory(httpClient); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/TomcatConfig.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/TomcatConfig.java new file mode 100644 index 00000000..90ed08fd --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/config/TomcatConfig.java @@ -0,0 +1,39 @@ +package com.orangeforms.common.core.config; + +import org.apache.tomcat.util.descriptor.web.SecurityCollection; +import org.apache.tomcat.util.descriptor.web.SecurityConstraint; +import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * tomcat配置对象。当前配置禁用了PUT和DELETE方法,防止渗透攻击。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Configuration +public class TomcatConfig { + + @Bean + public TomcatServletWebServerFactory servletContainer() { + TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); + factory.addContextCustomizers(context -> { + SecurityConstraint securityConstraint = new SecurityConstraint(); + securityConstraint.setUserConstraint("CONFIDENTIAL"); + SecurityCollection collection = new SecurityCollection(); + collection.addPattern("/*"); + collection.addMethod("HEAD"); + collection.addMethod("PUT"); + collection.addMethod("PATCH"); + collection.addMethod("DELETE"); + collection.addMethod("TRACE"); + collection.addMethod("COPY"); + collection.addMethod("SEARCH"); + collection.addMethod("PROPFIND"); + securityConstraint.addCollection(collection); + context.addConstraint(securityConstraint); + }); + return factory; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/AggregationType.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/AggregationType.java new file mode 100644 index 00000000..d0368de0 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/AggregationType.java @@ -0,0 +1,81 @@ +package com.orangeforms.common.core.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 聚合计算的常量类型对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class AggregationType { + + /** + * sum 计数 + */ + public static final int SUM = 0; + /** + * count 汇总 + */ + public static final int COUNT = 1; + /** + * average 平均值 + */ + public static final int AVG = 2; + /** + * min 最小值 + */ + public static final int MIN = 3; + /** + * max 最大值 + */ + public static final int MAX = 4; + + private static final Map DICT_MAP = new HashMap<>(5); + static { + DICT_MAP.put(SUM, "累计总和"); + DICT_MAP.put(COUNT, "数量总和"); + DICT_MAP.put(AVG, "平均值"); + DICT_MAP.put(MIN, "最小值"); + DICT_MAP.put(MAX, "最大值"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 获取与SQL对应的聚合函数字符串名称。 + * + * @return 聚合函数名称。 + */ + public static String getAggregationFunction(Integer aggregationType) { + switch (aggregationType) { + case COUNT: + return "COUNT"; + case AVG: + return "AVG"; + case SUM: + return "SUM"; + case MAX: + return "MAX"; + case MIN: + return "MIN"; + default: + throw new IllegalArgumentException("无效的聚合类型!"); + } + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private AggregationType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/AppDeviceType.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/AppDeviceType.java new file mode 100644 index 00000000..edad8271 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/AppDeviceType.java @@ -0,0 +1,69 @@ +package com.orangeforms.common.core.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * App 登录的设备类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class AppDeviceType { + + /** + * 移动端 (如果不考虑区分android或ios的,可以使用该值) + */ + public static final int MOBILE = 0; + /** + * android + */ + public static final int ANDROID = 1; + /** + * iOS + */ + public static final int IOS = 2; + /** + * 微信公众号和小程序 + */ + public static final int WEIXIN = 3; + /** + * PC WEB + */ + public static final int WEB = 4; + + private static final Map DICT_MAP = new HashMap<>(5); + static { + DICT_MAP.put(MOBILE, "Mobile"); + DICT_MAP.put(ANDROID, "Android"); + DICT_MAP.put(IOS, "iOS"); + DICT_MAP.put(WEIXIN, "Wechat"); + DICT_MAP.put(WEB, "WEB"); + } + + /** + * 根据设备类型返回设备名称。 + * + * @param deviceType 设备类型。 + * @return 设备名称。 + */ + public static String getDeviceTypeName(int deviceType) { + return DICT_MAP.get(deviceType); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private AppDeviceType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/ApplicationConstant.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/ApplicationConstant.java new file mode 100644 index 00000000..25fce820 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/ApplicationConstant.java @@ -0,0 +1,161 @@ +package com.orangeforms.common.core.constant; + +import java.util.regex.Pattern; + +/** + * 应用程序的常量声明对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class ApplicationConstant { + + /** + * 适用于所有类型的字典格式数据。该常量为字典的键字段。 + */ + public static final String DICT_ID = "id"; + /** + * 适用于所有类型的字典格式数据。该常量为字典的名称字段。 + */ + public static final String DICT_NAME = "name"; + /** + * 适用于所有类型的字典格式数据。该常量为字典的键父字段。 + */ + public static final String PARENT_ID = "parentId"; + /** + * 数据同步使用的缺省消息队列主题名称。 + */ + public static final String DEFAULT_DATA_SYNC_TOPIC = "OrangeFormsOpen"; + /** + * 全量数据同步中,新增数据对象的键名称。 + */ + public static final String DEFAULT_FULL_SYNC_DATA_KEY = "data"; + /** + * 全量数据同步中,原有数据对象的键名称。 + */ + public static final String DEFAULT_FULL_SYNC_OLD_DATA_KEY = "oldData"; + /** + * 全量数据同步中,数据对象主键的键名称。 + */ + public static final String DEFAULT_FULL_SYNC_ID_KEY = "id"; + /** + * 为字典表数据缓存时,缓存名称的固定后缀。 + */ + public static final String DICT_CACHE_NAME_SUFFIX = "-DICT"; + /** + * 为树形字典表数据缓存时,缓存名称的固定后缀。 + */ + public static final String TREE_DICT_CACHE_NAME_SUFFIX = "-TREE-DICT"; + /** + * 图片文件上传的父目录。 + */ + public static final String UPLOAD_IMAGE_PARENT_PATH = "image"; + /** + * 附件文件上传的父目录。 + */ + public static final String UPLOAD_ATTACHMENT_PARENT_PATH = "attachment"; + /** + * CSV文件扩展名。 + */ + public static final String CSV_EXT = "csv"; + /** + * XLSX文件扩展名。 + */ + public static final String XLSX_EXT = "xlsx"; + /** + * 统计分类计算时,按天聚合计算的常量值。(前端在MyOrderParam和MyGroupParam中传给后台) + */ + public static final String DAY_AGGREGATION = "day"; + /** + * 统计分类计算时,按月聚合计算的常量值。(前端在MyOrderParam和MyGroupParam中传给后台) + */ + public static final String MONTH_AGGREGATION = "month"; + /** + * 统计分类计算时,按年聚合计算的常量值。(前端在MyOrderParam和MyGroupParam中传给后台) + */ + public static final String YEAR_AGGREGATION = "year"; + /** + * 请求头跟踪id名。 + */ + public static final String HTTP_HEADER_TRACE_ID = "traceId"; + /** + * 请求头菜单Id。 + */ + public static final String HTTP_HEADER_MENU_ID = "MenuId"; + /** + * 数据权限中,标记所有菜单的Id值。 + */ + public static final String DATA_PERM_ALL_MENU_ID = "AllMenuId"; + /** + * 请求头中记录的原始请求URL。 + */ + public static final String HTTP_HEADER_ORIGINAL_REQUEST_URL = "MY_ORIGINAL_REQUEST_URL"; + /** + * 免登录验证接口的请求头key。 + */ + public static final String HTTP_HEADER_DONT_AUTH = "DONT_AUTH"; + /** + * 系统服务内部调用时,可使用该HEAD,以便和外部调用加以区分,便于监控和流量分析。 + */ + public static final String HTTP_HEADER_INTERNAL_TOKEN = "INTERNAL_AUTH_TOKEN"; + /** + * 操作日志的数据源类型。 + */ + public static final int OPERATION_LOG_DATASOURCE_TYPE = 1000; + /** + * 在线表单的数据源类型。 + */ + public static final int COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE = 1010; + /** + * 报表模块的数据源类型。 + */ + public static final int COMMON_REPORT_DATASOURCE_TYPE = 1020; + /** + * 全局编码字典的数据源类型。 + */ + public static final int COMMON_GLOBAL_DICT_TYPE = 1050; + /** + * 租户管理所对应的数据源常量值。 + */ + public static final int TENANT_ADMIN_DATASOURCE_TYPE = 1100; + /** + * 租户业务默认数据库(系统搭建时的第一个租户数据库)所对应的数据源常量值。 + */ + public static final int TENANT_BUSINESS_DATASOURCE_TYPE = 1120; + /** + * 租户通用数据所对应的数据源常量值,如全局编码字典、在线表单、流程和报表等内置表数据。 + */ + public static final int TENANT_COMMON_DATASOURCE_TYPE = 1130; + /** + * 租户动态数据源主题(Redis)。 + */ + public static final String TENANT_DYNAMIC_DATASOURCE_TOPIC = "TenantDynamicDatasoruce"; + /** + * 租户基础数据同步(RocketMQ),如upms、全局编码字典、在线表单、流程、报表等。 + */ + public static final String TENANT_DATASYNC_TOPIC = "TenantSync"; + /** + * 租户管理的应用名。 + */ + public static final String TENANT_ADMIN_APP_NAME = "tenant-admin"; + /** + * 重要说明:该值为项目生成后的缺省密钥,仅为使用户可以快速上手并跑通流程。 + * 在实际的应用中,一定要为不同的项目或服务,自行生成公钥和私钥,并将 PRIVATE_KEY 的引用改为服务的配置项。 + * 密钥的生成方式,可通过执行common.core.util.RsaUtil类的main函数动态生成。 + */ + public static final String PRIVATE_KEY = + "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKkLhAydtOtA4WuIkkIIUVaGWu4ElOEAQF9GTulHHWOwCHI1UvcKolvS1G+mdsKcmGtEAQ92AUde/kDRGu8Wn7kLDtCgUfo72soHz7Qfv5pVB4ohMxQd/9cxeKjKbDoirhB9Z3xGF20zUozp4ZPLxpTtI7azr0xzUtd5+D/HfLDrAgMBAAECgYEApESZhDz4YyeAJiPnpJ06lS8oS2VOWzsIUs0av5uoloeoHXtt7Lx7u2kroHeNrl3Hy2yg7ypH4dgQkGHin3VHrVAgjG3TxhgBXIqqntzzk2AGJKBeIIkRX86uTvtKZyp3flUgcwcGmpepAHS1V1DPY3aVYvbcqAmoL6DX6VYN0NECQQDQUitMdC76lEtAr5/ywS0nrZJDo6U7eQ7ywx/eiJ+YmrSye8oorlAj1VBWG+Cl6jdHOHtTQyYv/tu71fjzQiJTAkEAz7wb47/vcSUpNWQxItFpXz0o6rbJh71xmShn1AKP7XptOVZGlW9QRYEzHabV9m/DHqI00cMGhHrWZAhCiTkUCQJAFsJjaJ7o4weAkTieyO7B+CvGZw1h5/V55Jvcx3s1tH5yb22G0Jr6tm9/r2isSnQkReutzZLwgR3e886UvD7lcQJAAUcD2OOuQkDbPwPNtYwaHMbQgJj9JkOI9kskUE5vuiMdltOr/XFAyhygRtdmy2wmhAK1VnDfkmL6/IR8fEGImQJABOB0KCalb0M8CPnqqHzozrD8gPObnIIr4aVvLIPATN2g7MM2N6F7JbI4RZFiKa92LV6bhQCY8OvHi5K2cgFpbw=="; + /** + * SQL注入检测的正则对象。 + */ + @SuppressWarnings("all") + public static final Pattern SQL_INJECT_PATTERN = + Pattern.compile("(.*\\=.*\\-\\-.*)|(.*(\\+).*)|(.*\\w+(%|\\$|#|&)\\w+.*)|(.*\\|\\|.*)|(.*\\s+(and|or)\\s+.*)" + + "|(.*\\b(select|update|union|and|or|delete|insert|trancate|char|substr|ascii|declare|exec|count|master|into|drop|execute|sleep|extractvalue|updatexml|substring|database|concat|rand)\\b.*)"); + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private ApplicationConstant() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/DataPermRuleType.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/DataPermRuleType.java new file mode 100644 index 00000000..772d0597 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/DataPermRuleType.java @@ -0,0 +1,81 @@ +package com.orangeforms.common.core.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 数据权限规则类型常量类。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class DataPermRuleType { + + /** + * 查看全部。 + */ + public static final int TYPE_ALL = 0; + + /** + * 仅查看当前用户。 + */ + public static final int TYPE_USER_ONLY = 1; + + /** + * 仅查看当前部门。 + */ + public static final int TYPE_DEPT_ONLY = 2; + + /** + * 所在部门及子部门。 + */ + public static final int TYPE_DEPT_AND_CHILD_DEPT = 3; + + /** + * 多部门及子部门。 + */ + public static final int TYPE_MULTI_DEPT_AND_CHILD_DEPT = 4; + + /** + * 自定义部门列表。 + */ + public static final int TYPE_CUSTOM_DEPT_LIST = 5; + + /** + * 本部门所有用户。 + */ + public static final int TYPE_DEPT_USERS = 6; + + /** + * 本部门及子部门所有用户。 + */ + public static final int TYPE_DEPT_AND_CHILD_DEPT_USERS = 7; + + private static final Map DICT_MAP = new HashMap<>(6); + static { + DICT_MAP.put(TYPE_ALL, "查看全部"); + DICT_MAP.put(TYPE_USER_ONLY, "仅查看当前用户"); + DICT_MAP.put(TYPE_DEPT_ONLY, "仅查看所在部门"); + DICT_MAP.put(TYPE_DEPT_AND_CHILD_DEPT, "所在部门及子部门"); + DICT_MAP.put(TYPE_MULTI_DEPT_AND_CHILD_DEPT, "多部门及子部门"); + DICT_MAP.put(TYPE_CUSTOM_DEPT_LIST, "自定义部门列表"); + DICT_MAP.put(TYPE_DEPT_USERS, "本部门所有用户"); + DICT_MAP.put(TYPE_DEPT_AND_CHILD_DEPT_USERS, "本部门及子部门所有用户"); + } + + /** + * 判断参数是否为当前常量字典的合法取值范围。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private DataPermRuleType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/DictType.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/DictType.java new file mode 100644 index 00000000..5d294431 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/DictType.java @@ -0,0 +1,59 @@ +package com.orangeforms.common.core.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 字典类型常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class DictType { + + /** + * 数据表字典。 + */ + public static final int TABLE = 1; + /** + * URL字典。 + */ + public static final int URL = 5; + /** + * 常量字典。 + */ + public static final int CONST = 10; + /** + * 自定义字典。 + */ + public static final int CUSTOM = 15; + /** + * 全局编码字典。 + */ + public static final int GLOBAL_DICT = 20; + + private static final Map DICT_MAP = new HashMap<>(2); + static { + DICT_MAP.put(TABLE, "数据表字典"); + DICT_MAP.put(URL, "URL字典"); + DICT_MAP.put(CONST, "静态字典"); + DICT_MAP.put(CUSTOM, "自定义字典"); + DICT_MAP.put(GLOBAL_DICT, "全局编码字典"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private DictType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/ErrorCodeEnum.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/ErrorCodeEnum.java new file mode 100644 index 00000000..423ba928 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/ErrorCodeEnum.java @@ -0,0 +1,88 @@ +package com.orangeforms.common.core.constant; + +/** + * 返回应答中的错误代码和错误信息。 + * + * @author Jerry + * @date 2024-07-02 + */ +public enum ErrorCodeEnum { + + /** + * 没有错误 + */ + NO_ERROR("没有错误"), + /** + * 未处理的异常! + */ + UNHANDLED_EXCEPTION("未处理的异常!"), + + ARGUMENT_NULL_EXIST("数据验证失败,接口调用参数存在空值,请核对!"), + ARGUMENT_PK_ID_NULL("数据验证失败,接口调用主键Id参数为空,请核对!"), + INVALID_ARGUMENT_FORMAT("数据验证失败,不合法的参数格式,请核对!"), + INVALID_STATUS_ARGUMENT("数据验证失败,无效的状态参数值,请核对!"), + UPLOAD_FAILED("数据验证失败,数据上传失败!"), + INVALID_UPLOAD_FIELD("数据验证失败,该字段不支持数据上传!"), + INVALID_UPLOAD_STORE_TYPE("数据验证失败,并不支持上传存储类型!"), + INVALID_UPLOAD_FILE_ARGUMENT("数据验证失败,上传文件参数错误,请核对!"), + INVALID_UPLOAD_FILE_FORMAT("无效的上传文件格式!"), + INVALID_UPLOAD_FILE_IOERROR("上传文件写入失败,请联系管理员!"), + UNAUTHORIZED_LOGIN("当前用户尚未登录或登录已超时,请重新登录!"), + UNAUTHORIZED_USER_PERMISSION("权限验证失败,当前用户不能访问该接口,请核对!"), + NO_ACCESS_PERMISSION("当前用户没有访问权限,请核对!"), + NO_OPERATION_PERMISSION("当前用户没有操作权限,请核对!"), + + PASSWORD_ERR("密码错误,请重试!"), + INVALID_USERNAME_PASSWORD("用户名或密码错误,请重试!"), + INVALID_ACCESS_TOKEN("无效的用户访问令牌!"), + INVALID_USER_STATUS("用户状态错误,请刷新后重试!"), + INVALID_TENANT_CODE("指定的租户编码并不存在,请刷新后重试!"), + INVALID_TENANT_STATUS("当前租户为不可用状态,请刷新后重试!"), + INVALID_USER_TENANT("当前用户并不属于当前租户,请刷新后重试!"), + + HAS_CHILDREN_DATA("数据验证失败,子数据存在,请刷新后重试!"), + DATA_VALIDATED_FAILED("数据验证失败,请核对!"), + UPLOAD_FILE_FAILED("文件上传失败,请联系管理员!"), + DATA_SAVE_FAILED("数据保存失败,请联系管理员!"), + DATA_ACCESS_FAILED("数据访问失败,请联系管理员!"), + DATA_PERM_ACCESS_FAILED("数据访问失败,您没有该页面的数据访问权限!"), + DUPLICATED_UNIQUE_KEY("数据保存失败,存在重复数据,请核对!"), + DATA_NOT_EXIST("数据不存在,请刷新后重试!"), + DATA_PARENT_LEVEL_ID_NOT_EXIST("数据验证失败,父级别关联Id不存在,请刷新后重试!"), + DATA_PARENT_ID_NOT_EXIST("数据验证失败,ParentId不存在,请核对!"), + INVALID_RELATED_RECORD_ID("数据验证失败,关联数据并不存在,请刷新后重试!"), + INVALID_DATA_MODEL("数据验证失败,无效的数据实体对象!"), + INVALID_DATA_FIELD("数据验证失败,无效的数据实体对象字段!"), + INVALID_CLASS_FIELD("数据验证失败,无效的类对象字段!"), + SERVER_INTERNAL_ERROR("服务器内部错误,请联系管理员!"), + REDIS_CACHE_ACCESS_TIMEOUT("Redis缓存数据访问超时,请刷新后重试!"), + REDIS_CACHE_ACCESS_STATE_ERROR("Redis缓存数据访问状态错误,请刷新后重试!"), + FAILED_TO_INVOKE_THIRDPARTY_URL("调用第三方接口失败!"), + + FLOW_WORK_ORDER_EXIST("该业务数据Id存在尚未完成审批的流程实例,同一业务数据主键不能同时重复提交审批!"); + + // 下面的枚举值为特定枚举值,即开发者可以根据自己的项目需求定义更多的非通用枚举值 + + /** + * 构造函数。 + * + * @param errorMessage 错误消息。 + */ + ErrorCodeEnum(String errorMessage) { + this.errorMessage = errorMessage; + } + + /** + * 错误信息。 + */ + private final String errorMessage; + + /** + * 获取错误信息。 + * + * @return 错误信息。 + */ + public String getErrorMessage() { + return errorMessage; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/FieldFilterType.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/FieldFilterType.java new file mode 100644 index 00000000..db0e1752 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/FieldFilterType.java @@ -0,0 +1,127 @@ +package com.orangeforms.common.core.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 字段过滤类型常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FieldFilterType { + /** + * 等于过滤。 + */ + public static final int EQUAL = 0; + /** + * 不等于过滤。 + */ + public static final int NOT_EQUAL = 1; + /** + * 大于等于。 + */ + public static final int GE = 2; + /** + * 大于。 + */ + public static final int GT = 3; + /** + * 小于等于。 + */ + public static final int LE = 4; + /** + * 小于。 + */ + public static final int LT = 5; + /** + * 模糊查询。 + */ + public static final int LIKE = 6; + /** + * IN列表过滤。 + */ + public static final int IN = 7; + /** + * NOT IN列表过滤。 + */ + public static final int NOT_IN = 8; + /** + * 范围过滤。 + */ + public static final int BETWEEN = 9; + /** + * 不为空。 + */ + public static final int IS_NOT_NULL = 100; + /** + * 为空。 + */ + public static final int IS_NULL = 101; + + private static final Map DICT_MAP = new HashMap<>(9); + static { + DICT_MAP.put(EQUAL, " = "); + DICT_MAP.put(NOT_EQUAL, " <> "); + DICT_MAP.put(GE, " >= "); + DICT_MAP.put(GT, " > "); + DICT_MAP.put(LE, " <= "); + DICT_MAP.put(LT, " < "); + DICT_MAP.put(LIKE, " LIKE "); + DICT_MAP.put(IN, " IN "); + DICT_MAP.put(NOT_IN, " NOT IN "); + DICT_MAP.put(BETWEEN, " BETWEEN "); + DICT_MAP.put(IS_NOT_NULL, " IS NOT NULL "); + DICT_MAP.put(IS_NULL, " IS NULL "); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 获取显示名。 + * @param value 常量值。 + * @return 常量值对应的显示名。 + */ + public static String getName(Integer value) { + return DICT_MAP.get(value); + } + + /** + * 不支持日期型字段的过滤类型。 + * + * @param filterType 过滤类型。 + * @return 不支持返回true,否则false。 + */ + public static boolean unsupportDateFilterType(int filterType) { + return filterType == FieldFilterType.IN + || filterType == FieldFilterType.NOT_IN + || filterType == FieldFilterType.NOT_EQUAL + || filterType == FieldFilterType.LIKE; + } + + /** + * 支持多过滤值的过滤类型。 + * + * @param filterType 过滤类型。 + * @return 支持返回true,否则false。 + */ + public static boolean supportMultiValueFilterType(int filterType) { + return filterType == FieldFilterType.IN + || filterType == FieldFilterType.NOT_IN + || filterType == FieldFilterType.BETWEEN; + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FieldFilterType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/FilterParamType.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/FilterParamType.java new file mode 100644 index 00000000..dda91b2e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/FilterParamType.java @@ -0,0 +1,54 @@ +package com.orangeforms.common.core.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 字段过滤参数类型常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FilterParamType { + + /** + * 整数数值型。 + */ + public static final int LONG = 0; + /** + * 浮点型。 + */ + public static final int FLOAT = 1; + /** + * 字符型。 + */ + public static final int STRING = 2; + /** + * 日期型。 + */ + public static final int DATE = 3; + + private static final Map DICT_MAP = new HashMap<>(9); + static { + DICT_MAP.put(LONG, "整数数值型"); + DICT_MAP.put(FLOAT, "浮点型"); + DICT_MAP.put(STRING, "字符型"); + DICT_MAP.put(DATE, "日期型"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FilterParamType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/GlobalDeletedFlag.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/GlobalDeletedFlag.java new file mode 100644 index 00000000..a7ed6ba3 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/GlobalDeletedFlag.java @@ -0,0 +1,25 @@ +package com.orangeforms.common.core.constant; + +/** + * 数据记录逻辑删除标记常量。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class GlobalDeletedFlag { + + /** + * 表示数据表记录已经删除 + */ + public static final int DELETED = -1; + /** + * 数据记录正常 + */ + public static final int NORMAL = 1; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private GlobalDeletedFlag() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/MaskFieldTypeEnum.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/MaskFieldTypeEnum.java new file mode 100644 index 00000000..d242e26c --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/MaskFieldTypeEnum.java @@ -0,0 +1,47 @@ +package com.orangeforms.common.core.constant; + +/** + * 字段脱敏类型枚举。。 + * + * @author Jerry + * @date 2024-07-02 + */ +public enum MaskFieldTypeEnum { + + /** + * 自定义实现。 + */ + CUSTOM, + /** + * 姓名。 + */ + NAME, + /** + * 移动电话。 + */ + MOBILE_PHONE, + /** + * 座机电话。 + */ + FIXED_PHONE, + /** + * 身份证。 + */ + ID_CARD, + /** + * 银行卡号。 + */ + BANK_CARD, + /** + * 汽车牌照号。 + */ + CAR_LICENSE, + /** + * 邮件。 + */ + EMAIL, + /** + * 固定长度的前缀和后缀不被掩码。 + */ + NO_MASK_PREFIX_SUFFIX, +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/ObjectFieldType.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/ObjectFieldType.java new file mode 100644 index 00000000..660b606c --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/ObjectFieldType.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.core.constant; + +/** + * 对应于数据表字段中的类型,我们需要统一映射到Java实体对象字段的类型。 + * 该类是描述Java实体对象字段类型的常量类。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class ObjectFieldType { + + public static final String LONG = "Long"; + public static final String INTEGER = "Integer"; + public static final String DOUBLE = "Double"; + public static final String BIG_DECIMAL = "BigDecimal"; + public static final String BOOLEAN = "Boolean"; + public static final String STRING = "String"; + public static final String DATE = "Date"; + public static final String BYTE_ARRAY = "byte[]"; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private ObjectFieldType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/UserFilterGroup.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/UserFilterGroup.java new file mode 100644 index 00000000..d966cf6d --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/constant/UserFilterGroup.java @@ -0,0 +1,22 @@ +package com.orangeforms.common.core.constant; + +/** + * 用户分组过滤常量。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class UserFilterGroup { + + public static final String USER = "USER_GROUP"; + public static final String ROLE = "ROLE_GROUP"; + public static final String DEPT = "DEPT_GROUP"; + public static final String POST = "POST_GROUP"; + public static final String DEPT_POST = "DEPT_POST_GROUP"; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private UserFilterGroup() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/DataValidationException.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/DataValidationException.java new file mode 100644 index 00000000..66053ad5 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/DataValidationException.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.core.exception; + +/** + * 数据验证失败的自定义异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class DataValidationException extends RuntimeException { + + /** + * 构造函数。 + */ + public DataValidationException() { + + } + + /** + * 构造函数。 + * + * @param msg 错误信息。 + */ + public DataValidationException(String msg) { + super(msg); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidClassFieldException.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidClassFieldException.java new file mode 100644 index 00000000..762eac91 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidClassFieldException.java @@ -0,0 +1,30 @@ +package com.orangeforms.common.core.exception; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 无效的类对象字段的自定义异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class InvalidClassFieldException extends RuntimeException { + + private final String className; + private final String fieldName; + + /** + * 构造函数。 + * + * @param className 对象名。 + * @param fieldName 字段名。 + */ + public InvalidClassFieldException(String className, String fieldName) { + super("Invalid FieldName [" + fieldName + "] in Class [" + className + "]."); + this.className = className; + this.fieldName = fieldName; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidDataFieldException.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidDataFieldException.java new file mode 100644 index 00000000..2c5d249e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidDataFieldException.java @@ -0,0 +1,30 @@ +package com.orangeforms.common.core.exception; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 无效的实体对象字段的自定义异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class InvalidDataFieldException extends RuntimeException { + + private final String modelName; + private final String fieldName; + + /** + * 构造函数。 + * + * @param modelName 实体对象名。 + * @param fieldName 字段名。 + */ + public InvalidDataFieldException(String modelName, String fieldName) { + super("Invalid FieldName [" + fieldName + "] in Model Class [" + modelName + "]."); + this.modelName = modelName; + this.fieldName = fieldName; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidDataModelException.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidDataModelException.java new file mode 100644 index 00000000..b17abb8e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidDataModelException.java @@ -0,0 +1,27 @@ +package com.orangeforms.common.core.exception; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 无效的实体对象的自定义异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class InvalidDataModelException extends RuntimeException { + + private final String modelName; + + /** + * 构造函数。 + * + * @param modelName 实体对象名。 + */ + public InvalidDataModelException(String modelName) { + super("Invalid Model Class [" + modelName + "]."); + this.modelName = modelName; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidDblinkTypeException.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidDblinkTypeException.java new file mode 100644 index 00000000..b7589219 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidDblinkTypeException.java @@ -0,0 +1,24 @@ +package com.orangeforms.common.core.exception; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 无效的数据库链接类型自定义异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class InvalidDblinkTypeException extends RuntimeException { + + /** + * 构造函数。 + * + * @param dblinkType 数据库链接类型。 + */ + public InvalidDblinkTypeException(int dblinkType) { + super("Invalid Dblink Type [" + dblinkType + "]."); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidRedisModeException.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidRedisModeException.java new file mode 100644 index 00000000..9b197625 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidRedisModeException.java @@ -0,0 +1,27 @@ +package com.orangeforms.common.core.exception; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 无效的Redis模式的自定义异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class InvalidRedisModeException extends RuntimeException { + + private final String mode; + + /** + * 构造函数。 + * + * @param mode 错误的模式。 + */ + public InvalidRedisModeException(String mode) { + super("Invalid Redis Mode [" + mode + "], only supports [single/cluster/sentinel/master_slave]"); + this.mode = mode; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/MapCacheAccessException.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/MapCacheAccessException.java new file mode 100644 index 00000000..b47dd010 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/MapCacheAccessException.java @@ -0,0 +1,20 @@ +package com.orangeforms.common.core.exception; + +/** + * 内存缓存访问失败。比如:获取分布式数据锁超时、等待线程中断等。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class MapCacheAccessException extends RuntimeException { + + /** + * 构造函数。 + * + * @param msg 错误信息。 + * @param cause 原始异常。 + */ + public MapCacheAccessException(String msg, Throwable cause) { + super(msg, cause); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/MyRuntimeException.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/MyRuntimeException.java new file mode 100644 index 00000000..82d8f4ae --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/MyRuntimeException.java @@ -0,0 +1,46 @@ +package com.orangeforms.common.core.exception; + +/** + * 自定义的运行时异常,在需要抛出运行时异常时,可使用该异常。 + * NOTE:主要是为了避免SonarQube进行代码质量扫描时,给出警告。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class MyRuntimeException extends RuntimeException { + + /** + * 构造函数。 + */ + public MyRuntimeException() { + + } + + /** + * 构造函数。 + * + * @param throwable 引发异常对象。 + */ + public MyRuntimeException(Throwable throwable) { + super(throwable); + } + + /** + * 构造函数。 + * + * @param msg 错误信息。 + */ + public MyRuntimeException(String msg) { + super(msg); + } + + /** + * 构造函数。 + * + * @param msg 错误信息。 + * @param throwable 引发异常对象。 + */ + public MyRuntimeException(String msg, Throwable throwable) { + super(msg, throwable); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/NoDataAffectException.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/NoDataAffectException.java new file mode 100644 index 00000000..0d9dd3d9 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/NoDataAffectException.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.core.exception; + +/** + * 没有数据被修改的自定义异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class NoDataAffectException extends RuntimeException { + + /** + * 构造函数。 + */ + public NoDataAffectException() { + + } + + /** + * 构造函数。 + * + * @param msg 错误信息。 + */ + public NoDataAffectException(String msg) { + super(msg); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/NoDataPermException.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/NoDataPermException.java new file mode 100644 index 00000000..2e18d311 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/NoDataPermException.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.core.exception; + +/** + * 没有数据访问权限的自定义异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class NoDataPermException extends RuntimeException { + + /** + * 构造函数。 + */ + public NoDataPermException() { + + } + + /** + * 构造函数。 + * + * @param msg 错误信息。 + */ + public NoDataPermException(String msg) { + super(msg); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/RedisCacheAccessException.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/RedisCacheAccessException.java new file mode 100644 index 00000000..b0dfe017 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/exception/RedisCacheAccessException.java @@ -0,0 +1,20 @@ +package com.orangeforms.common.core.exception; + +/** + * Redis缓存访问失败。比如:获取分布式数据锁超时、等待线程中断等。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class RedisCacheAccessException extends RuntimeException { + + /** + * 构造函数。 + * + * @param msg 错误信息。 + * @param cause 原始异常。 + */ + public RedisCacheAccessException(String msg, Throwable cause) { + super(msg, cause); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/interceptor/MyRequestArgumentResolver.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/interceptor/MyRequestArgumentResolver.java new file mode 100644 index 00000000..08c198ad --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/interceptor/MyRequestArgumentResolver.java @@ -0,0 +1,227 @@ +package com.orangeforms.common.core.interceptor; + +import cn.hutool.core.convert.Convert; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.annotation.MyRequestBody; +import org.apache.commons.io.IOUtils; +import org.springframework.core.MethodParameter; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.lang.NonNull; +import org.springframework.util.Assert; +import org.springframework.web.bind.support.WebDataBinderFactory; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.method.support.ModelAndViewContainer; + +import jakarta.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.lang.reflect.ParameterizedType; +import java.math.BigDecimal; +import java.util.*; + +/** + * MyRequestBody解析器 + * 解决的问题: + * 1、单个字符串等包装类型都要写一个对象才可以用@RequestBody接收; + * 2、多个对象需要封装到一个对象里才可以用@RequestBody接收。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class MyRequestArgumentResolver implements HandlerMethodArgumentResolver { + + private static final String JSONBODY_ATTRIBUTE = "MY_REQUEST_BODY_ATTRIBUTE_XX"; + + private static final Set> CLASS_SET = new HashSet<>(); + + static { + CLASS_SET.add(Integer.class); + CLASS_SET.add(Long.class); + CLASS_SET.add(Short.class); + CLASS_SET.add(Float.class); + CLASS_SET.add(Double.class); + CLASS_SET.add(Boolean.class); + CLASS_SET.add(Byte.class); + CLASS_SET.add(BigDecimal.class); + CLASS_SET.add(Character.class); + CLASS_SET.add(Date.class); + } + + /** + * 设置支持的方法参数类型。 + * + * @param parameter 方法参数。 + * @return 支持的类型。 + */ + @Override + public boolean supportsParameter(@NonNull MethodParameter parameter) { + return parameter.hasParameterAnnotation(MyRequestBody.class); + } + + /** + * 参数解析,利用fastjson。 + * 注意:非基本类型返回null会报空指针异常,要通过反射或者JSON工具类创建一个空对象。 + */ + @Override + public Object resolveArgument( + @NonNull MethodParameter parameter, + ModelAndViewContainer mavContainer, + @NonNull NativeWebRequest webRequest, + WebDataBinderFactory binderFactory) throws Exception { + HttpServletRequest servletRequest = webRequest.getNativeRequest(HttpServletRequest.class); + Assert.notNull(servletRequest, "HttpServletRequest can't be NULL."); + String contentType = servletRequest.getContentType(); + if (!HttpMethod.POST.name().equals(servletRequest.getMethod())) { + throw new IllegalArgumentException("Only POST method can be applied @MyRequestBody annotation!"); + } + if (!StrUtil.containsIgnoreCase(contentType, MediaType.APPLICATION_JSON_VALUE)) { + throw new IllegalArgumentException( + "Only application/json Content-Type can be applied @MyRequestBody annotation!"); + } + // 根据@MyRequestBody注解value作为json解析的key + MyRequestBody parameterAnnotation = parameter.getParameterAnnotation(MyRequestBody.class); + Assert.notNull(parameterAnnotation, "parameterAnnotation can't be NULL"); + JSONObject jsonObject = getRequestBody(webRequest); + if (jsonObject == null) { + if (parameterAnnotation.required()) { + throw new IllegalArgumentException("Request Body is EMPTY!"); + } + return null; + } + String key = parameterAnnotation.value(); + if (StrUtil.isBlank(key)) { + key = parameter.getParameterName(); + } + Object value = jsonObject.get(key); + if (value == null) { + if (parameterAnnotation.required()) { + throw new IllegalArgumentException(String.format("Required parameter %s is not present!", key)); + } + return null; + } + // 获取参数类型。 + Class parameterType = parameter.getParameterType(); + // 基本类型 + if (parameterType.isPrimitive()) { + return parsePrimitive(parameterType.getName(), value); + } + // 基本类型包装类 + if (isBasicDataTypes(parameterType)) { + return parseBasicTypeWrapper(parameterType, value); + } else if (parameterType == String.class) { + // 字符串类型 + return value.toString(); + } + // 对象类型 + if (!(value instanceof JSONArray)) { + // 其他复杂对象 + return JSON.toJavaObject((JSONObject) value, parameterType); + } + if (parameter.getGenericParameterType() instanceof ParameterizedType) { + return ((JSONArray) value).toJavaObject(parameter.getGenericParameterType()); + } + // 非参数化的集合类型 + return JSON.parseObject(value.toString(), parameterType); + } + + private Object parsePrimitive(String parameterTypeName, Object value) { + final String booleanTypeName = "boolean"; + if (booleanTypeName.equals(parameterTypeName)) { + return Boolean.valueOf(value.toString()); + } + final String intTypeName = "int"; + if (intTypeName.equals(parameterTypeName)) { + return Integer.valueOf(value.toString()); + } + final String charTypeName = "char"; + if (charTypeName.equals(parameterTypeName)) { + return value.toString().charAt(0); + } + final String shortTypeName = "short"; + if (shortTypeName.equals(parameterTypeName)) { + return Short.valueOf(value.toString()); + } + final String longTypeName = "long"; + if (longTypeName.equals(parameterTypeName)) { + return Long.valueOf(value.toString()); + } + final String floatTypeName = "float"; + if (floatTypeName.equals(parameterTypeName)) { + return Float.valueOf(value.toString()); + } + final String doubleTypeName = "double"; + if (doubleTypeName.equals(parameterTypeName)) { + return Double.valueOf(value.toString()); + } + final String byteTypeName = "byte"; + if (byteTypeName.equals(parameterTypeName)) { + return Byte.valueOf(value.toString()); + } + return null; + } + + private Object parseBasicTypeWrapper(Class parameterType, Object value) { + if (Number.class.isAssignableFrom(parameterType)) { + return this.parseNumberType(parameterType, value); + } else if (parameterType == Boolean.class) { + return value; + } else if (parameterType == Character.class) { + return value.toString().charAt(0); + } else if (parameterType == Date.class) { + return Convert.toDate(value); + } + return null; + } + + private Object parseNumberType(Class parameterType, Object value) { + if (value instanceof String) { + return Convert.convert(parameterType, value); + } + Number number = (Number) value; + if (parameterType == Integer.class) { + return number.intValue(); + } else if (parameterType == Short.class) { + return number.shortValue(); + } else if (parameterType == Long.class) { + return number.longValue(); + } else if (parameterType == Float.class) { + return number.floatValue(); + } else if (parameterType == Double.class) { + return number.doubleValue(); + } else if (parameterType == Byte.class) { + return number.byteValue(); + } else if (parameterType == BigDecimal.class) { + if (value instanceof Double || value instanceof Float) { + return BigDecimal.valueOf(number.doubleValue()); + } else { + return BigDecimal.valueOf(number.longValue()); + } + } + return null; + } + + private boolean isBasicDataTypes(Class clazz) { + return CLASS_SET.contains(clazz); + } + + private JSONObject getRequestBody(NativeWebRequest webRequest) throws IOException { + HttpServletRequest servletRequest = webRequest.getNativeRequest(HttpServletRequest.class); + Assert.notNull(servletRequest, "servletRequest can't be NULL"); + // 有就直接获取 + JSONObject jsonObject = (JSONObject) webRequest.getAttribute(JSONBODY_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST); + // 没有就从请求中读取 + if (jsonObject == null) { + String jsonBody = IOUtils.toString(servletRequest.getReader()); + jsonObject = JSON.parseObject(jsonBody); + if (jsonObject != null) { + webRequest.setAttribute(JSONBODY_ATTRIBUTE, jsonObject, RequestAttributes.SCOPE_REQUEST); + } + } + return jsonObject; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/listener/LoadServiceRelationListener.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/listener/LoadServiceRelationListener.java new file mode 100644 index 00000000..d2c37fb1 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/listener/LoadServiceRelationListener.java @@ -0,0 +1,28 @@ +package com.orangeforms.common.core.listener; + +import com.orangeforms.common.core.base.service.BaseService; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; + +import java.util.Map; + +/** + * 应用程序启动后的事件监听对象。主要负责加载Model之间的字典关联和一对一关联所对应的Service结构关系。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class LoadServiceRelationListener implements ApplicationListener { + + @SuppressWarnings("all") + @Override + public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { + Map serviceMap = + applicationReadyEvent.getApplicationContext().getBeansOfType(BaseService.class); + for (Map.Entry e : serviceMap.entrySet()) { + e.getValue().loadRelationStruct(); + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/CallResult.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/CallResult.java new file mode 100644 index 00000000..70e09f76 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/CallResult.java @@ -0,0 +1,103 @@ +package com.orangeforms.common.core.object; + +import com.alibaba.fastjson.JSONObject; +import lombok.Data; + +/** + * 业务方法调用结果对象。可以同时返回具体的错误和JSON类型的数据对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class CallResult { + + /** + * 为了优化性能,所有没有携带数据的正确结果,均可用该对象表示。 + */ + private static final CallResult OK = new CallResult(); + /** + * 是否成功标记。 + */ + private boolean success = true; + /** + * 错误信息描述。 + */ + private String errorMessage = null; + /** + * 在验证同时,仍然需要附加的关联数据对象。 + */ + private JSONObject data; + + /** + * 创建验证结果对象。 + * + * @param errorMessage 错误描述信息。 + * @return 如果参数为空,表示成功,否则返回代码错误信息的错误对象实例。 + */ + public static CallResult create(String errorMessage) { + return errorMessage == null ? ok() : error(errorMessage); + } + + /** + * 创建验证结果对象。 + * + * @param errorMessage 错误描述信息。 + * @param data 附带的数据对象。 + * @return 如果参数为空,表示成功,否则返回代码错误信息的错误对象实例。 + */ + public static CallResult create(String errorMessage, JSONObject data) { + return errorMessage == null ? ok(data) : error(errorMessage); + } + + /** + * 创建表示验证成功的对象实例。 + * + * @return 验证成功对象实例。 + */ + public static CallResult ok() { + return OK; + } + + /** + * 创建表示验证成功的对象实例。 + * + * @param data 附带的数据对象。 + * @return 验证成功对象实例。 + */ + public static CallResult ok(JSONObject data) { + CallResult result = new CallResult(); + result.data = data; + return result; + } + + /** + * 创建表示验证失败的对象实例。 + * + * @param errorMessage 错误描述。 + * @return 验证失败对象实例。 + */ + public static CallResult error(String errorMessage) { + CallResult result = new CallResult(); + result.success = false; + result.errorMessage = errorMessage; + return result; + } + + /** + * 创建表示验证失败的对象实例。 + * + * @param errorMessage 错误描述。 + * @param data 附带的数据对象。 + * @return 验证失败对象实例。 + */ + public static CallResult error(String errorMessage, T data) { + CallResult result = new CallResult(); + result.success = false; + result.errorMessage = errorMessage; + JSONObject jsonObject = new JSONObject(); + jsonObject.put("errorData", data); + result.data = jsonObject; + return result; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/ColumnEncodedRule.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/ColumnEncodedRule.java new file mode 100644 index 00000000..c3422da4 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/ColumnEncodedRule.java @@ -0,0 +1,38 @@ +package com.orangeforms.common.core.object; + +import lombok.Data; + +/** + * 编码字段的编码规则。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class ColumnEncodedRule { + + /** + * 是否显示是计算并回显。 + */ + private Boolean calculateWhenView; + + /** + * 前缀。 + */ + private String prefix; + + /** + * 精确到DAYS/HOURS/MINUTES/SECONDS + */ + private String precisionTo; + + /** + * 中缀。 + */ + private String middle; + + /** + * 流水序号的字符宽度,不足的前面补0。 + */ + private Integer idWidth; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/ConstDictInfo.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/ConstDictInfo.java new file mode 100644 index 00000000..e063b9ab --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/ConstDictInfo.java @@ -0,0 +1,24 @@ +package com.orangeforms.common.core.object; + +import lombok.Data; + +import java.util.List; + +/** + * 常量字典的数据结构。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class ConstDictInfo { + + private List dictData; + + @Data + public static class ConstDictData { + private String type; + private Object id; + private String name; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/DummyClass.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/DummyClass.java new file mode 100644 index 00000000..5806fd02 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/DummyClass.java @@ -0,0 +1,27 @@ +package com.orangeforms.common.core.object; + +/** + * 哑元对象,主要用于注解中的缺省对象占位符。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class DummyClass { + + private static final Object EMPTY_OBJECT = new Object(); + + /** + * 可以忽略的空对象。避免sonarqube的各种警告。 + * + * @return 空对象。 + */ + public static Object emptyObject() { + return EMPTY_OBJECT; + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private DummyClass() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/GlobalThreadLocal.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/GlobalThreadLocal.java new file mode 100644 index 00000000..01b0d437 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/GlobalThreadLocal.java @@ -0,0 +1,52 @@ +package com.orangeforms.common.core.object; + +import cn.hutool.core.util.BooleanUtil; + +/** + * 线程本地化数据管理的工具类。可根据需求自行添加更多的线程本地化变量及其操作方法。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class GlobalThreadLocal { + + /** + * 存储数据权限过滤是否启用的线程本地化对象。 + * 目前的过滤条件,包括数据权限和租户过滤。 + */ + private static final ThreadLocal DATA_FILTER_ENABLE = ThreadLocal.withInitial(() -> Boolean.TRUE); + + /** + * 设置数据过滤是否打开。如果打开,当前Servlet线程所执行的SQL操作,均会进行数据过滤。 + * + * @param enable 打开为true,否则false。 + * @return 返回之前的状态,便于恢复。 + */ + public static boolean setDataFilter(boolean enable) { + boolean oldValue = DATA_FILTER_ENABLE.get(); + DATA_FILTER_ENABLE.set(enable); + return oldValue; + } + + /** + * 判断当前Servlet线程所执行的SQL操作,是否进行数据过滤。 + * + * @return true 进行数据权限过滤,否则false。 + */ + public static boolean enabledDataFilter() { + return BooleanUtil.isTrue(DATA_FILTER_ENABLE.get()); + } + + /** + * 清空该存储数据,主动释放线程本地化存储资源。 + */ + public static void clearDataFilter() { + DATA_FILTER_ENABLE.remove(); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private GlobalThreadLocal() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/LoginUserInfo.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/LoginUserInfo.java new file mode 100644 index 00000000..d33a5908 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/LoginUserInfo.java @@ -0,0 +1,62 @@ +package com.orangeforms.common.core.object; + +import lombok.Data; +import lombok.ToString; +import lombok.extern.slf4j.Slf4j; + +import java.util.Date; + +/** + * 在线登录用户信息。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ToString +@Slf4j +public class LoginUserInfo { + + /** + * 用户Id。 + */ + private Long userId; + /** + * 用户所在部门Id。 + * 仅当系统支持uaa时可用,否则可以直接忽略该字段。保留该字段是为了保持单体和微服务通用代码部分的兼容性。 + */ + private Long deptId; + /** + * 租户Id。 + * 仅当系统支持uaa时可用,否则可以直接忽略该字段。保留该字段是为了保持单体和微服务通用代码部分的兼容性。 + */ + private Long tenantId; + /** + * 是否为超级管理员。 + */ + private Boolean isAdmin; + /** + * 用户登录名。 + */ + private String loginName; + /** + * 用户显示名称。 + */ + private String showName; + /** + * 标识不同登录的会话Id。 + */ + private String sessionId; + /** + * 登录IP。 + */ + private String loginIp; + /** + * 登录时间。 + */ + private Date loginTime; + /** + * 登录设备类型。 + */ + private String deviceType; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyGroupCriteria.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyGroupCriteria.java new file mode 100644 index 00000000..02131aa6 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyGroupCriteria.java @@ -0,0 +1,24 @@ +package com.orangeforms.common.core.object; + +import lombok.AllArgsConstructor; +import lombok.Data; + +/** + * Mybatis Mapper.xml中所需的分组条件对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@AllArgsConstructor +public class MyGroupCriteria { + + /** + * GROUP BY 从句后面的参数。 + */ + private String groupBy; + /** + * SELECT 从句后面的分组显示字段。 + */ + private String groupSelect; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyGroupParam.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyGroupParam.java new file mode 100644 index 00000000..81fc69b5 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyGroupParam.java @@ -0,0 +1,231 @@ +package com.orangeforms.common.core.object; + +import cn.hutool.core.util.ReflectUtil; +import cn.hutool.core.util.StrUtil; +import com.orangeforms.common.core.config.CoreProperties; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.exception.InvalidClassFieldException; +import com.orangeforms.common.core.exception.InvalidDataFieldException; +import com.orangeforms.common.core.exception.InvalidDataModelException; +import com.orangeforms.common.core.util.ApplicationContextHolder; +import com.orangeforms.common.core.util.MyModelUtil; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.extern.slf4j.Slf4j; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +/** + * 查询分组参数请求对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EqualsAndHashCode(callSuper = true) +@Slf4j +@Data +public class MyGroupParam extends ArrayList { + + private final transient CoreProperties coreProperties = + ApplicationContextHolder.getBean(CoreProperties.class); + + /** + * SQL语句的SELECT LIST中,分组字段的返回字段名称列表。 + */ + private List selectGroupFieldList; + /** + * 分组参数解析后构建的SQL语句中所需的分组数据,如GROUP BY的字段列表和SELECT LIST中的分组字段显示列表。 + */ + private transient MyGroupCriteria groupCriteria; + /** + * 基于分组参数对象中的数据,构建SQL中select list和group by从句可以直接使用的分组对象。 + * + * @param groupParam 分组参数对象。 + * @param modelClazz 查询表对应的主对象的Class。 + * @return SQL中所需的GROUP对象。详见MyGroupCriteria类定义。 + */ + public static MyGroupParam buildGroupBy(MyGroupParam groupParam, Class modelClazz) { + if (groupParam == null) { + return null; + } + if (modelClazz == null) { + throw new IllegalArgumentException("modelClazz Argument can't be NULL"); + } + groupParam.selectGroupFieldList = new LinkedList<>(); + StringBuilder groupByBuilder = new StringBuilder(128); + StringBuilder groupSelectBuilder = new StringBuilder(128); + int i = 0; + for (GroupInfo groupInfo : groupParam) { + GroupBaseData groupBaseData = groupParam.parseGroupBaseData(groupInfo, modelClazz); + if (StrUtil.isBlank(groupBaseData.tableName)) { + throw new InvalidDataModelException(groupBaseData.modelName); + } + if (StrUtil.isBlank(groupBaseData.columnName)) { + throw new InvalidDataFieldException(groupBaseData.modelName, groupBaseData.fieldName); + } + groupParam.processGroupInfo(groupInfo, groupBaseData, groupByBuilder, groupSelectBuilder); + String aliasName = StrUtil.isBlank(groupInfo.aliasName) ? groupInfo.fieldName : groupInfo.aliasName; + // selectGroupFieldList中的元素,目前只是被export操作使用。会根据集合中的元素名称匹配导出表头。 + groupParam.selectGroupFieldList.add(aliasName); + if (++i < groupParam.size()) { + groupByBuilder.append(", "); + groupSelectBuilder.append(", "); + } + } + groupParam.groupCriteria = new MyGroupCriteria(groupByBuilder.toString(), groupSelectBuilder.toString()); + return groupParam; + } + + private GroupBaseData parseGroupBaseData(GroupInfo groupInfo, Class modelClazz) { + GroupBaseData baseData = new GroupBaseData(); + if (StrUtil.isBlank(groupInfo.fieldName)) { + throw new IllegalArgumentException("GroupInfo.fieldName can't be EMPTY"); + } + String[] stringArray = StrUtil.splitToArray(groupInfo.fieldName, '.'); + if (stringArray.length == 1) { + baseData.modelName = modelClazz.getSimpleName(); + baseData.fieldName = groupInfo.fieldName; + baseData.tableName = MyModelUtil.mapToTableName(modelClazz); + baseData.columnName = MyModelUtil.mapToColumnName(groupInfo.fieldName, modelClazz); + } else { + Field field = ReflectUtil.getField(modelClazz, stringArray[0]); + if (field == null) { + throw new InvalidClassFieldException(modelClazz.getSimpleName(), stringArray[0]); + } + Class fieldClazz = field.getType(); + baseData.modelName = fieldClazz.getSimpleName(); + baseData.fieldName = stringArray[1]; + baseData.tableName = MyModelUtil.mapToTableName(fieldClazz); + baseData.columnName = MyModelUtil.mapToColumnName(baseData.fieldName, fieldClazz); + } + return baseData; + } + + private void processGroupInfo( + GroupInfo groupInfo, GroupBaseData baseData, StringBuilder groupBy, StringBuilder groupSelect) { + String tableName = baseData.tableName; + String columnName = baseData.columnName; + if (StrUtil.isBlank(groupInfo.dateAggregateBy)) { + groupBy.append(tableName).append(".").append(columnName); + groupSelect.append(tableName).append(".").append(columnName); + if (StrUtil.isNotBlank(groupInfo.aliasName)) { + groupSelect.append(" ").append(groupInfo.aliasName); + } + return; + } + if (coreProperties.isMySql() || coreProperties.isDm()) { + this.processMySqlGroupInfoWithDateAggregation(groupInfo, baseData, groupBy, groupSelect); + } else if (coreProperties.isPostgresql() || coreProperties.isOpenGauss()) { + this.processPostgreSqlGroupInfoWithDateAggregation(groupInfo, baseData, groupBy, groupSelect); + } else if (coreProperties.isOracle() || coreProperties.isKingbase()) { + this.processOracleGroupInfoWithDateAggregation(groupInfo, baseData, groupBy, groupSelect); + } else { + throw new UnsupportedOperationException("Unsupport Database Type."); + } + if (StrUtil.isNotBlank(groupInfo.aliasName)) { + groupSelect.append(" ").append(groupInfo.aliasName); + } else { + groupSelect.append(" ").append(columnName); + } + } + + private void processMySqlGroupInfoWithDateAggregation( + GroupInfo groupInfo, GroupBaseData baseData, StringBuilder groupBy, StringBuilder groupSelect) { + groupBy.append("DATE_FORMAT(") + .append(baseData.tableName).append(".").append(baseData.columnName); + groupSelect.append("DATE_FORMAT(") + .append(baseData.tableName).append(".").append(baseData.columnName); + if (ApplicationConstant.DAY_AGGREGATION.equals(groupInfo.dateAggregateBy)) { + groupBy.append(", '%Y-%m-%d')"); + groupSelect.append(", '%Y-%m-%d')"); + } else if (ApplicationConstant.MONTH_AGGREGATION.equals(groupInfo.dateAggregateBy)) { + groupBy.append(", '%Y-%m-01')"); + groupSelect.append(", '%Y-%m-01')"); + } else if (ApplicationConstant.YEAR_AGGREGATION.equals(groupInfo.dateAggregateBy)) { + groupBy.append(", '%Y-01-01')"); + groupSelect.append(", '%Y-01-01')"); + } else { + throw new IllegalArgumentException("Illegal DATE_FORMAT for GROUP ID list."); + } + } + + private void processPostgreSqlGroupInfoWithDateAggregation( + GroupInfo groupInfo, GroupBaseData baseData, StringBuilder groupBy, StringBuilder groupSelect) { + String toCharFunc = "TO_CHAR("; + String dateFormat = ", 'YYYY-MM-dd')"; + groupBy.append(toCharFunc) + .append(baseData.tableName).append(".").append(baseData.columnName); + groupSelect.append(toCharFunc) + .append(baseData.tableName).append(".").append(baseData.columnName); + if (ApplicationConstant.DAY_AGGREGATION.equals(groupInfo.dateAggregateBy)) { + groupBy.append(dateFormat); + groupSelect.append(dateFormat); + } else if (ApplicationConstant.YEAR_AGGREGATION.equals(groupInfo.dateAggregateBy)) { + groupBy.append(", 'YYYY-01-01')"); + groupSelect.append(", 'YYYY-01-01')"); + } else if (ApplicationConstant.MONTH_AGGREGATION.equals(groupInfo.dateAggregateBy)) { + groupBy.append(", 'YYYY-MM-01')"); + groupSelect.append(", 'YYYY-MM-01')"); + } else { + throw new IllegalArgumentException("Illegal TO_CHAR for GROUP ID list."); + } + } + + private void processOracleGroupInfoWithDateAggregation( + GroupInfo groupInfo, GroupBaseData baseData, StringBuilder groupBy, StringBuilder groupSelect) { + String toCharFunc = "TO_CHAR("; + String dateFormat = ", 'YYYY-MM-dd')"; + groupBy.append(toCharFunc) + .append(baseData.tableName).append(".").append(baseData.columnName); + groupSelect.append(toCharFunc) + .append(baseData.tableName).append(".").append(baseData.columnName); + if (ApplicationConstant.DAY_AGGREGATION.equals(groupInfo.dateAggregateBy)) { + groupBy.append(dateFormat); + groupSelect.append(dateFormat); + } else if (ApplicationConstant.MONTH_AGGREGATION.equals(groupInfo.dateAggregateBy)) { + groupBy.append(", 'YYYY-MM') || '-01'"); + groupSelect.append(", 'YYYY-MM') || '-01'"); + } else if (ApplicationConstant.YEAR_AGGREGATION.equals(groupInfo.dateAggregateBy)) { + groupBy.append(", 'YYYY') || '-01-01'"); + groupSelect.append(", 'YYYY') || '-01-01'"); + } else { + throw new IllegalArgumentException("Illegal TO_CHAR for GROUP ID list."); + } + } + + /** + * 分组信息对象。 + */ + @Data + public static class GroupInfo { + /** + * Java对象的字段名。目前主要包含三种格式: + * 1. 简单的属性名称,如userId,将会直接映射到与其关联的数据库字段。表名为当前ModelClazz所对应的表名。 + * 映射结果或为 my_main_table.user_id + * 2. 一对一关联表属性,如user.userId,这里将先获取user属性的对象类型并映射到对应的表名,后面的userId为 + * user所在实体的属性。映射结果或为:my_sys_user.user_id + */ + private String fieldName; + /** + * SQL语句的Select List中,分组字段的别名。如果别名为NULL,直接取fieldName。 + */ + private String aliasName; + /** + * 如果该值不为NULL,则会对分组字段进行DATE_FORMAT函数的计算,并根据具体的值,将日期数据截取到指定的位。 + * day: 表示按照天聚合,将会截取到天。DATE_FORMAT(columnName, '%Y-%m-%d') + * month: 表示按照月聚合,将会截取到月。DATE_FORMAT(columnName, '%Y-%m-01') + * year: 表示按照年聚合,将会截取到年。DATE_FORMAT(columnName, '%Y-01-01') + */ + private String dateAggregateBy; + } + + private static class GroupBaseData { + private String modelName; + private String fieldName; + private String tableName; + private String columnName; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyOrderParam.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyOrderParam.java new file mode 100644 index 00000000..4ae6fb3e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyOrderParam.java @@ -0,0 +1,303 @@ +package com.orangeforms.common.core.object; + +import cn.hutool.core.util.ReflectUtil; +import com.mybatisflex.annotation.Id; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.exception.InvalidClassFieldException; +import com.orangeforms.common.core.exception.InvalidDataFieldException; +import com.orangeforms.common.core.exception.InvalidDataModelException; +import com.orangeforms.common.core.util.MyModelUtil; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import java.lang.reflect.Field; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; + +/** + * Controller参数中的排序请求对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EqualsAndHashCode(callSuper = true) +@Slf4j +@Data +public class MyOrderParam extends ArrayList { + + private static final String DICT_MAP = "DictMap."; + private static final Map, MyOrderParam> DEFAULT_ORDER_PARAM_MAP = new ConcurrentHashMap<>(); + + /** + * 基于排序对象中的JSON数据,构建SQL中order by从句可以直接使用的排序字符串。 + * 注意:如果orderParam为NULL,则会通过modelClazz对象推演出主键字典名,并按照主键倒排的方式生成默认的排序对象。 + * + * @param orderParam 排序参数对象。 + * @param modelClazz 查询主表对应的主对象的Class。 + * @return SQL中order by从句可以直接使用的排序字符串。 + */ + public static String buildOrderBy(MyOrderParam orderParam, Class modelClazz) { + return buildOrderBy(orderParam, modelClazz, true); + } + + /** + * 基于排序对象中的JSON数据,构建SQL中order by从句可以直接使用的排序字符串。 + * 注意:如果orderParam为NULL,则会通过modelClazz对象推演出主键字典名,并按照主键倒排的方式生成默认的排序对象。 + * + * @param orderParam 排序参数对象。 + * @param modelClazz 查询主表对应的主对象的Class。 + * @param addDefaultIfNull 如果为true,当orderParam参数为NULL是,则自动添加基于主键倒排序的索引。 + * @return SQL中order by从句可以直接使用的排序字符串。 + */ + public static String buildOrderBy(MyOrderParam orderParam, Class modelClazz, boolean addDefaultIfNull) { + if (orderParam == null) { + if (!addDefaultIfNull) { + return null; + } + orderParam = getAndSetDefaultOrderParam(modelClazz); + } + if (modelClazz == null) { + throw new IllegalArgumentException( + "modelClazz Argument in MyOrderParam.buildOrderBy can't be NULL"); + } + int i = 0; + StringBuilder orderBy = new StringBuilder(128); + for (OrderInfo orderInfo : orderParam) { + if (StringUtils.isBlank(orderInfo.getFieldName())) { + continue; + } + OrderBaseData orderBaseData = parseOrderBaseData(orderInfo, modelClazz); + if (StringUtils.isBlank(orderBaseData.tableName)) { + throw new InvalidDataModelException(orderBaseData.modelName); + } + if (StringUtils.isBlank(orderBaseData.columnName)) { + throw new InvalidDataFieldException(orderBaseData.modelName, orderBaseData.fieldName); + } + processOrderInfo(orderInfo, orderBaseData, orderBy); + if (++i < orderParam.size()) { + orderBy.append(", "); + } + } + return orderBy.toString(); + } + + private static MyOrderParam getAndSetDefaultOrderParam(Class modelClazz) { + MyOrderParam orderParam = DEFAULT_ORDER_PARAM_MAP.get(modelClazz); + if (orderParam != null) { + return orderParam; + } + orderParam = new MyOrderParam(); + DEFAULT_ORDER_PARAM_MAP.put(modelClazz, orderParam); + Field[] fields = ReflectUtil.getFields(modelClazz); + for (Field field : fields) { + if (field.getAnnotation(Id.class) != null) { + orderParam.add(new OrderInfo(field.getName(), false, null)); + break; + } + } + return orderParam; + } + + private static void processOrderInfo( + OrderInfo orderInfo, OrderBaseData orderBaseData, StringBuilder orderByBuilder) { + if (StringUtils.isNotBlank(orderInfo.dateAggregateBy)) { + orderByBuilder.append("DATE_FORMAT(") + .append(orderBaseData.tableName).append(".").append(orderBaseData.columnName); + if (ApplicationConstant.DAY_AGGREGATION.equals(orderInfo.dateAggregateBy)) { + orderByBuilder.append(", '%Y-%m-%d')"); + } else if (ApplicationConstant.MONTH_AGGREGATION.equals(orderInfo.dateAggregateBy)) { + orderByBuilder.append(", '%Y-%m-01')"); + } else if (ApplicationConstant.YEAR_AGGREGATION.equals(orderInfo.dateAggregateBy)) { + orderByBuilder.append(", '%Y-01-01')"); + } else { + throw new IllegalArgumentException("Illegal DATE_FORMAT for GROUP ID list."); + } + } else { + orderByBuilder.append(orderBaseData.tableName).append(".").append(orderBaseData.columnName); + } + if (orderInfo.asc != null && !orderInfo.asc) { + orderByBuilder.append(" DESC"); + } + } + + private static OrderBaseData parseOrderBaseData(OrderInfo orderInfo, Class modelClazz) { + OrderBaseData orderBaseData = new OrderBaseData(); + orderBaseData.fieldName = StringUtils.substringBefore(orderInfo.fieldName, DICT_MAP); + String[] stringArray = StringUtils.split(orderBaseData.fieldName, '.'); + if (stringArray.length == 1) { + orderBaseData.modelName = modelClazz.getSimpleName(); + orderBaseData.tableName = MyModelUtil.mapToTableName(modelClazz); + orderBaseData.columnName = MyModelUtil.mapToColumnName(orderBaseData.fieldName, modelClazz); + } else { + Field field = ReflectUtil.getField(modelClazz, stringArray[0]); + if (field == null) { + throw new InvalidClassFieldException(modelClazz.getSimpleName(), stringArray[0]); + } + Class fieldClazz = field.getType(); + orderBaseData.modelName = fieldClazz.getSimpleName(); + orderBaseData.fieldName = stringArray[1]; + orderBaseData.tableName = MyModelUtil.mapToTableName(fieldClazz); + orderBaseData.columnName = MyModelUtil.mapToColumnName(orderBaseData.fieldName, fieldClazz); + } + return orderBaseData; + } + + /** + * 在排序列表中,可能存在基于指定表字段的排序,该函数将获取指定表的所有排序字段。 + * 返回的字符串,可直接用于SQL中的ORDER BY从句。 + * + * @param orderParam 排序参数对象。 + * @param modelClazz 查询主表对应的主对象的Class。 + * @param relationModelName 与关联表对应的Model的名称,如my_course_paper表应对的Java对象CoursePaper。 + * 如果该值为null或空字符串,则获取所有主表的排序字段。 + * @return 返回的是表字段,而非Java对象的属性,多个字段之间逗号分隔。 + */ + public static String getOrderClauseByModelName( + MyOrderParam orderParam, Class modelClazz, String relationModelName) { + if (orderParam == null) { + return null; + } + if (modelClazz == null) { + throw new IllegalArgumentException( + "modelClazz Argument in MyOrderParam.getOrderClauseByModelName can't be NULL"); + } + List fieldNameList = new LinkedList<>(); + String prefix = null; + if (StringUtils.isNotBlank(relationModelName)) { + prefix = relationModelName + "."; + } + for (OrderInfo orderInfo : orderParam) { + OrderBaseData baseData = parseOrderBaseData(orderInfo, modelClazz, prefix, relationModelName); + if (baseData != null) { + fieldNameList.add(makeOrderBy(baseData, orderInfo.asc)); + } + } + return StringUtils.join(fieldNameList, ", "); + } + + private static OrderBaseData parseOrderBaseData( + OrderInfo orderInfo, Class modelClazz, String prefix, String relationModelName) { + OrderBaseData baseData = null; + String fieldName = StringUtils.substringBefore(orderInfo.fieldName, DICT_MAP); + if (prefix != null) { + if (fieldName.startsWith(prefix)) { + baseData = new OrderBaseData(); + Field field = ReflectUtil.getField(modelClazz, relationModelName); + if (field == null) { + throw new InvalidClassFieldException(modelClazz.getSimpleName(), relationModelName); + } + Class fieldClazz = field.getType(); + baseData.modelName = fieldClazz.getSimpleName(); + baseData.fieldName = StringUtils.removeStart(fieldName, prefix); + baseData.tableName = MyModelUtil.mapToTableName(fieldClazz); + baseData.columnName = MyModelUtil.mapToColumnName(fieldName, fieldClazz); + } + } else { + String dotLimitor = "."; + if (!fieldName.contains(dotLimitor)) { + baseData = new OrderBaseData(); + baseData.modelName = modelClazz.getSimpleName(); + baseData.tableName = MyModelUtil.mapToTableName(modelClazz); + baseData.columnName = MyModelUtil.mapToColumnName(fieldName, modelClazz); + } + } + return baseData; + } + + private static String makeOrderBy(OrderBaseData baseData, Boolean asc) { + if (StringUtils.isBlank(baseData.tableName)) { + throw new InvalidDataModelException(baseData.modelName); + } + if (StringUtils.isBlank(baseData.columnName)) { + throw new InvalidDataFieldException(baseData.modelName, baseData.fieldName); + } + StringBuilder orderBy = new StringBuilder(128); + orderBy.append(baseData.tableName).append(".").append(baseData.columnName); + if (asc != null && !asc) { + orderBy.append(" DESC"); + } + return orderBy.toString(); + } + + /** + * 在排序列表中,可能存在基于指定表字段的排序,该函数将删除指定表的所有排序字段。 + * + * @param orderParam 排序参数对象。 + * @param modelClazz 查询主表对应的主对象的Class。 + * @param relationModelName 与关联表对应的Model的名称,如my_course_paper表应对的Java对象CoursePaper。 + * 如果该值为null或空字符串,则获取所有主表的排序字段。 + */ + public static void removeOrderClauseByModelName( + MyOrderParam orderParam, Class modelClazz, String relationModelName) { + if (orderParam == null) { + return; + } + if (modelClazz == null) { + throw new IllegalArgumentException( + "modelClazz Argument in MyOrderParam.removeOrderClauseByModelName can't be NULL"); + } + List fieldIndexList = new LinkedList<>(); + String prefix = null; + if (StringUtils.isNotBlank(relationModelName)) { + prefix = relationModelName + "."; + } + int i = 0; + for (OrderInfo orderInfo : orderParam) { + String fieldName = StringUtils.substringBefore(orderInfo.fieldName, DICT_MAP); + if (prefix != null) { + if (fieldName.startsWith(prefix)) { + fieldIndexList.add(i); + } + } else { + if (!fieldName.contains(".")) { + fieldIndexList.add(i); + } + } + ++i; + } + for (int index : fieldIndexList) { + orderParam.remove(index); + } + } + + /** + * 排序信息对象。 + */ + @AllArgsConstructor + @NoArgsConstructor + @Data + public static class OrderInfo { + /** + * Java对象的字段名。如果fieldName为空,则忽略跳过。目前主要包含三种格式: + * 1. 简单的属性名称,如userId,将会直接映射到与其关联的数据库字段。表名为当前ModelClazz所对应的表名。 + * 映射结果或为 my_main_table.user_id + * 2. 字典属性名称,如userIdDictMap.id,由于仅仅支持字典中Id数据的排序,所以直接截取DictMap之前的字符串userId作为排序属性。 + * 表名为当前ModelClazz所对应的表名。映射结果或为 my_main_table.user_id + * 3. 一对一关联表属性,如user.userId,这里将先获取user属性的对象类型并映射到对应的表名,后面的userId为 + * user所在实体的属性。映射结果或为:my_sys_user.user_id + */ + private String fieldName; + /** + * 排序方向。true为升序,否则降序。 + */ + private Boolean asc = true; + /** + * 如果该值不为NULL,则会对日期型排序字段进行DATE_FORMAT函数的计算,并根据具体的值,将日期数据截取到指定的位。 + * day: 表示按照天聚合,将会截取到天。DATE_FORMAT(columnName, '%Y-%m-%d') + * month: 表示按照月聚合,将会截取到月。DATE_FORMAT(columnName, '%Y-%m-01') + * year: 表示按照年聚合,将会截取到年。DATE_FORMAT(columnName, '%Y-01-01') + */ + private String dateAggregateBy; + } + + private static class OrderBaseData { + private String modelName; + private String fieldName; + private String tableName; + private String columnName; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyPageData.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyPageData.java new file mode 100644 index 00000000..57bb1c8f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyPageData.java @@ -0,0 +1,36 @@ +package com.orangeforms.common.core.object; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.LinkedList; +import java.util.List; + +/** + * 分页数据的应答返回对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class MyPageData { + /** + * 数据列表。 + */ + private List dataList; + /** + * 数据总数量。 + */ + private Long totalCount; + + /** + * 为了保持前端的数据格式兼容性,在没有数据的时候,需要返回空分页对象。 + * @return 空分页对象。 + */ + public static MyPageData emptyPageData() { + return new MyPageData<>(new LinkedList<>(), 0L); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyPageParam.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyPageParam.java new file mode 100644 index 00000000..cd4ddc41 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyPageParam.java @@ -0,0 +1,69 @@ +package com.orangeforms.common.core.object; + +import lombok.Getter; + +/** + * Controller参数中的分页请求对象 + * + * @author Jerry + * @date 2024-07-02 + */ +@Getter +public class MyPageParam { + + public static final int DEFAULT_PAGE_NUM = 1; + public static final int DEFAULT_PAGE_SIZE = 10; + public static final int DEFAULT_MAX_SIZE = 2000; + + /** + * 分页号码,从1开始计数。 + */ + private Integer pageNum; + + /** + * 每页大小。 + */ + private Integer pageSize; + + /** + * 是否统计totalCount + */ + private Boolean count = true; + + /** + * 设置当前分页页号。 + * + * @param pageNum 页号,如果传入非法值,则使用缺省值。 + */ + public void setPageNum(Integer pageNum) { + if (pageNum == null) { + return; + } + if (pageNum <= 0) { + pageNum = DEFAULT_PAGE_NUM; + } + this.pageNum = pageNum; + } + + /** + * 设置分页的大小。 + * + * @param pageSize 分页大小,如果传入非法值,则使用缺省值。 + */ + public void setPageSize(Integer pageSize) { + if (pageSize == null) { + return; + } + if (pageSize <= 0) { + pageSize = DEFAULT_PAGE_SIZE; + } + if (pageSize > DEFAULT_MAX_SIZE) { + pageSize = DEFAULT_MAX_SIZE; + } + this.pageSize = pageSize; + } + + public void setCount(Boolean count) { + this.count = count; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyPrintInfo.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyPrintInfo.java new file mode 100644 index 00000000..6a5a60d9 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyPrintInfo.java @@ -0,0 +1,32 @@ +package com.orangeforms.common.core.object; + +import com.alibaba.fastjson.JSONArray; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 打印信息对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@NoArgsConstructor +public class MyPrintInfo { + + /** + * 打印模板Id。 + */ + private Long printId; + /** + * 打印参数列表。对应于common-report模块的ReportPrintParam对象。 + */ + private List printParams; + + public MyPrintInfo(Long printId, List printParams) { + this.printId = printId; + this.printParams = printParams; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyRelationParam.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyRelationParam.java new file mode 100644 index 00000000..26f23c15 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyRelationParam.java @@ -0,0 +1,122 @@ +package com.orangeforms.common.core.object; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.StrUtil; +import lombok.Builder; +import lombok.Data; +import lombok.Getter; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * 实体对象数据组装参数构建器。 + * BaseService中的实体对象数据组装函数,会根据该参数对象进行数据组装。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Builder +public class MyRelationParam { + + /** + * 是否组装字典关联的标记。 + * 组装RelationDict和RelationConstDict注解标记的字段。 + */ + private boolean buildDict; + + /** + * 是否组装一对一关联的标记。 + * 组装RelationOneToOne注解标记的字段。 + */ + private boolean buildOneToOne; + + /** + * 是否组装一对多关联的标记。 + * 组装RelationOneToMany注解标记的字段。 + */ + private boolean buildOneToMany; + + /** + * 在组装一对一关联的同时,是否继续关联从表中的字典。 + * 从表中RelationDict和RelationConstDict注解标记的字段。 + * 该字段为true时,无需设置buildOneToOne了。 + */ + private boolean buildOneToOneWithDict; + + /** + * 是否组装主表对多对多中间表关联的标记。 + * 组装RelationManyToMany注解标记的字段。 + */ + private boolean buildRelationManyToMany; + + /** + * 是否组装聚合计算关联的标记。 + * 组装RelationOneToManyAggregation和RelationManyToManyAggregation注解标记的字段。 + */ + private boolean buildRelationAggregation; + + /** + * 关联表中,需要忽略的脱敏字段名。key是关联表实体对象名,如SysUser,value是对象字段名的集合,如userId。 + */ + @Getter + private Map> ignoreMaskFieldMap; + + /** + * 关联表中需要忽略的脱敏字段结合。 + * @param ignoreRelationMaskFieldSet 数据项格式为"实体对象名.对象属性名",如 sysUser.userId。 + */ + public void setIgnoreMaskFieldSet(Set ignoreRelationMaskFieldSet) { + if (CollUtil.isEmpty(ignoreRelationMaskFieldSet)) { + return; + } + ignoreMaskFieldMap = MapUtil.newHashMap(); + for (String ignoreField : ignoreRelationMaskFieldSet) { + String[] fullFieldName = StrUtil.splitToArray(ignoreField, "."); + Set ignoreMaskFieldSet = + ignoreMaskFieldMap.computeIfAbsent(fullFieldName[0], k -> new HashSet<>()); + ignoreMaskFieldSet.add(fullFieldName[1]); + } + } + + /** + * 便捷方法,返回仅做字典关联的参数对象。 + * + * @return 返回仅做字典关联的参数对象。 + */ + public static MyRelationParam dictOnly() { + return MyRelationParam.builder().buildDict(true).build(); + } + + /** + * 便捷方法,返回仅做字典关联、一对一从表及其字典和聚合计算的参数对象。 + * NOTE: 对于一对多和多对多,这种从表数据是列表结果的关联,均不返回。 + * + * @return 返回仅做字典关联、一对一从表及其字典和聚合计算的参数对象。 + */ + public static MyRelationParam normal() { + return MyRelationParam.builder() + .buildDict(true) + .buildOneToOneWithDict(true) + .buildRelationAggregation(true) + .build(); + } + + /** + * 便捷方法,返回全部关联的参数对象。 + * + * @return 返回全部关联的参数对象。 + */ + public static MyRelationParam full() { + return MyRelationParam.builder() + .buildDict(true) + .buildOneToOneWithDict(true) + .buildRelationAggregation(true) + .buildRelationManyToMany(true) + .buildOneToMany(true) + .build(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyWhereCriteria.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyWhereCriteria.java new file mode 100644 index 00000000..d225446c --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/MyWhereCriteria.java @@ -0,0 +1,376 @@ +package com.orangeforms.common.core.object; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ReflectUtil; +import com.alibaba.fastjson.annotation.JSONField; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.exception.InvalidDataFieldException; +import com.orangeforms.common.core.exception.InvalidDataModelException; +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.core.util.MyModelUtil; +import lombok.*; +import lombok.extern.slf4j.Slf4j; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.regex.Matcher; + +/** + * Where中的条件语句。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Data +@NoArgsConstructor +public class MyWhereCriteria { + + /** + * 等于 + */ + public static final int OPERATOR_EQUAL = 0; + + /** + * 不等于 + */ + public static final int OPERATOR_NOT_EQUAL = 1; + + /** + * 大于等于 + */ + public static final int OPERATOR_GE = 2; + + /** + * 大于 + */ + public static final int OPERATOR_GT = 3; + + /** + * 小于等于 + */ + public static final int OPERATOR_LE = 4; + + /** + * 小于 + */ + public static final int OPERATOR_LT = 5; + + /** + * LIKE + */ + public static final int OPERATOR_LIKE = 6; + + /** + * NOT NULL + */ + public static final int OPERATOR_NOT_NULL = 7; + + /** + * IS NULL + */ + public static final int OPERATOR_IS_NULL = 8; + + /** + * IN + */ + public static final int OPERATOR_IN = 9; + + /** + * 参与过滤的实体对象的Class。 + */ + @JSONField(serialize = false) + private Class modelClazz; + + /** + * 数据库表名。 + */ + private String tableName; + + /** + * Java属性名称。 + */ + private String fieldName; + + /** + * 数据表字段名。 + */ + private String columnName; + + /** + * 数据表字段类型。 + */ + private Integer columnType; + + /** + * 操作符类型,取值范围见上面的常量值。 + */ + private Integer operatorType; + + /** + * 条件数据值。 + */ + private Object value; + + public MyWhereCriteria(Class modelClazz, String fieldName, Integer operatorType, Object value) { + this.modelClazz = modelClazz; + this.fieldName = fieldName; + this.operatorType = operatorType; + this.value = value; + } + + /** + * 设置条件值。 + * + * @param fieldName 条件所属的实体对象的字段名。 + * @param operatorType 条件操作符。具体值可参考当前对象的静态变量。 + * @param value 条件过滤值。 + * @return 验证结果对象,如果有错误将会返回具体的错误信息。 + */ + public CallResult setCriteria(String fieldName, Integer operatorType, Object value) { + this.operatorType = operatorType; + this.fieldName = fieldName; + this.value = value; + return doVerify(); + } + + /** + * 设置条件值。 + * + * @param modelClazz 数据表对应实体对象的Class. + * @param fieldName 条件所属的实体对象的字段名。 + * @param operatorType 条件操作符。具体值可参考当前对象的静态变量。 + * @param value 条件过滤值。 + * @return 验证结果对象,如果有错误将会返回具体的错误信息。 + */ + public CallResult setCriteria(Class modelClazz, String fieldName, Integer operatorType, Object value) { + this.modelClazz = modelClazz; + this.operatorType = operatorType; + this.fieldName = fieldName; + this.value = value; + return doVerify(); + } + + /** + * 设置条件值,通过该构造方法设置时,通常是直接将表名、字段名、字段类型等赋值,无需在通过modelClazz进行推演。 + * + * @param tableName 数据表名。 + * @param columnName 数据字段名。 + * @param columnType 数据字段类型。 + * @param operatorType 操作类型。具体值可参考当前对象的静态变量。 + * @param value 条件过滤值。 + */ + public void setCriteria( + String tableName, String columnName, String columnType, Integer operatorType, Object value) { + this.tableName = tableName; + this.columnName = columnName; + this.columnType = MyModelUtil.NUMERIC_FIELD_TYPE; + if (String.class.getSimpleName().equals(columnType)) { + this.columnType = MyModelUtil.STRING_FIELD_TYPE; + } else if (Date.class.getSimpleName().equals(columnType)) { + this.columnType = MyModelUtil.DATE_FIELD_TYPE; + } + this.operatorType = operatorType; + this.value = value; + } + + /** + * 在执行该函数之前,该对象的所有数据均已经赋值完毕。 + * 该函数主要验证操作符字段和条件值字段对应关系的合法性。 + * + * @return 验证结果对象,如果有错误将会返回具体的错误信息。 + */ + public CallResult doVerify() { + if (fieldName == null) { + return CallResult.error("过滤字段名称 [fieldName] 不能为空!"); + } + if (modelClazz != null && ReflectUtil.getField(modelClazz, fieldName) == null) { + return CallResult.error( + "过滤字段 [" + fieldName + "] 在实体对象 [" + modelClazz.getSimpleName() + "] 中并不存在!"); + } + if (!checkOperatorType()) { + return CallResult.error("无效的操作符类型 [" + operatorType + "]!"); + } + // 其他操作符必须包含value值 + if (operatorType != OPERATOR_IS_NULL && operatorType != OPERATOR_NOT_NULL && value == null) { + String operatorString = this.getOperatorString(); + return CallResult.error("操作符 [" + operatorString + "] 的条件值不能为空!"); + } + if (this.operatorType == OPERATOR_IN) { + if (!(value instanceof Collection)) { + return CallResult.error("操作符 [IN] 的条件值必须为集合对象!"); + } + if (CollUtil.isEmpty((Collection) value)) { + return CallResult.error("操作符 [IN] 的条件值不能为空!"); + } + } + return CallResult.ok(); + } + + /** + * 判断操作符类型是否合法。 + * + * @return 合法返回true,否则false。 + */ + public boolean checkOperatorType() { + return operatorType != null + && (operatorType >= OPERATOR_EQUAL && operatorType <= OPERATOR_IN); + } + + /** + * 获取操作符的字符串形式。 + * + * @return 操作符的字符串。 + */ + public String getOperatorString() { + switch (operatorType) { + case OPERATOR_EQUAL: + return " = "; + case OPERATOR_NOT_EQUAL: + return " != "; + case OPERATOR_GE: + return " >= "; + case OPERATOR_GT: + return " > "; + case OPERATOR_LE: + return " <= "; + case OPERATOR_LT: + return " < "; + case OPERATOR_LIKE: + return " LIKE "; + case OPERATOR_NOT_NULL: + return " IS NOT NULL "; + case OPERATOR_IS_NULL: + return " IS NULL "; + case OPERATOR_IN: + return " IN "; + default: + return null; + } + } + + /** + * 获取组装后的SQL Where从句,如 table_name.column_name = 'value'。 + * 与查询数据表对应的实体对象Class为当前对象的modelClazz字段。 + * + * @exception InvalidDataFieldException selectFieldList中存在非法实体字段时,抛出该异常。 + * @return 组装后的SQL条件从句。 + */ + public String makeCriteriaString() { + return makeCriteriaString(this.modelClazz); + } + + /** + * 获取组装后的SQL Where从句,如 table_name.column_name = 'value'。 + * + * @param modelClazz 与查询数据表对应的实体对象的Class。 + * @exception InvalidDataFieldException selectFieldList中存在非法实体字段时,抛出该异常。 + * @exception InvalidDataModelException 参数modelClazz没有对应的table,抛出该异常。 + * @return 组装后的SQL条件从句。 + */ + public String makeCriteriaString(Class modelClazz) { + String localTableName; + String localColumnName; + Integer localColumnType; + if (modelClazz != null) { + Tuple2 fieldInfo = MyModelUtil.mapToColumnInfo(fieldName, modelClazz); + if (fieldInfo == null) { + throw new InvalidDataFieldException(modelClazz.getSimpleName(), fieldName); + } + localColumnName = fieldInfo.getFirst(); + localColumnType = fieldInfo.getSecond(); + localTableName = MyModelUtil.mapToTableName(modelClazz); + if (localTableName == null) { + throw new InvalidDataModelException(modelClazz.getSimpleName()); + } + } else { + localTableName = this.tableName; + localColumnName = this.columnName; + localColumnType = this.columnType; + } + return this.buildClauseString(localTableName, localColumnName, localColumnType); + } + + /** + * 获取组装后的SQL Where从句。如 table_name.column_name = 'value'。 + * + * @param criteriaList 条件列表,所有条件直接目前仅支持 AND 的关系。 + * @exception InvalidDataFieldException selectFieldList中存在非法实体字段时,抛出该异常。 + * @return 组装后的SQL条件从句。 + */ + public static String makeCriteriaString(List criteriaList) { + return makeCriteriaString(criteriaList, null); + } + + /** + * 获取组装后的SQL Where从句。如 table_name.column_name = 'value'。 + * + * @param criteriaList 条件列表,所有条件直接目前仅支持 AND 的关系。 + * @param modelClazz 与数据表对应的实体对象的Class。 + * 如果不为NULL实体对象Class使用该值,否则使用每个MyWhereCriteria自身的modelClazz。 + * @exception InvalidDataFieldException selectFieldList中存在非法实体字段时,抛出该异常。 + * @return 组装后的SQL条件从句。 + */ + public static String makeCriteriaString(List criteriaList, Class modelClazz) { + if (CollUtil.isEmpty(criteriaList)) { + return null; + } + StringBuilder sb = new StringBuilder(256); + int i = 0; + for (MyWhereCriteria whereCriteria : criteriaList) { + Class clazz = modelClazz; + if (clazz == null) { + clazz = whereCriteria.modelClazz; + } + if (i++ != 0) { + sb.append(" AND "); + } + String criteriaString = whereCriteria.makeCriteriaString(clazz); + sb.append(criteriaString); + } + return sb.length() == 0 ? null : sb.toString(); + } + + private String buildClauseString(String tableName, String columnName, Integer columnType) { + StringBuilder sb = new StringBuilder(64); + sb.append(tableName).append(".").append(columnName).append(getOperatorString()); + if (operatorType == OPERATOR_IN) { + Collection filterValues = (Collection) value; + sb.append("("); + int i = 0; + for (Object filterValue : filterValues) { + this.doSqlInjectVerify(filterValue.toString()); + if (columnType.equals(MyModelUtil.NUMERIC_FIELD_TYPE)) { + sb.append(filterValue); + } else { + sb.append("'").append(filterValue).append("'"); + } + if (i++ != filterValues.size() - 1) { + sb.append(", "); + } + } + sb.append(")"); + return sb.toString(); + } + if (value == null) { + return sb.toString(); + } + this.doSqlInjectVerify(value.toString()); + if (columnType.equals(MyModelUtil.NUMERIC_FIELD_TYPE)) { + sb.append(value); + } else { + sb.append("'").append(value).append("'"); + } + return sb.toString(); + } + + private void doSqlInjectVerify(String v) { + Matcher matcher = ApplicationConstant.SQL_INJECT_PATTERN.matcher(v); + if (matcher.find()) { + String msg = String.format( + "The filterValue [%s] has SQL Inject Words", v); + throw new MyRuntimeException(msg); + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/ResponseResult.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/ResponseResult.java new file mode 100644 index 00000000..26e2eee5 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/ResponseResult.java @@ -0,0 +1,295 @@ +package com.orangeforms.common.core.object; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.annotation.JSONField; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.util.ContextUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; + +import jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; + +/** + * 接口返回对象 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Data +public class ResponseResult { + + /** + * 为了优化性能,所有没有携带数据的正确结果,均可用该对象表示。 + */ + private static final ResponseResult OK = new ResponseResult<>(); + /** + * 是否成功标记。 + */ + private boolean success = true; + /** + * 错误码。 + */ + private String errorCode = "NO-ERROR"; + /** + * 错误信息描述。 + */ + private String errorMessage = "NO-MESSAGE"; + /** + * 实际数据。 + */ + private T data = null; + /** + * HTTP状态码,通常用于内部调用的方法传递,不推荐返回给前端。 + */ + @JSONField(serialize = false) + private int httpStatus = 200; + + /** + * 根据参数errorCodeEnum的枚举值,判断创建成功对象还是错误对象。 + * 如果返回错误对象,errorCode 和 errorMessage 分别取自于参数 errorCodeEnum 的 name() 和 getErrorMessage()。 + * + * @param errorCodeEnum 错误码枚举。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult create(ErrorCodeEnum errorCodeEnum) { + return create(errorCodeEnum, errorCodeEnum.getErrorMessage()); + } + + /** + * 根据参数errorCodeEnum的枚举值,判断创建成功对象还是错误对象。 + * 如果返回错误对象,errorCode 和 errorMessage 分别取自于参数 errorCodeEnum 的 name() 和参数 errorMessage。 + * + * @param errorCodeEnum 错误码枚举。 + * @param errorMessage 如果该参数为null,错误信息取自errorCodeEnum参数内置的errorMessage,否则使用当前参数。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult create(ErrorCodeEnum errorCodeEnum, String errorMessage) { + errorMessage = errorMessage != null ? errorMessage : errorCodeEnum.getErrorMessage(); + return errorCodeEnum == ErrorCodeEnum.NO_ERROR ? success() : error(errorCodeEnum.name(), errorMessage); + } + + /** + * 根据参数errorCode是否为空,判断创建成功对象还是错误对象。 + * 如果返回错误对象,errorCode 和 errorMessage 分别取自于参数 errorCode 和参数 errorMessage。 + * + * @param errorCode 自定义的错误码。 + * @param errorMessage 自定义的错误信息。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult create(String errorCode, String errorMessage) { + return errorCode == null ? success() : error(errorCode, errorMessage); + } + + /** + * 根据参数errorCodeEnum的枚举值,判断创建成功对象还是错误对象。 + * 如果返回错误对象,errorCode 和 errorMessage 分别取自于参数 errorCodeEnum 的 name() 和参数 errorMessage。 + * + * @param errorCodeEnum 错误码枚举。 + * @param errorMessage 如果该参数为null,错误信息取自errorCodeEnum参数内置的errorMessage,否则使用当前参数。 + * @param data 如果错误枚举值为NO_ERROR,则返回该数据。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult create(ErrorCodeEnum errorCodeEnum, String errorMessage, T data) { + errorMessage = errorMessage != null ? errorMessage : errorCodeEnum.getErrorMessage(); + return errorCodeEnum == ErrorCodeEnum.NO_ERROR ? success(data) : error(errorCodeEnum.name(), errorMessage); + } + + /** + * 创建成功对象。 + * 如果需要绑定返回数据,可以在实例化后调用setDataObject方法。 + * + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult success() { + return OK; + } + + /** + * 创建带有返回数据的成功对象。 + * + * @param data 返回的数据对象。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult success(T data) { + ResponseResult resp = new ResponseResult<>(); + resp.data = data; + return resp; + } + + /** + * 创建带有返回数据的成功对象。 + * + * @param data 返回的数据对象。 + * @param clazz 目标数据类型。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult success(R data, Class clazz) { + ResponseResult resp = new ResponseResult<>(); + resp.data = MyModelUtil.copyTo(data, clazz); + return resp; + } + + /** + * 创建错误对象。 + * 如果返回错误对象,errorCode 和 errorMessage 分别取自于参数 errorCodeEnum 的 name() 和 getErrorMessage()。 + * + * @param errorCodeEnum 错误码枚举。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult error(ErrorCodeEnum errorCodeEnum) { + return error(errorCodeEnum.name(), errorCodeEnum.getErrorMessage()); + } + + /** + * 创建错误对象。 + * 如果返回错误对象,errorCode 和 errorMessage 分别取自于参数 errorCodeEnum 的 name() 和 getErrorMessage()。 + * + * @param httpStatus http状态值。 + * @param errorCodeEnum 错误码枚举。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult error(int httpStatus, ErrorCodeEnum errorCodeEnum) { + ResponseResult r = error(errorCodeEnum.name(), errorCodeEnum.getErrorMessage()); + r.setHttpStatus(httpStatus); + return r; + } + + /** + * 创建错误对象。 + * 如果返回错误对象,errorCode 和 errorMessage 分别取自于参数 errorCodeEnum 的 name() 和参数 errorMessage。 + * + * @param errorCodeEnum 错误码枚举。 + * @param errorMessage 自定义的错误信息。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult error(ErrorCodeEnum errorCodeEnum, String errorMessage) { + return error(errorCodeEnum.name(), errorMessage); + } + + /** + * 创建错误对象。 + * 如果返回错误对象,errorCode 和 errorMessage 分别取自于参数 errorCodeEnum 的 name() 和参数 errorMessage。 + * + * @param httpStatus http状态值。 + * @param errorCodeEnum 错误码枚举。 + * @param errorMessage 自定义的错误信息。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult error(int httpStatus, ErrorCodeEnum errorCodeEnum, String errorMessage) { + ResponseResult r = error(errorCodeEnum.name(), errorMessage); + r.setHttpStatus(httpStatus); + return r; + } + + /** + * 创建错误对象。 + * 如果返回错误对象,errorCode 和 errorMessage 分别取自于参数 errorCode 和参数 errorMessage。 + * + * @param errorCode 自定义的错误码。 + * @param errorMessage 自定义的错误信息。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult error(String errorCode, String errorMessage) { + return new ResponseResult<>(errorCode, errorMessage); + } + + /** + * 根据参数中出错的ResponseResult,创建新的错误应答对象。 + * + * @param errorCause 导致错误原因的应答对象。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult errorFrom(ResponseResult errorCause) { + return error(errorCause.errorCode, errorCause.getErrorMessage()); + } + + /** + * 根据参数中出错的CallResult,创建新的错误应答对象。 + * + * @param errorCause 导致错误原因的应答对象。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult errorFrom(CallResult errorCause) { + return error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorCause.getErrorMessage()); + } + + /** + * 根据参数中CallResult,创建新的应答对象。 + * + * @param result CallResult对象。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult from(CallResult result) { + if (result.isSuccess()) { + return success(); + } + return error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage()); + } + + /** + * 是否成功。 + * + * @return true成功,否则false。 + */ + public boolean isSuccess() { + return success; + } + + /** + * 通过HttpServletResponse直接输出应该信息的工具方法。 + * + * @param httpStatus http状态码。 + * @param responseResult 应答内容。 + * @param 数据对象类型。 + * @throws IOException 异常错误。 + */ + public static void output(int httpStatus, ResponseResult responseResult) throws IOException { + if (httpStatus != HttpServletResponse.SC_OK) { + log.error(JSON.toJSONString(responseResult)); + } else { + log.info(JSON.toJSONString(responseResult)); + } + HttpServletResponse response = ContextUtil.getHttpResponse(); + PrintWriter out = response.getWriter(); + response.setContentType("application/json; charset=utf-8"); + response.setStatus(httpStatus); + if (responseResult != null) { + out.print(JSON.toJSONString(responseResult)); + } + out.flush(); + } + + /** + * 通过HttpServletResponse直接输出应该信息的工具方法。 + * + * @param httpStatus http状态码。 + * @throws IOException 异常错误。 + */ + public static void output(int httpStatus) throws IOException { + output(httpStatus, null); + } + + /** + * 通过HttpServletResponse直接输出应该信息的工具方法。Http状态码为200。 + * + * @param responseResult 应答内容。 + * @param 数据对象类型。 + * @throws IOException 异常错误。 + */ + public static void output(ResponseResult responseResult) throws IOException { + output(HttpServletResponse.SC_OK, responseResult); + } + + private ResponseResult() { + } + + private ResponseResult(String errorCode, String errorMessage) { + this.success = false; + this.errorCode = errorCode; + this.errorMessage = errorMessage; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/TableModelInfo.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/TableModelInfo.java new file mode 100644 index 00000000..71c9d594 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/TableModelInfo.java @@ -0,0 +1,33 @@ +package com.orangeforms.common.core.object; + +import lombok.Data; + +/** + * 数据表模型基础信息。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class TableModelInfo { + + /** + * 数据表名。 + */ + private String tableName; + + /** + * 实体对象名。 + */ + private String modelName; + + /** + * 主键的表字段名。 + */ + private String keyColumnName; + + /** + * 主键在实体对象中的属性名。 + */ + private String keyFieldName; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/TokenData.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/TokenData.java new file mode 100644 index 00000000..79f3c1f9 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/TokenData.java @@ -0,0 +1,134 @@ +package com.orangeforms.common.core.object; + +import com.orangeforms.common.core.util.ContextUtil; +import lombok.Data; +import lombok.ToString; + +import jakarta.servlet.http.HttpServletRequest; +import java.util.Date; + +/** + * 基于Jwt,用于前后端传递的令牌对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ToString +public class TokenData { + + /** + * 在HTTP Request对象中的属性键。 + */ + public static final String REQUEST_ATTRIBUTE_NAME = "tokenData"; + /** + * 是否为百分号编码后的TokenData数据。 + */ + public static final String REQUEST_ENCODED_TOKEN = "encodedTokenData"; + /** + * 用户Id。 + */ + private Long userId; + /** + * 用户所属角色。多个角色之间逗号分隔。 + */ + private String roleIds; + /** + * 用户所在部门Id。 + * 仅当系统支持uaa时可用,否则可以直接忽略该字段。保留该字段是为了保持单体和微服务通用代码部分的兼容性。 + */ + private Long deptId; + /** + * 用户所属岗位Id。多个岗位之间逗号分隔。仅当系统支持岗位时有值。 + */ + private String postIds; + /** + * 用户的部门岗位Id。多个岗位之间逗号分隔。仅当系统支持岗位时有值。 + */ + private String deptPostIds; + /** + * 租户Id。 + * 仅当系统支持uaa时可用,否则可以直接忽略该字段。保留该字段是为了保持单体和微服务通用代码部分的兼容性。 + */ + private Long tenantId; + /** + * 是否为超级管理员。 + */ + private Boolean isAdmin; + /** + * 用户登录名。 + */ + private String loginName; + /** + * 用户显示名称。 + */ + private String showName; + /** + * 所在部门名。 + */ + private String deptName; + /** + * 设备类型。参考AppDeviceType。 + */ + private String deviceType; + /** + * 标识不同登录的会话Id。 + */ + private String sessionId; + /** + * 目前仅用于SaToken权限框架。 + * 主要用于辅助管理在线用户数据,SaToken默认的功能对于租户Id和登录用户的查询,没有提供方便的支持,或是效率较低。 + */ + private String mySessionId; + /** + * 访问uaa的授权token。 + * 仅当系统支持uaa时可用,否则可以直接忽略该字段。保留该字段是为了保持单体和微服务通用代码部分的兼容性。 + */ + private String uaaAccessToken; + /** + * 数据库路由键(仅当水平分库时使用)。 + */ + private Integer datasourceType; + /** + * 登录IP。 + */ + private String loginIp; + /** + * 登录时间。 + */ + private Date loginTime; + /** + * 登录头像地址。 + */ + private String headImageUrl; + /** + * 原始的请求Token。 + */ + private String token; + /** + * 应用编码。空值表示非第三方应用。 + */ + private String appCode; + + /** + * 将令牌对象添加到Http请求对象。 + * + * @param tokenData 令牌对象。 + */ + public static void addToRequest(TokenData tokenData) { + HttpServletRequest request = ContextUtil.getHttpRequest(); + if (request != null) { + request.setAttribute(TokenData.REQUEST_ATTRIBUTE_NAME, tokenData); + } + } + + /** + * 从Http Request对象中获取令牌对象。 + * + * @return 令牌对象。 + */ + public static TokenData takeFromRequest() { + HttpServletRequest request = ContextUtil.getHttpRequest(); + return request == null ? null : (TokenData) request.getAttribute(REQUEST_ATTRIBUTE_NAME); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/Tuple2.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/Tuple2.java new file mode 100644 index 00000000..19799a3e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/Tuple2.java @@ -0,0 +1,50 @@ +package com.orangeforms.common.core.object; + +/** + * 二元组对象。主要用于可以一次返回多个结果的场景,同时还能避免强制转换。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class Tuple2 { + + /** + * 第一个变量。 + */ + private final T1 first; + /** + * 第二个变量。 + */ + private final T2 second; + + /** + * 构造函数。 + * + * @param first 第一个变量。 + * @param second 第二个变量。 + */ + public Tuple2(T1 first, T2 second) { + this.first = first; + this.second = second; + } + + /** + * 获取第一个变量。 + * + * @return 返回第一个变量。 + */ + public T1 getFirst() { + return first; + } + + /** + * 获取第二个变量。 + * + * @return 返回第二个变量。 + */ + public T2 getSecond() { + return second; + } + +} + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/Tuple3.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/Tuple3.java new file mode 100644 index 00000000..bc6e4b7e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/Tuple3.java @@ -0,0 +1,65 @@ +package com.orangeforms.common.core.object; + +/** + * 三元组对象。主要用于可以一次返回多个结果的场景,同时还能避免强制转换。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class Tuple3 { + + /** + * 第一个变量。 + */ + private final T1 first; + /** + * 第二个变量。 + */ + private final T2 second; + + /** + * 第三个变量。 + */ + private final T3 third; + + /** + * 构造函数。 + * + * @param first 第一个变量。 + * @param second 第二个变量。 + * @param third 第三个变量。 + */ + public Tuple3(T1 first, T2 second, T3 third) { + this.first = first; + this.second = second; + this.third = third; + } + + /** + * 获取第一个变量。 + * + * @return 返回第一个变量。 + */ + public T1 getFirst() { + return first; + } + + /** + * 获取第二个变量。 + * + * @return 返回第二个变量。 + */ + public T2 getSecond() { + return second; + } + + /** + * 获取第三个变量。 + * + * @return 返回第三个变量。 + */ + public T3 getThird() { + return third; + } +} + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/TypedCallResult.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/TypedCallResult.java new file mode 100644 index 00000000..2dea0ca3 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/object/TypedCallResult.java @@ -0,0 +1,109 @@ +package com.orangeforms.common.core.object; + +import lombok.Data; + +/** + * 业务方法调用结果对象。可以同时返回具体的错误和自定义类型的数据对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class TypedCallResult { + + /** + * 为了优化性能,所有没有携带数据的正确结果,均可用该对象表示。 + */ + private static final TypedCallResult OK = new TypedCallResult<>(); + /** + * 是否成功标记。 + */ + private boolean success = true; + /** + * 错误信息描述。 + */ + private String errorMessage = null; + /** + * 在验证同时,仍然需要附加的关联数据对象。 + */ + private T data; + + /** + * 创建验证结果对象。 + * + * @param errorMessage 错误描述信息。 + * @return 如果参数为空,表示成功,否则返回代码错误信息的错误对象实例。 + */ + public static TypedCallResult create(String errorMessage) { + return errorMessage == null ? ok() : error(errorMessage); + } + + /** + * 创建验证结果对象。 + * + * @param errorMessage 错误描述信息。 + * @param data 附带的数据对象。 + * @return 如果参数为空,表示成功,否则返回代码错误信息的错误对象实例。 + */ + public static TypedCallResult create(String errorMessage, T data) { + return errorMessage == null ? ok(data) : error(errorMessage, data); + } + + /** + * 创建表示验证成功的对象实例。 + * + * @return 验证成功对象实例。 + */ + public static TypedCallResult ok() { + return OK; + } + + /** + * 创建表示验证成功的对象实例。 + * + * @param data 附带的数据对象。 + * @return 验证成功对象实例。 + */ + public static TypedCallResult ok(T data) { + TypedCallResult result = new TypedCallResult<>(); + result.data = data; + return result; + } + + /** + * 创建表示验证失败的对象实例。 + * + * @param errorMessage 错误描述。 + * @return 验证失败对象实例。 + */ + public static TypedCallResult error(String errorMessage) { + TypedCallResult result = new TypedCallResult<>(); + result.success = false; + result.errorMessage = errorMessage; + return result; + } + + /** + * 创建表示验证失败的对象实例。 + * + * @param errorMessage 错误描述。 + * @param data 附带的数据对象。 + * @return 验证失败对象实例。 + */ + public static TypedCallResult error(String errorMessage, T data) { + TypedCallResult result = new TypedCallResult<>(); + result.success = false; + result.errorMessage = errorMessage; + result.data = data; + return result; + } + + /** + * 根据参数中出错的TypedCallResult,创建新的错误调用结果对象。 + * @param result 错误调用结果对象。 + * @return 新的错误调用结果对象。 + */ + public static TypedCallResult errorFrom(TypedCallResult result) { + return error(result.getErrorMessage()); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/upload/BaseUpDownloader.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/upload/BaseUpDownloader.java new file mode 100644 index 00000000..840610bf --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/upload/BaseUpDownloader.java @@ -0,0 +1,216 @@ +package com.orangeforms.common.core.upload; + +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.util.ContextUtil; +import com.orangeforms.common.core.util.MyCommonUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.io.FilenameUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.web.multipart.MultipartFile; + +import javax.imageio.ImageIO; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Objects; + +/** + * 上传或下载文件抽象父类。 + * 包含存储本地文件的功能,以及上传和下载所需的通用方法。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public abstract class BaseUpDownloader { + + /** + * 构建上传文件的完整目录。 + * + * @param rootBaseDir 文件下载的根目录。 + * @param modelName 所在数据表的实体对象名。 + * @param fieldName 关联字段的实体对象属性名。 + * @param asImage 是否为图片对象。图片是无需权限验证的,因此和附件存放在不同的子目录。 + * @return 上传文件的完整路径名。 + */ + public String makeFullPath( + String rootBaseDir, String modelName, String fieldName, Boolean asImage) { + StringBuilder uploadPathBuilder = new StringBuilder(128); + if (StringUtils.isNotBlank(rootBaseDir)) { + uploadPathBuilder.append(rootBaseDir).append("/"); + } + if (Boolean.TRUE.equals(asImage)) { + uploadPathBuilder.append(ApplicationConstant.UPLOAD_IMAGE_PARENT_PATH); + } else { + uploadPathBuilder.append(ApplicationConstant.UPLOAD_ATTACHMENT_PARENT_PATH); + } + if (StringUtils.isNotBlank(modelName)) { + uploadPathBuilder.append("/").append(modelName); + } + if (StringUtils.isNotBlank(fieldName)) { + uploadPathBuilder.append("/").append(fieldName); + } + return uploadPathBuilder.toString(); + } + + /** + * 构建上传文件的完整目录。 + * + * @param rootBaseDir 文件下载的根目录。 + * @param path 文件目录。 + * @return 上传文件的完整路径名。 + */ + public String makeFullPath(String rootBaseDir, String path) { + StringBuilder uploadPathBuilder = new StringBuilder(128); + if (StringUtils.isNotBlank(rootBaseDir)) { + uploadPathBuilder.append(rootBaseDir).append("/"); + } + if (StringUtils.isNotBlank(path)) { + if (!StrUtil.startWith(path, "/")) { + uploadPathBuilder.append("/"); + } + uploadPathBuilder.append(path); + } + return uploadPathBuilder.toString(); + } + + /** + * 构建上传操作的返回对象。 + * + * @param serviceContextPath 微服务的上下文路径,如: /admin/upms。 + * @param originalFilename 上传文件的原始文件名(包含扩展名)。 + */ + protected void fillUploadResponseInfo( + UploadResponseInfo responseInfo, String serviceContextPath, String originalFilename) { + // 根据请求上传的uri构建下载uri,只是将末尾的/upload改为/download即可。 + HttpServletRequest request = ContextUtil.getHttpRequest(); + String uri = request.getRequestURI(); + uri = StringUtils.removeEnd(uri, "/"); + uri = StringUtils.removeEnd(uri, "/upload"); + String downloadUri; + if (StringUtils.isBlank(serviceContextPath)) { + downloadUri = uri + "/download"; + } else { + downloadUri = serviceContextPath + uri + "/download"; + } + StringBuilder filenameBuilder = new StringBuilder(64); + filenameBuilder.append(MyCommonUtil.generateUuid()) + .append(".").append(FilenameUtils.getExtension(originalFilename)); + responseInfo.setDownloadUri(downloadUri); + responseInfo.setFilename(filenameBuilder.toString()); + } + + /** + * 执行下载操作,从本地文件系统读取数据,并将读取的数据直接写入到HttpServletResponse应答对象。 + * + * @param rootBaseDir 文件下载的根目录。 + * @param modelName 所在数据表的实体对象名。 + * @param fieldName 关联字段的实体对象属性名。 + * @param fileName 文件名。 + * @param asImage 是否为图片对象。图片是无需权限验证的,因此和附件存放在不同的子目录。 + * @param response Http 应答对象。 + * @throws IOException 操作错误。 + */ + public abstract void doDownload( + String rootBaseDir, + String modelName, + String fieldName, + String fileName, + Boolean asImage, + HttpServletResponse response) throws IOException; + + /** + * 执行下载操作,从本地文件系统读取数据,并将读取的数据直接写入到HttpServletResponse应答对象。 + * + * @param rootBaseDir 文件下载的根目录。 + * @param uriPath uri中的路径名。 + * @param fileName 文件名。 + * @param response Http 应答对象。 + * @throws IOException 操作错误。 + */ + public abstract void doDownload( + String rootBaseDir, + String uriPath, + String fileName, + HttpServletResponse response) throws IOException; + + /** + * 执行文件上传操作,并存入本地文件系统,再将与该文件下载对应的Url直接写入到HttpServletResponse应答对象,返回给前端。 + * + * @param serviceContextPath 微服务的上下文路径,如: /admin/upms。 + * @param rootBaseDir 存放上传文件的根目录。 + * @param modelName 所在数据表的实体对象名。 + * @param fieldName 关联字段的实体对象属性名。 + * @param uploadFile Http请求中上传的文件对象。 + * @param asImage 是否为图片对象。图片是无需权限验证的,因此和附件存放在不同的子目录。 + * @return 存储在本地上传文件名。 + * @throws IOException 操作错误。 + */ + public abstract UploadResponseInfo doUpload( + String serviceContextPath, + String rootBaseDir, + String modelName, + String fieldName, + Boolean asImage, + MultipartFile uploadFile) throws IOException; + + /** + * 执行文件上传操作,并存入本地文件系统,再将与该文件下载对应的Url直接写入到HttpServletResponse应答对象,返回给前端。 + * + * @param serviceContextPath 微服务的上下文路径,如: /admin/upms。 + * @param rootBaseDir 存放上传文件的根目录。 + * @param uriPath uri中的路径名。 + * @param uploadFile Http请求中上传的文件对象。 + * @return 存储在本地上传文件名。 + * @throws IOException 操作错误。 + */ + public abstract UploadResponseInfo doUpload( + String serviceContextPath, + String rootBaseDir, + String uriPath, + MultipartFile uploadFile) throws IOException; + + /** + * 判断filename参数指定的文件名,是否被包含在fileInfoJson参数中。 + * + * @param fileInfoJson 内部类UploadFileInfo的JSONArray数组。 + * @param filename 被包含的文件名。 + * @return 存在返回true,否则false。 + */ + public static boolean containFile(String fileInfoJson, String filename) { + if (StringUtils.isAnyBlank(fileInfoJson, filename)) { + return false; + } + List fileInfoList = JSON.parseArray(fileInfoJson, UploadResponseInfo.class); + if (CollectionUtils.isNotEmpty(fileInfoList)) { + for (UploadResponseInfo fileInfo : fileInfoList) { + if (StringUtils.equals(filename, fileInfo.getFilename())) { + return true; + } + } + } + return false; + } + + protected UploadResponseInfo verifyUploadArgument( + Boolean asImage, MultipartFile uploadFile) throws IOException { + UploadResponseInfo responseInfo = new UploadResponseInfo(); + if (Objects.isNull(uploadFile) || uploadFile.isEmpty()) { + responseInfo.setUploadFailed(true); + responseInfo.setErrorMessage(ErrorCodeEnum.INVALID_UPLOAD_FILE_ARGUMENT.getErrorMessage()); + return responseInfo; + } + if (BooleanUtil.isTrue(asImage) && ImageIO.read(uploadFile.getInputStream()) == null) { + responseInfo.setUploadFailed(true); + responseInfo.setErrorMessage(ErrorCodeEnum.INVALID_UPLOAD_FILE_FORMAT.getErrorMessage()); + return responseInfo; + } + return responseInfo; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/upload/LocalUpDownloader.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/upload/LocalUpDownloader.java new file mode 100644 index 00000000..e883d06e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/upload/LocalUpDownloader.java @@ -0,0 +1,169 @@ +package com.orangeforms.common.core.upload; + +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; + +import jakarta.annotation.PostConstruct; +import jakarta.servlet.http.HttpServletResponse; +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +/** + * 存储本地文件的上传下载实现类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Component +public class LocalUpDownloader extends BaseUpDownloader { + + @Autowired + private UpDownloaderFactory factory; + + @PostConstruct + public void doRegister() { + factory.registerUpDownloader(UploadStoreTypeEnum.LOCAL_SYSTEM, this); + } + + @Override + public void doDownload( + String rootBaseDir, + String modelName, + String fieldName, + String fileName, + Boolean asImage, + HttpServletResponse response) { + String uploadPath = makeFullPath(rootBaseDir, modelName, fieldName, asImage); + String fullFileanme = uploadPath + "/" + fileName; + this.downloadInternal(fullFileanme, fileName, response); + } + + @Override + public void doDownload( + String rootBaseDir, + String uriPath, + String fileName, + HttpServletResponse response) throws IOException { + StringBuilder pathBuilder = new StringBuilder(128); + if (StrUtil.isNotBlank(rootBaseDir)) { + pathBuilder.append(rootBaseDir); + } + if (StrUtil.isNotBlank(uriPath)) { + pathBuilder.append(uriPath); + } + pathBuilder.append("/"); + String fullFileanme = pathBuilder.append(fileName).toString(); + this.downloadInternal(fullFileanme, fileName, response); + } + + @Override + public UploadResponseInfo doUpload( + String serviceContextPath, + String rootBaseDir, + String modelName, + String fieldName, + Boolean asImage, + MultipartFile uploadFile) throws IOException { + String uploadPath = makeFullPath(rootBaseDir, modelName, fieldName, asImage); + return this.doUploadInternally(serviceContextPath, uploadPath, asImage, uploadFile); + } + + @Override + public UploadResponseInfo doUpload( + String serviceContextPath, + String rootBaseDir, + String uriPath, + MultipartFile uploadFile) throws IOException { + String uploadPath = makeFullPath(rootBaseDir, uriPath); + return this.doUploadInternally(serviceContextPath, uploadPath, false, uploadFile); + } + + /** + * 判断filename参数指定的文件名,是否被包含在fileInfoJson参数中。 + * + * @param fileInfoJson 内部类UploadFileInfo的JSONArray数组。 + * @param filename 被包含的文件名。 + * @return 存在返回true,否则false。 + */ + public static boolean containFile(String fileInfoJson, String filename) { + if (StringUtils.isAnyBlank(fileInfoJson, filename)) { + return false; + } + List fileInfoList = JSON.parseArray(fileInfoJson, UploadResponseInfo.class); + if (CollectionUtils.isNotEmpty(fileInfoList)) { + for (UploadResponseInfo fileInfo : fileInfoList) { + if (StringUtils.equals(filename, fileInfo.getFilename())) { + return true; + } + } + } + return false; + } + + private UploadResponseInfo doUploadInternally( + String serviceContextPath, + String uploadPath, + Boolean asImage, + MultipartFile uploadFile) throws IOException { + UploadResponseInfo responseInfo = super.verifyUploadArgument(asImage, uploadFile); + if (BooleanUtil.isTrue(responseInfo.getUploadFailed())) { + return responseInfo; + } + responseInfo.setUploadPath(uploadPath); + fillUploadResponseInfo(responseInfo, serviceContextPath, uploadFile.getOriginalFilename()); + try { + byte[] bytes = uploadFile.getBytes(); + StringBuilder sb = new StringBuilder(256); + sb.append(uploadPath).append("/").append(responseInfo.getFilename()); + Path path = Paths.get(sb.toString()); + // 如果没有files文件夹,则创建 + if (!Files.isWritable(path)) { + Files.createDirectories(Paths.get(uploadPath)); + } + // 文件写入指定路径 + Files.write(path, bytes); + } catch (IOException e) { + log.error("Failed to write uploaded file [" + uploadFile.getOriginalFilename() + " ].", e); + responseInfo.setUploadFailed(true); + responseInfo.setErrorMessage(ErrorCodeEnum.INVALID_UPLOAD_FILE_IOERROR.getErrorMessage()); + return responseInfo; + } + return responseInfo; + } + + private void downloadInternal(String fullFileanme, String fileName, HttpServletResponse response) { + File file = new File(fullFileanme); + if (!file.exists()) { + log.warn("Download file [" + fullFileanme + "] failed, no file found!"); + response.setStatus(HttpServletResponse.SC_NOT_FOUND); + return; + } + response.setHeader("content-type", "application/octet-stream"); + response.setContentType("application/octet-stream"); + response.setHeader("Content-Disposition", "attachment;filename=" + fileName); + byte[] buff = new byte[2048]; + try (OutputStream os = response.getOutputStream(); + BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file))) { + int i = bis.read(buff); + while (i != -1) { + os.write(buff, 0, i); + os.flush(); + i = bis.read(buff); + } + } catch (IOException e) { + log.error("Failed to call LocalUpDownloader.doDownload", e); + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/upload/UpDownloaderFactory.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/upload/UpDownloaderFactory.java new file mode 100644 index 00000000..323880d4 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/upload/UpDownloaderFactory.java @@ -0,0 +1,49 @@ +package com.orangeforms.common.core.upload; + +import org.springframework.stereotype.Component; + +import java.util.EnumMap; +import java.util.Map; + +/** + * 业务对象根据上传下载存储类型,获取上传下载对象的工厂类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class UpDownloaderFactory { + + private final Map upDownloaderMap = new EnumMap<>(UploadStoreTypeEnum.class); + + /** + * 根据存储类型获取上传下载对象。 + * @param storeType 存储类型。 + * @return 匹配的上传下载对象。 + */ + public BaseUpDownloader get(UploadStoreTypeEnum storeType) { + BaseUpDownloader upDownloader = upDownloaderMap.get(storeType); + if (upDownloader == null) { + throw new UnsupportedOperationException( + "The storeType [" + storeType.name() + "] isn't supported, please add dependency jar first."); + } + return upDownloader; + } + + /** + * 注册上传下载对象到工厂。 + * + * @param storeType 存储类型。 + * @param upDownloader 上传下载对象。 + */ + public void registerUpDownloader(UploadStoreTypeEnum storeType, BaseUpDownloader upDownloader) { + if (storeType == null || upDownloader == null) { + throw new IllegalArgumentException("The Argument can't be NULL."); + } + if (upDownloaderMap.containsKey(storeType)) { + throw new UnsupportedOperationException( + "The storeType [" + storeType.name() + "] has been registered already."); + } + upDownloaderMap.put(storeType, upDownloader); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/upload/UploadResponseInfo.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/upload/UploadResponseInfo.java new file mode 100644 index 00000000..3610a541 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/upload/UploadResponseInfo.java @@ -0,0 +1,33 @@ +package com.orangeforms.common.core.upload; + +import lombok.Data; + +/** + * 数据上传操作的应答信息对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class UploadResponseInfo { + /** + * 上传是否出现错误。 + */ + private Boolean uploadFailed = false; + /** + * 具体错误信息。 + */ + private String errorMessage; + /** + * 返回前端的下载url。 + */ + private String downloadUri; + /** + * 上传文件所在路径。 + */ + private String uploadPath; + /** + * 返回给前端的文件名。 + */ + private String filename; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/upload/UploadStoreInfo.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/upload/UploadStoreInfo.java new file mode 100644 index 00000000..32d7fed6 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/upload/UploadStoreInfo.java @@ -0,0 +1,22 @@ +package com.orangeforms.common.core.upload; + +import lombok.Data; + +/** + * 上传数据存储信息对象。这里之所以使用对象,主要是便于今后扩展。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class UploadStoreInfo { + + /** + * 是否支持上传。 + */ + private boolean supportUpload; + /** + * 上传数据存储类型。 + */ + private UploadStoreTypeEnum storeType; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/upload/UploadStoreTypeEnum.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/upload/UploadStoreTypeEnum.java new file mode 100644 index 00000000..62c1d2d7 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/upload/UploadStoreTypeEnum.java @@ -0,0 +1,31 @@ +package com.orangeforms.common.core.upload; + +/** + * 上传数据存储介质类型枚举。 + * + * @author Jerry + * @date 2024-07-02 + */ +public enum UploadStoreTypeEnum { + + /** + * 本地系统。 + */ + LOCAL_SYSTEM, + /** + * minio分布式存储。 + */ + MINIO_SYSTEM, + /** + * 阿里云OSS存储。 + */ + ALIYUN_OSS_SYTEM, + /** + * 腾讯云COS存储。 + */ + QCLOUD_COS_SYTEM, + /** + * 华为云OBS存储。 + */ + HUAWEI_OBS_SYSTEM +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/AopTargetUtil.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/AopTargetUtil.java new file mode 100644 index 00000000..48844678 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/AopTargetUtil.java @@ -0,0 +1,81 @@ +package com.orangeforms.common.core.util; + +import cn.hutool.core.util.ReflectUtil; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.aop.framework.AdvisedSupport; +import org.springframework.aop.framework.AopProxy; +import org.springframework.aop.support.AopUtils; + +import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.stream.Collectors; + +/** + * 获取JDK动态代理/CGLIB代理对象代理的目标对象的工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class AopTargetUtil { + + /** + * 获取参数对象代理的目标对象。 + * + * @param proxy 代理对象 + * @return 代理的目标对象。 + */ + public static Object getTarget(Object proxy) { + if (!AopUtils.isAopProxy(proxy)) { + return proxy; + } + try { + if (AopUtils.isJdkDynamicProxy(proxy)) { + return getJdkDynamicProxyTargetObject(proxy); + } else { + return getCglibProxyTargetObject(proxy); + } + } catch (Exception e) { + log.error("Failed to call getJdkDynamicProxyTargetObject or getCglibProxyTargetObject", e); + return null; + } + } + + /** + * 获取被织入完整的方法名。 + * + * @param joinPoint 织入方法对象。 + * @return 被织入完整的方法名。 + */ + public static String getFullMethodName(ProceedingJoinPoint joinPoint) { + StringBuilder sb = new StringBuilder(512); + MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); + sb.append(methodSignature.getMethod().getName()).append("("); + String paramTypes = Arrays.stream(methodSignature.getParameterTypes()) + .map(Class::getSimpleName).collect(Collectors.joining(", ")); + sb.append(paramTypes).append(")"); + return sb.toString(); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private AopTargetUtil() { + } + + private static Object getCglibProxyTargetObject(Object proxy) throws Exception { + Field h = proxy.getClass().getDeclaredField("CGLIB$CALLBACK_0"); + Object dynamicAdvisedInterceptor = ReflectUtil.getFieldValue(proxy, h); + Field advised = dynamicAdvisedInterceptor.getClass().getDeclaredField("advised"); + return ((AdvisedSupport) ReflectUtil.getFieldValue(dynamicAdvisedInterceptor, advised)).getTargetSource().getTarget(); + } + + private static Object getJdkDynamicProxyTargetObject(Object proxy) throws Exception { + Field h = proxy.getClass().getSuperclass().getDeclaredField("h"); + AopProxy aopProxy = (AopProxy) ReflectUtil.getFieldValue(proxy, h); + Field advised = aopProxy.getClass().getDeclaredField("advised"); + return ((AdvisedSupport) ReflectUtil.getFieldValue(aopProxy, advised)).getTargetSource().getTarget(); + } +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/ApplicationContextHolder.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/ApplicationContextHolder.java new file mode 100644 index 00000000..2a53c923 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/ApplicationContextHolder.java @@ -0,0 +1,88 @@ +package com.orangeforms.common.core.util; + +import com.orangeforms.common.core.exception.MyRuntimeException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.lang.NonNull; +import org.springframework.stereotype.Component; + +import java.util.Collection; + +/** + * Spring 系统启动应用感知对象,主要用于获取Spring Bean的上下文对象,后续的代码中可以直接查找系统中加载的Bean对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class ApplicationContextHolder implements ApplicationContextAware { + + private static ApplicationContext applicationContext; + + /** + * Spring 启动的过程中会自动调用,并将应用上下文对象赋值进来。 + * + * @param applicationContext 应用上下文对象,可通过该对象查找Spring中已经加载的Bean。 + */ + @Override + public void setApplicationContext(@NonNull ApplicationContext applicationContext) { + doSetApplicationContext(applicationContext); + } + + /** + * 获取应用上下文对象。 + * + * @return 应用上下文。 + */ + public static ApplicationContext getApplicationContext() { + assertApplicationContext(); + return applicationContext; + } + + /** + * 根据BeanName,获取Bean对象。 + * + * @param beanName Bean名称。 + * @param 返回的Bean类型。 + * @return Bean对象。 + */ + @SuppressWarnings("unchecked") + public static T getBean(String beanName) { + assertApplicationContext(); + return (T) applicationContext.getBean(beanName); + } + + /** + * 根据Bean的ClassType,获取Bean对象。 + * + * @param beanType Bean的Class类型。 + * @param 返回的Bean类型。 + * @return Bean对象。 + */ + public static T getBean(Class beanType) { + assertApplicationContext(); + return applicationContext.getBean(beanType); + } + + /** + * 根据Bean的ClassType,获取Bean对象列表。 + * + * @param beanType Bean的Class类型。 + * @param 返回的Bean类型。 + * @return Bean对象列表。 + */ + public static Collection getBeanListOfType(Class beanType) { + assertApplicationContext(); + return applicationContext.getBeansOfType(beanType).values(); + } + + private static void assertApplicationContext() { + if (ApplicationContextHolder.applicationContext == null) { + throw new MyRuntimeException("applicaitonContext属性为null,请检查是否注入了ApplicationContextHolder!"); + } + } + + private static void doSetApplicationContext(ApplicationContext applicationContext) { + ApplicationContextHolder.applicationContext = applicationContext; + } +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/ContextUtil.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/ContextUtil.java new file mode 100644 index 00000000..95382bde --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/ContextUtil.java @@ -0,0 +1,51 @@ +package com.orangeforms.common.core.util; + +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +/** + * 获取Servlet HttpRequest和HttpResponse的工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class ContextUtil { + + /** + * 判断当前是否处于HttpServletRequest上下文环境。 + * + * @return 是返回true,否则false。 + */ + public static boolean hasRequestContext() { + return RequestContextHolder.getRequestAttributes() != null; + } + + /** + * 获取Servlet请求上下文的HttpRequest对象。 + * + * @return 请求上下文中的HttpRequest对象。 + */ + public static HttpServletRequest getHttpRequest() { + ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + return attributes == null ? null : attributes.getRequest(); + } + + /** + * 获取Servlet请求上下文的HttpResponse对象。 + * + * @return 请求上下文中的HttpResponse对象。 + */ + public static HttpServletResponse getHttpResponse() { + ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + return attributes == null ? null : attributes.getResponse(); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private ContextUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/DataSourceResolver.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/DataSourceResolver.java new file mode 100644 index 00000000..256ddf5a --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/DataSourceResolver.java @@ -0,0 +1,21 @@ +package com.orangeforms.common.core.util; + +/** + * 基于自定义解析规则的多数据源解析接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface DataSourceResolver { + + /** + * 动态解析方法。实现类可以根据当前的请求,或者上下文环境进行动态解析。 + * + * @param arg 可选的入参。MyDataSourceResolver注解中的arg参数。 + * @param intArg 可选的整型入参。MyDataSourceResolver注解中的intArg参数。 + * @param methodName 被织入方法名称。 + * @param methodArgs 被织入方法的所有参数。 + * @return 返回用于多数据源切换的类型值。DataSourceResolveAspect 切面方法会根据该返回值和配置信息,进行多数据源切换。 + */ + Integer resolve(String arg, Integer intArg, String methodName, Object[] methodArgs); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/DefaultDataSourceResolver.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/DefaultDataSourceResolver.java new file mode 100644 index 00000000..b11e16fc --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/DefaultDataSourceResolver.java @@ -0,0 +1,55 @@ +package com.orangeforms.common.core.util; + +import org.springframework.stereotype.Component; + +/** + * 常量值指向的数据源。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class DefaultDataSourceResolver implements DataSourceResolver { + + private static final ThreadLocal DEFAULT_CONTEXT_HOLDER = new ThreadLocal<>(); + + @Override + public Integer resolve(String arg, Integer intArg, String methodName, Object[] methodArgs) { + Integer datasourceType = DEFAULT_CONTEXT_HOLDER.get(); + return datasourceType != null ? datasourceType : intArg; + } + + /** + * 设置报表数据源类型值。 + * + * @param type 数据源类型 + * @return 原有数据源类型,如果第一次设置则返回null。 + */ + public static Integer setDataSourceType(Integer type) { + Integer datasourceType = DEFAULT_CONTEXT_HOLDER.get(); + DEFAULT_CONTEXT_HOLDER.set(type); + return datasourceType; + } + + /** + * 获取当前报表数据库操作执行线程的数据源类型,同时由动态数据源的路由函数调用。 + * + * @return 数据源类型。 + */ + public static Integer getDataSourceType() { + return DEFAULT_CONTEXT_HOLDER.get(); + } + + /** + * 清除线程本地变量,以免内存泄漏。 + + * @param originalType 原有的数据源类型,如果该值为null,则情况本地化变量。 + */ + public static void unset(Integer originalType) { + if (originalType == null) { + DEFAULT_CONTEXT_HOLDER.remove(); + } else { + DEFAULT_CONTEXT_HOLDER.set(originalType); + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/ExportUtil.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/ExportUtil.java new file mode 100644 index 00000000..b3d37aa8 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/ExportUtil.java @@ -0,0 +1,111 @@ +package com.orangeforms.common.core.util; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.io.IoUtil; +import cn.hutool.poi.excel.ExcelUtil; +import cn.hutool.poi.excel.ExcelWriter; +import cn.jimmyshi.beanquery.BeanQuery; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.exception.MyRuntimeException; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.csv.CSVFormat; +import org.apache.commons.csv.CSVPrinter; +import org.apache.commons.io.FilenameUtils; + +import jakarta.servlet.ServletOutputStream; +import jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.Writer; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 导出工具类,目前支持xlsx和csv两种类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class ExportUtil { + + /** + * 数据导出。目前仅支持xlsx和csv。 + * + * @param dataList 导出数据列表。 + * @param selectFieldMap 导出的数据字段,key为对象字段名称,value为中文标题名称。 + * @param filename 导出文件名。 + * @param 数据对象类型。 + * @throws IOException 文件操作失败。 + */ + public static void doExport( + Collection dataList, Map selectFieldMap, String filename) throws IOException { + if (CollUtil.isEmpty(dataList)) { + return; + } + StringBuilder sb = new StringBuilder(128); + for (Map.Entry e : selectFieldMap.entrySet()) { + sb.append(e.getKey()).append(" as ").append(e.getValue()).append(", "); + } + // 去掉末尾的逗号 + String selectFieldString = sb.substring(0, sb.length() - 2); + // 写出数据到xcel格式的输出流 + List> resultList = BeanQuery.select(selectFieldString).executeFrom(dataList); + normalizeMultiSelectList(resultList); + // 构建HTTP输出流参数 + HttpServletResponse response = ContextUtil.getHttpResponse(); + response.setHeader("content-type", "application/octet-stream"); + response.setContentType("application/octet-stream"); + response.setHeader("Content-Disposition", "attachment;filename=" + filename); + if (ApplicationConstant.XLSX_EXT.equals(FilenameUtils.getExtension(filename))) { + ServletOutputStream out = response.getOutputStream(); + ExcelWriter writer = ExcelUtil.getWriter(true); + writer.setRowHeight(-1, 30); + writer.setColumnWidth(-1, 30); + writer.setColumnWidth(1, 20); + writer.write(resultList); + writer.flush(out); + writer.close(); + IoUtil.close(out); + } else if (ApplicationConstant.CSV_EXT.equals(FilenameUtils.getExtension(filename))) { + Collection headerList = selectFieldMap.values(); + String[] headerArray = new String[headerList.size()]; + headerList.toArray(headerArray); + CSVFormat format = CSVFormat.DEFAULT.withHeader(headerArray); + response.setCharacterEncoding(StandardCharsets.UTF_8.name()); + try (Writer out = response.getWriter(); CSVPrinter printer = new CSVPrinter(out, format)) { + for (Map o : resultList) { + for (Map.Entry entry : o.entrySet()) { + printer.print(entry.getValue()); + } + printer.println(); + } + printer.flush(); + } catch (Exception e) { + log.error("Failed to call ExportUtil.doExport", e); + } + } else { + throw new MyRuntimeException("不支持的导出文件类型!"); + } + } + + @SuppressWarnings("unchecked") + private static void normalizeMultiSelectList(List> resultList) { + for (Map data : resultList) { + for (Map.Entry entry : data.entrySet()) { + if (entry.getValue() instanceof List) { + List> dictMapList = ((List>) entry.getValue()); + List nameList = dictMapList.stream() + .map(item -> item.get("name").toString()).collect(Collectors.toList()); + data.put(entry.getKey(), CollUtil.join(nameList, ",")); + } + } + } + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private ExportUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/ImportUtil.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/ImportUtil.java new file mode 100644 index 00000000..7b17f596 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/ImportUtil.java @@ -0,0 +1,356 @@ +package com.orangeforms.common.core.util; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.io.file.FileNameUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.ReflectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.poi.excel.ExcelUtil; +import cn.hutool.poi.excel.sax.handler.RowHandler; +import com.mybatisflex.annotation.Column; +import com.mybatisflex.annotation.Id; +import com.orangeforms.common.core.annotation.RelationConstDict; +import com.orangeforms.common.core.annotation.RelationDict; +import com.orangeforms.common.core.annotation.RelationGlobalDict; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.exception.MyRuntimeException; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.joda.time.DateTime; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.io.IOException; +import java.io.Serializable; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.math.BigDecimal; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 导入工具类,目前支持xlsx和xls两种类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class ImportUtil { + + /** + * 根据实体类的Class类型,生成导入的头信息。 + * + * @param modelClazz 实体对象的Class类型。 + * @param ignoreFields 忽略的字段名集合,如创建时间、创建人、更新时间、更新人等。 + * @param 实体对象类型。 + * @return 创建后的导入头信息列表。 + */ + public static List makeHeaderInfoList(Class modelClazz, Set ignoreFields) { + List resultList = new LinkedList<>(); + Field[] fields = ReflectUtil.getFields(modelClazz); + int index = 0; + for (Field field : fields) { + int modifiers = field.getModifiers(); + // transient类型的字段不能作为查询条件,静态字段和逻辑删除都不考虑。需要忽略的字段也要跳过。 + int transientMask = 128; + if ((modifiers & transientMask) == 1 + || Modifier.isStatic(modifiers) + || field.getAnnotation(Id.class) != null + || isLogicDeleteColumn(field) + || CollUtil.contains(ignoreFields, field.getName())) { + continue; + } + Column tableField = field.getAnnotation(Column.class); + if (tableField == null || !tableField.ignore()) { + ImportHeaderInfo headerInfo = new ImportHeaderInfo(); + headerInfo.fieldName = field.getName(); + headerInfo.index = index++; + makeHeaderInfoFieldTypeByField(field, headerInfo); + resultList.add(headerInfo); + } + } + return resultList; + } + + private static boolean isLogicDeleteColumn(Field field) { + Column c = field.getAnnotation(Column.class); + return c != null && c.isLogicDelete(); + } + + /** + * 保存导入文件。 + * + * @param baseDir 导入文件本地缓存的根目录。 + * @param subDir 导入文件本地缓存的子目录。 + * @param importFile 导入的文件。 + * @return 保存的本地文件名。 + */ + public static String saveImportFile( + String baseDir, String subDir, MultipartFile importFile) throws IOException { + StringBuilder sb = new StringBuilder(256); + sb.append(baseDir); + if (!StrUtil.endWith(baseDir, "/")) { + sb.append("/"); + } + sb.append("importedFile/"); + if (StrUtil.isNotBlank(subDir)) { + sb.append(subDir); + if (!StrUtil.endWith(subDir, "/")) { + sb.append("/"); + } + } + String pathname = sb.toString(); + sb.append(new DateTime().toString("yyyy-MM-dd-HH-mm-")); + sb.append(MyCommonUtil.generateUuid()) + .append(".").append(FileNameUtil.getSuffix(importFile.getOriginalFilename())); + String fullname = sb.toString(); + try { + byte[] bytes = importFile.getBytes(); + Path path = Paths.get(fullname); + // 如果没有files文件夹,则创建 + if (!Files.isWritable(path)) { + Files.createDirectories(Paths.get(pathname)); + } + // 文件写入指定路径 + Files.write(path, bytes); + } catch (IOException e) { + log.error("Failed to write imported file [" + importFile.getOriginalFilename() + " ].", e); + throw e; + } + return fullname; + } + + /** + * 导入指定的excel,基于SAX方式解析后返回数据列表。 + * + * @param headers 头信息数组。 + * @param skipHeader 是否跳过第一行,通常改行为头信息。 + * @param filename 文件名。 + * @return 解析后数据列表。 + */ + public static List> doImport( + ImportHeaderInfo[] headers, boolean skipHeader, String filename) { + Assert.notNull(headers); + Assert.isTrue(StrUtil.isNotBlank(filename)); + List> resultList = new LinkedList<>(); + ExcelUtil.readBySax(new File(filename), 0, createRowHandler(headers, skipHeader, resultList)); + return resultList; + } + + /** + * 导入指定的excel,基于SAX方式解析后返回Bean类型的数据列表。 + * + * @param headers 头信息数组。 + * @param skipHeader 是否跳过第一行,通常改行为头信息。 + * @param filename 文件名。 + * @param clazz Bean的Class类型。 + * @param translateDictFieldSet 需要进行反向翻译的字典字段集合。 + * @return 解析后数据列表。 + */ + public static List doImport( + ImportHeaderInfo[] headers, + boolean skipHeader, + String filename, + Class clazz, + Set translateDictFieldSet) { + // 这里将需要进行字典反向翻译的字段类型改为String,否则使用原有的字典Id类型时,无法正确执行下面的doImport方法。 + if (CollUtil.isNotEmpty(translateDictFieldSet)) { + for (ImportHeaderInfo header : headers) { + if (translateDictFieldSet.contains(header.fieldName)) { + header.fieldType = STRING_TYPE; + } + } + } + List> resultList = doImport(headers, skipHeader, filename); + if (CollUtil.isNotEmpty(translateDictFieldSet)) { + translateDictFieldSet.forEach(c -> doTranslateDict(resultList, clazz, c)); + } + return MyModelUtil.mapToBeanList(resultList, clazz); + } + + /** + * 转换数据列表中,需要进行反向字典翻译的字段。 + * + * @param dataList 数据列表。 + * @param modelClass 对象模型。 + * @param fieldName 需要进行字典反向翻译的字段名。注意,该字段为需要翻译替换的Java字段名,与此同时, + * 该字段 + DictMap后缀的字段名,必须被RelationConstDict和RelationDict注解标记。 + */ + @SuppressWarnings("unchecked") + public static void doTranslateDict(List> dataList, Class modelClass, String fieldName) { + if (CollUtil.isEmpty(dataList)) { + return; + } + Field field = ReflectUtil.getField(modelClass, fieldName + "DictMap"); + Assert.notNull(field); + Map inversedDictMap; + if (field.isAnnotationPresent(RelationConstDict.class)) { + RelationConstDict r = field.getAnnotation(RelationConstDict.class); + Field f = ReflectUtil.getField(r.constantDictClass(), "DICT_MAP"); + Map dictMap = (Map) ReflectUtil.getStaticFieldValue(f); + inversedDictMap = MapUtil.inverse(dictMap); + } else if (field.isAnnotationPresent(RelationDict.class)) { + RelationDict r = field.getAnnotation(RelationDict.class); + String slaveServiceName = r.slaveServiceName(); + if (StrUtil.isBlank(slaveServiceName)) { + slaveServiceName = r.slaveModelClass().getSimpleName() + "Service"; + } + BaseService service = + ApplicationContextHolder.getBean(StrUtil.lowerFirst(slaveServiceName)); + List dictDataList = service.getAllList(); + List> dataMapList = MyModelUtil.beanToMapList(dictDataList); + inversedDictMap = new HashMap<>(dataMapList.size()); + dataMapList.forEach(d -> + inversedDictMap.put(d.get(r.slaveNameField()).toString(), d.get(r.slaveIdField()))); + } else if (field.isAnnotationPresent(RelationGlobalDict.class)) { + RelationGlobalDict r = field.getAnnotation(RelationGlobalDict.class); + BaseService s = ApplicationContextHolder.getBean("globalDictService"); + Method m = ReflectUtil.getMethodByName(s.getClass(), "getGlobalDictItemDictMapFromCache"); + Map dictMap = ReflectUtil.invoke(s, m, r.dictCode(), null); + inversedDictMap = MapUtil.inverse(dictMap); + } else { + throw new UnsupportedOperationException("Only Support RelationConstDict and RelationDict Field"); + } + if (MapUtil.isEmpty(inversedDictMap)) { + log.warn("Dict Data List is EMPTY."); + return; + } + for (Map data : dataList) { + Object value = data.get(fieldName); + if (value != null) { + Object newValue = inversedDictMap.get(value.toString()); + if (newValue != null) { + data.put(fieldName, newValue); + } + } + } + } + + private static void makeHeaderInfoFieldTypeByField(Field field, ImportHeaderInfo headerInfo) { + if (field.getType().equals(Integer.class)) { + headerInfo.fieldType = INT_TYPE; + } else if (field.getType().equals(Long.class)) { + headerInfo.fieldType = LONG_TYPE; + } else if (field.getType().equals(String.class)) { + headerInfo.fieldType = STRING_TYPE; + } else if (field.getType().equals(Boolean.class)) { + headerInfo.fieldType = BOOLEAN_TYPE; + } else if (field.getType().equals(Date.class)) { + headerInfo.fieldType = DATE_TYPE; + } else if (field.getType().equals(Double.class)) { + headerInfo.fieldType = DOUBLE_TYPE; + } else if (field.getType().equals(Float.class)) { + headerInfo.fieldType = FLOAT_TYPE; + } else if (field.getType().equals(BigDecimal.class)) { + headerInfo.fieldType = BIG_DECIMAL_TYPE; + } else { + throw new MyRuntimeException("Unsupport Import FieldType"); + } + } + + private static RowHandler createRowHandler( + ImportHeaderInfo[] headers, boolean skipHeader, List> resultList) { + return new MyRowHandler(headers, skipHeader, resultList); + } + + public static final int INT_TYPE = 0; + public static final int LONG_TYPE = 1; + public static final int STRING_TYPE = 2; + public static final int BOOLEAN_TYPE = 3; + public static final int DATE_TYPE = 4; + public static final int DOUBLE_TYPE = 5; + public static final int FLOAT_TYPE = 6; + public static final int BIG_DECIMAL_TYPE = 7; + + @NoArgsConstructor + @AllArgsConstructor + @Data + public static class ImportHeaderInfo { + /** + * 对应的Java实体对象属性名。 + */ + private String fieldName; + /** + * 对应的Java实体对象类型。 + */ + private Integer fieldType; + /** + * 0 表示excel中的第一列。 + */ + private Integer index; + } + + private static class MyRowHandler implements RowHandler { + private ImportHeaderInfo[] headers; + private Map headerInfoMap; + private boolean skipHeader; + private List> resultList; + + public MyRowHandler(ImportHeaderInfo[] headers, boolean skipHeader, List> resultList) { + this.headers = headers; + this.skipHeader = skipHeader; + this.resultList = resultList; + this.headerInfoMap = Arrays.stream(headers) + .collect(Collectors.toMap(ImportHeaderInfo::getIndex, c -> c)); + } + + @Override + public void handle(int sheetIndex, long rowIndex, List rowList) { + if (this.skipHeader && rowIndex == 0) { + return; + } + int i = 0; + Map data = new HashMap<>(headers.length); + for (Object rowData : rowList) { + ImportHeaderInfo headerInfo = this.headerInfoMap.get(i++); + if (headerInfo == null) { + continue; + } + switch (headerInfo.fieldType) { + case INT_TYPE: + data.put(headerInfo.fieldName, Convert.toInt(rowData)); + break; + case LONG_TYPE: + data.put(headerInfo.fieldName, Convert.toLong(rowData)); + break; + case STRING_TYPE: + data.put(headerInfo.fieldName, Convert.toStr(rowData)); + break; + case BOOLEAN_TYPE: + data.put(headerInfo.fieldName, Convert.toBool(rowData)); + break; + case DATE_TYPE: + data.put(headerInfo.fieldName, Convert.toDate(rowData)); + break; + case DOUBLE_TYPE: + data.put(headerInfo.fieldName, Convert.toDouble(rowData)); + break; + case FLOAT_TYPE: + data.put(headerInfo.fieldName, Convert.toFloat(rowData)); + break; + case BIG_DECIMAL_TYPE: + data.put(headerInfo.fieldName, Convert.toBigDecimal(rowData)); + break; + default: + throw new MyRuntimeException( + "Invalid ImportHeaderInfo.fieldType [" + headerInfo.fieldType + "]."); + } + } + resultList.add(data); + } + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private ImportUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/IpUtil.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/IpUtil.java new file mode 100644 index 00000000..c9ac471f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/IpUtil.java @@ -0,0 +1,104 @@ +package com.orangeforms.common.core.util; + +import cn.hutool.core.util.StrUtil; +import lombok.extern.slf4j.Slf4j; + +import jakarta.servlet.http.HttpServletRequest; +import java.net.Inet6Address; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.SocketException; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; + +/** + * Ip工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class IpUtil { + + private static final String UNKNOWN = "unknown"; + + /** + * 通过Servlet的HttpRequest对象获取Ip地址。 + * + * @param request HttpRequest对象。 + * @return 本次请求的Ip地址。 + */ + public static String getRemoteIpAddress(HttpServletRequest request) { + String ip = null; + // X-Forwarded-For:Squid 服务代理 + String ipAddresses = request.getHeader("X-Forwarded-For"); + if (StrUtil.isBlank(ipAddresses) || UNKNOWN.equalsIgnoreCase(ipAddresses)) { + // Proxy-Client-IP:apache 服务代理 + ipAddresses = request.getHeader("Proxy-Client-IP"); + } + if (StrUtil.isBlank(ipAddresses) || UNKNOWN.equalsIgnoreCase(ipAddresses)) { + ipAddresses = request.getHeader("HTTP_X_FORWARDED_FOR"); + } + if (StrUtil.isBlank(ipAddresses) || UNKNOWN.equalsIgnoreCase(ipAddresses)) { + // WL-Proxy-Client-IP:weblogic 服务代理 + ipAddresses = request.getHeader("WL-Proxy-Client-IP"); + } + if (StrUtil.isBlank(ipAddresses) || UNKNOWN.equalsIgnoreCase(ipAddresses)) { + // HTTP_CLIENT_IP:有些代理服务器 + ipAddresses = request.getHeader("HTTP_CLIENT_IP"); + } + if (StrUtil.isBlank(ipAddresses) || UNKNOWN.equalsIgnoreCase(ipAddresses)) { + // X-Real-IP:nginx服务代理 + ipAddresses = request.getHeader("X-Real-IP"); + } + // 有些网络通过多层代理,那么获取到的ip就会有多个,一般都是通过逗号(,)分割开来,并且第一个ip为客户端的真实IP + if (StrUtil.isNotBlank(ipAddresses)) { + ip = ipAddresses.split(",")[0]; + } + // 还是不能获取到,最后再通过request.getRemoteAddr();获取 + if (StrUtil.isBlank(ipAddresses) || UNKNOWN.equalsIgnoreCase(ipAddresses)) { + ip = request.getRemoteAddr(); + } + return ip; + } + + public static String getFirstLocalIpAddress() { + String ip; + try { + List ipList = getHostAddress(); + // default the first + ip = (!ipList.isEmpty()) ? ipList.get(0) : ""; + } catch (Exception ex) { + ip = ""; + log.error("Failed to call ", ex); + } + return ip; + } + + private static List getHostAddress() throws SocketException { + List ipList = new ArrayList<>(5); + Enumeration interfaces = NetworkInterface.getNetworkInterfaces(); + while (interfaces.hasMoreElements()) { + NetworkInterface ni = interfaces.nextElement(); + Enumeration allAddress = ni.getInetAddresses(); + while (allAddress.hasMoreElements()) { + InetAddress address = allAddress.nextElement(); + // skip the IPv6 addr + // skip the IPv6 addr + if (address.isLoopbackAddress() || address instanceof Inet6Address) { + continue; + } + String hostAddress = address.getHostAddress(); + ipList.add(hostAddress); + } + } + return ipList; + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private IpUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/JwtUtil.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/JwtUtil.java new file mode 100644 index 00000000..84e23a06 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/JwtUtil.java @@ -0,0 +1,112 @@ +package com.orangeforms.common.core.util; + +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.security.Keys; +import lombok.extern.slf4j.Slf4j; + +import javax.crypto.SecretKey; +import java.util.Date; +import java.util.Map; + +/** + * 基于JWT的Token生成工具类 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class JwtUtil { + + private static final String TOKEN_PREFIX = "Bearer "; + private static final String CLAIM_KEY_CREATEDTIME = "CreatedTime"; + + /** + * Token缺省过期时间是30分钟 + */ + private static final Long TOKEN_EXPIRATION = 1800000L; + /** + * 缺省情况下,Token会每5分钟被刷新一次 + */ + private static final Long REFRESH_TOKEN_INTERVAL = 300000L; + + /** + * 生成加密后的JWT令牌,生成的结果中包含令牌前缀,如"Bearer " + * + * @param claims 令牌中携带的数据 + * @param expirationMillisecond 过期的毫秒数 + * @return 生成后的令牌信息 + */ + public static String generateToken(Map claims, long expirationMillisecond, String signingKey) { + // 自动添加token的创建时间 + long createTime = System.currentTimeMillis(); + claims.put(CLAIM_KEY_CREATEDTIME, createTime); + SecretKey sk = Keys.hmacShaKeyFor(signingKey.getBytes()); + String token = Jwts.builder().claims(claims) + .signWith(sk, Jwts.SIG.HS256) + .expiration(new Date(createTime + expirationMillisecond)) + .compact(); + return TOKEN_PREFIX + token; + } + + /** + * 生成加密后的JWT令牌,生成的结果中包含令牌前缀,如"Bearer " + * + * @param claims 令牌中携带的数据 + * @return 生成后的令牌信息 + */ + public static String generateToken(Map claims, String signingKey) { + return generateToken(claims, TOKEN_EXPIRATION, signingKey); + } + + /** + * 获取token中的数据对象 + * + * @param token 令牌信息(需要包含令牌前缀,如"Bearer ") + * @return 令牌中的数据对象,解析视频返回null。 + */ + public static Claims parseToken(String token, String signingKey) { + if (token == null || !token.startsWith(TOKEN_PREFIX)) { + return null; + } + String tokenKey = token.substring(TOKEN_PREFIX.length()); + Claims claims = null; + try { + SecretKey sk = Keys.hmacShaKeyFor(signingKey.getBytes()); + claims = Jwts.parser().verifyWith(sk).build().parseSignedClaims(tokenKey).getPayload(); + } catch (Exception e) { + log.error("Token Expired", e); + } + return claims; + } + + /** + * 判断令牌是否过期 + * + * @param claims 令牌解密后的Map对象。 + * @return true 过期,否则false。 + */ + public static boolean isNullOrExpired(Claims claims) { + return claims == null || claims.getExpiration().before(new Date()); + } + + /** + * 判断解密后的Token payload是否需要被强制刷新,如果需要,则调用generateToken方法重新生成Token。 + * + * @param claims Token解密后payload数据 + * @return true 需要刷新,否则false + */ + public static boolean needToRefresh(Claims claims) { + if (claims == null) { + return false; + } + Long createTime = (Long) claims.get(CLAIM_KEY_CREATEDTIME); + return createTime == null || System.currentTimeMillis() - createTime > REFRESH_TOKEN_INTERVAL; + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private JwtUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/LogMessageUtil.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/LogMessageUtil.java new file mode 100644 index 00000000..b89dd09b --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/LogMessageUtil.java @@ -0,0 +1,33 @@ +package com.orangeforms.common.core.util; + +/** + * 拼接日志消息的工具类。 + * 主要目标是,尽量保证日志输出的统一性,同时也可以有效减少与日志信息相关的常量字符串, + * 提高代码的规范度和可维护性。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class LogMessageUtil { + + /** + * RPC调用错误格式。 + */ + private static final String RPC_ERROR_MSG_FORMAT = "RPC Failed with Error message [%s]"; + + /** + * 组装RPC调用的错误信息。 + * + * @param errorMsg 具体的错误信息。 + * @return 格式化后的错误信息。 + */ + public static String makeRpcError(String errorMsg) { + return String.format(RPC_ERROR_MSG_FORMAT, errorMsg); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private LogMessageUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/MaskFieldHandler.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/MaskFieldHandler.java new file mode 100644 index 00000000..e1d3bc4b --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/MaskFieldHandler.java @@ -0,0 +1,21 @@ +package com.orangeforms.common.core.util; + +/** + * 自定义脱敏处理器接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface MaskFieldHandler { + + /** + * 处理自定义的脱敏数据。可以根据表名和字段名,使用不同的自定义脱敏规则。 + * + * @param modelName 脱敏字段所在实体对象名。 + * @param fieldName 脱敏实体对象名中的字段属性名。 + * @param data 待脱敏的数据。 + * @param maskChar 脱敏掩码字符。 + * @return 脱敏后的数据。 + */ + String handleMask(String modelName, String fieldName, String data, char maskChar); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/MaskFieldUtil.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/MaskFieldUtil.java new file mode 100644 index 00000000..830aa2ff --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/MaskFieldUtil.java @@ -0,0 +1,203 @@ +package com.orangeforms.common.core.util; + +import cn.hutool.core.util.CharUtil; +import cn.hutool.core.util.StrUtil; + +/** + * 脱敏的工具类。具体实现的源码基本来自hutool的DesensitizedUtil, + * 只是因为我们需要支持自定义脱敏字符,因此需要重写hutool中的工具类方法。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class MaskFieldUtil { + + /** + * 【中文姓名】只显示第一个汉字,其他隐藏为2个星号,比如:李**。 + * + * @param fullName 姓名。 + * @param maskChar 遮掩字符。 + * @return 脱敏后的姓名。 + */ + public static String chineseName(String fullName, char maskChar) { + if (StrUtil.isBlank(fullName)) { + return StrUtil.EMPTY; + } + return StrUtil.replace(fullName, 1, fullName.length(), maskChar); + } + + /** + * 【身份证号】前1位 和后2位。 + * + * @param idCardNum 身份证。 + * @param front 保留:前面的front位数;从1开始。 + * @param end 保留:后面的end位数;从1开始。 + * @param maskChar 遮掩字符。 + * @return 脱敏后的身份证。 + */ + public static String idCardNum(String idCardNum, int front, int end, char maskChar) { + return noMaskPrefixAndSuffix(idCardNum, front, end, maskChar); + } + + /** + * 字符串的前front位和后end位的字符,不会被脱敏。 + * + * @param str 原字符串。 + * @param front 保留:前面的front位数;从1开始。 + * @param end 保留:后面的end位数;从1开始。 + * @param maskChar 遮掩字符。 + * @return 脱敏后的结果字符串。 + */ + public static String noMaskPrefixAndSuffix(String str, int front, int end, char maskChar) { + //身份证不能为空 + if (StrUtil.isBlank(str)) { + return StrUtil.EMPTY; + } + //需要截取的长度不能大于身份证号长度 + if ((front + end) > str.length()) { + return StrUtil.EMPTY; + } + //需要截取的不能小于0 + if (front < 0 || end < 0) { + return StrUtil.EMPTY; + } + return StrUtil.replace(str, front, str.length() - end, maskChar); + } + + /** + * 【固定电话 前四位,后两位。 + * + * @param num 固定电话。 + * @param maskChar 遮掩字符。 + * @return 脱敏后的固定电话。 + */ + public static String fixedPhone(String num, char maskChar) { + if (StrUtil.isBlank(num)) { + return StrUtil.EMPTY; + } + return StrUtil.replace(num, 4, num.length() - 2, maskChar); + } + + /** + * 【手机号码】前三位,后4位,其他隐藏,比如135****2210。 + * + * @param num 移动电话。 + * @param maskChar 遮掩字符。 + * @return 脱敏后的移动电话。 + */ + public static String mobilePhone(String num, char maskChar) { + if (StrUtil.isBlank(num)) { + return StrUtil.EMPTY; + } + return StrUtil.replace(num, 3, num.length() - 4, maskChar); + } + + /** + * 【地址】只显示到地区,不显示详细地址,比如:北京市海淀区****。 + * + * @param address 家庭住址。 + * @param sensitiveSize 敏感信息长度。 + * @param maskChar 遮掩字符。 + * @return 脱敏后的家庭地址。 + */ + public static String address(String address, int sensitiveSize, char maskChar) { + if (StrUtil.isBlank(address)) { + return StrUtil.EMPTY; + } + int length = address.length(); + return StrUtil.replace(address, length - sensitiveSize, length, maskChar); + } + + /** + * 【电子邮箱】邮箱前缀仅显示第一个字母,前缀其他隐藏,用星号代替,@及后面的地址显示,比如:d**@126.com。 + * + * @param email 邮箱。 + * @param maskChar 遮掩字符。 + * @return 脱敏后的邮箱。 + */ + public static String email(String email, char maskChar) { + if (StrUtil.isBlank(email)) { + return StrUtil.EMPTY; + } + int index = StrUtil.indexOf(email, '@'); + if (index <= 1) { + return email; + } + return StrUtil.replace(email, 1, index, maskChar); + } + + /** + * 【密码】密码的全部字符都用*代替,比如:******。 + * + * @param password 密码。 + * @return 脱敏后的密码。 + */ + public static String password(String password) { + if (StrUtil.isBlank(password)) { + return StrUtil.EMPTY; + } + return StrUtil.repeat('*', password.length()); + } + + /** + * 【中国车牌】车牌中间用*代替。 + * eg1:null -》 "" + * eg1:"" -》 "" + * eg3:苏D40000 -》 苏D4***0 + * eg4:陕A12345D -》 陕A1****D + * eg5:京A123 -》 京A123 如果是错误的车牌,不处理。 + * + * @param carLicense 完整的车牌号。 + * @param maskChar 遮掩字符。 + * @return 脱敏后的车牌。 + */ + public static String carLicense(String carLicense, char maskChar) { + if (StrUtil.isBlank(carLicense)) { + return StrUtil.EMPTY; + } + // 普通车牌 + if (carLicense.length() == 7) { + carLicense = StrUtil.replace(carLicense, 3, 6, maskChar); + } else if (carLicense.length() == 8) { + // 新能源车牌 + carLicense = StrUtil.replace(carLicense, 3, 7, maskChar); + } + return carLicense; + } + + /** + * 银行卡号脱敏。 + * eg: 1101 **** **** **** 3256。 + * + * @param bankCardNo 银行卡号。 + * @param maskChar 遮掩字符。 + * @return 脱敏之后的银行卡号。 + */ + public static String bankCard(String bankCardNo, char maskChar) { + if (StrUtil.isBlank(bankCardNo)) { + return bankCardNo; + } + bankCardNo = StrUtil.trim(bankCardNo); + if (bankCardNo.length() < 9) { + return bankCardNo; + } + final int length = bankCardNo.length(); + final int midLength = length - 8; + final StringBuilder buf = new StringBuilder(); + buf.append(bankCardNo, 0, 4); + for (int i = 0; i < midLength; ++i) { + if (i % 4 == 0) { + buf.append(CharUtil.SPACE); + } + buf.append(maskChar); + } + buf.append(CharUtil.SPACE).append(bankCardNo, length - 4, length); + return buf.toString(); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private MaskFieldUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/MyCommonUtil.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/MyCommonUtil.java new file mode 100644 index 00000000..fa97c514 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/MyCommonUtil.java @@ -0,0 +1,442 @@ +package com.orangeforms.common.core.util; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ReflectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.crypto.digest.DigestUtil; +import com.orangeforms.common.core.constant.AppDeviceType; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.validator.AddGroup; +import com.orangeforms.common.core.validator.UpdateGroup; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.ConstraintViolation; +import jakarta.validation.Validation; +import jakarta.validation.Validator; +import jakarta.validation.groups.Default; +import java.lang.reflect.Field; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 脚手架中常用的基本工具方法集合,一般而言工程内部使用的方法。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class MyCommonUtil { + + private static final Validator VALIDATOR; + + static { + VALIDATOR = Validation.buildDefaultValidatorFactory().getValidator(); + } + + /** + * 创建uuid。 + * + * @return 返回uuid。 + */ + public static String generateUuid() { + return UUID.randomUUID().toString().replace("-", ""); + } + + /** + * 对用户密码进行加盐后加密。 + * + * @param password 明文密码。 + * @param passwordSalt 盐值。 + * @return 加密后的密码。 + */ + public static String encrptedPassword(String password, String passwordSalt) { + return DigestUtil.md5Hex(password + passwordSalt); + } + + /** + * 这个方法一般用于Controller对于入口参数的基本验证。 + * 对于字符串,如果为空字符串,也将视为Blank,同时返回true。 + * + * @param objs 一组参数。 + * @return 返回是否存在null或空字符串的参数。 + */ + public static boolean existBlankArgument(Object...objs) { + for (Object obj : objs) { + if (MyCommonUtil.isBlankOrNull(obj)) { + return true; + } + } + return false; + } + + /** + * 结果和 existBlankArgument 相反。 + * + * @param objs 一组参数。 + * @return 返回是否存在null或空字符串的参数。 + */ + public static boolean existNotBlankArgument(Object...objs) { + for (Object obj : objs) { + if (!MyCommonUtil.isBlankOrNull(obj)) { + return true; + } + } + return false; + } + + /** + * 验证参数是否为空。 + * + * @param obj 待判断的参数。 + * @return 空或者null返回true,否则false。 + */ + public static boolean isBlankOrNull(Object obj) { + if (obj instanceof Collection) { + return CollUtil.isEmpty((Collection) obj); + } + return obj == null || (obj instanceof CharSequence && StrUtil.isBlank((CharSequence) obj)); + } + + /** + * 验证参数是否为非空。 + * + * @param obj 待判断的参数。 + * @return 空或者null返回false,否则true。 + */ + public static boolean isNotBlankOrNull(Object obj) { + return !isBlankOrNull(obj); + } + + /** + * 判断source是否等于其中任何一个对象值。 + * + * @param source 源对象。 + * @param others 其他对象。 + * @return 等于其中任何一个返回true,否则false。 + */ + public static boolean equalsAny(Object source, Object...others) { + for (Object one : others) { + if (ObjectUtil.equal(source, one)) { + return true; + } + } + return false; + } + + /** + * 判断模型对象是否通过校验,没有通过返回具体的校验错误信息。 + * + * @param model 带校验的model。 + * @param groups Validate绑定的校验组。 + * @return 没有错误返回null,否则返回具体的错误信息。 + */ + public static String getModelValidationError(T model, Class...groups) { + if (model != null) { + Set> constraintViolations = VALIDATOR.validate(model, groups); + if (!constraintViolations.isEmpty()) { + Iterator> it = constraintViolations.iterator(); + ConstraintViolation constraint = it.next(); + return constraint.getMessage(); + } + } + return null; + } + + /** + * 判断模型对象是否通过校验,没有通过返回具体的校验错误信息。 + * + * @param model 带校验的model。 + * @param forUpdate 是否为更新。 + * @return 没有错误返回null,否则返回具体的错误信息。 + */ + public static String getModelValidationError(T model, boolean forUpdate) { + if (model != null) { + Set> constraintViolations; + if (forUpdate) { + constraintViolations = VALIDATOR.validate(model, Default.class, UpdateGroup.class); + } else { + constraintViolations = VALIDATOR.validate(model, Default.class, AddGroup.class); + } + if (!constraintViolations.isEmpty()) { + Iterator> it = constraintViolations.iterator(); + ConstraintViolation constraint = it.next(); + return constraint.getMessage(); + } + } + return null; + } + + /** + * 判断模型对象是否通过校验,没有通过返回具体的校验错误信息。 + * + * @param modelList 带校验的model列表。 + * @param groups Validate绑定的校验组。 + * @return 没有错误返回null,否则返回具体的错误信息。 + */ + public static String getModelValidationError(List modelList, Class... groups) { + if (CollUtil.isNotEmpty(modelList)) { + for (T model : modelList) { + String errorMessage = getModelValidationError(model, groups); + if (StrUtil.isNotBlank(errorMessage)) { + return errorMessage; + } + } + } + return null; + } + + /** + * 判断模型对象是否通过校验,没有通过返回具体的校验错误信息。 + * + * @param modelList 带校验的model列表。 + * @param forUpdate 是否为更新。 + * @return 没有错误返回null,否则返回具体的错误信息。 + */ + public static String getModelValidationError(List modelList, boolean forUpdate) { + if (CollUtil.isNotEmpty(modelList)) { + for (T model : modelList) { + String errorMessage = getModelValidationError(model, forUpdate); + if (StrUtil.isNotBlank(errorMessage)) { + return errorMessage; + } + } + } + return null; + } + + /** + * 拼接参数中的字符串列表,用指定分隔符进行分割,同时每个字符串对象用单引号括起来。 + * + * @param dataList 字符串集合。 + * @param separator 分隔符。 + * @return 拼接后的字符串。 + */ + public static String joinString(Collection dataList, final char separator) { + int index = 0; + StringBuilder sb = new StringBuilder(128); + for (String data : dataList) { + sb.append("'").append(data).append("'"); + if (index++ != dataList.size() - 1) { + sb.append(separator); + } + } + return sb.toString(); + } + + /** + * 将SQL Like中的通配符替换为字符本身的含义,以便于比较。 + * + * @param str 待替换的字符串。 + * @return 替换后的字符串。 + */ + public static String replaceSqlWildcard(String str) { + if (StrUtil.isBlank(str)) { + return str; + } + return StrUtil.replaceChars(StrUtil.replaceChars(str, "_", "\\_"), "%", "\\%"); + } + + /** + * 获取对象中,非空字段的名字列表。 + * + * @param object 数据对象。 + * @param clazz 数据对象的class类型。 + * @param 数据对象类型。 + * @return 数据对象中,值不为NULL的字段数组。 + */ + public static String[] getNotNullFieldNames(T object, Class clazz) { + Field[] fields = ReflectUtil.getFields(clazz); + List fieldNameList = Arrays.stream(fields) + .filter(f -> ReflectUtil.getFieldValue(object, f) != null) + .map(Field::getName).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(fieldNameList)) { + return fieldNameList.toArray(new String[]{}); + } + return new String[]{}; + } + + /** + * 获取请求头中的设备信息。 + * + * @return 设备类型,具体值可参考AppDeviceType常量类。 + */ + public static int getDeviceType() { + // 缺省都按照Web登录方式设置,如果前端header中的值为不合法值,这里也不会报错,而是使用Web缺省方式。 + int deviceType = AppDeviceType.WEB; + String deviceTypeString = ContextUtil.getHttpRequest().getHeader("deviceType"); + if (StrUtil.isNotBlank(deviceTypeString)) { + Integer type = Integer.valueOf(deviceTypeString); + if (AppDeviceType.isValid(type)) { + deviceType = type; + } + } + return deviceType; + } + + /** + * 获取请求头中的设备信息。 + * + * @return 设备类型,具体值可参考AppDeviceType常量类。 + */ + public static String getDeviceTypeWithString() { + // 缺省都按照Web登录方式设置,如果前端header中的值为不合法值,这里也不会报错,而是使用Web缺省方式。 + int deviceType = AppDeviceType.WEB; + String deviceTypeString = ContextUtil.getHttpRequest().getHeader("deviceType"); + if (StrUtil.isNotBlank(deviceTypeString)) { + Integer type = Integer.valueOf(deviceTypeString); + if (AppDeviceType.isValid(type)) { + deviceType = type; + } + } + return AppDeviceType.getDeviceTypeName(deviceType); + } + + /** + * 获取第三方应用的编码。 + * + * @return 第三方应用编码。 + */ + public static String getAppCodeFromRequest() { + HttpServletRequest request = ContextUtil.getHttpRequest(); + String appCode = request.getHeader("AppCode"); + if (StrUtil.isBlank(appCode)) { + appCode = request.getParameter("AppCode"); + } + return appCode; + } + + /** + * 获取用户身份令牌。 + * + * @param tokenKey 令牌的Key。 + * @return 用户身份令牌。 + */ + public static String getTokenFromRequest(String tokenKey) { + HttpServletRequest request = ContextUtil.getHttpRequest(); + String token = request.getHeader(tokenKey); + if (StrUtil.isBlank(token)) { + token = request.getParameter(tokenKey); + } + if (StrUtil.isBlank(token)) { + token = request.getHeader(ApplicationConstant.HTTP_HEADER_INTERNAL_TOKEN); + } + return token; + } + + /** + * 转换为字典格式的数据列表。 + * + * @param dataList 源数据列表。 + * @param idGetter 获取字典Id字段值的函数方法。 + * @param nameGetter 获取字典名字段值的函数方法。 + * @param 源数据对象类型。 + * @param 字典Id的类型。 + * @return 字典格式的数据列表。 + */ + public static List> toDictDataList( + Collection dataList, Function idGetter, Function nameGetter) { + if (CollUtil.isEmpty(dataList)) { + return new LinkedList<>(); + } + return dataList.stream().map(item -> { + Map dataMap = new HashMap<>(2); + dataMap.put(ApplicationConstant.DICT_ID, idGetter.apply(item)); + dataMap.put(ApplicationConstant.DICT_NAME, nameGetter.apply(item)); + return dataMap; + }).collect(Collectors.toList()); + } + + /** + * 转换为树形字典格式的数据列表。 + * + * @param dataList 源数据列表。 + * @param idGetter 获取字典Id字段值的函数方法。 + * @param nameGetter 获取字典名字段值的函数方法。 + * @param parentIdGetter 获取字典Id父字段值的函数方法。 + * @param 源数据对象类型。 + * @param 字典Id的类型。 + * @return 字典格式的数据列表。 + */ + public static List> toDictDataList( + Collection dataList, + Function idGetter, + Function nameGetter, + Function parentIdGetter) { + if (CollUtil.isEmpty(dataList)) { + return new LinkedList<>(); + } + return dataList.stream().map(item -> { + Map dataMap = new HashMap<>(2); + dataMap.put(ApplicationConstant.DICT_ID, idGetter.apply(item)); + dataMap.put(ApplicationConstant.DICT_NAME, nameGetter.apply(item)); + dataMap.put(ApplicationConstant.PARENT_ID, parentIdGetter.apply(item)); + return dataMap; + }).collect(Collectors.toList()); + } + + /** + * 转换为字典格式的数据列表,同时支持一个附加字段。 + * + * @param dataList 源数据列表。 + * @param idGetter 获取字典Id字段值的函数方法。 + * @param nameGetter 获取字典名字段值的函数方法。 + * @param extraName 附加字段名。。 + * @param extraGetter 获取附加字段值的函数方法。 + * @param 源数据对象类型。 + * @param 字典Id的类型。 + * @param 附加字段值的类型。 + * @return 字典格式的数据列表。 + */ + public static List> toDictDataList( + Collection dataList, + Function idGetter, + Function nameGetter, + String extraName, + Function extraGetter) { + if (CollUtil.isEmpty(dataList)) { + return new LinkedList<>(); + } + return dataList.stream().map(item -> { + Map dataMap = new HashMap<>(2); + dataMap.put(ApplicationConstant.DICT_ID, idGetter.apply(item)); + dataMap.put(ApplicationConstant.DICT_NAME, nameGetter.apply(item)); + dataMap.put(extraName, extraGetter.apply(item)); + return dataMap; + }).collect(Collectors.toList()); + } + + /** + * 将SQL查询条件中的变量值替换为SQL拼接的字符串值。 + * + * @param value 参数值。 + * @return 转换后的参数字符串。 + */ + public static String convertSqlParamValue(Object value) { + if (value == null) { + return "null"; + } + if (value instanceof Number) { + return String.valueOf(value); + } + if (value instanceof Boolean) { + return String.valueOf(value.equals(Boolean.TRUE) ? 1 : 0); + } + StringBuilder builder = new StringBuilder(); + builder.append("'"); + if (value instanceof Date) { + builder.append(DateUtil.format((Date) value, MyDateUtil.COMMON_SHORT_DATETIME_FORMAT)); + } else if (value instanceof String) { + builder.append(value); + } + builder.append("'"); + return builder.toString(); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private MyCommonUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/MyCustomMaskFieldHandler.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/MyCustomMaskFieldHandler.java new file mode 100644 index 00000000..3f4c2c1a --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/MyCustomMaskFieldHandler.java @@ -0,0 +1,23 @@ +package com.orangeforms.common.core.util; + +import org.springframework.stereotype.Component; + +/** + * 缺省的自定义脱敏处理器的实现类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class MyCustomMaskFieldHandler implements MaskFieldHandler { + + @Override + public String handleMask(String modelName, String fieldName, String data, char maskChar) { + // 这里是我们默认提供的躺平实现方式。 + // 在默认生成的代码中,如果脱敏字段的处理类型为CUSTOM的时候,就会暂时使用 + // 该类为默认实现,其实这里就是一个占位符实现类。用户可根据需求自行实现自己所需的脱敏处理器实现类。 + // 实现后,可在脱敏字段的MaskField注解的handler参数中,改为自己的实现类。 + // 最后一句很重要,实现类必须是bean对象,如当前类用@Component注解标记。 + throw new UnsupportedOperationException("请仔细阅读上面的代码注解,并实现自己的处理类,以替代默认生成的自定义实现类!!"); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/MyDateUtil.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/MyDateUtil.java new file mode 100644 index 00000000..033c5178 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/MyDateUtil.java @@ -0,0 +1,320 @@ +package com.orangeforms.common.core.util; + +import com.orangeforms.common.core.object.Tuple2; +import org.apache.commons.lang3.time.DateUtils; +import org.joda.time.DateTime; +import org.joda.time.Period; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; + +import java.util.Calendar; +import java.util.Date; + +import static org.joda.time.PeriodType.days; + +/** + * 日期工具类,主要封装了部分joda-time中的方法,让很多代码一行完成,同时统一了日期到字符串的pattern格式。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class MyDateUtil { + + /** + * 统一的日期pattern,今后可以根据自己的需求去修改。 + */ + public static final String COMMON_DATE_FORMAT = "yyyy-MM-dd"; + /** + * 统一的日期时间pattern,今后可以根据自己的需求去修改。 + */ + public static final String COMMON_DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS"; + /** + * 统一的短日期时间pattern,今后可以根据自己的需求去修改。 + */ + public static final String COMMON_SHORT_DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; + /** + * 缺省日期格式化器,提前获取提升运行时效率。 + */ + private static final DateTimeFormatter DATE_PARSE_FORMATTER = + DateTimeFormat.forPattern(MyDateUtil.COMMON_DATE_FORMAT); + /** + * 缺省日期时间格式化器,提前获取提升运行时效率。 + */ + private static final DateTimeFormatter DATETIME_PARSE_FORMATTER = + DateTimeFormat.forPattern(MyDateUtil.COMMON_DATETIME_FORMAT); + + /** + * 缺省短日期时间格式化器,提前获取提升运行时效率。 + */ + private static final DateTimeFormatter DATETIME_SHORT_PARSE_FORMATTER = + DateTimeFormat.forPattern(MyDateUtil.COMMON_SHORT_DATETIME_FORMAT); + + /** + * 获取一天的开始时间的字符串格式,如2019-08-03 00:00:00.000。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getBeginTimeOfDay(DateTime dateTime) { + return dateTime.withTimeAtStartOfDay().toString(COMMON_DATETIME_FORMAT); + } + + /** + * 获取一天的结束时间的字符串格式,如2019-08-03 23:59:59.999。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getEndTimeOfDay(DateTime dateTime) { + return dateTime.withTime(23, 59, 59, 999).toString(COMMON_DATETIME_FORMAT); + } + + /** + * 获取一天的开始时间的字符串短格式,如2019-08-03 00:00:00。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getBeginTimeOfDayWithShort(DateTime dateTime) { + return dateTime.withTimeAtStartOfDay().toString(COMMON_SHORT_DATETIME_FORMAT); + } + + /** + * 获取一天的结束时间的字符串短格式,如2019-08-03 23:59:59。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getEndTimeOfDayWithShort(DateTime dateTime) { + return dateTime.withTime(23, 59, 59, 999).toString(COMMON_SHORT_DATETIME_FORMAT); + } + + /** + * 获取参数时间对象所在周的第一天的日期时间短格式。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getBeginDateTimeOfWeek(DateTime dateTime) { + return getBeginTimeOfDayWithShort(dateTime.dayOfWeek().withMinimumValue()); + } + + /** + * 获取参数时间对象所在周的结束时间的字符串短格式。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getEndDateTimeOfWeek(DateTime dateTime) { + return getEndTimeOfDayWithShort(dateTime.dayOfWeek().withMaximumValue()); + } + + /** + * 获取参数时间对象所在月份第一天的日期时间短格式。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getBeginDateTimeOfMonth(DateTime dateTime) { + return getBeginTimeOfDayWithShort(dateTime.dayOfMonth().withMinimumValue()); + } + + /** + * 获取参数时间对象所在月份的结束时间的字符串短格式, + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getEndDateTimeOfMonth(DateTime dateTime) { + return getEndTimeOfDayWithShort(dateTime.dayOfMonth().withMaximumValue()); + } + + /** + * 获取参数时间对象所在年的第一天的日期时间短格式。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getBeginDateTimeOfYear(DateTime dateTime) { + return getBeginTimeOfDayWithShort(dateTime.dayOfYear().withMinimumValue()); + } + + /** + * 获取参数时间对象所在年的结束时间的字符串短格式。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getEndDateTimeOfYear(DateTime dateTime) { + return getEndTimeOfDayWithShort(dateTime.dayOfYear().withMaximumValue()); + } + + + /** + * 获取参数时间对象所在季度的第一天的日期时间短格式。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getBeginDateTimeOfQuarter(DateTime dateTime) { + int m = dateTime.getMonthOfYear(); + int m2 = 10; + if (m >= 1 && m <= 3) { + m2 = 1; + } else if (m >= 4 && m <= 6) { + m2 = 4; + } else if (m >= 7 && m <= 9) { + m2 = 7; + } + return getBeginTimeOfDayWithShort(dateTime.withMonthOfYear(m2).dayOfMonth().withMinimumValue()); + } + + /** + * 获取参数时间对象所在季度的结束时间的字符串短格式, + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getEndDateTimeOfQuarter(DateTime dateTime) { + int m = dateTime.getMonthOfYear(); + int m2 = 12; + if (m >= 1 && m <= 3) { + m2 = 3; + } else if (m >= 4 && m <= 6) { + m2 = 6; + } else if (m >= 7 && m <= 9) { + m2 = 9; + } + return getEndTimeOfDayWithShort(dateTime.withMonthOfYear(m2).dayOfMonth().withMaximumValue()); + } + + /** + * 获取一天中的开始时间和结束时间的字符串格式,如2019-08-03 00:00:00.000 和 2019-08-03 23:59:59.999。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 包含格式后字符串的二元组对象。 + */ + public static Tuple2 getDateTimeRangeOfDay(DateTime dateTime) { + return new Tuple2<>(getBeginTimeOfDay(dateTime), getEndTimeOfDay(dateTime)); + } + + /** + * 获取本月第一天的日期格式。如2019-08-01。 + * + * @param dateTime 待格式化的日期对象。 + * @return 格式化后的字符串。 + */ + public static String getBeginDateOfMonth(DateTime dateTime) { + return dateTime.withDayOfMonth(1).toString(COMMON_DATE_FORMAT); + } + + /** + * 获取本月第一天的日期格式。如2019-08-01。 + * + * @param dateString 待格式化的日期字符串对象。 + * @return 格式化后的字符串。 + */ + public static String getBeginDateOfMonth(String dateString) { + DateTime dateTime = toDate(dateString); + return dateTime.withDayOfMonth(1).toString(COMMON_DATE_FORMAT); + } + + /** + * 计算指定日期距离今天相差的天数。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 相差天数。 + */ + public static int getDayDiffToNow(DateTime dateTime) { + return new Period(dateTime, new DateTime(), days()).getDays(); + } + + /** + * 将日期对象格式化为缺省的字符串格式。 + * + * @param dateTime 待格式化的日期对象。 + * @return 格式化后的字符串。 + */ + public static String toDateString(DateTime dateTime) { + return dateTime.toString(COMMON_DATE_FORMAT); + } + + /** + * 将日期时间对象格式化为缺省的字符串格式。 + * + * @param dateTime 待格式化的日期对象。 + * @return 格式化后的字符串。 + */ + public static String toDateTimeString(DateTime dateTime) { + return dateTime.toString(COMMON_DATETIME_FORMAT); + } + + /** + * 将缺省格式的日期字符串解析为日期对象。 + * + * @param dateString 待解析的字符串。 + * @return 解析后的日期对象。 + */ + public static DateTime toDate(String dateString) { + return DATE_PARSE_FORMATTER.parseDateTime(dateString); + } + + /** + * 将缺省格式的日期字符串解析为日期对象。 + * + * @param dateTimeString 待解析的字符串。 + * @return 解析后的日期对象。 + */ + public static DateTime toDateTime(String dateTimeString) { + return DATETIME_PARSE_FORMATTER.parseDateTime(dateTimeString); + } + + /** + * 将缺省格式的(不包含毫秒的)日期时间字符串解析为日期对象。 + * + * @param dateTimeString 待解析的字符串。 + * @return 解析后的日期对象。 + */ + public static DateTime toDateTimeWithoutMs(String dateTimeString) { + return DATETIME_SHORT_PARSE_FORMATTER.parseDateTime(dateTimeString); + } + + /** + * 截取时间到天。如2019-10-03 01:20:30 转换为 2019-10-03 00:00:00。 + * 由于没有字符串的中间转换,因此效率更高。 + * + * @param date 待截取日期对象。 + * @return 转换后日期对象。 + */ + public static Date truncateToDay(Date date) { + return DateUtils.truncate(date, Calendar.DAY_OF_MONTH); + } + + /** + * 截取时间到月。如2019-10-03 01:20:30 转换为 2019-10-01 00:00:00。 + * 由于没有字符串的中间转换,因此效率更高。 + * + * @param date 待截取日期对象。 + * @return 转换后日期对象。 + */ + public static Date truncateToMonth(Date date) { + return DateUtils.truncate(date, Calendar.MONTH); + } + + /** + * 截取时间到年。如2019-10-03 01:20:30 转换为 2019-01-01 00:00:00。 + * 由于没有字符串的中间转换,因此效率更高。 + * + * @param date 待截取日期对象。 + * @return 转换后日期对象。 + */ + public static Date truncateToYear(Date date) { + return DateUtils.truncate(date, Calendar.YEAR); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private MyDateUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/MyModelUtil.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/MyModelUtil.java new file mode 100644 index 00000000..0d80d772 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/MyModelUtil.java @@ -0,0 +1,875 @@ +package com.orangeforms.common.core.util; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.ReflectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.mybatisflex.annotation.Column; +import com.mybatisflex.annotation.Id; +import com.mybatisflex.annotation.Table; +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.core.exception.InvalidDataFieldException; +import com.orangeforms.common.core.annotation.*; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.object.Tuple2; +import com.orangeforms.common.core.upload.UploadResponseInfo; +import com.orangeforms.common.core.upload.UploadStoreInfo; +import com.google.common.base.CaseFormat; +import lombok.extern.slf4j.Slf4j; + +import java.io.Serializable; +import java.lang.reflect.Field; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 负责Model数据操作、类型转换和关系关联等行为的工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class MyModelUtil { + + /** + * 数值型字段。 + */ + public static final Integer NUMERIC_FIELD_TYPE = 0; + /** + * 字符型字段。 + */ + public static final Integer STRING_FIELD_TYPE = 1; + /** + * 日期型字段。 + */ + public static final Integer DATE_FIELD_TYPE = 2; + /** + * 整个工程的实体对象中,创建者Id字段的Java对象名。 + */ + public static final String CREATE_USER_ID_FIELD_NAME = "createUserId"; + /** + * 整个工程的实体对象中,创建时间字段的Java对象名。 + */ + public static final String CREATE_TIME_FIELD_NAME = "createTime"; + /** + * 整个工程的实体对象中,更新者Id字段的Java对象名。 + */ + public static final String UPDATE_USER_ID_FIELD_NAME = "updateUserId"; + /** + * 整个工程的实体对象中,更新时间字段的Java对象名。 + */ + public static final String UPDATE_TIME_FIELD_NAME = "updateTime"; + /** + * mapToColumnName和mapToColumnInfo使用的缓存。 + */ + private static final Map> CACHED_COLUMNINFO_MAP = new ConcurrentHashMap<>(); + + /** + * 将Bean转换为Map。 + * + * @param data Bean数据对象。 + * @param Bean对象类型。 + * @return 转换后的Map。 + */ + public static Map beanToMap(T data) { + return BeanUtil.beanToMap(data); + } + + /** + * 将Bean的数据列表转换为Map列表。 + * + * @param dataList Bean数据列表。 + * @param Bean对象类型。 + * @return 转换后的Map列表。 + */ + public static List> beanToMapList(List dataList) { + return CollUtil.isEmpty(dataList) ? new LinkedList<>() + : dataList.stream().map(BeanUtil::beanToMap).collect(Collectors.toList()); + } + + /** + * 将Map的数据列表转换为Bean列表。 + * + * @param dataList Map数据列表。 + * @param Bean对象类型。 + * @return 转换后的Bean对象列表。 + */ + public static List mapToBeanList(List> dataList, Class clazz) { + return CollUtil.isEmpty(dataList) ? new LinkedList<>() + : dataList.stream().map(data -> BeanUtil.toBeanIgnoreError(data, clazz)).collect(Collectors.toList()); + } + + /** + * 拷贝源类型的集合数据到目标类型的集合中,其中源类型和目标类型中的对象字段类型完全相同。 + * NOTE: 该函数主要应用于框架中,Dto和Model之间的copy,特别针对一对一关联的深度copy。 + * 在Dto中,一对一对象可以使用Map来表示,而不需要使用从表对象的Dto。 + * + * @param sourceCollection 源类型集合。 + * @param targetClazz 目标类型的Class对象。 + * @param 源类型。 + * @param 目标类型。 + * @return copy后的目标类型对象集合。 + */ + public static List copyCollectionTo(Collection sourceCollection, Class targetClazz) { + List targetList = null; + if (sourceCollection == null) { + return targetList; + } + targetList = new LinkedList<>(); + if (CollUtil.isNotEmpty(sourceCollection)) { + for (S source : sourceCollection) { + try { + T target = targetClazz.newInstance(); + BeanUtil.copyProperties(source, target); + targetList.add(target); + } catch (Exception e) { + log.error("Failed to call MyModelUtil.copyCollectionTo", e); + return Collections.emptyList(); + } + } + } + return targetList; + } + + /** + * 拷贝源类型的对象数据到目标类型的对象中,其中源类型和目标类型中的对象字段类型完全相同。 + * NOTE: 该函数主要应用于框架中,Dto和Model之间的copy,特别针对一对一关联的深度copy。 + * 在Dto中,一对一对象可以使用Map来表示,而不需要使用从表对象的Dto。 + * + * @param source 源类型对象。 + * @param targetClazz 目标类型的Class对象。 + * @param 源类型。 + * @param 目标类型。 + * @return copy后的目标类型对象。 + */ + public static T copyTo(S source, Class targetClazz) { + if (source == null) { + return null; + } + try { + T target = targetClazz.newInstance(); + BeanUtil.copyProperties(source, target); + return target; + } catch (Exception e) { + log.error("Failed to call MyModelUtil.copyTo", e); + return null; + } + } + + /** + * 映射Model对象的字段反射对象,获取与该字段对应的数据库列名称。 + * + * @param field 字段反射对象。 + * @param modelClazz Model对象的Class类。 + * @return 该字段所对应的数据表列名称。 + */ + public static String mapToColumnName(Field field, Class modelClazz) { + return mapToColumnName(field.getName(), modelClazz); + } + + /** + * 映射Model对象的字段名称,获取与该字段对应的数据库列名称。 + * + * @param fieldName 字段名称。 + * @param modelClazz Model对象的Class类。 + * @return 该字段所对应的数据表列名称。 + */ + public static String mapToColumnName(String fieldName, Class modelClazz) { + Tuple2 columnInfo = mapToColumnInfo(fieldName, modelClazz); + return columnInfo == null ? null : columnInfo.getFirst(); + } + + /** + * 映射Model对象的字段反射对象,获取与该字段对应的数据库列名称。 + * 如果没有匹配到ColumnName,则立刻抛出异常。 + * + * @param field 字段反射对象。 + * @param modelClazz Model对象的Class类。 + * @return 该字段所对应的数据表列名称。 + */ + public static String safeMapToColumnName(Field field, Class modelClazz) { + return safeMapToColumnName(field.getName(), modelClazz); + } + + /** + * 映射Model对象的字段名称,获取与该字段对应的数据库列名称。 + * 如果没有匹配到ColumnName,则立刻抛出异常。 + * + * @param fieldName 字段名称。 + * @param modelClazz Model对象的Class类。 + * @return 该字段所对应的数据表列名称。 + */ + public static String safeMapToColumnName(String fieldName, Class modelClazz) { + String columnName = mapToColumnName(fieldName, modelClazz); + if (columnName == null) { + throw new InvalidDataFieldException(modelClazz.getSimpleName(), fieldName); + } + return columnName; + } + + /** + * 映射Model对象的字段名称,获取与该字段对应的数据库列名称和字段类型。 + * + * @param fieldName 字段名称。 + * @param modelClazz Model对象的Class类。 + * @return 该字段所对应的数据表列名称和Java字段类型。 + */ + public static Tuple2 mapToColumnInfo(String fieldName, Class modelClazz) { + if (StrUtil.isBlank(fieldName)) { + return null; + } + StringBuilder sb = new StringBuilder(128); + sb.append(modelClazz.getName()).append("-#-").append(fieldName); + Tuple2 columnInfo = CACHED_COLUMNINFO_MAP.get(sb.toString()); + if (columnInfo != null) { + return columnInfo; + } + Field field = ReflectUtil.getField(modelClazz, fieldName); + if (field == null) { + return null; + } + Column c = field.getAnnotation(Column.class); + String columnName = null; + if (c == null) { + Id id = field.getAnnotation(Id.class); + if (id != null) { + columnName = id.value(); + } + } + if (StrUtil.isBlank(columnName)) { + columnName = c == null ? CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, fieldName) : c.value(); + if (StrUtil.isBlank(columnName)) { + columnName = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, fieldName); + } + } + // 这里缺省情况下都是按照整型去处理,因为他覆盖太多的类型了。 + // 如Integer/Long/Double/BigDecimal,可根据实际情况完善和扩充。 + String typeName = field.getType().getSimpleName(); + Integer type = NUMERIC_FIELD_TYPE; + if (String.class.getSimpleName().equals(typeName)) { + type = STRING_FIELD_TYPE; + } else if (Date.class.getSimpleName().equals(typeName)) { + type = DATE_FIELD_TYPE; + } + columnInfo = new Tuple2<>(columnName, type); + CACHED_COLUMNINFO_MAP.put(sb.toString(), columnInfo); + return columnInfo; + } + + /** + * 映射Model主对象的Class名称,到Model所对应的表名称。 + * + * @param modelClazz Model主对象的Class。 + * @return Model对象对应的数据表名称。 + */ + public static String mapToTableName(Class modelClazz) { + Table t = modelClazz.getAnnotation(Table.class); + return t == null ? null : t.value(); + } + + /** + * 主Model类型中,遍历所有包含RelationConstDict注解的字段,并将关联的静态字典中的数据, + * 填充到thisModel对象的被注解字段中。 + * + * @param thisClazz 主对象的Class对象。 + * @param thisModel 主对象。 + * @param 主表对象类型。 + */ + @SuppressWarnings("unchecked") + public static void makeConstDictRelation(Class thisClazz, T thisModel) { + if (thisModel == null) { + return; + } + Field[] fields = ReflectUtil.getFields(thisClazz); + for (Field field : fields) { + // 这里不做任何空值判断,从而让配置错误在调试期间即可抛出 + Field thisTargetField = ReflectUtil.getField(thisClazz, field.getName()); + RelationConstDict r = thisTargetField.getAnnotation(RelationConstDict.class); + if (r == null) { + continue; + } + Field dictMapField = ReflectUtil.getField(r.constantDictClass(), "DICT_MAP"); + Map dictMap = + (Map) ReflectUtil.getFieldValue(r.constantDictClass(), dictMapField); + Object id = ReflectUtil.getFieldValue(thisModel, r.masterIdField()); + if (id != null) { + String name = dictMap.get(id); + if (name != null) { + Map m = new HashMap<>(2); + m.put("id", id); + m.put("name", name); + ReflectUtil.setFieldValue(thisModel, thisTargetField, m); + } + } + } + } + + /** + * 主Model类型中,遍历所有包含RelationConstDict注解的字段,并将关联的静态字典中的数据, + * 填充到thisModelList集合元素对象的被注解字段中。 + * + * @param thisClazz 主对象的Class对象。 + * @param thisModelList 主对象列表。 + * @param 主表对象类型。 + */ + @SuppressWarnings("unchecked") + public static void makeConstDictRelation(Class thisClazz, List thisModelList) { + if (CollUtil.isEmpty(thisModelList)) { + return; + } + List thisModelList2 = thisModelList.stream().filter(Objects::nonNull).toList(); + Field[] fields = ReflectUtil.getFields(thisClazz); + for (Field field : fields) { + // 这里不做任何空值判断,从而让配置错误在调试期间即可抛出 + Field thisTargetField = ReflectUtil.getField(thisClazz, field.getName()); + RelationConstDict r = thisTargetField.getAnnotation(RelationConstDict.class); + if (r == null) { + continue; + } + Field dictMapField = ReflectUtil.getField(r.constantDictClass(), "DICT_MAP"); + Map dictMap = + (Map) ReflectUtil.getFieldValue(r.constantDictClass(), dictMapField); + for (T thisModel : thisModelList2) { + Object id = ReflectUtil.getFieldValue(thisModel, r.masterIdField()); + if (id != null) { + String name = dictMap.get(id); + if (name != null) { + Map m = new HashMap<>(2); + m.put("id", id); + m.put("name", name); + ReflectUtil.setFieldValue(thisModel, thisTargetField, m); + } + } + } + } + } + + /** + * 在主Model类型中,根据thisRelationField字段的RelationDict注解参数,将被关联对象thatModel中的数据, + * 关联到thisModel对象的thisRelationField字段中。 + * + * @param thisClazz 主对象的Class对象。 + * @param thisModel 主对象。 + * @param thatModel 字典关联对象。 + * @param thisRelationField 主表对象中保存被关联对象的字段名称。 + * @param 主表对象类型。 + * @param 从表对象类型。 + */ + public static void makeDictRelation( + Class thisClazz, T thisModel, R thatModel, String thisRelationField) { + if (thatModel == null || thisModel == null) { + return; + } + // 这里不做任何空值判断,从而让配置错误在调试期间即可抛出 + Field thisTargetField = ReflectUtil.getField(thisClazz, thisRelationField); + RelationDict r = thisTargetField.getAnnotation(RelationDict.class); + Object slaveId = ReflectUtil.getFieldValue(thatModel, r.slaveIdField()); + if (slaveId != null) { + Map m = new HashMap<>(2); + m.put("id", slaveId); + m.put("name", ReflectUtil.getFieldValue(thatModel, r.slaveNameField())); + ReflectUtil.setFieldValue(thisModel, thisTargetField, m); + } + } + + /** + * 在主Model类型中,根据thisRelationField字段的RelationDict注解参数,将被关联对象集合thatModelList中的数据, + * 逐个关联到thisModelList每一个元素的thisRelationField字段中。 + * + * @param thisClazz 主对象的Class对象。 + * @param thisModelList 主对象列表。 + * @param thatModelList 字典关联对象列表集合。 + * @param thisRelationField 主表对象中保存被关联对象的字段名称。 + * @param 主表对象类型。 + * @param 从表对象类型。 + */ + public static void makeDictRelation( + Class thisClazz, List thisModelList, List thatModelList, String thisRelationField) { + if (CollUtil.isEmpty(thatModelList) || CollUtil.isEmpty(thisModelList)) { + return; + } + // 这里不做任何空值判断,从而让配置错误在调试期间即可抛出 + Field thisTargetField = ReflectUtil.getField(thisClazz, thisRelationField); + RelationDict r = thisTargetField.getAnnotation(RelationDict.class); + Field masterIdField = ReflectUtil.getField(thisClazz, r.masterIdField()); + Class thatClass = r.slaveModelClass(); + Field slaveIdField = ReflectUtil.getField(thatClass, r.slaveIdField()); + Field slaveNameField = ReflectUtil.getField(thatClass, r.slaveNameField()); + Map thatMap = new HashMap<>(20); + thatModelList.forEach(thatModel -> { + Object id = ReflectUtil.getFieldValue(thatModel, slaveIdField); + if (id != null) { + thatMap.put(id, thatModel); + } + }); + thisModelList.forEach(thisModel -> { + if (thisModel != null) { + Object id = ReflectUtil.getFieldValue(thisModel, masterIdField); + if (id != null) { + R thatModel = thatMap.get(id); + if (thatModel != null) { + Map m = new HashMap<>(4); + m.put("id", id); + m.put("name", ReflectUtil.getFieldValue(thatModel, slaveNameField)); + ReflectUtil.setFieldValue(thisModel, thisTargetField, m); + } + } + } + }); + } + + /** + * 在主Model类型中,根据thisRelationField字段的RelationDict注解参数,将被关联对象集合thatModelMap中的数据, + * 逐个关联到thisModelList每一个元素的thisRelationField字段中。 + * 该函数之所以使用Map,主要出于性能优化考虑,在连续使用thatModelMap进行关联时,有效的避免了从多次从List转换到Map的过程。 + * + * @param thisClazz 主对象的Class对象。 + * @param thisModelList 主对象列表。 + * @param thatMadelMap 字典关联对象映射集合。 + * @param thisRelationField 主表对象中保存被关联对象的字段名称。 + * @param 主表对象类型。 + * @param 从表对象类型。 + */ + public static void makeDictRelation( + Class thisClazz, List thisModelList, Map thatMadelMap, String thisRelationField) { + if (MapUtil.isEmpty(thatMadelMap) || CollUtil.isEmpty(thisModelList)) { + return; + } + // 这里不做任何空值判断,从而让配置错误在调试期间即可抛出 + Field thisTargetField = ReflectUtil.getField(thisClazz, thisRelationField); + RelationDict r = thisTargetField.getAnnotation(RelationDict.class); + Field masterIdField = ReflectUtil.getField(thisClazz, r.masterIdField()); + Class thatClass = r.slaveModelClass(); + Field slaveNameField = ReflectUtil.getField(thatClass, r.slaveNameField()); + thisModelList.forEach(thisModel -> { + if (thisModel != null) { + Object id = ReflectUtil.getFieldValue(thisModel, masterIdField); + if (id != null) { + R thatModel = thatMadelMap.get(id); + if (thatModel != null) { + Map m = new HashMap<>(4); + m.put("id", id); + m.put("name", ReflectUtil.getFieldValue(thatModel, slaveNameField)); + ReflectUtil.setFieldValue(thisModel, thisTargetField, m); + } + } + } + }); + } + + /** + * 在主Model类型中,根据thisRelationField字段的RelationGlobalDict注解参数,全局字典dictMap中的字典数据, + * 逐个关联到thisModelList每一个元素的thisRelationField字段中。 + * + * @param thisClazz 主对象的Class对象。 + * @param thisModelList 主对象列表。 + * @param dictMap 全局字典数据。 + * @param thisRelationField 主表对象中保存被关联对象的字段名称。 + * @param 主表对象类型。 + */ + public static void makeGlobalDictRelation( + Class thisClazz, List thisModelList, Map dictMap, String thisRelationField) { + if (MapUtil.isEmpty(dictMap) || CollUtil.isEmpty(thisModelList)) { + return; + } + // 这里不做任何空值判断,从而让配置错误在调试期间即可抛出 + Field thisTargetField = ReflectUtil.getField(thisClazz, thisRelationField); + RelationGlobalDict r = thisTargetField.getAnnotation(RelationGlobalDict.class); + Field masterIdField = ReflectUtil.getField(thisClazz, r.masterIdField()); + thisModelList.forEach(thisModel -> { + if (thisModel != null) { + Object id = ReflectUtil.getFieldValue(thisModel, masterIdField); + if (id != null) { + String name = dictMap.get(id.toString()); + if (name != null) { + Map m = new HashMap<>(2); + m.put("id", id); + m.put("name", name); + ReflectUtil.setFieldValue(thisModel, thisTargetField, m); + } + } + } + }); + } + + /** + * 在主Model类型中,根据thisRelationField字段的RelationOneToOne注解参数,将被关联对象列表thatModelList中的数据, + * 逐个关联到thisModelList每一个元素的thisRelationField字段中。 + * + * @param thisClazz 主对象的Class对象。 + * @param thisModelList 主对象列表。 + * @param thatModelList 一对一关联对象列表。 + * @param thisRelationField 主表对象中保存被关联对象的字段名称。 + * @param 主表对象类型。 + * @param 从表对象类型。 + */ + public static void makeOneToOneRelation( + Class thisClazz, List thisModelList, List thatModelList, String thisRelationField) { + if (CollUtil.isEmpty(thatModelList) || CollUtil.isEmpty(thisModelList)) { + return; + } + // 这里不做任何空值判断,从而让配置错误在调试期间即可抛出 + Field thisTargetField = ReflectUtil.getField(thisClazz, thisRelationField); + RelationOneToOne r = thisTargetField.getAnnotation(RelationOneToOne.class); + Field masterIdField = ReflectUtil.getField(thisClazz, r.masterIdField()); + Class thatClass = r.slaveModelClass(); + Field slaveIdField = ReflectUtil.getField(thatClass, r.slaveIdField()); + Map thatMap = new HashMap<>(20); + thatModelList.forEach(thatModel -> { + Object id = ReflectUtil.getFieldValue(thatModel, slaveIdField); + if (id != null) { + thatMap.put(id, thatModel); + } + }); + thisModelList.forEach(thisModel -> { + Object id = ReflectUtil.getFieldValue(thisModel, masterIdField); + if (id != null) { + R thatModel = thatMap.get(id); + if (thatModel != null) { + if (thisTargetField.getType().equals(Map.class)) { + ReflectUtil.setFieldValue(thisModel, thisTargetField, BeanUtil.beanToMap(thatModel)); + } else { + ReflectUtil.setFieldValue(thisModel, thisTargetField, thatModel); + } + } + } + }); + } + + /** + * 根据主对象和关联对象各自的关联Id函数,将主对象列表和关联对象列表中的数据关联到一起,并将关联对象 + * 设置到主对象的指定关联字段中。 + * NOTE: 用于主对象关联字段中,没有包含RelationOneToOne注解的场景。 + * + * @param thisClazz 主对象的Class对象。 + * @param thisModelList 主对象列表。 + * @param thisIdGetterFunc 主对象Id的Getter函数。 + * @param thatModelList 关联对象列表。 + * @param thatIdGetterFunc 关联对象Id的Getter函数。 + * @param thisRelationField 主对象中保存被关联对象的字段名称。 + * @param 主表对象类型。 + * @param 从表对象类型。 + */ + public static void makeOneToOneRelation( + Class thisClazz, + List thisModelList, + Function thisIdGetterFunc, + List thatModelList, + Function thatIdGetterFunc, + String thisRelationField) { + makeOneToOneRelation(thisClazz, thisModelList, + thisIdGetterFunc, thatModelList, thatIdGetterFunc, thisRelationField, false); + } + + /** + * 根据主对象和关联对象各自的关联Id函数,将主对象列表和关联对象列表中的数据关联到一起,并将关联对象 + * 设置到主对象的指定关联字段中。 + * NOTE: 用于主对象关联字段中,没有包含RelationOneToOne注解的场景。 + * + * @param thisClazz 主对象的Class对象。 + * @param thisModelList 主对象列表。 + * @param thisIdGetterFunc 主对象Id的Getter函数。 + * @param thatModelList 关联对象列表。 + * @param thatIdGetterFunc 关联对象Id的Getter函数。 + * @param thisRelationField 主对象中保存被关联对象的字段名称。 + * @param orderByThatList 如果为true,则按照ThatModelList的顺序输出。同时thisModelList被排序后的新列表替换。 + * @param 主表对象类型。 + * @param 从表对象类型。 + */ + public static void makeOneToOneRelation( + Class thisClazz, + List thisModelList, + Function thisIdGetterFunc, + List thatModelList, + Function thatIdGetterFunc, + String thisRelationField, + boolean orderByThatList) { + if (CollUtil.isEmpty(thisModelList)) { + return; + } + Field thisTargetField = ReflectUtil.getField(thisClazz, thisRelationField); + boolean isMap = thisTargetField.getType().equals(Map.class); + if (orderByThatList) { + List newThisModelList = new LinkedList<>(); + Map thisModelMap = + thisModelList.stream().collect(Collectors.toMap(thisIdGetterFunc, c -> c)); + thatModelList.forEach(thatModel -> { + Object thatId = thatIdGetterFunc.apply(thatModel); + if (thatId != null) { + T thisModel = thisModelMap.get(thatId); + if (thisModel != null) { + ReflectUtil.setFieldValue(thisModel, thisTargetField, normalize(isMap, thatModel)); + newThisModelList.add(thisModel); + } + } + }); + thisModelList.clear(); + thisModelList.addAll(newThisModelList); + return; + } + Map thatMadelMap = + thatModelList.stream().collect(Collectors.toMap(thatIdGetterFunc, c -> c)); + thisModelList.forEach(thisModel -> { + Object thisId = thisIdGetterFunc.apply(thisModel); + if (thisId != null) { + R thatModel = thatMadelMap.get(thisId); + if (thatModel != null) { + ReflectUtil.setFieldValue(thisModel, thisTargetField, normalize(isMap, thatModel)); + } + } + }); + } + + /** + * 在主Model类型中,根据thisRelationField字段的RelationOneToMany注解参数,将被关联对象列表thatModelList中的数据, + * 逐个关联到thisModelList每一个元素的thisRelationField字段中。 + * + * @param thisClazz 主对象的Class对象。 + * @param thisModelList 主对象列表。 + * @param thatModelList 一对多关联对象列表。 + * @param thisRelationField 主表对象中保存被关联对象的字段名称。 + * @param 主表对象类型。 + * @param 从表对象类型。 + */ + public static void makeOneToManyRelation( + Class thisClazz, List thisModelList, List thatModelList, String thisRelationField) { + if (CollUtil.isEmpty(thatModelList) || CollUtil.isEmpty(thisModelList)) { + return; + } + // 这里不做任何空值判断,从而让配置错误在调试期间即可抛出 + Field thisTargetField = ReflectUtil.getField(thisClazz, thisRelationField); + RelationOneToMany r = thisTargetField.getAnnotation(RelationOneToMany.class); + Field masterIdField = ReflectUtil.getField(thisClazz, r.masterIdField()); + Class thatClass = r.slaveModelClass(); + Field slaveIdField = ReflectUtil.getField(thatClass, r.slaveIdField()); + Map> thatMap = new HashMap<>(20); + thatModelList.forEach(thatModel -> { + Object id = ReflectUtil.getFieldValue(thatModel, slaveIdField); + if (id != null) { + List thatModelSubList = thatMap.computeIfAbsent(id, k -> new LinkedList<>()); + thatModelSubList.add(thatModel); + } + }); + thisModelList.forEach(thisModel -> { + Object id = ReflectUtil.getFieldValue(thisModel, masterIdField); + if (id != null) { + List thatModel = thatMap.get(id); + if (thatModel != null) { + ReflectUtil.setFieldValue(thisModel, thisTargetField, thatModel); + } + } + }); + } + + /** + * 在主Model类型中,根据thisRelationField字段的RelationManyToMany注解参数,将被关联对象列表relationModelList中的数据, + * 逐个关联到thisModelList每一个元素的thisRelationField字段中。 + * + * @param thisClazz 主对象的Class对象。 + * @param idFieldName 主表主键Id字段名。 + * @param thisModelList 主对象列表。 + * @param relationModelList 多对多关联对象列表。 + * @param thisRelationField 主表对象中保存被关联对象的字段名称。 + * @param 主表对象类型。 + * @param 关联表对象类型。 + */ + public static void makeManyToManyRelation( + Class thisClazz, String idFieldName, List thisModelList, List relationModelList, String thisRelationField) { + if (CollUtil.isEmpty(relationModelList) || CollUtil.isEmpty(thisModelList)) { + return; + } + // 这里不做任何空值判断,从而让配置错误在调试期间即可抛出 + Field thisTargetField = ReflectUtil.getField(thisClazz, thisRelationField); + RelationManyToMany r = thisTargetField.getAnnotation(RelationManyToMany.class); + Field masterIdField = ReflectUtil.getField(thisClazz, idFieldName); + Class thatClass = r.relationModelClass(); + Field slaveIdField = ReflectUtil.getField(thatClass, r.relationMasterIdField()); + Map> thatMap = new HashMap<>(20); + relationModelList.forEach(thatModel -> { + Object id = ReflectUtil.getFieldValue(thatModel, slaveIdField); + if (id != null) { + thatMap.computeIfAbsent(id, k -> new LinkedList<>()).add(thatModel); + } + }); + thisModelList.forEach(thisModel -> { + Object id = ReflectUtil.getFieldValue(thisModel, masterIdField); + if (id != null) { + List thatModel = thatMap.get(id); + if (thatModel != null) { + ReflectUtil.setFieldValue(thisModel, thisTargetField, thatModel); + } + } + }); + } + + private static Object normalize(boolean isMap, M model) { + return isMap ? BeanUtil.beanToMap(model) : model; + } + + /** + * 获取上传字段的存储信息。 + * + * @param modelClass model的class对象。 + * @param uploadFieldName 上传字段名。 + * @param model的类型。 + * @return 字段的上传存储信息对象。该值始终不会返回null。 + */ + public static UploadStoreInfo getUploadStoreInfo(Class modelClass, String uploadFieldName) { + UploadStoreInfo uploadStoreInfo = new UploadStoreInfo(); + Field uploadField = ReflectUtil.getField(modelClass, uploadFieldName); + if (uploadField == null) { + throw new UnsupportedOperationException("The Field [" + + uploadFieldName + "] doesn't exist in Model [" + modelClass.getSimpleName() + "]."); + } + uploadStoreInfo.setSupportUpload(false); + UploadFlagColumn anno = uploadField.getAnnotation(UploadFlagColumn.class); + if (anno != null) { + uploadStoreInfo.setSupportUpload(true); + uploadStoreInfo.setStoreType(anno.storeType()); + } + return uploadStoreInfo; + } + + /** + * 在插入实体对象数据之前,可以调用该方法,初始化通用字段的数据。 + * + * @param data 实体对象。 + * @param 实体对象类型。 + */ + public static void fillCommonsForInsert(M data) { + Field createdByField = ReflectUtil.getField(data.getClass(), CREATE_USER_ID_FIELD_NAME); + if (createdByField != null) { + ReflectUtil.setFieldValue(data, createdByField, TokenData.takeFromRequest().getUserId()); + } + Field createTimeField = ReflectUtil.getField(data.getClass(), CREATE_TIME_FIELD_NAME); + if (createTimeField != null) { + ReflectUtil.setFieldValue(data, createTimeField, new Date()); + } + Field updatedByField = ReflectUtil.getField(data.getClass(), UPDATE_USER_ID_FIELD_NAME); + if (updatedByField != null) { + ReflectUtil.setFieldValue(data, updatedByField, TokenData.takeFromRequest().getUserId()); + } + Field updateTimeField = ReflectUtil.getField(data.getClass(), UPDATE_TIME_FIELD_NAME); + if (updateTimeField != null) { + ReflectUtil.setFieldValue(data, updateTimeField, new Date()); + } + } + + /** + * 在更新实体对象数据之前,可以调用该方法,更新通用字段的数据。 + * + * @param data 实体对象。 + * @param originalData 原有实体对象。 + * @param 实体对象类型。 + */ + public static void fillCommonsForUpdate(M data, M originalData) { + Object createdByValue = ReflectUtil.getFieldValue(originalData, CREATE_USER_ID_FIELD_NAME); + if (createdByValue != null) { + ReflectUtil.setFieldValue(data, CREATE_USER_ID_FIELD_NAME, createdByValue); + } + Object createTimeValue = ReflectUtil.getFieldValue(originalData, CREATE_TIME_FIELD_NAME); + if (createTimeValue != null) { + ReflectUtil.setFieldValue(data, CREATE_TIME_FIELD_NAME, createTimeValue); + } + Field updatedByField = ReflectUtil.getField(data.getClass(), UPDATE_USER_ID_FIELD_NAME); + if (updatedByField != null) { + ReflectUtil.setFieldValue(data, updatedByField, TokenData.takeFromRequest().getUserId()); + } + Field updateTimeField = ReflectUtil.getField(data.getClass(), UPDATE_TIME_FIELD_NAME); + if (updateTimeField != null) { + ReflectUtil.setFieldValue(data, updateTimeField, new Date()); + } + } + + /** + * 为实体对象字段设置缺省值。如果data对象中指定字段的值为NULL,则设置缺省值,否则跳过。 + * + * @param data 实体对象。 + * @param fieldName 实体对象字段名。 + * @param defaultValue 缺省值。 + * @param 实体对象类型。 + * @param 缺省值类型。 + */ + public static void setDefaultValue(M data, String fieldName, V defaultValue) { + Object v = ReflectUtil.getFieldValue(data, fieldName); + if (v == null) { + ReflectUtil.setFieldValue(data, fieldName, defaultValue); + } + } + + /** + * 获取当前数据对象中,所有上传文件字段的数据,并将上传后的文件名存到集合中并返回。 + * + * @param data 数据对象。 + * @param clazz 数据对象的Class类型。 + * @param 数据对象类型。 + * @return 当前数据对象中,所有上传文件字段中,文件名属性的集合。 + */ + public static Set extractDownloadFileName(M data, Class clazz) { + Set resultSet = new HashSet<>(); + if (data == null) { + return resultSet; + } + Field[] fields = ReflectUtil.getFields(clazz); + for (Field field : fields) { + if (field.isAnnotationPresent(UploadFlagColumn.class)) { + String v = (String) ReflectUtil.getFieldValue(data, field); + List fileInfoList = JSON.parseArray(v, UploadResponseInfo.class); + if (CollUtil.isNotEmpty(fileInfoList)) { + fileInfoList.forEach(fileInfo -> resultSet.add(fileInfo.getFilename())); + } + } + } + return resultSet; + } + + /** + * 获取当前数据对象列表中,所有上传文件字段的数据,并将上传后的文件名存到集合中并返回。 + * + * @param dataList 数据对象。 + * @param clazz 数据对象的Class类型。 + * @param 数据对象类型。 + * @return 当前数据对象中,所有上传文件字段中,文件名属性的集合。 + */ + public static Set extractDownloadFileName(List dataList, Class clazz) { + Set resultSet = new HashSet<>(); + if (CollUtil.isEmpty(dataList)) { + return resultSet; + } + dataList.forEach(data -> resultSet.addAll(extractDownloadFileName(data, clazz))); + return resultSet; + } + + /** + * 根据数据对象指定字段的类型,将参数中的字段值集合转换为匹配的值类型集合。 + * @param clazz 数据对象的Class。 + * @param fieldName 字段名。 + * @param fieldValues 字符型的字段值集合。 + * @param 对象类型。 + * @return 转换后的字段值集合。 + */ + public static Set convertToTypeValues( + Class clazz, String fieldName, List fieldValues) { + Field f = ReflectUtil.getField(clazz, fieldName); + if (f == null) { + String errorMsg = "数据对象 [" + clazz.getSimpleName() + " ] 中,不存在该数据字段 [" + fieldName + "]!"; + throw new MyRuntimeException(errorMsg); + } + if (f.getType().equals(Long.class)) { + return fieldValues.stream().map(Long::valueOf).collect(Collectors.toSet()); + } else if (f.getType().equals(Integer.class)) { + return fieldValues.stream().map(Integer::valueOf).collect(Collectors.toSet()); + } + return new HashSet<>(fieldValues); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private MyModelUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/MyPageUtil.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/MyPageUtil.java new file mode 100644 index 00000000..fc2c7d8f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/MyPageUtil.java @@ -0,0 +1,155 @@ +package com.orangeforms.common.core.util; + +import cn.hutool.core.collection.CollUtil; +import cn.jimmyshi.beanquery.BeanQuery; +import com.alibaba.fastjson.JSONObject; +import com.github.pagehelper.Page; +import org.apache.commons.collections4.CollectionUtils; +import com.orangeforms.common.core.base.mapper.BaseModelMapper; +import com.orangeforms.common.core.object.MyPageData; +import com.orangeforms.common.core.object.Tuple2; + +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 生成带有分页信息的数据列表 + * + * @author Jerry + * @date 2024-07-02 + */ +public class MyPageUtil { + + private static final String DATA_LIST_LITERAL = "dataList"; + private static final String TOTAL_COUNT_LITERAL = "totalCount"; + + /** + * 用户构建带有分页信息的数据列表。 + * + * @param dataList 数据列表,该参数必须是调用PageMethod.startPage之后,立即执行mybatis查询操作的结果集。 + * @param includeFields 结果集中需要返回到前端的字段,多个字段之间逗号分隔。 + * @return 返回只是包含includeFields字段的数据列表,以及结果集TotalCount。 + */ + public static JSONObject makeResponseData(List dataList, String includeFields) { + JSONObject pageData = new JSONObject(); + pageData.put(DATA_LIST_LITERAL, BeanQuery.select(includeFields).from(dataList).execute()); + if (dataList instanceof Page) { + pageData.put(TOTAL_COUNT_LITERAL, ((Page)dataList).getTotal()); + } + return pageData; + } + + /** + * 用户构建带有分页信息的数据列表。 + * + * @param dataList 数据列表,该参数必须是调用PageMethod.startPage之后,立即执行mybatis查询操作的结果集。 + * @return 返回分页数据对象。 + */ + public static MyPageData makeResponseData(List dataList) { + MyPageData pageData = new MyPageData<>(); + pageData.setDataList(dataList); + if (dataList instanceof Page) { + pageData.setTotalCount(((Page)dataList).getTotal()); + } + return pageData; + } + + /** + * 用户构建带有分页信息的数据列表。 + * + * @param dataList 数据列表,该参数必须是调用PageMethod.startPage之后,立即执行mybatis查询操作的结果集。 + * @param totalCount 总数量。 + * @return 返回分页数据对象。 + */ + public static MyPageData makeResponseData(List dataList, Long totalCount) { + MyPageData pageData = new MyPageData<>(); + pageData.setDataList(dataList); + if (totalCount != null) { + pageData.setTotalCount(totalCount); + } + return pageData; + } + + /** + * 用户构建带有分页信息的数据列表。 + * + * @param dataList 实体对象数据列表。 + * @param modelMapper 实体对象到DomainVO对象的数据映射器。 + * @param DomainVO对象类型。 + * @param 实体对象类型。 + * @return 返回分页数据对象。 + */ + public static MyPageData makeResponseData(List dataList, BaseModelMapper modelMapper) { + long totalCount = 0L; + if (CollectionUtils.isEmpty(dataList)) { + // 这里需要构建分页数据对象,统一前端数据格式 + return MyPageData.emptyPageData(); + } + if (dataList instanceof Page) { + totalCount = ((Page) dataList).getTotal(); + } + return MyPageUtil.makeResponseData(modelMapper.fromModelList(dataList), totalCount); + } + + /** + * 构建带有分页信息的数据列表。 + * + * @param dataList 实体对象数据列表。 + * @param converter 转换函数对象。 + * @param 结果类型。 + * @param 实体对象类型。 + * @return 返回分页数据对象。 + */ + public static MyPageData makeResponseData(List dataList, Function converter) { + long totalCount = 0L; + if (CollUtil.isEmpty(dataList)) { + // 这里需要构建分页数据对象,统一前端数据格式 + return MyPageData.emptyPageData(); + } + if (dataList instanceof Page) { + totalCount = ((Page) dataList).getTotal(); + } + List resultList = dataList.stream().map(converter).collect(Collectors.toList()); + return MyPageUtil.makeResponseData(resultList, totalCount); + } + + /** + * 构建带有分页信息的数据列表。 + * + * @param dataList 实体对象数据列表。 + * @param targetClazz 模板对象类型。 + * @param 结果类型。 + * @param 实体对象类型。 + * @return 返回分页数据对象。 + */ + public static MyPageData makeResponseData(List dataList, Class targetClazz) { + long totalCount = 0L; + if (CollUtil.isEmpty(dataList)) { + // 这里需要构建分页数据对象,统一前端数据格式 + return MyPageData.emptyPageData(); + } + if (dataList instanceof Page) { + totalCount = ((Page) dataList).getTotal(); + } + List resultList = MyModelUtil.copyCollectionTo(dataList, targetClazz); + return MyPageUtil.makeResponseData(resultList, totalCount); + } + + /** + * 用户构建带有分页信息的数据列表。 + * + * @param responseData 第一个数据时数据列表,第二个是列表数量。 + * @param 源数据类型。 + * @return 返回分页数据对象。 + */ + public static MyPageData makeResponseData(Tuple2, Long> responseData) { + return makeResponseData(responseData.getFirst(), responseData.getSecond()); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private MyPageUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/RedisKeyUtil.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/RedisKeyUtil.java new file mode 100644 index 00000000..23494356 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/RedisKeyUtil.java @@ -0,0 +1,187 @@ +package com.orangeforms.common.core.util; + +import com.orangeforms.common.core.object.TokenData; + +/** + * Redis 键生成工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class RedisKeyUtil { + + private static final String SESSIONID_PREFIX = "SESSIONID:"; + + /** + * 获取通用的session缓存的键前缀。 + * + * @return session缓存的键前缀。 + */ + public static String getSessionIdPrefix() { + TokenData tokenData = TokenData.takeFromRequest(); + if (tokenData.getTenantId() == null) { + return SESSIONID_PREFIX; + } + return SESSIONID_PREFIX + tokenData.getTenantId() + "_"; + } + + /** + * 获取指定用户Id的session缓存的键前缀。 + * + * @param loginName 指定的用户登录名。 + * @return session缓存的键前缀。 + */ + public static String getSessionIdPrefix(String loginName) { + TokenData tokenData = TokenData.takeFromRequest(); + if (tokenData.getTenantId() == null) { + return SESSIONID_PREFIX + loginName + "_"; + } + return SESSIONID_PREFIX + tokenData.getTenantId() + "_" + loginName + "_"; + } + + /** + * 获取指定用户Id的session缓存的键前缀。 + * + * @param loginName 指定的用户登录名。 + * @param tokenData 令牌对象。 + * @return session缓存的键前缀。 + */ + public static String getSessionIdPrefix(TokenData tokenData, String loginName) { + if (tokenData.getTenantId() == null) { + return SESSIONID_PREFIX + loginName + "_"; + } + return SESSIONID_PREFIX + tokenData.getTenantId() + "_" + loginName + "_"; + } + + /** + * 获取指定用户Id和登录设备类型的session缓存的键前缀。 + * + * @param loginName 指定的用户登录名。 + * @param deviceType 设备类型。 + * @return session缓存的键前缀。 + */ + public static String getSessionIdPrefix(String loginName, int deviceType) { + TokenData tokenData = TokenData.takeFromRequest(); + if (tokenData.getTenantId() == null) { + return SESSIONID_PREFIX + loginName + "_" + deviceType + "_"; + } + return SESSIONID_PREFIX + tokenData.getTenantId() + "_" + loginName + "_" + deviceType + "_"; + } + + /** + * 计算SessionId返回存储于Redis中的键。 + * + * @param sessionId 会话Id。 + * @return 会话存储于Redis中的键值。 + */ + public static String makeSessionIdKey(String sessionId) { + return SESSIONID_PREFIX + sessionId; + } + + /** + * 计算SessionId关联的权限数据存储于Redis中的键。 + * + * @param sessionId 会话Id。 + * @return 会话关联的权限数据存储于Redis中的键值。 + */ + public static String makeSessionPermIdKey(String sessionId) { + return "PERM:" + sessionId; + } + + /** + * 计算SessionId关联的权限字存储于Redis中的键。 + * + * @param sessionId 会话Id。 + * @return 会话关联的权限字存储于Redis中的键值。 + */ + public static String makeSessionPermCodeKey(String sessionId) { + return "PERM_CODE:" + sessionId; + } + + /** + * 计算SessionId关联的数据权限数据存储于Redis中的键。 + * + * @param sessionId 会话Id。 + * @return 会话关联的数据权限数据存储于Redis中的键值。 + */ + public static String makeSessionDataPermIdKey(String sessionId) { + return "DATA_PERM:" + sessionId; + } + + /** + * 计算包含全局字典及其数据项的缓存键。 + * + * @param dictCode 全局字典编码。 + * @return 全局字典指定编码的缓存键。 + */ + public static String makeGlobalDictKey(String dictCode) { + return "GLOBAL_DICT:" + dictCode; + } + + /** + * 计算仅仅包含全局字典对象数据的缓存键。 + * + * @param dictCode 全局字典编码。 + * @return 全局字典指定编码的缓存键。 + */ + public static String makeGlobalDictOnlyKey(String dictCode) { + return "GLOBAL_DICT_ONLY:" + dictCode; + } + + /** + * 计算会话的菜单Id关联权限资源URL的缓存键。 + * + * @param sessionId 会话Id。 + * @param menuId 菜单Id。 + * @return 计算后的缓存键。 + */ + public static String makeSessionMenuPermKey(String sessionId, Object menuId) { + return "SESSION_MENU_ID:" + sessionId + "-" + menuId.toString(); + } + + /** + * 计算会话的菜单Id关联权限资源URL的缓存键的前缀。 + * + * @param sessionId 会话Id。 + * @return 计算后的缓存键前缀。 + */ + public static String getSessionMenuPermPrefix(String sessionId) { + return "SESSION_MENU_ID:" + sessionId + "-"; + } + + /** + * 计算会话关联的白名单URL的缓存键。 + * + * @param sessionId 会话Id。 + * @return 计算后的缓存键。 + */ + public static String makeSessionWhiteListPermKey(String sessionId) { + return "SESSION_WHITE_LIST:" + sessionId; + } + + /** + * 计算会话关联指定部门Ids的子部门Ids的缓存键。 + * + * @param sessionId 会话Id。 + * @param deptIds 部门Id,多个部门Id之间逗号分割。 + * @return 计算后的缓存键。 + */ + public static String makeSessionChildrenDeptIdKey(String sessionId, String deptIds) { + return "SESSION_CHILDREN_DEPT_ID:" + sessionId + "-" + deptIds; + } + + /** + * 计算租户编码的缓存键。 + * + * @param tenantCode 租户编码。 + */ + public static String makeTenantCodeKey(String tenantCode) { + return "TENANT_CODE:" + tenantCode; + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private RedisKeyUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/RsaUtil.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/RsaUtil.java new file mode 100644 index 00000000..05d34fb9 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/RsaUtil.java @@ -0,0 +1,102 @@ +package com.orangeforms.common.core.util; + +import cn.hutool.core.map.MapUtil; +import cn.hutool.crypto.asymmetric.KeyType; +import cn.hutool.crypto.asymmetric.RSA; +import lombok.extern.slf4j.Slf4j; + +import java.security.*; +import java.security.interfaces.RSAPrivateKey; +import java.security.interfaces.RSAPublicKey; +import java.util.Base64; +import java.util.Map; + +/** + * Java RSA 加密工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class RsaUtil { + + /** + * 密钥长度 于原文长度对应 以及越长速度越慢 + */ + private static final int KEY_SIZE = 1024; + /** + * 用于封装随机产生的公钥与私钥 + */ + private static final Map KEY_MAP = MapUtil.newHashMap(); + + /** + * 随机生成密钥对。 + */ + public static void genKeyPair() throws NoSuchAlgorithmException { + // KeyPairGenerator类用于生成公钥和私钥对,基于RSA算法生成对象 + KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA"); + // 初始化密钥对生成器 + keyPairGen.initialize(KEY_SIZE, new SecureRandom()); + // 生成一个密钥对,保存在keyPair中 + KeyPair keyPair = keyPairGen.generateKeyPair(); + // 得到私钥 + RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate(); + // 得到公钥 + RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); + String publicKeyString = Base64.getEncoder().encodeToString(publicKey.getEncoded()); + // 得到私钥字符串 + String privateKeyString = Base64.getEncoder().encodeToString(privateKey.getEncoded()); + // 将公钥和私钥保存到Map + // 0表示公钥 + KEY_MAP.put(0, publicKeyString); + // 1表示私钥 + KEY_MAP.put(1, privateKeyString); + } + + /** + * RSA公钥加密。 + * + * @param str 加密字符串 + * @param publicKey 公钥 + * @return 密文 + */ + public static String encrypt(String str, String publicKey) { + RSA rsa = new RSA(null, publicKey); + return Base64.getEncoder().encodeToString(rsa.encrypt(str, KeyType.PublicKey)); + } + + /** + * RSA私钥解密。 + * + * @param str 加密字符串 + * @param privateKey 私钥 + * @return 明文 + */ + public static String decrypt(String str, String privateKey) { + RSA rsa = new RSA(privateKey, null); + // 64位解码加密后的字符串 + return new String(rsa.decrypt(Base64.getDecoder().decode(str), KeyType.PrivateKey)); + } + + public static void main(String[] args) throws Exception { + long temp = System.currentTimeMillis(); + // 生成公钥和私钥 + genKeyPair(); + // 加密字符串 + log.info("公钥:" + KEY_MAP.get(0)); + log.info("私钥:" + KEY_MAP.get(1)); + log.info("生成密钥消耗时间:" + (System.currentTimeMillis() - temp) / 1000.0 + "秒"); + log.info("生成后的公钥前端使用!"); + log.info("生成后的私钥后台使用!"); + String message = "RSA测试ABCD~!@#$"; + log.info("原文:" + message); + temp = System.currentTimeMillis(); + String messageEn = encrypt(message, KEY_MAP.get(0)); + log.info("密文:" + messageEn); + log.info("加密消耗时间:" + (System.currentTimeMillis() - temp) / 1000.0 + "秒"); + temp = System.currentTimeMillis(); + String messageDe = decrypt(messageEn, KEY_MAP.get(1)); + log.info("解密:" + messageDe); + log.info("解密消耗时间:" + (System.currentTimeMillis() - temp) / 1000.0 + "秒"); + } +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/TreeNode.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/TreeNode.java new file mode 100644 index 00000000..5931410e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/util/TreeNode.java @@ -0,0 +1,92 @@ +package com.orangeforms.common.core.util; + +import cn.hutool.core.util.ObjectUtil; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 将列表结构组建为树结构的工具类。 + * + * @param 对象类型。 + * @param 节点之间关联键的类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class TreeNode { + + private K id; + private K parentId; + private T data; + private List> childList = new ArrayList<>(); + + /** + * 将列表结构组建为树结构的工具方法。 + * + * @param dataList 数据列表结构。 + * @param idFunc 获取关联id的函数对象。 + * @param parentIdFunc 获取关联ParentId的函数对象。 + * @param root 根节点。 + * @param 数据对象类型。 + * @param 节点之间关联键的类型。 + * @return 源数据对象的树结构存储。 + */ + public static List> build( + List dataList, Function idFunc, Function parentIdFunc, K root) { + List> treeNodeList = new ArrayList<>(); + for (T data : dataList) { + if (ObjectUtil.equals(parentIdFunc.apply(data), idFunc.apply(data))) { + continue; + } + TreeNode dataNode = new TreeNode<>(); + dataNode.setId(idFunc.apply(data)); + dataNode.setParentId(parentIdFunc.apply(data)); + dataNode.setData(data); + treeNodeList.add(dataNode); + } + return root == null ? toBuildTreeWithoutRoot(treeNodeList) : toBuildTree(treeNodeList, root); + } + + private static List> toBuildTreeWithoutRoot(List> treeNodes) { + Map> treeNodeMap = + treeNodes.stream().collect(Collectors.toMap(TreeNode::getId, n -> n)); + List> treeNodeList = new ArrayList<>(); + for (TreeNode treeNode : treeNodes) { + TreeNode parentNode = treeNodeMap.get(treeNode.getParentId()); + if (parentNode == null) { + treeNodeList.add(treeNode); + } else { + parentNode.add(treeNode); + } + } + return treeNodeList; + } + + private static List> toBuildTree(List> treeNodes, K root) { + List> treeNodeList = new ArrayList<>(); + for (TreeNode treeNode : treeNodes) { + if (root.equals(treeNode.getParentId())) { + treeNodeList.add(treeNode); + } + for (TreeNode it : treeNodes) { + if (it.getParentId() == treeNode.getId()) { + if (treeNode.getChildList() == null) { + treeNode.setChildList(new ArrayList<>()); + } + treeNode.add(it); + } + } + } + return treeNodeList; + } + + private void add(TreeNode node) { + childList.add(node); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/validator/AddGroup.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/validator/AddGroup.java new file mode 100644 index 00000000..a287fd56 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/validator/AddGroup.java @@ -0,0 +1,10 @@ +package com.orangeforms.common.core.validator; + +/** + * 数据增加的验证分组。通常用于数据新增场景。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface AddGroup { +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/validator/ConstDictRef.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/validator/ConstDictRef.java new file mode 100644 index 00000000..00e43b6a --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/validator/ConstDictRef.java @@ -0,0 +1,48 @@ +package com.orangeforms.common.core.validator; + +import jakarta.validation.Constraint; +import jakarta.validation.Payload; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 定义在Model对象中,标注字段值引用自指定的常量字典,和ConstDictRefValidator对象配合完成数据验证。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Constraint(validatedBy = ConstDictValidator.class) +public @interface ConstDictRef { + + /** + * 引用的常量字典对象,该对象必须包含isValid的静态方法。 + * + * @return 最大长度。 + */ + Class constDictClass(); + + /** + * 超过边界后的错误消息提示。 + * + * @return 错误提示。 + */ + String message() default "无效的字典引用值!"; + + /** + * 验证分组。 + * + * @return 验证分组。 + */ + Class[] groups() default {}; + + /** + * 载荷对象类型。 + * + * @return 载荷对象。 + */ + Class[] payload() default {}; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/validator/ConstDictValidator.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/validator/ConstDictValidator.java new file mode 100644 index 00000000..ba58a2a7 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/validator/ConstDictValidator.java @@ -0,0 +1,34 @@ +package com.orangeforms.common.core.validator; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ReflectUtil; + +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; +import java.lang.reflect.Method; + +/** + * * 数据字段自定义验证,用于验证Model中关联的常量字典值的合法性。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class ConstDictValidator implements ConstraintValidator { + + private ConstDictRef constDictRef; + + @Override + public void initialize(ConstDictRef constDictRef) { + this.constDictRef = constDictRef; + } + + @Override + public boolean isValid(Object s, ConstraintValidatorContext constraintValidatorContext) { + if (ObjectUtil.isEmpty(s)) { + return true; + } + Method method = + ReflectUtil.getMethodByName(constDictRef.constDictClass(), "isValid"); + return ReflectUtil.invokeStatic(method, s); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/validator/TextLength.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/validator/TextLength.java new file mode 100644 index 00000000..c5a983fb --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/validator/TextLength.java @@ -0,0 +1,55 @@ +package com.orangeforms.common.core.validator; + +import jakarta.validation.Constraint; +import jakarta.validation.Payload; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 定义在Model或Dto对象中,UTF-8编码的字符串字段长度的上限和下限,和TextLengthValidator对象配合完成数据验证。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Constraint(validatedBy = TextLengthValidator.class) +public @interface TextLength { + + /** + * 字符串字段的最小长度。 + * + * @return 最小长度。 + */ + int min() default 0; + + /** + * 字符串字段的最大长度。 + * + * @return 最大长度。 + */ + int max() default Integer.MAX_VALUE; + + /** + * 超过边界后的错误消息提示。 + * + * @return 错误提示。 + */ + String message() default "字段长度超过最大字节数!"; + + /** + * 验证分组。 + * + * @return 验证分组。 + */ + Class[] groups() default { }; + + /** + * 载荷对象类型。 + * + * @return 载荷对象。 + */ + Class[] payload() default { }; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/validator/TextLengthValidator.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/validator/TextLengthValidator.java new file mode 100644 index 00000000..5433bc2b --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/validator/TextLengthValidator.java @@ -0,0 +1,39 @@ +package com.orangeforms.common.core.validator; + +import org.apache.commons.lang3.CharUtils; + +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; + +/** + * 数据字段自定义验证,用于验证Model中UTF-8编码的字符串字段的最大长度和最小长度。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class TextLengthValidator implements ConstraintValidator { + + private TextLength textLength; + + @Override + public void initialize(TextLength textLength) { + this.textLength = textLength; + } + + @Override + public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) { + if (s == null) { + return true; + } + int length = 0; + for (int i = 0; i < s.length(); i++) { + char c = s.charAt(i); + if (CharUtils.isAscii(c)) { + ++length; + } else { + length += 2; + } + } + return length >= textLength.min() && length <= textLength.max(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/validator/UpdateGroup.java b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/validator/UpdateGroup.java new file mode 100644 index 00000000..1c196a79 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-core/src/main/java/com/orangeforms/common/core/validator/UpdateGroup.java @@ -0,0 +1,11 @@ +package com.orangeforms.common.core.validator; + +/** + * 数据修改的验证分组。通常用于数据更新的场景。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface UpdateGroup { + +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-datafilter/pom.xml b/OrangeFormsOpen-MybatisFlex/common/common-datafilter/pom.xml new file mode 100644 index 00000000..e791d2f7 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-datafilter/pom.xml @@ -0,0 +1,29 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-datafilter + 1.0.0 + common-datafilter + jar + + + + com.orangeforms + common-core + 1.0.0 + + + com.orangeforms + common-redis + 1.0.0 + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/aop/DisableDataFilterAspect.java b/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/aop/DisableDataFilterAspect.java new file mode 100644 index 00000000..91ab688d --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/aop/DisableDataFilterAspect.java @@ -0,0 +1,42 @@ +package com.orangeforms.common.datafilter.aop; + +import com.orangeforms.common.core.object.GlobalThreadLocal; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +/** + * 禁用Mybatis拦截器数据过滤的AOP处理类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Aspect +@Component +@Order(1) +@Slf4j +public class DisableDataFilterAspect { + + /** + * 所有标记了DisableDataFilter注解的类和方法。 + */ + @Pointcut("@within(com.orangeforms.common.core.annotation.DisableDataFilter) " + + "|| @annotation(com.orangeforms.common.core.annotation.DisableDataFilter)") + public void disableDataFilterPointCut() { + // 空注释,避免sonar警告 + } + + @Around("disableDataFilterPointCut()") + public Object around(ProceedingJoinPoint point) throws Throwable { + boolean dataFilterEnabled = GlobalThreadLocal.setDataFilter(false); + try { + return point.proceed(); + } finally { + GlobalThreadLocal.setDataFilter(dataFilterEnabled); + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/config/DataFilterAutoConfig.java b/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/config/DataFilterAutoConfig.java new file mode 100644 index 00000000..eefef7b5 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/config/DataFilterAutoConfig.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.datafilter.config; + +import org.springframework.boot.context.properties.EnableConfigurationProperties; + +/** + * common-datafilter模块的自动配置引导类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EnableConfigurationProperties({DataFilterProperties.class}) +public class DataFilterAutoConfig { +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/config/DataFilterProperties.java b/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/config/DataFilterProperties.java new file mode 100644 index 00000000..f4019a9d --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/config/DataFilterProperties.java @@ -0,0 +1,50 @@ +package com.orangeforms.common.datafilter.config; + +import lombok.Data; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * common-datafilter模块的配置类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ConfigurationProperties(prefix = "common-datafilter") +public class DataFilterProperties { + + /** + * 是否启用租户过滤。 + */ + @Value("${common-datafilter.tenant.enabled:false}") + private Boolean enabledTenantFilter; + + /** + * 是否启动数据权限过滤。 + */ + @Value("${common-datafilter.dataperm.enabled:false}") + private Boolean enabledDataPermFilter; + + /** + * 部门关联表的表名前缀,如zz_。该值主要用在MybatisDataFilterInterceptor拦截器中, + * 用于拼接数据权限过滤的SQL语句。 + */ + @Value("${common-datafilter.dataperm.deptRelationTablePrefix:}") + private String deptRelationTablePrefix; + + /** + * 该值为true的时候,在进行数据权限过滤时,会加上表名,如:zz_sys_user.dept_id = xxx。 + * 为false时,过滤条件不加表名,只是使用字段名,如:dept_id = xxx。该值目前主要适用于 + * Oracle分页SQL使用了子查询的场景。此场景下,由于子查询使用了别名,再在数据权限过滤条件中 + * 加上原有表名时,SQL语法会报错。 + */ + @Value("${common-datafilter.dataperm.addTableNamePrefix:true}") + private Boolean addTableNamePrefix; + + /** + * 是否打开menuId和当前url的匹配关系的验证。 + */ + @Value("${common-datafilter.dataperm.enableMenuPermVerify:true}") + private Boolean enableMenuPermVerify; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/config/DataFilterWebMvcConfigurer.java b/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/config/DataFilterWebMvcConfigurer.java new file mode 100644 index 00000000..2ba79d45 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/config/DataFilterWebMvcConfigurer.java @@ -0,0 +1,21 @@ +package com.orangeforms.common.datafilter.config; + +import com.orangeforms.common.datafilter.interceptor.DataFilterInterceptor; +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 2024-07-02 + */ +@Configuration +public class DataFilterWebMvcConfigurer implements WebMvcConfigurer { + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(new DataFilterInterceptor()).addPathPatterns("/**"); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/interceptor/DataFilterInterceptor.java b/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/interceptor/DataFilterInterceptor.java new file mode 100644 index 00000000..a20b9083 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/interceptor/DataFilterInterceptor.java @@ -0,0 +1,42 @@ +package com.orangeforms.common.datafilter.interceptor; + +import com.orangeforms.common.core.object.GlobalThreadLocal; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +/** + * 主要用于初始化,通过Mybatis拦截器插件进行数据过滤的标记。 + * 在调用controller接口处理方法之前,必须强制将数据过滤标记设置为缺省值。 + * 这样可以避免使用当前线程在处理上一个请求时,未能正常清理的数据过滤标记值。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class DataFilterInterceptor implements HandlerInterceptor { + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) + throws Exception { + // 每次进入Controller接口之前,均主动打开数据权限验证。 + // 可以避免该Servlet线程在处理之前的请求时异常退出,从而导致该状态数据没有被正常清除。 + GlobalThreadLocal.setDataFilter(true); + 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 { + GlobalThreadLocal.clearDataFilter(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/interceptor/MybatisDataFilterInterceptor.java b/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/interceptor/MybatisDataFilterInterceptor.java new file mode 100644 index 00000000..da29121b --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/interceptor/MybatisDataFilterInterceptor.java @@ -0,0 +1,646 @@ +package com.orangeforms.common.datafilter.interceptor; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.text.StrFormatter; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.ReflectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.mybatisflex.annotation.Table; +import com.mybatisflex.core.mybatis.FlexStatementHandler; +import com.mybatisflex.core.mybatis.MapperInvocationHandler; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.annotation.*; +import com.orangeforms.common.core.cache.CacheConfig; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.core.exception.NoDataPermException; +import com.orangeforms.common.core.object.GlobalThreadLocal; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.ApplicationContextHolder; +import com.orangeforms.common.core.util.ContextUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.RedisKeyUtil; +import com.orangeforms.common.core.constant.DataPermRuleType; +import com.orangeforms.common.datafilter.config.DataFilterProperties; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import net.sf.jsqlparser.JSQLParserException; +import net.sf.jsqlparser.expression.operators.conditional.AndExpression; +import net.sf.jsqlparser.parser.CCJSqlParserUtil; +import net.sf.jsqlparser.statement.Statement; +import net.sf.jsqlparser.statement.delete.Delete; +import net.sf.jsqlparser.statement.select.FromItem; +import net.sf.jsqlparser.statement.select.PlainSelect; +import net.sf.jsqlparser.statement.select.Select; +import net.sf.jsqlparser.statement.select.SubSelect; +import net.sf.jsqlparser.statement.update.Update; +import org.apache.ibatis.executor.statement.StatementHandler; +import org.apache.ibatis.mapping.BoundSql; +import org.apache.ibatis.mapping.MappedStatement; +import org.apache.ibatis.mapping.SqlCommandType; +import org.apache.ibatis.plugin.*; +import org.redisson.api.RBucket; +import org.redisson.api.RedissonClient; +import org.springframework.aop.framework.Advised; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.stereotype.Component; + +import jakarta.annotation.Resource; +import java.lang.reflect.Field; +import java.lang.reflect.ParameterizedType; +import java.sql.Connection; +import java.util.*; + +/** + * Mybatis拦截器。目前用于数据权限的统一拦截和注入处理。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Intercepts({@Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})}) +@Slf4j +@Component +public class MybatisDataFilterInterceptor implements Interceptor { + + @Autowired + private RedissonClient redissonClient; + @Autowired + private DataFilterProperties properties; + @Resource(name = "caffeineCacheManager") + private CacheManager cacheManager; + + /** + * 对象缓存。由于Set是排序后的,因此在查找排除方法名称时效率更高。 + * 在应用服务启动的监听器中(LoadDataPermMapperListener),会调用当前对象的(loadMappersWithDataPerm)方法,加载缓存。 + */ + private final Map cachedDataPermMap = MapUtil.newHashMap(); + /** + * 租户租户对象缓存。 + */ + private final Map cachedTenantMap = MapUtil.newHashMap(); + + /** + * 预先加载与数据过滤相关的数据到缓存,该函数会在(LoadDataFilterInfoListener)监听器中调用。 + */ + @SuppressWarnings("all") + public void loadInfoWithDataFilter() { + Map mapperMap = + ApplicationContextHolder.getApplicationContext().getBeansOfType(BaseDaoMapper.class); + for (BaseDaoMapper mapperProxy : mapperMap.values()) { + // 优先处理jdk的代理 + Object proxy = ReflectUtil.getFieldValue(mapperProxy, "h"); + // 如果不是jdk的代理,再看看cjlib的代理。 + if (proxy == null) { + proxy = ReflectUtil.getFieldValue(mapperProxy, "CGLIB$CALLBACK_0"); + } + if (proxy instanceof MapperInvocationHandler) { + proxy = ReflectUtil.getFieldValue(proxy, "mapper"); + proxy = ReflectUtil.getFieldValue(proxy, "h"); + } + Class mapperClass = (Class) ReflectUtil.getFieldValue(proxy, "mapperInterface"); + if (mapperClass == null) { + try { + mapperProxy = (BaseDaoMapper) + ((Advised) ReflectUtil.getFieldValue(proxy, "advised")).getTargetSource().getTarget(); + proxy = ReflectUtil.getFieldValue(mapperProxy, "h"); + if (proxy instanceof MapperInvocationHandler) { + proxy = ReflectUtil.getFieldValue(proxy, "mapper"); + proxy = ReflectUtil.getFieldValue(proxy, "h"); + } + mapperClass = (Class) ReflectUtil.getFieldValue(proxy, "mapperInterface"); + } catch (Exception e) { + throw new MyRuntimeException(e); + } + } + if (BooleanUtil.isTrue(properties.getEnabledTenantFilter())) { + loadTenantFilterData(mapperClass); + } + if (BooleanUtil.isTrue(properties.getEnabledDataPermFilter())) { + EnableDataPerm rule = mapperClass.getAnnotation(EnableDataPerm.class); + if (rule != null) { + loadDataPermFilterRules(mapperClass, rule); + } + } + } + } + + private void loadTenantFilterData(Class mapperClass) { + Class modelClass = (Class) ((ParameterizedType) + mapperClass.getGenericInterfaces()[0]).getActualTypeArguments()[0]; + Field[] fields = ReflectUtil.getFields(modelClass); + for (Field field : fields) { + if (field.getAnnotation(TenantFilterColumn.class) != null) { + ModelTenantInfo tenantInfo = new ModelTenantInfo(); + tenantInfo.setModelName(modelClass.getSimpleName()); + tenantInfo.setTableName(modelClass.getAnnotation(Table.class).value()); + tenantInfo.setFieldName(field.getName()); + tenantInfo.setColumnName(MyModelUtil.mapToColumnName(field, modelClass)); + // 判断当前dao中是否包括不需要自动注入租户Id过滤的方法。 + DisableTenantFilter disableTenantFilter = mapperClass.getAnnotation(DisableTenantFilter.class); + if (disableTenantFilter != null) { + // 这里开始获取当前Mapper已经声明的的SqlId中,有哪些是需要排除在外的。 + // 排除在外的将不进行数据过滤。 + Set excludeMethodNameSet = new HashSet<>(); + for (String excludeName : disableTenantFilter.includeMethodName()) { + excludeMethodNameSet.add(excludeName); + // 这里是给pagehelper中,分页查询先获取数据总量的查询。 + excludeMethodNameSet.add(excludeName + "_COUNT"); + } + tenantInfo.setExcludeMethodNameSet(excludeMethodNameSet); + } + cachedTenantMap.put(mapperClass.getName(), tenantInfo); + break; + } + } + } + + private void loadDataPermFilterRules(Class mapperClass, EnableDataPerm rule) { + String sysDataPermMapperName = "SysDataPermMapper"; + // 由于给数据权限Mapper添加@EnableDataPerm,将会导致无限递归,因此这里检测到之后, + // 会在系统启动加载监听器的时候,及时抛出异常。 + if (StrUtil.equals(sysDataPermMapperName, mapperClass.getSimpleName())) { + throw new IllegalStateException("Add @EnableDataPerm annotation to SysDataPermMapper is ILLEGAL!"); + } + // 这里开始获取当前Mapper已经声明的的SqlId中,有哪些是需要排除在外的。 + // 排除在外的将不进行数据过滤。 + Set excludeMethodNameSet = null; + String[] excludes = rule.excluseMethodName(); + if (excludes.length > 0) { + excludeMethodNameSet = new HashSet<>(); + for (String excludeName : excludes) { + excludeMethodNameSet.add(excludeName); + // 这里是给pagehelper中,分页查询先获取数据总量的查询。 + excludeMethodNameSet.add(excludeName + "_COUNT"); + } + } + // 获取Mapper关联的主表信息,包括表名,user过滤字段名和dept过滤字段名。 + Class modelClazz = (Class) + ((ParameterizedType) mapperClass.getGenericInterfaces()[0]).getActualTypeArguments()[0]; + Field[] fields = ReflectUtil.getFields(modelClazz); + Field userFilterField = null; + Field deptFilterField = null; + for (Field field : fields) { + if (null != field.getAnnotation(UserFilterColumn.class)) { + userFilterField = field; + } + if (null != field.getAnnotation(DeptFilterColumn.class)) { + deptFilterField = field; + } + if (userFilterField != null && deptFilterField != null) { + break; + } + } + // 通过注解解析与Mapper关联的Model,并获取与数据权限关联的信息,并将结果缓存。 + ModelDataPermInfo info = new ModelDataPermInfo(); + info.setMainTableName(MyModelUtil.mapToTableName(modelClazz)); + info.setMustIncludeUserRule(rule.mustIncludeUserRule()); + info.setExcludeMethodNameSet(excludeMethodNameSet); + if (userFilterField != null) { + info.setUserFilterColumn(MyModelUtil.mapToColumnName(userFilterField, modelClazz)); + } + if (deptFilterField != null) { + info.setDeptFilterColumn(MyModelUtil.mapToColumnName(deptFilterField, modelClazz)); + } + cachedDataPermMap.put(mapperClass.getName(), info); + } + + @Override + public Object intercept(Invocation invocation) throws Throwable { + // 判断当前线程本地存储中,业务操作是否禁用了数据权限过滤,如果禁用,则不进行后续的数据过滤处理了。 + if (!GlobalThreadLocal.enabledDataFilter() + && BooleanUtil.isFalse(properties.getEnabledTenantFilter())) { + return invocation.proceed(); + } + // 只有在HttpServletRequest场景下,该拦截器才起作用,对于系统级别的预加载数据不会应用数据权限。 + if (!ContextUtil.hasRequestContext()) { + return invocation.proceed(); + } + // 没有登录的用户,不会参与租户过滤,如果需要过滤的,自己在代码中手动实现 + // 通常对于无需登录的白名单url,也无需过滤了。 + // 另外就是登录接口中,获取菜单列表的接口,由于尚未登录,没有TokenData,所以这个接口我们手动加入了该条件。 + if (TokenData.takeFromRequest() == null) { + return invocation.proceed(); + } + FlexStatementHandler handler = null; + try { + handler = (FlexStatementHandler) invocation.getTarget(); + } catch (Exception e) { + handler = (FlexStatementHandler) + ReflectUtil.getFieldValue(ReflectUtil.getFieldValue(invocation.getTarget(), "h"), "target"); + } + StatementHandler delegate = + (StatementHandler) ReflectUtil.getFieldValue(handler, "delegate"); + // 通过反射获取delegate父类BaseStatementHandler的mappedStatement属性 + MappedStatement mappedStatement = + (MappedStatement) ReflectUtil.getFieldValue(delegate, "mappedStatement"); + SqlCommandType commandType = mappedStatement.getSqlCommandType(); + // 对于INSERT语句,我们不进行任何数据过滤。 + if (commandType == SqlCommandType.INSERT) { + return invocation.proceed(); + } + String sqlId = mappedStatement.getId(); + int pos = StrUtil.lastIndexOfIgnoreCase(sqlId, "."); + String className = StrUtil.sub(sqlId, 0, pos); + String methodName = StrUtil.subSuf(sqlId, pos + 1); + // 先进行租户过滤条件的处理,再将解析并处理后的SQL Statement交给下一步的数据权限过滤去处理。 + // 这样做的目的主要是为了减少一次SQL解析的过程,因为这是高频操作,所以要尽量去优化。 + Statement statement = null; + if (BooleanUtil.isTrue(properties.getEnabledTenantFilter())) { + statement = this.processTenantFilter(className, methodName, delegate.getBoundSql(), commandType); + } + // 处理数据权限过滤。 + if (GlobalThreadLocal.enabledDataFilter() + && BooleanUtil.isTrue(properties.getEnabledDataPermFilter())) { + this.processDataPermFilter(className, methodName, delegate.getBoundSql(), commandType, statement, sqlId); + } + return invocation.proceed(); + } + + private Statement processTenantFilter( + String className, String methodName, BoundSql boundSql, SqlCommandType commandType) throws JSQLParserException { + ModelTenantInfo info = cachedTenantMap.get(className); + if (info == null || CollUtil.contains(info.getExcludeMethodNameSet(), methodName)) { + return null; + } + String sql = boundSql.getSql(); + Statement statement = CCJSqlParserUtil.parse(sql); + StringBuilder filterBuilder = new StringBuilder(64); + filterBuilder.append(info.tableName).append(".") + .append(info.columnName) + .append("=") + .append(TokenData.takeFromRequest().getTenantId()); + String dataFilter = filterBuilder.toString(); + if (commandType == SqlCommandType.UPDATE) { + Update update = (Update) statement; + this.buildWhereClause(update, dataFilter); + } else if (commandType == SqlCommandType.DELETE) { + Delete delete = (Delete) statement; + this.buildWhereClause(delete, dataFilter); + } else { + Select select = (Select) statement; + PlainSelect selectBody = (PlainSelect) select.getSelectBody(); + FromItem fromItem = selectBody.getFromItem(); + if (fromItem != null) { + PlainSelect subSelect = null; + if (fromItem instanceof SubSelect) { + subSelect = (PlainSelect) ((SubSelect) fromItem).getSelectBody(); + } + if (subSelect != null) { + dataFilter = replaceTableAlias(info.getTableName(), subSelect, dataFilter); + buildWhereClause(subSelect, dataFilter); + } else { + dataFilter = replaceTableAlias(info.getTableName(), selectBody, dataFilter); + buildWhereClause(selectBody, dataFilter); + } + } + } + log.info("Tenant Filter Where Clause [{}]", dataFilter); + ReflectUtil.setFieldValue(boundSql, "sql", statement.toString()); + return statement; + } + + private void processDataPermFilter( + String className, String methodName, BoundSql boundSql, SqlCommandType commandType, Statement statement, String sqlId) + throws JSQLParserException { + // 判断当前线程本地存储中,业务操作是否禁用了数据权限过滤,如果禁用,则不进行后续的数据过滤处理了。 + // 数据过滤权限中,INSERT不过滤。如果是管理员则不参与数据权限的数据过滤,显示全部数据。 + TokenData tokenData = TokenData.takeFromRequest(); + if (Boolean.TRUE.equals(tokenData.getIsAdmin())) { + return; + } + ModelDataPermInfo info = cachedDataPermMap.get(className); + // 再次查找当前方法是否为排除方法,如果不是,就参与数据权限注入过滤。 + if (info == null || CollUtil.contains(info.getExcludeMethodNameSet(), methodName)) { + return; + } + String dataPermSessionKey = RedisKeyUtil.makeSessionDataPermIdKey(tokenData.getSessionId()); + Object cachedData = this.getCachedData(dataPermSessionKey); + if (cachedData == null) { + throw new NoDataPermException(StrFormatter.format( + "No Related DataPerm found for SQL_ID [{}] from Cache.", sqlId)); + } + JSONObject allMenuDataPermMap = cachedData instanceof JSONObject + ? (JSONObject) cachedData : JSON.parseObject(cachedData.toString()); + JSONObject menuDataPermMap = this.getAndVerifyMenuDataPerm(allMenuDataPermMap, sqlId); + Map dataPermMap = new HashMap<>(8); + for (Map.Entry entry : menuDataPermMap.entrySet()) { + dataPermMap.put(Integer.valueOf(entry.getKey()), entry.getValue().toString()); + } + if (MapUtil.isEmpty(dataPermMap)) { + throw new NoDataPermException(StrFormatter.format( + "No Related DataPerm found for SQL_ID [{}].", sqlId)); + } + if (dataPermMap.containsKey(DataPermRuleType.TYPE_ALL)) { + return; + } + // 如果当前过滤注解中mustIncludeUserRule参数为true,同时当前用户的数据权限中,不包含TYPE_USER_ONLY, + // 这里就需要自动添加该数据权限。 + if (info.getMustIncludeUserRule() + && !dataPermMap.containsKey(DataPermRuleType.TYPE_USER_ONLY)) { + dataPermMap.put(DataPermRuleType.TYPE_USER_ONLY, null); + } + this.processDataPerm(info, dataPermMap, boundSql, commandType, statement); + } + + private JSONObject getAndVerifyMenuDataPerm(JSONObject allMenuDataPermMap, String sqlId) { + String menuId = ContextUtil.getHttpRequest().getHeader(ApplicationConstant.HTTP_HEADER_MENU_ID); + if (menuId == null) { + menuId = ContextUtil.getHttpRequest().getParameter(ApplicationConstant.HTTP_HEADER_MENU_ID); + } + if (BooleanUtil.isFalse(properties.getEnableMenuPermVerify()) && menuId == null) { + menuId = ApplicationConstant.DATA_PERM_ALL_MENU_ID; + } + Assert.notNull(menuId); + JSONObject menuDataPermMap = allMenuDataPermMap.getJSONObject(menuId); + if (menuDataPermMap == null) { + menuDataPermMap = allMenuDataPermMap.getJSONObject(ApplicationConstant.DATA_PERM_ALL_MENU_ID); + } + if (menuDataPermMap == null) { + throw new NoDataPermException(StrFormatter.format( + "No Related DataPerm found for menuId [{}] and SQL_ID [{}].", menuId, sqlId)); + } + if (BooleanUtil.isTrue(properties.getEnableMenuPermVerify())) { + String url = ContextUtil.getHttpRequest().getHeader(ApplicationConstant.HTTP_HEADER_ORIGINAL_REQUEST_URL); + if (StrUtil.isBlank(url)) { + url = ContextUtil.getHttpRequest().getRequestURI(); + } + Assert.notNull(url); + if (!this.verifyMenuPerm(null, url, sqlId) && !this.verifyMenuPerm(menuId, url, sqlId)) { + String msg = StrFormatter.format("Mismatched DataPerm " + + "for menuId [{}] and url [{}] and SQL_ID [{}].", menuId, url, sqlId); + throw new NoDataPermException(msg); + } + } + return menuDataPermMap; + } + + private Object getCachedData(String dataPermSessionKey) { + Object cachedData; + Cache cache = cacheManager.getCache(CacheConfig.CacheEnum.DATA_PERMISSION_CACHE.name()); + org.springframework.util.Assert.notNull(cache, "Cache [DATA_PERMISSION_CACHE] can't be null."); + Cache.ValueWrapper wrapper = cache.get(dataPermSessionKey); + if (wrapper == null) { + cachedData = redissonClient.getBucket(dataPermSessionKey).get(); + if (cachedData != null) { + cache.put(dataPermSessionKey, JSON.parseObject(cachedData.toString())); + } + } else { + cachedData = wrapper.get(); + } + return cachedData; + } + + @SuppressWarnings("unchecked") + private boolean verifyMenuPerm(String menuId, String url, String sqlId) { + String sessionId = TokenData.takeFromRequest().getSessionId(); + String menuPermSessionKey; + if (menuId != null) { + menuPermSessionKey = RedisKeyUtil.makeSessionMenuPermKey(sessionId, menuId); + } else { + menuPermSessionKey = RedisKeyUtil.makeSessionWhiteListPermKey(sessionId); + } + Cache cache = cacheManager.getCache(CacheConfig.CacheEnum.MENU_PERM_CACHE.name()); + org.springframework.util.Assert.notNull(cache, "Cache [MENU_PERM_CACHE] can't be null!"); + Cache.ValueWrapper wrapper = cache.get(menuPermSessionKey); + if (wrapper != null) { + Object cachedData = wrapper.get(); + if (cachedData != null) { + return ((Set) cachedData).contains(url); + } + } + RBucket bucket = redissonClient.getBucket(menuPermSessionKey); + if (!bucket.isExists()) { + String msg; + if (menuId == null) { + msg = StrFormatter.format("No Related MenuPerm found " + + "in Redis Cache for WHITE_LIST and SQL_ID [{}] with sessionId [{}].", sqlId, sessionId); + } else { + msg = StrFormatter.format("No Related MenuPerm found " + + "in Redis Cache for menuId [{}] and SQL_ID [{}] with sessionId [{}].", menuId, sqlId, sessionId); + } + throw new NoDataPermException(msg); + } + Set cachedMenuPermSet = new HashSet<>(JSONArray.parseArray(bucket.get(), String.class)); + cache.put(menuPermSessionKey, cachedMenuPermSet); + return cachedMenuPermSet.contains(url); + } + + private void processDataPerm( + ModelDataPermInfo info, + Map dataPermMap, + BoundSql boundSql, + SqlCommandType commandType, + Statement statement) throws JSQLParserException { + List criteriaList = new LinkedList<>(); + for (Map.Entry entry : dataPermMap.entrySet()) { + String filterClause = processDataPermRule(info, entry.getKey(), entry.getValue()); + if (StrUtil.isNotBlank(filterClause)) { + criteriaList.add(filterClause); + } + } + if (CollUtil.isEmpty(criteriaList)) { + return; + } + StringBuilder filterBuilder = new StringBuilder(128); + filterBuilder.append("("); + filterBuilder.append(StrUtil.join(" OR ", criteriaList)); + filterBuilder.append(")"); + String dataFilter = filterBuilder.toString(); + if (statement == null) { + String sql = boundSql.getSql(); + statement = CCJSqlParserUtil.parse(sql); + } + if (commandType == SqlCommandType.UPDATE) { + Update update = (Update) statement; + this.buildWhereClause(update, dataFilter); + } else if (commandType == SqlCommandType.DELETE) { + Delete delete = (Delete) statement; + this.buildWhereClause(delete, dataFilter); + } else { + this.processSelect(statement, info, dataFilter); + } + log.info("DataPerm Filter Where Clause [{}]", dataFilter); + ReflectUtil.setFieldValue(boundSql, "sql", statement.toString()); + } + + private void processSelect(Statement statement, ModelDataPermInfo info, String dataFilter) + throws JSQLParserException { + Select select = (Select) statement; + PlainSelect selectBody = (PlainSelect) select.getSelectBody(); + FromItem fromItem = selectBody.getFromItem(); + if (fromItem == null) { + return; + } + PlainSelect subSelect = null; + if (fromItem instanceof SubSelect) { + subSelect = (PlainSelect) ((SubSelect) fromItem).getSelectBody(); + } + if (subSelect != null) { + dataFilter = replaceTableAlias(info.getMainTableName(), subSelect, dataFilter); + buildWhereClause(subSelect, dataFilter); + } else { + dataFilter = replaceTableAlias(info.getMainTableName(), selectBody, dataFilter); + buildWhereClause(selectBody, dataFilter); + } + } + + private String processDataPermRule(ModelDataPermInfo info, Integer ruleType, String dataIds) { + TokenData tokenData = TokenData.takeFromRequest(); + StringBuilder filter = new StringBuilder(128); + String tableName = info.getMainTableName(); + if (ruleType != DataPermRuleType.TYPE_USER_ONLY + && ruleType != DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT_USERS + && ruleType != DataPermRuleType.TYPE_DEPT_USERS) { + return this.processDeptDataPermRule(info, ruleType, dataIds); + } + if (StrUtil.isBlank(info.getUserFilterColumn())) { + log.warn("No UserFilterColumn for table [{}] but USER_FILTER_DATA_PERM exists !!!", tableName); + return filter.toString(); + } + if (BooleanUtil.isTrue(properties.getAddTableNamePrefix())) { + filter.append(info.getMainTableName()).append("."); + } + if (ruleType == DataPermRuleType.TYPE_USER_ONLY) { + filter.append(info.getUserFilterColumn()) + .append(" = ") + .append(tokenData.getUserId()); + } else { + filter.append(info.getUserFilterColumn()) + .append(" IN (") + .append(dataIds) + .append(") "); + } + return filter.toString(); + } + + private String processDeptDataPermRule(ModelDataPermInfo info, Integer ruleType, String deptIds) { + StringBuilder filter = new StringBuilder(128); + String tableName = info.getMainTableName(); + if (StrUtil.isBlank(info.getDeptFilterColumn())) { + log.warn("No DeptFilterColumn for table [{}] but DEPT_FILTER_DATA_PERM exists !!!", tableName); + return filter.toString(); + } + TokenData tokenData = TokenData.takeFromRequest(); + if (ruleType == DataPermRuleType.TYPE_DEPT_ONLY) { + if (BooleanUtil.isTrue(properties.getAddTableNamePrefix())) { + filter.append(info.getMainTableName()).append("."); + } + filter.append(info.getDeptFilterColumn()) + .append(" = ") + .append(tokenData.getDeptId()); + } else if (ruleType == DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT) { + filter.append(" EXISTS ") + .append("(SELECT 1 FROM ") + .append(properties.getDeptRelationTablePrefix()) + .append("sys_dept_relation WHERE ") + .append(properties.getDeptRelationTablePrefix()) + .append("sys_dept_relation.parent_dept_id = ") + .append(tokenData.getDeptId()) + .append(" AND "); + if (BooleanUtil.isTrue(properties.getAddTableNamePrefix())) { + filter.append(info.getMainTableName()).append("."); + } + filter.append(info.getDeptFilterColumn()) + .append(" = ") + .append(properties.getDeptRelationTablePrefix()) + .append("sys_dept_relation.dept_id) "); + } else if (ruleType == DataPermRuleType.TYPE_MULTI_DEPT_AND_CHILD_DEPT) { + filter.append(" EXISTS ") + .append("(SELECT 1 FROM ") + .append(properties.getDeptRelationTablePrefix()) + .append("sys_dept_relation WHERE ") + .append(properties.getDeptRelationTablePrefix()) + .append("sys_dept_relation.parent_dept_id IN (") + .append(deptIds) + .append(") AND "); + if (BooleanUtil.isTrue(properties.getAddTableNamePrefix())) { + filter.append(info.getMainTableName()).append("."); + } + filter.append(info.getDeptFilterColumn()) + .append(" = ") + .append(properties.getDeptRelationTablePrefix()) + .append("sys_dept_relation.dept_id) "); + } else if (ruleType == DataPermRuleType.TYPE_CUSTOM_DEPT_LIST) { + if (BooleanUtil.isTrue(properties.getAddTableNamePrefix())) { + filter.append(info.getMainTableName()).append("."); + } + filter.append(info.getDeptFilterColumn()) + .append(" IN (") + .append(deptIds) + .append(") "); + } + return filter.toString(); + } + + private String replaceTableAlias(String tableName, PlainSelect select, String dataFilter) { + if (select.getFromItem().getAlias() == null) { + return dataFilter; + } + return dataFilter.replaceAll(tableName, select.getFromItem().getAlias().getName()); + } + + private void buildWhereClause(Update update, String dataFilter) throws JSQLParserException { + if (update.getWhere() == null) { + update.setWhere(CCJSqlParserUtil.parseCondExpression(dataFilter)); + } else { + AndExpression and = new AndExpression( + CCJSqlParserUtil.parseCondExpression(dataFilter), update.getWhere()); + update.setWhere(and); + } + } + + private void buildWhereClause(Delete delete, String dataFilter) throws JSQLParserException { + if (delete.getWhere() == null) { + delete.setWhere(CCJSqlParserUtil.parseCondExpression(dataFilter)); + } else { + AndExpression and = new AndExpression( + CCJSqlParserUtil.parseCondExpression(dataFilter), delete.getWhere()); + delete.setWhere(and); + } + } + + private void buildWhereClause(PlainSelect select, String dataFilter) throws JSQLParserException { + if (select.getWhere() == null) { + select.setWhere(CCJSqlParserUtil.parseCondExpression(dataFilter)); + } else { + AndExpression and = new AndExpression( + CCJSqlParserUtil.parseCondExpression(dataFilter), select.getWhere()); + select.setWhere(and); + } + } + + @Override + public Object plugin(Object target) { + return Plugin.wrap(target, this); + } + + @Override + public void setProperties(Properties properties) { + // 这里需要空注解,否则sonar会不happy。 + } + + @Data + private static final class ModelDataPermInfo { + private Set excludeMethodNameSet; + private String userFilterColumn; + private String deptFilterColumn; + private String mainTableName; + private Boolean mustIncludeUserRule; + } + + @Data + private static final class ModelTenantInfo { + private Set excludeMethodNameSet; + private String modelName; + private String tableName; + private String fieldName; + private String columnName; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/listener/LoadDataFilterInfoListener.java b/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/listener/LoadDataFilterInfoListener.java new file mode 100644 index 00000000..5d7cb78b --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/listener/LoadDataFilterInfoListener.java @@ -0,0 +1,25 @@ +package com.orangeforms.common.datafilter.listener; + +import com.orangeforms.common.datafilter.interceptor.MybatisDataFilterInterceptor; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; + +/** + * 应用服务启动监听器。 + * 目前主要功能是调用MybatisDataFilterInterceptor中的loadInfoWithDataFilter方法, + * 将标记有过滤注解的数据加载到缓存,以提升系统运行时效率。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class LoadDataFilterInfoListener implements ApplicationListener { + + @Override + public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { + MybatisDataFilterInterceptor interceptor = + applicationReadyEvent.getApplicationContext().getBean(MybatisDataFilterInterceptor.class); + interceptor.loadInfoWithDataFilter(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..a08c930a --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-datafilter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.orangeforms.common.datafilter.config.DataFilterAutoConfig \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dbutil/pom.xml b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/pom.xml new file mode 100644 index 00000000..e7ba325b --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/pom.xml @@ -0,0 +1,54 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-dbutil + 1.0.0 + common-dbutil + jar + + + + com.orangeforms + common-core + 1.0.0 + + + mysql + mysql-connector-java + 8.0.22 + + + org.postgresql + postgresql + runtime + + + com.oracle.database.jdbc + ojdbc6 + 11.2.0.4 + + + com.dameng + DmJdbcDriver18 + 8.1.2.141 + + + org.opengauss + opengauss-jdbc + 5.0.0-og + + + ru.yandex.clickhouse + clickhouse-jdbc + 0.3.2 + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/constant/CustomDateValueType.java b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/constant/CustomDateValueType.java new file mode 100644 index 00000000..258b9a73 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/constant/CustomDateValueType.java @@ -0,0 +1,83 @@ +package com.orangeforms.common.dbutil.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 自定义日期过滤值类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class CustomDateValueType { + /** + * 本日。 + */ + public static final String CURRENT_DAY = "1"; + /** + * 本周。 + */ + public static final String CURRENT_WEEK = "2"; + /** + * 本月。 + */ + public static final String CURRENT_MONTH = "3"; + /** + * 本季度。 + */ + public static final String CURRENT_QUARTER = "4"; + /** + * 今年。 + */ + public static final String CURRENT_YEAR = "5"; + /** + * 昨天。 + */ + public static final String LAST_DAY = "11"; + /** + * 上周。 + */ + public static final String LAST_WEEK = "12"; + /** + * 上月。 + */ + public static final String LAST_MONTH = "13"; + /** + * 上季度。 + */ + public static final String LAST_QUARTER = "14"; + /** + * 去年。 + */ + public static final String LAST_YEAR = "15"; + + private static final Map DICT_MAP = new HashMap<>(2); + static { + DICT_MAP.put(CURRENT_DAY, "本日"); + DICT_MAP.put(CURRENT_WEEK, "本周"); + DICT_MAP.put(CURRENT_MONTH, "本月"); + DICT_MAP.put(CURRENT_QUARTER, "本季度"); + DICT_MAP.put(CURRENT_YEAR, "今年"); + DICT_MAP.put(LAST_DAY, "昨日"); + DICT_MAP.put(LAST_WEEK, "上周"); + DICT_MAP.put(LAST_MONTH, "上月"); + DICT_MAP.put(LAST_QUARTER, "上季度"); + DICT_MAP.put(LAST_YEAR, "去年"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(String value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private CustomDateValueType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/constant/DblinkType.java b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/constant/DblinkType.java new file mode 100644 index 00000000..83c2ecef --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/constant/DblinkType.java @@ -0,0 +1,74 @@ +package com.orangeforms.common.dbutil.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 数据库连接类型常量对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class DblinkType { + + /** + * MySQL。 + */ + public static final int MYSQL = 0; + /** + * PostgreSQL。 + */ + public static final int POSTGRESQL = 1; + /** + * Oracle。 + */ + public static final int ORACLE = 2; + /** + * Dameng。 + */ + public static final int DAMENG = 3; + /** + * 人大金仓。 + */ + public static final int KINGBASE = 4; + /** + * OpenGauss。 + */ + public static final int OPENGAUSS = 5; + /** + * ClickHouse。 + */ + public static final int CLICKHOUSE = 10; + /** + * Doris。 + */ + public static final int DORIS = 11; + + private static final Map DICT_MAP = new HashMap<>(3); + static { + DICT_MAP.put(MYSQL, "MySQL"); + DICT_MAP.put(POSTGRESQL, "PostgreSQL"); + DICT_MAP.put(ORACLE, "Oracle"); + DICT_MAP.put(DAMENG, "Dameng"); + DICT_MAP.put(KINGBASE, "人大金仓"); + DICT_MAP.put(OPENGAUSS, "OpenGauss"); + DICT_MAP.put(CLICKHOUSE, "ClickHouse"); + DICT_MAP.put(DORIS, "Doris"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private DblinkType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/DatasetFilter.java b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/DatasetFilter.java new file mode 100644 index 00000000..8ec9d20a --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/DatasetFilter.java @@ -0,0 +1,52 @@ +package com.orangeforms.common.dbutil.object; + +import com.orangeforms.common.core.constant.FieldFilterType; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; + +/** + * 数据集过滤对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class DatasetFilter extends ArrayList { + + @Data + public static class FilterInfo { + /** + * 过滤的数据集Id。 + */ + private Long datasetId; + /** + * 过滤参数名称。 + */ + private String paramName; + /** + * 过滤参数值是单值时。使用该字段值。 + */ + private Object paramValue; + /** + * 过滤参数值是集合时,使用该字段值。 + */ + private Collection paramValueList; + /** + * 过滤类型。参考常量类 FieldFilterType。 + */ + private Integer filterType = FieldFilterType.EQUAL; + /** + * 是否为日期值的过滤。 + */ + private Boolean dateValueFilter = false; + /** + * 日期精确到。year/month/week/day + */ + private String dateRange; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/DatasetParam.java b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/DatasetParam.java new file mode 100644 index 00000000..03886f41 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/DatasetParam.java @@ -0,0 +1,49 @@ +package com.orangeforms.common.dbutil.object; + +import com.orangeforms.common.core.object.MyOrderParam; +import com.orangeforms.common.core.object.MyPageParam; +import lombok.Data; + +import java.util.List; + +/** + * 数据集查询的各种参数。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class DatasetParam { + + /** + * SELECT选择的字段名列表。 + */ + private List selectColumnNameList; + /** + * 数据集过滤参数。 + */ + private DatasetFilter filter; + /** + * SQL结果集的参数。 + */ + private DatasetFilter sqlFilter; + /** + * 分页参数。 + */ + private MyPageParam pageParam; + /** + * 分组参数。 + */ + private MyOrderParam orderParam; + /** + * 排序字符串。 + */ + private String orderBy; + /** + * 该值目前仅用于SQL类型的结果集。 + * 如果该值为true,SQL结果集中定义的参数都会被替换为 (1 = 1) 的恒成立过滤。 + * 比如 select * from zz_sys_user where user_status = ${status}, + * 该值为true的时会被替换为 select * from zz_sys_user where 1 = 1。 + */ + private Boolean disableSqlDatasetFilter = false; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/GenericResultSet.java b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/GenericResultSet.java new file mode 100644 index 00000000..f3151866 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/GenericResultSet.java @@ -0,0 +1,39 @@ +package com.orangeforms.common.dbutil.object; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 报表通用的查询结果集对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@AllArgsConstructor +@NoArgsConstructor +@Data +public class GenericResultSet { + + /** + * 查询结果集的字段meta数据列表。 + */ + private List columnMetaList; + + /** + * 查询数据集。如果当前结果集为分页查询,将只包含分页数据。 + */ + private List dataList; + + /** + * 查询数据总数。如果当前结果集为分页查询,该值为分页前的数据总数,否则为0。 + */ + private Long totalCount = 0L; + + public GenericResultSet(List columnMetaList, List dataList) { + this.columnMetaList = columnMetaList; + this.dataList = dataList; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/SqlResultSet.java b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/SqlResultSet.java new file mode 100644 index 00000000..7c927194 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/SqlResultSet.java @@ -0,0 +1,28 @@ +package com.orangeforms.common.dbutil.object; + +import cn.hutool.core.collection.CollUtil; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * 直接从数据库获取的查询结果集对象。通常内部使用。 + * + * @author Jerry + * @date 2024-07-02 + */ +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +@Data +public class SqlResultSet extends GenericResultSet { + + public SqlResultSet(List columnMetaList, List dataList) { + super(columnMetaList, dataList); + } + + public static boolean isEmpty(SqlResultSet rs) { + return rs == null || CollUtil.isEmpty(rs.getDataList()); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/SqlTable.java b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/SqlTable.java new file mode 100644 index 00000000..fdda9cf8 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/SqlTable.java @@ -0,0 +1,41 @@ +package com.orangeforms.common.dbutil.object; + +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * 数据库中的表对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class SqlTable { + + /** + * 表名称。 + */ + private String tableName; + + /** + * 表注释。 + */ + private String tableComment; + + /** + * 创建时间。 + */ + private Date createTime; + + /** + * 关联的字段列表。 + */ + private List columnList; + + /** + * 数据库链接Id。 + */ + private Long dblinkId; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/SqlTableColumn.java b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/SqlTableColumn.java new file mode 100644 index 00000000..afd5763f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/SqlTableColumn.java @@ -0,0 +1,83 @@ +package com.orangeforms.common.dbutil.object; + +import lombok.Data; + +/** + * 数据库中的表字段对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class SqlTableColumn { + + /** + * 表字段名。 + */ + private String columnName; + + /** + * 字段注释。 + */ + private String columnComment; + + /** + * 表字段类型。 + */ + private String columnType; + + /** + * 表字段全类型。 + */ + private String fullColumnType; + + /** + * 是否自动增长。 + */ + private Boolean autoIncrement; + + /** + * 是否为主键。 + */ + private Boolean primaryKey; + + /** + * 是否可以为空值。 + */ + private Boolean nullable; + + /** + * 字段顺序。 + */ + private Integer columnShowOrder; + + /** + * 附加信息。 + */ + private String extra; + + /** + * 数值型字段精度。 + */ + private Integer numericPrecision; + + /** + * 数值型字段刻度。 + */ + private Integer numericScale; + + /** + * 字符型字段精度。 + */ + private Long stringPrecision; + + /** + * 缺省值。 + */ + private Object columnDefault; + + /** + * 数据库链接类型。该值为冗余字段,只是为了提升运行时效率。 + */ + private int dblinkType; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/DataSourceProvider.java b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/DataSourceProvider.java new file mode 100644 index 00000000..c0a2423f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/DataSourceProvider.java @@ -0,0 +1,108 @@ +package com.orangeforms.common.dbutil.provider; + +/** + * 数据源操作的提供者接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface DataSourceProvider { + + /** + * 返回数据库链接类型,具体值可参考DblinkType常量类。 + * @return 返回数据库链接类型 + */ + int getDblinkType(); + + /** + * 返回Jdbc的配置对象。 + * + * @param configuration Jdbc 的配置数据,JSON格式。 + * @return Jdbc的配置对象。 + */ + JdbcConfig getJdbcConfig(String configuration); + + /** + * 获取当前数据库表meta列表数据的SQL语句。 + * + * @param searchString 表名的模糊匹配字符串。如果为空,则没有前缀规律。 + * @return 查询数据库表meta列表数据的SQL语句。 + */ + String getTableMetaListSql(String searchString); + + /** + * 获取当前数据库表meta数据的SQL语句。 + * + * @return 查询数据库表meta数据的SQL语句。 + */ + String getTableMetaSql(); + + /** + * 获取当前数据库指定表字段meta列表数据的SQL语句。 + * + * @return 查询指定表字段meta列表数据的SQL语句。 + */ + String getTableColumnMetaListSql(); + + /** + * 获取测试数据库连接的查询SQL。 + * + * @return 测试数据库连接的查询SQL + */ + default String getTestQuery() { + return "SELECT 'x'"; + } + + /** + * 为当前的SQL参数,加上分页部分。 + * + * @param sql SQL查询语句。 + * @param pageNum 页号,从1开始。 + * @param pageSize 每页数据量,如果为null,则取出后面所有数据。 + * @return 加上分页功能的SQL语句。 + */ + String makePageSql(String sql, Integer pageNum, Integer pageSize); + + /** + * 将数据表字段类型转换为Java字段类型。 + * + * @param columnType 数据表字段类型。 + * @param numericPrecision 数值精度。 + * @param numericScale 数值刻度。 + * @return 转换后的类型。 + */ + String convertColumnTypeToJavaType(String columnType, Integer numericPrecision, Integer numericScale); + + /** + * Having从句中,统计字段参与过滤时,是否可以直接使用别名。 + * + * @return 返回true,支持"HAVING sumOfColumn > 0",返回false,则为"HAVING sum(count) > 0"。 + */ + default boolean havingClauseUsingAlias() { + return true; + } + + /** + * SELECT的字段别名,是否需要加双引号,对于有些数据库,如果不加双引号,就会被数据库进行强制性的规则转义。 + * + * @return 返回true,SELECT grade_id "gradeId",否则 SELECT grade_id gradeId + */ + default boolean aliasWithQuotes() { + return false; + } + + /** + * 获取日期类型过滤条件语句。 + * + * @param columnName 字段名。 + * @param operator 操作符。 + * @return 过滤从句。 + */ + default String makeDateTimeFilterSql(String columnName, String operator) { + StringBuilder s = new StringBuilder(128); + if (columnName == null) { + columnName = ""; + } + return s.append(columnName).append(" ").append(operator).append(" ?").toString(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/JdbcConfig.java b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/JdbcConfig.java new file mode 100644 index 00000000..031b9541 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/JdbcConfig.java @@ -0,0 +1,62 @@ +package com.orangeforms.common.dbutil.provider; + +import lombok.Data; + +/** + * JDBC配置。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class JdbcConfig { + + /** + * 驱动名。由子类提供。 + */ + private String driver; + /** + * 连接池验证查询的语句。 + */ + private String validationQuery = "SELECT 'x'"; + /** + * Jdbc连接串,需要子类提供实现。 + */ + private String jdbcConnectionString; + /** + * 主机名。 + */ + private String host; + /** + * 端口号。 + */ + private Integer port; + /** + * 用户名。 + */ + private String username; + /** + * 密码。 + */ + private String password; + /** + * 数据库名。 + */ + private String database; + /** + * 模式名。 + */ + private String schema; + /** + * 连接池初始大小。 + */ + private int initialPoolSize = 5; + /** + * 连接池最小连接数。 + */ + private int minPoolSize = 5; + /** + * 连接池最大连接数。 + */ + private int maxPoolSize = 50; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/MySqlConfig.java b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/MySqlConfig.java new file mode 100644 index 00000000..cc7558b2 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/MySqlConfig.java @@ -0,0 +1,42 @@ +package com.orangeforms.common.dbutil.provider; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * MySQL JDBC配置。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class MySqlConfig extends JdbcConfig { + + /** + * JDBC 驱动名。 + */ + private String driver = "com.mysql.cj.jdbc.Driver"; + /** + * 数据库JDBC连接串的扩展部分。 + */ + private String extraParams = "?characterEncoding=utf8&useSSL=true&serverTimezone=Asia/Shanghai"; + + /** + * 获取拼好后的JDBC连接串。 + * + * @return 拼好后的JDBC连接串。 + */ + @Override + public String getJdbcConnectionString() { + StringBuilder sb = new StringBuilder(256); + sb.append("jdbc:mysql://") + .append(getHost()) + .append(":") + .append(getPort()) + .append("/") + .append(getDatabase()) + .append(extraParams); + return sb.toString(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/MySqlProvider.java b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/MySqlProvider.java new file mode 100644 index 00000000..e4e52bac --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/MySqlProvider.java @@ -0,0 +1,112 @@ +package com.orangeforms.common.dbutil.provider; + +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.orangeforms.common.core.constant.ObjectFieldType; +import com.orangeforms.common.dbutil.constant.DblinkType; + +/** + * MySQL数据源的提供者实现类。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class MySqlProvider implements DataSourceProvider { + + @Override + public int getDblinkType() { + return DblinkType.MYSQL; + } + + @Override + public JdbcConfig getJdbcConfig(String configuration) { + return JSON.parseObject(configuration, MySqlConfig.class); + } + + @Override + public String getTableMetaListSql(String searchString) { + StringBuilder sql = new StringBuilder(); + sql.append(this.getTableMetaListSql()); + if (StrUtil.isNotBlank(searchString)) { + sql.append(" AND table_name LIKE ?"); + } + return sql.append(" ORDER BY table_name").toString(); + } + + @Override + public String getTableMetaSql() { + return this.getTableMetaListSql() + " AND table_name = ?"; + } + + @Override + public String getTableColumnMetaListSql() { + return "SELECT " + + " column_name columnName, " + + " data_type columnType, " + + " column_type fullColumnType, " + + " column_comment columnComment, " + + " CASE WHEN column_key = 'PRI' THEN 1 ELSE 0 END AS primaryKey, " + + " is_nullable nullable, " + + " ordinal_position columnShowOrder, " + + " extra extra, " + + " CHARACTER_MAXIMUM_LENGTH stringPrecision, " + + " numeric_precision numericPrecision, " + + " COLUMN_DEFAULT columnDefault " + + "FROM " + + " information_schema.columns " + + "WHERE " + + " table_name = ?" + + " AND table_schema = (SELECT database()) " + + "ORDER BY ordinal_position"; + } + + @Override + public String makePageSql(String sql, Integer pageNum, Integer pageSize) { + if (pageSize == null) { + pageSize = 10; + } + int offset = pageNum > 0 ? (pageNum - 1) * pageSize : 0; + return sql + " LIMIT " + offset + "," + pageSize; + } + + @Override + public String convertColumnTypeToJavaType(String columnType, Integer numericPrecision, Integer numericScale) { + if (StrUtil.equalsAnyIgnoreCase(columnType, + "varchar", "char", "text", "longtext", "mediumtext", "tinytext", "enum", "json")) { + return ObjectFieldType.STRING; + } + if (StrUtil.equalsAnyIgnoreCase(columnType, "int", "mediumint", "smallint", "tinyint")) { + return ObjectFieldType.INTEGER; + } + if (StrUtil.equalsIgnoreCase(columnType, "bit")) { + return ObjectFieldType.BOOLEAN; + } + if (StrUtil.equalsIgnoreCase(columnType, "bigint")) { + return ObjectFieldType.LONG; + } + if (StrUtil.equalsIgnoreCase(columnType, "decimal")) { + return ObjectFieldType.BIG_DECIMAL; + } + if (StrUtil.equalsAnyIgnoreCase(columnType, "float", "double")) { + return ObjectFieldType.DOUBLE; + } + if (StrUtil.equalsAnyIgnoreCase(columnType, "date", "datetime", "timestamp", "time")) { + return ObjectFieldType.DATE; + } + if (StrUtil.equalsAnyIgnoreCase(columnType, "longblob", "blob")) { + return ObjectFieldType.BYTE_ARRAY; + } + return null; + } + + private String getTableMetaListSql() { + return "SELECT " + + " table_name tableName, " + + " table_comment tableComment, " + + " create_time createTime " + + "FROM " + + " information_schema.tables " + + "WHERE " + + " table_schema = DATABASE() "; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/util/DataSourceUtil.java b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/util/DataSourceUtil.java new file mode 100644 index 00000000..752e645e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/util/DataSourceUtil.java @@ -0,0 +1,838 @@ +package com.orangeforms.common.dbutil.util; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.druid.pool.DruidDataSource; +import com.alibaba.druid.pool.DruidDataSourceFactory; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.constant.FieldFilterType; +import com.orangeforms.common.core.exception.InvalidDblinkTypeException; +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.core.object.MyPageParam; +import com.orangeforms.common.core.object.Tuple2; +import com.orangeforms.common.core.util.MyDateUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.dbutil.constant.DblinkType; +import com.orangeforms.common.dbutil.provider.*; +import com.orangeforms.common.dbutil.constant.CustomDateValueType; +import com.orangeforms.common.dbutil.object.*; +import lombok.extern.slf4j.Slf4j; +import net.sf.jsqlparser.parser.CCJSqlParserUtil; +import net.sf.jsqlparser.schema.Column; +import net.sf.jsqlparser.statement.select.PlainSelect; +import net.sf.jsqlparser.statement.select.Select; +import net.sf.jsqlparser.statement.select.SelectExpressionItem; +import net.sf.jsqlparser.statement.select.SelectItem; +import org.joda.time.DateTime; + +import javax.sql.DataSource; +import java.sql.*; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + +/** + * 动态加载的数据源工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public abstract class DataSourceUtil { + + private final Lock lock = new ReentrantLock(); + private final Map datasourceMap = MapUtil.newHashMap(); + private static final Map PROVIDER_MAP = new HashMap<>(5); + protected final Map dblinkProviderMap = new ConcurrentHashMap<>(4); + + private static final String SQL_SELECT = " SELECT "; + private static final String SQL_SELECT_FROM = " SELECT * FROM ("; + private static final String SQL_AS_TMP = " ) tmp "; + private static final String SQL_ORDER_BY = " ORDER BY "; + private static final String SQL_AND = " AND "; + private static final String SQL_WHERE = " WHERE "; + private static final String LOG_PREPARING_FORMAT = "==> Preparing: {}"; + private static final String LOG_PARMS_FORMAT = "==> Parameters: {}"; + private static final String LOG_TOTAL_FORMAT = "<== Total: {}"; + + static { + PROVIDER_MAP.put(DblinkType.MYSQL, new MySqlProvider()); + } + + /** + * 由子类实现,根据dblinkId获取数据库链接类型的方法。 + * + * @param dblinkId 数据库链接Id。 + * @return 数据库链接类型。 + */ + protected abstract int getDblinkTypeByDblinkId(Long dblinkId); + + /** + * 由子类实现,根据dblinkId获取数据库链接配置信息的方法。 + * + * @param dblinkId 数据库链接Id。 + * @return 数据库链接配置信息。 + */ + protected abstract String getDblinkConfigurationByDblinkId(Long dblinkId); + + /** + * 获取指定数据库类型的Provider实现类。 + * + * @param dblinkType 数据库类型。 + * @return 指定数据库类型的Provider实现类。 + */ + public DataSourceProvider getProvider(Integer dblinkType) { + return PROVIDER_MAP.get(dblinkType); + } + + /** + * 获取指定数据库链接的Provider实现类。 + * + * @param dblinkId 数据库链接Id。 + * @return 指定数据库类型的Provider实现类。 + */ + public DataSourceProvider getProvider(Long dblinkId) { + int dblinkType = this.getDblinkTypeByDblinkId(dblinkId); + DataSourceProvider provider = PROVIDER_MAP.get(dblinkType); + if (provider == null) { + throw new InvalidDblinkTypeException(dblinkType); + } + return provider; + } + + /** + * 测试数据库链接。 + * + * @param dblinkId 数据库链接Id。 + */ + public void testConnection(Long dblinkId) throws Exception { + DataSourceProvider provider = this.getProvider(dblinkId); + this.query(dblinkId, provider.getTestQuery()); + } + + /** + * 通过JDBC方式测试链接。 + * + * @param databaseType 数据库类型。参考DblinkType常量值。 + * @param host 主机名。 + * @param port 端口号。 + * @param schemaName 模式名。 + * @param databaseName 数据库名。 + * @param username 用户名。 + * @param password 密码。 + */ + public static void testConnection( + int databaseType, + String host, + Integer port, + String schemaName, + String databaseName, + String username, + String password) { + StringBuilder urlBuilder = new StringBuilder(256); + String hostAndPort = host + ":" + port; + urlBuilder.append("jdbc:mysql://") + .append(hostAndPort) + .append("/") + .append(databaseName) + .append("?characterEncoding=utf8&useSSL=true&serverTimezone=Asia/Shanghai"); + try { + Connection conn = DriverManager.getConnection(urlBuilder.toString(), username, password); + conn.close(); + } catch (SQLException e) { + log.error(e.getMessage(), e); + throw new MyRuntimeException(e.getMessage()); + } + } + + /** + * 根据Dblink对象获取关联的数据源。如果不存在会创建该数据库连接池的数据源, + * 并保存到Map中缓存,下次调用时可直接返回。 + * + * @param dblinkId 数据库链接Id。 + * @return 关联的数据库连接池的数据源。 + */ + public DataSource getDataSource(Long dblinkId) throws Exception { + DataSource dataSource = datasourceMap.get(dblinkId); + if (dataSource != null) { + return dataSource; + } + int dblinkType = this.getDblinkTypeByDblinkId(dblinkId); + DataSourceProvider provider = PROVIDER_MAP.get(dblinkType); + if (provider == null) { + throw new InvalidDblinkTypeException(dblinkType); + } + DruidDataSource druidDataSource = null; + lock.lock(); + try { + dataSource = datasourceMap.get(dblinkId); + if (dataSource != null) { + return dataSource; + } + JdbcConfig jdbcConfig = provider.getJdbcConfig(this.getDblinkConfigurationByDblinkId(dblinkId)); + Properties properties = new Properties(); + druidDataSource = (DruidDataSource) DruidDataSourceFactory.createDataSource(properties); + druidDataSource.setUrl(jdbcConfig.getJdbcConnectionString()); + druidDataSource.setDriverClassName(jdbcConfig.getDriver()); + druidDataSource.setValidationQuery(jdbcConfig.getValidationQuery()); + druidDataSource.setUsername(jdbcConfig.getUsername()); + druidDataSource.setPassword(jdbcConfig.getPassword()); + druidDataSource.setInitialSize(jdbcConfig.getInitialPoolSize()); + druidDataSource.setMinIdle(jdbcConfig.getMinPoolSize()); + druidDataSource.setMaxActive(jdbcConfig.getMaxPoolSize()); + druidDataSource.setConnectionErrorRetryAttempts(2); + druidDataSource.setTimeBetweenConnectErrorMillis(500); + druidDataSource.setBreakAfterAcquireFailure(true); + druidDataSource.init(); + datasourceMap.put(dblinkId, druidDataSource); + return druidDataSource; + } catch (Exception e) { + if (druidDataSource != null) { + druidDataSource.close(); + } + log.error("Failed to create DruidDatasource", e); + throw e; + } finally { + lock.unlock(); + } + } + + /** + * 关闭指定数据库链接Id关联的数据源,同时从缓存中移除该数据源对象。 + * + * @param dblinkId 数据库链接Id。 + */ + public void removeDataSource(Long dblinkId) { + lock.lock(); + try { + DataSource dataSource = datasourceMap.get(dblinkId); + if (dataSource == null) { + return; + } + ((DruidDataSource) dataSource).close(); + datasourceMap.remove(dblinkId); + } finally { + lock.unlock(); + } + } + + /** + * 获取指定数据源的数据库连接对象。 + * + * @param dblinkId 数据库链接Id。 + * @return 数据库连接对象。 + */ + public Connection getConnection(Long dblinkId) throws Exception { + DataSource dataSource = this.getDataSource(dblinkId); + return dataSource == null ? null : dataSource.getConnection(); + } + + /** + * 获取指定数据库链接的数据表列表。 + * + * @param dblinkId 数据库链接Id。 + * @param searchString 表名的模糊匹配字符串。如果为空,则没有前缀规律。 + * @return 数据表对象列表。 + */ + public List getTableList(Long dblinkId, String searchString) { + DataSourceProvider provider = this.getProvider(dblinkId); + List paramList = null; + if (StrUtil.isNotBlank(searchString)) { + paramList = new LinkedList<>(); + paramList.add("%" + searchString + "%"); + } + String querySql = provider.getTableMetaListSql(searchString); + try { + return this.query(dblinkId, querySql, paramList, SqlTable.class); + } catch (Exception e) { + log.error("Failed to call getTableList", e); + throw new MyRuntimeException(e); + } + } + + /** + * 获取指定数据库链接的数据表对象。 + * + * @param dblinkId 数据库链接Id。 + * @param tableName 表名称。 + * @return 数据表对象。 + */ + public SqlTable getTable(Long dblinkId, String tableName) { + DataSourceProvider provider = this.getProvider(dblinkId); + String querySql = provider.getTableMetaSql(); + List paramList = new LinkedList<>(); + paramList.add(tableName); + try { + return this.queryOne(dblinkId, querySql, paramList, SqlTable.class); + } catch (Exception e) { + log.error("Failed to call getTable", e); + throw new MyRuntimeException(e); + } + } + + /** + * 获取指定数据库链接下数据表的字段列表。 + * + * @param dblinkId 数据库链接Id。 + * @param tableName 表名称。 + * @return 数据表的字段列表。 + */ + public List getTableColumnList(Long dblinkId, String tableName) { + try { + DataSource dataSource = this.getDataSource(dblinkId); + try (Connection conn = dataSource.getConnection()) { + return this.getTableColumnList(dblinkId, conn, tableName); + } + } catch (Exception e) { + log.error("Failed to call getTableColumnList", e); + throw new MyRuntimeException(e); + } + } + + /** + * 获取指定数据库链接下数据表的字段列表。 + * + * @param dblinkId 数据库链接Id。 + * @param conn 数据库连接对象。 + * @param tableName 表名称。 + * @return 数据表的字段列表。 + */ + public List getTableColumnList(Long dblinkId, Connection conn, String tableName) { + DataSourceProvider provider = this.getProvider(dblinkId); + String querySql = provider.getTableColumnMetaListSql(); + List paramList = new LinkedList<>(); + paramList.add(tableName); + try { + List> dataList = this.query(conn, querySql, paramList); + return this.toTypedDataList(dataList, SqlTableColumn.class); + } catch (Exception e) { + log.error("Failed to call getTableColumnList", e); + throw new MyRuntimeException(e); + } + } + + /** + * 获取指定表的数据。 + * + * @param dblinkId 数据库链接Id。 + * @param tableName 表名。 + * @param datasetParam 数据集查询参数对象。 + * @return 表的数据结果。 + */ + public SqlResultSet> getTableDataList( + Long dblinkId, String tableName, DatasetParam datasetParam) throws Exception { + SqlTable table = this.getTable(dblinkId, tableName); + if (table == null) { + return null; + } + DataSourceProvider provider = this.getProvider(dblinkId); + if (datasetParam == null) { + datasetParam = new DatasetParam(); + } + String sql = "SELECT * FROM " + tableName; + if (CollUtil.isNotEmpty(datasetParam.getSelectColumnNameList())) { + sql = SQL_SELECT + StrUtil.join(",", datasetParam.getSelectColumnNameList()) + " FROM " + tableName; + } + Tuple2> filterTuple = this.buildWhereClauseByFilters(dblinkId, datasetParam.getFilter()); + sql += filterTuple.getFirst(); + List paramList = filterTuple.getSecond(); + String sqlCount = null; + MyPageParam pageParam = datasetParam.getPageParam(); + if (pageParam != null) { + net.sf.jsqlparser.statement.Statement statement = CCJSqlParserUtil.parse(sql); + Select select = (Select) statement; + PlainSelect selectBody = (PlainSelect) select.getSelectBody(); + List countSelectItems = new LinkedList<>(); + countSelectItems.add(new SelectExpressionItem(new Column("COUNT(1) AS CNT"))); + selectBody.setSelectItems(countSelectItems); + sqlCount = select.toString(); + sql = provider.makePageSql(sql, pageParam.getPageNum(), pageParam.getPageSize()); + } + return this.getDataListInternnally(dblinkId, provider, sqlCount, sql, datasetParam, paramList); + } + + /** + * 在指定数据库链接上执行查询语句,并返回指定映射对象类型的单条数据对象。 + * + * @param dblinkId 数据库链接Id。 + * @param query 待执行的SQL语句。 + * @param paramList 参数列表。 + * @param clazz 返回的映射对象Class类型。 + * @return 查询的结果对象。 + */ + public T queryOne(Long dblinkId, String query, List paramList, Class clazz) throws Exception { + List dataList = this.query(dblinkId, query, paramList, clazz); + return CollUtil.isEmpty(dataList) ? null : dataList.get(0); + } + + /** + * 在指定数据库链接上执行查询语句,并返回指定映射对象类型的数据列表。 + * + * @param dblinkId 数据库链接Id。 + * @param query 待执行的SQL语句。 + * @param paramList 参数列表。 + * @param clazz 返回的映射对象Class类型。 + * @return 查询的结果集。 + */ + public List query(Long dblinkId, String query, List paramList, Class clazz) throws Exception { + List> dataList = this.query(dblinkId, query, paramList); + return this.toTypedDataList(dataList, clazz); + } + + /** + * 在指定数据库链接上执行查询语句。 + * + * @param dblinkId 数据库链接Id。 + * @param query 待执行的SQL语句。 + * @return 查询的结果集。 + */ + public List> query(Long dblinkId, String query) throws Exception { + DataSource dataSource = this.getDataSource(dblinkId); + try (Connection conn = dataSource.getConnection()) { + return this.query(conn, query); + } catch (Exception e) { + log.error(e.getMessage(), e); + throw e; + } + } + + /** + * 在指定数据库链接上执行查询语句。 + * + * @param dblinkId 数据库链接Id。 + * @param query 待执行的SQL语句。 + * @param paramList 参数列表。 + * @return 查询的结果集。 + */ + public List> query(Long dblinkId, String query, List paramList) throws Exception { + DataSource dataSource = this.getDataSource(dblinkId); + try (Connection conn = dataSource.getConnection()) { + return this.query(conn, query, paramList); + } + } + + /** + * 计算过滤从句和过滤参数。 + * + * @param dblinkId 数据库链接Id。 + * @param filter 过滤参数列表。 + * @return 返回的Tuple对象的第一个参数是WHERE从句,第二个参数是过滤从句用到的参数列表。 + */ + public Tuple2> buildWhereClauseByFilters(Long dblinkId, DatasetFilter filter) { + filter = this.normalizeFilter(filter); + if (CollUtil.isEmpty(filter)) { + return new Tuple2<>("", null); + } + DataSourceProvider provider = this.getProvider(dblinkId); + StringBuilder where = new StringBuilder(); + int i = 0; + List paramList = new LinkedList<>(); + for (DatasetFilter.FilterInfo filterInfo : filter) { + if (i++ == 0) { + where.append(SQL_WHERE); + } else { + where.append(SQL_AND); + } + this.doBuildWhereClauseByFilter(filterInfo, provider, where, paramList); + } + return new Tuple2<>(where.toString(), paramList); + } + + private void doBuildWhereClauseByFilter( + DatasetFilter.FilterInfo filterInfo, + DataSourceProvider provider, + StringBuilder where, + List paramList) { + where.append(filterInfo.getParamName()); + if (filterInfo.getFilterType().equals(FieldFilterType.EQUAL)) { + this.doBuildWhereClauseByEqualFilter(filterInfo, provider, where, paramList); + } else if (filterInfo.getFilterType().equals(FieldFilterType.NOT_EQUAL)) { + where.append(" <> ?"); + paramList.add(filterInfo.getParamValue()); + } else if (filterInfo.getFilterType().equals(FieldFilterType.GE)) { + this.doBuildWhereClauseByGeFilter(filterInfo, provider, where, paramList); + } else if (filterInfo.getFilterType().equals(FieldFilterType.GT)) { + this.doBuildWhereClauseByGtFilter(filterInfo, provider, where, paramList); + } else if (filterInfo.getFilterType().equals(FieldFilterType.LE)) { + this.doBuildWhereClauseByLeFilter(filterInfo, provider, where, paramList); + } else if (filterInfo.getFilterType().equals(FieldFilterType.LT)) { + this.doBuildWhereClauseByLtFilter(filterInfo, provider, where, paramList); + } else if (filterInfo.getFilterType().equals(FieldFilterType.BETWEEN)) { + this.doBuildWhereClauseByBetweenFilter(filterInfo, provider, where, paramList); + } else if (filterInfo.getFilterType().equals(FieldFilterType.LIKE)) { + where.append(" LIKE ?"); + paramList.add("%" + filterInfo.getParamValue() + "%"); + } else if (filterInfo.getFilterType().equals(FieldFilterType.IN)) { + where.append(" IN ("); + where.append(StrUtil.repeatAndJoin("?", filterInfo.getParamValueList().size(), ",")); + where.append(")"); + paramList.addAll(filterInfo.getParamValueList()); + } else if (filterInfo.getFilterType().equals(FieldFilterType.NOT_IN)) { + where.append(" NOT IN ("); + where.append(StrUtil.repeatAndJoin("?", filterInfo.getParamValueList().size(), ",")); + where.append(")"); + paramList.addAll(filterInfo.getParamValueList()); + } else if (filterInfo.getFilterType().equals(FieldFilterType.IS_NOT_NULL)) { + where.append(" IS NOT NULL"); + } else if (filterInfo.getFilterType().equals(FieldFilterType.IS_NULL)) { + where.append(" IS NULL"); + } + } + + private void doBuildWhereClauseByEqualFilter( + DatasetFilter.FilterInfo filter, + DataSourceProvider provider, + StringBuilder where, + List paramList) { + if (BooleanUtil.isTrue(filter.getDateValueFilter())) { + String beginDateTime = this.getBeginDateTime(filter.getParamValue().toString(), filter.getDateRange()); + String endDateTime = this.getEndDateTime(filter.getParamValue().toString(), filter.getDateRange()); + where.append(provider.makeDateTimeFilterSql(null, ">=")); + where.append(SQL_AND); + where.append(provider.makeDateTimeFilterSql(filter.getParamName(), "<=")); + paramList.add(beginDateTime); + paramList.add(endDateTime); + } else { + where.append(" = ?"); + paramList.add(filter.getParamValue()); + } + } + + private void doBuildWhereClauseByGeFilter( + DatasetFilter.FilterInfo filter, + DataSourceProvider provider, + StringBuilder where, + List paramList) { + if (BooleanUtil.isTrue(filter.getDateValueFilter())) { + where.append(provider.makeDateTimeFilterSql(null, ">=")); + paramList.add(this.getBeginDateTime(filter.getParamValue().toString(), filter.getDateRange())); + } else { + paramList.add(filter.getParamValue()); + where.append(" >= ?"); + } + } + + private void doBuildWhereClauseByGtFilter( + DatasetFilter.FilterInfo filter, + DataSourceProvider provider, + StringBuilder where, + List paramList) { + if (BooleanUtil.isTrue(filter.getDateValueFilter())) { + where.append(provider.makeDateTimeFilterSql(null, ">")); + paramList.add(this.getEndDateTime(filter.getParamValue().toString(), filter.getDateRange())); + } else { + where.append(" > ?"); + paramList.add(filter.getParamValue()); + } + } + + private void doBuildWhereClauseByLeFilter( + DatasetFilter.FilterInfo filter, + DataSourceProvider provider, + StringBuilder where, + List paramList) { + if (BooleanUtil.isTrue(filter.getDateValueFilter())) { + where.append(provider.makeDateTimeFilterSql(null, "<=")); + paramList.add(this.getEndDateTime(filter.getParamValue().toString(), filter.getDateRange())); + } else { + where.append(" <= ?"); + paramList.add(filter.getParamValue()); + } + } + + private void doBuildWhereClauseByLtFilter( + DatasetFilter.FilterInfo filter, + DataSourceProvider provider, + StringBuilder where, + List paramList) { + if (BooleanUtil.isTrue(filter.getDateValueFilter())) { + where.append(provider.makeDateTimeFilterSql(null, "<")); + paramList.add(this.getBeginDateTime(filter.getParamValue().toString(), filter.getDateRange())); + } else { + where.append(" < ?"); + paramList.add(filter.getParamValue()); + } + } + + private void doBuildWhereClauseByBetweenFilter( + DatasetFilter.FilterInfo filter, + DataSourceProvider provider, + StringBuilder where, + List paramList) { + if (CollUtil.isEmpty(filter.getParamValueList())) { + return; + } + if (BooleanUtil.isTrue(filter.getDateValueFilter())) { + Object[] filterArray = filter.getParamValueList().toArray(); + where.append(provider.makeDateTimeFilterSql(null, ">=")); + paramList.add(this.getBeginDateTime(filterArray[0].toString(), filter.getDateRange())); + where.append(SQL_AND); + where.append(filter.getParamName()); + where.append(provider.makeDateTimeFilterSql(null, "<=")); + paramList.add(this.getEndDateTime(filterArray[1].toString(), filter.getDateRange())); + } else { + where.append(" BETWEEN ? AND ?"); + paramList.add(filter.getParamValueList()); + } + } + + private SqlResultSet> getDataListInternnally( + Long dblinkId, + DataSourceProvider provider, + String sqlCount, + String sql, + DatasetParam datasetParam, + List paramList) throws Exception { + Long totalCount = 0L; + SqlResultSet> resultSet = null; + try (Connection connection = this.getConnection(dblinkId)) { + boolean ignoreQueryData = false; + if (sqlCount != null) { + Map data = this.query(connection, sqlCount, paramList).get(0); + String key = data.entrySet().iterator().next().getKey(); + totalCount = (Long) data.get(key); + if (totalCount == 0L) { + ignoreQueryData = true; + } + } + if (!ignoreQueryData) { + if (datasetParam.getOrderBy() != null) { + sql += SQL_ORDER_BY + datasetParam.getOrderBy(); + } + resultSet = this.queryWithMeta(connection, sql, paramList); + resultSet.setTotalCount(totalCount); + } + } + return resultSet == null ? new SqlResultSet<>() : resultSet; + } + + private List> query(Connection conn, String query) throws SQLException { + try (Statement stat = conn.createStatement(); + ResultSet rs = stat.executeQuery(query)) { + log.info(LOG_PREPARING_FORMAT, query); + List> resultList = this.fetchResult(rs); + log.info(LOG_TOTAL_FORMAT, resultList.size()); + return resultList; + } catch (SQLException e) { + log.error(e.getMessage(), e); + throw e; + } + } + + private List> query(Connection conn, String query, List paramList) throws SQLException { + if (CollUtil.isEmpty(paramList)) { + return this.query(conn, query); + } + ResultSet rs = null; + try (PreparedStatement stat = conn.prepareStatement(query)) { + for (int i = 0; i < paramList.size(); i++) { + stat.setObject(i + 1, paramList.get(i)); + } + rs = stat.executeQuery(); + log.info(LOG_PREPARING_FORMAT, query); + List> resultList = this.fetchResult(rs); + log.info(LOG_TOTAL_FORMAT, resultList.size()); + return resultList; + } catch (SQLException e) { + log.error(e.getMessage(), e); + throw e; + } finally { + if (rs != null) { + try { + rs.close(); + } catch (Exception e) { + log.error("Failed to call rs.close", e); + } + } + } + } + + private SqlResultSet> queryWithMeta( + Connection connection, String query, List paramList) throws SQLException { + if (CollUtil.isEmpty(paramList)) { + try (Statement stat = connection.createStatement(); + ResultSet rs = stat.executeQuery(query)) { + log.info(LOG_PREPARING_FORMAT, query); + SqlResultSet> resultSet = this.fetchResultWithMeta(rs); + log.info(LOG_TOTAL_FORMAT, resultSet.getDataList() == null ? 0 : resultSet.getDataList().size()); + return resultSet; + } catch (SQLException e) { + log.error(e.getMessage(), e); + throw e; + } + } + ResultSet rs = null; + try (PreparedStatement stat = connection.prepareStatement(query)) { + for (int i = 0; i < paramList.size(); i++) { + stat.setObject(i + 1, paramList.get(i)); + } + rs = stat.executeQuery(); + log.info(LOG_PREPARING_FORMAT, query); + SqlResultSet> resultSet = this.fetchResultWithMeta(rs); + log.info(LOG_TOTAL_FORMAT, resultSet.getDataList() == null ? 0 : resultSet.getDataList().size()); + return resultSet; + } catch (SQLException e) { + log.error(e.getMessage(), e); + throw e; + } finally { + if (rs != null) { + try { + rs.close(); + } catch (Exception e) { + log.error("Failed to call rs.close", e); + } + } + } + } + + private List> fetchResult(ResultSet rs) throws SQLException { + ResultSetMetaData metaData = rs.getMetaData(); + int columnCount = metaData.getColumnCount(); + List> resultList = new LinkedList<>(); + while (rs.next()) { + JSONObject rowData = new JSONObject(); + for (int i = 0; i < columnCount; i++) { + rowData.put(metaData.getColumnLabel(i + 1), rs.getObject(i + 1)); + } + resultList.add(rowData); + } + return resultList; + } + + private SqlResultSet> fetchResultWithMeta(ResultSet rs) throws SQLException { + ResultSetMetaData metaData = rs.getMetaData(); + List columnMetaList = new LinkedList<>(); + int columnCount = metaData.getColumnCount(); + for (int i = 0; i < columnCount; i++) { + SqlTableColumn tableColumn = new SqlTableColumn(); + String columnLabel = metaData.getColumnLabel(i + 1); + tableColumn.setColumnName(columnLabel); + tableColumn.setColumnType(metaData.getColumnTypeName(i + 1)); + columnMetaList.add(tableColumn); + } + List> resultList = new LinkedList<>(); + while (rs.next()) { + JSONObject rowData = new JSONObject(); + for (int i = 0; i < columnCount; i++) { + rowData.put(metaData.getColumnLabel(i + 1), rs.getObject(i + 1)); + } + resultList.add(rowData); + } + return new SqlResultSet<>(columnMetaList, resultList); + } + + private List toTypedDataList(List> dataList, Class clazz) { + return MyModelUtil.mapToBeanList(dataList, clazz); + } + + private String getBeginDateTime(String dateValueType, String dateRange) { + DateTime now = DateTime.now(); + switch (dateValueType) { + case CustomDateValueType.CURRENT_DAY: + return MyDateUtil.getBeginTimeOfDayWithShort(now); + case CustomDateValueType.CURRENT_WEEK: + return MyDateUtil.getBeginDateTimeOfWeek(now); + case CustomDateValueType.CURRENT_MONTH: + return MyDateUtil.getBeginDateTimeOfMonth(now); + case CustomDateValueType.CURRENT_YEAR: + return MyDateUtil.getBeginDateTimeOfYear(now); + case CustomDateValueType.CURRENT_QUARTER: + return MyDateUtil.getBeginDateTimeOfQuarter(now); + case CustomDateValueType.LAST_DAY: + return MyDateUtil.getBeginTimeOfDay(now.minusDays(1)); + case CustomDateValueType.LAST_WEEK: + return MyDateUtil.getBeginDateTimeOfWeek(now.minusWeeks(1)); + case CustomDateValueType.LAST_MONTH: + return MyDateUtil.getBeginDateTimeOfMonth(now.minusMonths(1)); + case CustomDateValueType.LAST_YEAR: + return MyDateUtil.getBeginDateTimeOfYear(now.minusYears(1)); + case CustomDateValueType.LAST_QUARTER: + return MyDateUtil.getBeginDateTimeOfQuarter(now.minusMonths(3)); + default: + break; + } + // 执行到这里,基本就是自定义日期数据了 + if (StrUtil.isBlank(dateRange)) { + return dateValueType; + } + DateTime dateValue = MyDateUtil.toDateTimeWithoutMs(dateValueType); + switch (dateRange) { + case "year": + return MyDateUtil.getBeginDateTimeOfYear(dateValue); + case "month": + return MyDateUtil.getBeginDateTimeOfMonth(dateValue); + case "week": + return MyDateUtil.getBeginDateTimeOfWeek(dateValue); + case "date": + return MyDateUtil.getBeginTimeOfDayWithShort(dateValue); + default: + break; + } + return dateValueType; + } + + private String getEndDateTime(String dateValueType, String dateRange) { + DateTime now = DateTime.now(); + switch (dateValueType) { + case CustomDateValueType.CURRENT_DAY: + return MyDateUtil.getEndTimeOfDayWithShort(now); + case CustomDateValueType.CURRENT_WEEK: + return MyDateUtil.getEndDateTimeOfWeek(now); + case CustomDateValueType.CURRENT_MONTH: + return MyDateUtil.getEndDateTimeOfMonth(now); + case CustomDateValueType.CURRENT_YEAR: + return MyDateUtil.getEndDateTimeOfYear(now); + case CustomDateValueType.CURRENT_QUARTER: + return MyDateUtil.getEndDateTimeOfQuarter(now); + case CustomDateValueType.LAST_DAY: + return MyDateUtil.getEndTimeOfDay(now.minusDays(1)); + case CustomDateValueType.LAST_WEEK: + return MyDateUtil.getEndDateTimeOfWeek(now.minusWeeks(1)); + case CustomDateValueType.LAST_MONTH: + return MyDateUtil.getEndDateTimeOfMonth(now.minusMonths(1)); + case CustomDateValueType.LAST_YEAR: + return MyDateUtil.getEndDateTimeOfYear(now.minusYears(1)); + case CustomDateValueType.LAST_QUARTER: + return MyDateUtil.getEndDateTimeOfQuarter(now.minusMonths(3)); + default: + break; + } + // 执行到这里,基本就是自定义日期数据了 + if (StrUtil.isBlank(dateRange)) { + return dateValueType; + } + DateTime dateValue = MyDateUtil.toDateTimeWithoutMs(dateValueType); + switch (dateRange) { + case "year": + return MyDateUtil.getEndDateTimeOfYear(dateValue); + case "month": + return MyDateUtil.getEndDateTimeOfMonth(dateValue); + case "week": + return MyDateUtil.getEndDateTimeOfWeek(dateValue); + case "date": + return MyDateUtil.getEndTimeOfDayWithShort(dateValue); + default: + break; + } + return dateValueType; + } + + private DatasetFilter normalizeFilter(DatasetFilter filter) { + if (CollUtil.isEmpty(filter)) { + return filter; + } + DatasetFilter normalizedFilter = new DatasetFilter(); + for (DatasetFilter.FilterInfo filterInfo : filter) { + if (filterInfo.getFilterType().equals(FieldFilterType.IS_NULL) + || filterInfo.getFilterType().equals(FieldFilterType.IS_NOT_NULL) + || filterInfo.getParamValue() != null + || filterInfo.getParamValueList() != null) { + normalizedFilter.add(filterInfo); + } + } + return normalizedFilter; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/pom.xml b/OrangeFormsOpen-MybatisFlex/common/common-dict/pom.xml new file mode 100644 index 00000000..c2fc5d2d --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/pom.xml @@ -0,0 +1,31 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-dict + + + + com.orangeforms + common-redis + 1.0.0 + + + com.orangeforms + common-sequence + 1.0.0 + + + com.orangeforms + common-swagger + 1.0.0 + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/constant/GlobalDictItemStatus.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/constant/GlobalDictItemStatus.java new file mode 100644 index 00000000..3076abfa --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/constant/GlobalDictItemStatus.java @@ -0,0 +1,44 @@ +package com.orangeforms.common.dict.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 全局字典项目数据状态。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class GlobalDictItemStatus { + + /** + * 正常。 + */ + public static final int NORMAL = 0; + /** + * 禁用。 + */ + public static final int DISABLED = 1; + + private static final Map DICT_MAP = new HashMap<>(4); + static { + DICT_MAP.put(NORMAL, "正常"); + DICT_MAP.put(DISABLED, "禁用"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private GlobalDictItemStatus() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/GlobalDictItemMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/GlobalDictItemMapper.java new file mode 100644 index 00000000..640491b6 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/GlobalDictItemMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.dict.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.dict.model.GlobalDictItem; + +/** + * 全局字典项目数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface GlobalDictItemMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/GlobalDictMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/GlobalDictMapper.java new file mode 100644 index 00000000..eb8951e3 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/GlobalDictMapper.java @@ -0,0 +1,34 @@ +package com.orangeforms.common.dict.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.dict.model.GlobalDict; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +/** + * 全局字典数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface GlobalDictMapper extends BaseDaoMapper { + + /** + * 获取全局编码字典。 + * @param filter 过滤对象。 + * @param orderBy 排序字符串。 + * @return 全局编码字典。 + */ + @Select("") + List getGlobalDictList(@Param("filter") GlobalDict filter, @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/TenantGlobalDictItemMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/TenantGlobalDictItemMapper.java new file mode 100644 index 00000000..8a744d02 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/TenantGlobalDictItemMapper.java @@ -0,0 +1,54 @@ +package com.orangeforms.common.dict.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.dict.model.TenantGlobalDictItem; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 租户全局字典项目数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface TenantGlobalDictItemMapper extends BaseDaoMapper { + + /** + * 批量插入。 + * + * @param dictItemList 字典条目列表。 + */ + @Insert("") + void insertList(@Param("dictItemList") List dictItemList); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/TenantGlobalDictMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/TenantGlobalDictMapper.java new file mode 100644 index 00000000..6735d704 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/TenantGlobalDictMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.dict.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.dict.model.TenantGlobalDict; + +/** + * 租户全局字典数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface TenantGlobalDictMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/GlobalDictDto.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/GlobalDictDto.java new file mode 100644 index 00000000..564655d7 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/GlobalDictDto.java @@ -0,0 +1,40 @@ +package com.orangeforms.common.dict.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import com.orangeforms.common.core.validator.UpdateGroup; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 全局系统字典Dto。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "全局系统字典Dto") +@Data +public class GlobalDictDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long dictId; + + /** + * 字典编码。 + */ + @Schema(description = "字典编码") + @NotBlank(message = "数据验证失败,字典编码不能为空!") + private String dictCode; + + /** + * 字典中文名称。 + */ + @Schema(description = "字典中文名称") + @NotBlank(message = "数据验证失败,字典中文名称不能为空!") + private String dictName; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/GlobalDictItemDto.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/GlobalDictItemDto.java new file mode 100644 index 00000000..e80a934f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/GlobalDictItemDto.java @@ -0,0 +1,54 @@ +package com.orangeforms.common.dict.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import com.orangeforms.common.core.validator.UpdateGroup; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 全局系统字典项目Dto。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "全局系统字典项目Dto") +@Data +public class GlobalDictItemDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long id; + + /** + * 字典编码。 + */ + @Schema(description = "字典编码") + @NotBlank(message = "数据验证失败,字典编码不能为空!") + private String dictCode; + + /** + * 字典数据项Id。 + */ + @Schema(description = "字典数据项Id") + @NotNull(message = "数据验证失败,字典数据项Id不能为空!") + private String itemId; + + /** + * 字典数据项名称。 + */ + @Schema(description = "字典数据项名称") + @NotBlank(message = "数据验证失败,字典数据项名称不能为空!") + private String itemName; + + /** + * 显示顺序(数值越小越靠前)。 + */ + @Schema(description = "显示顺序") + @NotNull(message = "数据验证失败,显示顺序不能为空!") + private Integer showOrder; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/TenantGlobalDictDto.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/TenantGlobalDictDto.java new file mode 100644 index 00000000..63f55953 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/TenantGlobalDictDto.java @@ -0,0 +1,29 @@ +package com.orangeforms.common.dict.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 租户全局系统字典Dto。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "租户全局系统字典Dto") +@EqualsAndHashCode(callSuper = true) +@Data +public class TenantGlobalDictDto extends GlobalDictDto { + + /** + * 是否为所有租户的通用字典。 + */ + @Schema(description = "是否为所有租户的通用字典") + private Boolean tenantCommon; + + /** + * 租户的非公用字典的初始化字典数据。 + */ + @Schema(description = "租户的非公用字典的初始化字典数据") + private String initialData; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/TenantGlobalDictItemDto.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/TenantGlobalDictItemDto.java new file mode 100644 index 00000000..f6ac99a6 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/TenantGlobalDictItemDto.java @@ -0,0 +1,18 @@ +package com.orangeforms.common.dict.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 租户全局系统字典项目Dto。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "租户全局系统字典项目Dto") +@EqualsAndHashCode(callSuper = true) +@Data +public class TenantGlobalDictItemDto extends GlobalDictItemDto { + +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/model/GlobalDict.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/model/GlobalDict.java new file mode 100644 index 00000000..148b1596 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/model/GlobalDict.java @@ -0,0 +1,65 @@ +package com.orangeforms.common.dict.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; + +import java.util.Date; + +/** + * 全局系统字典实体类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_global_dict") +public class GlobalDict { + + /** + * 主键Id。 + */ + @Id(value = "dict_id") + private Long dictId; + + /** + * 字典编码。 + */ + @Column(value = "dict_code") + private String dictCode; + + /** + * 字典中文名称。 + */ + @Column(value = "dict_name") + private String dictName; + + /** + * 更新用户名。 + */ + @Column(value = "update_user_id") + private Long updateUserId; + + /** + * 更新时间。 + */ + @Column(value = "update_time") + private Date updateTime; + + /** + * 创建用户Id。 + */ + @Column(value = "create_user_id") + private Long createUserId; + + /** + * 创建时间。 + */ + @Column(value = "create_time") + private Date createTime; + + /** + * 逻辑删除字段。 + */ + @Column(value = "deleted_flag", isLogicDelete = true) + private Integer deletedFlag; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/model/GlobalDictItem.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/model/GlobalDictItem.java new file mode 100644 index 00000000..8e1b3664 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/model/GlobalDictItem.java @@ -0,0 +1,82 @@ +package com.orangeforms.common.dict.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; + +import java.util.Date; + +/** + * 全局系统字典项目实体类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_global_dict_item") +public class GlobalDictItem { + + /** + * 主键Id。 + */ + @Id(value = "id") + private Long id; + + /** + * 字典编码。 + */ + @Column(value = "dict_code") + private String dictCode; + + /** + * 字典数据项Id。 + */ + @Column(value = "item_id") + private String itemId; + + /** + * 字典数据项名称。 + */ + @Column(value = "item_name") + private String itemName; + + /** + * 显示顺序(数值越小越靠前)。 + */ + @Column(value = "show_order") + private Integer showOrder; + + /** + * 字典状态。具体值引用DictItemStatus常量类。 + */ + private Integer status; + + /** + * 创建时间。 + */ + @Column(value = "create_time") + private Date createTime; + + /** + * 创建用户Id。 + */ + @Column(value = "create_user_id") + private Long createUserId; + + /** + * 更新用户名。 + */ + @Column(value = "update_user_id") + private Long updateUserId; + + /** + * 更新时间。 + */ + @Column(value = "update_time") + private Date updateTime; + + /** + * 逻辑删除字段。 + */ + @Column(value = "deleted_flag", isLogicDelete = true) + private Integer deletedFlag; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/model/TenantGlobalDict.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/model/TenantGlobalDict.java new file mode 100644 index 00000000..0a2f16c8 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/model/TenantGlobalDict.java @@ -0,0 +1,29 @@ +package com.orangeforms.common.dict.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 租户全局系统字典实体类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@Table(value = "zz_tenant_global_dict") +public class TenantGlobalDict extends GlobalDict { + + /** + * 是否为所有租户的通用字典。 + */ + @Column(value = "tenant_common") + private Boolean tenantCommon; + + /** + * 租户的非公用字典的初始化字典数据。 + */ + @Column(value = "initial_data") + private String initialData; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/model/TenantGlobalDictItem.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/model/TenantGlobalDictItem.java new file mode 100644 index 00000000..5a637533 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/model/TenantGlobalDictItem.java @@ -0,0 +1,23 @@ +package com.orangeforms.common.dict.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 租户全局系统字典项目实体类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@Table(value = "zz_tenant_global_dict_item") +public class TenantGlobalDictItem extends GlobalDictItem { + + /** + * 租户Id。 + */ + @Column(value = "tenant_id") + private Long tenantId; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/GlobalDictItemService.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/GlobalDictItemService.java new file mode 100644 index 00000000..66750ff7 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/GlobalDictItemService.java @@ -0,0 +1,92 @@ +package com.orangeforms.common.dict.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.dict.model.GlobalDictItem; + +import java.io.Serializable; +import java.util.List; + +/** + * 全局字典项目数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface GlobalDictItemService extends IBaseService { + + /** + * 保存新增的全局字典项目。 + * + * @param globalDictItem 新字典项目对象。 + * @return 保存后的对象。 + */ + GlobalDictItem saveNew(GlobalDictItem globalDictItem); + + /** + * 更新全局字典项目对象。 + * + * @param globalDictItem 更新的全局字典项目对象。 + * @param originalGlobalDictItem 原有的全局字典项目对象。 + * @return 更新成功返回true,否则false。 + */ + boolean update(GlobalDictItem globalDictItem, GlobalDictItem originalGlobalDictItem); + + /** + * 更新字典条目的编码。 + * + * @param oldCode 原有编码。 + * @param newCode 新编码。 + */ + void updateNewCode(String oldCode, String newCode); + + /** + * 更新字典条目的状态。 + * + * @param globalDictItem 字典项目对象。 + * @param status 状态值。 + */ + void updateStatus(GlobalDictItem globalDictItem, Integer status); + + /** + * 删除指定字典项目。 + * + * @param globalDictItem 待删除字典项目。 + * @return 成功返回true,否则false。 + */ + boolean remove(GlobalDictItem globalDictItem); + + /** + * 判断指定的编码和项目Id是否存在。 + * + * @param dictCode 字典编码。 + * @param itemId 项目Id。 + * @return true存在,否则false。 + */ + boolean existDictCodeAndItemId(String dictCode, Serializable itemId); + + /** + * 根据字典编码和项目Id获取指定字段项目对象。 + * + * @param dictCode 字典编码。 + * @param itemId 项目Id。 + * @return 字典项目对象。 + */ + GlobalDictItem getGlobalDictItemByDictCodeAndItemId(String dictCode, Serializable itemId); + + /** + * 查询数据字典项目列表。 + * + * @param filter 过滤对象。 + * @param orderBy 排序字符串,如果为空,则按照showOrder升序排序。 + * @return 查询结果列表。 + */ + List getGlobalDictItemList(GlobalDictItem filter, String orderBy); + + /** + * 查询指定字典编码的数据字典项目列表。查询结果按照showOrder升序排序。 + * + * @param dictCode 过滤对象。 + * @return 查询结果列表。 + */ + List getGlobalDictItemListByDictCode(String dictCode); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/GlobalDictService.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/GlobalDictService.java new file mode 100644 index 00000000..2eaadcf2 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/GlobalDictService.java @@ -0,0 +1,108 @@ +package com.orangeforms.common.dict.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.dict.model.GlobalDict; +import com.orangeforms.common.dict.model.GlobalDictItem; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 全局字典数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface GlobalDictService extends IBaseService { + + /** + * 保存全局字典对象。 + * + * @param globalDict 全局字典对象。 + * @return 保存后的字典对象。 + */ + GlobalDict saveNew(GlobalDict globalDict); + + /** + * 更新全局字典对象。 + * + * @param globalDict 更新的全局字典对象。 + * @param originalGlobalDict 原有的全局字典对象。 + * @return 更新成功返回true,否则false。 + */ + boolean update(GlobalDict globalDict, GlobalDict originalGlobalDict); + + /** + * 删除全局字典对象,以及其关联的字典项目数据。 + * + * @param dictId 全局字典Id。 + * @return 是否删除成功。 + */ + boolean remove(Long dictId); + + /** + * 获取全局字典列表。 + * + * @param filter 过滤对象。 + * @param orderBy 排序条件。 + * @return 查询结果集列表。 + */ + List getGlobalDictList(GlobalDict filter, String orderBy); + + /** + * 判断字典编码是否存在。 + * + * @param dictCode 字典编码。 + * @return true表示存在,否则false。 + */ + boolean existDictCode(String dictCode); + + /** + * 判断指定字典编码的字典项目是否存在。 + * 该方法通常会在业务主表中调用,为了提升整体运行时效率,该方法会从缓存中获取,如果缓存为空, + * 会从数据库读取指定编码的字典数据,并同步到缓存。 + * + * @param dictCode 字典编码。 + * @param itemId 字典项目Id。 + * @return true表示存在,否则false。 + */ + boolean existDictItemFromCache(String dictCode, Serializable itemId); + + /** + * 从缓存中获取指定编码的字典项目列表。 + * 该方法通常会在业务主表中调用,为了提升整体运行时效率,该方法会从缓存中获取,如果缓存为空, + * 会从数据库读取指定编码的字典数据,并同步到缓存。 + * + * @param dictCode 字典编码。 + * @param itemIds 字典项目Id集合。 + * @return 查询结果列表。 + */ + List getGlobalDictItemListFromCache(String dictCode, Set itemIds); + + /** + * 从缓存中获取指定编码的字典项目列表。返回的结果Map中,键是itemId,值是itemName。 + * 该方法通常会在业务主表中调用,为了提升整体运行时效率,该方法会从缓存中获取,如果缓存为空, + * 会从数据库读取指定编码的字典数据,并同步到缓存。 + * + * @param dictCode 字典编码。 + * @param itemIds 字典项目Id集合。 + * @return 查询结果列表。 + */ + Map getGlobalDictItemDictMapFromCache(String dictCode, Set itemIds); + + /** + * 强制同步指定字典编码的全部字典项目到缓存。 + * + * @param dictCode 字典编码。 + */ + void reloadCachedData(String dictCode); + + /** + * 从缓存中移除指定字典编码的数据。 + * + * @param dictCode 字典编码。 + */ + void removeCache(String dictCode); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/TenantGlobalDictItemService.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/TenantGlobalDictItemService.java new file mode 100644 index 00000000..74d3f5fa --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/TenantGlobalDictItemService.java @@ -0,0 +1,115 @@ +package com.orangeforms.common.dict.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.dict.model.TenantGlobalDict; +import com.orangeforms.common.dict.model.TenantGlobalDictItem; + +import java.io.Serializable; +import java.util.List; + +/** + * 租户全局字典项目数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface TenantGlobalDictItemService extends IBaseService { + + /** + * 保存新增的租户字典项目。 + * + * @param tenantGlobalDict 字典对象。 + * @param tenantGlobalDictItem 新字典项目对象。 + * @return 保存后的对象。 + */ + TenantGlobalDictItem saveNew(TenantGlobalDict tenantGlobalDict, TenantGlobalDictItem tenantGlobalDictItem); + + /** + * 批量新增的租户字典项目。 + * + * @param dictItemList 字典项对象列表。 + */ + void saveNewBatch(List dictItemList); + + /** + * 更新租户字典项目对象。 + * + * @param tenantGlobalDict 字典对象。 + * @param tenantGlobalDictItem 更新的全局字典项目对象。 + * @param originalTenantGlobalDictItem 原有的全局字典项目对象。 + * @return 更新成功返回true,否则false。 + */ + boolean update( + TenantGlobalDict tenantGlobalDict, + TenantGlobalDictItem tenantGlobalDictItem, + TenantGlobalDictItem originalTenantGlobalDictItem); + + /** + * 更新字典条目的编码。 + * + * @param oldCode 原有编码。 + * @param newCode 新编码。 + */ + void updateNewCode(String oldCode, String newCode); + + /** + * 更新字典条目的状态。 + * + * @param tenantGlobalDict 字典对象。 + * @param tenantGlobalDictItem 字典项目对象。 + * @param status 状态值。 + */ + void updateStatus(TenantGlobalDict tenantGlobalDict, TenantGlobalDictItem tenantGlobalDictItem, Integer status); + + /** + * 删除指定租户字典项目。 + * + * @param tenantGlobalDict 字典对象。 + * @param tenantGlobalDictItem 待删除字典项目。 + * @return 成功返回true,否则false。 + */ + boolean remove(TenantGlobalDict tenantGlobalDict, TenantGlobalDictItem tenantGlobalDictItem); + + /** + * 判断指定字典的项目Id是否存在。如果是租户非公用字典,会基于租户Id进行过滤。 + * + * @param tenantGlobalDict 字典对象。 + * @param itemId 项目Id。 + * @return true存在,否则false。 + */ + boolean existDictCodeAndItemId(TenantGlobalDict tenantGlobalDict, Serializable itemId); + + /** + * 判断指定租户的编码是否已经存在字典数据。 + * + * @param dictCode 字典编码。 + * @return true存在,否则false。 + */ + boolean existDictCode(String dictCode); + + /** + * 根据租户字典编码和项目Id获取指定字段项目对象。 + * + * @param dictCode 字典编码。 + * @param itemId 项目Id。 + * @return 字典项目对象。 + */ + TenantGlobalDictItem getGlobalDictItemByDictCodeAndItemId(String dictCode, Serializable itemId); + + /** + * 查询租户数据字典项目列表。 + * + * @param filter 过滤对象。 + * @param orderBy 排序字符串,如果为空,则按照showOrder升序排序。 + * @return 查询结果列表。 + */ + List getGlobalDictItemList(TenantGlobalDictItem filter, String orderBy); + + /** + * 查询指定字典的租户数据字典项目列表。如果是租户非公用字典,会仅仅返回该租户的字典数据列表。按照showOrder升序排序。 + * + * @param tenantGlobalDict 编码字典对象。 + * @return 查询结果列表。 + */ + List getGlobalDictItemList(TenantGlobalDict tenantGlobalDict); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/TenantGlobalDictService.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/TenantGlobalDictService.java new file mode 100644 index 00000000..3c02c46c --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/TenantGlobalDictService.java @@ -0,0 +1,137 @@ +package com.orangeforms.common.dict.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.dict.model.TenantGlobalDict; +import com.orangeforms.common.dict.model.TenantGlobalDictItem; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 租户全局字典数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface TenantGlobalDictService extends IBaseService { + + /** + * 保存租户全局字典对象。 + * + * @param tenantGlobalDict 全局租户字典对象。 + * @param tenantIdSet 租户Id集合。 + * @return 保存后的字典对象。 + */ + TenantGlobalDict saveNew(TenantGlobalDict tenantGlobalDict, Set tenantIdSet); + + /** + * 更新租户全局字典对象。 + * + * @param tenantGlobalDict 更新的租户全局字典对象。 + * @param originalTenantGlobalDict 原有的租户全局字典对象。 + * @return 更新成功返回true,否则false。 + */ + boolean update(TenantGlobalDict tenantGlobalDict, TenantGlobalDict originalTenantGlobalDict); + + /** + * 删除租户全局字典对象,以及其关联的字典项目数据。 + * + * @param dictId 全局字典Id。 + * @return 是否删除成功。 + */ + boolean remove(Long dictId); + + /** + * 获取全局字典列表。 + * + * @param filter 过滤对象。 + * @param orderBy 排序条件。 + * @return 查询结果集列表。 + */ + List getGlobalDictList(TenantGlobalDict filter, String orderBy); + + /** + * 判断租户字典编码是否存在。 + * + * @param dictCode 字典编码。 + * @return true表示存在,否则false。 + */ + boolean existDictCode(String dictCode); + + /** + * 根据字典编码获取全局字典编码对象。 + * + * @param dictCode 字典编码。 + * @return 查询后的字典对象。 + */ + TenantGlobalDict getTenantGlobalDictByDictCode(String dictCode); + + /** + * 从缓存中中获取指定字典数据。如果缓存中不存在,会从数据库读取并同步到缓存。 + * + * @param dictCode 字典编码。 + * @return 查询到的字段对象。 + */ + TenantGlobalDict getTenantGlobalDictFromCache(String dictCode); + + /** + * 从缓存中获取指定编码的字典项目列表。 + * 如果是租户非公用字典,会仅仅返回该租户的字典数据列表。 + * 该方法通常会在业务主表中调用,为了提升整体运行时效率,该方法会从缓存中获取,如果缓存为空, + * 会从数据库读取指定编码的字典数据,并同步到缓存。 + * + * @param tenantGlobalDict 编码字典对象。 + * @param itemIds 字典项目Id集合。 + * @return 查询结果列表。 + */ + List getGlobalDictItemListFromCache(TenantGlobalDict tenantGlobalDict, Set itemIds); + + /** + * 从缓存中获取指定编码的字典项目列表。返回的结果Map中,键是itemId,值是itemName。 + * 如果是租户非公用字典,会仅仅返回该租户的字典数据列表。 + * 该方法通常会在业务主表中调用,为了提升整体运行时效率,该方法会从缓存中获取,如果缓存为空, + * 会从数据库读取指定编码的字典数据,并同步到缓存。 + * + * @param tenantGlobalDict 编码字典对象。 + * @param itemIds 字典项目Id集合。 + * @return 查询结果列表。 + */ + Map getGlobalDictItemDictMapFromCache(TenantGlobalDict tenantGlobalDict, Set itemIds); + + /** + * 强制同步指定所有租户通用字典编码的全部字典项目到缓存。 + * 如果是租户非公用字典,会仅仅返回该租户的字典数据列表。 + * + * @param tenantGlobalDict 编码字典对象。 + */ + void reloadCachedData(TenantGlobalDict tenantGlobalDict); + + /** + * 重置所有非公用租户编码字典的数据到缓存。 + * 该方法会将指定编码字典中,所有租户的缓存全部重新加载。一般用于系统故障,或大促活动的数据预热。 + * + * @param tenantGlobalDict 非公用编码字典对象。 + */ + void reloadAllTenantCachedData(TenantGlobalDict tenantGlobalDict); + + /** + * 从缓存中移除指定字典编码的数据。 + * 该方法的实现内部会判断是否为公用字典,还是租户可修改的非公用字典。 + * + * @param tenantGlobalDict 字典编码。 + */ + void removeCache(TenantGlobalDict tenantGlobalDict); + + /** + * 判断指定字典编码的字典项目是否存在。 + * 该方法通常会在业务主表中调用,为了提升整体运行时效率,该方法会从缓存中获取,如果缓存为空, + * 会从数据库读取指定编码的字典数据,并同步到缓存。 + * + * @param dictCode 字典编码。 + * @param itemId 字典项目Id。 + * @return true表示存在,否则false。 + */ + boolean existDictItemFromCache(String dictCode, Serializable itemId); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/GlobalDictItemServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/GlobalDictItemServiceImpl.java new file mode 100644 index 00000000..fbf3fd89 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/GlobalDictItemServiceImpl.java @@ -0,0 +1,143 @@ +package com.orangeforms.common.dict.service.impl; + +import cn.hutool.core.util.StrUtil; +import com.mybatisflex.core.query.QueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.constant.GlobalDeletedFlag; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.dict.constant.GlobalDictItemStatus; +import com.orangeforms.common.dict.dao.GlobalDictItemMapper; +import com.orangeforms.common.dict.model.GlobalDictItem; +import com.orangeforms.common.dict.service.GlobalDictItemService; +import com.orangeforms.common.dict.service.GlobalDictService; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * 全局字典项目数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_GLOBAL_DICT_TYPE) +@Service("globalDictItemService") +public class GlobalDictItemServiceImpl + extends BaseService implements GlobalDictItemService { + + @Autowired + private GlobalDictItemMapper globalDictItemMapper; + @Autowired + private GlobalDictService globalDictService; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return globalDictItemMapper; + } + + @Override + public GlobalDictItem saveNew(GlobalDictItem globalDictItem) { + globalDictService.removeCache(globalDictItem.getDictCode()); + globalDictItem.setId(idGenerator.nextLongId()); + globalDictItem.setDeletedFlag(GlobalDeletedFlag.NORMAL); + globalDictItem.setStatus(GlobalDictItemStatus.NORMAL); + globalDictItem.setCreateUserId(TokenData.takeFromRequest().getUserId()); + globalDictItem.setUpdateUserId(globalDictItem.getCreateUserId()); + globalDictItem.setCreateTime(new Date()); + globalDictItem.setUpdateTime(globalDictItem.getCreateTime()); + globalDictItemMapper.insert(globalDictItem); + return globalDictItem; + } + + @Override + public boolean update(GlobalDictItem globalDictItem, GlobalDictItem originalGlobalDictItem) { + globalDictService.removeCache(globalDictItem.getDictCode()); + // 该方法不能直接修改字典状态。 + globalDictItem.setStatus(originalGlobalDictItem.getStatus()); + globalDictItem.setCreateUserId(originalGlobalDictItem.getCreateUserId()); + globalDictItem.setCreateTime(originalGlobalDictItem.getCreateTime()); + globalDictItem.setUpdateUserId(TokenData.takeFromRequest().getUserId()); + globalDictItem.setUpdateTime(new Date()); + return globalDictItemMapper.update(globalDictItem) == 1; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void updateNewCode(String oldCode, String newCode) { + GlobalDictItem globalDictItem = new GlobalDictItem(); + globalDictItem.setDictCode(newCode); + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(GlobalDictItem::getDictCode, oldCode); + globalDictItemMapper.updateByQuery(globalDictItem, queryWrapper); + } + + @Override + public void updateStatus(GlobalDictItem globalDictItem, Integer status) { + globalDictService.removeCache(globalDictItem.getDictCode()); + globalDictItem.setStatus(status); + globalDictItem.setUpdateUserId(TokenData.takeFromRequest().getUserId()); + globalDictItem.setUpdateTime(new Date()); + globalDictItemMapper.update(globalDictItem); + } + + @Override + public boolean remove(GlobalDictItem globalDictItem) { + globalDictService.removeCache(globalDictItem.getDictCode()); + return this.removeById(globalDictItem.getId()); + } + + @Override + public boolean existDictCodeAndItemId(String dictCode, Serializable itemId) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(GlobalDictItem::getDictCode, dictCode); + queryWrapper.eq(GlobalDictItem::getItemId, itemId.toString()); + return globalDictItemMapper.selectCountByQuery(queryWrapper) > 0; + } + + @Override + public GlobalDictItem getGlobalDictItemByDictCodeAndItemId(String dictCode, Serializable itemId) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(GlobalDictItem::getDictCode, dictCode); + queryWrapper.eq(GlobalDictItem::getItemId, itemId.toString()); + return globalDictItemMapper.selectOneByQuery(queryWrapper); + } + + @Override + public List getGlobalDictItemList(GlobalDictItem filter, String orderBy) { + QueryWrapper queryWrapper = filter == null ? QueryWrapper.create() : QueryWrapper.create(filter); + if (StrUtil.isNotBlank(orderBy)) { + queryWrapper.orderBy(orderBy); + } else { + queryWrapper.orderBy(GlobalDictItem::getShowOrder, true); + } + return globalDictItemMapper.selectListByQuery(queryWrapper); + } + + @Override + public List getGlobalDictItemListByDictCode(String dictCode) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(GlobalDictItem::getDictCode, dictCode); + queryWrapper.orderBy(GlobalDictItem::getShowOrder, true); + return globalDictItemMapper.selectListByQuery(queryWrapper); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/GlobalDictServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/GlobalDictServiceImpl.java new file mode 100644 index 00000000..e6c50e43 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/GlobalDictServiceImpl.java @@ -0,0 +1,184 @@ +package com.orangeforms.common.dict.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.mybatisflex.core.query.QueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.constant.GlobalDeletedFlag; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.RedisKeyUtil; +import com.orangeforms.common.dict.constant.GlobalDictItemStatus; +import com.orangeforms.common.dict.dao.GlobalDictMapper; +import com.orangeforms.common.dict.model.GlobalDict; +import com.orangeforms.common.dict.model.GlobalDictItem; +import com.orangeforms.common.dict.service.GlobalDictItemService; +import com.orangeforms.common.dict.service.GlobalDictService; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import lombok.extern.slf4j.Slf4j; +import org.redisson.api.RMap; +import org.redisson.api.RedissonClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.Serializable; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 全局字典数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_GLOBAL_DICT_TYPE) +@Service("globalDictService") +public class GlobalDictServiceImpl extends BaseService implements GlobalDictService { + + @Autowired + private GlobalDictMapper globalDictMapper; + @Autowired + private GlobalDictItemService globalDictItemService; + @Autowired + private RedissonClient redissonClient; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return globalDictMapper; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public GlobalDict saveNew(GlobalDict globalDict) { + globalDict.setDictId(idGenerator.nextLongId()); + globalDict.setDeletedFlag(GlobalDeletedFlag.NORMAL); + globalDict.setCreateUserId(TokenData.takeFromRequest().getUserId()); + globalDict.setUpdateUserId(globalDict.getCreateUserId()); + globalDict.setCreateTime(new Date()); + globalDict.setUpdateTime(globalDict.getCreateTime()); + globalDictMapper.insert(globalDict); + return globalDict; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(GlobalDict globalDict, GlobalDict originalGlobalDict) { + this.removeCache(originalGlobalDict.getDictCode()); + globalDict.setCreateUserId(originalGlobalDict.getCreateUserId()); + globalDict.setCreateTime(originalGlobalDict.getCreateTime()); + globalDict.setUpdateUserId(TokenData.takeFromRequest().getUserId()); + globalDict.setUpdateTime(new Date()); + if (globalDictMapper.update(globalDict) != 1) { + return false; + } + if (!StrUtil.equals(globalDict.getDictCode(), originalGlobalDict.getDictCode())) { + globalDictItemService.updateNewCode(originalGlobalDict.getDictCode(), globalDict.getDictCode()); + } + return true; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long dictId) { + GlobalDict globalDict = this.getById(dictId); + if (globalDict == null) { + return false; + } + this.removeCache(globalDict.getDictCode()); + if (globalDictMapper.deleteById(dictId) == 0) { + return false; + } + GlobalDictItem filter = new GlobalDictItem(); + filter.setDictCode(globalDict.getDictCode()); + globalDictItemService.removeBy(filter); + return true; + } + + @Override + public List getGlobalDictList(GlobalDict filter, String orderBy) { + return globalDictMapper.getGlobalDictList(filter, orderBy); + } + + @Override + public boolean existDictCode(String dictCode) { + return globalDictMapper.selectCountByQuery(new QueryWrapper().eq(GlobalDict::getDictCode, dictCode)) > 0; + } + + @Override + public boolean existDictItemFromCache(String dictCode, Serializable itemId) { + return CollUtil.isNotEmpty(this.getGlobalDictItemListFromCache(dictCode, CollUtil.newHashSet(itemId))); + } + + @Override + public List getGlobalDictItemListFromCache(String dictCode, Set itemIds) { + if (CollUtil.isNotEmpty(itemIds) && !(itemIds.iterator().next() instanceof String)) { + itemIds = itemIds.stream().map(Object::toString).collect(Collectors.toSet()); + } + List dataList; + RMap cachedMap = + redissonClient.getMap(RedisKeyUtil.makeGlobalDictKey(dictCode)); + if (cachedMap.isExists()) { + Map dataMap = + CollUtil.isEmpty(itemIds) ? cachedMap.readAllMap() : cachedMap.getAll(itemIds); + dataList = dataMap.values().stream() + .map(c -> JSON.parseObject(c, GlobalDictItem.class)).collect(Collectors.toList()); + dataList.sort(Comparator.comparingInt(GlobalDictItem::getShowOrder)); + } else { + dataList = globalDictItemService.getGlobalDictItemListByDictCode(dictCode); + this.putCache(dictCode, dataList); + if (CollUtil.isNotEmpty(itemIds)) { + Set tmpItemIds = itemIds; + dataList = dataList.stream() + .filter(c -> tmpItemIds.contains(c.getItemId())).collect(Collectors.toList()); + } + } + return dataList; + } + + @Override + public Map getGlobalDictItemDictMapFromCache(String dictCode, Set itemIds) { + List dataList = this.getGlobalDictItemListFromCache(dictCode, itemIds); + return dataList.stream().collect(Collectors.toMap(GlobalDictItem::getItemId, GlobalDictItem::getItemName)); + } + + @Override + public void reloadCachedData(String dictCode) { + this.removeCache(dictCode); + List dataList = globalDictItemService.getGlobalDictItemListByDictCode(dictCode); + this.putCache(dictCode, dataList); + } + + @Override + public void removeCache(String dictCode) { + if (StrUtil.isNotBlank(dictCode)) { + redissonClient.getMap(RedisKeyUtil.makeGlobalDictKey(dictCode)).delete(); + } + } + + private void putCache(String dictCode, List globalDictItemList) { + if (CollUtil.isNotEmpty(globalDictItemList)) { + Map dataMap = globalDictItemList.stream() + .filter(item -> item.getStatus() == GlobalDictItemStatus.NORMAL) + .collect(Collectors.toMap(GlobalDictItem::getItemId, JSON::toJSONString)); + if (MapUtil.isNotEmpty(dataMap)) { + redissonClient.getMap(RedisKeyUtil.makeGlobalDictKey(dictCode)).putAll(dataMap); + } + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/TenantGlobalDictItemServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/TenantGlobalDictItemServiceImpl.java new file mode 100644 index 00000000..71aed12c --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/TenantGlobalDictItemServiceImpl.java @@ -0,0 +1,189 @@ +package com.orangeforms.common.dict.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.core.util.BooleanUtil; +import com.mybatisflex.core.query.QueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.constant.GlobalDeletedFlag; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.dict.constant.GlobalDictItemStatus; +import com.orangeforms.common.dict.dao.TenantGlobalDictItemMapper; +import com.orangeforms.common.dict.model.TenantGlobalDict; +import com.orangeforms.common.dict.model.TenantGlobalDictItem; +import com.orangeforms.common.dict.service.TenantGlobalDictItemService; +import com.orangeforms.common.dict.service.TenantGlobalDictService; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * 租户全局字典项目数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.TENANT_COMMON_DATASOURCE_TYPE) +@Slf4j +@Service("tenantGlobalDictItemService") +public class TenantGlobalDictItemServiceImpl + extends BaseService implements TenantGlobalDictItemService { + + @Autowired + private TenantGlobalDictItemMapper tenantGlobalDictItemMapper; + @Autowired + private TenantGlobalDictService tenantGlobalDictService; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return tenantGlobalDictItemMapper; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public TenantGlobalDictItem saveNew(TenantGlobalDict dict, TenantGlobalDictItem dictItem) { + tenantGlobalDictService.removeCache(dict); + if (BooleanUtil.isFalse(dict.getTenantCommon())) { + dictItem.setTenantId(TokenData.takeFromRequest().getTenantId()); + } + dictItem.setId(idGenerator.nextLongId()); + dictItem.setDeletedFlag(GlobalDeletedFlag.NORMAL); + dictItem.setStatus(GlobalDictItemStatus.NORMAL); + dictItem.setCreateUserId(TokenData.takeFromRequest().getUserId()); + dictItem.setUpdateUserId(dictItem.getCreateUserId()); + dictItem.setCreateTime(new Date()); + dictItem.setUpdateTime(dictItem.getCreateTime()); + tenantGlobalDictItemMapper.insert(dictItem); + return dictItem; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNewBatch(List dictItemList) { + if (CollUtil.isEmpty(dictItemList)) { + return; + } + Date now = new Date(); + for (TenantGlobalDictItem dictItem : dictItemList) { + if (dictItem.getId() == null) { + dictItem.setId(idGenerator.nextLongId()); + } + if (dictItem.getCreateUserId() == null) { + dictItem.setCreateUserId(TokenData.takeFromRequest().getUserId()); + } + dictItem.setUpdateUserId(dictItem.getCreateUserId()); + dictItem.setUpdateTime(now); + dictItem.setCreateTime(now); + dictItem.setStatus(GlobalDictItemStatus.NORMAL); + dictItem.setDeletedFlag(GlobalDeletedFlag.NORMAL); + } + tenantGlobalDictItemMapper.insertList(dictItemList); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(TenantGlobalDict dict, TenantGlobalDictItem dictItem, TenantGlobalDictItem originalDictItem) { + tenantGlobalDictService.removeCache(dict); + // 该方法不能直接修改字典状态,更不会修改tenantId。 + dictItem.setStatus(originalDictItem.getStatus()); + dictItem.setTenantId(originalDictItem.getTenantId()); + dictItem.setCreateUserId(originalDictItem.getCreateUserId()); + dictItem.setCreateTime(originalDictItem.getCreateTime()); + dictItem.setUpdateUserId(TokenData.takeFromRequest().getUserId()); + dictItem.setUpdateTime(new Date()); + return tenantGlobalDictItemMapper.update(dictItem) == 1; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void updateNewCode(String oldCode, String newCode) { + TenantGlobalDictItem dictItem = new TenantGlobalDictItem(); + dictItem.setDictCode(newCode); + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(TenantGlobalDictItem::getDictCode, oldCode); + tenantGlobalDictItemMapper.updateByQuery(dictItem, queryWrapper); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void updateStatus(TenantGlobalDict dict, TenantGlobalDictItem dictItem, Integer status) { + tenantGlobalDictService.removeCache(dict); + dictItem.setStatus(status); + dictItem.setUpdateUserId(TokenData.takeFromRequest().getUserId()); + dictItem.setUpdateTime(new Date()); + tenantGlobalDictItemMapper.update(dictItem); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(TenantGlobalDict dict, TenantGlobalDictItem dictItem) { + tenantGlobalDictService.removeCache(dict); + return this.removeById(dictItem.getId()); + } + + @Override + public boolean existDictCodeAndItemId(TenantGlobalDict dict, Serializable itemId) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(TenantGlobalDictItem::getDictCode, dict.getDictCode()); + queryWrapper.eq(TenantGlobalDictItem::getItemId, itemId.toString()); + if (BooleanUtil.isFalse(dict.getTenantCommon())) { + queryWrapper.eq(TenantGlobalDictItem::getTenantId, TokenData.takeFromRequest().getTenantId()); + } + return tenantGlobalDictItemMapper.selectCountByQuery(queryWrapper) > 0; + } + + @Override + public boolean existDictCode(String dictCode) { + return tenantGlobalDictItemMapper.selectCountByQuery( + new QueryWrapper().eq(TenantGlobalDictItem::getDictCode, dictCode)) > 0; + } + + @Override + public TenantGlobalDictItem getGlobalDictItemByDictCodeAndItemId(String dictCode, Serializable itemId) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(TenantGlobalDictItem::getDictCode, dictCode); + queryWrapper.eq(TenantGlobalDictItem::getItemId, itemId.toString()); + return tenantGlobalDictItemMapper.selectOneByQuery(queryWrapper); + } + + @Override + public List getGlobalDictItemList(TenantGlobalDictItem filter, String orderBy) { + QueryWrapper queryWrapper = filter == null ? QueryWrapper.create() : QueryWrapper.create(filter); + if (StrUtil.isNotBlank(orderBy)) { + queryWrapper.orderBy(orderBy); + } else { + queryWrapper.orderBy(TenantGlobalDictItem::getShowOrder, true); + } + return tenantGlobalDictItemMapper.selectListByQuery(queryWrapper); + } + + @Override + public List getGlobalDictItemList(TenantGlobalDict dict) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(TenantGlobalDictItem::getDictCode, dict.getDictCode()); + if (BooleanUtil.isFalse(dict.getTenantCommon())) { + queryWrapper.eq(TenantGlobalDictItem::getTenantId, TokenData.takeFromRequest().getTenantId()); + } + queryWrapper.orderBy(TenantGlobalDictItem::getShowOrder, true); + return tenantGlobalDictItemMapper.selectListByQuery(queryWrapper); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/TenantGlobalDictServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/TenantGlobalDictServiceImpl.java new file mode 100644 index 00000000..cbf7ea20 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/TenantGlobalDictServiceImpl.java @@ -0,0 +1,302 @@ +package com.orangeforms.common.dict.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.mybatisflex.core.query.QueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.constant.GlobalDeletedFlag; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.core.util.RedisKeyUtil; +import com.orangeforms.common.dict.constant.GlobalDictItemStatus; +import com.orangeforms.common.dict.dao.TenantGlobalDictMapper; +import com.orangeforms.common.dict.model.TenantGlobalDict; +import com.orangeforms.common.dict.model.TenantGlobalDictItem; +import com.orangeforms.common.dict.service.TenantGlobalDictItemService; +import com.orangeforms.common.dict.service.TenantGlobalDictService; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import lombok.extern.slf4j.Slf4j; +import org.redisson.api.RBucket; +import org.redisson.api.RMap; +import org.redisson.api.RedissonClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.Serializable; +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +/** + * 租户全局字典数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.TENANT_COMMON_DATASOURCE_TYPE) +@Slf4j +@Service("tenantGlobalDictService") +public class TenantGlobalDictServiceImpl + extends BaseService implements TenantGlobalDictService { + + @Autowired + private TenantGlobalDictMapper tenantGlobalDictMapper; + @Autowired + private TenantGlobalDictItemService tenantGlobalDictItemService; + @Autowired + private RedissonClient redissonClient; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return tenantGlobalDictMapper; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public TenantGlobalDict saveNew(TenantGlobalDict dict, Set tenantIdSet) { + String initialData = dict.getInitialData(); + dict.setDictId(idGenerator.nextLongId()); + dict.setDeletedFlag(GlobalDeletedFlag.NORMAL); + dict.setCreateUserId(TokenData.takeFromRequest().getUserId()); + dict.setUpdateUserId(dict.getCreateUserId()); + dict.setCreateTime(new Date()); + dict.setUpdateTime(dict.getCreateTime()); + if (BooleanUtil.isTrue(dict.getTenantCommon())) { + dict.setInitialData(null); + } + tenantGlobalDictMapper.insert(dict); + List dictItemList = null; + if (StrUtil.isNotBlank(initialData)) { + dictItemList = JSONArray.parseArray(initialData, TenantGlobalDictItem.class); + dictItemList.forEach(dictItem -> { + dictItem.setDictCode(dict.getDictCode()); + dictItem.setCreateUserId(dict.getCreateUserId()); + }); + } + if (BooleanUtil.isTrue(dict.getTenantCommon())) { + tenantGlobalDictItemService.saveNewBatch(dictItemList); + } else { + if (CollUtil.isEmpty(tenantIdSet) || dictItemList == null) { + return dict; + } + for (Long tenantId : tenantIdSet) { + dictItemList.forEach(dictItem -> { + dictItem.setId(idGenerator.nextLongId()); + dictItem.setTenantId(tenantId); + }); + tenantGlobalDictItemService.saveNewBatch(dictItemList); + } + } + return dict; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(TenantGlobalDict dict, TenantGlobalDict originalDict) { + this.removeGlobalDictAllCache(originalDict); + dict.setCreateUserId(originalDict.getCreateUserId()); + dict.setCreateTime(originalDict.getCreateTime()); + dict.setUpdateUserId(TokenData.takeFromRequest().getUserId()); + dict.setUpdateTime(new Date()); + if (tenantGlobalDictMapper.update(dict) != 1) { + return false; + } + if (!StrUtil.equals(dict.getDictCode(), originalDict.getDictCode())) { + tenantGlobalDictItemService.updateNewCode(originalDict.getDictCode(), dict.getDictCode()); + } + return true; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long dictId) { + TenantGlobalDict dict = this.getById(dictId); + if (dict == null) { + return false; + } + this.removeGlobalDictAllCache(dict); + if (tenantGlobalDictMapper.deleteById(dictId) == 0) { + return false; + } + TenantGlobalDictItem filter = new TenantGlobalDictItem(); + filter.setDictCode(dict.getDictCode()); + tenantGlobalDictItemService.removeBy(filter); + return true; + } + + @Override + public List getGlobalDictList(TenantGlobalDict filter, String orderBy) { + QueryWrapper queryWrapper = filter == null ? QueryWrapper.create() : QueryWrapper.create(filter); + if (StrUtil.isNotBlank(orderBy)) { + queryWrapper.orderBy(orderBy); + } + return tenantGlobalDictMapper.selectListByQuery(queryWrapper); + } + + @Override + public boolean existDictCode(String dictCode) { + return tenantGlobalDictMapper.selectCountByQuery( + new QueryWrapper().eq(TenantGlobalDict::getDictCode, dictCode)) > 0; + } + + @Override + public TenantGlobalDict getTenantGlobalDictByDictCode(String dictCode) { + return tenantGlobalDictMapper.selectOneByQuery(new QueryWrapper().eq(TenantGlobalDict::getDictCode, dictCode)); + } + + @Override + public TenantGlobalDict getTenantGlobalDictFromCache(String dictCode) { + String key = RedisKeyUtil.makeGlobalDictOnlyKey(dictCode); + RBucket bucket = redissonClient.getBucket(key); + if (bucket.isExists()) { + return JSON.parseObject(bucket.get(), TenantGlobalDict.class); + } + TenantGlobalDict dict = this.getTenantGlobalDictByDictCode(dictCode); + if (dict != null) { + bucket.set(JSON.toJSONString(dict)); + } + return dict; + } + + @Override + public List getGlobalDictItemListFromCache(TenantGlobalDict dict, Set itemIds) { + if (CollUtil.isNotEmpty(itemIds) && !(itemIds.iterator().next() instanceof String)) { + itemIds = itemIds.stream().map(Object::toString).collect(Collectors.toSet()); + } + String key = RedisKeyUtil.makeGlobalDictKey(dict.getDictCode()); + if (BooleanUtil.isFalse(dict.getTenantCommon())) { + key = this.appendTenantSuffix(key); + } + List dataList; + RMap cachedMap = redissonClient.getMap(key); + if (cachedMap.isExists()) { + Map dataMap = + CollUtil.isEmpty(itemIds) ? cachedMap.readAllMap() : cachedMap.getAll(itemIds); + dataList = dataMap.values().stream() + .map(c -> JSON.parseObject(c, TenantGlobalDictItem.class)).collect(Collectors.toList()); + dataList.sort(Comparator.comparingInt(TenantGlobalDictItem::getShowOrder)); + } else { + dataList = tenantGlobalDictItemService.getGlobalDictItemList(dict); + this.putCache(dict, dataList); + if (CollUtil.isNotEmpty(itemIds)) { + Set tmpItemIds = itemIds; + dataList = dataList.stream() + .filter(c -> tmpItemIds.contains(c.getItemId())).collect(Collectors.toList()); + } + } + return dataList; + } + + @Override + public Map getGlobalDictItemDictMapFromCache( + TenantGlobalDict dict, Set itemIds) { + List dataList = this.getGlobalDictItemListFromCache(dict, itemIds); + return dataList.stream() + .collect(Collectors.toMap(TenantGlobalDictItem::getItemId, TenantGlobalDictItem::getItemName)); + } + + @Override + public void reloadCachedData(TenantGlobalDict dict) { + this.removeCache(dict); + List dataList = tenantGlobalDictItemService.getGlobalDictItemList(dict); + this.putCache(dict, dataList); + } + + @Override + public void reloadAllTenantCachedData(TenantGlobalDict dict) { + if (StrUtil.isBlank(dict.getDictCode())) { + return; + } + String dictCodeKey = RedisKeyUtil.makeGlobalDictKey(dict.getDictCode()); + redissonClient.getKeys().deleteByPattern(dictCodeKey + "*"); + TenantGlobalDictItem filter = new TenantGlobalDictItem(); + filter.setDictCode(dict.getDictCode()); + List dictItemList = + tenantGlobalDictItemService.getGlobalDictItemList(filter, null); + if (CollUtil.isEmpty(dictItemList)) { + return; + } + Map> dictItemMap = + dictItemList.stream().collect(Collectors.groupingBy(TenantGlobalDictItem::getTenantId)); + for (Map.Entry> entry : dictItemMap.entrySet()) { + String key = dictCodeKey + "-" + entry.getKey(); + Map dataMap = entry.getValue().stream() + .collect(Collectors.toMap(TenantGlobalDictItem::getItemId, JSON::toJSONString)); + RMap cachedMap = redissonClient.getMap(key); + cachedMap.putAll(dataMap); + cachedMap.expire(1, TimeUnit.DAYS); + } + } + + @Override + public void removeCache(TenantGlobalDict dict) { + if (StrUtil.isBlank(dict.getDictCode())) { + return; + } + String key = RedisKeyUtil.makeGlobalDictKey(dict.getDictCode()); + if (BooleanUtil.isFalse(dict.getTenantCommon())) { + key = this.appendTenantSuffix(key); + } + redissonClient.getMap(key).delete(); + } + + @Override + public boolean existDictItemFromCache(String dictCode, Serializable itemId) { + TenantGlobalDict tenantGlobalDict = this.getTenantGlobalDictFromCache(dictCode); + return CollUtil.isNotEmpty(this.getGlobalDictItemListFromCache(tenantGlobalDict, CollUtil.newHashSet(itemId))); + } + + private void putCache(TenantGlobalDict dict, List dictItemList) { + if (CollUtil.isEmpty(dictItemList)) { + return; + } + String key = RedisKeyUtil.makeGlobalDictKey(dict.getDictCode()); + if (BooleanUtil.isFalse(dict.getTenantCommon())) { + key = this.appendTenantSuffix(key); + } + Map dataMap = dictItemList.stream() + .filter(item -> item.getStatus() == GlobalDictItemStatus.NORMAL) + .collect(Collectors.toMap(TenantGlobalDictItem::getItemId, JSON::toJSONString)); + if (MapUtil.isNotEmpty(dataMap)) { + RMap cachedMap = redissonClient.getMap(key); + cachedMap.putAll(dataMap); + cachedMap.expire(1, TimeUnit.DAYS); + } + } + + private String appendTenantSuffix(String key) { + return key + "-" + TokenData.takeFromRequest().getTenantId(); + } + + private void removeGlobalDictAllCache(TenantGlobalDict dict) { + String dictCode = dict.getDictCode(); + if (StrUtil.isBlank(dictCode)) { + return; + } + String key = RedisKeyUtil.makeGlobalDictOnlyKey(dictCode); + redissonClient.getBucket(key).delete(); + key = RedisKeyUtil.makeGlobalDictKey(dictCode); + if (BooleanUtil.isTrue(dict.getTenantCommon())) { + redissonClient.getMap(key).delete(); + } else { + redissonClient.getKeys().deleteByPatternAsync(key + "*"); + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/util/GlobalDictOperationHelper.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/util/GlobalDictOperationHelper.java new file mode 100644 index 00000000..05e308ef --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/util/GlobalDictOperationHelper.java @@ -0,0 +1,89 @@ +package com.orangeforms.common.dict.util; + +import cn.hutool.core.util.StrUtil; +import com.github.pagehelper.Page; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.ResponseResult; +import com.orangeforms.common.core.object.MyPageData; +import com.orangeforms.common.core.object.MyPageParam; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.dict.dto.GlobalDictDto; +import com.orangeforms.common.dict.model.GlobalDict; +import com.orangeforms.common.dict.model.GlobalDictItem; +import com.orangeforms.common.dict.service.GlobalDictService; +import com.orangeforms.common.dict.vo.GlobalDictVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 全局编码字典操作的通用帮助对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Component +public class GlobalDictOperationHelper { + + @Autowired + private GlobalDictService globalDictService; + + /** + * 获取全部编码字典列表。 + * + * @param globalDictDtoFilter 过滤对象。 + * @param pageParam 分页参数。 + * @return 字典的数据列表。 + */ + public ResponseResult> listAllGlobalDict( + GlobalDictDto globalDictDtoFilter, MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + GlobalDict filter = MyModelUtil.copyTo(globalDictDtoFilter, GlobalDict.class); + List dictList = globalDictService.getGlobalDictList(filter, null); + List dictVoList = MyModelUtil.copyCollectionTo(dictList, GlobalDictVo.class); + long totalCount = 0L; + if (dictList instanceof Page) { + totalCount = ((Page) dictList).getTotal(); + } + return ResponseResult.success(MyPageUtil.makeResponseData(dictVoList, totalCount)); + } + + public List> toDictDataList(List resultList, String itemIdType) { + return resultList.stream().map(item -> { + Map dataMap = new HashMap<>(4); + Object itemId = item.getItemId(); + if (StrUtil.equals(itemIdType, "Long")) { + itemId = Long.valueOf(item.getItemId()); + } else if (StrUtil.equals(itemIdType, "Integer")) { + itemId = Integer.valueOf(item.getItemId()); + } + dataMap.put(ApplicationConstant.DICT_ID, itemId); + dataMap.put(ApplicationConstant.DICT_NAME, item.getItemName()); + dataMap.put("showOrder", item.getShowOrder()); + dataMap.put("status", item.getStatus()); + return dataMap; + }).collect(Collectors.toList()); + } + + public List> toDictDataList2(List resultList) { + return resultList.stream().map(item -> { + Map dataMap = new HashMap<>(5); + dataMap.put(ApplicationConstant.DICT_ID, item.getId()); + dataMap.put("itemId", item.getItemId()); + dataMap.put(ApplicationConstant.DICT_NAME, item.getItemName()); + dataMap.put("showOrder", item.getShowOrder()); + dataMap.put("status", item.getStatus()); + return dataMap; + }).collect(Collectors.toList()); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/GlobalDictItemVo.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/GlobalDictItemVo.java new file mode 100644 index 00000000..cbf07bd4 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/GlobalDictItemVo.java @@ -0,0 +1,77 @@ +package com.orangeforms.common.dict.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 全局系统字典项目Vo。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "全局系统字典项目Vo") +@Data +public class GlobalDictItemVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long id; + + /** + * 字典编码。 + */ + @Schema(description = "字典编码") + private String dictCode; + + /** + * 字典数据项Id。 + */ + @Schema(description = "字典数据项Id") + private String itemId; + + /** + * 字典数据项名称。 + */ + @Schema(description = "字典数据项名称") + private String itemName; + + /** + * 显示顺序(数值越小越靠前)。 + */ + @Schema(description = "显示顺序") + private Integer showOrder; + + /** + * 字典状态。具体值引用DictItemStatus常量类。 + */ + @Schema(description = "字典状态") + private Integer status; + + /** + * 创建用户Id。 + */ + @Schema(description = "创建用户Id") + private Long createUserId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建用户名。 + */ + @Schema(description = "创建用户名") + private Long updateUserId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/GlobalDictVo.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/GlobalDictVo.java new file mode 100644 index 00000000..f77a2581 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/GlobalDictVo.java @@ -0,0 +1,59 @@ +package com.orangeforms.common.dict.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 全局系统字典Vo。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "全局系统字典Vo") +@Data +public class GlobalDictVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long dictId; + + /** + * 字典编码。 + */ + @Schema(description = "字典编码") + private String dictCode; + + /** + * 字典中文名称。 + */ + @Schema(description = "字典中文名称") + private String dictName; + + /** + * 创建用户Id。 + */ + @Schema(description = "创建用户Id") + private Long createUserId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建用户名。 + */ + @Schema(description = "创建用户名") + private Long updateUserId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/TenantGlobalDictItemVo.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/TenantGlobalDictItemVo.java new file mode 100644 index 00000000..967b561d --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/TenantGlobalDictItemVo.java @@ -0,0 +1,18 @@ +package com.orangeforms.common.dict.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 租户全局系统字典项目Vo。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "租户全局系统字典项目Vo") +@Data +@EqualsAndHashCode(callSuper = true) +public class TenantGlobalDictItemVo extends GlobalDictItemVo { + +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/TenantGlobalDictVo.java b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/TenantGlobalDictVo.java new file mode 100644 index 00000000..94ac38fc --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/TenantGlobalDictVo.java @@ -0,0 +1,29 @@ +package com.orangeforms.common.dict.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 租户全局系统字典Vo。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "租户全局系统字典Vo") +@Data +@EqualsAndHashCode(callSuper = true) +public class TenantGlobalDictVo extends GlobalDictVo { + + /** + * 是否为所有租户的通用字典。 + */ + @Schema(description = "是否为所有租户的通用字典") + private Boolean tenantCommon; + + /** + * 租户的非公用字典的初始化字典数据。 + */ + @Schema(description = "租户的非公用字典的初始化字典数据") + private String initialData; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-ext/pom.xml b/OrangeFormsOpen-MybatisFlex/common/common-ext/pom.xml new file mode 100644 index 00000000..f34963db --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-ext/pom.xml @@ -0,0 +1,21 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-ext + + + + com.orangeforms + common-redis + 1.0.0 + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/java/com/orangeforms/common/ext/base/BizWidgetDatasource.java b/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/java/com/orangeforms/common/ext/base/BizWidgetDatasource.java new file mode 100644 index 00000000..81673674 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/java/com/orangeforms/common/ext/base/BizWidgetDatasource.java @@ -0,0 +1,41 @@ +package com.orangeforms.common.ext.base; + +import com.orangeforms.common.core.object.MyOrderParam; +import com.orangeforms.common.core.object.MyPageData; +import com.orangeforms.common.core.object.MyPageParam; + +import java.util.List; +import java.util.Map; + +/** + * 业务组件获取数据的数据源接口。 + * 如果业务服务集成了common-ext组件,可以通过实现该接口的方式,为BizWidgetController访问提供数据。 + * 对于没有集成common-ext组件的服务,可以通过http方式,为BizWidgetController访问提供数据。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface BizWidgetDatasource { + + /** + * 获取指定通用业务组件的数据。 + * + * @param widgetType 业务组件类型。 + * @param filter 过滤参数。不同的数据源参数不同。这里我们以键值对的方式传递。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 查询后的分页数据列表。 + */ + MyPageData> getDataList( + String widgetType, Map filter, MyOrderParam orderParam, MyPageParam pageParam); + + /** + * 获取指定主键Id的数据对象。 + * + * @param widgetType 业务组件类型。 + * @param fieldName 字段名,如果为空,则使用主键字段名。 + * @param fieldValues 字段值集合。 + * @return 指定主键Id的数据对象。 + */ + List> getDataListWithInList(String widgetType, String fieldName, List fieldValues); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/java/com/orangeforms/common/ext/config/CommonExtAutoConfig.java b/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/java/com/orangeforms/common/ext/config/CommonExtAutoConfig.java new file mode 100644 index 00000000..41180d8c --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/java/com/orangeforms/common/ext/config/CommonExtAutoConfig.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.ext.config; + +import org.springframework.boot.context.properties.EnableConfigurationProperties; + +/** + * common-ext通用扩展模块的自动配置引导类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EnableConfigurationProperties({CommonExtProperties.class}) +public class CommonExtAutoConfig { +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/java/com/orangeforms/common/ext/config/CommonExtProperties.java b/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/java/com/orangeforms/common/ext/config/CommonExtProperties.java new file mode 100644 index 00000000..7aeb2c23 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/java/com/orangeforms/common/ext/config/CommonExtProperties.java @@ -0,0 +1,76 @@ +package com.orangeforms.common.ext.config; + +import cn.hutool.core.collection.CollUtil; +import lombok.Data; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * common-ext配置属性类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ConfigurationProperties(prefix = "common-ext") +public class CommonExtProperties implements InitializingBean { + + /** + * 上传存储类型。具体值可参考枚举 UploadStoreTypeEnum。默认0为本地存储。 + */ + @Value("${common-ext.uploadStoreType:0}") + private Integer uploadStoreType; + + /** + * 仅当uploadStoreType等于0的时候,该配置值生效。 + */ + @Value("${common-ext.uploadFileBaseDir:./zz-resource/upload-files/commonext}") + private String uploadFileBaseDir; + + private List apps; + + private Map applicationMap; + + @Override + public void afterPropertiesSet() throws Exception { + if (CollUtil.isEmpty(apps)) { + applicationMap = new HashMap<>(1); + } else { + applicationMap = apps.stream().collect(Collectors.toMap(AppProperties::getAppCode, c -> c)); + } + } + + @Data + public static class AppProperties { + /** + * 应用编码。 + */ + private String appCode; + /** + * 通用业务组件数据源属性列表。 + */ + private List bizWidgetDatasources; + } + + @Data + public static class BizWidgetDatasourceProperties { + /** + * 通用业务组件的数据源类型。多个类型之间逗号分隔,如:upms_user,upms_dept。 + */ + private String types; + /** + * 列表数据接口地址。格式为完整的url,如:http://xxxxx + */ + private String listUrl; + /** + * 详情数据接口地址。格式为完整的url,如:http://xxxxx + */ + private String viewUrl; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/java/com/orangeforms/common/ext/constant/BizWidgetDatasourceType.java b/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/java/com/orangeforms/common/ext/constant/BizWidgetDatasourceType.java new file mode 100644 index 00000000..5d3b4ae6 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/java/com/orangeforms/common/ext/constant/BizWidgetDatasourceType.java @@ -0,0 +1,41 @@ +package com.orangeforms.common.ext.constant; + +/** + * 业务组件数据源类型常量类。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class BizWidgetDatasourceType { + + /** + * 通用用户组件数据源类型。 + */ + public static final String UPMS_USER_TYPE = "upms_user"; + + /** + * 通用部门组件数据源类型。 + */ + public static final String UPMS_DEPT_TYPE = "upms_dept"; + + /** + * 通用角色组件数据源类型。 + */ + public static final String UPMS_ROLE_TYPE = "upms_role"; + + /** + * 通用岗位组件数据源类型。 + */ + public static final String UPMS_POST_TYPE = "upms_post"; + + /** + * 通用部门岗位组件数据源类型。 + */ + public static final String UPMS_DEPT_POST_TYPE = "upms_dept_post"; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private BizWidgetDatasourceType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/java/com/orangeforms/common/ext/controller/BizWidgetController.java b/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/java/com/orangeforms/common/ext/controller/BizWidgetController.java new file mode 100644 index 00000000..021ac5e1 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/java/com/orangeforms/common/ext/controller/BizWidgetController.java @@ -0,0 +1,58 @@ +package com.orangeforms.common.ext.controller; + +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.ext.util.BizWidgetDatasourceExtHelper; +import com.orangeforms.common.core.annotation.MyRequestBody; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +/** + * 业务组件获取数据的访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@RestController +@RequestMapping("${common-ext.urlPrefix}/bizwidget") +public class BizWidgetController { + + @Autowired + private BizWidgetDatasourceExtHelper bizWidgetDatasourceExtHelper; + + @PostMapping("/list") + public ResponseResult>> list( + @MyRequestBody(required = true) String widgetType, + @MyRequestBody JSONObject filter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + String appCode = TokenData.takeFromRequest().getAppCode(); + MyPageData> pageData = + bizWidgetDatasourceExtHelper.getDataList(appCode, widgetType, filter, orderParam, pageParam); + return ResponseResult.success(pageData); + } + + /** + * 查看指定多条数据的详情。 + * + * @param widgetType 组件类型。 + * @param fieldName 字段名,如果为空则默认为主键过滤。 + * @param fieldValues 字段值。多个值之间逗号分割。 + * @return 详情数据。 + */ + @PostMapping("/view") + public ResponseResult>> view( + @MyRequestBody(required = true) String widgetType, + @MyRequestBody String fieldName, + @MyRequestBody(required = true) String fieldValues) { + String appCode = TokenData.takeFromRequest().getAppCode(); + List> dataMapList = + bizWidgetDatasourceExtHelper.getDataListWithInList(appCode, widgetType, fieldName, fieldValues); + return ResponseResult.success(dataMapList); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/java/com/orangeforms/common/ext/controller/UtilController.java b/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/java/com/orangeforms/common/ext/controller/UtilController.java new file mode 100644 index 00000000..0d94cc1c --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/java/com/orangeforms/common/ext/controller/UtilController.java @@ -0,0 +1,112 @@ +package com.orangeforms.common.ext.controller; + +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.EnumUtil; +import cn.hutool.core.util.StrUtil; +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.upload.BaseUpDownloader; +import com.orangeforms.common.core.upload.UpDownloaderFactory; +import com.orangeforms.common.core.upload.UploadResponseInfo; +import com.orangeforms.common.core.upload.UploadStoreTypeEnum; +import com.orangeforms.common.core.util.ContextUtil; +import com.orangeforms.common.ext.config.CommonExtProperties; +import lombok.extern.slf4j.Slf4j; +import org.redisson.api.RBinaryStream; +import org.redisson.api.RedissonClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.OutputStream; + +/** + * 扩展工具接口类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@RestController +@RequestMapping("${common-ext.urlPrefix}/util") +public class UtilController { + + @Autowired + private UpDownloaderFactory upDownloaderFactory; + @Autowired + private CommonExtProperties properties; + @Autowired + private RedissonClient redissonClient; + + private static final String IMAGE_DATA_FIELD = "imageData"; + + /** + * 上传图片数据。 + * + * @param uploadFile 上传图片文件。 + */ + @PostMapping("/uploadImage") + public void uploadImage(@RequestParam("uploadFile") MultipartFile uploadFile) throws IOException { + BaseUpDownloader upDownloader = + upDownloaderFactory.get(EnumUtil.getEnumAt(UploadStoreTypeEnum.class, properties.getUploadStoreType())); + UploadResponseInfo responseInfo = upDownloader.doUpload(null, + properties.getUploadFileBaseDir(), "CommonExt", IMAGE_DATA_FIELD, true, uploadFile); + if (BooleanUtil.isTrue(responseInfo.getUploadFailed())) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, + ResponseResult.error(ErrorCodeEnum.UPLOAD_FAILED, responseInfo.getErrorMessage())); + return; + } + String uploadUri = ContextUtil.getHttpRequest().getRequestURI(); + uploadUri = StrUtil.removeSuffix(uploadUri, "/"); + uploadUri = StrUtil.removeSuffix(uploadUri, "/uploadImage"); + responseInfo.setDownloadUri(uploadUri + "/downloadImage"); + ResponseResult.output(ResponseResult.success(responseInfo)); + } + + /** + * 下载图片数据。 + * + * @param filename 文件名。 + * @param response Http 应答对象。 + */ + @GetMapping("/downloadImage") + public void downloadImage(@RequestParam String filename, HttpServletResponse response) { + try { + BaseUpDownloader upDownloader = + upDownloaderFactory.get(EnumUtil.getEnumAt(UploadStoreTypeEnum.class, properties.getUploadStoreType())); + upDownloader.doDownload(properties.getUploadFileBaseDir(), + "CommonExt", IMAGE_DATA_FIELD, filename, true, response); + } catch (Exception e) { + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + log.error(e.getMessage(), e); + } + } + + /** + * 下载缓存的会话图片数据。 + * + * @param filename 文件名。 + * @param response Http 应答对象。 + */ + @GetMapping("/downloadSessionImage") + public void downloadSessionImage(@RequestParam String filename, HttpServletResponse response) throws IOException { + TokenData tokenData = TokenData.takeFromRequest(); + String key = tokenData.getSessionId() + filename; + RBinaryStream stream = redissonClient.getBinaryStream(key); + if (!stream.isExists()) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, + ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, "无效的会话缓存图片!")); + } + response.setHeader("content-type", "application/octet-stream"); + response.setContentType("application/octet-stream"); + response.setHeader("Content-Disposition", "attachment;filename=" + filename); + try (OutputStream os = response.getOutputStream()) { + os.write(stream.getAndDelete()); + } catch (IOException e) { + log.error("Failed to call LocalUpDownloader.doDownload", e); + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/java/com/orangeforms/common/ext/util/BizWidgetDatasourceExtHelper.java b/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/java/com/orangeforms/common/ext/util/BizWidgetDatasourceExtHelper.java new file mode 100644 index 00000000..ba9cef17 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/java/com/orangeforms/common/ext/util/BizWidgetDatasourceExtHelper.java @@ -0,0 +1,209 @@ +package com.orangeforms.common.ext.util; + +import cn.hutool.core.lang.Assert; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.text.StrFormatter; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpResponse; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.ext.base.BizWidgetDatasource; +import com.orangeforms.common.ext.config.CommonExtProperties; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import jakarta.annotation.PostConstruct; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 高级通用业务组件的扩展帮助实现类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Component +public class BizWidgetDatasourceExtHelper { + + @Autowired + private CommonExtProperties properties; + /** + * 全部框架使用橙单框架,同时组件所在模块,如在线表单,报表等和业务服务位于同一服务内是使用。 + */ + private static final String DEFAULT_ORANGE_APP = "__DEFAULT_ORANGE_APP__"; + /** + * Map的数据结构为:Map> + */ + private Map> dataExtractorMap = MapUtil.newHashMap(); + + @PostConstruct + private void laodThirdPartyAppConfig() { + Map appPropertiesMap = properties.getApplicationMap(); + if (MapUtil.isEmpty(appPropertiesMap)) { + return; + } + for (Map.Entry entry : appPropertiesMap.entrySet()) { + String appCode = entry.getKey(); + List datasources = entry.getValue().getBizWidgetDatasources(); + Map m = new HashMap<>(datasources.size()); + for (CommonExtProperties.BizWidgetDatasourceProperties datasource : datasources) { + List types = StrUtil.split(datasource.getTypes(), ","); + DatasourceWrapper w = new DatasourceWrapper(); + w.setListUrl(datasource.getListUrl()); + w.setViewUrl(datasource.getViewUrl()); + for (String type : types) { + m.put(type, w); + } + } + dataExtractorMap.put(appCode, m); + } + } + + /** + * 为默认APP注册基础组件数据源对象。 + * + * @param type 数据源类型。 + * @param datasource 业务通用组件的数据源接口。 + */ + public void registerDatasource(String type, BizWidgetDatasource datasource) { + Assert.notBlank(type); + Assert.notNull(datasource); + Map datasourceWrapperMap = + dataExtractorMap.computeIfAbsent(DEFAULT_ORANGE_APP, k -> new HashMap<>(2)); + datasourceWrapperMap.put(type, new DatasourceWrapper(datasource)); + } + + /** + * 根据过滤条件获取指定通用业务组件的数据列表。 + * + * @param appCode 接入应用编码。如果为空,则使用默认的 DEFAULT_ORANGE_APP。 + * @param type 组件数据源类型。 + * @param filter 过滤参数。不同的数据源参数不同。这里我们以键值对的方式传递。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 查询后的分页数据列表。 + */ + public MyPageData> getDataList( + String appCode, String type, Map filter, MyOrderParam orderParam, MyPageParam pageParam) { + if (StrUtil.isBlank(type)) { + throw new MyRuntimeException("Argument [types] can't be BLANK"); + } + if (StrUtil.isBlank(appCode)) { + return this.getDataList(type, filter, orderParam, pageParam); + } + DatasourceWrapper wrapper = this.getDatasourceWrapper(appCode, type); + JSONObject body = new JSONObject(); + body.put("type", type); + if (MapUtil.isNotEmpty(filter)) { + body.put("filter", filter); + } + if (orderParam != null) { + body.put("orderParam", orderParam); + } + if (pageParam != null) { + body.put("pageParam", pageParam); + } + String response = this.invokeThirdPartyUrlWithPost(wrapper.getListUrl(), body.toJSONString()); + ResponseResult>> responseResult = + JSON.parseObject(response, new TypeReference>>>() { + }); + if (!responseResult.isSuccess()) { + throw new MyRuntimeException(responseResult.getErrorMessage()); + } + return responseResult.getData(); + } + + /** + * 根据指定字段的集合获取指定通用业务组件的数据对象列表。 + * + * @param appCode 接入应用Id。如果为空,则使用默认的 DEFAULT_ORANGE_APP。 + * @param type 组件数据源类型。 + * @param fieldName 字段名称。 + * @param fieldValues 字段值结合。 + * @return 指定字段数据集合的数据对象列表。 + */ + public List> getDataListWithInList( + String appCode, String type, String fieldName, String fieldValues) { + if (StrUtil.isBlank(fieldValues)) { + throw new MyRuntimeException("Argument [fieldValues] can't be BLANK"); + } + if (StrUtil.isBlank(type)) { + throw new MyRuntimeException("Argument [types] can't be BLANK"); + } + if (StrUtil.isBlank(appCode)) { + return this.getDataListWithInList(type, fieldName, fieldValues); + } + DatasourceWrapper wrapper = this.getDatasourceWrapper(appCode, type); + JSONObject body = new JSONObject(); + body.put("type", type); + if (StrUtil.isNotBlank(fieldName)) { + body.put("fieldName", fieldName); + } + body.put("fieldValues", fieldValues); + String response = this.invokeThirdPartyUrlWithPost(wrapper.getViewUrl(), body.toJSONString()); + ResponseResult>> responseResult = + JSON.parseObject(response, new TypeReference>>>() { + }); + if (!responseResult.isSuccess()) { + throw new MyRuntimeException(responseResult.getErrorMessage()); + } + return responseResult.getData(); + } + + private MyPageData> getDataList( + String type, Map filter, MyOrderParam orderParam, MyPageParam pageParam) { + DatasourceWrapper wrapper = this.getDatasourceWrapper(DEFAULT_ORANGE_APP, type); + return wrapper.getBizWidgetDataSource().getDataList(type, filter, orderParam, pageParam); + } + + private List> getDataListWithInList(String type, String fieldName, String fieldValues) { + DatasourceWrapper wrapper = this.getDatasourceWrapper(DEFAULT_ORANGE_APP, type); + return wrapper.getBizWidgetDataSource().getDataListWithInList(type, fieldName, StrUtil.split(fieldValues, ",")); + } + + private String invokeThirdPartyUrlWithPost(String url, String body) { + String token = TokenData.takeFromRequest().getToken(); + Map headerMap = new HashMap<>(1); + headerMap.put("Authorization", token); + StringBuilder fullUrl = new StringBuilder(128); + fullUrl.append(url).append("?token=").append(token); + HttpResponse httpResponse = HttpUtil.createPost(fullUrl.toString()).body(body).addHeaders(headerMap).execute(); + if (!httpResponse.isOk()) { + String msg = StrFormatter.format( + "Failed to call [{}] with ERROR HTTP Status [{}] and [{}].", + url, httpResponse.getStatus(), httpResponse.body()); + log.error(msg); + throw new MyRuntimeException(msg); + } + return httpResponse.body(); + } + + private DatasourceWrapper getDatasourceWrapper(String appCode, String type) { + Map datasourceWrapperMap = dataExtractorMap.get(appCode); + Assert.notNull(datasourceWrapperMap); + DatasourceWrapper wrapper = datasourceWrapperMap.get(type); + Assert.notNull(wrapper); + return wrapper; + } + + @NoArgsConstructor + @Data + public static class DatasourceWrapper { + private BizWidgetDatasource bizWidgetDataSource; + private String listUrl; + private String viewUrl; + + public DatasourceWrapper(BizWidgetDatasource bizWidgetDataSource) { + this.bizWidgetDataSource = bizWidgetDataSource; + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..fc140409 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-ext/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.orangeforms.common.ext.config.CommonExtAutoConfig \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow-online/pom.xml b/OrangeFormsOpen-MybatisFlex/common/common-flow-online/pom.xml new file mode 100644 index 00000000..9e40544e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow-online/pom.xml @@ -0,0 +1,29 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-flow-online + 1.0.0 + common-flow-online + jar + + + + com.orangeforms + common-flow + 1.0.0 + + + com.orangeforms + common-online + 1.0.0 + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/config/FlowOnlineAutoConfig.java b/OrangeFormsOpen-MybatisFlex/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/config/FlowOnlineAutoConfig.java new file mode 100644 index 00000000..07538229 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/config/FlowOnlineAutoConfig.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.flow.online.config; + +import org.springframework.boot.context.properties.EnableConfigurationProperties; + +/** + * common-flow-online模块的自动配置引导类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EnableConfigurationProperties({FlowOnlineProperties.class}) +public class FlowOnlineAutoConfig { +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/config/FlowOnlineProperties.java b/OrangeFormsOpen-MybatisFlex/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/config/FlowOnlineProperties.java new file mode 100644 index 00000000..143afba4 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/config/FlowOnlineProperties.java @@ -0,0 +1,20 @@ +package com.orangeforms.common.flow.online.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * 在线表单工作流模块的配置对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ConfigurationProperties(prefix = "common-flow-online") +public class FlowOnlineProperties { + + /** + * 在线表单的URL前缀。 + */ + private String urlPrefix; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/controller/FlowOnlineOperationController.java b/OrangeFormsOpen-MybatisFlex/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/controller/FlowOnlineOperationController.java new file mode 100644 index 00000000..cdeb15bb --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/controller/FlowOnlineOperationController.java @@ -0,0 +1,1082 @@ +package com.orangeforms.common.flow.online.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import io.swagger.v3.oas.annotations.tags.Tag; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.common.core.annotation.DisableDataFilter; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.online.config.OnlineProperties; +import com.orangeforms.common.online.dto.OnlineFilterDto; +import com.orangeforms.common.online.model.*; +import com.orangeforms.common.online.model.constant.FieldKind; +import com.orangeforms.common.online.service.*; +import com.orangeforms.common.online.model.constant.FieldFilterType; +import com.orangeforms.common.online.model.constant.RelationType; +import com.orangeforms.common.online.util.OnlineOperationHelper; +import com.orangeforms.common.flow.online.service.FlowOnlineOperationService; +import com.orangeforms.common.flow.constant.FlowTaskStatus; +import com.orangeforms.common.flow.constant.FlowConstant; +import com.orangeforms.common.flow.constant.FlowApprovalType; +import com.orangeforms.common.flow.util.FlowOperationHelper; +import com.orangeforms.common.flow.dto.FlowWorkOrderDto; +import com.orangeforms.common.flow.dto.FlowTaskCommentDto; +import com.orangeforms.common.flow.exception.FlowOperationException; +import com.orangeforms.common.flow.model.constant.FlowMessageType; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.flow.service.*; +import com.orangeforms.common.flow.vo.*; +import com.orangeforms.common.redis.cache.SessionCacheHelper; +import com.orangeforms.common.satoken.annotation.SaTokenDenyAuth; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.history.HistoricProcessInstance; +import org.flowable.engine.runtime.ProcessInstance; +import org.flowable.task.api.Task; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import jakarta.servlet.http.HttpServletResponse; +import java.io.*; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 工作流在线表单流程操作接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "工作流在线表单流程操作接口") +@Slf4j +@RestController +@RequestMapping("${common-flow.urlPrefix}/flowOnlineOperation") +@ConditionalOnProperty(name = "common-flow.operationEnabled", havingValue = "true") +public class FlowOnlineOperationController { + + @Autowired + private FlowEntryService flowEntryService; + @Autowired + private FlowApiService flowApiService; + @Autowired + private FlowOperationHelper flowOperationHelper; + @Autowired + private FlowOnlineOperationService flowOnlineOperationService; + @Autowired + private FlowWorkOrderService flowWorkOrderService; + @Autowired + private FlowMessageService flowMessageService; + @Autowired + private OnlineFormService onlineFormService; + @Autowired + private OnlinePageService onlinePageService; + @Autowired + private OnlineOperationService onlineOperationService; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private OnlineOperationHelper onlineOperationHelper; + @Autowired + private OnlineProperties onlineProperties; + @Autowired + private SessionCacheHelper sessionCacheHelper; + + private static final String ONE_TO_MANY_VAR_SUFFIX = "List"; + + /** + * 根据指定流程的主版本,发起一个流程实例,同时作为第一个任务节点的执行人,执行第一个用户任务。 + * 该接口无需数据权限过滤,因此用DisableDataFilter注解标注。如果当前系统没有支持数据权限过滤,该注解不会有任何影响。 + * 注:流程设计页面的"启动"按钮,调用该接口可以启动任何流程用于流程配置后的测试验证。 + * + * @param processDefinitionKey 流程定义标识。 + * @param flowTaskCommentDto 审批意见。 + * @param taskVariableData 流程任务变量数据。 + * @param masterData 流程审批相关的主表数据。 + * @param slaveData 流程审批相关的多个从表数据。 + * @param copyData 传阅数据,格式为type和id,type的值参考FlowConstant中的常量值。 + * @return 应答结果对象。 + */ + @DisableDataFilter + @SaCheckPermission("flowEntry.all") + @OperationLog(type = SysOperationLogType.START_FLOW) + @PostMapping("/startPreview") + public ResponseResult startPreview( + @MyRequestBody(required = true) String processDefinitionKey, + @MyRequestBody(required = true) FlowTaskCommentDto flowTaskCommentDto, + @MyRequestBody JSONObject taskVariableData, + @MyRequestBody(required = true) JSONObject masterData, + @MyRequestBody JSONObject slaveData, + @MyRequestBody JSONObject copyData) { + return this.startAndTake( + processDefinitionKey, flowTaskCommentDto, taskVariableData, masterData, slaveData, copyData); + } + + /** + * 根据指定流程的主版本,发起一个流程实例,同时作为第一个任务节点的执行人,执行第一个用户任务。 + * 该接口无需数据权限过滤,因此用DisableDataFilter注解标注。如果当前系统没有支持数据权限过滤,该注解不会有任何影响。 + * + * @param processDefinitionKey 流程定义标识。 + * @param flowTaskCommentDto 审批意见。 + * @param taskVariableData 流程任务变量数据。 + * @param masterData 流程审批相关的主表数据。 + * @param slaveData 流程审批相关的多个从表数据。 + * @param copyData 传阅数据,格式为type和id,type的值参考FlowConstant中的常量值。 + * @return 应答结果对象。 + */ + @DisableDataFilter + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.START_FLOW) + @PostMapping("/startAndTakeUserTask/{processDefinitionKey}") + public ResponseResult startAndTakeUserTask( + @PathVariable("processDefinitionKey") String processDefinitionKey, + @MyRequestBody(required = true) FlowTaskCommentDto flowTaskCommentDto, + @MyRequestBody JSONObject taskVariableData, + @MyRequestBody(required = true) JSONObject masterData, + @MyRequestBody JSONObject slaveData, + @MyRequestBody JSONObject copyData) { + return this.startAndTake( + processDefinitionKey, flowTaskCommentDto, taskVariableData, masterData, slaveData, copyData); + } + + /** + * 启动流程并创建工单,同时将当前录入的数据存入草稿。 + * + * @param processDefinitionKey 流程定义标识。 + * @param processInstanceId 流程实例Id。第一次保存时,该值为null。 + * @param masterData 流程审批相关的主表数据。 + * @param slaveData 流程审批相关的多个从表数据。 + * @return 应答结果对象,草稿的待办任务对象。 + */ + @DisableDataFilter + @SaTokenDenyAuth + @PostMapping("/startAndSaveDraft/{processDefinitionKey}") + public ResponseResult startAndSaveDraft( + @PathVariable("processDefinitionKey") String processDefinitionKey, + @MyRequestBody String processInstanceId, + @MyRequestBody JSONObject masterData, + @MyRequestBody JSONObject slaveData) { + String errorMessage; + if (MapUtil.isEmpty(masterData) && MapUtil.isEmpty(slaveData)) { + errorMessage = "数据验证失败,业务数据不能全部为空!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + ResponseResult> verifyResult = + this.verifyAndGetFlowEntryPublishAndDatasource(processDefinitionKey, true); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + FlowEntryPublish flowEntryPublish = verifyResult.getData().getFirst(); + OnlineTable masterTable = verifyResult.getData().getSecond().getMasterTable(); + // 自动填充创建人数据。 + for (OnlineColumn column : masterTable.getColumnMap().values()) { + if (ObjectUtil.equals(column.getFieldKind(), FieldKind.CREATE_USER_ID)) { + masterData.put(column.getColumnName(), TokenData.takeFromRequest().getUserId()); + } else if (ObjectUtil.equals(column.getFieldKind(), FieldKind.CREATE_DEPT_ID)) { + masterData.put(column.getColumnName(), TokenData.takeFromRequest().getDeptId()); + } + } + FlowWorkOrder flowWorkOrder; + if (processInstanceId == null) { + flowWorkOrder = flowOnlineOperationService.saveNewDraftAndStartProcess( + flowEntryPublish.getProcessDefinitionId(), masterTable.getTableId(), masterData, slaveData); + } else { + ResponseResult flowWorkOrderResult = + flowOperationHelper.verifyAndGetFlowWorkOrderWithDraft(processDefinitionKey, processInstanceId); + if (!flowWorkOrderResult.isSuccess()) { + return ResponseResult.errorFrom(flowWorkOrderResult); + } + flowWorkOrder = flowWorkOrderResult.getData(); + flowWorkOrderService.updateDraft(flowWorkOrderResult.getData().getWorkOrderId(), + JSON.toJSONString(masterData), JSON.toJSONString(slaveData)); + } + List taskList = flowApiService.getProcessInstanceActiveTaskList(flowWorkOrder.getProcessInstanceId()); + List flowTaskVoList = flowApiService.convertToFlowTaskList(taskList); + return ResponseResult.success(flowTaskVoList.get(0)); + } + + /** + * 提交流程的用户任务。 + * 该接口无需数据权限过滤,因此用DisableDataFilter注解标注。如果当前系统没有支持数据权限过滤,该注解不会有任何影响。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 流程任务Id。 + * @param flowTaskCommentDto 流程审批数据。 + * @param taskVariableData 流程任务变量数据。 + * @param masterData 流程审批相关的主表数据。 + * @param slaveData 流程审批相关的多个从表数据。 + * @param copyData 传阅数据,格式为type和id,type的值参考FlowConstant中的常量值。 + * @return 应答结果对象。 + */ + @DisableDataFilter + @OperationLog(type = SysOperationLogType.SUBMIT_TASK) + @PostMapping("/submitUserTask") + public ResponseResult submitUserTask( + @MyRequestBody(required = true) String processInstanceId, + @MyRequestBody(required = true) String taskId, + @MyRequestBody(required = true) FlowTaskCommentDto flowTaskCommentDto, + @MyRequestBody JSONObject taskVariableData, + @MyRequestBody JSONObject masterData, + @MyRequestBody JSONObject slaveData, + @MyRequestBody JSONObject copyData) { + String errorMessage; + // 验证流程任务的合法性。 + Task task = flowApiService.getProcessInstanceActiveTask(processInstanceId, taskId); + ResponseResult taskInfoResult = flowOperationHelper.verifyAndGetRuntimeTaskInfo(task); + if (!taskInfoResult.isSuccess()) { + return ResponseResult.errorFrom(taskInfoResult); + } + TaskInfoVo taskInfo = taskInfoResult.getData(); + // 验证在线表单及其关联数据源的合法性。 + ResponseResult datasourceResult = this.verifyAndGetOnlineDatasource(taskInfo.getFormId()); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + CallResult assigneeVerifyResult = flowApiService.verifyAssigneeOrCandidateAndClaim(task); + if (!assigneeVerifyResult.isSuccess()) { + return ResponseResult.errorFrom(assigneeVerifyResult); + } + OnlineDatasource datasource = datasourceResult.getData(); + ProcessInstance instance = flowApiService.getProcessInstance(processInstanceId); + String dataId = instance.getBusinessKey(); + // 这里把传阅数据放到任务变量中,是为了避免给流程数据操作方法增加额外的方法调用参数。 + if (MapUtil.isNotEmpty(copyData)) { + if (taskVariableData == null) { + taskVariableData = new JSONObject(); + } + taskVariableData.put(FlowConstant.COPY_DATA_KEY, copyData); + } + FlowTaskComment flowTaskComment = BeanUtil.copyProperties(flowTaskCommentDto, FlowTaskComment.class); + if (StrUtil.isBlank(dataId)) { + return this.submitNewTask(processInstanceId, taskId, + flowTaskComment, taskVariableData, datasource, masterData, slaveData); + } + try { + if (StrUtil.equals(flowTaskComment.getApprovalType(), FlowApprovalType.TRANSFER) + && StrUtil.isBlank(flowTaskComment.getDelegateAssignee())) { + errorMessage = "数据验证失败,加签或转办任务指派人不能为空!!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + // 如果本次请求中包含从表数据,则一同插入。 + ResponseResult>> slaveDataListResult = + onlineOperationHelper.buildSlaveDataList(datasource.getDatasourceId(), slaveData); + if (!slaveDataListResult.isSuccess()) { + return ResponseResult.errorFrom(slaveDataListResult); + } + flowOnlineOperationService.updateAndTakeTask( + task, flowTaskComment, taskVariableData, datasource, masterData, dataId, slaveDataListResult.getData()); + } catch (FlowOperationException e) { + log.error("Failed to call [FlowOnlineOperationService.updateAndTakeTask]", e); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, e.getMessage()); + } + return ResponseResult.success(); + } + + /** + * 查看指定流程实例的草稿数据。 + * NOTE: 白名单接口。 + * + * @param processDefinitionKey 流程定义标识。 + * @param processInstanceId 流程实例Id。 + * @return 流程实例的草稿数据。 + */ + @DisableDataFilter + @GetMapping("/viewDraftData") + public ResponseResult viewDraftData( + @RequestParam String processDefinitionKey, @RequestParam String processInstanceId) { + String errorMessage; + ResponseResult flowWorkOrderResult = + flowOperationHelper.verifyAndGetFlowWorkOrderWithDraft(processDefinitionKey, processInstanceId); + if (!flowWorkOrderResult.isSuccess()) { + return ResponseResult.errorFrom(flowWorkOrderResult); + } + FlowWorkOrder flowWorkOrder = flowWorkOrderResult.getData(); + if (flowWorkOrder.getOnlineTableId() == null) { + errorMessage = "数据验证失败,当前工单不是在线表单工单!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + FlowWorkOrderExt flowWorkOrderExt = + flowWorkOrderService.getFlowWorkOrderExtByWorkOrderId(flowWorkOrder.getWorkOrderId()); + if (StrUtil.isBlank(flowWorkOrderExt.getDraftData())) { + return ResponseResult.success(null); + } + Long tableId = flowWorkOrder.getOnlineTableId(); + OnlineTable masterTable = onlineTableService.getOnlineTableFromCache(tableId); + JSONObject draftData = JSON.parseObject(flowWorkOrderExt.getDraftData()); + JSONObject masterData = draftData.getJSONObject(FlowConstant.MASTER_DATA_KEY); + JSONObject slaveData = draftData.getJSONObject(FlowConstant.SLAVE_DATA_KEY); + OnlineDatasource datasource = + onlineDatasourceService.getOnlineDatasourceByMasterTableId(tableId); + List slaveRelationList = null; + if (slaveData != null) { + ResponseResult> relationListResult = + onlineOperationHelper.verifyAndGetRelationList(datasource.getDatasourceId(), null); + if (!relationListResult.isSuccess()) { + return ResponseResult.errorFrom(relationListResult); + } + slaveRelationList = relationListResult.getData(); + } + datasource.setMasterTable(masterTable); + JSONObject jsonData = this.buildDraftData(datasource, masterData, slaveRelationList, slaveData); + return ResponseResult.success(jsonData); + } + + /** + * 获取当前流程实例的详情数据。包括主表数据、一对一从表数据、一对多从表数据列表等。 + * 该接口无需数据权限过滤,因此用DisableDataFilter注解标注。如果当前系统没有支持数据权限过滤,该注解不会有任何影响。 + * + * @param processInstanceId 当前运行时的流程实例Id。 + * @param taskId 流程任务Id。 + * @return 当前流程实例的详情数据。 + */ + @DisableDataFilter + @GetMapping("/viewUserTask") + public ResponseResult viewUserTask( + @RequestParam String processInstanceId, @RequestParam String taskId) { + // 验证流程任务的合法性。 + Task task = flowApiService.getProcessInstanceActiveTask(processInstanceId, taskId); + ProcessInstance instance = flowApiService.getProcessInstance(processInstanceId); + // 如果业务主数据为空,则直接返回。 + if (StrUtil.isBlank(instance.getBusinessKey())) { + return ResponseResult.success(null); + } + ResponseResult taskInfoResult = flowOperationHelper.verifyAndGetRuntimeTaskInfo(task); + if (!taskInfoResult.isSuccess()) { + return ResponseResult.errorFrom(taskInfoResult); + } + TaskInfoVo taskInfo = taskInfoResult.getData(); + // 验证在线表单及其关联数据源的合法性。 + ResponseResult datasourceResult = this.verifyAndGetOnlineDatasource(taskInfo.getFormId()); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + ResponseResult> relationListResult = + onlineOperationHelper.verifyAndGetRelationList(datasourceResult.getData().getDatasourceId(), null); + if (!relationListResult.isSuccess()) { + return ResponseResult.errorFrom(relationListResult); + } + JSONObject jsonData = this.buildUserTaskData( + instance.getBusinessKey(), datasourceResult.getData(), relationListResult.getData()); + return ResponseResult.success(jsonData); + } + + /** + * 获取已经结束的流程实例的详情数据。包括主表数据、一对一从表数据、一对多从表数据列表等。 + * 该接口无需数据权限过滤,因此用DisableDataFilter注解标注。如果当前系统没有支持数据权限过滤,该注解不会有任何影响。 + * + * @param processInstanceId 历史流程实例Id。 + * @param taskId 历史任务Id。如果该值为null,仅有发起人可以查看当前流程数据,否则只有任务的指派人才能查看。 + * @return 历史流程实例的详情数据。 + */ + @DisableDataFilter + @GetMapping("/viewHistoricProcessInstance") + public ResponseResult viewHistoricProcessInstance( + @RequestParam String processInstanceId, @RequestParam(required = false) String taskId) { + // 验证流程实例的合法性。 + ResponseResult verifyResult = + flowOperationHelper.verifyAndGetHistoricProcessInstance(processInstanceId, taskId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + HistoricProcessInstance instance = verifyResult.getData(); + if (StrUtil.isBlank(instance.getBusinessKey())) { + // 对于没有提交过任何用户任务的场景,可直接返回空数据。 + return ResponseResult.success(new JSONObject()); + } + FlowEntryPublish flowEntryPublish = + flowEntryService.getFlowEntryPublishList(CollUtil.newHashSet(instance.getProcessDefinitionId())).get(0); + TaskInfoVo taskInfoVo = JSON.parseObject(flowEntryPublish.getInitTaskInfo(), TaskInfoVo.class); + // 验证在线表单及其关联数据源的合法性。 + ResponseResult datasourceResult = this.verifyAndGetOnlineDatasource(taskInfoVo.getFormId()); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + ResponseResult> relationListResult = + onlineOperationHelper.verifyAndGetRelationList(datasourceResult.getData().getDatasourceId(), null); + if (!relationListResult.isSuccess()) { + return ResponseResult.errorFrom(relationListResult); + } + JSONObject jsonData = this.buildUserTaskData( + instance.getBusinessKey(), datasourceResult.getData(), relationListResult.getData()); + return ResponseResult.success(jsonData); + } + + /** + * 根据消息Id,获取流程Id关联的业务数据。 + * NOTE:白名单接口。f + * + * @param messageId 抄送消息Id。 + * @return 抄送消息关联的流程实例业务数据。 + */ + @DisableDataFilter + @GetMapping("/viewCopyBusinessData") + public ResponseResult viewCopyBusinessData(@RequestParam Long messageId) { + String errorMessage; + // 验证流程任务的合法性。 + FlowMessage flowMessage = flowMessageService.getById(messageId); + if (flowMessage == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + if (flowMessage.getMessageType() != FlowMessageType.COPY_TYPE) { + errorMessage = "数据验证失败,当前消息不是抄送类型消息!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (flowMessage.getOnlineFormData() == null || !flowMessage.getOnlineFormData()) { + errorMessage = "数据验证失败,当前消息为静态路由表单数据,不能通过该接口获取!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!flowMessageService.isCandidateIdentityOnMessage(messageId)) { + errorMessage = "数据验证失败,当前用户没有权限访问该消息!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + HistoricProcessInstance instance = + flowApiService.getHistoricProcessInstance(flowMessage.getProcessInstanceId()); + // 如果业务主数据为空,则直接返回。 + if (StrUtil.isBlank(instance.getBusinessKey())) { + errorMessage = "数据验证失败,当前消息为所属流程实例没有包含业务主键Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + Long formId = Long.valueOf(flowMessage.getBusinessDataShot()); + // 验证在线表单及其关联数据源的合法性。 + ResponseResult datasourceResult = this.verifyAndGetOnlineDatasource(formId); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + OnlineDatasource datasource = datasourceResult.getData(); + ResponseResult> relationListResult = + onlineOperationHelper.verifyAndGetRelationList(datasource.getDatasourceId(), null); + if (!relationListResult.isSuccess()) { + return ResponseResult.errorFrom(relationListResult); + } + JSONObject jsonData = this.buildUserTaskData( + instance.getBusinessKey(), datasource, relationListResult.getData()); + // 将当前消息更新为已读 + flowMessageService.readCopyTask(messageId); + return ResponseResult.success(jsonData); + } + + /** + * 工作流工单列表。 + * + * @param processDefinitionKey 流程标识名。 + * @param flowWorkOrderDtoFilter 过滤对象。 + * @param pageParam 分页参数。 + * @return 查询结果。 + */ + @SaTokenDenyAuth + @PostMapping("/listWorkOrder/{processDefinitionKey}") + public ResponseResult> listWorkOrder( + @PathVariable("processDefinitionKey") String processDefinitionKey, + @MyRequestBody FlowWorkOrderDto flowWorkOrderDtoFilter, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount()); + } + FlowWorkOrder flowWorkOrderFilter = + flowOperationHelper.makeWorkOrderFilter(flowWorkOrderDtoFilter, processDefinitionKey); + MyOrderParam orderParam = new MyOrderParam(); + orderParam.add(new MyOrderParam.OrderInfo("workOrderId", false, null)); + String orderBy = MyOrderParam.buildOrderBy(orderParam, FlowWorkOrder.class); + List flowWorkOrderList = + flowWorkOrderService.getFlowWorkOrderList(flowWorkOrderFilter, orderBy); + MyPageData resultData = + MyPageUtil.makeResponseData(flowWorkOrderList, FlowWorkOrderVo.class); + flowOperationHelper.buildWorkOrderApprovalStatus(processDefinitionKey, resultData.getDataList()); + // 根据工单的提交用户名获取用户的显示名称,便于前端显示。 + // 同时这也是一个如何通过插件方法,将loginName映射到showName的示例, + flowWorkOrderService.fillUserShowNameByLoginName(resultData.getDataList()); + // 工单自身的查询中可以受到数据权限的过滤,但是工单集成业务数据时,则无需再对业务数据进行数据权限过滤了。 + GlobalThreadLocal.setDataFilter(false); + ResponseResult responseResult = this.makeWorkOrderTaskInfo(resultData.getDataList()); + if (!responseResult.isSuccess()) { + return ResponseResult.errorFrom(responseResult); + } + return ResponseResult.success(resultData); + } + + /** + * 为数据源主表字段上传文件。 + * + * @param processDefinitionKey 流程引擎流程定义标识。 + * @param processInstanceId 流程实例Id。 + * @param taskId 流程任务Id。 + * @param datasourceId 数据源Id。 + * @param relationId 数据源关联Id。 + * @param fieldName 数据表字段名。 + * @param asImage 是否为图片文件。 + * @param uploadFile 上传文件对象。 + */ + @DisableDataFilter + @OperationLog(type = SysOperationLogType.UPLOAD, saveResponse = false) + @PostMapping("/upload") + public void upload( + @RequestParam String processDefinitionKey, + @RequestParam(required = false) String processInstanceId, + @RequestParam(required = false) String taskId, + @RequestParam Long datasourceId, + @RequestParam(required = false) Long relationId, + @RequestParam String fieldName, + @RequestParam Boolean asImage, + @RequestParam("uploadFile") MultipartFile uploadFile) throws IOException { + ResponseResult verifyResult = + this.verifyUploadOrDownload(processDefinitionKey, processInstanceId, taskId, datasourceId); + if (!verifyResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, ResponseResult.errorFrom(verifyResult)); + return; + } + ResponseResult verifyTableResult = + this.verifyAndGetOnlineTable(datasourceId, relationId, null, null); + if (!verifyTableResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, ResponseResult.errorFrom(verifyTableResult)); + return; + } + onlineOperationHelper.doUpload(verifyTableResult.getData(), fieldName, asImage, uploadFile); + } + + /** + * 下载文件接口。 + * 越权访问限制说明: + * taskId为空,当前用户必须为当前流程的发起人,否则必须为当前任务的指派人或候选人。 + * relationId为空,下载数据为主表字段,否则为关联的从表字段。 + * 该接口无需数据权限过滤,因此用DisableDataFilter注解标注。如果当前系统没有支持数据权限过滤,该注解不会有任何影响。 + * + * @param processDefinitionKey 流程引擎流程定义标识。 + * @param processInstanceId 流程实例Id。 + * @param taskId 流程任务Id。 + * @param datasourceId 数据源Id。 + * @param relationId 数据源关联Id。 + * @param dataId 附件所在记录的主键Id。 + * @param fieldName 数据表字段名。 + * @param asImage 是否为图片文件。 + * @param response Http 应答对象。 + */ + @DisableDataFilter + @OperationLog(type = SysOperationLogType.DOWNLOAD, saveResponse = false) + @GetMapping("/download") + public void download( + @RequestParam String processDefinitionKey, + @RequestParam(required = false) String processInstanceId, + @RequestParam(required = false) String taskId, + @RequestParam Long datasourceId, + @RequestParam(required = false) Long relationId, + @RequestParam(required = false) String dataId, + @RequestParam String fieldName, + @RequestParam String filename, + @RequestParam Boolean asImage, + HttpServletResponse response) throws IOException { + ResponseResult verifyResult = + this.verifyUploadOrDownload(processDefinitionKey, processInstanceId, taskId, datasourceId); + if (!verifyResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, ResponseResult.errorFrom(verifyResult)); + return; + } + ResponseResult verifyTableResult = + this.verifyAndGetOnlineTable(datasourceId, relationId, verifyResult.getData(), dataId); + if (!verifyTableResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, ResponseResult.errorFrom(verifyTableResult)); + return; + } + onlineOperationHelper.doDownload(verifyTableResult.getData(), dataId, fieldName, filename, asImage, response); + } + + /** + * 获取所有流程对象,同时获取关联的在线表单对象列表。 + * + * @return 查询结果。 + */ + @GetMapping("/listFlowEntryForm") + public ResponseResult> listFlowEntryForm() { + List flowEntryList = flowEntryService.getFlowEntryList(null, null); + List flowEntryVoList = MyModelUtil.copyCollectionTo(flowEntryList, FlowEntryVo.class); + if (CollUtil.isNotEmpty(flowEntryVoList)) { + Set pageIdSet = flowEntryVoList.stream().map(FlowEntryVo::getPageId).collect(Collectors.toSet()); + List formList = onlineFormService.getOnlineFormListByPageIds(pageIdSet); + formList.forEach(f -> f.setWidgetJson(null)); + Map> formMap = + formList.stream().collect(Collectors.groupingBy(OnlineForm::getPageId)); + for (FlowEntryVo flowEntryVo : flowEntryVoList) { + List flowEntryFormList = formMap.get(flowEntryVo.getPageId()); + flowEntryVo.setFormList(MyModelUtil.beanToMapList(flowEntryFormList)); + } + } + return ResponseResult.success(flowEntryVoList); + } + + /** + * 获取在线表单工作流Id所关联的权限数据,包括权限字列表和权限资源列表。 + * 注:该接口仅用于微服务间调用使用,无需对前端开放。 + * + * @param onlineFlowEntryIds 在线表单工作流Id集合。 + * @return 参数中在线表单工作流Id集合所关联的权限数据。 + */ + @GetMapping("/calculatePermData") + public ResponseResult>> calculatePermData(@RequestParam Set onlineFlowEntryIds) { + return ResponseResult.success(flowOnlineOperationService.calculatePermData(onlineFlowEntryIds)); + } + + private ResponseResult startAndTake( + String processDefinitionKey, + FlowTaskCommentDto flowTaskCommentDto, + JSONObject taskVariableData, + JSONObject masterData, + JSONObject slaveData, + JSONObject copyData) { + ResponseResult> verifyResult = + this.verifyAndGetFlowEntryPublishAndDatasource(processDefinitionKey, true); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + FlowEntryPublish flowEntryPublish = verifyResult.getData().getFirst(); + OnlineDatasource datasource = verifyResult.getData().getSecond(); + OnlineTable masterTable = datasource.getMasterTable(); + // 这里把传阅数据放到任务变量中,是为了避免给流程数据操作方法增加额外的方法调用参数。 + if (MapUtil.isNotEmpty(copyData)) { + if (taskVariableData == null) { + taskVariableData = new JSONObject(); + } + taskVariableData.put(FlowConstant.COPY_DATA_KEY, copyData); + } + FlowTaskComment flowTaskComment = BeanUtil.copyProperties(flowTaskCommentDto, FlowTaskComment.class); + // 保存在线表单提交的数据,同时启动流程和自动完成第一个用户任务。 + if (slaveData == null) { + flowOnlineOperationService.saveNewAndStartProcess( + flowEntryPublish.getProcessDefinitionId(), + flowTaskComment, + taskVariableData, + masterTable, + masterData); + } else { + // 如果本次请求中包含从表数据,则一同插入。 + ResponseResult>> slaveDataListResult = + onlineOperationHelper.buildSlaveDataList(datasource.getDatasourceId(), slaveData); + if (!slaveDataListResult.isSuccess()) { + return ResponseResult.errorFrom(slaveDataListResult); + } + flowOnlineOperationService.saveNewAndStartProcess( + flowEntryPublish.getProcessDefinitionId(), + flowTaskComment, + taskVariableData, + masterTable, + masterData, + slaveDataListResult.getData()); + } + return ResponseResult.success(); + } + + private ResponseResult verifyAndGetOnlineDatasource(Long formId) { + List formDatasourceList = onlineFormService.getFormDatasourceListFromCache(formId); + if (CollUtil.isEmpty(formDatasourceList)) { + String errorMessage = "数据验证失败,流程任务绑定的在线表单Id [" + formId + "] 不存在,请修改流程图!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return onlineOperationHelper.verifyAndGetDatasource(formDatasourceList.get(0).getDatasourceId()); + } + + private ResponseResult> verifyAndGetFlowEntryPublishAndDatasource( + String processDefinitionKey, boolean checkStarter) { + String errorMessage; + // 1. 验证流程数据的合法性。 + ResponseResult flowEntryResult = flowOperationHelper.verifyAndGetFlowEntry(processDefinitionKey); + if (!flowEntryResult.isSuccess()) { + return ResponseResult.errorFrom(flowEntryResult); + } + // 2. 验证流程一个用户任务的合法性。 + FlowEntryPublish flowEntryPublish = flowEntryResult.getData().getMainFlowEntryPublish(); + if (BooleanUtil.isFalse(flowEntryPublish.getActiveStatus())) { + errorMessage = "数据验证失败,当前流程发布对象已被挂起,不能启动新流程!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + ResponseResult taskInfoResult = + flowOperationHelper.verifyAndGetInitialTaskInfo(flowEntryPublish, checkStarter); + if (!taskInfoResult.isSuccess()) { + return ResponseResult.errorFrom(taskInfoResult); + } + TaskInfoVo taskInfo = taskInfoResult.getData(); + // 3. 验证在线表单及其关联数据源的合法性。 + ResponseResult datasourceResult = this.verifyAndGetOnlineDatasource(taskInfo.getFormId()); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + return ResponseResult.success(new Tuple2<>(flowEntryPublish, datasourceResult.getData())); + } + + private ResponseResult verifyAndGetOnlineTable( + Long datasourceId, Long relationId, String businessKey, String dataId) { + ResponseResult datasourceResult = + onlineOperationHelper.verifyAndGetDatasource(datasourceId); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + OnlineTable masterTable = datasourceResult.getData().getMasterTable(); + OnlineTable table = masterTable; + ResponseResult relationResult = null; + if (relationId != null) { + relationResult = onlineOperationHelper.verifyAndGetRelation(datasourceId, relationId); + if (!relationResult.isSuccess()) { + return ResponseResult.errorFrom(relationResult); + } + table = relationResult.getData().getSlaveTable(); + } + if (StrUtil.hasBlank(businessKey, dataId)) { + return ResponseResult.success(table); + } + String errorMessage; + // 如果relationId为null,这里就是主表数据。 + if (relationId == null) { + if (!StrUtil.equals(businessKey, dataId)) { + errorMessage = "数据验证失败,参数主键Id与流程主表主键Id不匹配!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(table); + } + OnlineDatasourceRelation relation = relationResult.getData(); + OnlineTable slaveTable = relation.getSlaveTable(); + Map dataMap = + onlineOperationService.getMasterData(slaveTable, null, null, dataId); + if (dataMap == null) { + errorMessage = "数据验证失败,从表主键Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineColumn slaveColumn = relation.getSlaveColumn(); + Object relationSlaveDataId = dataMap.get(slaveColumn.getColumnName()); + if (relationSlaveDataId == null) { + errorMessage = "数据验证失败,当前关联的从表字段值为NULL!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineColumn masterColumn = masterTable.getColumnMap().get(relation.getMasterColumnId()); + if (BooleanUtil.isTrue(masterColumn.getPrimaryKey()) + && !StrUtil.equals(relationSlaveDataId.toString(), businessKey)) { + errorMessage = "数据验证失败,当前从表主键Id关联的主表Id当前流程的BusinessKey不一致!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + Map masterDataMap = + onlineOperationService.getMasterData(masterTable, null, null, businessKey); + if (masterDataMap == null) { + errorMessage = "数据验证失败,主表主键Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + Object relationMasterDataId = masterDataMap.get(masterColumn.getColumnName()); + if (relationMasterDataId == null) { + errorMessage = "数据验证失败,当前关联的主表字段值为NULL!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!StrUtil.equals(relationMasterDataId.toString(), relationSlaveDataId.toString())) { + errorMessage = "数据验证失败,当前关联的主表字段值和从表字段值不一致!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(table); + } + + private ResponseResult verifyUploadOrDownload( + String processDefinitionKey, String processInstanceId, String taskId, Long datasourceId) { + if (!StrUtil.isAllBlank(processInstanceId, taskId)) { + ResponseResult verifyResult = + flowOperationHelper.verifyUploadOrDownloadPermission(processInstanceId, taskId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(ResponseResult.errorFrom(verifyResult)); + } + } + String errorMessage; + FlowEntry flowEntry = flowEntryService.getFlowEntryFromCache(processDefinitionKey); + if (flowEntry == null) { + errorMessage = "数据验证失败,指定流程Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + String businessKey = null; + if (processInstanceId != null) { + HistoricProcessInstance instance = flowApiService.getHistoricProcessInstance(processInstanceId); + if (!StrUtil.equals(flowEntry.getProcessDefinitionKey(), instance.getProcessDefinitionKey())) { + errorMessage = "数据验证失败,指定流程实例并不属于当前流程!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + businessKey = instance.getBusinessKey(); + } + List datasourceList = + onlinePageService.getOnlinePageDatasourceListByPageId(flowEntry.getPageId()); + Optional r = datasourceList.stream() + .map(OnlinePageDatasource::getDatasourceId).filter(c -> c.equals(datasourceId)).findFirst(); + if (r.isEmpty()) { + errorMessage = "数据验证失败,当前数据源Id并不属于当前流程!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(businessKey); + } + + private ResponseResult submitNewTask( + String instanceId, + String taskId, + FlowTaskComment comment, + JSONObject variableData, + OnlineDatasource datasource, + JSONObject masterData, + JSONObject slaveData) { + OnlineTable masterTable = datasource.getMasterTable(); + // 保存在线表单提交的数据,同时启动流程和自动完成第一个用户任务。 + if (slaveData == null) { + flowOnlineOperationService.saveNewAndTakeTask( + instanceId, taskId, comment, variableData, masterTable, masterData); + } else { + // 如果本次请求中包含从表数据,则一同插入。 + ResponseResult>> slaveDataListResult = + onlineOperationHelper.buildSlaveDataList(datasource.getDatasourceId(), slaveData); + if (!slaveDataListResult.isSuccess()) { + return ResponseResult.errorFrom(slaveDataListResult); + } + flowOnlineOperationService.saveNewAndTakeTask( + instanceId, taskId, comment, variableData, masterTable, masterData, slaveDataListResult.getData()); + } + return ResponseResult.success(); + } + + private JSONObject buildUserTaskData( + String businessKey, OnlineDatasource datasource, List relationList) { + OnlineTable masterTable = datasource.getMasterTable(); + JSONObject jsonData = new JSONObject(); + List oneToOneRelationList = relationList.stream() + .filter(r -> r.getRelationType().equals(RelationType.ONE_TO_ONE)).collect(Collectors.toList()); + Map result = + onlineOperationService.getMasterData(masterTable, oneToOneRelationList, relationList, businessKey); + if (MapUtil.isEmpty(result)) { + return jsonData; + } + jsonData.put(datasource.getVariableName(), result); + List oneToManyRelationList = relationList.stream() + .filter(r -> r.getRelationType().equals(RelationType.ONE_TO_MANY)).collect(Collectors.toList()); + if (CollUtil.isEmpty(oneToManyRelationList)) { + return jsonData; + } + for (OnlineDatasourceRelation relation : oneToManyRelationList) { + OnlineFilterDto filterDto = new OnlineFilterDto(); + filterDto.setTableName(relation.getSlaveTable().getTableName()); + OnlineColumn slaveColumn = relation.getSlaveTable().getColumnMap().get(relation.getSlaveColumnId()); + filterDto.setColumnName(slaveColumn.getColumnName()); + filterDto.setFilterType(FieldFilterType.EQUAL_FILTER); + OnlineColumn masterColumn = masterTable.getColumnMap().get(relation.getMasterColumnId()); + Object columnValue = result.get(masterColumn.getColumnName()); + filterDto.setColumnValue(columnValue); + MyPageData> pageData = onlineOperationService.getSlaveDataList( + relation, CollUtil.newLinkedList(filterDto), null, null); + if (CollUtil.isNotEmpty(pageData.getDataList())) { + result.put(relation.getVariableName() + ONE_TO_MANY_VAR_SUFFIX, pageData.getDataList()); + } + } + return jsonData; + } + + private JSONObject buildDraftData( + OnlineDatasource datasource, + JSONObject masterData, + List relationList, + JSONObject slaveData) { + OnlineTable masterTable = datasource.getMasterTable(); + JSONObject jsonData = new JSONObject(); + JSONObject normalizedMasterData = new JSONObject(); + Map columnNameAndColumnMap = masterTable.getColumnMap() + .values().stream().collect(Collectors.toMap(OnlineColumn::getColumnName, c -> c)); + if (masterData != null) { + for (Map.Entry entry : masterData.entrySet()) { + OnlineColumn column = columnNameAndColumnMap.get(entry.getKey()); + Object v = onlineOperationHelper.convertToTypeValue(column, entry.getValue().toString()); + normalizedMasterData.put(entry.getKey(), v); + } + } + if (slaveData != null && relationList != null) { + Map relationMap = + relationList.stream().collect(Collectors.toMap(OnlineDatasourceRelation::getRelationId, c -> c)); + for (Map.Entry entry : slaveData.entrySet()) { + OnlineDatasourceRelation relation = relationMap.get(Long.valueOf(entry.getKey())); + if (relation != null) { + this.buildRelationDraftData(relation, entry.getValue(), normalizedMasterData); + } + } + } + jsonData.put(datasource.getVariableName(), normalizedMasterData); + return jsonData; + } + + private void buildRelationDraftData(OnlineDatasourceRelation relation, Object value, JSONObject masterData) { + if (relation.getRelationType().equals(RelationType.ONE_TO_ONE)) { + Map slaveColumnNameAndColumnMap = + relation.getSlaveTable().getColumnMap().values() + .stream().collect(Collectors.toMap(OnlineColumn::getColumnName, c -> c)); + JSONObject slaveObject = (JSONObject) value; + JSONObject normalizedSlaveObject = new JSONObject(); + for (Map.Entry entry2 : slaveObject.entrySet()) { + OnlineColumn column = slaveColumnNameAndColumnMap.get(entry2.getKey()); + Object v = onlineOperationHelper.convertToTypeValue(column, entry2.getValue().toString()); + normalizedSlaveObject.put(entry2.getKey(), v); + } + masterData.put(relation.getVariableName(), normalizedSlaveObject); + } else if (relation.getRelationType().equals(RelationType.ONE_TO_MANY)) { + JSONArray slaveArray = (JSONArray) value; + JSONArray normalizedSlaveArray = new JSONArray(); + for (int i = 0; i <= slaveArray.size() - 1; i++) { + JSONObject slaveObject = slaveArray.getJSONObject(i); + JSONObject normalizedSlaveObject = new JSONObject(); + normalizedSlaveObject.putAll(slaveObject); + normalizedSlaveArray.add(normalizedSlaveObject); + } + masterData.put(relation.getVariableName(), normalizedSlaveArray); + } + } + + private ResponseResult makeWorkOrderTaskInfo(List flowWorkOrderVoList) { + if (CollUtil.isEmpty(flowWorkOrderVoList)) { + return ResponseResult.success(); + } + Set definitionIdSet = + flowWorkOrderVoList.stream().map(FlowWorkOrderVo::getProcessDefinitionId).collect(Collectors.toSet()); + List flowEntryPublishList = flowEntryService.getFlowEntryPublishList(definitionIdSet); + Map flowEntryPublishMap = + flowEntryPublishList.stream().collect(Collectors.toMap(FlowEntryPublish::getProcessDefinitionId, c -> c)); + for (FlowWorkOrderVo flowWorkOrderVo : flowWorkOrderVoList) { + FlowEntryPublish flowEntryPublish = flowEntryPublishMap.get(flowWorkOrderVo.getProcessDefinitionId()); + flowWorkOrderVo.setInitTaskInfo(flowEntryPublish.getInitTaskInfo()); + } + Long tableId = flowWorkOrderVoList.get(0).getOnlineTableId(); + OnlineTable masterTable = onlineTableService.getOnlineTableFromCache(tableId); + ResponseResult responseResult = + this.buildWorkOrderMasterData(flowWorkOrderVoList, masterTable); + if (!responseResult.isSuccess()) { + return ResponseResult.errorFrom(responseResult); + } + responseResult = this.buildWorkOrderDraftData(flowWorkOrderVoList, masterTable); + if (!responseResult.isSuccess()) { + return ResponseResult.errorFrom(responseResult); + } + List unfinishedProcessInstanceIds = flowWorkOrderVoList.stream() + .filter(c -> !c.getFlowStatus().equals(FlowTaskStatus.FINISHED)) + .map(FlowWorkOrderVo::getProcessInstanceId) + .collect(Collectors.toList()); + if (CollUtil.isEmpty(unfinishedProcessInstanceIds)) { + return ResponseResult.success(); + } + Map> taskMap = + flowApiService.getTaskListByProcessInstanceIds(unfinishedProcessInstanceIds) + .stream().collect(Collectors.groupingBy(Task::getProcessInstanceId)); + for (FlowWorkOrderVo flowWorkOrderVo : flowWorkOrderVoList) { + List instanceTaskList = taskMap.get(flowWorkOrderVo.getProcessInstanceId()); + if (instanceTaskList != null) { + JSONArray taskArray = new JSONArray(); + for (Task task : instanceTaskList) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("taskId", task.getId()); + jsonObject.put("taskName", task.getName()); + jsonObject.put("taskKey", task.getTaskDefinitionKey()); + jsonObject.put("assignee", task.getAssignee()); + taskArray.add(jsonObject); + } + flowWorkOrderVo.setRuntimeTaskInfoList(taskArray); + } + } + return ResponseResult.success(); + } + + private ResponseResult buildWorkOrderDraftData( + List flowWorkOrderVoList, OnlineTable masterTable) { + List draftWorkOrderList = flowWorkOrderVoList.stream() + .filter(c -> c.getFlowStatus().equals(FlowTaskStatus.DRAFT)).collect(Collectors.toList()); + if (CollUtil.isEmpty(draftWorkOrderList)) { + return ResponseResult.success(); + } + Set workOrderIdSet = draftWorkOrderList.stream() + .map(FlowWorkOrderVo::getWorkOrderId).collect(Collectors.toSet()); + List workOrderExtList = + flowWorkOrderService.getFlowWorkOrderExtByWorkOrderIds(workOrderIdSet); + Map workOrderExtMap = workOrderExtList.stream() + .collect(Collectors.toMap(FlowWorkOrderExt::getWorkOrderId, c -> c)); + for (FlowWorkOrderVo workOrder : draftWorkOrderList) { + FlowWorkOrderExt workOrderExt = workOrderExtMap.get(workOrder.getWorkOrderId()); + if (workOrderExt == null) { + continue; + } + JSONObject draftData = JSON.parseObject(workOrderExt.getDraftData()); + JSONObject masterData = draftData.getJSONObject(FlowConstant.MASTER_DATA_KEY); + JSONObject slaveData = draftData.getJSONObject(FlowConstant.SLAVE_DATA_KEY); + OnlineDatasource datasource = + onlineDatasourceService.getOnlineDatasourceByMasterTableId(masterTable.getTableId()); + List slaveRelationList = null; + if (slaveData != null) { + ResponseResult> relationListResult = + onlineOperationHelper.verifyAndGetRelationList(datasource.getDatasourceId(), RelationType.ONE_TO_ONE); + if (!relationListResult.isSuccess()) { + return ResponseResult.errorFrom(relationListResult); + } + slaveRelationList = relationListResult.getData(); + } + datasource.setMasterTable(masterTable); + JSONObject jsonData = this.buildDraftData(datasource, masterData, slaveRelationList, slaveData); + JSONObject masterAndOneToOneData = jsonData.getJSONObject(datasource.getVariableName()); + if (MapUtil.isNotEmpty(masterAndOneToOneData)) { + List> dataList = new LinkedList<>(); + dataList.add(masterAndOneToOneData); + onlineOperationService.buildDataListWithDict(masterTable, slaveRelationList, dataList); + } + workOrder.setMasterData(masterAndOneToOneData); + } + return ResponseResult.success(); + } + + private ResponseResult buildWorkOrderMasterData( + List flowWorkOrderVoList, OnlineTable masterTable) { + Set businessKeySet = flowWorkOrderVoList.stream() + .map(FlowWorkOrderVo::getBusinessKey) + .filter(Objects::nonNull).collect(Collectors.toSet()); + if (CollUtil.isEmpty(businessKeySet)) { + return ResponseResult.success(); + } + Set convertedBusinessKeySet = + onlineOperationHelper.convertToTypeValue(masterTable.getPrimaryKeyColumn(), businessKeySet); + List filterList = new LinkedList<>(); + OnlineFilterDto filterDto = new OnlineFilterDto(); + filterDto.setTableName(masterTable.getTableName()); + filterDto.setColumnName(masterTable.getPrimaryKeyColumn().getColumnName()); + filterDto.setFilterType(FieldFilterType.IN_LIST_FILTER); + filterDto.setColumnValueList(new HashSet<>(convertedBusinessKeySet)); + filterList.add(filterDto); + TaskInfoVo taskInfoVo = JSON.parseObject(flowWorkOrderVoList.get(0).getInitTaskInfo(), TaskInfoVo.class); + // 验证在线表单及其关联数据源的合法性。 + ResponseResult datasourceResult = this.verifyAndGetOnlineDatasource(taskInfoVo.getFormId()); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + OnlineDatasource datasource = datasourceResult.getData(); + ResponseResult> relationListResult = + onlineOperationHelper.verifyAndGetRelationList(datasource.getDatasourceId(), RelationType.ONE_TO_ONE); + if (!relationListResult.isSuccess()) { + return ResponseResult.errorFrom(relationListResult); + } + MyPageData> pageData = onlineOperationService.getMasterDataList( + masterTable, relationListResult.getData(), null, filterList, null, null); + List> dataList = pageData.getDataList(); + Map> dataMap = dataList.stream() + .collect(Collectors.toMap(c -> c.get(masterTable.getPrimaryKeyColumn().getColumnName()).toString(), c -> c)); + for (FlowWorkOrderVo flowWorkOrderVo : flowWorkOrderVoList) { + if (StrUtil.isNotBlank(flowWorkOrderVo.getBusinessKey())) { + Object dataId = onlineOperationHelper.convertToTypeValue( + masterTable.getPrimaryKeyColumn(), flowWorkOrderVo.getBusinessKey()); + Map data = dataMap.get(dataId.toString()); + if (data != null) { + flowWorkOrderVo.setMasterData(data); + } + } + } + return ResponseResult.success(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/service/FlowOnlineOperationService.java b/OrangeFormsOpen-MybatisFlex/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/service/FlowOnlineOperationService.java new file mode 100644 index 00000000..79b7f412 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/service/FlowOnlineOperationService.java @@ -0,0 +1,136 @@ +package com.orangeforms.common.flow.online.service; + +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.online.model.OnlineDatasource; +import com.orangeforms.common.online.model.OnlineDatasourceRelation; +import com.orangeforms.common.online.model.OnlineTable; +import com.orangeforms.common.flow.model.FlowWorkOrder; +import com.orangeforms.common.flow.model.FlowTaskComment; +import org.flowable.task.api.Task; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 流程操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowOnlineOperationService { + + /** + * 保存在线表单的数据,同时启动流程。如果当前用户是第一个用户任务的Assignee, + * 或者第一个用户任务的Assignee是流程发起人变量,该方法还会自动Take第一个任务。 + * + * @param processDefinitionId 流程定义Id。 + * @param flowTaskComment 流程审批批注对象。 + * @param taskVariableData 流程任务的变量数据。 + * @param table 表对象。 + * @param data 表数据。 + */ + void saveNewAndStartProcess( + String processDefinitionId, + FlowTaskComment flowTaskComment, + JSONObject taskVariableData, + OnlineTable table, + JSONObject data); + + /** + * 保存在线表单的数据,同时启动流程。如果当前用户是第一个用户任务的Assignee, + * 或者第一个用户任务的Assignee是流程发起人变量,该方法还会自动Take第一个任务。 + * + * @param processDefinitionId 流程定义Id。 + * @param flowTaskComment 流程审批批注对象。 + * @param taskVariableData 流程任务的变量数据。 + * @param masterTable 主表对象。 + * @param masterData 主表数据。 + * @param slaveDataListMap 关联从表数据Map。 + */ + void saveNewAndStartProcess( + String processDefinitionId, + FlowTaskComment flowTaskComment, + JSONObject taskVariableData, + OnlineTable masterTable, + JSONObject masterData, + Map> slaveDataListMap); + + /** + * 保存在线表单的草稿数据,同时启动一个流程实例。 + * + * @param processDefinitionId 流程定义Id。 + * @param tableId 在线表单主表Id。 + * @param masterData 主表数据。 + * @param slaveData 所有关联从表数据。 + * @return 流程工单对象。 + */ + FlowWorkOrder saveNewDraftAndStartProcess( + String processDefinitionId, Long tableId, JSONObject masterData, JSONObject slaveData); + + /** + * 保存在线表单的数据,同时Take用户任务。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 流程任务Id。 + * @param flowTaskComment 流程审批批注对象。 + * @param taskVariableData 流程任务的变量数据。 + * @param table 表对象。 + * @param data 表数据。 + */ + void saveNewAndTakeTask( + String processInstanceId, + String taskId, + FlowTaskComment flowTaskComment, + JSONObject taskVariableData, + OnlineTable table, + JSONObject data); + + /** + * 保存在线表单的数据,同时Take用户任务。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 流程任务Id。 + * @param flowTaskComment 流程审批批注对象。 + * @param taskVariableData 流程任务的变量数据。 + * @param masterTable 主表对象。 + * @param masterData 主表数据。 + * @param slaveDataListMap 关联从表数据Map。 + */ + void saveNewAndTakeTask( + String processInstanceId, + String taskId, + FlowTaskComment flowTaskComment, + JSONObject taskVariableData, + OnlineTable masterTable, + JSONObject masterData, + Map> slaveDataListMap); + + /** + * 保存业务表数据,同时接收流程任务。 + * + * @param task 流程任务。 + * @param flowTaskComment 流程审批批注对象。 + * @param taskVariableData 流程任务的变量数据。 + * @param datasource 主表所在数据源。 + * @param masterData 主表数据。 + * @param masterDataId 主表数据主键。 + * @param slaveDataListMap 从表数据。 + */ + void updateAndTakeTask( + Task task, + FlowTaskComment flowTaskComment, + JSONObject taskVariableData, + OnlineDatasource datasource, + JSONObject masterData, + String masterDataId, + Map> slaveDataListMap); + + /** + * 获取在线表单工作流Id所关联的权限数据,包括权限字列表和权限资源列表。 + * + * @param onlineFormEntryIds 在线表单工作流Id集合。 + * @return 参数中在线表单工作流Id集合所关联的权限数据。 + */ + List> calculatePermData(Set onlineFormEntryIds); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/service/impl/FlowOnlineBusinessServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/service/impl/FlowOnlineBusinessServiceImpl.java new file mode 100644 index 00000000..c94dfbf2 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/service/impl/FlowOnlineBusinessServiceImpl.java @@ -0,0 +1,97 @@ +package com.orangeforms.common.flow.online.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; +import com.orangeforms.common.core.annotation.MyDataSource; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.flow.base.service.BaseFlowOnlineService; +import com.orangeforms.common.flow.model.FlowWorkOrder; +import com.orangeforms.common.flow.util.FlowCustomExtFactory; +import com.orangeforms.common.online.exception.OnlineRuntimeException; +import com.orangeforms.common.online.model.OnlineColumn; +import com.orangeforms.common.online.model.OnlineTable; +import com.orangeforms.common.online.model.OnlineDatasource; +import com.orangeforms.common.online.model.OnlineDatasourceRelation; +import com.orangeforms.common.online.model.constant.FieldKind; +import com.orangeforms.common.online.service.OnlineDatasourceRelationService; +import com.orangeforms.common.online.service.OnlineDatasourceService; +import com.orangeforms.common.online.service.OnlineOperationService; +import com.orangeforms.common.online.service.OnlineTableService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import jakarta.annotation.PostConstruct; +import java.util.List; + +/** + * 在线表单和流程监听器进行数据对接时的服务实现类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSource(ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("flowOnlineBusinessService") +public class FlowOnlineBusinessServiceImpl implements BaseFlowOnlineService { + + @Autowired + private FlowCustomExtFactory flowCustomExtFactory; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private OnlineDatasourceRelationService onlineDatasourceRelationService; + @Autowired + private OnlineOperationService onlineOperationService; + + @PostConstruct + public void doRegister() { + flowCustomExtFactory.getOnlineBusinessDataExtHelper().setOnlineBusinessService(this); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void updateFlowStatus(FlowWorkOrder workOrder) { + OnlineTable onlineTable = onlineTableService.getOnlineTableFromCache(workOrder.getOnlineTableId()); + if (onlineTable == null) { + log.error("OnlineTableId [{}] doesn't exist while calling FlowOnlineBusinessServiceImpl.updateFlowStatus", + workOrder.getOnlineTableId()); + return; + } + String dataId = workOrder.getBusinessKey(); + for (OnlineColumn column : onlineTable.getColumnMap().values()) { + if (ObjectUtil.equals(column.getFieldKind(), FieldKind.FLOW_FINISHED_STATUS)) { + onlineOperationService.updateColumn(onlineTable, dataId, column, workOrder.getFlowStatus()); + } + if (ObjectUtil.equals(column.getFieldKind(), FieldKind.FLOW_APPROVAL_STATUS)) { + onlineOperationService.updateColumn(onlineTable, dataId, column, workOrder.getLatestApprovalStatus()); + } + } + } + + @Override + public void deleteBusinessData(FlowWorkOrder workOrder) { + OnlineTable onlineTable = onlineTableService.getOnlineTableFromCache(workOrder.getOnlineTableId()); + if (onlineTable == null) { + log.error("OnlineTableId [{}] doesn't exist while calling FlowOnlineBusinessServiceImpl.deleteBusinessData", + workOrder.getOnlineTableId()); + return; + } + OnlineDatasource datasource = + onlineDatasourceService.getOnlineDatasourceByMasterTableId(onlineTable.getTableId()); + List relationList = + onlineDatasourceRelationService.getOnlineDatasourceRelationListFromCache(CollUtil.newHashSet(datasource.getDatasourceId())); + String dataId = workOrder.getBusinessKey(); + for (OnlineDatasourceRelation relation : relationList) { + OnlineTable slaveTable = onlineTableService.getOnlineTableFromCache(relation.getSlaveTableId()); + if (slaveTable == null) { + throw new OnlineRuntimeException("数据验证失败,数据源关联 [" + relation.getRelationName() + "] 的从表Id不存在!"); + } + relation.setSlaveTable(slaveTable); + } + onlineOperationService.delete(onlineTable, relationList, dataId); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/service/impl/FlowOnlineOperationServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/service/impl/FlowOnlineOperationServiceImpl.java new file mode 100644 index 00000000..f7ae1011 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/service/impl/FlowOnlineOperationServiceImpl.java @@ -0,0 +1,287 @@ +package com.orangeforms.common.flow.online.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.annotation.MyDataSource; +import com.orangeforms.common.core.annotation.MultiDatabaseWriteMethod; +import com.orangeforms.common.online.config.OnlineProperties; +import com.orangeforms.common.online.model.OnlineDatasource; +import com.orangeforms.common.online.model.OnlineDatasourceRelation; +import com.orangeforms.common.online.model.OnlineTable; +import com.orangeforms.common.online.service.OnlineDatasourceService; +import com.orangeforms.common.online.service.OnlineOperationService; +import com.orangeforms.common.flow.config.FlowProperties; +import com.orangeforms.common.flow.constant.FlowConstant; +import com.orangeforms.common.flow.constant.FlowApprovalType; +import com.orangeforms.common.flow.constant.FlowTaskStatus; +import com.orangeforms.common.flow.exception.FlowOperationException; +import com.orangeforms.common.flow.model.FlowEntry; +import com.orangeforms.common.flow.model.FlowWorkOrder; +import com.orangeforms.common.flow.model.FlowTaskComment; +import com.orangeforms.common.flow.service.FlowEntryService; +import com.orangeforms.common.flow.service.FlowApiService; +import com.orangeforms.common.flow.service.FlowWorkOrderService; +import com.orangeforms.common.flow.online.service.FlowOnlineOperationService; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.runtime.ProcessInstance; +import org.flowable.task.api.Task; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import java.util.stream.Collectors; + +@Slf4j +@MyDataSource(ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("flowOnlineOperationService") +public class FlowOnlineOperationServiceImpl implements FlowOnlineOperationService { + + @Autowired + private FlowApiService flowApiService; + @Autowired + private FlowWorkOrderService flowWorkOrderService; + @Autowired + private FlowEntryService flowEntryService; + @Autowired + private OnlineOperationService onlineOperationService; + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private OnlineProperties onlineProperties; + @Autowired + private FlowProperties flowProperties; + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNewAndStartProcess( + String processDefinitionId, + FlowTaskComment flowTaskComment, + JSONObject taskVariableData, + OnlineTable table, + JSONObject data) { + this.saveNewAndStartProcess(processDefinitionId, flowTaskComment, taskVariableData, table, data, null); + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNewAndStartProcess( + String processDefinitionId, + FlowTaskComment flowTaskComment, + JSONObject taskVariableData, + OnlineTable masterTable, + JSONObject masterData, + Map> slaveDataListMap) { + Object dataId = onlineOperationService.saveNewWithRelation(masterTable, masterData, slaveDataListMap); + Assert.notNull(dataId); + if (taskVariableData == null) { + taskVariableData = new JSONObject(); + } + taskVariableData.put(FlowConstant.MASTER_DATA_KEY, masterData); + taskVariableData.put(FlowConstant.SLAVE_DATA_KEY, this.normailizeSlaveDataListMap(slaveDataListMap)); + taskVariableData.put(FlowConstant.MASTER_TABLE_KEY, masterTable); + ProcessInstance instance = flowApiService.start(processDefinitionId, dataId); + flowWorkOrderService.saveNew(instance, dataId, masterTable.getTableId(), null); + flowApiService.takeFirstTask(instance.getProcessInstanceId(), flowTaskComment, taskVariableData); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public FlowWorkOrder saveNewDraftAndStartProcess( + String processDefinitionId, Long tableId, JSONObject masterData, JSONObject slaveData) { + ProcessInstance instance = flowApiService.start(processDefinitionId, null); + return flowWorkOrderService.saveNewWithDraft( + instance, tableId, null, JSON.toJSONString(masterData), JSON.toJSONString(slaveData)); + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNewAndTakeTask( + String processInstanceId, + String taskId, + FlowTaskComment flowTaskComment, + JSONObject taskVariableData, + OnlineTable table, + JSONObject data) { + this.saveNewAndTakeTask( + processInstanceId, taskId, flowTaskComment, taskVariableData, table, data, null); + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNewAndTakeTask( + String processInstanceId, + String taskId, + FlowTaskComment flowTaskComment, + JSONObject taskVariableData, + OnlineTable masterTable, + JSONObject masterData, + Map> slaveDataListMap) { + Object dataId = onlineOperationService.saveNewWithRelation(masterTable, masterData, slaveDataListMap); + Assert.notNull(dataId); + Task task = flowApiService.getProcessInstanceActiveTask(processInstanceId, taskId); + flowApiService.setBusinessKeyForProcessInstance(processInstanceId, dataId); + Map variables = + flowApiService.initAndGetProcessInstanceVariables(task.getProcessDefinitionId()); + if (taskVariableData == null) { + taskVariableData = new JSONObject(); + } + taskVariableData.putAll(variables); + taskVariableData.put(FlowConstant.MASTER_DATA_KEY, masterData); + taskVariableData.put(FlowConstant.SLAVE_DATA_KEY, this.normailizeSlaveDataListMap(slaveDataListMap)); + taskVariableData.put(FlowConstant.MASTER_TABLE_KEY, masterTable); + flowApiService.completeTask(task, flowTaskComment, taskVariableData); + ProcessInstance instance = flowApiService.getProcessInstance(processInstanceId); + FlowWorkOrder flowWorkOrder = + flowWorkOrderService.getFlowWorkOrderByProcessInstanceId(instance.getProcessInstanceId()); + if (flowWorkOrder == null) { + flowWorkOrderService.saveNew(instance, dataId, masterTable.getTableId(), null); + } else { + flowWorkOrder.setBusinessKey(dataId.toString()); + flowWorkOrder.setUpdateTime(new Date()); + flowWorkOrder.setFlowStatus(FlowTaskStatus.SUBMITTED); + flowWorkOrderService.updateById(flowWorkOrder); + } + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public void updateAndTakeTask( + Task task, + FlowTaskComment flowTaskComment, + JSONObject taskVariableData, + OnlineDatasource datasource, + JSONObject masterData, + String masterDataId, + Map> slaveDataListMap) { + int flowStatus = FlowTaskStatus.APPROVING; + if (flowTaskComment.getApprovalType().equals(FlowApprovalType.REFUSE)) { + flowStatus = FlowTaskStatus.REFUSED; + } else if (flowTaskComment.getApprovalType().equals(FlowApprovalType.STOP)) { + flowStatus = FlowTaskStatus.FINISHED; + } + OnlineTable masterTable = datasource.getMasterTable(); + Long datasourceId = datasource.getDatasourceId(); + flowWorkOrderService.updateFlowStatusByProcessInstanceId(task.getProcessInstanceId(), flowStatus); + this.updateMasterData(masterTable, masterData, masterDataId); + if (slaveDataListMap != null) { + for (Map.Entry> relationEntry : slaveDataListMap.entrySet()) { + Long relationId = relationEntry.getKey().getRelationId(); + onlineOperationService.updateRelationData( + masterTable, masterData, masterDataId, datasourceId, relationId, relationEntry.getValue()); + } + } + if (flowTaskComment.getApprovalType().equals(FlowApprovalType.STOP)) { + Integer s = MapUtil.getInt(taskVariableData, FlowConstant.LATEST_APPROVAL_STATUS_KEY); + flowWorkOrderService.updateLatestApprovalStatusByProcessInstanceId(task.getProcessInstanceId(), s); + CallResult stopResult = flowApiService.stopProcessInstance( + task.getProcessInstanceId(), flowTaskComment.getTaskComment(), flowStatus); + if (!stopResult.isSuccess()) { + throw new FlowOperationException(stopResult.getErrorMessage()); + } + } else { + if (taskVariableData == null) { + taskVariableData = new JSONObject(); + } + taskVariableData.put(FlowConstant.MASTER_DATA_KEY, masterData); + taskVariableData.put(FlowConstant.SLAVE_DATA_KEY, this.normailizeSlaveDataListMap(slaveDataListMap)); + taskVariableData.put(FlowConstant.MASTER_TABLE_KEY, masterTable); + flowApiService.completeTask(task, flowTaskComment, taskVariableData); + } + } + + @Override + public List> calculatePermData(Set onlineFormEntryIds) { + if (CollUtil.isEmpty(onlineFormEntryIds)) { + return new LinkedList<>(); + } + List> permDataList = new LinkedList<>(); + List flowEntries = flowEntryService.getInList(onlineFormEntryIds); + Set pageIds = flowEntries.stream().map(FlowEntry::getPageId).collect(Collectors.toSet()); + Map pageAndVariableNameMap = + onlineDatasourceService.getPageIdAndVariableNameMapByPageIds(pageIds); + for (FlowEntry flowEntry : flowEntries) { + JSONObject permData = new JSONObject(); + permData.put("entryId", flowEntry.getEntryId()); + String key = StrUtil.upperFirst(flowEntry.getProcessDefinitionKey()); + List permCodeList = new LinkedList<>(); + String formPermCode = "form" + key; + permCodeList.add(formPermCode); + permCodeList.add(formPermCode + ":fragment" + key); + permData.put("permCodeList", permCodeList); + String flowUrlPrefix = flowProperties.getUrlPrefix(); + String onlineUrlPrefix = onlineProperties.getUrlPrefix(); + List permList = CollUtil.newLinkedList( + onlineUrlPrefix + "/onlineForm/view", + onlineUrlPrefix + "/onlineForm/render", + onlineUrlPrefix + "/onlineOperation/listByOneToManyRelationId/" + pageAndVariableNameMap.get(flowEntry.getPageId()), + onlineUrlPrefix + "/onlineOperation/uploadByOneToManyRelationId/" + pageAndVariableNameMap.get(flowEntry.getPageId()), + onlineUrlPrefix + "/onlineOperation/dowloadByOneToManyRelationId/" + pageAndVariableNameMap.get(flowEntry.getPageId()), + flowUrlPrefix + "/flowOperation/viewInitialHistoricTaskInfo", + flowUrlPrefix + "/flowOperation/startOnly", + flowUrlPrefix + "/flowOperation/viewInitialTaskInfo", + flowUrlPrefix + "/flowOperation/viewRuntimeTaskInfo", + flowUrlPrefix + "/flowOperation/viewProcessBpmn", + flowUrlPrefix + "/flowOperation/viewHighlightFlowData", + flowUrlPrefix + "/flowOperation/listFlowTaskComment", + flowUrlPrefix + "/flowOperation/cancelWorkOrder", + flowUrlPrefix + "/flowOperation/listRuntimeTask", + flowUrlPrefix + "/flowOperation/listHistoricProcessInstance", + flowUrlPrefix + "/flowOperation/listHistoricTask", + flowUrlPrefix + "/flowOperation/freeJumpTo", + flowUrlPrefix + "/flowOnlineOperation/startPreview", + flowUrlPrefix + "/flowOnlineOperation/viewUserTask", + flowUrlPrefix + "/flowOnlineOperation/viewHistoricProcessInstance", + flowUrlPrefix + "/flowOnlineOperation/submitUserTask", + flowUrlPrefix + "/flowOnlineOperation/upload", + flowUrlPrefix + "/flowOnlineOperation/download", + flowUrlPrefix + "/flowOperation/submitConsign", + flowUrlPrefix + "/flowOnlineOperation/startAndTakeUserTask/" + flowEntry.getProcessDefinitionKey(), + flowUrlPrefix + "/flowOnlineOperation/startAndSaveDraft/" + flowEntry.getProcessDefinitionKey(), + flowUrlPrefix + "/flowOnlineOperation/listWorkOrder/" + flowEntry.getProcessDefinitionKey(), + flowUrlPrefix + "/flowOnlineOperation/printWorkOrder/" + flowEntry.getProcessDefinitionKey() + ); + permData.put("permList", permList); + permDataList.add(permData); + } + return permDataList; + } + + private void updateMasterData(OnlineTable masterTable, JSONObject masterData, String dataId) { + if (masterData == null) { + return; + } + // 如果存在主表数据,就执行主表数据的更新。 + Map originalMasterData = + onlineOperationService.getMasterData(masterTable, null, null, dataId); + for (Map.Entry entry : originalMasterData.entrySet()) { + masterData.putIfAbsent(entry.getKey(), entry.getValue()); + } + if (!onlineOperationService.update(masterTable, masterData)) { + throw new FlowOperationException("主表数据不存在!"); + } + } + + private Map> normailizeSlaveDataListMap( + Map> slaveDataListMap) { + if (slaveDataListMap == null || slaveDataListMap.isEmpty()) { + return null; + } + Map> resultMap = new HashMap<>(slaveDataListMap.size()); + for (Map.Entry> entry : slaveDataListMap.entrySet()) { + resultMap.put(entry.getKey().getSlaveTable().getTableName(), entry.getValue()); + } + return resultMap; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow-online/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/OrangeFormsOpen-MybatisFlex/common/common-flow-online/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..8ec96e36 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow-online/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.orangeforms.common.flow.online.config.FlowOnlineAutoConfig \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/pom.xml b/OrangeFormsOpen-MybatisFlex/common/common-flow/pom.xml new file mode 100644 index 00000000..daad1d91 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/pom.xml @@ -0,0 +1,49 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-flow + 1.0.0 + common-flow + jar + + + + com.orangeforms + common-satoken + 1.0.0 + + + com.orangeforms + common-datafilter + 1.0.0 + + + com.orangeforms + common-sequence + 1.0.0 + + + com.orangeforms + common-log + 1.0.0 + + + com.orangeforms + common-swagger + 1.0.0 + + + org.flowable + flowable-spring-boot-starter-process + ${flowable.version} + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/advice/FlowExceptionHandler.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/advice/FlowExceptionHandler.java new file mode 100644 index 00000000..b7ee7293 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/advice/FlowExceptionHandler.java @@ -0,0 +1,58 @@ +package com.orangeforms.common.flow.advice; + +import com.alibaba.fastjson.JSON; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.ResponseResult; +import com.orangeforms.common.core.util.ContextUtil; +import com.orangeforms.common.flow.exception.FlowEmptyUserException; +import com.orangeforms.common.flow.model.FlowTaskComment; +import com.orangeforms.common.flow.service.FlowTaskCommentService; +import lombok.extern.slf4j.Slf4j; +import org.flowable.common.engine.api.FlowableException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.annotation.Order; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +/** + * 流程业务层的异常处理类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Order(1) +@RestControllerAdvice("com.orangeforms") +public class FlowExceptionHandler { + + @Autowired + private FlowTaskCommentService flowTaskCommentService; + + @ExceptionHandler(value = FlowableException.class) + public ResponseResult exceptionHandle(FlowableException ex, HttpServletRequest request) { + if (ex instanceof FlowEmptyUserException) { + FlowEmptyUserException flowEmptyUserException = (FlowEmptyUserException) ex; + FlowTaskComment comment = JSON.parseObject(flowEmptyUserException.getMessage(), FlowTaskComment.class); + flowTaskCommentService.saveNew(comment); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, "下一个任务节点的审批人为空,提交被自动驳回!"); + } + log.error("Unhandled FlowException from URL [" + request.getRequestURI() + "]", ex); + ContextUtil.getHttpResponse().setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + return ResponseResult.error(ErrorCodeEnum.UNHANDLED_EXCEPTION, ex.getMessage()); + } + + @SuppressWarnings("unchecked") + private T findCause(Throwable ex, Class clazz) { + if (ex.getCause() == null) { + return null; + } + if (ex.getCause().getClass().equals(clazz)) { + return (T) ex.getCause(); + } else { + return this.findCause(ex.getCause(), clazz); + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/base/service/BaseFlowOnlineService.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/base/service/BaseFlowOnlineService.java new file mode 100644 index 00000000..c22362f9 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/base/service/BaseFlowOnlineService.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.flow.base.service; + +import com.orangeforms.common.flow.model.FlowWorkOrder; + +/** + * 工作流在线表单的服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface BaseFlowOnlineService { + + /** + * 更新在线表单主表数据的流程状态字段值。 + * + * @param workOrder 工单对象。 + */ + void updateFlowStatus(FlowWorkOrder workOrder); + + /** + * 根据工单对象级联删除业务数据。 + * + * @param workOrder 工单对象。 + */ + void deleteBusinessData(FlowWorkOrder workOrder); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/config/CustomEngineConfigurator.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/config/CustomEngineConfigurator.java new file mode 100644 index 00000000..bf9709a6 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/config/CustomEngineConfigurator.java @@ -0,0 +1,48 @@ +package com.orangeforms.common.flow.config; + +import com.orangeforms.common.core.config.DynamicDataSource; +import com.orangeforms.common.core.constant.ApplicationConstant; +import lombok.extern.slf4j.Slf4j; +import org.flowable.common.engine.impl.AbstractEngineConfiguration; +import org.flowable.common.engine.impl.EngineConfigurator; +import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; + +import javax.sql.DataSource; +import java.util.Map; + +/** + * 服务启动过程中动态切换flowable引擎内置表所在的数据源。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class CustomEngineConfigurator implements EngineConfigurator { + + @Override + public void beforeInit(AbstractEngineConfiguration engineConfiguration) { + DataSource dataSource = engineConfiguration.getDataSource(); + if (dataSource instanceof TransactionAwareDataSourceProxy) { + TransactionAwareDataSourceProxy proxy = (TransactionAwareDataSourceProxy) dataSource; + DataSource targetDataSource = proxy.getTargetDataSource(); + if (targetDataSource instanceof DynamicDataSource) { + DynamicDataSource dynamicDataSource = (DynamicDataSource) targetDataSource; + Map dynamicDataSourceMap = dynamicDataSource.getResolvedDataSources(); + DataSource flowDataSource = dynamicDataSourceMap.get(ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE); + if (flowDataSource != null) { + engineConfiguration.setDataSource(flowDataSource); + } + } + } + } + + @Override + public void configure(AbstractEngineConfiguration engineConfiguration) { + // 默认实现。 + } + + @Override + public int getPriority() { + return 0; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/config/FlowAutoConfig.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/config/FlowAutoConfig.java new file mode 100644 index 00000000..a6c7345a --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/config/FlowAutoConfig.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.flow.config; + +import org.springframework.boot.context.properties.EnableConfigurationProperties; + +/** + * common-flow模块的自动配置引导类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EnableConfigurationProperties({FlowProperties.class}) +public class FlowAutoConfig { +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/config/FlowProperties.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/config/FlowProperties.java new file mode 100644 index 00000000..3acf5347 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/config/FlowProperties.java @@ -0,0 +1,20 @@ +package com.orangeforms.common.flow.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * 工作流的配置对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ConfigurationProperties(prefix = "common-flow") +public class FlowProperties { + + /** + * 工作落工单操作接口的URL前缀。 + */ + private String urlPrefix; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowApprovalType.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowApprovalType.java new file mode 100644 index 00000000..aa4de82c --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowApprovalType.java @@ -0,0 +1,97 @@ +package com.orangeforms.common.flow.constant; + +/** + * 工作流任务触发BUTTON。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FlowApprovalType { + + /** + * 保存。 + */ + public static final String SAVE = "save"; + /** + * 同意。 + */ + public static final String AGREE = "agree"; + /** + * 拒绝。 + */ + public static final String REFUSE = "refuse"; + /** + * 驳回。 + */ + public static final String REJECT = "reject"; + /** + * 撤销。 + */ + public static final String REVOKE = "revoke"; + /** + * 指派。 + */ + public static final String TRANSFER = "transfer"; + /** + * 多实例会签。 + */ + public static final String MULTI_SIGN = "multi_sign"; + /** + * 会签同意。 + */ + public static final String MULTI_AGREE = "multi_agree"; + /** + * 会签拒绝。 + */ + public static final String MULTI_REFUSE = "multi_refuse"; + /** + * 会签弃权。 + */ + public static final String MULTI_ABSTAIN = "multi_abstain"; + /** + * 多实例加签。 + */ + public static final String MULTI_CONSIGN = "multi_consign"; + /** + * 多实例减签。 + */ + public static final String MULTI_MINUS_SIGN = "multi_minus_sign"; + /** + * 中止。 + */ + public static final String STOP = "stop"; + /** + * 干预。 + */ + public static final String INTERVENE = "intervene"; + /** + * 自由跳转。 + */ + public static final String FREE_JUMP = "free_jump"; + /** + * 流程复活。 + */ + public static final String REUSED = "reused"; + /** + * 流程复活。 + */ + public static final String REVIVE = "revive"; + /** + * 超时自动审批。 + */ + public static final String TIMEOUT_AUTO_COMPLETE = "timeout_auto_complete"; + /** + * 空审批人自动审批。 + */ + public static final String EMPTY_USER_AUTO_COMPLETE = "empty_user_auto_complete"; + /** + * 空审批人自动退回。 + */ + public static final String EMPTY_USER_AUTO_REJECT = "empty_user_auto_reject"; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowApprovalType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowBackType.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowBackType.java new file mode 100644 index 00000000..495831b8 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowBackType.java @@ -0,0 +1,25 @@ +package com.orangeforms.common.flow.constant; + +/** + * 待办任务回退类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FlowBackType { + + /** + * 驳回。 + */ + public static final int REJECT = 0; + /** + * 撤回。 + */ + public static final int REVOKE = 1; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowBackType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowBuiltinApprovalStatus.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowBuiltinApprovalStatus.java new file mode 100644 index 00000000..cdb89485 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowBuiltinApprovalStatus.java @@ -0,0 +1,33 @@ +package com.orangeforms.common.flow.constant; + +/** + * 内置的流程审批状态。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class FlowBuiltinApprovalStatus { + + /** + * 同意。 + */ + public static final int AGREED = 1; + /** + * 拒绝。 + */ + public static final int REFUSED = 2; + /** + * 会签同意。 + */ + public static final int MULTI_AGREED = 3; + /** + * 会签拒绝。 + */ + public static final int MULTI_REFUSED = 4; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowBuiltinApprovalStatus() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowConstant.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowConstant.java new file mode 100644 index 00000000..12ccf122 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowConstant.java @@ -0,0 +1,266 @@ +package com.orangeforms.common.flow.constant; + +/** + * 工作流中的常量数据。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class FlowConstant { + + /** + * 标识流程实例启动用户的变量名。 + */ + public static final String START_USER_NAME_VAR = "${startUserName}"; + + /** + * 流程实例发起人变量名。 + */ + public static final String PROC_INSTANCE_INITIATOR_VAR = "initiator"; + + /** + * 流程实例中发起人用户的变量名。 + */ + public static final String PROC_INSTANCE_START_USER_NAME_VAR = "startUserName"; + + /** + * 流程任务的指定人变量。 + */ + public static final String TASK_APPOINTED_ASSIGNEE_VAR = "appointedAssignee"; + + /** + * 操作类型变量。 + */ + public static final String OPERATION_TYPE_VAR = "operationType"; + + /** + * 提交用户。 + */ + public static final String SUBMIT_USER_VAR = "submitUser"; + + /** + * 多任务拒绝数量变量。 + */ + public static final String MULTI_REFUSE_COUNT_VAR = "multiRefuseCount"; + + /** + * 多任务同意数量变量。 + */ + public static final String MULTI_AGREE_COUNT_VAR = "multiAgreeCount"; + + /** + * 多任务弃权数量变量。 + */ + public static final String MULTI_ABSTAIN_COUNT_VAR = "multiAbstainCount"; + + /** + * 会签发起任务。 + */ + public static final String MULTI_SIGN_START_TASK_VAR = "multiSignStartTask"; + + /** + * 会签任务总数量。 + */ + public static final String MULTI_SIGN_NUM_OF_INSTANCES_VAR = "multiNumOfInstances"; + + /** + * 会签任务执行的批次Id。 + */ + public static final String MULTI_SIGN_TASK_EXECUTION_ID_VAR = "taskExecutionId"; + + /** + * 多实例实例数量变量。 + */ + public static final String NUMBER_OF_INSTANCES_VAR = "nrOfInstances"; + + /** + * 多实例已完成实例数量变量。 + */ + public static final String NUMBER_OF_COMPLETED_INSTANCES_VAR = "nrOfCompletedInstances"; + + /** + * 多任务指派人列表变量。 + */ + public static final String MULTI_ASSIGNEE_LIST_VAR = "assigneeList"; + + /** + * 上级部门领导审批变量。 + */ + public static final String GROUP_TYPE_UP_DEPT_POST_LEADER_VAR = "upDeptPostLeader"; + + /** + * 本部门领导审批变量。 + */ + public static final String GROUP_TYPE_DEPT_POST_LEADER_VAR = "deptPostLeader"; + + /** + * 所有部门岗位审批变量。 + */ + public static final String GROUP_TYPE_ALL_DEPT_POST_VAR = "allDeptPost"; + + /** + * 本部门岗位审批变量。 + */ + public static final String GROUP_TYPE_SELF_DEPT_POST_VAR = "selfDeptPost"; + + /** + * 同级部门岗位审批变量。 + */ + public static final String GROUP_TYPE_SIBLING_DEPT_POST_VAR = "siblingDeptPost"; + + /** + * 上级部门岗位审批变量。 + */ + public static final String GROUP_TYPE_UP_DEPT_POST_VAR = "upDeptPost"; + + /** + * 任意部门关联的岗位审批变量。 + */ + public static final String GROUP_TYPE_DEPT_POST_VAR = "deptPost"; + + /** + * 指定角色分组变量。 + */ + public static final String GROUP_TYPE_ROLE_VAR = "role"; + + /** + * 指定部门分组变量。 + */ + public static final String GROUP_TYPE_DEPT_VAR = "dept"; + + /** + * 指定用户分组变量。 + */ + public static final String GROUP_TYPE_USER_VAR = "user"; + + /** + * 指定审批人。 + */ + public static final String GROUP_TYPE_ASSIGNEE = "ASSIGNEE"; + + /** + * 岗位。 + */ + public static final String GROUP_TYPE_POST = "POST"; + + /** + * 上级部门领导审批。 + */ + public static final String GROUP_TYPE_UP_DEPT_POST_LEADER = "UP_DEPT_POST_LEADER"; + + /** + * 本部门岗位领导审批。 + */ + public static final String GROUP_TYPE_DEPT_POST_LEADER = "DEPT_POST_LEADER"; + + /** + * 本部门岗位前缀。 + */ + public static final String SELF_DEPT_POST_PREFIX = "SELF_DEPT_"; + + /** + * 上级部门岗位前缀。 + */ + public static final String UP_DEPT_POST_PREFIX = "UP_DEPT_"; + + /** + * 同级部门岗位前缀。 + */ + public static final String SIBLING_DEPT_POST_PREFIX = "SIBLING_DEPT_"; + + /** + * 当前流程实例所有任务的抄送数据前缀。 + */ + public static final String COPY_DATA_MAP_PREFIX = "copyDataMap_"; + + /** + * 作为临时变量存入任务变量JSONObject对象时的key。 + */ + public static final String COPY_DATA_KEY = "copyDataKey"; + + /** + * 流程中业务快照数据中,主表数据的Key。 + */ + public static final String MASTER_DATA_KEY = "masterData"; + + /** + * 流程中业务快照数据中,关联从表数据的Key。 + */ + public static final String SLAVE_DATA_KEY = "slaveData"; + + /** + * 流程任务的最近更新状态的Key。 + */ + public static final String LATEST_APPROVAL_STATUS_KEY = "latestApprovalStatus"; + + /** + * 流程用户任务待办之前的通知类型的Key。 + */ + public static final String USER_TASK_NOTIFY_TYPES_KEY = "flowNotifyTypeList"; + + /** + * 流程用户任务自动跳过类型的Key。 + */ + public static final String USER_TASK_AUTO_SKIP_KEY = "autoSkipType"; + + /** + * 流程用户任务驳回类型的Key。 + */ + public static final String USER_TASK_REJECT_TYPE_KEY = "rejectType"; + + /** + * 驳回时携带的变量数据。 + */ + public static final String REJECT_TO_SOURCE_DATA_VAR = "rejectData"; + + /** + * 驳回时携带的变量数据。 + */ + public static final String REJECT_BACK_TO_SOURCE_DATA_VAR = "rejectBackData"; + + /** + * 指定审批人。 + */ + public static final String DELEGATE_ASSIGNEE_VAR = "defaultAssignee"; + + /** + * 业务主表对象的键。目前仅仅用户在线表单工作流。 + */ + public static final String MASTER_TABLE_KEY = "masterTable"; + + /** + * 不删除任务超时作业。 + */ + public static final String NOT_DELETE_TIMEOUT_TASK_JOB_KEY = "notDeleteTimeoutTaskJob"; + + /** + * 用户任务超时小时数。 + */ + public static final String TASK_TIMEOUT_HOURS = "timeoutHours"; + + /** + * 用户任务超时处理方式。 + */ + public static final String TASK_TIMEOUT_HANDLE_WAY = "timeoutHandleWay"; + + /** + * 用户任务超时指定审批人。 + */ + public static final String TASK_TIMEOUT_DEFAULT_ASSIGNEE = "defaultAssignee"; + + /** + * 空处理人处理方式。 + */ + public static final String EMPTY_USER_HANDLE_WAY = "emptyUserHandleWay"; + + /** + * 空处理人时指定的审批人。 + */ + public static final String EMPTY_USER_TO_ASSIGNEE = "emptyUserToAssignee"; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowConstant() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowTaskStatus.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowTaskStatus.java new file mode 100644 index 00000000..d25ec6e4 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowTaskStatus.java @@ -0,0 +1,49 @@ +package com.orangeforms.common.flow.constant; + +/** + * 工作流任务类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FlowTaskStatus { + + /** + * 已提交。 + */ + public static final int SUBMITTED = 0; + /** + * 审批中。 + */ + public static final int APPROVING = 1; + /** + * 被拒绝。 + */ + public static final int REFUSED = 2; + /** + * 已结束。 + */ + public static final int FINISHED = 3; + /** + * 提前停止。 + */ + public static final Integer STOPPED = 4; + /** + * 已取消。 + */ + public static final Integer CANCELLED = 5; + /** + * 保存草稿。 + */ + public static final Integer DRAFT = 6; + /** + * 流程复活。 + */ + public static final Integer REVIVE = 7; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowTaskStatus() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowTaskType.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowTaskType.java new file mode 100644 index 00000000..8d97ba9b --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowTaskType.java @@ -0,0 +1,25 @@ +package com.orangeforms.common.flow.constant; + +/** + * 工作流任务类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FlowTaskType { + + /** + * 其他类型任务。 + */ + public static final int OTHER_TYPE = 0; + /** + * 用户任务。 + */ + public static final int USER_TYPE = 1; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowTaskType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowCategoryController.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowCategoryController.java new file mode 100644 index 00000000..95558d08 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowCategoryController.java @@ -0,0 +1,232 @@ +package com.orangeforms.common.flow.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.flow.dto.*; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.flow.model.constant.FlowEntryStatus; +import com.orangeforms.common.flow.service.*; +import com.orangeforms.common.flow.vo.*; +import lombok.extern.slf4j.Slf4j; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +/** + * 工作流流程分类接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "工作流流程分类接口") +@Slf4j +@RestController +@RequestMapping("${common-flow.urlPrefix}/flowCategory") +@ConditionalOnProperty(name = "common-flow.operationEnabled", havingValue = "true") +public class FlowCategoryController { + + @Autowired + private FlowCategoryService flowCategoryService; + @Autowired + private FlowEntryService flowEntryService; + + /** + * 新增FlowCategory数据。 + * + * @param flowCategoryDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"flowCategoryDto.categoryId"}) + @SaCheckPermission("flowCategory.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody FlowCategoryDto flowCategoryDto) { + String errorMessage = MyCommonUtil.getModelValidationError(flowCategoryDto); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + FlowCategory flowCategory = MyModelUtil.copyTo(flowCategoryDto, FlowCategory.class); + if (flowCategoryService.existByCode(flowCategory.getCode())) { + return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, "数据验证失败,当前流程分类已经存在!"); + } + flowCategory = flowCategoryService.saveNew(flowCategory); + return ResponseResult.success(flowCategory.getCategoryId()); + } + + /** + * 更新FlowCategory数据。 + * + * @param flowCategoryDto 更新对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("flowCategory.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody FlowCategoryDto flowCategoryDto) { + String errorMessage = MyCommonUtil.getModelValidationError(flowCategoryDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + FlowCategory flowCategory = MyModelUtil.copyTo(flowCategoryDto, FlowCategory.class); + ResponseResult verifyResult = this.doVerifyAndGet(flowCategory.getCategoryId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + FlowCategory originalFlowCategory = verifyResult.getData(); + if (!StrUtil.equals(flowCategory.getCode(), originalFlowCategory.getCode())) { + FlowEntry filter = new FlowEntry(); + filter.setCategoryId(flowCategory.getCategoryId()); + filter.setStatus(FlowEntryStatus.PUBLISHED); + List flowEntryList = flowEntryService.getListByFilter(filter); + if (CollUtil.isNotEmpty(flowEntryList)) { + errorMessage = "数据验证失败,当前流程分类存在已经发布的流程数据,因此分类标识不能修改!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (flowCategoryService.existByCode(flowCategory.getCode())) { + errorMessage = "数据验证失败,当前流程分类已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage); + } + } + if (!flowCategoryService.update(flowCategory, originalFlowCategory)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 删除FlowCategory数据。 + * + * @param categoryId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("flowCategory.all") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long categoryId) { + String errorMessage; + ResponseResult verifyResult = this.doVerifyAndGet(categoryId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + FlowEntry filter = new FlowEntry(); + filter.setCategoryId(categoryId); + List flowEntryList = flowEntryService.getListByFilter(filter); + if (CollUtil.isNotEmpty(flowEntryList)) { + errorMessage = "数据验证失败,请先删除当前流程分类关联的流程数据!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!flowCategoryService.remove(categoryId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的FlowCategory列表。 + * + * @param flowCategoryDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("flowCategory.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody FlowCategoryDto flowCategoryDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + FlowCategory flowCategoryFilter = MyModelUtil.copyTo(flowCategoryDtoFilter, FlowCategory.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, FlowCategory.class); + List flowCategoryList = flowCategoryService.getFlowCategoryListWithRelation(flowCategoryFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(flowCategoryList, FlowCategoryVo.class)); + } + + /** + * 查看指定FlowCategory对象详情。 + * + * @param categoryId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("flowCategory.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long categoryId) { + ResponseResult verifyResult = this.doVerifyAndGet(categoryId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + return ResponseResult.success(verifyResult.getData(), FlowCategoryVo.class); + } + + /** + * 以字典形式返回全部FlowCategory数据集合。字典的键值为[categoryId, name]。 + * 白名单接口,登录用户均可访问。 + * + * @param filter 过滤对象。 + * @return 应答结果对象,包含的数据为 List>,map中包含两条记录,key的值分别是id和name,value对应具体数据。 + */ + @GetMapping("/listDict") + public ResponseResult>> listDict(@ParameterObject FlowCategoryDto filter) { + List resultList = + flowCategoryService.getFlowCategoryList(MyModelUtil.copyTo(filter, FlowCategory.class), null); + return ResponseResult.success( + MyCommonUtil.toDictDataList(resultList, FlowCategory::getCategoryId, FlowCategory::getName)); + } + + /** + * 根据字典Id集合,获取查询后的字典数据。 + * + * @param dictIds 字典Id集合。 + * @return 应答结果对象,包含字典形式的数据集合。 + */ + @GetMapping("/listDictByIds") + public ResponseResult>> listDictByIds(@RequestParam List dictIds) { + List resultList = flowCategoryService.getInList(new HashSet<>(dictIds)); + return ResponseResult.success( + MyCommonUtil.toDictDataList(resultList, FlowCategory::getCategoryId, FlowCategory::getName)); + } + + private ResponseResult doVerifyAndGet(Long categoryId) { + String errorMessage; + if (MyCommonUtil.existBlankArgument(categoryId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + FlowCategory flowCategory = flowCategoryService.getById(categoryId); + if (flowCategory == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + TokenData tokenData = TokenData.takeFromRequest(); + if (!StrUtil.equals(flowCategory.getAppCode(), tokenData.getAppCode())) { + errorMessage = "数据验证失败,当前应用并不存在该流程分类的定义!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (ObjectUtil.notEqual(flowCategory.getTenantId(), tokenData.getTenantId())) { + errorMessage = "数据验证失败,当前租户并不存在该流程分类的定义!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(flowCategory); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowEntryController.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowEntryController.java new file mode 100644 index 00000000..855e59de --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowEntryController.java @@ -0,0 +1,475 @@ +package com.orangeforms.common.flow.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.flow.constant.FlowTaskType; +import com.orangeforms.common.flow.dto.*; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.flow.model.constant.FlowEntryStatus; +import com.orangeforms.common.flow.service.*; +import com.orangeforms.common.flow.vo.*; +import lombok.extern.slf4j.Slf4j; +import org.flowable.bpmn.model.*; +import org.flowable.bpmn.model.Process; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import javax.xml.stream.XMLStreamException; +import java.util.*; + +/** + * 工作流流程定义接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "工作流流程定义接口") +@Slf4j +@RestController +@RequestMapping("${common-flow.urlPrefix}/flowEntry") +@ConditionalOnProperty(name = "common-flow.operationEnabled", havingValue = "true") +public class FlowEntryController { + + @Autowired + private FlowEntryService flowEntryService; + @Autowired + private FlowCategoryService flowCategoryService; + @Autowired + private FlowEntryVariableService flowEntryVariableService; + @Autowired + private FlowApiService flowApiService; + @Autowired + private FlowTaskExtService flowTaskExtService; + + /** + * 新增工作流对象数据。 + * + * @param flowEntryDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"flowEntryDto.entryId"}) + @SaCheckPermission("flowEntry.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody FlowEntryDto flowEntryDto) { + String errorMessage = MyCommonUtil.getModelValidationError(flowEntryDto); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + FlowEntry flowEntry = MyModelUtil.copyTo(flowEntryDto, FlowEntry.class); + if (flowEntryService.existByProcessDefinitionKey(flowEntry.getProcessDefinitionKey())) { + errorMessage = "数据验证失败,该流程定义标识已存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + // 验证关联Id的数据合法性 + CallResult callResult = flowEntryService.verifyRelatedData(flowEntry, null); + if (!callResult.isSuccess()) { + errorMessage = callResult.getErrorMessage(); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + flowEntry = flowEntryService.saveNew(flowEntry); + return ResponseResult.success(flowEntry.getEntryId()); + } + + /** + * 更新工作流对象数据。 + * + * @param flowEntryDto 更新对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("flowEntry.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody FlowEntryDto flowEntryDto) { + String errorMessage = MyCommonUtil.getModelValidationError(flowEntryDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + FlowEntry flowEntry = MyModelUtil.copyTo(flowEntryDto, FlowEntry.class); + ResponseResult verifyResult = this.doVerifyAndGet(flowEntry.getEntryId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + FlowEntry originalFlowEntry = verifyResult.getData(); + if (ObjectUtil.notEqual(flowEntry.getProcessDefinitionKey(), originalFlowEntry.getProcessDefinitionKey())) { + if (originalFlowEntry.getStatus().equals(FlowEntryStatus.PUBLISHED)) { + errorMessage = "数据验证失败,当前流程为发布状态,流程标识不能修改!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (flowEntryService.existByProcessDefinitionKey(flowEntry.getProcessDefinitionKey())) { + errorMessage = "数据验证失败,该流程定义标识已存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + // 验证关联Id的数据合法性 + CallResult callResult = flowEntryService.verifyRelatedData(flowEntry, originalFlowEntry); + if (!callResult.isSuccess()) { + errorMessage = callResult.getErrorMessage(); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!flowEntryService.update(flowEntry, originalFlowEntry)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 删除工作流对象数据。 + * + * @param entryId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("flowEntry.all") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long entryId) { + String errorMessage; + if (MyCommonUtil.existBlankArgument(entryId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + ResponseResult verifyResult = this.doVerifyAndGet(entryId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + FlowEntry originalFlowEntry = verifyResult.getData(); + if (originalFlowEntry.getStatus().equals(FlowEntryStatus.PUBLISHED)) { + errorMessage = "数据验证失败,当前流程为发布状态,不能删除!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!flowEntryService.remove(entryId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 发布工作流。 + * + * @param entryId 流程主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("flowEntry.all") + @OperationLog(type = SysOperationLogType.PUBLISH) + @PostMapping("/publish") + public ResponseResult publish(@MyRequestBody(required = true) Long entryId) throws XMLStreamException { + String errorMessage; + ResponseResult verifyResult = this.doVerifyAndGet(entryId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + FlowEntry flowEntry = verifyResult.getData(); + if (StrUtil.isBlank(flowEntry.getBpmnXml())) { + errorMessage = "数据验证失败,该流程没有流程图不能被发布!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + ResponseResult taskInfoResult = this.verifyAndGetInitialTaskInfo(flowEntry); + if (!taskInfoResult.isSuccess()) { + return ResponseResult.errorFrom(taskInfoResult); + } + String taskInfo = taskInfoResult.getData() == null ? null : JSON.toJSONString(taskInfoResult.getData()); + flowEntryService.publish(flowEntry, taskInfo); + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的工作流列表。 + * + * @param flowEntryDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("flowEntry.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody FlowEntryDto flowEntryDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + FlowEntry flowEntryFilter = MyModelUtil.copyTo(flowEntryDtoFilter, FlowEntry.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, FlowEntry.class); + List flowEntryList = flowEntryService.getFlowEntryListWithRelation(flowEntryFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(flowEntryList, FlowEntryVo.class)); + } + + /** + * 查看指定工作流对象详情。 + * + * @param entryId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("flowEntry.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long entryId) { + ResponseResult verifyResult = this.doVerifyAndGet(entryId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + FlowEntry flowEntry = flowEntryService.getByIdWithRelation(entryId, MyRelationParam.full()); + if (flowEntry == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(flowEntry, FlowEntryVo.class); + } + + /** + * 列出指定流程的发布版本列表。 + * + * @param entryId 流程主键Id。 + * @return 应答结果对象,包含流程发布列表数据。 + */ + @SaCheckPermission("flowEntry.all") + @GetMapping("/listFlowEntryPublish") + public ResponseResult> listFlowEntryPublish(@RequestParam Long entryId) { + ResponseResult verifyResult = this.doVerifyAndGet(entryId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + List flowEntryPublishList = flowEntryService.getFlowEntryPublishList(entryId); + return ResponseResult.success(MyModelUtil.copyCollectionTo(flowEntryPublishList, FlowEntryPublishVo.class)); + } + + /** + * 以字典形式返回全部FlowEntry数据集合。字典的键值为[entryId, procDefinitionName]。 + * 白名单接口,登录用户均可访问。 + * + * @param filter 过滤对象。 + * @return 应答结果对象,包含的数据为 List>,map中包含两条记录,key的值分别是id和name,value对应具体数据。 + */ + @GetMapping("/listDict") + public ResponseResult>> listDict(@ParameterObject FlowEntryDto filter) { + List resultList = + flowEntryService.getFlowEntryList(MyModelUtil.copyTo(filter, FlowEntry.class), null); + return ResponseResult.success( + MyCommonUtil.toDictDataList(resultList, FlowEntry::getEntryId, FlowEntry::getProcessDefinitionName)); + } + + /** + * 获取所有流程分类和流程定义的列表。白名单接口。 + * + * @return 所有流程分类和流程定义的列表 + */ + @GetMapping("/listAll") + public ResponseResult listAll() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("flowEntryList", flowEntryService.getFlowEntryList(null, null)); + jsonObject.put("flowCategoryList", flowCategoryService.getFlowCategoryList(null, null)); + return ResponseResult.success(jsonObject); + } + + /** + * 白名单接口,根据流程Id,获取流程引擎需要的流程标识和流程名称。 + * + * @param entryId 流程Id。 + * @return 流程的部分数据。 + */ + @GetMapping("/viewDict") + public ResponseResult> viewDict(@RequestParam Long entryId) { + ResponseResult verifyResult = this.doVerifyAndGet(entryId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + FlowEntry flowEntry = verifyResult.getData(); + Map resultMap = new HashMap<>(2); + resultMap.put("processDefinitionKey", flowEntry.getProcessDefinitionKey()); + resultMap.put("processDefinitionName", flowEntry.getProcessDefinitionName()); + return ResponseResult.success(resultMap); + } + + /** + * 切换指定工作的发布主版本。 + * + * @param entryId 工作流主键Id。 + * @param newEntryPublishId 新的工作流发布主版本对象的主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("flowEntry.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/updateMainVersion") + public ResponseResult updateMainVersion( + @MyRequestBody(required = true) Long entryId, + @MyRequestBody(required = true) Long newEntryPublishId) { + String errorMessage; + ResponseResult verifyResult = this.doVerifyAndGet(entryId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + FlowEntryPublish flowEntryPublish = flowEntryService.getFlowEntryPublishFromCache(newEntryPublishId); + if (flowEntryPublish == null) { + errorMessage = "数据验证失败,当前流程发布版本并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (ObjectUtil.notEqual(entryId, flowEntryPublish.getEntryId())) { + errorMessage = "数据验证失败,当前工作流并不包含该工作流发布版本数据,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (BooleanUtil.isTrue(flowEntryPublish.getMainVersion())) { + errorMessage = "数据验证失败,该版本已经为当前工作流的发布主版本,不能重复设置!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + flowEntryService.updateFlowEntryMainVersion(flowEntryService.getById(entryId), flowEntryPublish); + return ResponseResult.success(); + } + + /** + * 挂起工作流的指定发布版本。 + * + * @param entryPublishId 工作发布Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("flowEntry.all") + @OperationLog(type = SysOperationLogType.SUSPEND) + @PostMapping("/suspendFlowEntryPublish") + public ResponseResult suspendFlowEntryPublish(@MyRequestBody(required = true) Long entryPublishId) { + String errorMessage; + FlowEntryPublish flowEntryPublish = flowEntryService.getFlowEntryPublishFromCache(entryPublishId); + if (flowEntryPublish == null) { + errorMessage = "数据验证失败,当前流程发布版本并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + ResponseResult verifyResult = this.doVerifyAndGet(flowEntryPublish.getEntryId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (BooleanUtil.isFalse(flowEntryPublish.getActiveStatus())) { + errorMessage = "数据验证失败,当前流程发布版本已处于挂起状态!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + flowEntryService.suspendFlowEntryPublish(flowEntryPublish); + return ResponseResult.success(); + } + + /** + * 激活工作流的指定发布版本。 + * + * @param entryPublishId 工作发布Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("flowEntry.all") + @OperationLog(type = SysOperationLogType.RESUME) + @PostMapping("/activateFlowEntryPublish") + public ResponseResult activateFlowEntryPublish(@MyRequestBody(required = true) Long entryPublishId) { + String errorMessage; + FlowEntryPublish flowEntryPublish = flowEntryService.getFlowEntryPublishFromCache(entryPublishId); + if (flowEntryPublish == null) { + errorMessage = "数据验证失败,当前流程发布版本并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + ResponseResult verifyResult = this.doVerifyAndGet(flowEntryPublish.getEntryId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (BooleanUtil.isTrue(flowEntryPublish.getActiveStatus())) { + errorMessage = "数据验证失败,当前流程发布版本已处于激活状态!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + flowEntryService.activateFlowEntryPublish(flowEntryPublish); + return ResponseResult.success(); + } + + private ResponseResult doVerifyAndGet(Long entryId) { + String errorMessage; + if (MyCommonUtil.existBlankArgument(entryId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + FlowEntry flowEntry = flowEntryService.getById(entryId); + if (flowEntry == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + TokenData tokenData = TokenData.takeFromRequest(); + if (!StrUtil.equals(flowEntry.getAppCode(), tokenData.getAppCode())) { + errorMessage = "数据验证失败,当前应用并不存在该流程定义!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (ObjectUtil.notEqual(flowEntry.getTenantId(), tokenData.getTenantId())) { + errorMessage = "数据验证失败,当前租户并不存在该流程定义!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(flowEntry); + } + + private ResponseResult verifyAndGetInitialTaskInfo(FlowEntry flowEntry) throws XMLStreamException { + String errorMessage; + BpmnModel bpmnModel = flowApiService.convertToBpmnModel(flowEntry.getBpmnXml()); + Process process = bpmnModel.getMainProcess(); + if (process == null) { + errorMessage = "数据验证失败,当前流程标识 [" + flowEntry.getProcessDefinitionKey() + "] 关联的流程模型并不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + Collection elementList = process.getFlowElements(); + FlowElement startEvent = null; + // 这里我们只定位流程模型中的第二个节点。 + for (FlowElement flowElement : elementList) { + if (flowElement instanceof StartEvent) { + startEvent = flowElement; + break; + } + } + if (startEvent == null) { + errorMessage = "数据验证失败,当前流程图没有包含 [开始事件] 节点,请修改流程图!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + FlowElement firstTask = this.findFirstTask(elementList, startEvent); + if (firstTask == null) { + errorMessage = "数据验证失败,当前流程图没有包含 [开始事件] 节点没有任何连线,请修改流程图!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + TaskInfoVo taskInfoVo; + if (firstTask instanceof UserTask) { + UserTask userTask = (UserTask) firstTask; + String formKey = userTask.getFormKey(); + if (StrUtil.isNotBlank(formKey)) { + taskInfoVo = JSON.parseObject(formKey, TaskInfoVo.class); + } else { + taskInfoVo = new TaskInfoVo(); + } + taskInfoVo.setAssignee(userTask.getAssignee()); + taskInfoVo.setTaskKey(userTask.getId()); + taskInfoVo.setTaskType(FlowTaskType.USER_TYPE); + Map> extensionMap = userTask.getExtensionElements(); + if (MapUtil.isNotEmpty(extensionMap)) { + taskInfoVo.setOperationList(flowTaskExtService.buildOperationListExtensionElement(extensionMap)); + taskInfoVo.setVariableList(flowTaskExtService.buildVariableListExtensionElement(extensionMap)); + } + } else { + taskInfoVo = new TaskInfoVo(); + taskInfoVo.setTaskType(FlowTaskType.OTHER_TYPE); + } + return ResponseResult.success(taskInfoVo); + } + + private FlowElement findFirstTask(Collection elementList, FlowElement startEvent) { + for (FlowElement flowElement : elementList) { + if (flowElement instanceof SequenceFlow) { + SequenceFlow sequenceFlow = (SequenceFlow) flowElement; + if (sequenceFlow.getSourceFlowElement().equals(startEvent)) { + return sequenceFlow.getTargetFlowElement(); + } + } + } + return null; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowEntryVariableController.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowEntryVariableController.java new file mode 100644 index 00000000..371d37cc --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowEntryVariableController.java @@ -0,0 +1,159 @@ +package com.orangeforms.common.flow.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.common.flow.vo.*; +import com.orangeforms.common.flow.dto.*; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.flow.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.core.validator.UpdateGroup; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; + +import java.util.*; +import jakarta.validation.groups.Default; + +/** + * 工作流流程变量接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "工作流流程变量接口") +@Slf4j +@RestController +@RequestMapping("${common-flow.urlPrefix}/flowEntryVariable") +@ConditionalOnProperty(name = "common-flow.operationEnabled", havingValue = "true") +public class FlowEntryVariableController { + + @Autowired + private FlowEntryVariableService flowEntryVariableService; + + /** + * 新增流程变量数据。 + * + * @param flowEntryVariableDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"flowEntryVariableDto.variableId"}) + @SaCheckPermission("flowEntry.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody FlowEntryVariableDto flowEntryVariableDto) { + String errorMessage = MyCommonUtil.getModelValidationError(flowEntryVariableDto); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + FlowEntryVariable flowEntryVariable = MyModelUtil.copyTo(flowEntryVariableDto, FlowEntryVariable.class); + flowEntryVariable = flowEntryVariableService.saveNew(flowEntryVariable); + return ResponseResult.success(flowEntryVariable.getVariableId()); + } + + /** + * 更新流程变量数据。 + * + * @param flowEntryVariableDto 更新对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("flowEntry.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody FlowEntryVariableDto flowEntryVariableDto) { + String errorMessage = MyCommonUtil.getModelValidationError(flowEntryVariableDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + FlowEntryVariable flowEntryVariable = MyModelUtil.copyTo(flowEntryVariableDto, FlowEntryVariable.class); + FlowEntryVariable originalFlowEntryVariable = flowEntryVariableService.getById(flowEntryVariable.getVariableId()); + if (originalFlowEntryVariable == null) { + // NOTE: 修改下面方括号中的话述 + errorMessage = "数据验证失败,当前 [数据] 并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!flowEntryVariableService.update(flowEntryVariable, originalFlowEntryVariable)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 删除流程变量数据。 + * + * @param variableId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("flowEntry.all") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long variableId) { + String errorMessage; + if (MyCommonUtil.existBlankArgument(variableId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + // 验证关联Id的数据合法性 + FlowEntryVariable originalFlowEntryVariable = flowEntryVariableService.getById(variableId); + if (originalFlowEntryVariable == null) { + // NOTE: 修改下面方括号中的话述 + errorMessage = "数据验证失败,当前 [对象] 并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!flowEntryVariableService.remove(variableId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的流程变量列表。 + * + * @param flowEntryVariableDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("flowEntry.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody FlowEntryVariableDto flowEntryVariableDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + FlowEntryVariable flowEntryVariableFilter = MyModelUtil.copyTo(flowEntryVariableDtoFilter, FlowEntryVariable.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, FlowEntryVariable.class); + List flowEntryVariableList = + flowEntryVariableService.getFlowEntryVariableListWithRelation(flowEntryVariableFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(flowEntryVariableList, FlowEntryVariableVo.class)); + } + + /** + * 查看指定流程变量对象详情。 + * + * @param variableId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("flowEntry.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long variableId) { + if (MyCommonUtil.existBlankArgument(variableId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + FlowEntryVariable flowEntryVariable = flowEntryVariableService.getByIdWithRelation(variableId, MyRelationParam.full()); + if (flowEntryVariable == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(flowEntryVariable, FlowEntryVariableVo.class); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowMessageController.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowMessageController.java new file mode 100644 index 00000000..ffcc00b6 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowMessageController.java @@ -0,0 +1,110 @@ +package com.orangeforms.common.flow.controller; + +import io.swagger.v3.oas.annotations.tags.Tag; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.flow.model.constant.FlowMessageType; +import com.orangeforms.common.flow.model.FlowMessage; +import com.orangeforms.common.flow.service.FlowMessageService; +import com.orangeforms.common.flow.vo.FlowMessageVo; +import com.github.pagehelper.page.PageMethod; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 工作流消息接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "工作流消息接口") +@Slf4j +@RestController +@RequestMapping("${common-flow.urlPrefix}/flowMessage") +@ConditionalOnProperty(name = "common-flow.operationEnabled", havingValue = "true") +public class FlowMessageController { + + @Autowired + private FlowMessageService flowMessageService; + + /** + * 获取当前用户的未读消息总数。 + * NOTE:白名单接口。 + * + * @return 应答结果对象,包含当前用户的未读消息总数。 + */ + @GetMapping("/getMessageCount") + public ResponseResult getMessageCount() { + JSONObject resultData = new JSONObject(); + resultData.put("remindingMessageCount", flowMessageService.countRemindingMessageListByUser()); + resultData.put("copyMessageCount", flowMessageService.countCopyMessageByUser()); + return ResponseResult.success(resultData); + } + + /** + * 获取当前用户的催办消息列表。 + * 不仅仅包含,其中包括当前用户所属角色、部门和岗位的候选组催办消息。 + * NOTE:白名单接口。 + * + * @return 应答结果对象,包含查询结果集。 + */ + @PostMapping("/listRemindingTask") + public ResponseResult> listRemindingTask(@MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount()); + } + List flowMessageList = flowMessageService.getRemindingMessageListByUser(); + return ResponseResult.success(MyPageUtil.makeResponseData(flowMessageList, FlowMessageVo.class)); + } + + /** + * 获取当前用户的抄送消息列表。 + * 不仅仅包含,其中包括当前用户所属角色、部门和岗位的候选组抄送消息。 + * NOTE:白名单接口。 + * + * @param read true表示已读,false表示未读。 + * @return 应答结果对象,包含查询结果集。 + */ + @PostMapping("/listCopyMessage") + public ResponseResult> listCopyMessage( + @MyRequestBody MyPageParam pageParam, @MyRequestBody Boolean read) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount()); + } + List flowMessageList = flowMessageService.getCopyMessageListByUser(read); + return ResponseResult.success(MyPageUtil.makeResponseData(flowMessageList, FlowMessageVo.class)); + } + + /** + * 读取抄送消息,同时更新当前用户对指定抄送消息的读取状态。 + * + * @param messageId 消息Id。 + * @return 应答结果对象。 + */ + @PostMapping("/readCopyTask") + public ResponseResult readCopyTask(@MyRequestBody Long messageId) { + String errorMessage; + // 验证流程任务的合法性。 + FlowMessage flowMessage = flowMessageService.getById(messageId); + if (flowMessage == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + if (flowMessage.getMessageType() != FlowMessageType.COPY_TYPE) { + errorMessage = "数据验证失败,当前消息不是抄送类型消息!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!flowMessageService.isCandidateIdentityOnMessage(messageId)) { + errorMessage = "数据验证失败,当前用户没有权限访问该消息!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + flowMessageService.readCopyTask(messageId); + return ResponseResult.success(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowOperationController.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowOperationController.java new file mode 100644 index 00000000..033d7e2c --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowOperationController.java @@ -0,0 +1,941 @@ +package com.orangeforms.common.flow.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import io.swagger.v3.oas.annotations.tags.Tag; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.annotation.DisableDataFilter; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.flow.constant.FlowApprovalType; +import com.orangeforms.common.flow.exception.FlowOperationException; +import com.orangeforms.common.flow.constant.FlowConstant; +import com.orangeforms.common.flow.constant.FlowTaskStatus; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.flow.service.*; +import com.orangeforms.common.flow.util.FlowCustomExtFactory; +import com.orangeforms.common.flow.util.FlowOperationHelper; +import com.orangeforms.common.flow.vo.FlowTaskCommentVo; +import com.orangeforms.common.flow.vo.FlowTaskVo; +import com.orangeforms.common.flow.vo.FlowUserInfoVo; +import com.orangeforms.common.flow.vo.TaskInfoVo; +import lombok.extern.slf4j.Slf4j; +import org.flowable.bpmn.converter.BpmnXMLConverter; +import org.flowable.bpmn.model.BpmnModel; +import org.flowable.bpmn.model.UserTask; +import org.flowable.engine.history.HistoricActivityInstance; +import org.flowable.engine.history.HistoricProcessInstance; +import org.flowable.task.api.Task; +import org.flowable.task.api.TaskInfo; +import org.flowable.task.api.history.HistoricTaskInstance; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.util.StreamUtils; +import org.springframework.web.bind.annotation.*; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.text.ParseException; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 工作流流程操作接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "工作流流程操作接口") +@Slf4j +@RestController +@RequestMapping("${common-flow.urlPrefix}/flowOperation") +@ConditionalOnProperty(name = "common-flow.operationEnabled", havingValue = "true") +public class FlowOperationController { + + @Autowired + private FlowEntryService flowEntryService; + @Autowired + private FlowTaskCommentService flowTaskCommentService; + @Autowired + private FlowTaskExtService flowTaskExtService; + @Autowired + private FlowApiService flowApiService; + @Autowired + private FlowWorkOrderService flowWorkOrderService; + @Autowired + private FlowMessageService flowMessageService; + @Autowired + private FlowOperationHelper flowOperationHelper; + @Autowired + private FlowCustomExtFactory flowCustomExtFactory; + @Autowired + private FlowMultiInstanceTransService flowMultiInstanceTransService; + + private static final String ACTIVE_MULTI_INST_TASK = "activeMultiInstanceTask"; + private static final String SHOW_NAME = "showName"; + private static final String INSTANCE_ID = "processInstanceId"; + + /** + * 获取开始节点之后的第一个任务节点的数据。 + * + * @param processDefinitionKey 流程标识。 + * @return 任务节点的自定义对象数据。 + */ + @GetMapping("/viewInitialTaskInfo") + public ResponseResult viewInitialTaskInfo(@RequestParam String processDefinitionKey) { + ResponseResult flowEntryResult = flowOperationHelper.verifyAndGetFlowEntry(processDefinitionKey); + if (!flowEntryResult.isSuccess()) { + return ResponseResult.errorFrom(flowEntryResult); + } + FlowEntryPublish flowEntryPublish = flowEntryResult.getData().getMainFlowEntryPublish(); + String initTaskInfo = flowEntryPublish.getInitTaskInfo(); + TaskInfoVo taskInfo = StrUtil.isBlank(initTaskInfo) + ? null : JSON.parseObject(initTaskInfo, TaskInfoVo.class); + if (taskInfo != null) { + String loginName = TokenData.takeFromRequest().getLoginName(); + taskInfo.setAssignedMe(StrUtil.equalsAny( + taskInfo.getAssignee(), loginName, FlowConstant.START_USER_NAME_VAR)); + } + return ResponseResult.success(taskInfo); + } + + /** + * 获取流程运行时指定任务的信息。 + * + * @param processDefinitionId 流程引擎的定义Id。 + * @param processInstanceId 流程引擎的实例Id。 + * @param taskId 流程引擎的任务Id。 + * @return 任务节点的自定义对象数据。 + */ + @GetMapping("/viewRuntimeTaskInfo") + public ResponseResult viewRuntimeTaskInfo( + @RequestParam String processDefinitionId, + @RequestParam String processInstanceId, + @RequestParam String taskId) { + Task task = flowApiService.getProcessInstanceActiveTask(processInstanceId, taskId); + ResponseResult taskInfoResult = flowOperationHelper.verifyAndGetRuntimeTaskInfo(task); + if (!taskInfoResult.isSuccess()) { + return ResponseResult.errorFrom(taskInfoResult); + } + TaskInfoVo taskInfoVo = taskInfoResult.getData(); + FlowTaskExt flowTaskExt = + flowTaskExtService.getByProcessDefinitionIdAndTaskId(processDefinitionId, taskInfoVo.getTaskKey()); + if (flowTaskExt != null) { + if (StrUtil.isNotBlank(flowTaskExt.getOperationListJson())) { + taskInfoVo.setOperationList(JSON.parseArray(flowTaskExt.getOperationListJson(), JSONObject.class)); + } + if (StrUtil.isNotBlank(flowTaskExt.getVariableListJson())) { + taskInfoVo.setVariableList(JSON.parseArray(flowTaskExt.getVariableListJson(), JSONObject.class)); + } + } + return ResponseResult.success(taskInfoVo); + } + + /** + * 获取流程运行时指定任务的信息。 + * + * @param processDefinitionId 流程引擎的定义Id。 + * @param processInstanceId 流程引擎的实例Id。 + * @param taskId 流程引擎的任务Id。 + * @return 任务节点的自定义对象数据。 + */ + @GetMapping("/viewHistoricTaskInfo") + public ResponseResult viewHistoricTaskInfo( + @RequestParam String processDefinitionId, + @RequestParam String processInstanceId, + @RequestParam String taskId) { + String errorMessage; + HistoricTaskInstance taskInstance = flowApiService.getHistoricTaskInstance(processInstanceId, taskId); + String loginName = TokenData.takeFromRequest().getLoginName(); + if (!StrUtil.equals(taskInstance.getAssignee(), loginName)) { + errorMessage = "数据验证失败,当前用户不是指派人!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + TaskInfoVo taskInfoVo = JSON.parseObject(taskInstance.getFormKey(), TaskInfoVo.class); + FlowTaskExt flowTaskExt = + flowTaskExtService.getByProcessDefinitionIdAndTaskId(processDefinitionId, taskInstance.getTaskDefinitionKey()); + if (flowTaskExt != null) { + if (StrUtil.isNotBlank(flowTaskExt.getOperationListJson())) { + taskInfoVo.setOperationList(JSON.parseArray(flowTaskExt.getOperationListJson(), JSONObject.class)); + } + if (StrUtil.isNotBlank(flowTaskExt.getVariableListJson())) { + taskInfoVo.setVariableList(JSON.parseArray(flowTaskExt.getVariableListJson(), JSONObject.class)); + } + } + return ResponseResult.success(taskInfoVo); + } + + /** + * 获取第一个提交表单数据的任务信息。 + * + * @param processInstanceId 流程实例Id。 + * @return 任务节点的自定义对象数据。 + */ + @GetMapping("/viewInitialHistoricTaskInfo") + public ResponseResult viewInitialHistoricTaskInfo(@RequestParam String processInstanceId) { + String errorMessage; + List taskCommentList = + flowTaskCommentService.getFlowTaskCommentList(processInstanceId); + if (CollUtil.isEmpty(taskCommentList)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + FlowTaskComment taskComment = taskCommentList.get(0); + HistoricTaskInstance task = flowApiService.getHistoricTaskInstance(processInstanceId, taskComment.getTaskId()); + if (StrUtil.isBlank(task.getFormKey())) { + errorMessage = "数据验证失败,指定任务的formKey属性不存在,请重新修改流程图!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + TaskInfoVo taskInfo = JSON.parseObject(task.getFormKey(), TaskInfoVo.class); + taskInfo.setTaskKey(task.getTaskDefinitionKey()); + return ResponseResult.success(taskInfo); + } + + /** + * 获取任务的用户信息列表。 + * + * @param processDefinitionId 流程定义Id。 + * @param processInstanceId 流程实例Id。 + * @param taskId 流程任务Id。 + * @param historic 是否为历史任务。 + * @return 任务相关的用户信息列表。 + */ + @DisableDataFilter + @GetMapping("/viewTaskUserInfo") + public ResponseResult> viewTaskUserInfo( + @RequestParam String processDefinitionId, + @RequestParam String processInstanceId, + @RequestParam String taskId, + @RequestParam Boolean historic) { + TaskInfo taskInfo; + HistoricTaskInstance hisotricTask; + if (BooleanUtil.isFalse(historic)) { + taskInfo = flowApiService.getTaskById(taskId); + if (taskInfo == null) { + hisotricTask = flowApiService.getHistoricTaskInstance(processInstanceId, taskId); + taskInfo = hisotricTask; + historic = true; + } + } else { + hisotricTask = flowApiService.getHistoricTaskInstance(processInstanceId, taskId); + taskInfo = hisotricTask; + } + if (taskInfo == null) { + String errorMessage = "数据验证失败,任务Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + String taskKey = taskInfo.getTaskDefinitionKey(); + FlowTaskExt taskExt = flowTaskExtService.getByProcessDefinitionIdAndTaskId(processDefinitionId, taskKey); + boolean isMultiInstanceTask = flowApiService.isMultiInstanceTask(taskInfo.getProcessDefinitionId(), taskKey); + List resultUserInfoList = + flowTaskExtService.getCandidateUserInfoList(processInstanceId, taskExt, taskInfo, isMultiInstanceTask, historic); + if (BooleanUtil.isTrue(historic) || isMultiInstanceTask) { + List taskCommentList = buildApprovedFlowTaskCommentList(taskInfo, isMultiInstanceTask); + Map resultUserInfoMap = + resultUserInfoList.stream().collect(Collectors.toMap(FlowUserInfoVo::getLoginName, c -> c)); + for (FlowTaskComment taskComment : taskCommentList) { + FlowUserInfoVo flowUserInfoVo = resultUserInfoMap.get(taskComment.getCreateLoginName()); + if (flowUserInfoVo != null) { + flowUserInfoVo.setLastApprovalTime(taskComment.getCreateTime()); + } + } + } + return ResponseResult.success(resultUserInfoList); + } + + /** + * 获取多实例会签任务的指派人列表。 + * NOTE: 白名单接口。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 多实例任务的上一级任务Id。 + * @return 应答结果,指定会签任务的指派人列表。 + */ + @GetMapping("/listMultiSignAssignees") + public ResponseResult> listMultiSignAssignees( + @RequestParam String processInstanceId, @RequestParam String taskId) { + ResponseResult verifyResult = this.doVerifyMultiSign(processInstanceId, taskId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + Task activeMultiInstanceTask = + verifyResult.getData().getObject(ACTIVE_MULTI_INST_TASK, Task.class); + String multiInstanceExecId = flowApiService.getExecutionVariableStringWithSafe( + activeMultiInstanceTask.getExecutionId(), FlowConstant.MULTI_SIGN_TASK_EXECUTION_ID_VAR); + FlowMultiInstanceTrans trans = + flowMultiInstanceTransService.getWithAssigneeListByMultiInstanceExecId(multiInstanceExecId); + List commentList = + flowTaskCommentService.getFlowTaskCommentListByMultiInstanceExecId(multiInstanceExecId); + List assigneeList = StrUtil.split(trans.getAssigneeList(), ","); + Set approvedAssigneeSet = commentList.stream() + .map(FlowTaskComment::getCreateLoginName).collect(Collectors.toSet()); + List resultList = new LinkedList<>(); + Map usernameMap = + flowCustomExtFactory.getFlowIdentityExtHelper().mapUserShowNameByLoginName(new HashSet<>(assigneeList)); + for (String assignee : assigneeList) { + JSONObject resultData = new JSONObject(); + resultData.put("assignee", assignee); + resultData.put(SHOW_NAME, usernameMap.get(assignee)); + resultData.put("approved", approvedAssigneeSet.contains(assignee)); + resultList.add(resultData); + } + return ResponseResult.success(resultList); + } + + /** + * 提交多实例加签或减签。 + * NOTE: 白名单接口。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 多实例任务的上一级任务Id。 + * @param newAssignees 加签减签人列表,多个指派人之间逗号分隔。 + * @param isAdd 是否为加签,如果没有该参数,为了保持兼容性,缺省值为true。 + * @return 应答结果。 + */ + @PostMapping("/submitConsign") + public ResponseResult submitConsign( + @MyRequestBody(required = true) String processInstanceId, + @MyRequestBody(required = true) String taskId, + @MyRequestBody(required = true) String newAssignees, + @MyRequestBody Boolean isAdd) { + String errorMessage; + ResponseResult verifyResult = this.doVerifyMultiSign(processInstanceId, taskId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + HistoricTaskInstance taskInstance = + verifyResult.getData().getObject("taskInstance", HistoricTaskInstance.class); + Task activeMultiInstanceTask = + verifyResult.getData().getObject(ACTIVE_MULTI_INST_TASK, Task.class); + String multiInstanceExecId = flowApiService.getExecutionVariableStringWithSafe( + activeMultiInstanceTask.getExecutionId(), FlowConstant.MULTI_SIGN_TASK_EXECUTION_ID_VAR); + JSONArray assigneeArray = JSON.parseArray(newAssignees); + if (isAdd == null) { + isAdd = true; + } + if (!isAdd) { + List commentList = + flowTaskCommentService.getFlowTaskCommentListByMultiInstanceExecId(multiInstanceExecId); + if (CollUtil.isNotEmpty(commentList)) { + Set approvedAssigneeSet = commentList.stream() + .map(FlowTaskComment::getCreateLoginName).collect(Collectors.toSet()); + String loginName = this.findExistAssignee(approvedAssigneeSet, assigneeArray); + if (loginName != null) { + errorMessage = "数据验证失败,用户 [" + loginName + "] 已经审批,不能减签该用户!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + } else { + // 避免同一人被重复加签。 + FlowMultiInstanceTrans trans = + flowMultiInstanceTransService.getWithAssigneeListByMultiInstanceExecId(multiInstanceExecId); + Set assigneeSet = new HashSet<>(StrUtil.split(trans.getAssigneeList(), ",")); + String loginName = this.findExistAssignee(assigneeSet, assigneeArray); + if (loginName != null) { + errorMessage = "数据验证失败,用户 [" + loginName + "] 已经是会签人,不能重复指定!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + try { + flowApiService.submitConsign(taskInstance, activeMultiInstanceTask, newAssignees, isAdd); + } catch (FlowOperationException e) { + errorMessage = e.getMessage(); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 返回当前用户待办的任务列表。 + * + * @param processDefinitionKey 流程标识。 + * @param processDefinitionName 流程定义名 (模糊查询)。 + * @param taskName 任务名称 (模糊查询)。 + * @param pageParam 分页对象。 + * @return 返回当前用户待办的任务列表。如果指定流程标识,则仅返回该流程的待办任务列表。 + */ + @DisableDataFilter + @PostMapping("/listRuntimeTask") + public ResponseResult> listRuntimeTask( + @MyRequestBody String processDefinitionKey, + @MyRequestBody String processDefinitionName, + @MyRequestBody String taskName, + @MyRequestBody(required = true) MyPageParam pageParam) { + String username = TokenData.takeFromRequest().getLoginName(); + MyPageData pageData = flowApiService.getTaskListByUserName( + username, processDefinitionKey, processDefinitionName, taskName, pageParam); + List flowTaskVoList = flowApiService.convertToFlowTaskList(pageData.getDataList()); + return ResponseResult.success(MyPageUtil.makeResponseData(flowTaskVoList, pageData.getTotalCount())); + } + + /** + * 返回当前用户待办的任务数量。 + * + * @return 返回当前用户待办的任务数量。 + */ + @PostMapping("/countRuntimeTask") + public ResponseResult countRuntimeTask() { + String username = TokenData.takeFromRequest().getLoginName(); + long totalCount = flowApiService.getTaskCountByUserName(username); + return ResponseResult.success(totalCount); + } + + /** + * 主动驳回当前的待办任务到开始节点,只用当前待办任务的指派人或者候选者才能完成该操作。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 待办任务Id。 + * @param taskComment 驳回备注。 + * @return 操作应答结果。 + */ + @PostMapping("/rejectToStartUserTask") + public ResponseResult rejectToStartUserTask( + @MyRequestBody(required = true) String processInstanceId, + @MyRequestBody(required = true) String taskId, + @MyRequestBody(required = true) String taskComment) { + ResponseResult taskResult = + flowOperationHelper.verifySubmitAndGetTask(processInstanceId, taskId, null); + if (!taskResult.isSuccess()) { + return ResponseResult.errorFrom(taskResult); + } + FlowTaskComment firstTaskComment = flowTaskCommentService.getFirstFlowTaskComment(processInstanceId); + CallResult result = flowApiService.backToRuntimeTask( + taskResult.getData(), firstTaskComment.getTaskKey(), true, taskComment); + if (!result.isSuccess()) { + return ResponseResult.errorFrom(result); + } + return ResponseResult.success(); + } + + /** + * 主动驳回当前的待办任务,只用当前待办任务的指派人或者候选者才能完成该操作。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 待办任务Id。 + * @param taskComment 驳回备注。 + * @return 操作应答结果。 + */ + @PostMapping("/rejectRuntimeTask") + public ResponseResult rejectRuntimeTask( + @MyRequestBody(required = true) String processInstanceId, + @MyRequestBody(required = true) String taskId, + @MyRequestBody(required = true) String taskComment) { + String errorMessage; + ResponseResult taskResult = + flowOperationHelper.verifySubmitAndGetTask(processInstanceId, taskId, null); + if (!taskResult.isSuccess()) { + return ResponseResult.errorFrom(taskResult); + } + CallResult result = flowApiService.backToRuntimeTask(taskResult.getData(), null, true, taskComment); + if (!result.isSuccess()) { + return ResponseResult.errorFrom(result); + } + return ResponseResult.success(); + } + + /** + * 撤回当前用户提交的,但是尚未被审批的待办任务。只有已办任务的指派人才能完成该操作。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 待撤回的已办任务Id。 + * @param taskComment 撤回备注。 + * @return 操作应答结果。 + */ + @PostMapping("/revokeHistoricTask") + public ResponseResult revokeHistoricTask( + @MyRequestBody(required = true) String processInstanceId, + @MyRequestBody(required = true) String taskId, + @MyRequestBody(required = true) String taskComment) { + String errorMessage; + if (!flowApiService.existActiveProcessInstance(processInstanceId)) { + errorMessage = "数据验证失败,当前流程实例已经结束,不能执行撤回!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + HistoricTaskInstance taskInstance = flowApiService.getHistoricTaskInstance(processInstanceId, taskId); + if (taskInstance == null) { + errorMessage = "数据验证失败,当前任务不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!StrUtil.equals(taskInstance.getAssignee(), TokenData.takeFromRequest().getLoginName())) { + errorMessage = "数据验证失败,任务指派人与当前用户不匹配!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + FlowTaskComment latestComment = flowTaskCommentService.getLatestFlowTaskComment(processInstanceId); + if (latestComment == null) { + errorMessage = "数据验证失败,当前实例没有任何审批提交记录!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!latestComment.getTaskId().equals(taskId)) { + errorMessage = "数据验证失败,当前审批任务已被办理,不能撤回!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + List activeTaskList = flowApiService.getProcessInstanceActiveTaskList(processInstanceId); + if (CollUtil.isEmpty(activeTaskList)) { + errorMessage = "数据验证失败,当前流程没有任何待办任务!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (latestComment.getApprovalType().equals(FlowApprovalType.TRANSFER)) { + if (activeTaskList.size() > 1) { + errorMessage = "数据验证失败,转办任务数量不能多于1个!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + // 如果是转办任务,无需节点跳转,将指派人改为当前用户即可。 + Task task = activeTaskList.get(0); + task.setAssignee(TokenData.takeFromRequest().getLoginName()); + } else { + CallResult result = + flowApiService.backToRuntimeTask(activeTaskList.get(0), null, false, taskComment); + if (!result.isSuccess()) { + return ResponseResult.errorFrom(result); + } + } + return ResponseResult.success(); + } + + /** + * 获取当前流程任务的审批列表。 + * + * @param processInstanceId 当前运行时的流程实例Id。 + * @return 当前流程实例的详情数据。 + */ + @GetMapping("/listFlowTaskComment") + public ResponseResult> listFlowTaskComment(@RequestParam String processInstanceId) { + List flowTaskCommentList = + flowTaskCommentService.getFlowTaskCommentList(processInstanceId); + List resultList = MyModelUtil.copyCollectionTo(flowTaskCommentList, FlowTaskCommentVo.class); + return ResponseResult.success(resultList); + } + + /** + * 获取指定流程定义的流程图。 + * + * @param processDefinitionId 流程定义Id。 + * @return 流程图。 + */ + @GetMapping("/viewProcessBpmn") + public ResponseResult viewProcessBpmn(@RequestParam String processDefinitionId) throws IOException { + BpmnXMLConverter converter = new BpmnXMLConverter(); + BpmnModel bpmnModel = flowApiService.getBpmnModelByDefinitionId(processDefinitionId); + byte[] xmlBytes = converter.convertToXML(bpmnModel); + InputStream in = new ByteArrayInputStream(xmlBytes); + return ResponseResult.success(StreamUtils.copyToString(in, StandardCharsets.UTF_8)); + } + + /** + * 获取流程图高亮数据。 + * + * @param processInstanceId 流程实例Id。 + * @return 流程图高亮数据。 + */ + @GetMapping("/viewHighlightFlowData") + public ResponseResult viewHighlightFlowData(@RequestParam String processInstanceId) { + List activityInstanceList = + flowApiService.getHistoricActivityInstanceList(processInstanceId); + Set finishedTaskSet = activityInstanceList.stream() + .filter(s -> !StrUtil.equals(s.getActivityType(), "sequenceFlow")) + .map(HistoricActivityInstance::getActivityId).collect(Collectors.toSet()); + Set finishedSequenceFlowSet = activityInstanceList.stream() + .filter(s -> StrUtil.equals(s.getActivityType(), "sequenceFlow")) + .map(HistoricActivityInstance::getActivityId).collect(Collectors.toSet()); + //获取流程实例当前正在待办的节点 + List unfinishedInstanceList = + flowApiService.getHistoricUnfinishedInstanceList(processInstanceId); + Set unfinishedTaskSet = new LinkedHashSet<>(); + for (HistoricActivityInstance unfinishedActivity : unfinishedInstanceList) { + unfinishedTaskSet.add(unfinishedActivity.getActivityId()); + } + JSONObject jsonData = new JSONObject(); + jsonData.put("finishedTaskSet", finishedTaskSet); + jsonData.put("finishedSequenceFlowSet", finishedSequenceFlowSet); + jsonData.put("unfinishedTaskSet", unfinishedTaskSet); + return ResponseResult.success(jsonData); + } + + /** + * 获取当前用户的已办理的审批任务列表。 + * + * @param processDefinitionName 流程名。 + * @param beginDate 流程发起开始时间。 + * @param endDate 流程发起结束时间。 + * @param pageParam 分页对象。 + * @return 查询结果应答。 + */ + @DisableDataFilter + @PostMapping("/listHistoricTask") + public ResponseResult>> listHistoricTask( + @MyRequestBody String processDefinitionName, + @MyRequestBody String beginDate, + @MyRequestBody String endDate, + @MyRequestBody(required = true) MyPageParam pageParam) throws ParseException { + MyPageData pageData = + flowApiService.getHistoricTaskInstanceFinishedList(processDefinitionName, beginDate, endDate, pageParam); + List> resultList = new LinkedList<>(); + pageData.getDataList().forEach(instance -> resultList.add(BeanUtil.beanToMap(instance))); + List taskInstanceList = pageData.getDataList(); + if (CollUtil.isNotEmpty(taskInstanceList)) { + Set instanceIdSet = taskInstanceList.stream() + .map(HistoricTaskInstance::getProcessInstanceId).collect(Collectors.toSet()); + List instanceList = flowApiService.getHistoricProcessInstanceList(instanceIdSet); + Set loginNameSet = instanceList.stream() + .map(HistoricProcessInstance::getStartUserId).collect(Collectors.toSet()); + List userInfoList = flowCustomExtFactory + .getFlowIdentityExtHelper().getUserInfoListByUsernameSet(loginNameSet); + Map userInfoMap = + userInfoList.stream().collect(Collectors.toMap(FlowUserInfoVo::getLoginName, c -> c)); + Map instanceMap = + instanceList.stream().collect(Collectors.toMap(HistoricProcessInstance::getId, c -> c)); + List workOrderList = + flowWorkOrderService.getInList(INSTANCE_ID, instanceIdSet); + Map workOrderMap = + workOrderList.stream().collect(Collectors.toMap(FlowWorkOrder::getProcessInstanceId, c -> c)); + resultList.forEach(result -> { + String instanceId = result.get(INSTANCE_ID).toString(); + HistoricProcessInstance instance = instanceMap.get(instanceId); + result.put("processDefinitionKey", instance.getProcessDefinitionKey()); + result.put("processDefinitionName", instance.getProcessDefinitionName()); + result.put("startUser", instance.getStartUserId()); + FlowUserInfoVo userInfo = userInfoMap.get(instance.getStartUserId()); + result.put(SHOW_NAME, userInfo.getShowName()); + result.put("headImageUrl", userInfo.getHeadImageUrl()); + result.put("businessKey", instance.getBusinessKey()); + FlowWorkOrder flowWorkOrder = workOrderMap.get(instanceId); + if (flowWorkOrder != null) { + result.put("workOrderCode", flowWorkOrder.getWorkOrderCode()); + } + }); + Set taskIdSet = + taskInstanceList.stream().map(HistoricTaskInstance::getId).collect(Collectors.toSet()); + List commentList = flowTaskCommentService.getFlowTaskCommentListByTaskIds(taskIdSet); + Map> commentMap = + commentList.stream().collect(Collectors.groupingBy(FlowTaskComment::getTaskId)); + resultList.forEach(result -> { + List comments = commentMap.get(result.get("id").toString()); + if (CollUtil.isNotEmpty(comments)) { + result.put("approvalType", comments.get(0).getApprovalType()); + comments.remove(0); + } + }); + } + return ResponseResult.success(MyPageUtil.makeResponseData(resultList, pageData.getTotalCount())); + } + + /** + * 根据输入参数查询,当前用户的历史流程数据。 + * + * @param processDefinitionName 流程名。 + * @param beginDate 流程发起开始时间。 + * @param endDate 流程发起结束时间。 + * @param pageParam 分页对象。 + * @return 查询结果应答。 + */ + @DisableDataFilter + @PostMapping("/listHistoricProcessInstance") + public ResponseResult>> listHistoricProcessInstance( + @MyRequestBody String processDefinitionName, + @MyRequestBody String beginDate, + @MyRequestBody String endDate, + @MyRequestBody(required = true) MyPageParam pageParam) throws ParseException { + String loginName = TokenData.takeFromRequest().getLoginName(); + MyPageData pageData = flowApiService.getHistoricProcessInstanceList( + null, processDefinitionName, loginName, beginDate, endDate, pageParam, true); + Set loginNameSet = pageData.getDataList().stream() + .map(HistoricProcessInstance::getStartUserId).collect(Collectors.toSet()); + List userInfoList = flowCustomExtFactory + .getFlowIdentityExtHelper().getUserInfoListByUsernameSet(loginNameSet); + if (CollUtil.isEmpty(userInfoList)) { + userInfoList = new LinkedList<>(); + } + Map userInfoMap = + userInfoList.stream().collect(Collectors.toMap(FlowUserInfoVo::getLoginName, c -> c)); + Set instanceIdSet = pageData.getDataList().stream() + .map(HistoricProcessInstance::getId).collect(Collectors.toSet()); + List workOrderList = + flowWorkOrderService.getInList(INSTANCE_ID, instanceIdSet); + Map workOrderMap = + workOrderList.stream().collect(Collectors.toMap(FlowWorkOrder::getProcessInstanceId, c -> c)); + List> resultList = new LinkedList<>(); + pageData.getDataList().forEach(instance -> { + Map data = BeanUtil.beanToMap(instance); + FlowUserInfoVo userInfo = userInfoMap.get(instance.getStartUserId()); + if (userInfo != null) { + data.put(SHOW_NAME, userInfo.getShowName()); + data.put("headImageUrl", userInfo.getHeadImageUrl()); + } + FlowWorkOrder workOrder = workOrderMap.get(instance.getId()); + if (workOrder != null) { + data.put("workOrderCode", workOrder.getWorkOrderCode()); + data.put("flowStatus", workOrder.getFlowStatus()); + } + resultList.add(data); + }); + return ResponseResult.success(MyPageUtil.makeResponseData(resultList, pageData.getTotalCount())); + } + + /** + * 根据输入参数查询,所有历史流程数据。 + * + * @param processDefinitionName 流程名。 + * @param startUser 流程发起用户。 + * @param beginDate 流程发起开始时间。 + * @param endDate 流程发起结束时间。 + * @param pageParam 分页对象。 + * @return 查询结果。 + */ + @PostMapping("/listAllHistoricProcessInstance") + public ResponseResult>> listAllHistoricProcessInstance( + @MyRequestBody String processDefinitionName, + @MyRequestBody String startUser, + @MyRequestBody String beginDate, + @MyRequestBody String endDate, + @MyRequestBody(required = true) MyPageParam pageParam) throws ParseException { + MyPageData pageData = flowApiService.getHistoricProcessInstanceList( + null, processDefinitionName, startUser, beginDate, endDate, pageParam, false); + List> resultList = new LinkedList<>(); + pageData.getDataList().forEach(instance -> resultList.add(BeanUtil.beanToMap(instance))); + List unfinishedProcessInstanceIds = pageData.getDataList().stream() + .filter(c -> c.getEndTime() == null) + .map(HistoricProcessInstance::getId) + .collect(Collectors.toList()); + MyPageData> pageResultData = + MyPageUtil.makeResponseData(resultList, pageData.getTotalCount()); + if (CollUtil.isEmpty(unfinishedProcessInstanceIds)) { + return ResponseResult.success(pageResultData); + } + Set processInstanceIds = pageData.getDataList().stream() + .map(HistoricProcessInstance::getId).collect(Collectors.toSet()); + List taskList = flowApiService.getTaskListByProcessInstanceIds(unfinishedProcessInstanceIds); + Map> taskMap = + taskList.stream().collect(Collectors.groupingBy(Task::getProcessInstanceId)); + for (Map result : resultList) { + String processInstanceId = result.get(INSTANCE_ID).toString(); + List instanceTaskList = taskMap.get(processInstanceId); + if (instanceTaskList != null) { + JSONArray taskArray = new JSONArray(); + for (Task task : instanceTaskList) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("taskId", task.getId()); + jsonObject.put("taskName", task.getName()); + jsonObject.put("taskKey", task.getTaskDefinitionKey()); + jsonObject.put("assignee", task.getAssignee()); + taskArray.add(jsonObject); + } + result.put("runtimeTaskInfoList", taskArray); + } + } + return ResponseResult.success(pageResultData); + } + + /** + * 催办工单,只有流程发起人才可以催办工单。 + * 催办场景必须要取消数据权限过滤,因为流程的指派很可能是跨越部门的。 + * 既然被指派和催办了,这里就应该禁用工单表的数据权限过滤约束。 + * 如果您的系统没有支持数据权限过滤,DisableDataFilter不会有任何影响,建议保留。 + * + * @param workOrderId 工单Id。 + * @return 应答结果。 + */ + @DisableDataFilter + @OperationLog(type = SysOperationLogType.REMIND_TASK) + @PostMapping("/remindRuntimeTask") + public ResponseResult remindRuntimeTask(@MyRequestBody(required = true) Long workOrderId) { + FlowWorkOrder flowWorkOrder = flowWorkOrderService.getById(workOrderId); + if (flowWorkOrder == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + String errorMessage; + if (!flowWorkOrder.getCreateUserId().equals(TokenData.takeFromRequest().getUserId())) { + errorMessage = "数据验证失败,只有流程发起人才能催办工单!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (flowWorkOrder.getFlowStatus().equals(FlowTaskStatus.FINISHED) + || flowWorkOrder.getFlowStatus().equals(FlowTaskStatus.CANCELLED) + || flowWorkOrder.getFlowStatus().equals(FlowTaskStatus.STOPPED)) { + errorMessage = "数据验证失败,已经结束的流程,不能催办工单!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (flowWorkOrder.getFlowStatus().equals(FlowTaskStatus.DRAFT)) { + errorMessage = "数据验证失败,流程草稿不能催办工单!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + flowMessageService.saveNewRemindMessage(flowWorkOrder); + return ResponseResult.success(); + } + + /** + * 取消工作流工单,仅当没有进入任何审批流程之前,才可以取消工单。 + * + * @param workOrderId 工单Id。 + * @param cancelReason 取消原因。 + * @return 应答结果。 + */ + @OperationLog(type = SysOperationLogType.CANCEL_FLOW) + @DisableDataFilter + @PostMapping("/cancelWorkOrder") + public ResponseResult cancelWorkOrder( + @MyRequestBody(required = true) Long workOrderId, + @MyRequestBody(required = true) String cancelReason) { + FlowWorkOrder flowWorkOrder = flowWorkOrderService.getById(workOrderId); + if (flowWorkOrder == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + String errorMessage; + if (!flowWorkOrder.getFlowStatus().equals(FlowTaskStatus.SUBMITTED) + && !flowWorkOrder.getFlowStatus().equals(FlowTaskStatus.DRAFT)) { + errorMessage = "数据验证失败,当前流程已经进入审批状态,不能撤销工单!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!flowWorkOrder.getCreateUserId().equals(TokenData.takeFromRequest().getUserId())) { + errorMessage = "数据验证失败,当前用户不是工单所有者,不能撤销工单!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + CallResult result; + // 草稿工单直接删除当前工单。 + if (flowWorkOrder.getFlowStatus().equals(FlowTaskStatus.DRAFT)) { + result = flowWorkOrderService.removeDraft(flowWorkOrder); + } else { + result = flowApiService.stopProcessInstance( + flowWorkOrder.getProcessInstanceId(), cancelReason, true); + } + if (!result.isSuccess()) { + return ResponseResult.errorFrom(result); + } + return ResponseResult.success(); + } + + /** + * 获取指定流程定义Id的所有用户任务数据列表。 + * + * @param processDefinitionId 流程定义Id。 + * @return 查询结果。 + */ + @GetMapping("/listAllUserTask") + public ResponseResult> listAllUserTask(@RequestParam String processDefinitionId) { + Map taskMap = flowApiService.getAllUserTaskMap(processDefinitionId); + List resultList = new LinkedList<>(); + for (UserTask t : taskMap.values()) { + JSONObject data = new JSONObject(); + data.put("id", t.getId()); + data.put("name", t.getName()); + resultList.add(data); + } + return ResponseResult.success(resultList); + } + + /** + * 终止流程实例,将任务从当前节点直接流转到主流程的结束事件。 + * + * @param processInstanceId 流程实例Id。 + * @param stopReason 停止原因。 + * @return 执行结果应答。 + */ + @SaCheckPermission("flowOperation.all") + @OperationLog(type = SysOperationLogType.STOP_FLOW) + @DisableDataFilter + @PostMapping("/stopProcessInstance") + public ResponseResult stopProcessInstance( + @MyRequestBody(required = true) String processInstanceId, + @MyRequestBody(required = true) String stopReason) { + CallResult result = flowApiService.stopProcessInstance(processInstanceId, stopReason, false); + if (!result.isSuccess()) { + return ResponseResult.errorFrom(result); + } + return ResponseResult.success(); + } + + /** + * 删除流程实例。 + * + * @param processInstanceId 流程实例Id。 + * @return 执行结果应答。 + */ + @SaCheckPermission("flowOperation.all") + @OperationLog(type = SysOperationLogType.DELETE_FLOW) + @PostMapping("/deleteProcessInstance") + public ResponseResult deleteProcessInstance(@MyRequestBody(required = true) String processInstanceId) { + flowApiService.deleteProcessInstance(processInstanceId); + return ResponseResult.success(); + } + + private List buildApprovedFlowTaskCommentList(TaskInfo taskInfo, boolean isMultiInstanceTask) { + List taskCommentList; + if (isMultiInstanceTask) { + String multiInstanceExecId; + FlowMultiInstanceTrans trans = + flowMultiInstanceTransService.getByExecutionId(taskInfo.getExecutionId(), taskInfo.getId()); + if (trans != null) { + multiInstanceExecId = trans.getMultiInstanceExecId(); + } else { + multiInstanceExecId = flowApiService.getExecutionVariableStringWithSafe( + taskInfo.getExecutionId(), FlowConstant.MULTI_SIGN_TASK_EXECUTION_ID_VAR); + } + taskCommentList = flowTaskCommentService.getFlowTaskCommentListByMultiInstanceExecId(multiInstanceExecId); + } else { + taskCommentList = flowTaskCommentService.getFlowTaskCommentListByExecutionId( + taskInfo.getProcessInstanceId(), taskInfo.getId(), taskInfo.getExecutionId()); + } + return taskCommentList; + } + + private ResponseResult doVerifyMultiSign(String processInstanceId, String taskId) { + String errorMessage; + if (!flowApiService.existActiveProcessInstance(processInstanceId)) { + errorMessage = "数据验证失败,当前流程实例已经结束,不能执行加签!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + HistoricTaskInstance taskInstance = flowApiService.getHistoricTaskInstance(processInstanceId, taskId); + if (taskInstance == null) { + errorMessage = "数据验证失败,当前任务不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + String loginName = TokenData.takeFromRequest().getLoginName(); + if (!StrUtil.equals(taskInstance.getAssignee(), loginName)) { + errorMessage = "数据验证失败,任务指派人与当前用户不匹配!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + List activeTaskList = flowApiService.getProcessInstanceActiveTaskList(processInstanceId); + Task activeMultiInstanceTask = null; + Map userTaskMap = flowApiService.getAllUserTaskMap(taskInstance.getProcessDefinitionId()); + for (Task activeTask : activeTaskList) { + UserTask userTask = userTaskMap.get(activeTask.getTaskDefinitionKey()); + if (!userTask.hasMultiInstanceLoopCharacteristics()) { + errorMessage = "数据验证失败,指定加签任务不存在或已审批完毕!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + String startTaskId = flowApiService.getTaskVariableStringWithSafe( + activeTask.getId(), FlowConstant.MULTI_SIGN_START_TASK_VAR); + if (StrUtil.equals(startTaskId, taskId)) { + activeMultiInstanceTask = activeTask; + break; + } + } + if (activeMultiInstanceTask == null) { + errorMessage = "数据验证失败,指定加签任务不存在或已审批完毕!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + JSONObject resultData = new JSONObject(); + resultData.put("taskInstance", taskInstance); + resultData.put(ACTIVE_MULTI_INST_TASK, activeMultiInstanceTask); + return ResponseResult.success(resultData); + } + + private String findExistAssignee(Set assigneeSet, JSONArray assigneeArray) { + for (int i = 0; i < assigneeArray.size(); i++) { + String loginName = assigneeArray.getString(i); + if (assigneeSet.contains(loginName)) { + return loginName; + } + } + return null; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowCategoryMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowCategoryMapper.java new file mode 100644 index 00000000..7cd964f6 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowCategoryMapper.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowCategory; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * FlowCategory数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowCategoryMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param flowCategoryFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getFlowCategoryList( + @Param("flowCategoryFilter") FlowCategory flowCategoryFilter, @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryMapper.java new file mode 100644 index 00000000..3e4154a8 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryMapper.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowEntry; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * FlowEntry数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowEntryMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param flowEntryFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getFlowEntryList( + @Param("flowEntryFilter") FlowEntry flowEntryFilter, @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryPublishMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryPublishMapper.java new file mode 100644 index 00000000..233c5531 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryPublishMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowEntryPublish; + +/** + * 数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowEntryPublishMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryPublishVariableMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryPublishVariableMapper.java new file mode 100644 index 00000000..76de0460 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryPublishVariableMapper.java @@ -0,0 +1,22 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowEntryPublishVariable; + +import java.util.List; + +/** + * 数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowEntryPublishVariableMapper extends BaseDaoMapper { + + /** + * 批量插入流程发布的变量列表。 + * + * @param entryPublishVariableList 流程发布的变量列表。 + */ + void insertList(List entryPublishVariableList); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryVariableMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryVariableMapper.java new file mode 100644 index 00000000..c7c133bb --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryVariableMapper.java @@ -0,0 +1,27 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowEntryVariable; +import org.apache.ibatis.annotations.Param; + +import java.util.*; + +/** + * 流程变量数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowEntryVariableMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param flowEntryVariableFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getFlowEntryVariableList( + @Param("flowEntryVariableFilter") FlowEntryVariable flowEntryVariableFilter, + @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMessageCandidateIdentityMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMessageCandidateIdentityMapper.java new file mode 100644 index 00000000..c37279f2 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMessageCandidateIdentityMapper.java @@ -0,0 +1,21 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowMessageCandidateIdentity; +import org.apache.ibatis.annotations.Param; + +/** + * 流程任务消息的候选身份数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowMessageCandidateIdentityMapper extends BaseDaoMapper { + + /** + * 删除指定流程实例的消息关联数据。 + * + * @param processInstanceId 流程实例Id。 + */ + void deleteByProcessInstanceId(@Param("processInstanceId") String processInstanceId); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMessageIdentityOperationMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMessageIdentityOperationMapper.java new file mode 100644 index 00000000..bc635b07 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMessageIdentityOperationMapper.java @@ -0,0 +1,21 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowMessageIdentityOperation; +import org.apache.ibatis.annotations.Param; + +/** + * 流程任务消息所属用户的操作数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowMessageIdentityOperationMapper extends BaseDaoMapper { + + /** + * 删除指定流程实例的消息关联数据。 + * + * @param processInstanceId 流程实例Id。 + */ + void deleteByProcessInstanceId(@Param("processInstanceId") String processInstanceId); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMessageMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMessageMapper.java new file mode 100644 index 00000000..b34474ae --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMessageMapper.java @@ -0,0 +1,79 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowMessage; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Set; + +/** + * 工作流消息数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowMessageMapper extends BaseDaoMapper { + + /** + * 获取指定用户和身份分组Id集合的催办消息列表。 + * + * @param tenantId 租户Id。 + * @param appCode 应用编码。 + * @param loginName 用户的登录名。与流程任务的assignee精确匹配。 + * @param groupIdSet 用户身份分组Id集合。 + * @return 查询后的催办消息列表。 + */ + List getRemindingMessageListByUser( + @Param("tenantId") Long tenantId, + @Param("appCode") String appCode, + @Param("loginName") String loginName, + @Param("groupIdSet") Set groupIdSet); + + /** + * 获取指定用户和身份分组Id集合的抄送消息列表。 + * + * @param tenantId 租户Id。 + * @param appCode 应用编码。 + * @param loginName 用户登录名。 + * @param groupIdSet 用户身份分组Id集合。 + * @param read true表示已读,false表示未读。 + * @return 查询后的抄送消息列表。 + */ + List getCopyMessageListByUser( + @Param("tenantId") Long tenantId, + @Param("appCode") String appCode, + @Param("loginName") String loginName, + @Param("groupIdSet") Set groupIdSet, + @Param("read") Boolean read); + + /** + * 计算当前用户催办消息的数量。 + * + * @param tenantId 租户Id。 + * @param appCode 应用编码。 + * @param loginName 用户登录名。 + * @param groupIdSet 用户身份分组Id集合。 + * @return 数据数量。 + */ + int countRemindingMessageListByUser( + @Param("tenantId") Long tenantId, + @Param("appCode") String appCode, + @Param("loginName") String loginName, + @Param("groupIdSet") Set groupIdSet); + + /** + * 计算当前用户未读抄送消息的数量。 + * + * @param tenantId 租户Id。 + * @param appCode 应用编码。 + * @param loginName 用户登录名。 + * @param groupIdSet 用户身份分组Id集合。 + * @return 数据数量 + */ + int countCopyMessageListByUser( + @Param("tenantId") Long tenantId, + @Param("appCode") String appCode, + @Param("loginName") String loginName, + @Param("groupIdSet") Set groupIdSet); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMultiInstanceTransMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMultiInstanceTransMapper.java new file mode 100644 index 00000000..131e9368 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMultiInstanceTransMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowMultiInstanceTrans; + +/** + * 流程多实例任务执行流水访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowMultiInstanceTransMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowTaskCommentMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowTaskCommentMapper.java new file mode 100644 index 00000000..5da2bf06 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowTaskCommentMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowTaskComment; + +/** + * 流程任务批注数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowTaskCommentMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowTaskExtMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowTaskExtMapper.java new file mode 100644 index 00000000..9145a5e2 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowTaskExtMapper.java @@ -0,0 +1,22 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowTaskExt; + +import java.util.List; + +/** + * 流程任务扩展数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowTaskExtMapper extends BaseDaoMapper { + + /** + * 批量插入流程任务扩展信息列表。 + * + * @param flowTaskExtList 流程任务扩展信息列表。 + */ + void insertList(List flowTaskExtList); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowWorkOrderExtMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowWorkOrderExtMapper.java new file mode 100644 index 00000000..b69fd718 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowWorkOrderExtMapper.java @@ -0,0 +1,14 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowWorkOrderExt; + +/** + * 工作流工单扩展数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowWorkOrderExtMapper extends BaseDaoMapper { + +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowWorkOrderMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowWorkOrderMapper.java new file mode 100644 index 00000000..fe270142 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowWorkOrderMapper.java @@ -0,0 +1,49 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.annotation.EnableDataPerm; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowWorkOrder; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.*; + +/** + * 工作流工单表数据操作访问接口。 + * 如果当前系统支持数据权限过滤,当前用户必须要能看自己的工单数据,所以需要把EnableDataPerm + * 的mustIncludeUserRule参数设置为true,即便当前用户的数据权限中并不包含DataPermRuleType.TYPE_USER_ONLY, + * 数据过滤拦截组件也会自动补偿该类型的数据权限,以便当前用户可以看到自己发起的工单。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EnableDataPerm(mustIncludeUserRule = true) +public interface FlowWorkOrderMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param flowWorkOrderFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getFlowWorkOrderList( + @Param("flowWorkOrderFilter") FlowWorkOrder flowWorkOrderFilter, @Param("orderBy") String orderBy); + + /** + * 计算指定前缀工单编码的最大值。 + * + * @param prefix 工单编码前缀。 + * @return 该工单编码前缀的最大值。 + */ + @Select("SELECT MAX(work_order_code) FROM zz_flow_work_order WHERE work_order_code LIKE '${prefix}'") + String getMaxWorkOrderCodeByPrefix(@Param("prefix") String prefix); + + /** + * 根据工单编码查询指定工单,查询过程也会考虑逻辑删除的数据。 + * @param workOrderCode 工单编码。 + * @return 工单编码的流程工单数量。 + */ + @Select("SELECT COUNT(*) FROM zz_flow_work_order WHERE work_order_code = #{workOrderCode}") + int getCountByWorkOrderCode(@Param("workOrderCode") String workOrderCode); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowCategoryMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowCategoryMapper.xml new file mode 100644 index 00000000..65460911 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowCategoryMapper.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_flow_category.tenant_id IS NULL + + + AND zz_flow_category.tenant_id = #{flowCategoryFilter.tenantId} + + + AND zz_flow_category.app_code IS NULL + + + AND zz_flow_category.app_code = #{flowCategoryFilter.appCode} + + + AND zz_flow_category.name = #{flowCategoryFilter.name} + + + AND zz_flow_category.code = #{flowCategoryFilter.code} + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryMapper.xml new file mode 100644 index 00000000..78351d5d --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryMapper.xml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_flow_entry.tenant_id IS NULL + + + AND zz_flow_entry.tenant_id = #{flowEntryFilter.tenantId} + + + AND zz_flow_entry.app_code IS NULL + + + AND zz_flow_entry.app_code = #{flowEntryFilter.appCode} + + + AND zz_flow_entry.process_definition_name = #{flowEntryFilter.processDefinitionName} + + + AND zz_flow_entry.process_definition_key = #{flowEntryFilter.processDefinitionKey} + + + AND zz_flow_entry.category_id = #{flowEntryFilter.categoryId} + + + AND zz_flow_entry.status = #{flowEntryFilter.status} + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryPublishMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryPublishMapper.xml new file mode 100644 index 00000000..a8c679aa --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryPublishMapper.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryPublishVariableMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryPublishVariableMapper.xml new file mode 100644 index 00000000..68bd83ff --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryPublishVariableMapper.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + INSERT INTO zz_flow_entry_publish_variable VALUES + + (#{item.variableId}, + #{item.entryPublishId}, + #{item.variableName}, + #{item.showName}, + #{item.variableType}, + #{item.bindDatasourceId}, + #{item.bindRelationId}, + #{item.bindColumnId}, + #{item.builtin}) + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryVariableMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryVariableMapper.xml new file mode 100644 index 00000000..09a4ea8e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryVariableMapper.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_flow_entry_variable.entry_id = #{flowEntryVariableFilter.entryId} + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMessageCandidateIdentityMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMessageCandidateIdentityMapper.xml new file mode 100644 index 00000000..5dc31fc7 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMessageCandidateIdentityMapper.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + DELETE FROM zz_flow_msg_candidate_identity a + WHERE EXISTS (SELECT * FROM zz_flow_message b + WHERE a.message_id = b.message_id AND b.process_instance_id = #{processInstanceId}) + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMessageIdentityOperationMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMessageIdentityOperationMapper.xml new file mode 100644 index 00000000..60a8e4a0 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMessageIdentityOperationMapper.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + DELETE FROM zz_flow_msg_identity_operation a + WHERE EXISTS (SELECT * FROM zz_flow_message b + WHERE a.message_id = b.message_id AND b.process_instance_id = #{processInstanceId}) + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMessageMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMessageMapper.xml new file mode 100644 index 00000000..2fcd87f5 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMessageMapper.xml @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND a.tenant_id IS NULL + + + AND a.tenant_id = #{tenantId} + + + AND a.app_code IS NULL + + + AND a.app_code = #{appCode} + + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMultiInstanceTransMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMultiInstanceTransMapper.xml new file mode 100644 index 00000000..732758a2 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMultiInstanceTransMapper.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowTaskCommentMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowTaskCommentMapper.xml new file mode 100644 index 00000000..69323d82 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowTaskCommentMapper.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowTaskExtMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowTaskExtMapper.xml new file mode 100644 index 00000000..2fca8da4 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowTaskExtMapper.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + INSERT INTO zz_flow_task_ext VALUES + + (#{item.processDefinitionId}, + #{item.taskId}, + #{item.operationListJson}, + #{item.variableListJson}, + #{item.assigneeListJson}, + #{item.groupType}, + #{item.deptPostListJson}, + #{item.roleIds}, + #{item.deptIds}, + #{item.candidateUsernames}, + #{item.copyListJson}, + #{item.extraDataJson}) + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowWorkOrderExtMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowWorkOrderExtMapper.xml new file mode 100644 index 00000000..2d3867d3 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowWorkOrderExtMapper.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowWorkOrderMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowWorkOrderMapper.xml new file mode 100644 index 00000000..24da5a15 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowWorkOrderMapper.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_flow_work_order.deleted_flag = ${@com.orangeforms.common.core.constant.GlobalDeletedFlag@NORMAL} + + + + + + + AND zz_flow_work_order.tenant_id IS NULL + + + AND zz_flow_work_order.tenant_id = #{flowWorkOrderFilter.tenantId} + + + AND zz_flow_work_order.app_code IS NULL + + + AND zz_flow_work_order.app_code = #{flowWorkOrderFilter.appCode} + + + AND zz_flow_work_order.work_order_code = #{flowWorkOrderFilter.workOrderCode} + + + AND zz_flow_work_order.process_definition_key = #{flowWorkOrderFilter.processDefinitionKey} + + + AND zz_flow_work_order.latest_approval_status = #{flowWorkOrderFilter.latestApprovalStatus} + + + AND zz_flow_work_order.flow_status = #{flowWorkOrderFilter.flowStatus} + + + AND zz_flow_work_order.create_time >= #{flowWorkOrderFilter.createTimeStart} + + + AND zz_flow_work_order.create_time <= #{flowWorkOrderFilter.createTimeEnd} + + + AND zz_flow_work_order.create_user_id = #{flowWorkOrderFilter.createUserId} + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowCategoryDto.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowCategoryDto.java new file mode 100644 index 00000000..05b4b875 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowCategoryDto.java @@ -0,0 +1,47 @@ +package com.orangeforms.common.flow.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import com.orangeforms.common.core.validator.UpdateGroup; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 流程分类的Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "流程分类的Dto对象") +@Data +public class FlowCategoryDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long categoryId; + + /** + * 显示名称。 + */ + @Schema(description = "显示名称") + @NotBlank(message = "数据验证失败,显示名称不能为空!") + private String name; + + /** + * 分类编码。 + */ + @Schema(description = "分类编码") + @NotBlank(message = "数据验证失败,分类编码不能为空!") + private String code; + + /** + * 实现顺序。 + */ + @Schema(description = "实现顺序") + @NotNull(message = "数据验证失败,实现顺序不能为空!") + private Integer showOrder; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowEntryDto.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowEntryDto.java new file mode 100644 index 00000000..817ae003 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowEntryDto.java @@ -0,0 +1,107 @@ +package com.orangeforms.common.flow.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import com.orangeforms.common.core.validator.ConstDictRef; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.flow.model.constant.FlowBindFormType; +import com.orangeforms.common.flow.model.constant.FlowEntryStatus; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 流程的Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "流程的Dto对象") +@Data +public class FlowEntryDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键不能为空!", groups = {UpdateGroup.class}) + private Long entryId; + + /** + * 流程名称。 + */ + @Schema(description = "流程名称") + @NotBlank(message = "数据验证失败,流程名称不能为空!") + private String processDefinitionName; + + /** + * 流程标识Key。 + */ + @Schema(description = "流程标识Key") + @NotBlank(message = "数据验证失败,流程标识Key不能为空!") + private String processDefinitionKey; + + /** + * 流程分类。 + */ + @Schema(description = "流程分类") + @NotNull(message = "数据验证失败,流程分类不能为空!") + private Long categoryId; + + /** + * 流程状态。 + */ + @Schema(description = "流程状态") + @ConstDictRef(constDictClass = FlowEntryStatus.class, message = "数据验证失败,工作流状态为无效值!") + private Integer status; + + /** + * 流程定义的xml。 + */ + @Schema(description = "流程定义的xml") + private String bpmnXml; + + /** + * 流程图类型。0: 普通流程图,1: 钉钉风格的流程图。 + */ + @Schema(description = "流程图类型。0: 普通流程图,1: 钉钉风格的流程图") + private Integer diagramType; + + /** + * 绑定表单类型。 + */ + @Schema(description = "绑定表单类型") + @ConstDictRef(constDictClass = FlowBindFormType.class, message = "数据验证失败,工作流绑定表单类型为无效值!") + @NotNull(message = "数据验证失败,工作流绑定表单类型不能为空!") + private Integer bindFormType; + + /** + * 在线表单的页面Id。 + */ + @Schema(description = "在线表单的页面Id") + private Long pageId; + + /** + * 在线表单的缺省路由名称。 + */ + @Schema(description = "在线表单的缺省路由名称") + private String defaultRouterName; + + /** + * 在线表单Id。 + */ + @Schema(description = "在线表单Id") + private Long defaultFormId; + + /** + * 工单表编码字段的编码规则,如果为空则不计算工单编码。 + */ + @Schema(description = "工单表编码字段的编码规则") + private String encodedRule; + + /** + * 流程的自定义扩展数据(JSON格式)。 + */ + @Schema(description = "流程的自定义扩展数据") + private String extensionData; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowEntryVariableDto.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowEntryVariableDto.java new file mode 100644 index 00000000..75659d13 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowEntryVariableDto.java @@ -0,0 +1,81 @@ +package com.orangeforms.common.flow.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import com.orangeforms.common.core.validator.ConstDictRef; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.flow.model.constant.FlowVariableType; +import lombok.Data; + +import jakarta.validation.constraints.*; + +/** + * 流程变量Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "流程变量Dto对象") +@Data +public class FlowEntryVariableDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long variableId; + + /** + * 流程Id。 + */ + @Schema(description = "流程Id") + @NotNull(message = "数据验证失败,流程Id不能为空!") + private Long entryId; + + /** + * 变量名。 + */ + @Schema(description = "变量名") + @NotBlank(message = "数据验证失败,变量名不能为空!") + private String variableName; + + /** + * 显示名。 + */ + @Schema(description = "显示名") + @NotBlank(message = "数据验证失败,显示名不能为空!") + private String showName; + + /** + * 流程变量类型。 + */ + @Schema(description = "流程变量类型") + @ConstDictRef(constDictClass = FlowVariableType.class, message = "数据验证失败,流程变量类型为无效值!") + @NotNull(message = "数据验证失败,流程变量类型不能为空!") + private Integer variableType; + + /** + * 绑定数据源Id。 + */ + @Schema(description = "绑定数据源Id") + private Long bindDatasourceId; + + /** + * 绑定数据源关联Id。 + */ + @Schema(description = "绑定数据源关联Id") + private Long bindRelationId; + + /** + * 绑定字段Id。 + */ + @Schema(description = "绑定字段Id") + private Long bindColumnId; + + /** + * 是否内置。 + */ + @Schema(description = "是否内置") + @NotNull(message = "数据验证失败,是否内置不能为空!") + private Boolean builtin; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowMessageDto.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowMessageDto.java new file mode 100644 index 00000000..0d616e97 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowMessageDto.java @@ -0,0 +1,51 @@ +package com.orangeforms.common.flow.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 工作流通知消息Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "工作流通知消息Dto对象") +@Data +public class FlowMessageDto { + + /** + * 消息类型。 + */ + @Schema(description = "消息类型") + private Integer messageType; + + /** + * 工单Id。 + */ + @Schema(description = "工单Id") + private Long workOrderId; + + /** + * 流程名称。 + */ + @Schema(description = "流程名称") + private String processDefinitionName; + + /** + * 流程任务名称。 + */ + @Schema(description = "流程任务名称") + private String taskName; + + /** + * 更新时间范围过滤起始值(>=)。 + */ + @Schema(description = "updateTime 范围过滤起始值") + private String updateTimeStart; + + /** + * 更新时间范围过滤结束值(<=)。 + */ + @Schema(description = "updateTime 范围过滤结束值") + private String updateTimeEnd; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowTaskCommentDto.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowTaskCommentDto.java new file mode 100644 index 00000000..4af04f6e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowTaskCommentDto.java @@ -0,0 +1,38 @@ +package com.orangeforms.common.flow.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 流程任务的批注。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "流程任务的批注") +@Data +public class FlowTaskCommentDto { + + /** + * 流程任务触发按钮类型,内置值可参考FlowTaskButton。 + */ + @Schema(description = "流程任务触发按钮类型") + @NotNull(message = "数据验证失败,任务的审批类型不能为空!") + private String approvalType; + + /** + * 流程任务的批注内容。 + */ + @Schema(description = "流程任务的批注内容") + @NotBlank(message = "数据验证失败,任务审批内容不能为空!") + private String taskComment; + + /** + * 委托指定人,比如加签、转办等。 + */ + @Schema(description = "委托指定人,比如加签、转办等") + private String delegateAssignee; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowWorkOrderDto.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowWorkOrderDto.java new file mode 100644 index 00000000..f87c94c5 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowWorkOrderDto.java @@ -0,0 +1,39 @@ +package com.orangeforms.common.flow.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 工作流工单Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "工作流工单Dto对象") +@Data +public class FlowWorkOrderDto { + + /** + * 工单编码。 + */ + @Schema(description = "工单编码") + private String workOrderCode; + + /** + * 流程状态。参考FlowTaskStatus常量值对象。 + */ + @Schema(description = "流程状态") + private Integer flowStatus; + + /** + * createTime 范围过滤起始值(>=)。 + */ + @Schema(description = "createTime 范围过滤起始值") + private String createTimeStart; + + /** + * createTime 范围过滤结束值(<=)。 + */ + @Schema(description = "createTime 范围过滤结束值") + private String createTimeEnd; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/exception/FlowEmptyUserException.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/exception/FlowEmptyUserException.java new file mode 100644 index 00000000..02784712 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/exception/FlowEmptyUserException.java @@ -0,0 +1,21 @@ +package com.orangeforms.common.flow.exception; + +import org.flowable.common.engine.api.FlowableException; + +/** + * 流程空用户异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class FlowEmptyUserException extends FlowableException { + + /** + * 构造函数。 + * + * @param msg 错误信息。 + */ + public FlowEmptyUserException(String msg) { + super(msg); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/exception/FlowOperationException.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/exception/FlowOperationException.java new file mode 100644 index 00000000..313571e1 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/exception/FlowOperationException.java @@ -0,0 +1,35 @@ +package com.orangeforms.common.flow.exception; + +/** + * 流程操作异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class FlowOperationException extends RuntimeException { + + /** + * 构造函数。 + */ + public FlowOperationException() { + + } + + /** + * 构造函数。 + * + * @param throwable 引发异常对象。 + */ + public FlowOperationException(Throwable throwable) { + super(throwable); + } + + /** + * 构造函数。 + * + * @param msg 错误信息。 + */ + public FlowOperationException(String msg) { + super(msg); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/AutoSkipTaskListener.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/AutoSkipTaskListener.java new file mode 100644 index 00000000..4c1fce9f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/AutoSkipTaskListener.java @@ -0,0 +1,165 @@ +package com.orangeforms.common.flow.listener; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.text.StrFormatter; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.ApplicationContextHolder; +import com.orangeforms.common.flow.constant.FlowApprovalType; +import com.orangeforms.common.flow.constant.FlowConstant; +import com.orangeforms.common.flow.model.FlowTaskComment; +import com.orangeforms.common.flow.model.FlowTaskExt; +import com.orangeforms.common.flow.object.FlowTaskOperation; +import com.orangeforms.common.flow.service.FlowApiService; +import com.orangeforms.common.flow.service.FlowTaskCommentService; +import com.orangeforms.common.flow.service.FlowTaskExtService; +import lombok.extern.slf4j.Slf4j; +import org.flowable.bpmn.model.ExtensionAttribute; +import org.flowable.bpmn.model.UserTask; +import org.flowable.engine.delegate.TaskListener; +import org.flowable.task.api.Task; +import org.flowable.task.service.delegate.DelegateTask; + +import java.util.*; + +/** + * 流程任务自动审批跳过的监听器。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class AutoSkipTaskListener implements TaskListener { + + private final transient FlowTaskCommentService flowTaskCommentService = + ApplicationContextHolder.getBean(FlowTaskCommentService.class); + private final transient FlowApiService flowApiService = + ApplicationContextHolder.getBean(FlowApiService.class); + private final transient FlowTaskExtService flowTaskExtService = + ApplicationContextHolder.getBean(FlowTaskExtService.class); + + /** + * 流程的发起者等于当前任务的Assignee。 + */ + private static final String EQ_START_USER = "0"; + /** + * 上一步的提交者等于当前任务的Assignee。 + */ + private static final String EQ_PREV_SUBMIT_USER = "1"; + /** + * 当前任务的Assignee之前提交过审核。 + */ + private static final String EQ_HISTORIC_SUBMIT_USER = "2"; + + @Override + public void notify(DelegateTask t) { + UserTask userTask = flowApiService.getUserTask(t.getProcessDefinitionId(), t.getTaskDefinitionKey()); + List attributes = userTask.getAttributes().get(FlowConstant.USER_TASK_AUTO_SKIP_KEY); + Set skipTypes = new HashSet<>(StrUtil.split(attributes.get(0).getValue(), ",")); + String assignedUser = this.getAssignedUser(userTask, t.getProcessDefinitionId(), t.getExecutionId()); + if (StrUtil.isBlank(assignedUser)) { + return; + } + for (String skipType : skipTypes) { + if (this.verifyAndHandle(userTask, t, skipType, assignedUser)) { + return; + } + } + } + + private boolean verifyAndHandle(UserTask userTask, DelegateTask task, String skipType, String assignedUser) { + FlowTaskComment comment = null; + switch (skipType) { + case EQ_START_USER: + Object v = task.getVariable(FlowConstant.PROC_INSTANCE_START_USER_NAME_VAR); + if (ObjectUtil.equal(v, assignedUser)) { + comment = flowTaskCommentService.getFirstFlowTaskComment(task.getProcessInstanceId()); + } + break; + case EQ_PREV_SUBMIT_USER: + Object v2 = task.getVariable(FlowConstant.SUBMIT_USER_VAR); + if (ObjectUtil.equal(v2, assignedUser)) { + TokenData tokenData = TokenData.takeFromRequest(); + comment = new FlowTaskComment(); + comment.setCreateUserId(tokenData.getUserId()); + comment.setCreateLoginName(tokenData.getLoginName()); + comment.setCreateUsername(tokenData.getShowName()); + } + break; + case EQ_HISTORIC_SUBMIT_USER: + List comments = + flowTaskCommentService.getFlowTaskCommentList(task.getProcessInstanceId()); + List resultComments = new LinkedList<>(); + for (FlowTaskComment c : comments) { + if (StrUtil.equals(c.getCreateLoginName(), assignedUser)) { + resultComments.add(c); + } + } + if (CollUtil.isNotEmpty(resultComments)) { + comment = resultComments.get(0); + } + break; + default: + break; + } + if (comment != null) { + FlowTaskExt flowTaskExt = flowTaskExtService + .getByProcessDefinitionIdAndTaskId(task.getProcessDefinitionId(), userTask.getId()); + JSONObject taskVariableData = new JSONObject(); + if (StrUtil.isNotBlank(flowTaskExt.getOperationListJson())) { + List taskOperationList = + JSONArray.parseArray(flowTaskExt.getOperationListJson(), FlowTaskOperation.class); + taskOperationList.stream() + .filter(op -> op.getType().equals(FlowApprovalType.AGREE)) + .map(FlowTaskOperation::getLatestApprovalStatus).findFirst() + .ifPresent(status -> taskVariableData.put(FlowConstant.LATEST_APPROVAL_STATUS_KEY, status)); + } + Task t = flowApiService.getTaskById(task.getId()); + comment.fillWith(t); + comment.setApprovalType(FlowApprovalType.AGREE); + comment.setTaskComment(StrFormatter.format("自动跳过审批。审批人 [{}], 跳过原因 [{}]。", + userTask.getAssignee(), this.getMessageBySkipType(skipType))); + flowApiService.completeTask(t, comment, taskVariableData); + } + return comment != null; + } + + private String getAssignedUser(UserTask userTask, String processDefinitionId, String executionId) { + String assignedUser = userTask.getAssignee(); + if (StrUtil.isNotBlank(assignedUser)) { + if (assignedUser.startsWith("${") && assignedUser.endsWith("}")) { + String variableName = assignedUser.substring(2, assignedUser.length() - 1); + assignedUser = flowApiService.getExecutionVariableStringWithSafe(executionId, variableName); + } + } else { + FlowTaskExt flowTaskExt = flowTaskExtService + .getByProcessDefinitionIdAndTaskId(processDefinitionId, userTask.getId()); + List candidateUsernames; + if (StrUtil.isBlank(flowTaskExt.getCandidateUsernames())) { + candidateUsernames = Collections.emptyList(); + } else if (!StrUtil.equals(flowTaskExt.getCandidateUsernames(), "${" + FlowConstant.TASK_APPOINTED_ASSIGNEE_VAR + "}")) { + candidateUsernames = StrUtil.split(flowTaskExt.getCandidateUsernames(), ","); + } else { + String value = flowApiService + .getExecutionVariableStringWithSafe(executionId, FlowConstant.TASK_APPOINTED_ASSIGNEE_VAR); + candidateUsernames = value == null ? null : StrUtil.split(value, ","); + } + if (candidateUsernames != null && candidateUsernames.size() == 1) { + assignedUser = candidateUsernames.get(0); + } + } + return assignedUser; + } + + private String getMessageBySkipType(String skipType) { + return switch (skipType) { + case EQ_PREV_SUBMIT_USER -> "审批人与上一审批节点处理人相同"; + case EQ_START_USER -> "审批人为发起人"; + case EQ_HISTORIC_SUBMIT_USER -> "审批人审批过"; + default -> ""; + }; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/DeptPostLeaderListener.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/DeptPostLeaderListener.java new file mode 100644 index 00000000..7f47ecca --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/DeptPostLeaderListener.java @@ -0,0 +1,27 @@ +package com.orangeforms.common.flow.listener; + +import com.orangeforms.common.flow.constant.FlowConstant; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.delegate.TaskListener; +import org.flowable.task.service.delegate.DelegateTask; + +import java.util.Map; + +/** + * 当用户任务的候选组为本部门领导岗位时,该监听器会在任务创建时,获取当前流程实例发起人的部门领导。 + * 并将其指派为当前任务的候选组。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class DeptPostLeaderListener implements TaskListener { + + @Override + public void notify(DelegateTask delegateTask) { + Map variables = delegateTask.getVariables(); + if (variables.get(FlowConstant.GROUP_TYPE_DEPT_POST_LEADER_VAR) == null) { + delegateTask.setAssignee(variables.get(FlowConstant.PROC_INSTANCE_START_USER_NAME_VAR).toString()); + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/FlowFinishedListener.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/FlowFinishedListener.java new file mode 100644 index 00000000..43f7563f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/FlowFinishedListener.java @@ -0,0 +1,56 @@ +package com.orangeforms.common.flow.listener; + +import cn.hutool.core.util.StrUtil; +import com.orangeforms.common.core.object.GlobalThreadLocal; +import com.orangeforms.common.core.util.ApplicationContextHolder; +import com.orangeforms.common.flow.model.FlowWorkOrder; +import com.orangeforms.common.flow.service.FlowWorkOrderService; +import com.orangeforms.common.flow.constant.FlowTaskStatus; +import com.orangeforms.common.flow.util.FlowCustomExtFactory; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.delegate.DelegateExecution; +import org.flowable.engine.delegate.ExecutionListener; + +/** + * 流程实例监听器,在流程实例结束的时候,需要完成一些自定义的业务行为。如: + * 1. 更新流程工单表的审批状态字段。 + * 2. 业务数据同步。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class FlowFinishedListener implements ExecutionListener { + + private final transient FlowWorkOrderService flowWorkOrderService = + ApplicationContextHolder.getBean(FlowWorkOrderService.class); + private final transient FlowCustomExtFactory flowCustomExtFactory = + ApplicationContextHolder.getBean(FlowCustomExtFactory.class); + + @Override + public void notify(DelegateExecution execution) { + if (!StrUtil.equals("end", execution.getEventName())) { + return; + } + boolean enabled = GlobalThreadLocal.setDataFilter(false); + try { + String processInstanceId = execution.getProcessInstanceId(); + FlowWorkOrder workOrder = flowWorkOrderService.getFlowWorkOrderByProcessInstanceId(processInstanceId); + if (workOrder == null) { + return; + } + int flowStatus = FlowTaskStatus.FINISHED; + if (workOrder.getFlowStatus().equals(FlowTaskStatus.CANCELLED) + || workOrder.getFlowStatus().equals(FlowTaskStatus.STOPPED)) { + flowStatus = workOrder.getFlowStatus(); + } + workOrder.setFlowStatus(flowStatus); + // 更新流程工单中的流程状态。 + flowWorkOrderService.updateFlowStatusByProcessInstanceId(processInstanceId, flowStatus); + // 处理在线表单工作流的自定义状态更新。 + flowCustomExtFactory.getOnlineBusinessDataExtHelper().updateFlowStatus(workOrder); + } finally { + GlobalThreadLocal.setDataFilter(enabled); + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/FlowTaskNotifyListener.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/FlowTaskNotifyListener.java new file mode 100644 index 00000000..ba8e09ad --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/FlowTaskNotifyListener.java @@ -0,0 +1,80 @@ +package com.orangeforms.common.flow.listener; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.orangeforms.common.core.util.ApplicationContextHolder; +import com.orangeforms.common.flow.constant.FlowConstant; +import com.orangeforms.common.flow.model.FlowTaskExt; +import com.orangeforms.common.flow.object.FlowUserTaskExtData; +import com.orangeforms.common.flow.service.FlowApiService; +import com.orangeforms.common.flow.service.FlowTaskExtService; +import com.orangeforms.common.flow.util.BaseFlowNotifyExtHelper; +import com.orangeforms.common.flow.util.FlowCustomExtFactory; +import com.orangeforms.common.flow.vo.FlowTaskVo; +import com.orangeforms.common.flow.vo.FlowUserInfoVo; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.delegate.TaskListener; +import org.flowable.engine.runtime.ProcessInstance; +import org.flowable.task.api.Task; +import org.flowable.task.service.delegate.DelegateTask; + +import java.util.List; + +/** + * 任务进入待办状态时的通知监听器。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class FlowTaskNotifyListener implements TaskListener { + + private final transient FlowTaskExtService flowTaskExtService = + ApplicationContextHolder.getBean(FlowTaskExtService.class); + private final transient FlowApiService flowApiService = + ApplicationContextHolder.getBean(FlowApiService.class); + private final transient FlowCustomExtFactory flowCustomExtFactory = + ApplicationContextHolder.getBean(FlowCustomExtFactory.class); + + @Override + public void notify(DelegateTask delegateTask) { + String definitionId = delegateTask.getProcessDefinitionId(); + String instanceId = delegateTask.getProcessInstanceId(); + String taskId = delegateTask.getId(); + String taskKey = delegateTask.getTaskDefinitionKey(); + FlowTaskExt taskExt = flowTaskExtService.getByProcessDefinitionIdAndTaskId(definitionId, taskKey); + if (StrUtil.isBlank(taskExt.getExtraDataJson())) { + return; + } + FlowUserTaskExtData extData = JSON.parseObject(taskExt.getExtraDataJson(), FlowUserTaskExtData.class); + if (CollUtil.isEmpty(extData.getFlowNotifyTypeList())) { + return; + } + ProcessInstance instance = flowApiService.getProcessInstance(instanceId); + Object initiator = flowApiService.getProcessInstanceVariable(instanceId, FlowConstant.PROC_INSTANCE_INITIATOR_VAR); + boolean isMultiInstanceTask = flowApiService.isMultiInstanceTask(definitionId, taskKey); + Task task = flowApiService.getProcessInstanceActiveTask(instanceId, taskId); + List userInfoList = + flowTaskExtService.getCandidateUserInfoList(instanceId, taskExt, task, isMultiInstanceTask, false); + if (CollUtil.isEmpty(userInfoList)) { + log.warn("ProcessDefinition [{}] Task [{}] don't find the candidate users for notification.", + instance.getProcessDefinitionName(), task.getName()); + return; + } + BaseFlowNotifyExtHelper helper = flowCustomExtFactory.getFlowNotifyExtHelper(); + Assert.notNull(helper); + for (String notifyType : extData.getFlowNotifyTypeList()) { + FlowTaskVo flowTaskVo = new FlowTaskVo(); + flowTaskVo.setProcessDefinitionId(definitionId); + flowTaskVo.setProcessInstanceId(instanceId); + flowTaskVo.setTaskKey(taskKey); + flowTaskVo.setTaskName(delegateTask.getName()); + flowTaskVo.setTaskId(delegateTask.getId()); + flowTaskVo.setBusinessKey(instance.getBusinessKey()); + flowTaskVo.setProcessInstanceInitiator(initiator.toString()); + helper.doNotify(notifyType, userInfoList, flowTaskVo); + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/FlowUserTaskListener.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/FlowUserTaskListener.java new file mode 100644 index 00000000..6760fcc4 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/FlowUserTaskListener.java @@ -0,0 +1,32 @@ +package com.orangeforms.common.flow.listener; + +import com.orangeforms.common.core.util.ApplicationContextHolder; +import com.orangeforms.common.flow.constant.FlowConstant; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.RuntimeService; +import org.flowable.engine.delegate.TaskListener; +import org.flowable.task.service.delegate.DelegateTask; + +import java.util.Map; + +/** + * 流程任务通用监听器。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class FlowUserTaskListener implements TaskListener { + + private final transient RuntimeService runtimeService = + ApplicationContextHolder.getBean(RuntimeService.class); + + @Override + public void notify(DelegateTask delegateTask) { + Map variables = delegateTask.getVariables(); + if (variables.get(FlowConstant.DELEGATE_ASSIGNEE_VAR) != null) { + delegateTask.setAssignee(variables.get(FlowConstant.DELEGATE_ASSIGNEE_VAR).toString()); + runtimeService.removeVariableLocal(delegateTask.getExecutionId(), FlowConstant.DELEGATE_ASSIGNEE_VAR); + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/UpDeptPostLeaderListener.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/UpDeptPostLeaderListener.java new file mode 100644 index 00000000..f29d6cbb --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/UpDeptPostLeaderListener.java @@ -0,0 +1,27 @@ +package com.orangeforms.common.flow.listener; + +import com.orangeforms.common.flow.constant.FlowConstant; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.delegate.TaskListener; +import org.flowable.task.service.delegate.DelegateTask; + +import java.util.Map; + +/** + * 当用户任务的候选组为上级部门领导岗位时,该监听器会在任务创建时,获取当前流程实例发起人的部门领导。 + * 并将其指派为当前任务的候选组。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class UpDeptPostLeaderListener implements TaskListener { + + @Override + public void notify(DelegateTask delegateTask) { + Map variables = delegateTask.getVariables(); + if (variables.get(FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER_VAR) == null) { + delegateTask.setAssignee(variables.get(FlowConstant.PROC_INSTANCE_START_USER_NAME_VAR).toString()); + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/UpdateLatestApprovalStatusListener.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/UpdateLatestApprovalStatusListener.java new file mode 100644 index 00000000..4b7144da --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/UpdateLatestApprovalStatusListener.java @@ -0,0 +1,44 @@ +package com.orangeforms.common.flow.listener; + +import cn.hutool.core.util.StrUtil; +import com.orangeforms.common.core.util.ApplicationContextHolder; +import com.orangeforms.common.flow.model.FlowWorkOrder; +import com.orangeforms.common.flow.service.FlowWorkOrderService; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.delegate.DelegateExecution; +import org.flowable.engine.delegate.ExecutionListener; +import org.flowable.engine.impl.el.FixedValue; + +/** + * 更新流程的最后审批状态的监听器,目前用于排他网关到任务结束节点的连线上, + * 以便于准确的判断流程实例的最后审批状态。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class UpdateLatestApprovalStatusListener implements ExecutionListener { + + private FixedValue latestApprovalStatus; + + private final transient FlowWorkOrderService flowWorkOrderService = + ApplicationContextHolder.getBean(FlowWorkOrderService.class); + + public void setAutoStoreVariablesExp(FixedValue approvalStatus) { + this.latestApprovalStatus = approvalStatus; + } + + @Override + public void notify(DelegateExecution execution) { + if (StrUtil.isNotBlank(latestApprovalStatus.getExpressionText())) { + FlowWorkOrder workOrder = + flowWorkOrderService.getFlowWorkOrderByProcessInstanceId(execution.getProcessInstanceId()); + if (workOrder == null) { + return; + } + Integer approvalStatus = Integer.valueOf(latestApprovalStatus.getExpressionText()); + String processInstanceId = execution.getProcessInstanceId(); + flowWorkOrderService.updateLatestApprovalStatusByProcessInstanceId(processInstanceId, approvalStatus); + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowCategory.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowCategory.java new file mode 100644 index 00000000..2b78ff69 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowCategory.java @@ -0,0 +1,77 @@ +package com.orangeforms.common.flow.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; + +import java.util.Date; + +/** + * 流程分类的实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_flow_category") +public class FlowCategory { + + /** + * 主键Id。 + */ + @Id(value = "category_id") + private Long categoryId; + + /** + * 租户Id。 + */ + @Column(value = "tenant_id") + private Long tenantId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Column(value = "app_code") + private String appCode; + + /** + * 显示名称。 + */ + @Column(value = "name") + private String name; + + /** + * 分类编码。 + */ + @Column(value = "code") + private String code; + + /** + * 实现顺序。 + */ + @Column(value = "show_order") + private Integer showOrder; + + /** + * 更新时间。 + */ + @Column(value = "update_time") + private Date updateTime; + + /** + * 更新者Id。 + */ + @Column(value = "update_user_id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @Column(value = "create_time") + private Date createTime; + + /** + * 创建者Id。 + */ + @Column(value = "create_user_id") + private Long createUserId; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntry.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntry.java new file mode 100644 index 00000000..ceea833f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntry.java @@ -0,0 +1,154 @@ +package com.orangeforms.common.flow.model; + +import com.mybatisflex.annotation.*; +import com.orangeforms.common.core.annotation.RelationOneToOne; +import lombok.Data; + +import java.util.Date; + +/** + * 流程的实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_flow_entry") +public class FlowEntry { + + /** + * 主键。 + */ + @Id(value = "entry_id") + private Long entryId; + + /** + * 租户Id。 + */ + @Column(value = "tenant_id") + private Long tenantId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Column(value = "app_code") + private String appCode; + + /** + * 流程名称。 + */ + @Column(value = "process_definition_name") + private String processDefinitionName; + + /** + * 流程标识Key。 + */ + @Column(value = "process_definition_key") + private String processDefinitionKey; + + /** + * 流程分类。 + */ + @Column(value = "category_id") + private Long categoryId; + + /** + * 工作流部署的发布主版本Id。 + */ + @Column(value = "main_entry_publish_id") + private Long mainEntryPublishId; + + /** + * 最新发布时间。 + */ + @Column(value = "latest_publish_time") + private Date latestPublishTime; + + /** + * 流程状态。 + */ + @Column(value = "status") + private Integer status; + + /** + * 流程定义的xml。 + */ + @Column(value = "bpmn_xml") + private String bpmnXml; + + /** + * 流程图类型。0: 普通流程图,1: 钉钉风格的流程图。 + */ + @Column(value = "diagram_type") + private Integer diagramType; + + /** + * 绑定表单类型。 + */ + @Column(value = "bind_form_type") + private Integer bindFormType; + + /** + * 在线表单的页面Id。 + */ + @Column(value = "page_id") + private Long pageId; + + /** + * 在线表单Id。 + */ + @Column(value = "default_form_id") + private Long defaultFormId; + + /** + * 静态表单的缺省路由名称。 + */ + @Column(value = "default_router_name") + private String defaultRouterName; + + /** + * 工单表编码字段的编码规则,如果为空则不计算工单编码。 + */ + @Column(value = "encoded_rule") + private String encodedRule; + + /** + * 流程的自定义扩展数据(JSON格式)。 + */ + @Column(value = "extension_data") + private String extensionData; + + /** + * 更新时间。 + */ + @Column(value = "update_time") + private Date updateTime; + + /** + * 更新者Id。 + */ + @Column(value = "update_user_id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @Column(value = "create_time") + private Date createTime; + + /** + * 创建者Id。 + */ + @Column(value = "create_user_id") + private Long createUserId; + + @Column(ignore = true) + private FlowEntryPublish mainFlowEntryPublish; + + @RelationOneToOne( + masterIdField = "categoryId", + slaveModelClass = FlowCategory.class, + slaveIdField = "categoryId") + @Column(ignore = true) + private FlowCategory flowCategory; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntryPublish.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntryPublish.java new file mode 100644 index 00000000..21e4c774 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntryPublish.java @@ -0,0 +1,89 @@ +package com.orangeforms.common.flow.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; + +import java.util.Date; + +/** + * 流程发布数据的实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_flow_entry_publish") +public class FlowEntryPublish { + + /** + * 主键Id。 + */ + @Id(value = "entry_publish_id") + private Long entryPublishId; + + /** + * 流程Id。 + */ + @Column(value = "entry_id") + private Long entryId; + + /** + * 流程引擎的部署Id。 + */ + @Column(value = "deploy_id") + private String deployId; + + /** + * 流程引擎中的流程定义Id。 + */ + @Column(value = "process_definition_id") + private String processDefinitionId; + + /** + * 发布版本。 + */ + @Column(value = "publish_version") + private Integer publishVersion; + + /** + * 激活状态。 + */ + @Column(value = "active_status") + private Boolean activeStatus; + + /** + * 是否为主版本。 + */ + @Column(value = "main_version") + private Boolean mainVersion; + + /** + * 创建者Id。 + */ + @Column(value = "create_user_id") + private Long createUserId; + + /** + * 发布时间。 + */ + @Column(value = "publish_time") + private Date publishTime; + + /** + * 第一个非开始节点任务的附加信息。 + */ + @Column(value = "init_task_info") + private String initTaskInfo; + + /** + * 分析后的节点JSON信息。 + */ + @Column(value = "analyzed_node_json") + private String analyzedNodeJson; + + /** + * 流程的自定义扩展数据(JSON格式)。 + */ + @Column(value = "extension_data") + private String extensionData; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntryPublishVariable.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntryPublishVariable.java new file mode 100644 index 00000000..da09c1b5 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntryPublishVariable.java @@ -0,0 +1,69 @@ +package com.orangeforms.common.flow.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; + +/** + * FlowEntryPublishVariable实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_flow_entry_publish_variable") +public class FlowEntryPublishVariable { + + /** + * 主键Id。 + */ + @Id(value = "variable_id") + private Long variableId; + + /** + * 流程Id。 + */ + @Column(value = "entry_publish_id") + private Long entryPublishId; + + /** + * 变量名。 + */ + @Column(value = "variable_name") + private String variableName; + + /** + * 显示名。 + */ + @Column(value = "show_name") + private String showName; + + /** + * 变量类型。 + */ + @Column(value = "variable_type") + private Integer variableType; + + /** + * 是否内置。 + */ + @Column(value = "builtin") + private Boolean builtin; + + /** + * 绑定数据源Id。 + */ + @Column(value = "bind_datasource_id") + private Long bindDatasourceId; + + /** + * 绑定数据源关联Id。 + */ + @Column(value = "bind_relation_id") + private Long bindRelationId; + + /** + * 绑定字段Id。 + */ + @Column(value = "bind_column_id") + private Long bindColumnId; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntryVariable.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntryVariable.java new file mode 100644 index 00000000..1e05bc6a --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntryVariable.java @@ -0,0 +1,77 @@ +package com.orangeforms.common.flow.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; + +import java.util.Date; + +/** + * 流程变量实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_flow_entry_variable") +public class FlowEntryVariable { + + /** + * 主键Id。 + */ + @Id(value = "variable_id") + private Long variableId; + + /** + * 流程Id。 + */ + @Column(value = "entry_id") + private Long entryId; + + /** + * 变量名。 + */ + @Column(value = "variable_name") + private String variableName; + + /** + * 显示名。 + */ + @Column(value = "show_name") + private String showName; + + /** + * 流程变量类型。 + */ + @Column(value = "variable_type") + private Integer variableType; + + /** + * 绑定数据源Id。 + */ + @Column(value = "bind_datasource_id") + private Long bindDatasourceId; + + /** + * 绑定数据源关联Id。 + */ + @Column(value = "bind_relation_id") + private Long bindRelationId; + + /** + * 绑定字段Id。 + */ + @Column(value = "bind_column_id") + private Long bindColumnId; + + /** + * 是否内置。 + */ + @Column(value = "builtin") + private Boolean builtin; + + /** + * 创建时间。 + */ + @Column(value = "create_time") + private Date createTime; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMessage.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMessage.java new file mode 100644 index 00000000..f0c977fe --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMessage.java @@ -0,0 +1,167 @@ +package com.orangeforms.common.flow.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; + +import java.util.Date; + +/** + * 工作流通知消息实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_flow_message") +public class FlowMessage { + + /** + * 主键Id。 + */ + @Id(value = "message_id") + private Long messageId; + + /** + * 租户Id。 + */ + @Column(value = "tenant_id") + private Long tenantId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Column(value = "app_code") + private String appCode; + + /** + * 消息类型。 + */ + @Column(value = "message_type") + private Integer messageType; + + /** + * 消息内容。 + */ + @Column(value = "message_content") + private String messageContent; + + /** + * 催办次数。 + */ + @Column(value = "remind_count") + private Integer remindCount; + + /** + * 工单Id。 + */ + @Column(value = "work_order_id") + private Long workOrderId; + + /** + * 流程定义Id。 + */ + @Column(value = "process_definition_id") + private String processDefinitionId; + + /** + * 流程定义标识。 + */ + @Column(value = "process_definition_key") + private String processDefinitionKey; + + /** + * 流程名称。 + */ + @Column(value = "process_definition_name") + private String processDefinitionName; + + /** + * 流程实例Id。 + */ + @Column(value = "process_instance_id") + private String processInstanceId; + + /** + * 流程实例发起者。 + */ + @Column(value = "process_instance_initiator") + private String processInstanceInitiator; + + /** + * 流程任务Id。 + */ + @Column(value = "task_id") + private String taskId; + + /** + * 流程任务定义标识。 + */ + @Column(value = "task_definition_key") + private String taskDefinitionKey; + + /** + * 流程任务名称。 + */ + @Column(value = "task_name") + private String taskName; + + /** + * 创建时间。 + */ + @Column(value = "task_start_time") + private Date taskStartTime; + + /** + * 任务指派人登录名。 + */ + @Column(value = "task_assignee") + private String taskAssignee; + + /** + * 任务是否已完成。 + */ + @Column(value = "task_finished") + private Boolean taskFinished; + + /** + * 业务数据快照。 + */ + @Column(value = "business_data_shot") + private String businessDataShot; + + /** + * 是否为在线表单消息数据。 + */ + @Column(value = "online_form_data") + private Boolean onlineFormData; + + /** + * 更新时间。 + */ + @Column(value = "update_time") + private Date updateTime; + + /** + * 更新者Id。 + */ + @Column(value = "update_user_id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @Column(value = "create_time") + private Date createTime; + + /** + * 创建者Id。 + */ + @Column(value = "create_user_id") + private Long createUserId; + + /** + * 创建者显示名。 + */ + @Column(value = "create_username") + private String createUsername; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMessageCandidateIdentity.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMessageCandidateIdentity.java new file mode 100644 index 00000000..c27056f7 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMessageCandidateIdentity.java @@ -0,0 +1,39 @@ +package com.orangeforms.common.flow.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; + +/** + * 流程任务消息的候选身份实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_flow_msg_candidate_identity") +public class FlowMessageCandidateIdentity { + + /** + * 主键Id。 + */ + @Id(value = "id") + private Long id; + + /** + * 任务消息Id。 + */ + @Column(value = "message_id") + private Long messageId; + + /** + * 候选身份类型。 + */ + @Column(value = "candidate_type") + private String candidateType; + + /** + * 候选身份Id。 + */ + @Column(value = "candidate_id") + private String candidateId; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMessageIdentityOperation.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMessageIdentityOperation.java new file mode 100644 index 00000000..f1eb555b --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMessageIdentityOperation.java @@ -0,0 +1,48 @@ +package com.orangeforms.common.flow.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; + +import java.util.Date; + +/** + * 流程任务消息所属用户的操作表。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_flow_msg_identity_operation") +public class FlowMessageIdentityOperation { + + /** + * 主键Id。 + */ + @Id(value = "id") + private Long id; + + /** + * 任务消息Id。 + */ + @Column(value = "message_id") + private Long messageId; + + /** + * 用户登录名。 + */ + @Column(value = "login_name") + private String loginName; + + /** + * 操作类型。 + * 常量值参考FlowMessageOperationType对象。 + */ + @Column(value = "operation_type") + private Integer operationType; + + /** + * 操作时间。 + */ + @Column(value = "operation_time") + private Date operationTime; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMultiInstanceTrans.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMultiInstanceTrans.java new file mode 100644 index 00000000..245af434 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMultiInstanceTrans.java @@ -0,0 +1,97 @@ +package com.orangeforms.common.flow.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.flowable.task.api.TaskInfo; + +import java.util.Date; + +/** + * 流程多实例任务执行流水对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@NoArgsConstructor +@Table(value = "zz_flow_multi_instance_trans") +public class FlowMultiInstanceTrans { + + /** + * 主键Id。 + */ + @Id(value = "id") + private Long id; + + /** + * 流程实例Id。 + */ + @Column(value = "process_instance_id") + private String processInstanceId; + + /** + * 任务Id。 + */ + @Column(value = "task_id") + private String taskId; + + /** + * 任务标识。 + */ + @Column(value = "task_key") + private String taskKey; + + /** + * 会签任务的执行Id。 + */ + @Column(value = "multi_instance_exec_id") + private String multiInstanceExecId; + + /** + * 任务的执行Id。 + */ + @Column(value = "execution_id") + private String executionId; + + /** + * 会签指派人列表。 + */ + @Column(value = "assignee_list") + private String assigneeList; + + /** + * 创建者Id。 + */ + @Column(value = "create_user_id") + private Long createUserId; + + /** + * 创建者登录名。 + */ + @Column(value = "create_login_name") + private String createLoginName; + + /** + * 创建者显示名。 + */ + @Column(value = "create_username") + private String createUsername; + + /** + * 创建时间。 + */ + @Column(value = "create_time") + private Date createTime; + + public FlowMultiInstanceTrans(TaskInfo task) { + this.fillWith(task); + } + + public void fillWith(TaskInfo task) { + this.taskId = task.getId(); + this.taskKey = task.getTaskDefinitionKey(); + this.processInstanceId = task.getProcessInstanceId(); + this.executionId = task.getExecutionId(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowTaskComment.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowTaskComment.java new file mode 100644 index 00000000..2d042cc9 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowTaskComment.java @@ -0,0 +1,150 @@ +package com.orangeforms.common.flow.model; + +import com.mybatisflex.annotation.*; +import com.orangeforms.common.core.util.ContextUtil; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.flowable.task.api.TaskInfo; + +import java.util.Date; + +/** + * FlowTaskComment实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@NoArgsConstructor +@Table(value = "zz_flow_task_comment") +public class FlowTaskComment { + + /** + * 主键Id。 + */ + @Id(value = "id") + private Long id; + + /** + * 流程实例Id。 + */ + @Column(value = "process_instance_id") + private String processInstanceId; + + /** + * 任务Id。 + */ + @Column(value = "task_id") + private String taskId; + + /** + * 任务标识。 + */ + @Column(value = "task_key") + private String taskKey; + + /** + * 任务名称。 + */ + @Column(value = "task_name") + private String taskName; + + /** + * 用于驳回和自由跳的目标任务标识。 + */ + @Column(value = "target_task_key") + private String targetTaskKey; + + /** + * 任务的执行Id。 + */ + @Column(value = "execution_id") + private String executionId; + + /** + * 会签任务的执行Id。 + */ + @Column(value = "multi_instance_exec_id") + private String multiInstanceExecId; + + /** + * 审批类型。 + */ + @Column(value = "approval_type") + private String approvalType; + + /** + * 批注内容。 + */ + @Column(value = "task_comment") + private String taskComment; + + /** + * 委托指定人,比如加签、转办等。 + */ + @Column(value = "delegate_assignee") + private String delegateAssignee; + + /** + * 自定义数据。开发者可自行扩展,推荐使用JSON格式数据。 + */ + @Column(value = "custom_business_data") + private String customBusinessData; + + /** + * 审批人头像。 + */ + @Column(value = "head_image_url") + private String headImageUrl; + + /** + * 创建者Id。 + */ + @Column(value = "create_user_id") + private Long createUserId; + + /** + * 创建者登录名。 + */ + @Column(value = "create_login_name") + private String createLoginName; + + /** + * 创建者显示名。 + */ + @Column(value = "create_username") + private String createUsername; + + /** + * 创建时间。 + */ + @Column(value = "create_time") + private Date createTime; + + private static final String REQ_ATTRIBUTE_KEY = "flowTaskComment"; + + public FlowTaskComment(TaskInfo task) { + this.fillWith(task); + } + + public static void setToRequest(FlowTaskComment comment) { + if (ContextUtil.getHttpRequest() != null) { + ContextUtil.getHttpRequest().setAttribute(REQ_ATTRIBUTE_KEY, comment); + } + } + + public static FlowTaskComment getFromRequest() { + if (ContextUtil.getHttpRequest() == null) { + return null; + } + return (FlowTaskComment) ContextUtil.getHttpRequest().getAttribute(REQ_ATTRIBUTE_KEY); + } + + public void fillWith(TaskInfo task) { + this.taskId = task.getId(); + this.taskKey = task.getTaskDefinitionKey(); + this.taskName = task.getName(); + this.processInstanceId = task.getProcessInstanceId(); + this.executionId = task.getExecutionId(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowTaskExt.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowTaskExt.java new file mode 100644 index 00000000..5033e6dc --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowTaskExt.java @@ -0,0 +1,87 @@ +package com.orangeforms.common.flow.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; + +/** + * 流程任务扩展实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_flow_task_ext") +public class FlowTaskExt { + + /** + * 流程引擎的定义Id。 + */ + @Column(value = "process_definition_id") + private String processDefinitionId; + + /** + * 流程引擎任务Id。 + */ + @Column(value = "task_id") + private String taskId; + + /** + * 操作列表JSON。 + */ + @Column(value = "operation_list_json") + private String operationListJson; + + /** + * 变量列表JSON。 + */ + @Column(value = "variable_list_json") + private String variableListJson; + + /** + * 存储多实例的assigneeList的JSON。 + */ + @Column(value = "assignee_list_json") + private String assigneeListJson; + + /** + * 分组类型。 + */ + @Column(value = "group_type") + private String groupType; + + /** + * 保存岗位相关的数据。 + */ + @Column(value = "dept_post_list_json") + private String deptPostListJson; + + /** + * 逗号分隔的角色Id。 + */ + @Column(value = "role_ids") + private String roleIds; + + /** + * 逗号分隔的部门Id。 + */ + @Column(value = "dept_ids") + private String deptIds; + + /** + * 逗号分隔候选用户名。 + */ + @Column(value = "candidate_usernames") + private String candidateUsernames; + + /** + * 抄送相关的数据。 + */ + @Column(value = "copy_list_json") + private String copyListJson; + + /** + * 用户任务的扩展属性,存储为JSON的字符串格式。 + */ + @Column(value = "extra_data_json") + private String extraDataJson; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowWorkOrder.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowWorkOrder.java new file mode 100644 index 00000000..d3478bbb --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowWorkOrder.java @@ -0,0 +1,162 @@ +package com.orangeforms.common.flow.model; + +import com.mybatisflex.annotation.*; +import com.orangeforms.common.core.annotation.DeptFilterColumn; +import com.orangeforms.common.core.annotation.UserFilterColumn; +import com.orangeforms.common.core.annotation.RelationConstDict; +import com.orangeforms.common.flow.constant.FlowTaskStatus; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 工作流工单实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_flow_work_order") +public class FlowWorkOrder { + + /** + * 主键Id。 + */ + @Id(value = "work_order_id") + private Long workOrderId; + + /** + * 租户Id。 + */ + @Column(value = "tenant_id") + private Long tenantId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Column(value = "app_code") + private String appCode; + + /** + * 工单编码字段。 + */ + @Column(value = "work_order_code") + private String workOrderCode; + + /** + * 流程定义标识。 + */ + @Column(value = "process_definition_key") + private String processDefinitionKey; + + /** + * 流程名称。 + */ + @Column(value = "process_definition_name") + private String processDefinitionName; + + /** + * 流程引擎的定义Id。 + */ + @Column(value = "process_definition_id") + private String processDefinitionId; + + /** + * 流程实例Id。 + */ + @Column(value = "process_instance_id") + private String processInstanceId; + + /** + * 在线表单的主表Id。 + */ + @Column(value = "online_table_id") + private Long onlineTableId; + + /** + * 静态表单所使用的数据表名。 + */ + @Column(value = "table_name") + private String tableName; + + /** + * 业务主键值。 + */ + @Column(value = "business_key") + private String businessKey; + + /** + * 最近的审批状态。 + */ + @Column(value = "latest_approval_status") + private Integer latestApprovalStatus; + + /** + * 流程状态。参考FlowTaskStatus常量值对象。 + */ + @Column(value = "flow_status") + private Integer flowStatus; + + /** + * 提交用户登录名称。 + */ + @Column(value = "submit_username") + private String submitUsername; + + /** + * 提交用户所在部门Id。 + */ + @DeptFilterColumn + @Column(value = "dept_id") + private Long deptId; + + /** + * 更新时间。 + */ + @Column(value = "update_time") + private Date updateTime; + + /** + * 更新者Id。 + */ + @Column(value = "update_user_id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @Column(value = "create_time") + private Date createTime; + + /** + * 创建者Id。 + */ + @UserFilterColumn + @Column(value = "create_user_id") + private Long createUserId; + + /** + * 逻辑删除标记字段(1: 正常 -1: 已删除)。 + */ + @Column(value = "deleted_flag", isLogicDelete = true) + private Integer deletedFlag; + + /** + * createTime 范围过滤起始值(>=)。 + */ + @Column(ignore = true) + private String createTimeStart; + + /** + * createTime 范围过滤结束值(<=)。 + */ + @Column(ignore = true) + private String createTimeEnd; + + @RelationConstDict( + masterIdField = "flowStatus", + constantDictClass = FlowTaskStatus.class) + @Column(ignore = true) + private Map flowStatusDictMap; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowWorkOrderExt.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowWorkOrderExt.java new file mode 100644 index 00000000..369b017f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowWorkOrderExt.java @@ -0,0 +1,71 @@ +package com.orangeforms.common.flow.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; + +import java.util.Date; + +/** + * 工作流工单扩展数据实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_flow_work_order_ext") +public class FlowWorkOrderExt { + + /** + * 主键Id。 + */ + @Id(value = "id") + private Long id; + + /** + * 流程工单Id。 + */ + @Column(value = "work_order_id") + private Long workOrderId; + + /** + * 草稿数据。 + */ + @Column(value = "draft_data") + private String draftData; + + /** + * 业务数据。 + */ + @Column(value = "business_data") + private String businessData; + + /** + * 更新时间。 + */ + @Column(value = "update_time") + private Date updateTime; + + /** + * 更新者Id。 + */ + @Column(value = "update_user_id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @Column(value = "create_time") + private Date createTime; + + /** + * 创建者Id。 + */ + @Column(value = "create_user_id") + private Long createUserId; + + /** + * 逻辑删除标记字段(1: 正常 -1: 已删除)。 + */ + @Column(value = "deleted_flag", isLogicDelete = true) + private Integer deletedFlag; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowBindFormType.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowBindFormType.java new file mode 100644 index 00000000..37de6e36 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowBindFormType.java @@ -0,0 +1,44 @@ +package com.orangeforms.common.flow.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 工作流绑定表单类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FlowBindFormType { + + /** + * 在线表单。 + */ + public static final int ONLINE_FORM = 0; + /** + * 路由表单。 + */ + public static final int ROUTER_FORM = 1; + + private static final Map DICT_MAP = new HashMap<>(2); + static { + DICT_MAP.put(ONLINE_FORM, "在线表单"); + DICT_MAP.put(ROUTER_FORM, "路由表单"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowBindFormType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowEntryStatus.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowEntryStatus.java new file mode 100644 index 00000000..826e9895 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowEntryStatus.java @@ -0,0 +1,44 @@ +package com.orangeforms.common.flow.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 工作流状态。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FlowEntryStatus { + + /** + * 未发布。 + */ + public static final int UNPUBLISHED = 0; + /** + * 已发布。 + */ + public static final int PUBLISHED = 1; + + private static final Map DICT_MAP = new HashMap<>(2); + static { + DICT_MAP.put(UNPUBLISHED, "未发布"); + DICT_MAP.put(PUBLISHED, "已发布"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowEntryStatus() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowMessageOperationType.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowMessageOperationType.java new file mode 100644 index 00000000..6bd62cfd --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowMessageOperationType.java @@ -0,0 +1,21 @@ +package com.orangeforms.common.flow.model.constant; + +/** + * 工作流消息操作类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FlowMessageOperationType { + + /** + * 已读操作。 + */ + public static final int READ_FINISHED = 0; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowMessageOperationType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowMessageType.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowMessageType.java new file mode 100644 index 00000000..18d41da2 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowMessageType.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.flow.model.constant; + +/** + * 工作流消息类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FlowMessageType { + + /** + * 催办消息。 + */ + public static final int REMIND_TYPE = 0; + + /** + * 抄送消息。 + */ + public static final int COPY_TYPE = 1; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowMessageType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowVariableType.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowVariableType.java new file mode 100644 index 00000000..f68f49ad --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowVariableType.java @@ -0,0 +1,44 @@ +package com.orangeforms.common.flow.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 流程变量类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FlowVariableType { + + /** + * 流程实例变量。 + */ + public static final int INSTANCE = 0; + /** + * 任务变量。 + */ + public static final int TASK = 1; + + private static final Map DICT_MAP = new HashMap<>(2); + static { + DICT_MAP.put(INSTANCE, "流程实例变量"); + DICT_MAP.put(TASK, "任务变量"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowVariableType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowElementExtProperty.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowElementExtProperty.java new file mode 100644 index 00000000..a3277c29 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowElementExtProperty.java @@ -0,0 +1,18 @@ +package com.orangeforms.common.flow.object; + +import lombok.Data; + +/** + * 流程任务的扩展属性。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class FlowElementExtProperty { + + /** + * 最近的审批状态,该值目前仅仅用于流程线元素,即SequenceElement。 + */ + private Integer latestApprovalStatus; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowEntryExtensionData.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowEntryExtensionData.java new file mode 100644 index 00000000..fec564d5 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowEntryExtensionData.java @@ -0,0 +1,37 @@ +package com.orangeforms.common.flow.object; + +import lombok.Data; + +import java.util.List; +import java.util.Map; + +/** + * 流程扩展数据对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class FlowEntryExtensionData { + + /** + * 通知类型。 + */ + private List notifyTypes; + /** + * 流程审批状态字典数据列表。Map的key是id和name。 + */ + private List> approvalStatusDict; + /** + * 级联删除业务数据。 + */ + private Boolean cascadeDeleteBusinessData = false; + /** + * 是否支持流程复活。 + */ + private Boolean supportRevive = false; + /** + * 复活数据保留天数。0表示永久保留。 + */ + private Integer keptReviveDays = 0; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowRumtimeObject.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowRumtimeObject.java new file mode 100644 index 00000000..978284c7 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowRumtimeObject.java @@ -0,0 +1,24 @@ +package com.orangeforms.common.flow.object; + +import lombok.Data; +import org.flowable.engine.runtime.ProcessInstance; +import org.flowable.task.api.Task; + +/** + * 工作流运行时常用对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class FlowRumtimeObject { + + /** + * 运行时流程实例对象。 + */ + private ProcessInstance instance; + /** + * 运行时流程任务对象。 + */ + private Task task; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowTaskMultiSignAssign.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowTaskMultiSignAssign.java new file mode 100644 index 00000000..55c1388b --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowTaskMultiSignAssign.java @@ -0,0 +1,22 @@ +package com.orangeforms.common.flow.object; + +import lombok.Data; + +/** + * 表示多实例任务的指派人信息。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class FlowTaskMultiSignAssign { + + /** + * 指派人类型。参考常量类 UserFilterGroup。 + */ + private String assigneeType; + /** + * 逗号分隔的指派人列表。 + */ + private String assigneeList; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowTaskOperation.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowTaskOperation.java new file mode 100644 index 00000000..8ad86d88 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowTaskOperation.java @@ -0,0 +1,38 @@ +package com.orangeforms.common.flow.object; + +import lombok.Data; + +/** + * 流程图中的用户任务操作数据。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class FlowTaskOperation { + + /** + * 操作Id。 + */ + private String id; + /** + * 操作的标签名。 + */ + private String label; + /** + * 操作类型。 + */ + private String type; + /** + * 显示顺序。 + */ + private Integer showOrder; + /** + * 最后审批状态。 + */ + private Integer latestApprovalStatus; + /** + * 在流程图中定义的多实例会签的指定人员信息。 + */ + private FlowTaskMultiSignAssign multiSignAssignee; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowTaskPostCandidateGroup.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowTaskPostCandidateGroup.java new file mode 100644 index 00000000..5e954d8f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowTaskPostCandidateGroup.java @@ -0,0 +1,64 @@ +package com.orangeforms.common.flow.object; + +import com.orangeforms.common.flow.constant.FlowConstant; +import lombok.Data; + +import java.util.LinkedList; +import java.util.List; + +/** + * 流程任务岗位候选组数据。仅用于流程任务的候选组类型为岗位时。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class FlowTaskPostCandidateGroup { + + /** + * 唯一值,目前仅前端使用。 + */ + private String id; + /** + * 岗位类型。 + * 1. 所有部门岗位审批变量,值为 (allDeptPost)。 + * 2. 本部门岗位审批变量,值为 (selfDeptPost)。 + * 3. 上级部门岗位审批变量,值为 (upDeptPost)。 + * 4. 任意部门关联的岗位审批变量,值为 (deptPost)。 + */ + private String type; + /** + * 岗位Id。type为(1,2,3)时使用该值。 + */ + private String postId; + /** + * 部门岗位Id。type为(4)时使用该值。 + */ + private String deptPostId; + + public static List buildCandidateGroupList(List groupDataList) { + List candidateGroupList = new LinkedList<>(); + for (FlowTaskPostCandidateGroup groupData : groupDataList) { + switch (groupData.getType()) { + case FlowConstant.GROUP_TYPE_ALL_DEPT_POST_VAR: + candidateGroupList.add(groupData.getPostId()); + break; + case FlowConstant.GROUP_TYPE_DEPT_POST_VAR: + candidateGroupList.add(groupData.getDeptPostId()); + break; + case FlowConstant.GROUP_TYPE_SELF_DEPT_POST_VAR: + candidateGroupList.add("${" + FlowConstant.SELF_DEPT_POST_PREFIX + groupData.getPostId() + "}"); + break; + case FlowConstant.GROUP_TYPE_SIBLING_DEPT_POST_VAR: + candidateGroupList.add("${" + FlowConstant.SIBLING_DEPT_POST_PREFIX + groupData.getPostId() + "}"); + break; + case FlowConstant.GROUP_TYPE_UP_DEPT_POST_VAR: + candidateGroupList.add("${" + FlowConstant.UP_DEPT_POST_PREFIX + groupData.getPostId() + "}"); + break; + default: + break; + } + } + return candidateGroupList; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowUserTaskExtData.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowUserTaskExtData.java new file mode 100644 index 00000000..85d8a7a3 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowUserTaskExtData.java @@ -0,0 +1,63 @@ +package com.orangeforms.common.flow.object; + +import lombok.Data; + +import java.util.List; + +/** + * 流程用户任务扩展数据对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class FlowUserTaskExtData { + + public static final String NOTIFY_TYPE_MSG = "message"; + public static final String NOTIFY_TYPE_EMAIL = "email"; + + public static final String TIMEOUT_AUTO_COMPLETE = "autoComplete"; + public static final String TIMEOUT_SEND_MSG = "sendMessage"; + + public static final String EMPTY_USER_TO_ASSIGNEE = "toAssignee"; + public static final String EMPTY_USER_AUTO_REJECT = "autoReject"; + public static final String EMPTY_USER_AUTO_COMPLETE = "autoComplete"; + + /** + * 拒绝后再提交,走重新审批。 + */ + public static final String REJECT_TYPE_REDO = "0"; + /** + * 拒绝后再提交,直接回到驳回前的节点。 + */ + public static final String REJECT_TYPE_BACK_TO_SOURCE = "1"; + + /** + * 任务通知类型列表。 + */ + private List flowNotifyTypeList; + /** + * 拒绝后再次提交的审批类型。 + */ + private String rejectType = REJECT_TYPE_REDO; + /** + * 到期提醒的小时数(从待办任务被创建的时候开始计算)。 + */ + private Integer timeoutHours; + /** + * 任务超时的处理方式。 + */ + private String timeoutHandleWay; + /** + * 默认审批人。 + */ + private String defaultAssignee; + /** + * 空用户审批处理方式。 + */ + private String emptyUserHandleWay; + /** + * 空用户审批时设定的审批人。 + */ + private String emptyUserToAssignee; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowApiService.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowApiService.java new file mode 100644 index 00000000..892ea587 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowApiService.java @@ -0,0 +1,568 @@ +package com.orangeforms.common.flow.service; + +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.object.MyPageData; +import com.orangeforms.common.core.object.MyPageParam; +import com.orangeforms.common.core.object.Tuple2; +import com.orangeforms.common.flow.model.FlowTaskComment; +import com.orangeforms.common.flow.model.FlowTaskExt; +import com.orangeforms.common.flow.vo.FlowTaskVo; +import org.flowable.bpmn.model.BpmnModel; +import org.flowable.bpmn.model.FieldExtension; +import org.flowable.bpmn.model.FlowElement; +import org.flowable.bpmn.model.UserTask; +import org.flowable.engine.delegate.ExecutionListener; +import org.flowable.engine.delegate.TaskListener; +import org.flowable.engine.history.HistoricActivityInstance; +import org.flowable.engine.history.HistoricProcessInstance; +import org.flowable.engine.repository.ProcessDefinition; +import org.flowable.engine.runtime.ProcessInstance; +import org.flowable.task.api.Task; +import org.flowable.task.api.TaskInfo; +import org.flowable.task.api.history.HistoricTaskInstance; + +import javax.xml.stream.XMLStreamException; +import java.text.ParseException; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 流程引擎API的接口封装服务。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowApiService { + + /** + * 启动流程实例。 + * + * @param processDefinitionId 流程定义Id。 + * @param dataId 业务主键Id。 + * @return 新启动的流程实例。 + */ + ProcessInstance start(String processDefinitionId, Object dataId); + + /** + * 完成第一个用户任务。 + * + * @param processInstanceId 流程实例Id。 + * @param flowTaskComment 审批对象。 + * @param taskVariableData 流程任务的变量数据。 + * @return 新完成的任务对象。 + */ + Task takeFirstTask(String processInstanceId, FlowTaskComment flowTaskComment, JSONObject taskVariableData); + + /** + * 启动流程实例,如果当前登录用户为第一个用户任务的指派者,或者Assginee为流程启动人变量时, + * 则自动完成第一个用户任务。 + * + * @param processDefinitionId 流程定义Id。 + * @param dataId 当前流程主表的主键数据。 + * @param flowTaskComment 审批对象。 + * @param taskVariableData 流程任务的变量数据。 + * @return 新启动的流程实例。 + */ + ProcessInstance startAndTakeFirst( + String processDefinitionId, Object dataId, FlowTaskComment flowTaskComment, JSONObject taskVariableData); + + /** + * 多实例加签减签。 + * + * @param startTaskInstance 会签对象的发起任务实例。 + * @param multiInstanceActiveTask 正在执行的多实例任务对象。 + * @param newAssignees 新指派人,多个指派人之间逗号分隔。 + * @param isAdd 是否为加签。 + */ + void submitConsign(HistoricTaskInstance startTaskInstance, Task multiInstanceActiveTask, String newAssignees, boolean isAdd); + + /** + * 完成任务,同时提交审批数据。 + * + * @param task 工作流任务对象。 + * @param flowTaskComment 审批对象。 + * @param taskVariableData 流程任务的变量数据。 + */ + void completeTask(Task task, FlowTaskComment flowTaskComment, JSONObject taskVariableData); + + /** + * 判断当前登录用户是否为流程实例中的用户任务的指派人。或是候选人之一,如果是候选人则拾取该任务并成为指派人。 + * 如果都不是,就会返回具体的错误信息。 + * + * @param task 流程实例中的用户任务。 + * @return 调用结果。 + */ + CallResult verifyAssigneeOrCandidateAndClaim(Task task); + + /** + * 初始化并返回流程实例的变量Map。 + * + * @param processDefinitionId 流程定义Id。 + * @return 初始化后的流程实例变量Map。 + */ + Map initAndGetProcessInstanceVariables(String processDefinitionId); + + /** + * 判断当前登录用户是否为流程实例中的用户任务的指派人。或是候选人之一。 + * + * @param task 流程实例中的用户任务。 + * @return 是返回true,否则false。 + */ + boolean isAssigneeOrCandidate(TaskInfo task); + + /** + * 获取指定流程定义的全部流程节点。 + * + * @param processDefinitionId 流程定义Id。 + * @return 当前流程定义的全部节点集合。 + */ + Collection getProcessAllElements(String processDefinitionId); + + /** + * 判断当前登录用户是否为流程实例的发起人。 + * + * @param processInstanceId 流程实例Id。 + * @return 是返回true,否则false。 + */ + boolean isProcessInstanceStarter(String processInstanceId); + + /** + * 为流程实例设置BusinessKey。 + * + * @param processInstanceId 流程实例Id。 + * @param dataId 通常为主表的主键Id。 + */ + void setBusinessKeyForProcessInstance(String processInstanceId, Object dataId); + + /** + * 判断指定的流程实例Id是否存在。 + * + * @param processInstanceId 流程实例Id。 + * @return 存在返回true,否则false。 + */ + boolean existActiveProcessInstance(String processInstanceId); + + /** + * 获取指定的流程实例对象。 + * + * @param processInstanceId 流程实例Id。 + * @return 流程实例对象。 + */ + ProcessInstance getProcessInstance(String processInstanceId); + + /** + * 获取指定的流程实例对象。 + * + * @param processDefinitionId 流程定义Id。 + * @param businessKey 业务主键Id。 + * @return 流程实例对象。 + */ + ProcessInstance getProcessInstanceByBusinessKey(String processDefinitionId, String businessKey); + + /** + * 获取流程实例的列表。 + * + * @param processInstanceIdSet 流程实例Id集合。 + * @return 流程实例列表。 + */ + List getProcessInstanceList(Set processInstanceIdSet); + + /** + * 根据流程定义Id查询流程定义对象。 + * + * @param processDefinitionId 流程定义Id。 + * @return 流程定义对象。 + */ + ProcessDefinition getProcessDefinitionById(String processDefinitionId); + + /** + * 根据流程部署Id查询流程定义对象。 + * + * @param deployId 流程部署Id。 + * @return 流程定义对象。 + */ + ProcessDefinition getProcessDefinitionByDeployId(String deployId); + + /** + * 获取流程定义的列表。 + * + * @param processDefinitionIdSet 流程定义Id集合。 + * @return 流程定义列表。 + */ + List getProcessDefinitionList(Set processDefinitionIdSet); + + /** + * 挂起流程定义对象。 + * + * @param processDefinitionId 流程定义Id。 + */ + void suspendProcessDefinition(String processDefinitionId); + + /** + * 激活流程定义对象。 + * + * @param processDefinitionId 流程定义Id。 + */ + void activateProcessDefinition(String processDefinitionId); + + /** + * 获取指定流程定义的BpmnModel。 + * + * @param processDefinitionId 流程定义Id。 + * @return 关联的BpmnModel。 + */ + BpmnModel getBpmnModelByDefinitionId(String processDefinitionId); + + /** + * 判断任务是否为多实例任务。 + * + * @param processDefinitionId 流程定义Id。 + * @param taskKey 流程任务标识。 + * @return true为多实例,否则false。 + */ + boolean isMultiInstanceTask(String processDefinitionId, String taskKey); + + /** + * 设置流程实例的变量集合。 + * + * @param processInstanceId 流程实例Id。 + * @param variableMap 变量名。 + */ + void setProcessInstanceVariables(String processInstanceId, Map variableMap); + + /** + * 获取流程实例的变量。 + * + * @param processInstanceId 流程实例Id。 + * @param variableName 变量名。 + * @return 变量值。 + */ + Object getProcessInstanceVariable(String processInstanceId, String variableName); + + /** + * 获取指定流程实例和任务Id的当前活动任务。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 流程任务Id。 + * @return 当前流程实例的活动任务。 + */ + Task getProcessInstanceActiveTask(String processInstanceId, String taskId); + + /** + * 获取指定流程实例的当前活动任务列表。 + * + * @param processInstanceId 流程实例Id。 + * @return 当前流程实例的活动任务。 + */ + List getProcessInstanceActiveTaskList(String processInstanceId); + + /** + * 获取指定流程实例的当前活动任务列表,同时转换为流出任务视图对象列表。 + * + * @param processInstanceId 流程实例Id。 + * @return 当前流程实例的活动任务。 + */ + List getProcessInstanceActiveTaskListAndConvert(String processInstanceId); + + /** + * 根据任务Id,获取当前运行时任务。 + * + * @param taskId 任务Id。 + * @return 运行时任务对象。 + */ + Task getTaskById(String taskId); + + /** + * 获取用户的任务列表。这其中包括当前用户作为指派人和候选人。 + * + * @param username 指派人。 + * @param definitionKey 流程定义的标识。 + * @param definitionName 流程定义名。 + * @param taskName 任务名称。 + * @param pageParam 分页对象。 + * @return 用户的任务列表。 + */ + MyPageData getTaskListByUserName( + String username, String definitionKey, String definitionName, String taskName, MyPageParam pageParam); + + /** + * 获取用户的任务数量。这其中包括当前用户作为指派人和候选人。 + * + * @param username 指派人。 + * @return 用户的任务数量。 + */ + long getTaskCountByUserName(String username); + + /** + * 获取流程实例Id集合的运行时任务列表。 + * + * @param processInstanceIdSet 流程实例Id集合。 + * @return 运行时任务列表。 + */ + List getTaskListByProcessInstanceIds(List processInstanceIdSet); + + /** + * 将流程任务列表数据,转换为前端可以显示的流程对象。 + * + * @param taskList 流程引擎中的任务列表。 + * @return 前端可以显示的流程任务列表。 + */ + List convertToFlowTaskList(List taskList); + + /** + * 添加流程实例结束的监听器。 + * + * @param bpmnModel 流程模型。 + * @param listenerClazz 流程监听器的Class对象。 + */ + void addProcessInstanceEndListener(BpmnModel bpmnModel, Class listenerClazz); + + /** + * 添加流程任务的执行监听器。 + * + * @param flowElement 指定任务节点。 + * @param listenerClazz 执行监听器。 + * @param event 事件。 + * @param fieldExtensions 执行监听器的扩展变量列表。 + */ + void addExecutionListener( + FlowElement flowElement, + Class listenerClazz, + String event, + List fieldExtensions); + + /** + * 添加流程任务创建的任务监听器。 + * + * @param userTask 用户任务。 + * @param listenerClazz 任务监听器。 + */ + void addTaskCreateListener(UserTask userTask, Class listenerClazz); + + /** + * 获取流程实例的历史流程实例。 + * + * @param processInstanceId 流程实例Id。 + * @return 历史流程实例。 + */ + HistoricProcessInstance getHistoricProcessInstance(String processInstanceId); + + /** + * 获取流程实例的历史流程实例列表。 + * + * @param processInstanceIdSet 流程实例Id集合。 + * @return 历史流程实例列表。 + */ + List getHistoricProcessInstanceList(Set processInstanceIdSet); + + /** + * 查询历史流程实例的列表。 + * + * @param processDefinitionKey 流程标识名。 + * @param processDefinitionName 流程名。 + * @param startUser 流程发起用户。 + * @param beginDate 流程发起开始时间。 + * @param endDate 流程发起结束时间。 + * @param pageParam 分页对象。 + * @param finishedOnly 仅仅返回已经结束的流程。 + * @return 分页后的查询列表对象。 + * @throws ParseException 日期参数解析失败。 + */ + MyPageData getHistoricProcessInstanceList( + String processDefinitionKey, + String processDefinitionName, + String startUser, + String beginDate, + String endDate, + MyPageParam pageParam, + boolean finishedOnly) throws ParseException; + + /** + * 获取流程实例的已完成历史任务列表。 + * + * @param processInstanceId 流程实例Id。 + * @return 流程实例已完成的历史任务列表。 + */ + List getHistoricActivityInstanceList(String processInstanceId); + + /** + * 获取流程实例的已完成历史任务列表,同时按照每个活动实例的开始时间升序排序。 + * + * @param processInstanceId 流程实例Id。 + * @return 流程实例已完成的历史任务列表。 + */ + List getHistoricActivityInstanceListOrderByStartTime(String processInstanceId); + + /** + * 获取当前用户的历史已办理任务列表。 + * + * @param processDefinitionName 流程名。 + * @param beginDate 流程发起开始时间。 + * @param endDate 流程发起结束时间。 + * @param pageParam 分页对象。 + * @return 分页后的查询列表对象。 + * @throws ParseException 日期参数解析失败。 + */ + MyPageData getHistoricTaskInstanceFinishedList( + String processDefinitionName, + String beginDate, + String endDate, + MyPageParam pageParam) throws ParseException; + + /** + * 获取指定的历史任务实例。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 任务Id。 + * @return 历史任务实例。 + */ + HistoricTaskInstance getHistoricTaskInstance(String processInstanceId, String taskId); + + /** + * 获取流程实例的待完成任务列表。 + * + * @param processInstanceId 流程实例Id。 + * @return 流程实例待完成的任务列表。 + */ + List getHistoricUnfinishedInstanceList(String processInstanceId); + + /** + * 终止流程实例,将任务从当前节点直接流转到主流程的结束事件。 + * + * @param processInstanceId 流程实例Id。 + * @param stopReason 停止原因。 + * @param forCancel 是否由取消工单触发。 + * @return 执行结果。 + */ + CallResult stopProcessInstance(String processInstanceId, String stopReason, boolean forCancel); + + /** + * 终止流程实例,将任务从当前节点直接流转到主流程的结束事件。 + * + * @param processInstanceId 流程实例Id。 + * @param stopReason 停止原因。 + * @param status 流程状态。 + * @return 执行结果。 + */ + CallResult stopProcessInstance(String processInstanceId, String stopReason, int status); + + /** + * 删除流程实例。 + * + * @param processInstanceId 流程实例Id。 + */ + void deleteProcessInstance(String processInstanceId); + + /** + * 获取任务的指定本地变量。 + * + * @param taskId 任务Id。 + * @param variableName 变量名。 + * @return 变量值。 + */ + Object getTaskVariable(String taskId, String variableName); + + /** + * 安全的获取任务变量,并返回字符型的变量值。 + * + * @param taskId 任务Id。 + * @param variableName 变量名。 + * @return 返回变量值的字符串形式,如果变量不存在不会抛异常,返回null。 + */ + String getTaskVariableStringWithSafe(String taskId, String variableName); + + /** + * 获取任务执行时的指定本地变量。 + * + * @param executionId 任务执行时Id。 + * @param variableName 变量名。 + * @return 变量值。 + */ + Object getExecutionVariable(String executionId, String variableName); + + /** + * 安全的获取任务执行时变量,并返回字符型的变量值。 + * + * @param executionId 任务执行时Id。 + * @param variableName 变量名。 + * @return 返回变量值的字符串形式,如果变量不存在不会抛异常,返回null。 + */ + String getExecutionVariableStringWithSafe(String executionId, String variableName); + + /** + * 获取历史流程变量。 + * + * @param processInstanceId 流程实例Id。 + * @param variableName 变量名。 + * @return 获取历史流程变量。 + */ + Object getHistoricProcessInstanceVariable(String processInstanceId, String variableName); + + /** + * 将xml格式的流程模型字符串,转换为标准的流程模型。 + * + * @param bpmnXml xml格式的流程模型字符串。 + * @return 转换后的标准的流程模型。 + * @throws XMLStreamException XML流处理异常 + */ + BpmnModel convertToBpmnModel(String bpmnXml) throws XMLStreamException; + + /** + * 回退到上一个用户任务节点。如果没有指定,则回退到上一个任务。 + * + * @param task 当前活动任务。 + * @param targetKey 指定回退到的任务标识。如果为null,则回退到上一个任务。 + * @param forReject true表示驳回,false为撤回。 + * @param reason 驳回或者撤销的原因。 + * @return 回退结果。 + */ + CallResult backToRuntimeTask(Task task, String targetKey, boolean forReject, String reason); + + /** + * 转办任务给他人。 + * + * @param task 流程任务。 + * @param flowTaskComment 审批对象。 + */ + void transferTo(Task task, FlowTaskComment flowTaskComment); + + /** + * 获取当前任务在流程图中配置候选用户组数据。 + * + * @param flowTaskExt 流程任务扩展对象。 + * @param taskId 运行时任务Id。 + * @return 候选用户组数据。 + */ + List getCandidateUsernames(FlowTaskExt flowTaskExt, String taskId); + + /** + * 获取当前任务在流程图中配置到的部门岗位Id集合和岗位Id集合。 + * + * @param flowTaskExt 流程任务扩展对象。 + * @param processInstanceId 流程实例Id。 + * @param historic 是否为历史任务。 + * @return first为部门岗位Id集合,second是岗位Id集合。 + */ + Tuple2, Set> getDeptPostIdAndPostIds( + FlowTaskExt flowTaskExt, String processInstanceId, boolean historic); + + /** + * 获取流程图中所有用户任务的映射。 + * + * @param processDefinitionId 流程定义Id。 + * @return 流程图中所有用户任务的映射。 + */ + Map getAllUserTaskMap(String processDefinitionId); + + /** + * 获取流程图中指定的用户任务。 + * + * @param processDefinitionId 流程定义Id。 + * @param taskKey 用户任务标识。 + * @return 用户任务。 + */ + UserTask getUserTask(String processDefinitionId, String taskKey); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowCategoryService.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowCategoryService.java new file mode 100644 index 00000000..506c6f15 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowCategoryService.java @@ -0,0 +1,69 @@ +package com.orangeforms.common.flow.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.flow.model.*; + +import java.util.List; + +/** + * FlowCategory数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowCategoryService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param flowCategory 新增对象。 + * @return 返回新增对象。 + */ + FlowCategory saveNew(FlowCategory flowCategory); + + /** + * 更新数据对象。 + * + * @param flowCategory 更新的对象。 + * @param originalFlowCategory 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(FlowCategory flowCategory, FlowCategory originalFlowCategory); + + /** + * 删除指定数据。 + * + * @param categoryId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long categoryId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getFlowCategoryListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getFlowCategoryList(FlowCategory filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getFlowCategoryList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getFlowCategoryListWithRelation(FlowCategory filter, String orderBy); + + /** + * 当前流程分类编码是否存在。 + * + * @param code 流程分类编码。 + * @return true存在,否则false。 + */ + boolean existByCode(String code); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowEntryService.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowEntryService.java new file mode 100644 index 00000000..9cd3a366 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowEntryService.java @@ -0,0 +1,133 @@ +package com.orangeforms.common.flow.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.flow.model.*; + +import javax.xml.stream.XMLStreamException; +import java.util.List; +import java.util.Set; + +/** + * FlowEntry数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowEntryService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param flowEntry 新增工作流对象。 + * @return 返回新增对象。 + */ + FlowEntry saveNew(FlowEntry flowEntry); + + /** + * 发布指定流程。 + * + * @param flowEntry 待发布的流程对象。 + * @param initTaskInfo 第一个非开始节点任务的附加信息。 + * @throws XMLStreamException 解析bpmn.xml的异常。 + */ + void publish(FlowEntry flowEntry, String initTaskInfo) throws XMLStreamException; + + /** + * 更新数据对象。 + * + * @param flowEntry 更新的对象。 + * @param originalFlowEntry 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(FlowEntry flowEntry, FlowEntry originalFlowEntry); + + /** + * 删除指定数据。 + * + * @param entryId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long entryId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getFlowEntryListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getFlowEntryList(FlowEntry filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getFlowEntryList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getFlowEntryListWithRelation(FlowEntry filter, String orderBy); + + /** + * 根据流程定义标识获取流程对象。从缓存中读取,如不存在则从数据库读取后,再同步到缓存。 + * + * @param processDefinitionKey 流程定义标识。 + * @return 流程对象。 + */ + FlowEntry getFlowEntryFromCache(String processDefinitionKey); + + /** + * 根据流程Id获取流程发布列表数据。 + * + * @param entryId 流程Id。 + * @return 流程关联的发布列表数据。 + */ + List getFlowEntryPublishList(Long entryId); + + /** + * 根据流程引擎中的流程定义Id集合,查询流程发布对象。 + * + * @param processDefinitionIdSet 流程引擎中的流程定义Id集合。 + * @return 查询结果。 + */ + List getFlowEntryPublishList(Set processDefinitionIdSet); + + /** + * 获取指定工作流发布版本对象。从缓存中读取,如缓存中不存在,从数据库读取并同步缓存。 + * + * @param entryPublishId 工作流发布对象Id。 + * @return 查询后的对象。 + */ + FlowEntryPublish getFlowEntryPublishFromCache(Long entryPublishId); + + /** + * 为指定工作流更新发布的主版本。 + * + * @param flowEntry 工作流对象。 + * @param newMainFlowEntryPublish 工作流新的发布主版本对象。 + */ + void updateFlowEntryMainVersion(FlowEntry flowEntry, FlowEntryPublish newMainFlowEntryPublish); + + /** + * 挂起指定的工作流发布对象。 + * + * @param flowEntryPublish 待挂起的工作流发布对象。 + */ + void suspendFlowEntryPublish(FlowEntryPublish flowEntryPublish); + + /** + * 激活指定的工作流发布对象。 + * + * @param flowEntryPublish 待恢复的工作流发布对象。 + */ + void activateFlowEntryPublish(FlowEntryPublish flowEntryPublish); + + /** + * 判断指定流程定义标识是否存在。 + * @param processDefinitionKey 流程定义标识。 + * @return true存在,否则false。 + */ + boolean existByProcessDefinitionKey(String processDefinitionKey); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowEntryVariableService.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowEntryVariableService.java new file mode 100644 index 00000000..963a33fb --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowEntryVariableService.java @@ -0,0 +1,68 @@ +package com.orangeforms.common.flow.service; + +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.core.base.service.IBaseService; + +import java.util.*; + +/** + * 流程变量数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowEntryVariableService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param flowEntryVariable 新增对象。 + * @return 返回新增对象。 + */ + FlowEntryVariable saveNew(FlowEntryVariable flowEntryVariable); + + /** + * 更新数据对象。 + * + * @param flowEntryVariable 更新的对象。 + * @param originalFlowEntryVariable 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(FlowEntryVariable flowEntryVariable, FlowEntryVariable originalFlowEntryVariable); + + /** + * 删除指定数据。 + * + * @param variableId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long variableId); + + /** + * 删除指定流程Id的所有变量。 + * + * @param entryId 流程Id。 + */ + void removeByEntryId(Long entryId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getFlowEntryVariableListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getFlowEntryVariableList(FlowEntryVariable filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getFlowEntryVariableList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getFlowEntryVariableListWithRelation(FlowEntryVariable filter, String orderBy); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowMessageService.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowMessageService.java new file mode 100644 index 00000000..1d0b53f8 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowMessageService.java @@ -0,0 +1,106 @@ +package com.orangeforms.common.flow.service; + +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.flow.model.FlowMessage; +import com.orangeforms.common.flow.model.FlowWorkOrder; +import org.flowable.task.api.Task; + +import java.util.List; + +/** + * 工作流消息数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowMessageService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param flowMessage 新增对象。 + * @return 保存后的消息对象。 + */ + FlowMessage saveNew(FlowMessage flowMessage); + + /** + * 根据工单参数,保存催单消息对象。如果当前工单存在多个待办任务,则插入多条催办消息数据。 + * + * @param flowWorkOrder 待催办的工单。 + */ + void saveNewRemindMessage(FlowWorkOrder flowWorkOrder); + + /** + * 保存抄送消息对象。 + * + * @param task 待抄送的任务。 + * @param copyDataJson 抄送人员或者组的Id数据。 + */ + void saveNewCopyMessage(Task task, JSONObject copyDataJson); + + /** + * 更新指定运行时任务Id的消费为已完成状态。 + * + * @param taskId 运行时任务Id。 + */ + void updateFinishedStatusByTaskId(String taskId); + + /** + * 更新指定流程实例Id的消费为已完成状态。 + * + * @param processInstanceId 流程实例IdId。 + */ + void updateFinishedStatusByProcessInstanceId(String processInstanceId); + + /** + * 获取当前用户的催办消息列表。 + * + * @return 查询后的催办消息列表。 + */ + List getRemindingMessageListByUser(); + + /** + * 获取当前用户的抄送消息列表。 + * + * @param read true表示已读,false表示未读。 + * @return 查询后的抄送消息列表。 + */ + List getCopyMessageListByUser(Boolean read); + + /** + * 判断当前用户是否有权限访问指定消息Id。 + * + * @param messageId 消息Id。 + * @return true为合法访问者,否则false。 + */ + boolean isCandidateIdentityOnMessage(Long messageId); + + /** + * 读取抄送消息,同时更新当前用户对指定抄送消息的读取状态。 + * + * @param messageId 消息Id。 + */ + void readCopyTask(Long messageId); + + /** + * 计算当前用户催办消息的数量。 + * + * @return 当前用户催办消息数量。 + */ + int countRemindingMessageListByUser(); + + /** + * 计算当前用户未读抄送消息的数量。 + * + * @return 当前用户未读抄送消息数量。 + */ + int countCopyMessageByUser(); + + /** + * 删除指定流程实例的消息。 + * + * @param processInstanceId 流程实例Id。 + */ + void removeByProcessInstanceId(String processInstanceId); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowMultiInstanceTransService.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowMultiInstanceTransService.java new file mode 100644 index 00000000..3b0ff74c --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowMultiInstanceTransService.java @@ -0,0 +1,38 @@ +package com.orangeforms.common.flow.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.flow.model.FlowMultiInstanceTrans; + +/** + * 会签任务操作流水数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowMultiInstanceTransService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param flowMultiInstanceTrans 新增对象。 + * @return 返回新增对象。 + */ + FlowMultiInstanceTrans saveNew(FlowMultiInstanceTrans flowMultiInstanceTrans); + + /** + * 根据流程执行Id获取对象。 + * + * @param executionId 流程执行Id。 + * @param taskId 执行任务Id。 + * @return 数据对象。 + */ + FlowMultiInstanceTrans getByExecutionId(String executionId, String taskId); + + /** + * 根据多实例的统一执行Id,获取assgineeList字段不为空的数据。 + * + * @param multiInstanceExecId 多实例统一执行Id。 + * @return 数据对象。 + */ + FlowMultiInstanceTrans getWithAssigneeListByMultiInstanceExecId(String multiInstanceExecId); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowTaskCommentService.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowTaskCommentService.java new file mode 100644 index 00000000..7e90388f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowTaskCommentService.java @@ -0,0 +1,83 @@ +package com.orangeforms.common.flow.service; + +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.core.base.service.IBaseService; + +import java.util.*; + +/** + * 流程任务批注数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowTaskCommentService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param flowTaskComment 新增对象。 + * @return 返回新增对象。 + */ + FlowTaskComment saveNew(FlowTaskComment flowTaskComment); + + /** + * 查询指定流程实例Id下的所有审批任务的批注。 + * + * @param processInstanceId 流程实例Id。 + * @return 查询结果集。 + */ + List getFlowTaskCommentList(String processInstanceId); + + /** + * 查询与指定流程任务Id集合关联的所有审批任务的批注。 + * + * @param taskIdSet 流程任务Id集合。 + * @return 查询结果集。 + */ + List getFlowTaskCommentListByTaskIds(Set taskIdSet); + + /** + * 获取指定流程实例的最后一条审批任务。 + * + * @param processInstanceId 流程实例Id。 + * @return 查询结果。 + */ + FlowTaskComment getLatestFlowTaskComment(String processInstanceId); + + /** + * 获取指定流程实例和任务定义标识的最后一条审批任务。 + * + * @param processInstanceId 流程实例Id。 + * @param taskDefinitionKey 任务定义标识。 + * @return 查询结果。 + */ + FlowTaskComment getLatestFlowTaskComment(String processInstanceId, String taskDefinitionKey); + + /** + * 获取指定流程实例的第一条审批任务。 + * + * @param processInstanceId 流程实例Id。 + * @return 查询结果。 + */ + FlowTaskComment getFirstFlowTaskComment(String processInstanceId); + + /** + * 获取指定任务实例和执行批次的审批数据列表。 + * + * @param processInstanceId 流程实例。 + * @param taskId 任务Id + * @param executionId 任务执行Id + * @return 审批数据列表。 + */ + List getFlowTaskCommentListByExecutionId( + String processInstanceId, String taskId, String executionId); + + /** + * 根据多实例执行Id获取任务审批对象数据列表。 + * + * @param multiInstanceExecId 多实例执行Id。 + * @return 审批数据列表。 + */ + List getFlowTaskCommentListByMultiInstanceExecId(String multiInstanceExecId); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowTaskExtService.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowTaskExtService.java new file mode 100644 index 00000000..dca29c00 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowTaskExtService.java @@ -0,0 +1,124 @@ +package com.orangeforms.common.flow.service; + +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.flow.object.FlowElementExtProperty; +import com.orangeforms.common.flow.vo.FlowUserInfoVo; +import com.orangeforms.common.core.base.service.IBaseService; +import org.flowable.bpmn.model.BpmnModel; +import org.flowable.bpmn.model.ExtensionElement; +import org.flowable.bpmn.model.FlowElement; +import org.flowable.bpmn.model.UserTask; +import org.flowable.task.api.TaskInfo; + +import java.util.List; +import java.util.Map; + +/** + * 流程任务扩展数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowTaskExtService extends IBaseService { + + /** + * 批量插入流程任务扩展信息列表。 + * + * @param flowTaskExtList 流程任务扩展信息列表。 + */ + void saveBatch(List flowTaskExtList); + + /** + * 查询指定的流程任务扩展对象。 + * + * @param processDefinitionId 流程引擎的定义Id。 + * @param taskId 流程引擎的任务Id。 + * @return 查询结果。 + */ + FlowTaskExt getByProcessDefinitionIdAndTaskId(String processDefinitionId, String taskId); + + /** + * 查询指定的流程定义的任务扩展对象。 + * + * @param processDefinitionId 流程引擎的定义Id。 + * @return 查询结果。 + */ + List getByProcessDefinitionId(String processDefinitionId); + + /** + * 获取任务扩展信息中的候选人用户信息列表。 + * + * @param processInstanceId 流程引擎的实例Id。 + * @param flowTaskExt 任务扩展对象。 + * @param taskInfo 任务信息。 + * @param isMultiInstanceTask 是否为多实例任务。 + * @param historic 是否为历史任务。 + * @return 候选人用户信息列表。 + */ + List getCandidateUserInfoList( + String processInstanceId, + FlowTaskExt flowTaskExt, + TaskInfo taskInfo, + boolean isMultiInstanceTask, + boolean historic); + + /** + * 获取指定任务的用户列表信息。 + * + * @param processInstanceId 流程实例。 + * @param executionId 执行实例。 + * @param flowTaskExt 流程用户任务的扩展对象。 + * @return 候选人用户信息列表。 + */ + List getCandidateUserInfoList( + String processInstanceId, + String executionId, + FlowTaskExt flowTaskExt); + + /** + * 通过UserTask对象中的扩展节点信息,构建FLowTaskExt对象。 + * + * @param userTask 流程图中定义的用户任务对象。 + * @return 构建后的流程任务扩展信息对象。 + */ + FlowTaskExt buildTaskExtByUserTask(UserTask userTask); + + /** + * 获取指定流程图中所有UserTask对象的扩展节点信息,构建FLowTaskExt对象列表。 + * + * @param bpmnModel 流程图模型对象。 + * @return 当前流程图中所有用户流程任务的扩展信息对象列表。 + */ + List buildTaskExtList(BpmnModel bpmnModel); + + /** + * 根据流程定义中用户任务的扩展节点数据,构建出前端所需的操作列表数据对象。 + * @param extensionMap 用户任务的扩展节点。 + * @return 前端所需的操作列表数据对象。 + */ + List buildOperationListExtensionElement(Map> extensionMap); + + /** + * 根据流程定义中用户任务的扩展节点数据,构建出前端所需的变量列表数据对象。 + * @param extensionMap 用户任务的扩展节点。 + * @return 前端所需的变量列表数据对象。 + */ + List buildVariableListExtensionElement(Map> extensionMap); + + /** + * 读取流程定义中,流程元素的扩展属性数据。 + * + * @param element 流程图中定义的流程元素。 + * @return 流程元素的扩展属性数据。 + */ + FlowElementExtProperty buildFlowElementExt(FlowElement element); + + /** + * 读取流程定义中,流程元素的扩展属性数据。 + * + * @param element 流程图中定义的流程元素。 + * @return 流程元素的扩展属性数据,并转换为JSON对象。 + */ + JSONObject buildFlowElementExtToJson(FlowElement element); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowWorkOrderService.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowWorkOrderService.java new file mode 100644 index 00000000..4299abe7 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowWorkOrderService.java @@ -0,0 +1,184 @@ +package com.orangeforms.common.flow.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.object.MyOrderParam; +import com.orangeforms.common.core.object.MyPageData; +import com.orangeforms.common.core.object.MyPageParam; +import com.orangeforms.common.flow.dto.FlowWorkOrderDto; +import com.orangeforms.common.flow.model.FlowWorkOrder; +import com.orangeforms.common.flow.model.FlowWorkOrderExt; +import com.orangeforms.common.flow.vo.FlowWorkOrderVo; +import org.flowable.engine.runtime.ProcessInstance; + +import java.util.*; + +/** + * 工作流工单表数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowWorkOrderService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param instance 流程实例对象。 + * @param dataId 流程实例的BusinessKey。 + * @param onlineTableId 在线数据表的主键Id。 + * @param tableName 面向静态表单所使用的表名。 + * @return 新增的工作流工单对象。 + */ + FlowWorkOrder saveNew(ProcessInstance instance, Object dataId, Long onlineTableId, String tableName); + + /** + * 保存工单草稿。 + * + * @param instance 流程实例对象。 + * @param onlineTableId 在线表单的主表Id。 + * @param tableName 静态表单的主表表名。 + * @param masterData 主表数据。 + * @param slaveData 从表数据。 + * @return 工单对象。 + */ + FlowWorkOrder saveNewWithDraft( + ProcessInstance instance, Long onlineTableId, String tableName, String masterData, String slaveData); + + /** + * 更新流程工单的草稿数据。 + * + * @param workOrderId 工单Id。 + * @param masterData 主表数据。 + * @param slaveData 从表数据。 + */ + void updateDraft(Long workOrderId, String masterData, String slaveData); + + /** + * 删除指定数据。 + * + * @param workOrderId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long workOrderId); + + /** + * 删除指定流程实例Id的关联工单。 + * + * @param processInstanceId 流程实例Id。 + */ + void removeByProcessInstanceId(String processInstanceId); + + /** + * 获取工作流工单单表查询结果。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getFlowWorkOrderList(FlowWorkOrder filter, String orderBy); + + /** + * 获取工作流工单列表及其关联字典数据。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getFlowWorkOrderListWithRelation(FlowWorkOrder filter, String orderBy); + + /** + * 根据流程实例Id,查询关联的工单对象。 + * + * @param processInstanceId 流程实例Id。 + * @return 工作流工单对象。 + */ + FlowWorkOrder getFlowWorkOrderByProcessInstanceId(String processInstanceId); + + /** + * 根据业务主键,查询是否存在指定的工单。 + * + * @param tableName 静态表单工作流使用的数据表。 + * @param businessKey 业务数据主键Id。 + * @param unfinished 是否为没有结束工单。 + * @return 存在返回true,否则false。 + */ + boolean existByBusinessKey(String tableName, Object businessKey, boolean unfinished); + + /** + * 根据流程定义和业务主键,查询是否存在指定的未完成工单。 + * + * @param processDefinitionKey 静态表单工作流使用的数据表。 + * @param businessKey 业务数据主键Id。 + * @return 存在返回true,否则false。 + */ + boolean existUnfinished(String processDefinitionKey, Object businessKey); + + /** + * 根据流程实例Id,更新流程状态。 + * + * @param processInstanceId 流程实例Id。 + * @param flowStatus 新的流程状态值,如果该值为null,不执行任何更新。 + */ + void updateFlowStatusByProcessInstanceId(String processInstanceId, Integer flowStatus); + + /** + * 根据流程实例Id,更新流程最后审批状态。 + * + * @param processInstanceId 流程实例Id。 + * @param approvalStatus 新的流程最后审批状态,如果该值为null,不执行任何更新。 + */ + void updateLatestApprovalStatusByProcessInstanceId(String processInstanceId, Integer approvalStatus); + + /** + * 是否有查看该工单的数据权限。 + * + * @param processInstanceId 流程实例Id。 + * @return 存在返回true,否则false。 + */ + boolean hasDataPermOnFlowWorkOrder(String processInstanceId); + + /** + * 根据工单列表中的submitUserName,找到映射的userShowName,并会写到Vo中指定字段。 + * 同时这也是一个如何通过插件方法,将loginName映射到showName的示例, + * + * @param dataList 工单Vo对象列表。 + */ + void fillUserShowNameByLoginName(List dataList); + + /** + * 根据工单Id获取工单扩展对象数据。 + * + * @param workOrderId 工单Id。 + * @return 工单扩展对象。 + */ + FlowWorkOrderExt getFlowWorkOrderExtByWorkOrderId(Long workOrderId); + + /** + * 根据工单Id集合获取工单扩展对象数据列表。 + * + * @param workOrderIds 工单Id集合。 + * @return 工单扩展对象列表。 + */ + List getFlowWorkOrderExtByWorkOrderIds(Set workOrderIds); + + /** + * 移除草稿工单,同时停止已经启动的流程实例。 + * + * @param flowWorkOrder 工单对象。 + * @return 停止流程实例的结果。 + */ + CallResult removeDraft(FlowWorkOrder flowWorkOrder); + + /** + * 获取分页后的工单列表同时构建部分任务数据。该方法主要是为了尽量减少路由表单工作流listWorkOrder的重复代码。 + * + * @param filter 工单过滤对象。 + * @param pageParam 分页参数对象。 + * @param orderParam 排序参数对象。 + * @param processDefinitionKey 流程定义标识。 + * @return 分页的工单列表。 + */ + MyPageData getPagedWorkOrderListAndBuildData( + FlowWorkOrderDto filter, MyPageParam pageParam, MyOrderParam orderParam, String processDefinitionKey); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowApiServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowApiServiceImpl.java new file mode 100644 index 00000000..164d5486 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowApiServiceImpl.java @@ -0,0 +1,2032 @@ +package com.orangeforms.common.flow.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.*; +import cn.hutool.core.convert.Convert; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.annotation.MultiDatabaseWriteMethod; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.constant.UserFilterGroup; +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyDateUtil; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.flow.exception.FlowOperationException; +import com.orangeforms.common.flow.object.*; +import com.orangeforms.common.flow.constant.FlowConstant; +import com.orangeforms.common.flow.constant.FlowApprovalType; +import com.orangeforms.common.flow.constant.FlowTaskStatus; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.flow.service.*; +import com.orangeforms.common.flow.util.BaseFlowIdentityExtHelper; +import com.orangeforms.common.flow.util.CustomChangeActivityStateBuilderImpl; +import com.orangeforms.common.flow.util.FlowCustomExtFactory; +import com.orangeforms.common.flow.vo.FlowTaskVo; +import com.orangeforms.common.flow.vo.FlowUserInfoVo; +import lombok.Cleanup; +import lombok.extern.slf4j.Slf4j; +import org.flowable.bpmn.converter.BpmnXMLConverter; +import org.flowable.bpmn.model.*; +import org.flowable.bpmn.model.Process; +import org.flowable.common.engine.impl.de.odysseus.el.ExpressionFactoryImpl; +import org.flowable.common.engine.impl.de.odysseus.el.util.SimpleContext; +import org.flowable.common.engine.impl.identity.Authentication; +import org.flowable.common.engine.impl.javax.el.ExpressionFactory; +import org.flowable.common.engine.impl.javax.el.ValueExpression; +import org.flowable.engine.*; +import org.flowable.engine.delegate.ExecutionListener; +import org.flowable.engine.delegate.TaskListener; +import org.flowable.engine.history.*; +import org.flowable.engine.impl.RuntimeServiceImpl; +import org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior; +import org.flowable.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior; +import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl; +import org.flowable.engine.repository.ProcessDefinition; +import org.flowable.engine.runtime.ChangeActivityStateBuilder; +import org.flowable.engine.runtime.Execution; +import org.flowable.engine.runtime.ProcessInstance; +import org.flowable.engine.runtime.ProcessInstanceBuilder; +import org.flowable.identitylink.api.IdentityLink; +import org.flowable.task.api.Task; +import org.flowable.task.api.TaskInfo; +import org.flowable.task.api.TaskQuery; +import org.flowable.task.api.history.HistoricTaskInstance; +import org.flowable.task.api.history.HistoricTaskInstanceQuery; +import org.flowable.variable.api.history.HistoricVariableInstance; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; + +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("flowApiService") +public class FlowApiServiceImpl implements FlowApiService { + + @Autowired + private RepositoryService repositoryService; + @Autowired + private RuntimeService runtimeService; + @Autowired + private TaskService taskService; + @Autowired + private HistoryService historyService; + @Autowired + private ManagementService managementService; + @Autowired + private FlowEntryService flowEntryService; + @Autowired + private FlowTaskCommentService flowTaskCommentService; + @Autowired + private FlowTaskExtService flowTaskExtService; + @Autowired + private FlowWorkOrderService flowWorkOrderService; + @Autowired + private FlowMessageService flowMessageService; + @Autowired + private FlowCustomExtFactory flowCustomExtFactory; + @Autowired + private FlowMultiInstanceTransService flowMultiInstanceTransService; + + @Transactional(rollbackFor = Exception.class) + @Override + public ProcessInstance start(String processDefinitionId, Object dataId) { + TokenData tokenData = TokenData.takeFromRequest(); + Map variableMap = this.initAndGetProcessInstanceVariables(processDefinitionId); + Authentication.setAuthenticatedUserId(tokenData.getLoginName()); + String businessKey = dataId == null ? null : dataId.toString(); + ProcessInstanceBuilder builder = runtimeService.createProcessInstanceBuilder() + .processDefinitionId(processDefinitionId).businessKey(businessKey).variables(variableMap); + if (tokenData.getTenantId() != null) { + builder.tenantId(tokenData.getTenantId().toString()); + } else { + if (tokenData.getAppCode() != null) { + builder.tenantId(tokenData.getAppCode()); + } + } + return builder.start(); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public Task takeFirstTask(String processInstanceId, FlowTaskComment flowTaskComment, JSONObject taskVariableData) { + String loginName = TokenData.takeFromRequest().getLoginName(); + // 获取流程启动后的第一个任务。 + Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).active().singleResult(); + if (StrUtil.equalsAny(task.getAssignee(), loginName, FlowConstant.START_USER_NAME_VAR)) { + // 按照规则,调用该方法的用户,就是第一个任务的assignee,因此默认会自动执行complete。 + flowTaskComment.fillWith(task); + this.completeTask(task, flowTaskComment, taskVariableData); + } + return task; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public ProcessInstance startAndTakeFirst( + String processDefinitionId, Object dataId, FlowTaskComment flowTaskComment, JSONObject taskVariableData) { + ProcessInstance instance = this.start(processDefinitionId, dataId); + this.takeFirstTask(instance.getProcessInstanceId(), flowTaskComment, taskVariableData); + return instance; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void submitConsign( + HistoricTaskInstance startTaskInstance, Task multiInstanceActiveTask, String newAssignees, boolean isAdd) { + JSONArray assigneeArray = JSON.parseArray(newAssignees); + String multiInstanceExecId = this.getExecutionVariableStringWithSafe( + multiInstanceActiveTask.getExecutionId(), FlowConstant.MULTI_SIGN_TASK_EXECUTION_ID_VAR); + FlowMultiInstanceTrans trans = + flowMultiInstanceTransService.getWithAssigneeListByMultiInstanceExecId(multiInstanceExecId); + Set assigneeSet = new HashSet<>(StrUtil.split(trans.getAssigneeList(), ",")); + Task runtimeTask = null; + for (int i = 0; i < assigneeArray.size(); i++) { + String assignee = assigneeArray.getString(i); + if (isAdd) { + assigneeSet.add(assignee); + } else { + assigneeSet.remove(assignee); + } + if (isAdd) { + Map variables = new HashMap<>(2); + variables.put("assignee", assigneeArray.getString(i)); + variables.put(FlowConstant.MULTI_SIGN_START_TASK_VAR, startTaskInstance.getId()); + runtimeService.addMultiInstanceExecution( + multiInstanceActiveTask.getTaskDefinitionKey(), multiInstanceActiveTask.getProcessInstanceId(), variables); + } else { + TaskQuery query = taskService.createTaskQuery().active(); + query.processInstanceId(multiInstanceActiveTask.getProcessInstanceId()); + query.taskDefinitionKey(multiInstanceActiveTask.getTaskDefinitionKey()); + query.taskAssignee(assignee); + runtimeTask = query.singleResult(); + if (runtimeTask == null) { + throw new FlowOperationException("审批人 [" + assignee + "] 已经提交审批,不能执行减签操作!"); + } + runtimeService.deleteMultiInstanceExecution(runtimeTask.getExecutionId(), false); + } + } + if (!isAdd && runtimeTask != null) { + this.doChangeTask(runtimeTask); + } + trans.setAssigneeList(StrUtil.join(",", assigneeSet)); + flowMultiInstanceTransService.updateById(trans); + FlowTaskComment flowTaskComment = new FlowTaskComment(); + flowTaskComment.fillWith(startTaskInstance); + flowTaskComment.setApprovalType(isAdd ? FlowApprovalType.MULTI_CONSIGN : FlowApprovalType.MULTI_MINUS_SIGN); + String showName = TokenData.takeFromRequest().getLoginName(); + String comment = String.format("用户 [%s] [%s] [%s]。", isAdd ? "加签" : "减签", showName, newAssignees); + flowTaskComment.setTaskComment(comment); + flowTaskCommentService.saveNew(flowTaskComment); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void completeTask(Task task, FlowTaskComment flowTaskComment, JSONObject taskVariableData) { + if (taskVariableData == null) { + taskVariableData = new JSONObject(); + } + JSONObject passCopyData = (JSONObject) taskVariableData.remove(FlowConstant.COPY_DATA_KEY); + // 判断当前完成执行的任务,是否存在抄送设置。 + Object copyData = runtimeService.getVariable( + task.getProcessInstanceId(), FlowConstant.COPY_DATA_MAP_PREFIX + task.getTaskDefinitionKey()); + if (copyData != null || passCopyData != null) { + JSONObject copyDataJson = this.mergeCopyData(copyData, passCopyData); + flowMessageService.saveNewCopyMessage(task, copyDataJson); + } + if (flowTaskComment != null) { + // 这里处理多实例会签逻辑。 + if (flowTaskComment.getApprovalType().equals(FlowApprovalType.MULTI_SIGN)) { + String loginName = TokenData.takeFromRequest().getLoginName(); + String assigneeList = this.getMultiInstanceAssigneeList(task, taskVariableData); + Assert.isTrue(StrUtil.isNotBlank(assigneeList)); + taskVariableData.put(FlowConstant.MULTI_AGREE_COUNT_VAR, 0); + taskVariableData.put(FlowConstant.MULTI_REFUSE_COUNT_VAR, 0); + taskVariableData.put(FlowConstant.MULTI_ABSTAIN_COUNT_VAR, 0); + taskVariableData.put(FlowConstant.MULTI_SIGN_NUM_OF_INSTANCES_VAR, 0); + taskVariableData.put(FlowConstant.MULTI_SIGN_START_TASK_VAR, task.getId()); + String multiInstanceExecId = MyCommonUtil.generateUuid(); + taskVariableData.put(FlowConstant.MULTI_SIGN_TASK_EXECUTION_ID_VAR, multiInstanceExecId); + String comment = String.format("用户 [%s] 会签 [%s]。", loginName, assigneeList); + FlowMultiInstanceTrans multiInstanceTrans = new FlowMultiInstanceTrans(task); + multiInstanceTrans.setMultiInstanceExecId(multiInstanceExecId); + multiInstanceTrans.setAssigneeList(assigneeList); + flowMultiInstanceTransService.saveNew(multiInstanceTrans); + flowTaskComment.setTaskComment(comment); + } + // 处理转办。 + if (FlowApprovalType.TRANSFER.equals(flowTaskComment.getApprovalType())) { + this.transferTo(task, flowTaskComment); + return; + } + this.handleMultiInstanceApprovalType( + task.getExecutionId(), flowTaskComment.getApprovalType(), taskVariableData); + taskVariableData.put(FlowConstant.OPERATION_TYPE_VAR, flowTaskComment.getApprovalType()); + this.setSubmitUserVar(taskVariableData, flowTaskComment); + flowTaskComment.fillWith(task); + if (this.isMultiInstanceTask(task.getProcessDefinitionId(), task.getTaskDefinitionKey())) { + String multiInstanceExecId = getExecutionVariableStringWithSafe( + task.getExecutionId(), FlowConstant.MULTI_SIGN_TASK_EXECUTION_ID_VAR); + FlowMultiInstanceTrans multiInstanceTrans = new FlowMultiInstanceTrans(task); + multiInstanceTrans.setMultiInstanceExecId(multiInstanceExecId); + flowMultiInstanceTransService.saveNew(multiInstanceTrans); + flowTaskComment.setMultiInstanceExecId(multiInstanceExecId); + } + flowTaskCommentService.saveNew(flowTaskComment); + } + taskVariableData.remove(FlowConstant.PROC_INSTANCE_START_USER_NAME_VAR); + Integer approvalStatus = MapUtil.getInt(taskVariableData, FlowConstant.LATEST_APPROVAL_STATUS_KEY); + flowWorkOrderService.updateLatestApprovalStatusByProcessInstanceId(task.getProcessInstanceId(), approvalStatus); + taskService.complete(task.getId(), taskVariableData, this.makeTransientVariableMap(taskVariableData)); + flowMessageService.updateFinishedStatusByTaskId(task.getId()); + } + + private void setSubmitUserVar(JSONObject taskVariableData, FlowTaskComment comment) { + TokenData tokenData = TokenData.takeFromRequest(); + if (tokenData != null) { + taskVariableData.put(FlowConstant.SUBMIT_USER_VAR, tokenData.getLoginName()); + } else { + if (StrUtil.isNotBlank(comment.getCreateLoginName())) { + taskVariableData.put(FlowConstant.SUBMIT_USER_VAR, comment.getCreateLoginName()); + } + } + } + + private JSONObject makeTransientVariableMap(JSONObject taskVariableData) { + JSONObject result = new JSONObject(); + if (taskVariableData == null) { + return result; + } + Object masterData = taskVariableData.get(FlowConstant.MASTER_DATA_KEY); + if (masterData != null) { + result.put(FlowConstant.MASTER_DATA_KEY, masterData); + } + Object slaveData = taskVariableData.get(FlowConstant.SLAVE_DATA_KEY); + if (slaveData != null) { + result.put(FlowConstant.SLAVE_DATA_KEY, slaveData); + } + Object masterTable = taskVariableData.get(FlowConstant.MASTER_TABLE_KEY); + if (masterTable != null) { + result.put(FlowConstant.MASTER_TABLE_KEY, masterTable); + } + taskVariableData.remove(FlowConstant.MASTER_DATA_KEY); + taskVariableData.remove(FlowConstant.SLAVE_DATA_KEY); + taskVariableData.remove(FlowConstant.MASTER_TABLE_KEY); + return result; + } + + private String getMultiInstanceAssigneeList(Task task, JSONObject taskVariableData) { + JSONArray assigneeArray = taskVariableData.getJSONArray(FlowConstant.MULTI_ASSIGNEE_LIST_VAR); + String assigneeList; + if (CollUtil.isEmpty(assigneeArray)) { + FlowTaskExt flowTaskExt = flowTaskExtService.getByProcessDefinitionIdAndTaskId( + task.getProcessDefinitionId(), task.getTaskDefinitionKey()); + assigneeList = this.buildMutiSignAssigneeList(flowTaskExt.getOperationListJson()); + if (assigneeList != null) { + taskVariableData.put(FlowConstant.MULTI_ASSIGNEE_LIST_VAR, StrUtil.split(assigneeList, ',')); + } + } else { + assigneeList = CollUtil.join(assigneeArray, ","); + } + return assigneeList; + } + + private JSONObject mergeCopyData(Object copyData, JSONObject passCopyData) { + // passCopyData是传阅数据,copyData是抄送数据。 + JSONObject resultCopyDataJson = passCopyData; + if (resultCopyDataJson == null) { + resultCopyDataJson = JSON.parseObject(copyData.toString()); + } else if (copyData != null) { + JSONObject copyDataJson = JSON.parseObject(copyData.toString()); + for (Map.Entry entry : copyDataJson.entrySet()) { + String value = resultCopyDataJson.getString(entry.getKey()); + if (value == null) { + resultCopyDataJson.put(entry.getKey(), entry.getValue()); + } else { + List list1 = StrUtil.split(value, ","); + List list2 = StrUtil.split(entry.getValue().toString(), ","); + Set valueSet = new HashSet<>(list1); + valueSet.addAll(list2); + resultCopyDataJson.put(entry.getKey(), StrUtil.join(",", valueSet)); + } + } + } + this.processMergeCopyData(resultCopyDataJson); + return resultCopyDataJson; + } + + private void processMergeCopyData(JSONObject resultCopyDataJson) { + TokenData tokenData = TokenData.takeFromRequest(); + BaseFlowIdentityExtHelper flowIdentityExtHelper = flowCustomExtFactory.getFlowIdentityExtHelper(); + for (Map.Entry entry : resultCopyDataJson.entrySet()) { + String type = entry.getKey(); + switch (type) { + case FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER_VAR: + Object upLeaderDeptPostId = + flowIdentityExtHelper.getUpLeaderDeptPostId(tokenData.getDeptId()); + entry.setValue(upLeaderDeptPostId); + break; + case FlowConstant.GROUP_TYPE_DEPT_POST_LEADER_VAR: + Object leaderDeptPostId = + flowIdentityExtHelper.getLeaderDeptPostId(tokenData.getDeptId()); + entry.setValue(leaderDeptPostId); + break; + case FlowConstant.GROUP_TYPE_SELF_DEPT_POST_VAR: + Set selfPostIdSet = new HashSet<>(StrUtil.split(entry.getValue().toString(), ",")); + Map deptPostIdMap = + flowIdentityExtHelper.getDeptPostIdMap(tokenData.getDeptId(), selfPostIdSet); + String deptPostIdValues = ""; + if (deptPostIdMap != null) { + deptPostIdValues = StrUtil.join(",", deptPostIdMap.values()); + } + entry.setValue(deptPostIdValues); + break; + case FlowConstant.GROUP_TYPE_SIBLING_DEPT_POST_VAR: + Set siblingPostIdSet = new HashSet<>(StrUtil.split(entry.getValue().toString(), ",")); + Map siblingDeptPostIdMap = + flowIdentityExtHelper.getSiblingDeptPostIdMap(tokenData.getDeptId(), siblingPostIdSet); + String siblingDeptPostIdValues = ""; + if (siblingDeptPostIdMap != null) { + siblingDeptPostIdValues = StrUtil.join(",", siblingDeptPostIdMap.values()); + } + entry.setValue(siblingDeptPostIdValues); + break; + case FlowConstant.GROUP_TYPE_UP_DEPT_POST_VAR: + Set upPostIdSet = new HashSet<>(StrUtil.split(entry.getValue().toString(), ",")); + Map upDeptPostIdMap = + flowIdentityExtHelper.getUpDeptPostIdMap(tokenData.getDeptId(), upPostIdSet); + String upDeptPostIdValues = ""; + if (upDeptPostIdMap != null) { + upDeptPostIdValues = StrUtil.join(",", upDeptPostIdMap.values()); + } + entry.setValue(upDeptPostIdValues); + break; + default: + break; + } + } + } + + @Transactional(rollbackFor = Exception.class) + @Override + public CallResult verifyAssigneeOrCandidateAndClaim(Task task) { + String errorMessage; + String loginName = TokenData.takeFromRequest().getLoginName(); + // 这里必须先执行拾取操作,如果当前用户是候选人,特别是对于分布式场景,更是要先完成候选人的拾取。 + if (task.getAssignee() == null) { + // 没有指派人 + if (!this.isAssigneeOrCandidate(task)) { + errorMessage = "数据验证失败,当前用户不是该待办任务的候选人,请刷新后重试!"; + return CallResult.error(errorMessage); + } + // 作为候选人主动拾取任务。 + taskService.claim(task.getId(), loginName); + } else { + if (!task.getAssignee().equals(loginName)) { + errorMessage = "数据验证失败,当前用户不是该待办任务的指派人,请刷新后重试!"; + return CallResult.error(errorMessage); + } + } + return CallResult.ok(); + } + + @Override + public Map initAndGetProcessInstanceVariables(String processDefinitionId) { + TokenData tokenData = TokenData.takeFromRequest(); + String loginName = tokenData.getLoginName(); + // 设置流程变量。 + Map variableMap = new HashMap<>(4); + variableMap.put(FlowConstant.PROC_INSTANCE_INITIATOR_VAR, loginName); + variableMap.put(FlowConstant.PROC_INSTANCE_START_USER_NAME_VAR, loginName); + List flowTaskExtList = flowTaskExtService.getByProcessDefinitionId(processDefinitionId); + boolean hasDeptPostLeader = false; + boolean hasUpDeptPostLeader = false; + boolean hasPostCandidateGroup = false; + for (FlowTaskExt flowTaskExt : flowTaskExtList) { + if (StrUtil.equals(flowTaskExt.getGroupType(), FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER)) { + hasUpDeptPostLeader = true; + } else if (StrUtil.equals(flowTaskExt.getGroupType(), FlowConstant.GROUP_TYPE_DEPT_POST_LEADER)) { + hasDeptPostLeader = true; + } else if (StrUtil.equals(flowTaskExt.getGroupType(), FlowConstant.GROUP_TYPE_POST)) { + hasPostCandidateGroup = true; + } + } + // 如果流程图的配置中包含用户身份相关的变量(如:部门领导和上级领导审批),flowIdentityExtHelper就不能为null。 + // 这个需要子类去实现 BaseFlowIdentityExtHelper 接口,并注册到FlowCustomExtFactory的工厂中。 + BaseFlowIdentityExtHelper flowIdentityExtHelper = flowCustomExtFactory.getFlowIdentityExtHelper(); + if (hasUpDeptPostLeader) { + Assert.notNull(flowIdentityExtHelper); + Object upLeaderDeptPostId = flowIdentityExtHelper.getUpLeaderDeptPostId(tokenData.getDeptId()); + if (upLeaderDeptPostId == null) { + variableMap.put(FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER_VAR, null); + } else { + variableMap.put(FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER_VAR, upLeaderDeptPostId.toString()); + } + } + if (hasDeptPostLeader) { + Assert.notNull(flowIdentityExtHelper); + Object leaderDeptPostId = flowIdentityExtHelper.getLeaderDeptPostId(tokenData.getDeptId()); + if (leaderDeptPostId == null) { + variableMap.put(FlowConstant.GROUP_TYPE_DEPT_POST_LEADER_VAR, null); + } else { + variableMap.put(FlowConstant.GROUP_TYPE_DEPT_POST_LEADER_VAR, leaderDeptPostId.toString()); + } + } + if (hasPostCandidateGroup) { + Assert.notNull(flowIdentityExtHelper); + Map postGroupDataMap = + this.buildPostCandidateGroupData(flowIdentityExtHelper, flowTaskExtList); + variableMap.putAll(postGroupDataMap); + } + this.buildCopyData(flowTaskExtList, variableMap); + return variableMap; + } + + private void buildCopyData(List flowTaskExtList, Map variableMap) { + for (FlowTaskExt flowTaskExt : flowTaskExtList) { + if (StrUtil.isBlank(flowTaskExt.getCopyListJson())) { + continue; + } + List copyDataList = JSON.parseArray(flowTaskExt.getCopyListJson(), JSONObject.class); + Map copyDataMap = new HashMap<>(copyDataList.size()); + for (JSONObject copyData : copyDataList) { + String type = copyData.getString("type"); + String id = copyData.getString("id"); + copyDataMap.put(type, id == null ? "" : id); + } + variableMap.put(FlowConstant.COPY_DATA_MAP_PREFIX + flowTaskExt.getTaskId(), JSON.toJSONString(copyDataMap)); + } + } + + private Map buildPostCandidateGroupData( + BaseFlowIdentityExtHelper flowIdentityExtHelper, List flowTaskExtList) { + Map postVariableMap = MapUtil.newHashMap(); + Set selfPostIdSet = new HashSet<>(); + Set siblingPostIdSet = new HashSet<>(); + Set upPostIdSet = new HashSet<>(); + for (FlowTaskExt flowTaskExt : flowTaskExtList) { + if (flowTaskExt.getGroupType().equals(FlowConstant.GROUP_TYPE_POST)) { + Assert.notNull(flowTaskExt.getDeptPostListJson()); + List groupDataList = + JSONArray.parseArray(flowTaskExt.getDeptPostListJson(), FlowTaskPostCandidateGroup.class); + for (FlowTaskPostCandidateGroup groupData : groupDataList) { + switch (groupData.getType()) { + case FlowConstant.GROUP_TYPE_SELF_DEPT_POST_VAR -> selfPostIdSet.add(groupData.getPostId()); + case FlowConstant.GROUP_TYPE_SIBLING_DEPT_POST_VAR -> siblingPostIdSet.add(groupData.getPostId()); + case FlowConstant.GROUP_TYPE_UP_DEPT_POST_VAR -> upPostIdSet.add(groupData.getPostId()); + default -> { + } + } + } + } + } + postVariableMap.putAll(this.buildSelfPostCandidateGroupData(flowIdentityExtHelper, selfPostIdSet)); + postVariableMap.putAll(this.buildSiblingPostCandidateGroupData(flowIdentityExtHelper, siblingPostIdSet)); + postVariableMap.putAll(this.buildUpPostCandidateGroupData(flowIdentityExtHelper, upPostIdSet)); + return postVariableMap; + } + + private Map buildSelfPostCandidateGroupData( + BaseFlowIdentityExtHelper flowIdentityExtHelper, Set selfPostIdSet) { + Map postVariableMap = MapUtil.newHashMap(); + if (CollUtil.isNotEmpty(selfPostIdSet)) { + Map deptPostIdMap = + flowIdentityExtHelper.getDeptPostIdMap(TokenData.takeFromRequest().getDeptId(), selfPostIdSet); + for (String postId : selfPostIdSet) { + if (MapUtil.isNotEmpty(deptPostIdMap) && deptPostIdMap.containsKey(postId)) { + String deptPostId = deptPostIdMap.get(postId); + postVariableMap.put(FlowConstant.SELF_DEPT_POST_PREFIX + postId, deptPostId); + } else { + postVariableMap.put(FlowConstant.SELF_DEPT_POST_PREFIX + postId, ""); + } + } + } + return postVariableMap; + } + + private Map buildSiblingPostCandidateGroupData( + BaseFlowIdentityExtHelper flowIdentityExtHelper, Set siblingPostIdSet) { + Map postVariableMap = MapUtil.newHashMap(); + if (CollUtil.isNotEmpty(siblingPostIdSet)) { + Map siblingDeptPostIdMap = + flowIdentityExtHelper.getSiblingDeptPostIdMap(TokenData.takeFromRequest().getDeptId(), siblingPostIdSet); + for (String postId : siblingPostIdSet) { + if (MapUtil.isNotEmpty(siblingDeptPostIdMap) && siblingDeptPostIdMap.containsKey(postId)) { + String siblingDeptPostId = siblingDeptPostIdMap.get(postId); + postVariableMap.put(FlowConstant.SIBLING_DEPT_POST_PREFIX + postId, siblingDeptPostId); + } else { + postVariableMap.put(FlowConstant.SIBLING_DEPT_POST_PREFIX + postId, ""); + } + } + } + return postVariableMap; + } + + private Map buildUpPostCandidateGroupData( + BaseFlowIdentityExtHelper flowIdentityExtHelper, Set upPostIdSet) { + Map postVariableMap = MapUtil.newHashMap(); + if (CollUtil.isNotEmpty(upPostIdSet)) { + Map upDeptPostIdMap = + flowIdentityExtHelper.getUpDeptPostIdMap(TokenData.takeFromRequest().getDeptId(), upPostIdSet); + for (String postId : upPostIdSet) { + if (MapUtil.isNotEmpty(upDeptPostIdMap) && upDeptPostIdMap.containsKey(postId)) { + String upDeptPostId = upDeptPostIdMap.get(postId); + postVariableMap.put(FlowConstant.UP_DEPT_POST_PREFIX + postId, upDeptPostId); + } else { + postVariableMap.put(FlowConstant.UP_DEPT_POST_PREFIX + postId, ""); + } + } + } + return postVariableMap; + } + + @Override + public boolean isAssigneeOrCandidate(TaskInfo task) { + String loginName = TokenData.takeFromRequest().getLoginName(); + if (StrUtil.isNotBlank(task.getAssignee())) { + return StrUtil.equals(loginName, task.getAssignee()); + } + TaskQuery query = taskService.createTaskQuery(); + this.buildCandidateCondition(query, loginName); + query.taskId(task.getId()); + return query.active().count() != 0; + } + + @Override + public Collection getProcessAllElements(String processDefinitionId) { + Process process = repositoryService.getBpmnModel(processDefinitionId).getProcesses().get(0); + return this.getAllElements(process.getFlowElements(), null); + } + + @Override + public boolean isProcessInstanceStarter(String processInstanceId) { + String loginName = TokenData.takeFromRequest().getLoginName(); + return historyService.createHistoricProcessInstanceQuery() + .processInstanceId(processInstanceId).startedBy(loginName).count() != 0; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void setBusinessKeyForProcessInstance(String processInstanceId, Object dataId) { + runtimeService.updateBusinessKey(processInstanceId, dataId.toString()); + } + + @Override + public boolean existActiveProcessInstance(String processInstanceId) { + return runtimeService.createProcessInstanceQuery() + .processInstanceId(processInstanceId).active().count() != 0; + } + + @Override + public ProcessInstance getProcessInstance(String processInstanceId) { + return runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); + } + + @Override + public ProcessInstance getProcessInstanceByBusinessKey(String processDefinitionId, String businessKey) { + return runtimeService.createProcessInstanceQuery() + .processDefinitionId(processDefinitionId).processInstanceBusinessKey(businessKey).singleResult(); + } + + @Override + public Task getProcessInstanceActiveTask(String processInstanceId, String taskId) { + TaskQuery query = taskService.createTaskQuery().processInstanceId(processInstanceId); + if (StrUtil.isNotBlank(taskId)) { + query.taskId(taskId); + } + return query.active().singleResult(); + } + + @Override + public List getProcessInstanceActiveTaskList(String processInstanceId) { + return taskService.createTaskQuery().processInstanceId(processInstanceId).list(); + } + + @Override + public List getProcessInstanceActiveTaskListAndConvert(String processInstanceId) { + List taskList = taskService.createTaskQuery().processInstanceId(processInstanceId).list(); + return this.convertToFlowTaskList(taskList); + } + + @Override + public Task getTaskById(String taskId) { + return taskService.createTaskQuery().taskId(taskId).singleResult(); + } + + @Override + public MyPageData getTaskListByUserName( + String username, String definitionKey, String definitionName, String taskName, MyPageParam pageParam) { + TaskQuery query = this.createQuery(); + if (StrUtil.isNotBlank(definitionKey)) { + query.processDefinitionKey(definitionKey); + } + if (StrUtil.isNotBlank(definitionName)) { + query.processDefinitionNameLike("%" + definitionName + "%"); + } + if (StrUtil.isNotBlank(taskName)) { + query.taskNameLike("%" + taskName + "%"); + } + this.buildCandidateCondition(query, username); + long totalCount = query.count(); + query.orderByTaskCreateTime().desc(); + int firstResult = (pageParam.getPageNum() - 1) * pageParam.getPageSize(); + List taskList = query.listPage(firstResult, pageParam.getPageSize()); + return new MyPageData<>(taskList, totalCount); + } + + @Override + public long getTaskCountByUserName(String username) { + TaskQuery query = this.createQuery(); + this.buildCandidateCondition(query, username); + return query.count(); + } + + @Override + public List getTaskListByProcessInstanceIds(List processInstanceIdSet) { + return taskService.createTaskQuery().processInstanceIdIn(processInstanceIdSet).active().list(); + } + + @Override + public List getProcessInstanceList(Set processInstanceIdSet) { + return runtimeService.createProcessInstanceQuery().processInstanceIds(processInstanceIdSet).list(); + } + + @Override + public ProcessDefinition getProcessDefinitionById(String processDefinitionId) { + return repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult(); + } + + @Override + public List getProcessDefinitionList(Set processDefinitionIdSet) { + return repositoryService.createProcessDefinitionQuery().processDefinitionIds(processDefinitionIdSet).list(); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void suspendProcessDefinition(String processDefinitionId) { + repositoryService.suspendProcessDefinitionById(processDefinitionId); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void activateProcessDefinition(String processDefinitionId) { + repositoryService.activateProcessDefinitionById(processDefinitionId); + } + + @Override + public BpmnModel getBpmnModelByDefinitionId(String processDefinitionId) { + return repositoryService.getBpmnModel(processDefinitionId); + } + + @Override + public boolean isMultiInstanceTask(String processDefinitionId, String taskKey) { + BpmnModel model = this.getBpmnModelByDefinitionId(processDefinitionId); + FlowElement flowElement = model.getFlowElement(taskKey); + if (!(flowElement instanceof UserTask userTask)) { + return false; + } + return userTask.hasMultiInstanceLoopCharacteristics(); + } + + @Override + public ProcessDefinition getProcessDefinitionByDeployId(String deployId) { + return repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult(); + } + + @Override + public void setProcessInstanceVariables(String processInstanceId, Map variableMap) { + runtimeService.setVariables(processInstanceId, variableMap); + } + + @Override + public Object getProcessInstanceVariable(String processInstanceId, String variableName) { + return runtimeService.getVariable(processInstanceId, variableName); + } + + @Override + public List convertToFlowTaskList(List taskList) { + List flowTaskVoList = new LinkedList<>(); + if (CollUtil.isEmpty(taskList)) { + return flowTaskVoList; + } + Set processDefinitionIdSet = taskList.stream() + .map(Task::getProcessDefinitionId).collect(Collectors.toSet()); + Set procInstanceIdSet = taskList.stream() + .map(Task::getProcessInstanceId).collect(Collectors.toSet()); + List flowEntryPublishList = + flowEntryService.getFlowEntryPublishList(processDefinitionIdSet); + Map flowEntryPublishMap = + flowEntryPublishList.stream().collect(Collectors.toMap(FlowEntryPublish::getProcessDefinitionId, c -> c)); + List instanceList = this.getProcessInstanceList(procInstanceIdSet); + Map instanceMap = + instanceList.stream().collect(Collectors.toMap(ProcessInstance::getId, c -> c)); + List definitionList = this.getProcessDefinitionList(processDefinitionIdSet); + Map definitionMap = + definitionList.stream().collect(Collectors.toMap(ProcessDefinition::getId, c -> c)); + List workOrderList = + flowWorkOrderService.getInList("processInstanceId", procInstanceIdSet); + Map workOrderMap = + workOrderList.stream().collect(Collectors.toMap(FlowWorkOrder::getProcessInstanceId, c -> c)); + for (Task task : taskList) { + FlowTaskVo flowTaskVo = new FlowTaskVo(); + flowTaskVo.setTaskId(task.getId()); + flowTaskVo.setTaskName(task.getName()); + flowTaskVo.setTaskKey(task.getTaskDefinitionKey()); + flowTaskVo.setTaskFormKey(task.getFormKey()); + flowTaskVo.setTaskStartTime(task.getCreateTime()); + flowTaskVo.setEntryId(flowEntryPublishMap.get(task.getProcessDefinitionId()).getEntryId()); + ProcessDefinition processDefinition = definitionMap.get(task.getProcessDefinitionId()); + flowTaskVo.setProcessDefinitionId(processDefinition.getId()); + flowTaskVo.setProcessDefinitionName(processDefinition.getName()); + flowTaskVo.setProcessDefinitionKey(processDefinition.getKey()); + flowTaskVo.setProcessDefinitionVersion(processDefinition.getVersion()); + ProcessInstance processInstance = instanceMap.get(task.getProcessInstanceId()); + flowTaskVo.setProcessInstanceId(processInstance.getId()); + Object initiator = this.getProcessInstanceVariable( + processInstance.getId(), FlowConstant.PROC_INSTANCE_INITIATOR_VAR); + flowTaskVo.setProcessInstanceInitiator(initiator.toString()); + flowTaskVo.setProcessInstanceStartTime(processInstance.getStartTime()); + flowTaskVo.setBusinessKey(processInstance.getBusinessKey()); + FlowWorkOrder flowWorkOrder = workOrderMap.get(task.getProcessInstanceId()); + if (flowWorkOrder != null) { + flowTaskVo.setIsDraft(flowWorkOrder.getFlowStatus().equals(FlowTaskStatus.DRAFT)); + flowTaskVo.setWorkOrderCode(flowWorkOrder.getWorkOrderCode()); + } + flowTaskVoList.add(flowTaskVo); + } + Set loginNameSet = flowTaskVoList.stream() + .map(FlowTaskVo::getProcessInstanceInitiator).collect(Collectors.toSet()); + List flowUserInfos = flowCustomExtFactory + .getFlowIdentityExtHelper().getUserInfoListByUsernameSet(loginNameSet); + Map userInfoMap = + flowUserInfos.stream().collect(Collectors.toMap(FlowUserInfoVo::getLoginName, c -> c)); + for (FlowTaskVo flowTaskVo : flowTaskVoList) { + FlowUserInfoVo userInfo = userInfoMap.get(flowTaskVo.getProcessInstanceInitiator()); + flowTaskVo.setShowName(userInfo.getShowName()); + flowTaskVo.setHeadImageUrl(userInfo.getHeadImageUrl()); + } + return flowTaskVoList; + } + + @Override + public void addProcessInstanceEndListener(BpmnModel bpmnModel, Class listenerClazz) { + Assert.notNull(listenerClazz); + Process process = bpmnModel.getMainProcess(); + FlowableListener listener = this.createListener("end", listenerClazz.getName()); + process.getExecutionListeners().add(listener); + } + + @Override + public void addExecutionListener( + FlowElement flowElement, + Class listenerClazz, + String event, + List fieldExtensions) { + Assert.notNull(listenerClazz); + FlowableListener listener = this.createListener(event, listenerClazz.getName()); + if (fieldExtensions != null) { + listener.setFieldExtensions(fieldExtensions); + } + flowElement.getExecutionListeners().add(listener); + } + + @Override + public void addTaskCreateListener(UserTask userTask, Class listenerClazz) { + Assert.notNull(listenerClazz); + FlowableListener listener = this.createListener("create", listenerClazz.getName()); + userTask.getTaskListeners().add(listener); + } + + @Override + public HistoricProcessInstance getHistoricProcessInstance(String processInstanceId) { + return historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); + } + + @Override + public List getHistoricProcessInstanceList(Set processInstanceIdSet) { + return historyService.createHistoricProcessInstanceQuery().processInstanceIds(processInstanceIdSet).list(); + } + + @Override + public MyPageData getHistoricProcessInstanceList( + String processDefinitionKey, + String processDefinitionName, + String startUser, + String beginDate, + String endDate, + MyPageParam pageParam, + boolean finishedOnly) throws ParseException { + HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery(); + if (StrUtil.isNotBlank(processDefinitionKey)) { + query.processDefinitionKey(processDefinitionKey); + } + if (StrUtil.isNotBlank(processDefinitionName)) { + query.processDefinitionName(processDefinitionName); + } + if (StrUtil.isNotBlank(startUser)) { + query.startedBy(startUser); + } + if (StrUtil.isNotBlank(beginDate)) { + SimpleDateFormat sdf = new SimpleDateFormat(MyDateUtil.COMMON_SHORT_DATETIME_FORMAT); + query.startedAfter(sdf.parse(beginDate)); + } + if (StrUtil.isNotBlank(endDate)) { + SimpleDateFormat sdf = new SimpleDateFormat(MyDateUtil.COMMON_SHORT_DATETIME_FORMAT); + query.startedBefore(sdf.parse(endDate)); + } + TokenData tokenData = TokenData.takeFromRequest(); + if (tokenData.getTenantId() != null) { + query.processInstanceTenantId(tokenData.getTenantId().toString()); + } else { + if (tokenData.getAppCode() == null) { + query.processInstanceWithoutTenantId(); + } else { + query.processInstanceTenantId(tokenData.getAppCode()); + } + } + if (finishedOnly) { + query.finished(); + } + query.orderByProcessInstanceStartTime().desc(); + long totalCount = query.count(); + int firstResult = (pageParam.getPageNum() - 1) * pageParam.getPageSize(); + List instanceList = query.listPage(firstResult, pageParam.getPageSize()); + return new MyPageData<>(instanceList, totalCount); + } + + @Override + public MyPageData getHistoricTaskInstanceFinishedList( + String processDefinitionName, + String beginDate, + String endDate, + MyPageParam pageParam) throws ParseException { + String loginName = TokenData.takeFromRequest().getLoginName(); + HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery() + .taskAssignee(loginName) + .finished(); + if (StrUtil.isNotBlank(processDefinitionName)) { + query.processDefinitionName(processDefinitionName); + } + if (StrUtil.isNotBlank(beginDate)) { + SimpleDateFormat sdf = new SimpleDateFormat(MyDateUtil.COMMON_SHORT_DATETIME_FORMAT); + query.taskCompletedAfter(sdf.parse(beginDate)); + } + if (StrUtil.isNotBlank(endDate)) { + SimpleDateFormat sdf = new SimpleDateFormat(MyDateUtil.COMMON_SHORT_DATETIME_FORMAT); + query.taskCompletedBefore(sdf.parse(endDate)); + } + TokenData tokenData = TokenData.takeFromRequest(); + if (tokenData.getTenantId() != null) { + query.taskTenantId(tokenData.getTenantId().toString()); + } else { + if (StrUtil.isBlank(tokenData.getAppCode())) { + query.taskWithoutTenantId(); + } else { + query.taskTenantId(tokenData.getAppCode()); + } + } + query.orderByHistoricTaskInstanceEndTime().desc(); + long totalCount = query.count(); + int firstResult = (pageParam.getPageNum() - 1) * pageParam.getPageSize(); + List instanceList = query.listPage(firstResult, pageParam.getPageSize()); + return new MyPageData<>(instanceList, totalCount); + } + + @Override + public List getHistoricActivityInstanceList(String processInstanceId) { + return historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list(); + } + + @Override + public List getHistoricActivityInstanceListOrderByStartTime(String processInstanceId) { + return historyService.createHistoricActivityInstanceQuery() + .processInstanceId(processInstanceId).orderByHistoricActivityInstanceStartTime().asc().list(); + } + + @Override + public HistoricTaskInstance getHistoricTaskInstance(String processInstanceId, String taskId) { + return historyService.createHistoricTaskInstanceQuery() + .processInstanceId(processInstanceId).taskId(taskId).singleResult(); + } + + @Override + public List getHistoricUnfinishedInstanceList(String processInstanceId) { + return historyService.createHistoricActivityInstanceQuery() + .processInstanceId(processInstanceId).unfinished().list(); + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public CallResult stopProcessInstance(String processInstanceId, String stopReason, boolean forCancel) { + //需要先更新状态,以便FlowFinishedListener监听器可以正常的判断流程结束的状态。 + int status = FlowTaskStatus.STOPPED; + if (forCancel) { + status = FlowTaskStatus.CANCELLED; + } + return this.stopProcessInstance(processInstanceId, stopReason, status); + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public CallResult stopProcessInstance(String processInstanceId, String stopReason, int status) { + List taskList = taskService.createTaskQuery().processInstanceId(processInstanceId).active().list(); + if (CollUtil.isEmpty(taskList)) { + return CallResult.error("数据验证失败,当前流程尚未开始或已经结束!"); + } + BpmnModel bpmnModel = repositoryService.getBpmnModel(taskList.get(0).getProcessDefinitionId()); + EndEvent endEvent = bpmnModel.getMainProcess() + .findFlowElementsOfType(EndEvent.class, false).get(0); + List currentActivitiIds = new LinkedList<>(); + flowWorkOrderService.updateFlowStatusByProcessInstanceId(processInstanceId, status); + for (Task task : taskList) { + String currActivityId = task.getTaskDefinitionKey(); + currentActivitiIds.add(currActivityId); + FlowNode currFlow = (FlowNode) bpmnModel.getMainProcess().getFlowElement(currActivityId); + if (currFlow == null) { + List subProcessList = + bpmnModel.getMainProcess().findFlowElementsOfType(SubProcess.class); + for (SubProcess subProcess : subProcessList) { + FlowElement flowElement = subProcess.getFlowElement(currActivityId); + if (flowElement != null) { + currFlow = (FlowNode) flowElement; + break; + } + } + } + org.springframework.util.Assert.notNull(currFlow, "currFlow can't be NULL"); + if (!(currFlow.getParentContainer().equals(endEvent.getParentContainer()))) { + throw new FlowOperationException("数据验证失败,不能从子流程直接中止!"); + } + FlowTaskComment taskComment = new FlowTaskComment(task); + taskComment.setApprovalType(FlowApprovalType.STOP); + taskComment.setTaskComment(stopReason); + flowTaskCommentService.saveNew(taskComment); + } + this.doChangeState(processInstanceId, currentActivitiIds, CollUtil.newArrayList(endEvent.getId())); + flowMessageService.updateFinishedStatusByProcessInstanceId(processInstanceId); + return CallResult.ok(); + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public void deleteProcessInstance(String processInstanceId) { + historyService.deleteHistoricProcessInstance(processInstanceId); + flowMessageService.removeByProcessInstanceId(processInstanceId); + FlowWorkOrder workOrder = flowWorkOrderService.getFlowWorkOrderByProcessInstanceId(processInstanceId); + if (workOrder == null) { + return; + } + FlowEntry flowEntry = flowEntryService.getFlowEntryFromCache(workOrder.getProcessDefinitionKey()); + if (StrUtil.isNotBlank(flowEntry.getExtensionData())) { + FlowEntryExtensionData extData = JSON.parseObject(flowEntry.getExtensionData(), FlowEntryExtensionData.class); + if (BooleanUtil.isTrue(extData.getCascadeDeleteBusinessData())) { + // 级联删除在线表单工作流的业务数据。 + flowCustomExtFactory.getOnlineBusinessDataExtHelper().deleteBusinessData(workOrder); + } + } + flowWorkOrderService.removeByProcessInstanceId(processInstanceId); + } + + @Override + public Object getTaskVariable(String taskId, String variableName) { + return taskService.getVariable(taskId, variableName); + } + + @Override + public String getTaskVariableStringWithSafe(String taskId, String variableName) { + try { + Object v = taskService.getVariable(taskId, variableName); + if (v == null) { + return null; + } + return v.toString(); + } catch (Exception e) { + String errorMessage = + String.format("Failed to getTaskVariable taskId [%s], variableName [%s]", taskId, variableName); + log.error(errorMessage, e); + return null; + } + } + + @Override + public Object getExecutionVariable(String executionId, String variableName) { + return runtimeService.getVariable(executionId, variableName); + } + + @Override + public String getExecutionVariableStringWithSafe(String executionId, String variableName) { + try { + Object v = runtimeService.getVariable(executionId, variableName); + if (v == null) { + return null; + } + return v.toString(); + } catch (Exception e) { + String errorMessage = String.format( + "Failed to getExecutionVariableStringWithSafe executionId [%s], variableName [%s]", executionId, variableName); + log.error(errorMessage, e); + return null; + } + } + + @Override + public Object getHistoricProcessInstanceVariable(String processInstanceId, String variableName) { + HistoricVariableInstance hv = historyService.createHistoricVariableInstanceQuery() + .processInstanceId(processInstanceId).variableName(variableName).singleResult(); + return hv == null ? null : hv.getValue(); + } + + @Override + public BpmnModel convertToBpmnModel(String bpmnXml) throws XMLStreamException { + BpmnXMLConverter converter = new BpmnXMLConverter(); + InputStream in = new ByteArrayInputStream(bpmnXml.getBytes(StandardCharsets.UTF_8)); + @Cleanup XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(in); + return converter.convertToBpmnModel(reader); + } + + @Transactional + @Override + public CallResult backToRuntimeTask(Task task, String targetKey, boolean forReject, String reason) { + String errorMessage; + ProcessDefinition processDefinition = this.getProcessDefinitionById(task.getProcessDefinitionId()); + Collection allElements = this.getProcessAllElements(processDefinition.getId()); + FlowElement source = null; + // 获取跳转的节点元素 + FlowElement target = null; + for (FlowElement flowElement : allElements) { + if (flowElement.getId().equals(task.getTaskDefinitionKey())) { + source = flowElement; + if (StrUtil.isBlank(targetKey)) { + break; + } + } + if (StrUtil.isNotBlank(targetKey)) { + if (flowElement.getId().equals(targetKey)) { + target = flowElement; + } + } + } + if (targetKey != null && target == null) { + errorMessage = "数据验证失败,被驳回的指定目标节点不存在!"; + return CallResult.error(errorMessage); + } + UserTask oneUserTask = null; + List targetIds = null; + if (target == null) { + List parentUserTaskList = this.getParentUserTaskList(source, null, null); + if (CollUtil.isEmpty(parentUserTaskList)) { + errorMessage = "数据验证失败,当前节点为初始任务节点,不能驳回!"; + return CallResult.error(errorMessage); + } + // 获取活动ID, 即节点Key + Set parentUserTaskKeySet = new HashSet<>(); + parentUserTaskList.forEach(item -> parentUserTaskKeySet.add(item.getId())); + List historicActivityIdList = + this.getHistoricActivityInstanceListOrderByStartTime(task.getProcessInstanceId()); + // 数据清洗,将回滚导致的脏数据清洗掉 + List lastHistoricTaskInstanceList = + this.cleanHistoricTaskInstance(allElements, historicActivityIdList); + // 此时历史任务实例为倒序,获取最后走的节点 + targetIds = new ArrayList<>(); + // 循环结束标识,遇到当前目标节点的次数 + int number = 0; + StringBuilder parentHistoricTaskKey = new StringBuilder(); + for (String historicTaskInstanceKey : lastHistoricTaskInstanceList) { + // 当会签时候会出现特殊的,连续都是同一个节点历史数据的情况,这种时候跳过 + if (parentHistoricTaskKey.toString().equals(historicTaskInstanceKey)) { + continue; + } + parentHistoricTaskKey = new StringBuilder(historicTaskInstanceKey); + if (historicTaskInstanceKey.equals(task.getTaskDefinitionKey())) { + number++; + } + if (number == 2) { + break; + } + // 如果当前历史节点,属于父级的节点,说明最后一次经过了这个点,需要退回这个点 + if (parentUserTaskKeySet.contains(historicTaskInstanceKey)) { + targetIds.add(historicTaskInstanceKey); + } + } + // 目的获取所有需要被跳转的节点 currentIds + // 取其中一个父级任务,因为后续要么存在公共网关,要么就是串行公共线路 + oneUserTask = parentUserTaskList.get(0); + } + // 获取所有正常进行的执行任务的活动节点ID,这些任务不能直接使用,需要找出其中需要撤回的任务 + List runExecutionList = + runtimeService.createExecutionQuery().processInstanceId(task.getProcessInstanceId()).list(); + List runActivityIdList = runExecutionList.stream() + .map(Execution::getActivityId) + .filter(StrUtil::isNotBlank).collect(Collectors.toList()); + // 需驳回任务列表 + List currentIds = new ArrayList<>(); + // 通过父级网关的出口连线,结合 runExecutionList 比对,获取需要撤回的任务 + List currentFlowElementList = this.getChildUserTaskList( + target != null ? target : oneUserTask, runActivityIdList, null, null); + currentFlowElementList.forEach(item -> currentIds.add(item.getId())); + if (target == null) { + // 规定:并行网关之前节点必须需存在唯一用户任务节点,如果出现多个任务节点,则并行网关节点默认为结束节点,原因为不考虑多对多情况 + if (targetIds.size() > 1 && currentIds.size() > 1) { + errorMessage = "数据验证失败,任务出现多对多情况,无法撤回!"; + return CallResult.error(errorMessage); + } + } + AtomicReference> tmp = new AtomicReference<>(); + // 用于下面新增网关删除信息时使用 + String targetTmp = targetKey != null ? targetKey : String.join(",", targetIds); + // currentIds 为活动ID列表 + // currentExecutionIds 为执行任务ID列表 + // 需要通过执行任务ID来设置驳回信息,活动ID不行 + currentIds.forEach(currentId -> runExecutionList.forEach(runExecution -> { + if (StrUtil.isNotBlank(runExecution.getActivityId()) && currentId.equals(runExecution.getActivityId())) { + // 查询当前节点的执行任务的历史数据 + tmp.set(historyService.createHistoricActivityInstanceQuery() + .processInstanceId(task.getProcessInstanceId()) + .executionId(runExecution.getId()) + .activityId(runExecution.getActivityId()).list()); + // 如果这个列表的数据只有 1 条数据 + // 网关肯定只有一条,且为包容网关或并行网关 + // 这里的操作目的是为了给网关在扭转前提前加上删除信息,结构与普通节点的删除信息一样,目的是为了知道这个网关也是有经过跳转的 + if (tmp.get() != null && tmp.get().size() == 1 && StrUtil.isNotBlank(tmp.get().get(0).getActivityType()) + && ("parallelGateway".equals(tmp.get().get(0).getActivityType()) || "inclusiveGateway".equals(tmp.get().get(0).getActivityType()))) { + // singleResult 能够执行更新操作 + // 利用 流程实例ID + 执行任务ID + 活动节点ID 来指定唯一数据,保证数据正确 + historyService.createNativeHistoricActivityInstanceQuery().sql( + "UPDATE ACT_HI_ACTINST SET DELETE_REASON_ = 'Change activity to " + targetTmp + "' WHERE PROC_INST_ID_='" + task.getProcessInstanceId() + "' AND EXECUTION_ID_='" + runExecution.getId() + "' AND ACT_ID_='" + runExecution.getActivityId() + "'").singleResult(); + } + } + })); + try { + if (StrUtil.isNotBlank(targetKey)) { + runtimeService.createChangeActivityStateBuilder() + .processInstanceId(task.getProcessInstanceId()) + .moveActivityIdsToSingleActivityId(currentIds, targetKey).changeState(); + } else { + // 如果父级任务多于 1 个,说明当前节点不是并行节点,原因为不考虑多对多情况 + if (targetIds.size() > 1) { + // 1 对 多任务跳转,currentIds 当前节点(1),targetIds 跳转到的节点(多) + ChangeActivityStateBuilder builder = runtimeService.createChangeActivityStateBuilder() + .processInstanceId(task.getProcessInstanceId()) + .moveSingleActivityIdToActivityIds(currentIds.get(0), targetIds); + for (String targetId : targetIds) { + FlowTaskComment taskComment = + flowTaskCommentService.getLatestFlowTaskComment(task.getProcessInstanceId(), targetId); + // 如果驳回后的目标任务包含指定人,则直接通过变量回抄,如果没有则自动忽略该变量,不会给流程带来任何影响。 + String submitLoginName = taskComment.getCreateLoginName(); + if (StrUtil.isNotBlank(submitLoginName)) { + builder.localVariable(targetId, FlowConstant.TASK_APPOINTED_ASSIGNEE_VAR, submitLoginName); + } + } + builder.changeState(); + } + // 如果父级任务只有一个,因此当前任务可能为网关中的任务 + if (targetIds.size() == 1) { + // 1 对 1 或 多 对 1 情况,currentIds 当前要跳转的节点列表(1或多),targetIds.get(0) 跳转到的节点(1) + // 如果驳回后的目标任务包含指定人,则直接通过变量回抄,如果没有则自动忽略该变量,不会给流程带来任何影响。 + ChangeActivityStateBuilder builder = runtimeService.createChangeActivityStateBuilder() + .processInstanceId(task.getProcessInstanceId()) + .moveActivityIdsToSingleActivityId(currentIds, targetIds.get(0)); + FlowTaskComment taskComment = + flowTaskCommentService.getLatestFlowTaskComment(task.getProcessInstanceId(), targetIds.get(0)); + String submitLoginName = taskComment.getCreateLoginName(); + if (StrUtil.isNotBlank(submitLoginName)) { + builder.localVariable(targetIds.get(0), FlowConstant.TASK_APPOINTED_ASSIGNEE_VAR, submitLoginName); + } + builder.changeState(); + } + } + FlowTaskComment comment = new FlowTaskComment(); + comment.setTaskId(task.getId()); + comment.setTaskKey(task.getTaskDefinitionKey()); + comment.setTaskName(task.getName()); + comment.setApprovalType(forReject ? FlowApprovalType.REJECT : FlowApprovalType.REVOKE); + comment.setProcessInstanceId(task.getProcessInstanceId()); + comment.setTaskComment(reason); + flowTaskCommentService.saveNew(comment); + } catch (Exception e) { + log.error("Failed to execute moveSingleActivityIdToActivityIds", e); + return CallResult.error(e.getMessage()); + } + return CallResult.ok(); + } + + private List getParentUserTaskList( + FlowElement source, Set hasSequenceFlow, List userTaskList) { + userTaskList = userTaskList == null ? new ArrayList<>() : userTaskList; + hasSequenceFlow = hasSequenceFlow == null ? new HashSet<>() : hasSequenceFlow; + // 如果该节点为开始节点,且存在上级子节点,则顺着上级子节点继续迭代 + if (source instanceof StartEvent && source.getSubProcess() != null) { + userTaskList = getParentUserTaskList(source.getSubProcess(), hasSequenceFlow, userTaskList); + } + List sequenceFlows = getElementIncomingFlows(source); + if (sequenceFlows != null) { + // 循环找到目标元素 + for (SequenceFlow sequenceFlow : sequenceFlows) { + // 如果发现连线重复,说明循环了,跳过这个循环 + if (hasSequenceFlow.contains(sequenceFlow.getId())) { + continue; + } + // 添加已经走过的连线 + hasSequenceFlow.add(sequenceFlow.getId()); + // 类型为用户节点,则新增父级节点 + if (sequenceFlow.getSourceFlowElement() instanceof UserTask) { + userTaskList.add((UserTask) sequenceFlow.getSourceFlowElement()); + continue; + } + // 类型为子流程,则添加子流程开始节点出口处相连的节点 + if (sequenceFlow.getSourceFlowElement() instanceof SubProcess) { + // 获取子流程用户任务节点 + List childUserTaskList = findChildProcessUserTasks( + (StartEvent) ((SubProcess) sequenceFlow.getSourceFlowElement()).getFlowElements().toArray()[0], null, null); + // 如果找到节点,则说明该线路找到节点,不继续向下找,反之继续 + if (childUserTaskList != null && !childUserTaskList.isEmpty()) { + userTaskList.addAll(childUserTaskList); + continue; + } + } + // 网关场景的继续迭代 + // 注意:已经经过的节点与连线都应该用浅拷贝出来的对象 + // 比如分支:a->b->c与a->d->c,走完a->b->c后走另一个路线是,已经经过的节点应该不包含a->b->c路线的数据 + userTaskList = getParentUserTaskList( + sequenceFlow.getSourceFlowElement(), new HashSet<>(hasSequenceFlow), userTaskList); + } + } + return userTaskList; + } + + private List getChildUserTaskList( + FlowElement source, List runActiveIdList, Set hasSequenceFlow, List flowElementList) { + hasSequenceFlow = hasSequenceFlow == null ? new HashSet<>() : hasSequenceFlow; + flowElementList = flowElementList == null ? new ArrayList<>() : flowElementList; + // 如果该节点为开始节点,且存在上级子节点,则顺着上级子节点继续迭代 + if (source instanceof EndEvent && source.getSubProcess() != null) { + flowElementList = getChildUserTaskList( + source.getSubProcess(), runActiveIdList, hasSequenceFlow, flowElementList); + } + // 根据类型,获取出口连线 + List sequenceFlows = getElementOutgoingFlows(source); + if (sequenceFlows != null) { + // 循环找到目标元素 + for (SequenceFlow sequenceFlow: sequenceFlows) { + // 如果发现连线重复,说明循环了,跳过这个循环 + if (hasSequenceFlow.contains(sequenceFlow.getId())) { + continue; + } + // 添加已经走过的连线 + hasSequenceFlow.add(sequenceFlow.getId()); + // 如果为用户任务类型,或者为网关 + // 活动节点ID 在运行的任务中存在,添加 + FlowElement targetElement = sequenceFlow.getTargetFlowElement(); + if ((targetElement instanceof UserTask || targetElement instanceof Gateway) + && runActiveIdList.contains(targetElement.getId())) { + flowElementList.add(sequenceFlow.getTargetFlowElement()); + continue; + } + // 如果节点为子流程节点情况,则从节点中的第一个节点开始获取 + if (sequenceFlow.getTargetFlowElement() instanceof SubProcess) { + List childUserTaskList = getChildUserTaskList( + (FlowElement) (((SubProcess) sequenceFlow.getTargetFlowElement()).getFlowElements().toArray()[0]), runActiveIdList, hasSequenceFlow, null); + // 如果找到节点,则说明该线路找到节点,不继续向下找,反之继续 + if (childUserTaskList != null && !childUserTaskList.isEmpty()) { + flowElementList.addAll(childUserTaskList); + continue; + } + } + // 继续迭代 + // 注意:已经经过的节点与连线都应该用浅拷贝出来的对象 + // 比如分支:a->b->c与a->d->c,走完a->b->c后走另一个路线是,已经经过的节点应该不包含a->b->c路线的数据 + flowElementList = getChildUserTaskList( + sequenceFlow.getTargetFlowElement(), runActiveIdList, new HashSet<>(hasSequenceFlow), flowElementList); + } + } + return flowElementList; + } + + private List cleanHistoricTaskInstance( + Collection allElements, List historicActivityList) { + // 会签节点收集 + List multiTask = new ArrayList<>(); + allElements.forEach(flowElement -> { + if (flowElement instanceof UserTask) { + // 如果该节点的行为为会签行为,说明该节点为会签节点 + if (((UserTask) flowElement).getBehavior() instanceof ParallelMultiInstanceBehavior + || ((UserTask) flowElement).getBehavior() instanceof SequentialMultiInstanceBehavior) { + multiTask.add(flowElement.getId()); + } + } + }); + // 循环放入栈,栈 LIFO:后进先出 + Stack stack = new Stack<>(); + historicActivityList.forEach(stack::push); + // 清洗后的历史任务实例 + List lastHistoricTaskInstanceList = new ArrayList<>(); + // 网关存在可能只走了部分分支情况,且还存在跳转废弃数据以及其他分支数据的干扰,因此需要对历史节点数据进行清洗 + // 临时用户任务 key + StringBuilder userTaskKey = null; + // 临时被删掉的任务 key,存在并行情况 + List deleteKeyList = new ArrayList<>(); + // 临时脏数据线路 + List> dirtyDataLineList = new ArrayList<>(); + // 由某个点跳到会签点,此时出现多个会签实例对应 1 个跳转情况,需要把这些连续脏数据都找到 + // 会签特殊处理下标 + int multiIndex = -1; + // 会签特殊处理 key + StringBuilder multiKey = null; + // 会签特殊处理操作标识 + boolean multiOpera = false; + while (!stack.empty()) { + // 从这里开始 userTaskKey 都还是上个栈的 key + // 是否是脏数据线路上的点 + final boolean[] isDirtyData = {false}; + for (Set oldDirtyDataLine : dirtyDataLineList) { + if (oldDirtyDataLine.contains(stack.peek().getActivityId())) { + isDirtyData[0] = true; + } + } + // 删除原因不为空,说明从这条数据开始回跳或者回退的 + // MI_END:会签完成后,其他未签到节点的删除原因,不在处理范围内 + if (stack.peek().getDeleteReason() != null && !"MI_END".equals(stack.peek().getDeleteReason())) { + // 可以理解为脏线路起点 + String dirtyPoint = ""; + if (stack.peek().getDeleteReason().contains("Change activity to ")) { + dirtyPoint = stack.peek().getDeleteReason().replace("Change activity to ", ""); + } + // 会签回退删除原因有点不同 + if (stack.peek().getDeleteReason().contains("Change parent activity to ")) { + dirtyPoint = stack.peek().getDeleteReason().replace("Change parent activity to ", ""); + } + FlowElement dirtyTask = null; + // 获取变更节点的对应的入口处连线 + // 如果是网关并行回退情况,会变成两条脏数据路线,效果一样 + for (FlowElement flowElement : allElements) { + if (flowElement.getId().equals(stack.peek().getActivityId())) { + dirtyTask = flowElement; + } + } + // 获取脏数据线路 + Set dirtyDataLine = + findDirtyRoads(dirtyTask, null, null, StrUtil.split(dirtyPoint, ','), null); + // 自己本身也是脏线路上的点,加进去 + dirtyDataLine.add(stack.peek().getActivityId()); + log.info(stack.peek().getActivityId() + "点脏路线集合:" + dirtyDataLine); + // 是全新的需要添加的脏线路 + boolean isNewDirtyData = true; + for (Set strings : dirtyDataLineList) { + // 如果发现他的上个节点在脏线路内,说明这个点可能是并行的节点,或者连续驳回 + // 这时,都以之前的脏线路节点为标准,只需合并脏线路即可,也就是路线补全 + if (strings.contains(userTaskKey.toString())) { + isNewDirtyData = false; + strings.addAll(dirtyDataLine); + } + } + // 已确定时全新的脏线路 + if (isNewDirtyData) { + // deleteKey 单一路线驳回到并行,这种同时生成多个新实例记录情况,这时 deleteKey 其实是由多个值组成 + // 按照逻辑,回退后立刻生成的实例记录就是回退的记录 + // 至于驳回所生成的 Key,直接从删除原因中获取,因为存在驳回到并行的情况 + deleteKeyList.add(dirtyPoint + ","); + dirtyDataLineList.add(dirtyDataLine); + } + // 添加后,现在这个点变成脏线路上的点了 + isDirtyData[0] = true; + } + // 如果不是脏线路上的点,说明是有效数据,添加历史实例 Key + if (!isDirtyData[0]) { + lastHistoricTaskInstanceList.add(stack.peek().getActivityId()); + } + // 校验脏线路是否结束 + for (int i = 0; i < deleteKeyList.size(); i ++) { + // 如果发现脏数据属于会签,记录下下标与对应 Key,以备后续比对,会签脏数据范畴开始 + if (multiKey == null && multiTask.contains(stack.peek().getActivityId()) + && deleteKeyList.get(i).contains(stack.peek().getActivityId())) { + multiIndex = i; + multiKey = new StringBuilder(stack.peek().getActivityId()); + } + // 会签脏数据处理,节点退回会签清空 + // 如果在会签脏数据范畴中发现 Key改变,说明会签脏数据在上个节点就结束了,可以把会签脏数据删掉 + if (multiKey != null && !multiKey.toString().equals(stack.peek().getActivityId())) { + deleteKeyList.set(multiIndex , deleteKeyList.get(multiIndex).replace(stack.peek().getActivityId() + ",", "")); + multiKey = null; + // 结束进行下校验删除 + multiOpera = true; + } + // 其他脏数据处理 + // 发现该路线最后一条脏数据,说明这条脏数据线路处理完了,删除脏数据信息 + // 脏数据产生的新实例中是否包含这条数据 + if (multiKey == null && deleteKeyList.get(i).contains(stack.peek().getActivityId())) { + // 删除匹配到的部分 + deleteKeyList.set(i , deleteKeyList.get(i).replace(stack.peek().getActivityId() + ",", "")); + } + // 如果每组中的元素都以匹配过,说明脏数据结束 + if ("".equals(deleteKeyList.get(i))) { + // 同时删除脏数据 + deleteKeyList.remove(i); + dirtyDataLineList.remove(i); + break; + } + } + // 会签数据处理需要在循环外处理,否则可能导致溢出 + // 会签的数据肯定是之前放进去的所以理论上不会溢出,但还是校验下 + if (multiOpera && deleteKeyList.size() > multiIndex && "".equals(deleteKeyList.get(multiIndex))) { + // 同时删除脏数据 + deleteKeyList.remove(multiIndex); + dirtyDataLineList.remove(multiIndex); + multiIndex = -1; + multiOpera = false; + } + // pop() 方法与 peek() 方法不同,在返回值的同时,会把值从栈中移除 + // 保存新的 userTaskKey 在下个循环中使用 + userTaskKey = new StringBuilder(stack.pop().getActivityId()); + } + log.info("清洗后的历史节点数据:" + lastHistoricTaskInstanceList); + return lastHistoricTaskInstanceList; + } + + private List findChildProcessUserTasks(FlowElement source, Set hasSequenceFlow, List userTaskList) { + hasSequenceFlow = hasSequenceFlow == null ? new HashSet<>() : hasSequenceFlow; + userTaskList = userTaskList == null ? new ArrayList<>() : userTaskList; + // 根据类型,获取出口连线 + List sequenceFlows = getElementOutgoingFlows(source); + if (sequenceFlows != null) { + // 循环找到目标元素 + for (SequenceFlow sequenceFlow : sequenceFlows) { + // 如果发现连线重复,说明循环了,跳过这个循环 + if (hasSequenceFlow.contains(sequenceFlow.getId())) { + continue; + } + // 添加已经走过的连线 + hasSequenceFlow.add(sequenceFlow.getId()); + // 如果为用户任务类型,且任务节点的 Key 正在运行的任务中存在,添加 + if (sequenceFlow.getTargetFlowElement() instanceof UserTask) { + userTaskList.add((UserTask) sequenceFlow.getTargetFlowElement()); + continue; + } + // 如果节点为子流程节点情况,则从节点中的第一个节点开始获取 + if (sequenceFlow.getTargetFlowElement() instanceof SubProcess) { + List childUserTaskList = findChildProcessUserTasks((FlowElement) (((SubProcess) sequenceFlow.getTargetFlowElement()).getFlowElements().toArray()[0]), hasSequenceFlow, null); + // 如果找到节点,则说明该线路找到节点,不继续向下找,反之继续 + if (childUserTaskList != null && !childUserTaskList.isEmpty()) { + userTaskList.addAll(childUserTaskList); + continue; + } + } + // 继续迭代 + // 注意:已经经过的节点与连线都应该用浅拷贝出来的对象 + // 比如分支:a->b->c与a->d->c,走完a->b->c后走另一个路线是,已经经过的节点应该不包含a->b->c路线的数据 + userTaskList = findChildProcessUserTasks(sequenceFlow.getTargetFlowElement(), new HashSet<>(hasSequenceFlow), userTaskList); + } + } + return userTaskList; + } + + private Set findDirtyRoads( + FlowElement source, List passRoads, Set hasSequenceFlow, List targets, Set dirtyRoads) { + passRoads = passRoads == null ? new ArrayList<>() : passRoads; + dirtyRoads = dirtyRoads == null ? new HashSet<>() : dirtyRoads; + hasSequenceFlow = hasSequenceFlow == null ? new HashSet<>() : hasSequenceFlow; + // 如果该节点为开始节点,且存在上级子节点,则顺着上级子节点继续迭代 + if (source instanceof StartEvent && source.getSubProcess() != null) { + dirtyRoads = findDirtyRoads(source.getSubProcess(), passRoads, hasSequenceFlow, targets, dirtyRoads); + } + // 根据类型,获取入口连线 + List sequenceFlows = getElementIncomingFlows(source); + if (sequenceFlows != null) { + // 循环找到目标元素 + for (SequenceFlow sequenceFlow: sequenceFlows) { + // 如果发现连线重复,说明循环了,跳过这个循环 + if (hasSequenceFlow.contains(sequenceFlow.getId())) { + continue; + } + // 添加已经走过的连线 + hasSequenceFlow.add(sequenceFlow.getId()); + // 新增经过的路线 + passRoads.add(sequenceFlow.getSourceFlowElement().getId()); + // 如果此点为目标点,确定经过的路线为脏线路,添加点到脏线路中,然后找下个连线 + if (targets.contains(sequenceFlow.getSourceFlowElement().getId())) { + dirtyRoads.addAll(passRoads); + continue; + } + // 如果该节点为开始节点,且存在上级子节点,则顺着上级子节点继续迭代 + if (sequenceFlow.getSourceFlowElement() instanceof SubProcess) { + dirtyRoads = findChildProcessAllDirtyRoad( + (StartEvent) ((SubProcess) sequenceFlow.getSourceFlowElement()).getFlowElements().toArray()[0], null, dirtyRoads); + // 是否存在子流程上,true 是,false 否 + Boolean isInChildProcess = dirtyTargetInChildProcess( + (StartEvent) ((SubProcess) sequenceFlow.getSourceFlowElement()).getFlowElements().toArray()[0], null, targets, null); + if (isInChildProcess) { + // 已在子流程上找到,该路线结束 + continue; + } + } + // 继续迭代 + // 注意:已经经过的节点与连线都应该用浅拷贝出来的对象 + // 比如分支:a->b->c与a->d->c,走完a->b->c后走另一个路线是,已经经过的节点应该不包含a->b->c路线的数据 + dirtyRoads = findDirtyRoads(sequenceFlow.getSourceFlowElement(), + new ArrayList<>(passRoads), new HashSet<>(hasSequenceFlow), targets, dirtyRoads); + } + } + return dirtyRoads; + } + + private Set findChildProcessAllDirtyRoad( + FlowElement source, Set hasSequenceFlow, Set dirtyRoads) { + hasSequenceFlow = hasSequenceFlow == null ? new HashSet<>() : hasSequenceFlow; + dirtyRoads = dirtyRoads == null ? new HashSet<>() : dirtyRoads; + // 根据类型,获取出口连线 + List sequenceFlows = getElementOutgoingFlows(source); + if (sequenceFlows != null) { + // 循环找到目标元素 + for (SequenceFlow sequenceFlow: sequenceFlows) { + // 如果发现连线重复,说明循环了,跳过这个循环 + if (hasSequenceFlow.contains(sequenceFlow.getId())) { + continue; + } + // 添加已经走过的连线 + hasSequenceFlow.add(sequenceFlow.getId()); + // 添加脏路线 + dirtyRoads.add(sequenceFlow.getTargetFlowElement().getId()); + // 如果节点为子流程节点情况,则从节点中的第一个节点开始获取 + if (sequenceFlow.getTargetFlowElement() instanceof SubProcess) { + dirtyRoads = findChildProcessAllDirtyRoad( + (FlowElement) (((SubProcess) sequenceFlow.getTargetFlowElement()).getFlowElements().toArray()[0]), hasSequenceFlow, dirtyRoads); + } + // 继续迭代 + // 注意:已经经过的节点与连线都应该用浅拷贝出来的对象 + // 比如分支:a->b->c与a->d->c,走完a->b->c后走另一个路线是,已经经过的节点应该不包含a->b->c路线的数据 + dirtyRoads = findChildProcessAllDirtyRoad( + sequenceFlow.getTargetFlowElement(), new HashSet<>(hasSequenceFlow), dirtyRoads); + } + } + return dirtyRoads; + } + + private Boolean dirtyTargetInChildProcess( + FlowElement source, Set hasSequenceFlow, List targets, Boolean inChildProcess) { + hasSequenceFlow = hasSequenceFlow == null ? new HashSet<>() : hasSequenceFlow; + inChildProcess = inChildProcess != null && inChildProcess; + // 根据类型,获取出口连线 + List sequenceFlows = getElementOutgoingFlows(source); + if (sequenceFlows != null && !inChildProcess) { + // 循环找到目标元素 + for (SequenceFlow sequenceFlow: sequenceFlows) { + // 如果发现连线重复,说明循环了,跳过这个循环 + if (hasSequenceFlow.contains(sequenceFlow.getId())) { + continue; + } + // 添加已经走过的连线 + hasSequenceFlow.add(sequenceFlow.getId()); + // 如果发现目标点在子流程上存在,说明只到子流程为止 + if (targets.contains(sequenceFlow.getTargetFlowElement().getId())) { + inChildProcess = true; + break; + } + // 如果节点为子流程节点情况,则从节点中的第一个节点开始获取 + if (sequenceFlow.getTargetFlowElement() instanceof SubProcess) { + inChildProcess = dirtyTargetInChildProcess((FlowElement) (((SubProcess) sequenceFlow.getTargetFlowElement()).getFlowElements().toArray()[0]), hasSequenceFlow, targets, inChildProcess); + } + // 继续迭代 + // 注意:已经经过的节点与连线都应该用浅拷贝出来的对象 + // 比如分支:a->b->c与a->d->c,走完a->b->c后走另一个路线是,已经经过的节点应该不包含a->b->c路线的数据 + inChildProcess = dirtyTargetInChildProcess(sequenceFlow.getTargetFlowElement(), new HashSet<>(hasSequenceFlow), targets, inChildProcess); + } + } + return inChildProcess; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void transferTo(Task task, FlowTaskComment flowTaskComment) { + List transferUserList = StrUtil.split(flowTaskComment.getDelegateAssignee(), ","); + for (String transferUser : transferUserList) { + if (transferUser.equals(FlowConstant.START_USER_NAME_VAR)) { + String startUser = this.getProcessInstanceVariable( + task.getProcessInstanceId(), FlowConstant.PROC_INSTANCE_START_USER_NAME_VAR).toString(); + String newDelegateAssignee = StrUtil.replace( + flowTaskComment.getDelegateAssignee(), FlowConstant.START_USER_NAME_VAR, startUser); + flowTaskComment.setDelegateAssignee(newDelegateAssignee); + transferUserList = StrUtil.split(flowTaskComment.getDelegateAssignee(), ","); + break; + } + } + taskService.unclaim(task.getId()); + FlowTaskExt taskExt = flowTaskExtService.getByProcessDefinitionIdAndTaskId( + task.getProcessDefinitionId(), task.getTaskDefinitionKey()); + if (StrUtil.isNotBlank(taskExt.getCandidateUsernames())) { + List candidateUsernames = this.getCandidateUsernames(taskExt, task.getId()); + if (CollUtil.isNotEmpty(candidateUsernames)) { + for (String username : candidateUsernames) { + taskService.deleteCandidateUser(task.getId(), username); + } + } + } else if (StrUtil.equals(taskExt.getGroupType(), FlowConstant.GROUP_TYPE_ASSIGNEE)) { + List links = taskService.getIdentityLinksForTask(task.getId()); + for (IdentityLink link : links) { + taskService.deleteUserIdentityLink(task.getId(), link.getUserId(), link.getType()); + } + } else { + this.removeCandidateGroup(taskExt, task); + } + transferUserList.forEach(u -> taskService.addCandidateUser(task.getId(), u)); + flowTaskComment.fillWith(task); + flowTaskCommentService.saveNew(flowTaskComment); + } + + @Override + public List getCandidateUsernames(FlowTaskExt flowTaskExt, String taskId) { + if (StrUtil.isBlank(flowTaskExt.getCandidateUsernames())) { + return Collections.emptyList(); + } + if (!StrUtil.equals(flowTaskExt.getCandidateUsernames(), "${" + FlowConstant.TASK_APPOINTED_ASSIGNEE_VAR + "}")) { + return StrUtil.split(flowTaskExt.getCandidateUsernames(), ","); + } + Object candidateUsernames = getTaskVariableStringWithSafe(taskId, FlowConstant.TASK_APPOINTED_ASSIGNEE_VAR); + return candidateUsernames == null ? null : StrUtil.split(candidateUsernames.toString(), ","); + } + + @Override + public Tuple2, Set> getDeptPostIdAndPostIds( + FlowTaskExt flowTaskExt, String processInstanceId, boolean historic) { + Set postIdSet = new LinkedHashSet<>(); + Set deptPostIdSet = new LinkedHashSet<>(); + if (StrUtil.equals(flowTaskExt.getGroupType(), FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER)) { + Object v = this.getProcessInstanceVariable( + processInstanceId, FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER_VAR, historic); + if (ObjectUtil.isNotEmpty(v)) { + deptPostIdSet.add(v.toString()); + } + } else if (StrUtil.equals(flowTaskExt.getGroupType(), FlowConstant.GROUP_TYPE_DEPT_POST_LEADER)) { + Object v = this.getProcessInstanceVariable( + processInstanceId, FlowConstant.GROUP_TYPE_DEPT_POST_LEADER_VAR, historic); + if (ObjectUtil.isNotEmpty(v)) { + deptPostIdSet.add(v.toString()); + } + } else if (StrUtil.equals(flowTaskExt.getGroupType(), FlowConstant.GROUP_TYPE_POST) + && StrUtil.isNotBlank(flowTaskExt.getDeptPostListJson())) { + this.buildDeptPostIdAndPostIdsForPost(flowTaskExt, processInstanceId, historic, postIdSet, deptPostIdSet); + } + return new Tuple2<>(deptPostIdSet, postIdSet); + } + + @Override + public Map getAllUserTaskMap(String processDefinitionId) { + BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId); + Process process = bpmnModel.getProcesses().get(0); + return process.findFlowElementsOfType(UserTask.class) + .stream().collect(Collectors.toMap(UserTask::getId, a -> a, (k1, k2) -> k1)); + } + + @Override + public UserTask getUserTask(String processDefinitionId, String taskKey) { + BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId); + for (Process process : bpmnModel.getProcesses()) { + UserTask userTask = process.findFlowElementsOfType(UserTask.class) + .stream().filter(t -> t.getId().equals(taskKey)).findFirst().orElse(null); + if (userTask != null) { + return userTask; + } + } + return null; + } + + private void doChangeState(String processInstanceId, List currentIds, List targetIds) { + if (ObjectUtil.hasEmpty(currentIds, targetIds)) { + throw new MyRuntimeException("跳转的源节点和任务节点数量均不能为空!"); + } + ChangeActivityStateBuilder builder = + this.createChangeActivityStateBuilder(currentIds, targetIds, processInstanceId); + targetIds.forEach(targetId -> { + FlowTaskComment comment = flowTaskCommentService.getLatestFlowTaskComment(processInstanceId, targetId); + if (comment != null && StrUtil.isNotBlank(comment.getCreateLoginName())) { + builder.localVariable(targetId, FlowConstant.TASK_APPOINTED_ASSIGNEE_VAR, comment.getCreateLoginName()); + } + }); + builder.changeState(); + } + + private ChangeActivityStateBuilder createChangeActivityStateBuilder( + List currentIds, List targetIds, String processInstanceId) { + ChangeActivityStateBuilder builder; + if (currentIds.size() > 1 && targetIds.size() > 1) { + builder = new CustomChangeActivityStateBuilderImpl((RuntimeServiceImpl) runtimeService); + ((CustomChangeActivityStateBuilderImpl) builder) + .moveActivityIdsToActivityIds(currentIds, targetIds) + .processInstanceId(processInstanceId); + } else { + builder = runtimeService.createChangeActivityStateBuilder().processInstanceId(processInstanceId); + if (targetIds.size() == 1) { + if (currentIds.size() == 1) { + builder.moveActivityIdTo(currentIds.get(0), targetIds.get(0)); + } else { + builder.moveActivityIdsToSingleActivityId(currentIds, targetIds.get(0)); + } + } else { + builder.moveSingleActivityIdToActivityIds(currentIds.get(0), targetIds); + } + } + return builder; + } + + private void removeCandidateGroup(FlowTaskExt taskExt, Task task) { + if (StrUtil.isNotBlank(taskExt.getDeptIds())) { + for (String deptId : StrUtil.split(taskExt.getDeptIds(), ",")) { + taskService.deleteCandidateGroup(task.getId(), deptId); + } + } + if (StrUtil.isNotBlank(taskExt.getRoleIds())) { + for (String roleId : StrUtil.split(taskExt.getRoleIds(), ",")) { + taskService.deleteCandidateGroup(task.getId(), roleId); + } + } + Tuple2, Set> tuple2 = + getDeptPostIdAndPostIds(taskExt, task.getProcessInstanceId(), false); + if (CollUtil.isNotEmpty(tuple2.getFirst())) { + for (String deptPostId : tuple2.getFirst()) { + taskService.deleteCandidateGroup(task.getId(), deptPostId); + } + } + if (CollUtil.isNotEmpty(tuple2.getSecond())) { + for (String postId : tuple2.getSecond()) { + taskService.deleteCandidateGroup(task.getId(), postId); + } + } + } + + private void buildDeptPostIdAndPostIdsForPost( + FlowTaskExt flowTaskExt, + String processInstanceId, + boolean historic, + Set postIdSet, + Set deptPostIdSet) { + List groupDataList = + JSON.parseArray(flowTaskExt.getDeptPostListJson(), FlowTaskPostCandidateGroup.class); + for (FlowTaskPostCandidateGroup groupData : groupDataList) { + switch (groupData.getType()) { + case FlowConstant.GROUP_TYPE_ALL_DEPT_POST_VAR: + postIdSet.add(groupData.getPostId()); + break; + case FlowConstant.GROUP_TYPE_DEPT_POST_VAR: + deptPostIdSet.add(groupData.getDeptPostId()); + break; + case FlowConstant.GROUP_TYPE_SELF_DEPT_POST_VAR: + Object v = this.getProcessInstanceVariable( + processInstanceId, FlowConstant.SELF_DEPT_POST_PREFIX + groupData.getPostId(), historic); + if (ObjectUtil.isNotEmpty(v)) { + deptPostIdSet.add(v.toString()); + } + break; + case FlowConstant.GROUP_TYPE_UP_DEPT_POST_VAR: + Object v2 = this.getProcessInstanceVariable( + processInstanceId, FlowConstant.UP_DEPT_POST_PREFIX + groupData.getPostId(), historic); + if (ObjectUtil.isNotEmpty(v2)) { + deptPostIdSet.add(v2.toString()); + } + break; + case FlowConstant.GROUP_TYPE_SIBLING_DEPT_POST_VAR: + Object v3 = this.getProcessInstanceVariable( + processInstanceId, FlowConstant.SIBLING_DEPT_POST_PREFIX + groupData.getPostId(), historic); + if (ObjectUtil.isNotEmpty(v3)) { + deptPostIdSet.addAll(StrUtil.split(v3.toString(), ",") + .stream().filter(StrUtil::isNotBlank).toList()); + } + break; + default: + break; + } + } + } + + private Object getProcessInstanceVariable(String processInstanceId, String variableName, boolean historic) { + if (historic) { + return getHistoricProcessInstanceVariable(processInstanceId, variableName); + } + return getProcessInstanceVariable(processInstanceId, variableName); + } + + private void handleMultiInstanceApprovalType(String executionId, String approvalType, JSONObject taskVariableData) { + if (StrUtil.isBlank(approvalType)) { + return; + } + if (StrUtil.equalsAny(approvalType, + FlowApprovalType.MULTI_AGREE, + FlowApprovalType.MULTI_REFUSE, + FlowApprovalType.MULTI_ABSTAIN)) { + Map variables = runtimeService.getVariables(executionId); + Integer agreeCount = (Integer) variables.get(FlowConstant.MULTI_AGREE_COUNT_VAR); + Integer refuseCount = (Integer) variables.get(FlowConstant.MULTI_REFUSE_COUNT_VAR); + Integer abstainCount = (Integer) variables.get(FlowConstant.MULTI_ABSTAIN_COUNT_VAR); + Integer nrOfInstances = (Integer) variables.get(FlowConstant.NUMBER_OF_INSTANCES_VAR); + taskVariableData.put(FlowConstant.MULTI_AGREE_COUNT_VAR, agreeCount); + taskVariableData.put(FlowConstant.MULTI_REFUSE_COUNT_VAR, refuseCount); + taskVariableData.put(FlowConstant.MULTI_ABSTAIN_COUNT_VAR, abstainCount); + taskVariableData.put(FlowConstant.MULTI_SIGN_NUM_OF_INSTANCES_VAR, nrOfInstances); + switch (approvalType) { + case FlowApprovalType.MULTI_AGREE: + if (agreeCount == null) { + agreeCount = 0; + } + taskVariableData.put(FlowConstant.MULTI_AGREE_COUNT_VAR, agreeCount + 1); + break; + case FlowApprovalType.MULTI_REFUSE: + if (refuseCount == null) { + refuseCount = 0; + } + taskVariableData.put(FlowConstant.MULTI_REFUSE_COUNT_VAR, refuseCount + 1); + break; + case FlowApprovalType.MULTI_ABSTAIN: + if (abstainCount == null) { + abstainCount = 0; + } + taskVariableData.put(FlowConstant.MULTI_ABSTAIN_COUNT_VAR, abstainCount + 1); + break; + default: + break; + } + } + } + + private TaskQuery createQuery() { + TaskQuery query = taskService.createTaskQuery().active(); + TokenData tokenData = TokenData.takeFromRequest(); + if (tokenData.getTenantId() != null) { + query.taskTenantId(tokenData.getTenantId().toString()); + } else { + if (StrUtil.isBlank(tokenData.getAppCode())) { + query.taskWithoutTenantId(); + } else { + query.taskTenantId(tokenData.getAppCode()); + } + } + return query; + } + + private void buildCandidateCondition(TaskQuery query, String loginName) { + Set groupIdSet = new HashSet<>(); + // NOTE: 需要注意的是,部门Id、部门岗位Id,或者其他类型的分组Id,他们之间一定不能重复。 + TokenData tokenData = TokenData.takeFromRequest(); + Object deptId = tokenData.getDeptId(); + if (deptId != null) { + groupIdSet.add(deptId.toString()); + } + String roleIds = tokenData.getRoleIds(); + if (StrUtil.isNotBlank(tokenData.getRoleIds())) { + groupIdSet.addAll(StrUtil.split(roleIds, ",")); + } + String postIds = tokenData.getPostIds(); + if (StrUtil.isNotBlank(tokenData.getPostIds())) { + groupIdSet.addAll(StrUtil.split(postIds, ",")); + } + String deptPostIds = tokenData.getDeptPostIds(); + if (StrUtil.isNotBlank(deptPostIds)) { + groupIdSet.addAll(StrUtil.split(deptPostIds, ",")); + } + if (CollUtil.isNotEmpty(groupIdSet)) { + query.or().taskCandidateGroupIn(groupIdSet).taskCandidateOrAssigned(loginName).endOr(); + } else { + query.taskCandidateOrAssigned(loginName); + } + } + + private String buildMutiSignAssigneeList(String operationListJson) { + FlowTaskMultiSignAssign multiSignAssignee = null; + List taskOperationList = JSONArray.parseArray(operationListJson, FlowTaskOperation.class); + for (FlowTaskOperation taskOperation : taskOperationList) { + if (FlowApprovalType.MULTI_SIGN.equals(taskOperation.getType())) { + multiSignAssignee = taskOperation.getMultiSignAssignee(); + break; + } + } + org.springframework.util.Assert.notNull(multiSignAssignee, "multiSignAssignee can't be NULL"); + if (UserFilterGroup.USER.equals(multiSignAssignee.getAssigneeType())) { + return multiSignAssignee.getAssigneeList(); + } + Set usernameSet = null; + BaseFlowIdentityExtHelper extHelper = flowCustomExtFactory.getFlowIdentityExtHelper(); + Set idSet = CollUtil.newHashSet(StrUtil.split(multiSignAssignee.getAssigneeList(), ",")); + switch (multiSignAssignee.getAssigneeType()) { + case UserFilterGroup.ROLE -> usernameSet = extHelper.getUsernameListByRoleIds(idSet); + case UserFilterGroup.DEPT -> usernameSet = extHelper.getUsernameListByDeptIds(idSet); + case UserFilterGroup.POST -> usernameSet = extHelper.getUsernameListByPostIds(idSet); + case UserFilterGroup.DEPT_POST -> usernameSet = extHelper.getUsernameListByDeptPostIds(idSet); + default -> { + } + } + return CollUtil.isEmpty(usernameSet) ? null : CollUtil.join(usernameSet, ","); + } + + private Collection getAllElements(Collection flowElements, Collection allElements) { + allElements = allElements == null ? new ArrayList<>() : allElements; + for (FlowElement flowElement : flowElements) { + allElements.add(flowElement); + if (flowElement instanceof SubProcess) { + allElements = getAllElements(((SubProcess) flowElement).getFlowElements(), allElements); + } + } + return allElements; + } + + private void doChangeTask(Task runtimeTask) { + Map allUserTaskMap = + this.getAllUserTaskMap(runtimeTask.getProcessDefinitionId()); + UserTask userTaskModel = allUserTaskMap.get(runtimeTask.getTaskDefinitionKey()); + String completeCondition = userTaskModel.getLoopCharacteristics().getCompletionCondition(); + Execution parentExecution = this.getMultiInstanceRootExecution(runtimeTask); + Object nrOfCompletedInstances = runtimeService.getVariable( + parentExecution.getId(), FlowConstant.NUMBER_OF_COMPLETED_INSTANCES_VAR); + Object nrOfInstances = runtimeService.getVariable( + parentExecution.getId(), FlowConstant.NUMBER_OF_INSTANCES_VAR); + ExpressionFactory factory = new ExpressionFactoryImpl(); + SimpleContext context = new SimpleContext(); + context.setVariable("nrOfCompletedInstances", + factory.createValueExpression(nrOfCompletedInstances, Integer.class)); + context.setVariable("nrOfInstances", + factory.createValueExpression(nrOfInstances, Integer.class)); + ValueExpression e = factory.createValueExpression(context, completeCondition, Boolean.class); + Boolean ok = Convert.convert(Boolean.class, e.getValue(context)); + if (BooleanUtil.isTrue(ok)) { + FlowElement targetKey = userTaskModel.getOutgoingFlows().get(0).getTargetFlowElement(); + ChangeActivityStateBuilder builder = runtimeService.createChangeActivityStateBuilder() + .processInstanceId(runtimeTask.getProcessInstanceId()) + .moveActivityIdTo(userTaskModel.getId(), targetKey.getId()); + builder.localVariable(targetKey.getId(), FlowConstant.MULTI_SIGN_NUM_OF_INSTANCES_VAR, nrOfInstances); + builder.changeState(); + } + } + + private Execution getMultiInstanceRootExecution(Task runtimeTask) { + List executionList = runtimeService.createExecutionQuery() + .processInstanceId(runtimeTask.getProcessInstanceId()) + .activityId(runtimeTask.getTaskDefinitionKey()).list(); + for (Execution e : executionList) { + ExecutionEntityImpl ee = (ExecutionEntityImpl) e; + if (ee.isMultiInstanceRoot()) { + return e; + } + } + Execution execution = executionList.get(0); + return runtimeService.createExecutionQuery() + .processInstanceId(runtimeTask.getProcessInstanceId()) + .executionId(execution.getParentId()).singleResult(); + } + + private List getElementIncomingFlows(FlowElement source) { + List sequenceFlows = null; + if (source instanceof org.flowable.bpmn.model.Task) { + sequenceFlows = ((org.flowable.bpmn.model.Task) source).getIncomingFlows(); + } else if (source instanceof Gateway) { + sequenceFlows = ((Gateway) source).getIncomingFlows(); + } else if (source instanceof SubProcess) { + sequenceFlows = ((SubProcess) source).getIncomingFlows(); + } else if (source instanceof StartEvent) { + sequenceFlows = ((StartEvent) source).getIncomingFlows(); + } else if (source instanceof EndEvent) { + sequenceFlows = ((EndEvent) source).getIncomingFlows(); + } + return sequenceFlows; + } + + private List getElementOutgoingFlows(FlowElement source) { + List sequenceFlows = null; + if (source instanceof org.flowable.bpmn.model.Task) { + sequenceFlows = ((org.flowable.bpmn.model.Task) source).getOutgoingFlows(); + } else if (source instanceof Gateway) { + sequenceFlows = ((Gateway) source).getOutgoingFlows(); + } else if (source instanceof SubProcess) { + sequenceFlows = ((SubProcess) source).getOutgoingFlows(); + } else if (source instanceof StartEvent) { + sequenceFlows = ((StartEvent) source).getOutgoingFlows(); + } else if (source instanceof EndEvent) { + sequenceFlows = ((EndEvent) source).getOutgoingFlows(); + } + return sequenceFlows; + } + + private FlowableListener createListener(String eventName, String listenerClassName) { + FlowableListener listener = new FlowableListener(); + listener.setEvent(eventName); + listener.setImplementationType("class"); + listener.setImplementation(listenerClassName); + return listener; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowCategoryServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowCategoryServiceImpl.java new file mode 100644 index 00000000..3994aabc --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowCategoryServiceImpl.java @@ -0,0 +1,129 @@ +package com.orangeforms.common.flow.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.mybatisflex.core.query.QueryWrapper; +import com.github.pagehelper.Page; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.flow.dao.*; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.flow.service.*; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; +import java.util.Set; + +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("flowCategoryService") +public class FlowCategoryServiceImpl extends BaseService implements FlowCategoryService { + + @Autowired + private FlowCategoryMapper flowCategoryMapper; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return flowCategoryMapper; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public FlowCategory saveNew(FlowCategory flowCategory) { + flowCategory.setCategoryId(idGenerator.nextLongId()); + TokenData tokenData = TokenData.takeFromRequest(); + flowCategory.setAppCode(tokenData.getAppCode()); + flowCategory.setTenantId(tokenData.getTenantId()); + flowCategory.setUpdateUserId(tokenData.getUserId()); + flowCategory.setCreateUserId(tokenData.getUserId()); + Date now = new Date(); + flowCategory.setUpdateTime(now); + flowCategory.setCreateTime(now); + flowCategoryMapper.insert(flowCategory); + return flowCategory; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(FlowCategory flowCategory, FlowCategory originalFlowCategory) { + TokenData tokenData = TokenData.takeFromRequest(); + flowCategory.setAppCode(tokenData.getAppCode()); + flowCategory.setTenantId(tokenData.getTenantId()); + flowCategory.setUpdateUserId(tokenData.getUserId()); + flowCategory.setCreateUserId(originalFlowCategory.getCreateUserId()); + flowCategory.setUpdateTime(new Date()); + flowCategory.setCreateTime(originalFlowCategory.getCreateTime()); + // 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。 + return flowCategoryMapper.update(flowCategory, false) == 1; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long categoryId) { + return flowCategoryMapper.deleteById(categoryId) == 1; + } + + @Override + public List getFlowCategoryList(FlowCategory filter, String orderBy) { + if (filter == null) { + filter = new FlowCategory(); + } + TokenData tokenData = TokenData.takeFromRequest(); + filter.setTenantId(tokenData.getTenantId()); + filter.setAppCode(tokenData.getAppCode()); + return flowCategoryMapper.getFlowCategoryList(filter, orderBy); + } + + @Override + public List getFlowCategoryListWithRelation(FlowCategory filter, String orderBy) { + List resultList = this.getFlowCategoryList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + @Override + public boolean existByCode(String code) { + FlowCategory filter = new FlowCategory(); + filter.setCode(code); + return CollUtil.isNotEmpty(this.getFlowCategoryList(filter, null)); + } + + @Override + public List getInList(Set categoryIds) { + QueryWrapper qw = new QueryWrapper(); + qw.in(FlowCategory::getCategoryId, categoryIds); + TokenData tokenData = TokenData.takeFromRequest(); + if (tokenData.getAppCode() == null) { + qw.isNull(FlowCategory::getAppCode); + } else { + qw.eq(FlowCategory::getAppCode, tokenData.getAppCode()); + } + if (tokenData.getTenantId() == null) { + qw.isNull(FlowCategory::getTenantId); + } else { + qw.eq(FlowCategory::getTenantId, tokenData.getTenantId()); + } + return flowCategoryMapper.selectListByQuery(qw); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowEntryServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowEntryServiceImpl.java new file mode 100644 index 00000000..39183fc8 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowEntryServiceImpl.java @@ -0,0 +1,485 @@ +package com.orangeforms.common.flow.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.mybatisflex.core.query.QueryWrapper; +import com.github.pagehelper.Page; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.redis.util.CommonRedisUtil; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.flow.listener.*; +import com.orangeforms.common.flow.object.*; +import com.orangeforms.common.flow.util.FlowRedisKeyUtil; +import com.orangeforms.common.flow.util.BaseFlowIdentityExtHelper; +import com.orangeforms.common.flow.util.FlowCustomExtFactory; +import com.orangeforms.common.flow.constant.FlowConstant; +import com.orangeforms.common.flow.dao.*; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.flow.service.*; +import com.orangeforms.common.flow.model.constant.FlowEntryStatus; +import com.orangeforms.common.flow.model.constant.FlowVariableType; +import lombok.Cleanup; +import lombok.extern.slf4j.Slf4j; +import org.flowable.bpmn.converter.BpmnXMLConverter; +import org.flowable.bpmn.model.*; +import org.flowable.engine.RepositoryService; +import org.flowable.engine.repository.Deployment; +import org.flowable.engine.repository.ProcessDefinition; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.stream.Collectors; + +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("flowEntryService") +public class FlowEntryServiceImpl extends BaseService implements FlowEntryService { + + @Autowired + private FlowEntryMapper flowEntryMapper; + @Autowired + private FlowEntryPublishMapper flowEntryPublishMapper; + @Autowired + private FlowEntryPublishVariableMapper flowEntryPublishVariableMapper; + @Autowired + private FlowEntryVariableService flowEntryVariableService; + @Autowired + private FlowCategoryService flowCategoryService; + @Autowired + private FlowTaskExtService flowTaskExtService; + @Autowired + private FlowApiService flowApiService; + @Autowired + private FlowCustomExtFactory flowCustomExtFactory; + @Autowired + private RepositoryService repositoryService; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private CommonRedisUtil commonRedisUtil; + + private static final Integer FLOW_ENTRY_PUBLISH_TTL = 60 * 60 * 24; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return flowEntryMapper; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public FlowEntry saveNew(FlowEntry flowEntry) { + flowEntry.setEntryId(idGenerator.nextLongId()); + flowEntry.setStatus(FlowEntryStatus.UNPUBLISHED); + TokenData tokenData = TokenData.takeFromRequest(); + flowEntry.setAppCode(tokenData.getAppCode()); + flowEntry.setTenantId(tokenData.getTenantId()); + flowEntry.setUpdateUserId(tokenData.getUserId()); + flowEntry.setCreateUserId(tokenData.getUserId()); + Date now = new Date(); + flowEntry.setUpdateTime(now); + flowEntry.setCreateTime(now); + flowEntryMapper.insert(flowEntry); + this.insertBuiltinEntryVariables(flowEntry.getEntryId()); + return flowEntry; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void publish(FlowEntry flowEntry, String initTaskInfo) throws XMLStreamException { + commonRedisUtil.evictFormCache( + FlowRedisKeyUtil.makeFlowEntryKey(flowEntry.getProcessDefinitionKey())); + FlowCategory flowCategory = flowCategoryService.getById(flowEntry.getCategoryId()); + InputStream xmlStream = new ByteArrayInputStream( + flowEntry.getBpmnXml().getBytes(StandardCharsets.UTF_8)); + @Cleanup XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(xmlStream); + BpmnXMLConverter converter = new BpmnXMLConverter(); + BpmnModel bpmnModel = converter.convertToBpmnModel(reader); + bpmnModel.getMainProcess().setName(flowEntry.getProcessDefinitionName()); + bpmnModel.getMainProcess().setId(flowEntry.getProcessDefinitionKey()); + flowApiService.addProcessInstanceEndListener(bpmnModel, FlowFinishedListener.class); + List flowTaskExtList = flowTaskExtService.buildTaskExtList(bpmnModel); + if (StrUtil.isNotBlank(flowEntry.getExtensionData())) { + FlowEntryExtensionData flowEntryExtensionData = + JSON.parseObject(flowEntry.getExtensionData(), FlowEntryExtensionData.class); + this.mergeTaskNotifyData(flowEntryExtensionData, flowTaskExtList); + } + this.processFlowTaskExtList(flowTaskExtList, bpmnModel); + TokenData tokenData = TokenData.takeFromRequest(); + Deployment deploy = repositoryService.createDeployment() + .addBpmnModel(flowEntry.getProcessDefinitionKey() + ".bpmn", bpmnModel) + .tenantId(tokenData.getTenantId() != null ? tokenData.getTenantId().toString() : tokenData.getAppCode()) + .name(flowEntry.getProcessDefinitionName()) + .key(flowEntry.getProcessDefinitionKey()) + .category(flowCategory.getCode()) + .deploy(); + ProcessDefinition processDefinition = flowApiService.getProcessDefinitionByDeployId(deploy.getId()); + FlowEntryPublish flowEntryPublish = new FlowEntryPublish(); + flowEntryPublish.setEntryPublishId(idGenerator.nextLongId()); + flowEntryPublish.setEntryId(flowEntry.getEntryId()); + flowEntryPublish.setProcessDefinitionId(processDefinition.getId()); + flowEntryPublish.setDeployId(processDefinition.getDeploymentId()); + flowEntryPublish.setPublishVersion(processDefinition.getVersion()); + flowEntryPublish.setActiveStatus(true); + flowEntryPublish.setMainVersion(flowEntry.getStatus().equals(FlowEntryStatus.UNPUBLISHED)); + flowEntryPublish.setCreateUserId(TokenData.takeFromRequest().getUserId()); + flowEntryPublish.setPublishTime(new Date()); + flowEntryPublish.setInitTaskInfo(initTaskInfo); + flowEntryPublish.setExtensionData(flowEntry.getExtensionData()); + flowEntryPublishMapper.insert(flowEntryPublish); + FlowEntry updatedFlowEntry = new FlowEntry(); + updatedFlowEntry.setEntryId(flowEntry.getEntryId()); + updatedFlowEntry.setStatus(FlowEntryStatus.PUBLISHED); + updatedFlowEntry.setLatestPublishTime(new Date()); + // 对于从未发布过的工作,第一次发布的时候会将本地发布置位主版本。 + if (flowEntry.getStatus().equals(FlowEntryStatus.UNPUBLISHED)) { + updatedFlowEntry.setMainEntryPublishId(flowEntryPublish.getEntryPublishId()); + } + flowEntryMapper.update(updatedFlowEntry); + FlowEntryVariable flowEntryVariableFilter = new FlowEntryVariable(); + flowEntryVariableFilter.setEntryId(flowEntry.getEntryId()); + List flowEntryVariableList = + flowEntryVariableService.getFlowEntryVariableList(flowEntryVariableFilter, null); + if (CollUtil.isNotEmpty(flowTaskExtList)) { + flowTaskExtList.forEach(t -> t.setProcessDefinitionId(processDefinition.getId())); + flowTaskExtService.saveBatch(flowTaskExtList); + } + this.insertEntryPublishVariables(flowEntryVariableList, flowEntryPublish.getEntryPublishId()); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(FlowEntry flowEntry, FlowEntry originalFlowEntry) { + commonRedisUtil.evictFormCache( + FlowRedisKeyUtil.makeFlowEntryKey(flowEntry.getProcessDefinitionKey())); + TokenData tokenData = TokenData.takeFromRequest(); + flowEntry.setAppCode(tokenData.getAppCode()); + flowEntry.setTenantId(tokenData.getTenantId()); + flowEntry.setUpdateUserId(tokenData.getUserId()); + flowEntry.setCreateUserId(originalFlowEntry.getCreateUserId()); + flowEntry.setUpdateTime(new Date()); + flowEntry.setCreateTime(originalFlowEntry.getCreateTime()); + flowEntry.setPageId(originalFlowEntry.getPageId()); + return flowEntryMapper.update(flowEntry) == 1; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long entryId) { + FlowEntry flowEntry = this.getById(entryId); + if (flowEntry != null) { + commonRedisUtil.evictFormCache( + FlowRedisKeyUtil.makeFlowEntryKey(flowEntry.getProcessDefinitionKey())); + } + if (flowEntryMapper.deleteById(entryId) != 1) { + return false; + } + flowEntryVariableService.removeByEntryId(entryId); + return true; + } + + @Override + public List getFlowEntryList(FlowEntry filter, String orderBy) { + if (filter == null) { + filter = new FlowEntry(); + } + TokenData tokenData = TokenData.takeFromRequest(); + filter.setTenantId(tokenData.getTenantId()); + filter.setAppCode(tokenData.getAppCode()); + return flowEntryMapper.getFlowEntryList(filter, orderBy); + } + + @Override + public List getFlowEntryListWithRelation(FlowEntry filter, String orderBy) { + List resultList = this.getFlowEntryList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + Set mainEntryPublishIdSet = resultList.stream() + .map(FlowEntry::getMainEntryPublishId).filter(Objects::nonNull).collect(Collectors.toSet()); + if (CollUtil.isNotEmpty(mainEntryPublishIdSet)) { + List mainEntryPublishList = + flowEntryPublishMapper.selectListByIds(mainEntryPublishIdSet); + MyModelUtil.makeOneToOneRelation(FlowEntry.class, resultList, FlowEntry::getMainEntryPublishId, + mainEntryPublishList, FlowEntryPublish::getEntryPublishId, "mainFlowEntryPublish"); + } + return resultList; + } + + @Override + public FlowEntry getFlowEntryFromCache(String processDefinitionKey) { + String key = FlowRedisKeyUtil.makeFlowEntryKey(processDefinitionKey); + QueryWrapper qw = new QueryWrapper(); + qw.eq(FlowEntry::getProcessDefinitionKey, processDefinitionKey); + TokenData tokenData = TokenData.takeFromRequest(); + if (StrUtil.isNotBlank(tokenData.getAppCode())) { + qw.eq(FlowEntry::getAppCode, tokenData.getAppCode()); + } else { + qw.isNull(FlowEntry::getAppCode); + } + if (tokenData.getTenantId() != null) { + qw.eq(FlowEntry::getTenantId, tokenData.getTenantId()); + } else { + qw.isNull(FlowEntry::getTenantId); + } + return commonRedisUtil.getFromCacheWithQueryWrapper(key, qw, flowEntryMapper::selectOneByQuery, FlowEntry.class); + } + + @Override + public List getFlowEntryPublishList(Long entryId) { + FlowEntryPublish filter = new FlowEntryPublish(); + filter.setEntryId(entryId); + QueryWrapper queryWrapper = QueryWrapper.create(filter); + queryWrapper.orderBy(FlowEntryPublish::getEntryPublishId, false); + return flowEntryPublishMapper.selectListByQuery(queryWrapper); + } + + @Override + public List getFlowEntryPublishList(Set processDefinitionIdSet) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.in(FlowEntryPublish::getProcessDefinitionId, processDefinitionIdSet); + return flowEntryPublishMapper.selectListByQuery(queryWrapper); + } + + @Override + public FlowEntryPublish getFlowEntryPublishFromCache(Long entryPublishId) { + String key = FlowRedisKeyUtil.makeFlowEntryPublishKey(entryPublishId); + return commonRedisUtil.getFromCache( + key, entryPublishId, flowEntryPublishMapper::selectOneById, FlowEntryPublish.class, FLOW_ENTRY_PUBLISH_TTL); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void updateFlowEntryMainVersion(FlowEntry flowEntry, FlowEntryPublish newMainFlowEntryPublish) { + commonRedisUtil.evictFormCache( + FlowRedisKeyUtil.makeFlowEntryKey(flowEntry.getProcessDefinitionKey())); + commonRedisUtil.evictFormCache( + FlowRedisKeyUtil.makeFlowEntryPublishKey(newMainFlowEntryPublish.getEntryPublishId())); + FlowEntryPublish oldMainFlowEntryPublish = + flowEntryPublishMapper.selectOneById(flowEntry.getMainEntryPublishId()); + if (oldMainFlowEntryPublish != null) { + commonRedisUtil.evictFormCache( + FlowRedisKeyUtil.makeFlowEntryPublishKey(oldMainFlowEntryPublish.getEntryPublishId())); + oldMainFlowEntryPublish.setMainVersion(false); + flowEntryPublishMapper.update(oldMainFlowEntryPublish); + } + newMainFlowEntryPublish.setMainVersion(true); + flowEntryPublishMapper.update(newMainFlowEntryPublish); + FlowEntry updatedEntry = new FlowEntry(); + updatedEntry.setEntryId(flowEntry.getEntryId()); + updatedEntry.setMainEntryPublishId(newMainFlowEntryPublish.getEntryPublishId()); + flowEntryMapper.update(updatedEntry); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void suspendFlowEntryPublish(FlowEntryPublish flowEntryPublish) { + commonRedisUtil.evictFormCache( + FlowRedisKeyUtil.makeFlowEntryPublishKey(flowEntryPublish.getEntryPublishId())); + FlowEntryPublish updatedEntryPublish = new FlowEntryPublish(); + updatedEntryPublish.setEntryPublishId(flowEntryPublish.getEntryPublishId()); + updatedEntryPublish.setActiveStatus(false); + flowEntryPublishMapper.update(updatedEntryPublish); + flowApiService.suspendProcessDefinition(flowEntryPublish.getProcessDefinitionId()); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void activateFlowEntryPublish(FlowEntryPublish flowEntryPublish) { + commonRedisUtil.evictFormCache( + FlowRedisKeyUtil.makeFlowEntryPublishKey(flowEntryPublish.getEntryPublishId())); + FlowEntryPublish updatedEntryPublish = new FlowEntryPublish(); + updatedEntryPublish.setEntryPublishId(flowEntryPublish.getEntryPublishId()); + updatedEntryPublish.setActiveStatus(true); + flowEntryPublishMapper.update(updatedEntryPublish); + flowApiService.activateProcessDefinition(flowEntryPublish.getProcessDefinitionId()); + } + + @Override + public boolean existByProcessDefinitionKey(String processDefinitionKey) { + FlowEntry filter = new FlowEntry(); + filter.setProcessDefinitionKey(processDefinitionKey); + return CollUtil.isNotEmpty(this.getFlowEntryList(filter, null)); + } + + @Override + public CallResult verifyRelatedData(FlowEntry flowEntry, FlowEntry originalFlowEntry) { + String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!"; + if (this.needToVerify(flowEntry, originalFlowEntry, FlowEntry::getCategoryId) + && !flowCategoryService.existId(flowEntry.getCategoryId())) { + return CallResult.error(String.format(errorMessageFormat, "流程类别Id")); + } + return CallResult.ok(); + } + + private void insertBuiltinEntryVariables(Long entryId) { + Date now = new Date(); + FlowEntryVariable operationTypeVariable = new FlowEntryVariable(); + operationTypeVariable.setVariableId(idGenerator.nextLongId()); + operationTypeVariable.setEntryId(entryId); + operationTypeVariable.setVariableName(FlowConstant.OPERATION_TYPE_VAR); + operationTypeVariable.setShowName("审批类型"); + operationTypeVariable.setVariableType(FlowVariableType.TASK); + operationTypeVariable.setBuiltin(true); + operationTypeVariable.setCreateTime(now); + flowEntryVariableService.saveNew(operationTypeVariable); + FlowEntryVariable startUserNameVariable = new FlowEntryVariable(); + startUserNameVariable.setVariableId(idGenerator.nextLongId()); + startUserNameVariable.setEntryId(entryId); + startUserNameVariable.setVariableName("startUserName"); + startUserNameVariable.setShowName("流程启动用户"); + startUserNameVariable.setVariableType(FlowVariableType.INSTANCE); + startUserNameVariable.setBuiltin(true); + startUserNameVariable.setCreateTime(now); + flowEntryVariableService.saveNew(startUserNameVariable); + } + + private void insertEntryPublishVariables(List entryVariableList, Long entryPublishId) { + if (CollUtil.isEmpty(entryVariableList)) { + return; + } + List entryPublishVariableList = + MyModelUtil.copyCollectionTo(entryVariableList, FlowEntryPublishVariable.class); + for (FlowEntryPublishVariable variable : entryPublishVariableList) { + variable.setVariableId(idGenerator.nextLongId()); + variable.setEntryPublishId(entryPublishId); + } + flowEntryPublishVariableMapper.insertList(entryPublishVariableList); + } + + private void mergeTaskNotifyData(FlowEntryExtensionData flowEntryExtensionData, List flowTaskExtList) { + if (CollUtil.isEmpty(flowEntryExtensionData.getNotifyTypes())) { + return; + } + List flowTaskNotifyTypes = + flowEntryExtensionData.getNotifyTypes().stream().filter(StrUtil::isNotBlank).collect(Collectors.toList()); + if (CollUtil.isEmpty(flowTaskNotifyTypes)) { + return; + } + for (FlowTaskExt flowTaskExt : flowTaskExtList) { + if (flowTaskExt.getExtraDataJson() == null) { + JSONObject o = new JSONObject(); + o.put(FlowConstant.USER_TASK_NOTIFY_TYPES_KEY, flowTaskNotifyTypes); + flowTaskExt.setExtraDataJson(o.toJSONString()); + } else { + FlowUserTaskExtData taskExtData = + JSON.parseObject(flowTaskExt.getExtraDataJson(), FlowUserTaskExtData.class); + if (CollUtil.isEmpty(taskExtData.getFlowNotifyTypeList())) { + taskExtData.setFlowNotifyTypeList(flowTaskNotifyTypes); + } else { + Set notifyTypesSet = taskExtData.getFlowNotifyTypeList() + .stream().filter(StrUtil::isNotBlank).collect(Collectors.toSet()); + notifyTypesSet.addAll(flowTaskNotifyTypes); + taskExtData.setFlowNotifyTypeList(new LinkedList<>(notifyTypesSet)); + } + flowTaskExt.setExtraDataJson(JSON.toJSONString(taskExtData)); + } + } + } + + private void doAddLatestApprovalStatusListener(Collection elementList) { + List sequenceFlowList = + elementList.stream().filter(SequenceFlow.class::isInstance).toList(); + for (FlowElement sequenceFlow : sequenceFlowList) { + FlowElementExtProperty extProperty = flowTaskExtService.buildFlowElementExt(sequenceFlow); + if (extProperty != null && extProperty.getLatestApprovalStatus() != null) { + List fieldExtensions = new LinkedList<>(); + FieldExtension fieldExtension = new FieldExtension(); + fieldExtension.setFieldName(FlowConstant.LATEST_APPROVAL_STATUS_KEY); + fieldExtension.setStringValue(extProperty.getLatestApprovalStatus().toString()); + fieldExtensions.add(fieldExtension); + flowApiService.addExecutionListener( + sequenceFlow, UpdateLatestApprovalStatusListener.class, "start", fieldExtensions); + } + } + List subProcesseList = elementList.stream() + .filter(SubProcess.class::isInstance).map(SubProcess.class::cast).toList(); + for (SubProcess subProcess : subProcesseList) { + this.doAddLatestApprovalStatusListener(subProcess.getFlowElements()); + } + } + + private void calculateAllElementList(Collection elements, List resultList) { + resultList.addAll(elements); + for (FlowElement element : elements) { + if (element instanceof SubProcess) { + this.calculateAllElementList(((SubProcess) element).getFlowElements(), resultList); + } + } + } + + private void processFlowTaskExtList(List flowTaskExtList, BpmnModel bpmnModel) { + List elementList = new LinkedList<>(); + this.calculateAllElementList(bpmnModel.getMainProcess().getFlowElements(), elementList); + this.doAddLatestApprovalStatusListener(elementList); + Map elementMap = elementList.stream() + .filter(UserTask.class::isInstance).collect(Collectors.toMap(FlowElement::getId, c -> c)); + BaseFlowIdentityExtHelper flowIdentityExtHelper = flowCustomExtFactory.getFlowIdentityExtHelper(); + for (FlowTaskExt t : flowTaskExtList) { + UserTask userTask = (UserTask) elementMap.get(t.getTaskId()); + flowApiService.addTaskCreateListener(userTask, FlowUserTaskListener.class); + Map> attributes = userTask.getAttributes(); + if (CollUtil.isNotEmpty(attributes.get(FlowConstant.USER_TASK_AUTO_SKIP_KEY))) { + flowApiService.addTaskCreateListener(userTask, AutoSkipTaskListener.class); + } + // 如果流程图中包含部门领导审批和上级部门领导审批的选项,就需要注册 FlowCustomExtFactory 工厂中的 + // BaseFlowIdentityExtHelper 对象,该注册操作需要业务模块中实现。 + if (StrUtil.equals(t.getGroupType(), FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER)) { + userTask.setCandidateGroups( + CollUtil.newArrayList("${" + FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER_VAR + "}")); + Assert.notNull(flowIdentityExtHelper); + flowApiService.addTaskCreateListener(userTask, flowIdentityExtHelper.getUpDeptPostLeaderListener()); + } else if (StrUtil.equals(t.getGroupType(), FlowConstant.GROUP_TYPE_DEPT_POST_LEADER)) { + userTask.setCandidateGroups( + CollUtil.newArrayList("${" + FlowConstant.GROUP_TYPE_DEPT_POST_LEADER_VAR + "}")); + Assert.notNull(flowIdentityExtHelper); + flowApiService.addTaskCreateListener(userTask, flowIdentityExtHelper.getDeptPostLeaderListener()); + } else if (StrUtil.equals(t.getGroupType(), FlowConstant.GROUP_TYPE_POST)) { + Assert.notNull(t.getDeptPostListJson()); + List groupDataList = + JSON.parseArray(t.getDeptPostListJson(), FlowTaskPostCandidateGroup.class); + List candidateGroupList = + FlowTaskPostCandidateGroup.buildCandidateGroupList(groupDataList); + userTask.setCandidateGroups(candidateGroupList); + } + this.processFlowTaskExtListener(userTask, t); + } + } + + private void processFlowTaskExtListener(UserTask userTask, FlowTaskExt taskExt) { + if (StrUtil.isBlank(taskExt.getExtraDataJson())) { + return; + } + FlowUserTaskExtData userTaskExtData = + JSON.parseObject(taskExt.getExtraDataJson(), FlowUserTaskExtData.class); + if (CollUtil.isNotEmpty(userTaskExtData.getFlowNotifyTypeList())) { + flowApiService.addTaskCreateListener(userTask, FlowTaskNotifyListener.class); + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowEntryVariableServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowEntryVariableServiceImpl.java new file mode 100644 index 00000000..70a60674 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowEntryVariableServiceImpl.java @@ -0,0 +1,134 @@ +package com.orangeforms.common.flow.service.impl; + +import com.mybatisflex.core.query.QueryWrapper; +import com.orangeforms.common.flow.service.*; +import com.orangeforms.common.flow.dao.*; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.github.pagehelper.Page; +import lombok.extern.slf4j.Slf4j; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; + +/** + * 流程变量数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("flowEntryVariableService") +public class FlowEntryVariableServiceImpl extends BaseService implements FlowEntryVariableService { + + @Autowired + private FlowEntryVariableMapper flowEntryVariableMapper; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return flowEntryVariableMapper; + } + + /** + * 保存新增对象。 + * + * @param flowEntryVariable 新增对象。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public FlowEntryVariable saveNew(FlowEntryVariable flowEntryVariable) { + flowEntryVariable.setVariableId(idGenerator.nextLongId()); + flowEntryVariable.setCreateTime(new Date()); + flowEntryVariableMapper.insert(flowEntryVariable); + return flowEntryVariable; + } + + /** + * 更新数据对象。 + * + * @param flowEntryVariable 更新的对象。 + * @param originalFlowEntryVariable 原有数据对象。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(FlowEntryVariable flowEntryVariable, FlowEntryVariable originalFlowEntryVariable) { + flowEntryVariable.setCreateTime(originalFlowEntryVariable.getCreateTime()); + // 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。 + return flowEntryVariableMapper.update(flowEntryVariable, false) == 1; + } + + /** + * 删除指定数据。 + * + * @param variableId 主键Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long variableId) { + return flowEntryVariableMapper.deleteById(variableId) == 1; + } + + /** + * 删除指定流程Id的所有变量。 + * + * @param entryId 流程Id。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void removeByEntryId(Long entryId) { + flowEntryVariableMapper.deleteByQuery(new QueryWrapper().eq(FlowEntryVariable::getEntryId, entryId)); + } + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getFlowEntryVariableListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getFlowEntryVariableList(FlowEntryVariable filter, String orderBy) { + return flowEntryVariableMapper.getFlowEntryVariableList(filter, orderBy); + } + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getFlowEntryVariableList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getFlowEntryVariableListWithRelation(FlowEntryVariable filter, String orderBy) { + List resultList = flowEntryVariableMapper.getFlowEntryVariableList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowMessageServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowMessageServiceImpl.java new file mode 100644 index 00000000..1508bf32 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowMessageServiceImpl.java @@ -0,0 +1,384 @@ +package com.orangeforms.common.flow.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.mybatisflex.core.query.QueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.flow.constant.FlowConstant; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.flow.model.constant.FlowMessageOperationType; +import com.orangeforms.common.flow.model.constant.FlowMessageType; +import com.orangeforms.common.flow.dao.FlowMessageIdentityOperationMapper; +import com.orangeforms.common.flow.dao.FlowMessageCandidateIdentityMapper; +import com.orangeforms.common.flow.dao.FlowMessageMapper; +import com.orangeforms.common.flow.object.FlowTaskPostCandidateGroup; +import com.orangeforms.common.flow.service.FlowApiService; +import com.orangeforms.common.flow.service.FlowMessageService; +import com.orangeforms.common.flow.service.FlowTaskExtService; +import com.orangeforms.common.flow.util.FlowCustomExtFactory; +import com.orangeforms.common.flow.vo.TaskInfoVo; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.runtime.ProcessInstance; +import org.flowable.task.api.Task; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; + +/** + * 工作流消息数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("flowMessageService") +public class FlowMessageServiceImpl extends BaseService implements FlowMessageService { + + @Autowired + private FlowMessageMapper flowMessageMapper; + @Autowired + private FlowMessageCandidateIdentityMapper flowMessageCandidateIdentityMapper; + @Autowired + private FlowMessageIdentityOperationMapper flowMessageIdentityOperationMapper; + @Autowired + private FlowTaskExtService flowTaskExtService; + @Autowired + private FlowApiService flowApiService; + @Autowired + private FlowCustomExtFactory flowCustomExtFactory; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return flowMessageMapper; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public FlowMessage saveNew(FlowMessage flowMessage) { + flowMessage.setMessageId(idGenerator.nextLongId()); + TokenData tokenData = TokenData.takeFromRequest(); + if (tokenData != null) { + flowMessage.setTenantId(tokenData.getTenantId()); + flowMessage.setAppCode(tokenData.getAppCode()); + flowMessage.setCreateUserId(tokenData.getUserId()); + flowMessage.setCreateUsername(tokenData.getShowName()); + flowMessage.setUpdateUserId(tokenData.getUserId()); + } + flowMessage.setCreateTime(new Date()); + flowMessage.setUpdateTime(flowMessage.getCreateTime()); + flowMessageMapper.insert(flowMessage); + return flowMessage; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNewRemindMessage(FlowWorkOrder flowWorkOrder) { + List taskList = + flowApiService.getProcessInstanceActiveTaskList(flowWorkOrder.getProcessInstanceId()); + for (Task task : taskList) { + FlowMessage filter = new FlowMessage(); + filter.setTaskId(task.getId()); + List messageList = flowMessageMapper.selectListByQuery(QueryWrapper.create(filter)); + // 同一个任务只能催办一次,多次催办则累加催办次数。 + if (CollUtil.isNotEmpty(messageList)) { + for (FlowMessage flowMessage : messageList) { + flowMessage.setRemindCount(flowMessage.getRemindCount() + 1); + flowMessageMapper.update(flowMessage); + } + continue; + } + FlowMessage flowMessage = BeanUtil.copyProperties(flowWorkOrder, FlowMessage.class); + flowMessage.setMessageType(FlowMessageType.REMIND_TYPE); + flowMessage.setRemindCount(1); + flowMessage.setProcessInstanceInitiator(flowWorkOrder.getSubmitUsername()); + flowMessage.setTaskId(task.getId()); + flowMessage.setTaskName(task.getName()); + flowMessage.setTaskStartTime(task.getCreateTime()); + flowMessage.setTaskAssignee(task.getAssignee()); + flowMessage.setTaskFinished(false); + if (TokenData.takeFromRequest() == null) { + Set usernameSet = CollUtil.newHashSet(flowWorkOrder.getSubmitUsername()); + Map m = flowCustomExtFactory.getFlowIdentityExtHelper().mapUserShowNameByLoginName(usernameSet); + flowMessage.setCreateUsername(m.containsKey(flowWorkOrder.getSubmitUsername()) + ? m.get(flowWorkOrder.getSubmitUsername()) : flowWorkOrder.getSubmitUsername()); + } + this.saveNew(flowMessage); + FlowTaskExt flowTaskExt = flowTaskExtService.getByProcessDefinitionIdAndTaskId( + flowWorkOrder.getProcessDefinitionId(), task.getTaskDefinitionKey()); + if (flowTaskExt != null) { + // 插入与当前消息关联任务的候选人 + this.saveMessageCandidateIdentityWithMessage( + flowWorkOrder.getProcessInstanceId(), flowTaskExt, task, flowMessage.getMessageId()); + } + // 插入与当前消息关联任务的指派人。 + if (StrUtil.isNotBlank(task.getAssignee())) { + this.saveMessageCandidateIdentity( + flowMessage.getMessageId(), FlowConstant.GROUP_TYPE_USER_VAR, task.getAssignee()); + } + } + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNewCopyMessage(Task task, JSONObject copyDataJson) { + if (copyDataJson.isEmpty()) { + return; + } + ProcessInstance instance = flowApiService.getProcessInstance(task.getProcessInstanceId()); + FlowMessage flowMessage = new FlowMessage(); + flowMessage.setMessageType(FlowMessageType.COPY_TYPE); + flowMessage.setRemindCount(0); + flowMessage.setProcessDefinitionId(instance.getProcessDefinitionId()); + flowMessage.setProcessDefinitionKey(instance.getProcessDefinitionKey()); + flowMessage.setProcessDefinitionName(instance.getProcessDefinitionName()); + flowMessage.setProcessInstanceId(instance.getProcessInstanceId()); + flowMessage.setProcessInstanceInitiator(instance.getStartUserId()); + flowMessage.setTaskId(task.getId()); + flowMessage.setTaskDefinitionKey(task.getTaskDefinitionKey()); + flowMessage.setTaskName(task.getName()); + flowMessage.setTaskStartTime(task.getCreateTime()); + flowMessage.setTaskAssignee(task.getAssignee()); + flowMessage.setTaskFinished(false); + flowMessage.setOnlineFormData(true); + // 如果是在线表单,这里就保存关联的在线表单Id,便于在线表单业务数据的查找。 + if (BooleanUtil.isTrue(flowMessage.getOnlineFormData())) { + TaskInfoVo taskInfo = JSON.parseObject(task.getFormKey(), TaskInfoVo.class); + flowMessage.setBusinessDataShot(taskInfo.getFormId().toString()); + } + this.saveNew(flowMessage); + for (Map.Entry entry : copyDataJson.entrySet()) { + if (entry.getValue() != null) { + this.saveMessageCandidateIdentityList( + flowMessage.getMessageId(), entry.getKey(), entry.getValue().toString()); + } + } + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void updateFinishedStatusByTaskId(String taskId) { + FlowMessage flowMessage = new FlowMessage(); + flowMessage.setTaskFinished(true); + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(FlowMessage::getTaskId, taskId); + flowMessageMapper.updateByQuery(flowMessage, queryWrapper); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void updateFinishedStatusByProcessInstanceId(String processInstanceId) { + FlowMessage flowMessage = new FlowMessage(); + flowMessage.setTaskFinished(true); + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(FlowMessage::getProcessInstanceId, processInstanceId); + flowMessageMapper.updateByQuery(flowMessage, queryWrapper); + } + + @Override + public List getRemindingMessageListByUser() { + TokenData tokenData = TokenData.takeFromRequest(); + return flowMessageMapper.getRemindingMessageListByUser( + tokenData.getTenantId(), tokenData.getAppCode(), tokenData.getLoginName(), buildGroupIdSet()); + } + + @Override + public List getCopyMessageListByUser(Boolean read) { + TokenData tokenData = TokenData.takeFromRequest(); + return flowMessageMapper.getCopyMessageListByUser( + tokenData.getTenantId(), tokenData.getAppCode(), tokenData.getLoginName(), buildGroupIdSet(), read); + } + + @Override + public boolean isCandidateIdentityOnMessage(Long messageId) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(FlowMessageCandidateIdentity::getMessageId, messageId); + queryWrapper.in(FlowMessageCandidateIdentity::getCandidateId, buildGroupIdSet()); + return flowMessageCandidateIdentityMapper.selectCountByQuery(queryWrapper) > 0; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void readCopyTask(Long messageId) { + FlowMessageIdentityOperation operation = new FlowMessageIdentityOperation(); + operation.setId(idGenerator.nextLongId()); + operation.setMessageId(messageId); + operation.setLoginName(TokenData.takeFromRequest().getLoginName()); + operation.setOperationType(FlowMessageOperationType.READ_FINISHED); + operation.setOperationTime(new Date()); + flowMessageIdentityOperationMapper.insert(operation); + } + + @Override + public int countRemindingMessageListByUser() { + TokenData tokenData = TokenData.takeFromRequest(); + return flowMessageMapper.countRemindingMessageListByUser( + tokenData.getTenantId(), tokenData.getAppCode(), tokenData.getLoginName(), buildGroupIdSet()); + } + + @Override + public int countCopyMessageByUser() { + TokenData tokenData = TokenData.takeFromRequest(); + return flowMessageMapper.countCopyMessageListByUser( + tokenData.getTenantId(), tokenData.getAppCode(), tokenData.getLoginName(), buildGroupIdSet()); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void removeByProcessInstanceId(String processInstanceId) { + flowMessageCandidateIdentityMapper.deleteByProcessInstanceId(processInstanceId); + flowMessageIdentityOperationMapper.deleteByProcessInstanceId(processInstanceId); + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(FlowMessage::getProcessInstanceId, processInstanceId); + flowMessageMapper.deleteByQuery(queryWrapper); + } + + private Set buildGroupIdSet() { + TokenData tokenData = TokenData.takeFromRequest(); + Set groupIdSet = new HashSet<>(1); + groupIdSet.add(tokenData.getLoginName()); + this.parseAndAddIdArray(groupIdSet, tokenData.getRoleIds()); + this.parseAndAddIdArray(groupIdSet, tokenData.getDeptPostIds()); + this.parseAndAddIdArray(groupIdSet, tokenData.getPostIds()); + if (tokenData.getDeptId() != null) { + groupIdSet.add(tokenData.getDeptId().toString()); + } + return groupIdSet; + } + + private void parseAndAddIdArray(Set groupIdSet, String idArray) { + if (StrUtil.isNotBlank(idArray)) { + if (groupIdSet == null) { + groupIdSet = new HashSet<>(); + } + groupIdSet.addAll(StrUtil.split(idArray, ',')); + } + } + + private void saveMessageCandidateIdentityWithMessage( + String processInstanceId, FlowTaskExt flowTaskExt, Task task, Long messageId) { + List candidates = flowApiService.getCandidateUsernames(flowTaskExt, task.getId()); + if (CollUtil.isNotEmpty(candidates)) { + this.saveMessageCandidateIdentityList( + messageId, FlowConstant.GROUP_TYPE_USER_VAR, CollUtil.join(candidates, ",")); + } + this.saveMessageCandidateIdentityList( + messageId, FlowConstant.GROUP_TYPE_ROLE_VAR, flowTaskExt.getRoleIds()); + this.saveMessageCandidateIdentityList( + messageId, FlowConstant.GROUP_TYPE_DEPT_VAR, flowTaskExt.getDeptIds()); + if (StrUtil.equals(flowTaskExt.getGroupType(), FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER)) { + Object v = flowApiService.getProcessInstanceVariable( + processInstanceId, FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER_VAR); + if (v != null) { + this.saveMessageCandidateIdentity( + messageId, FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER_VAR, v.toString()); + } + } else if (StrUtil.equals(flowTaskExt.getGroupType(), FlowConstant.GROUP_TYPE_DEPT_POST_LEADER)) { + Object v = flowApiService.getProcessInstanceVariable( + processInstanceId, FlowConstant.GROUP_TYPE_DEPT_POST_LEADER_VAR); + if (v != null) { + this.saveMessageCandidateIdentity( + messageId, FlowConstant.GROUP_TYPE_DEPT_POST_LEADER_VAR, v.toString()); + } + } else if (StrUtil.equals(flowTaskExt.getGroupType(), FlowConstant.GROUP_TYPE_POST)) { + Assert.notBlank(flowTaskExt.getDeptPostListJson()); + List groupDataList = + JSONArray.parseArray(flowTaskExt.getDeptPostListJson(), FlowTaskPostCandidateGroup.class); + for (FlowTaskPostCandidateGroup groupData : groupDataList) { + this.saveMessageCandidateIdentity(messageId, processInstanceId, groupData); + } + } + } + + private void saveMessageCandidateIdentity( + Long messageId, String processInstanceId, FlowTaskPostCandidateGroup groupData) { + FlowMessageCandidateIdentity candidateIdentity = new FlowMessageCandidateIdentity(); + candidateIdentity.setId(idGenerator.nextLongId()); + candidateIdentity.setMessageId(messageId); + candidateIdentity.setCandidateType(groupData.getType()); + switch (groupData.getType()) { + case FlowConstant.GROUP_TYPE_ALL_DEPT_POST_VAR: + candidateIdentity.setCandidateId(groupData.getPostId()); + flowMessageCandidateIdentityMapper.insert(candidateIdentity); + break; + case FlowConstant.GROUP_TYPE_DEPT_POST_VAR: + candidateIdentity.setCandidateId(groupData.getDeptPostId()); + flowMessageCandidateIdentityMapper.insert(candidateIdentity); + break; + case FlowConstant.GROUP_TYPE_SELF_DEPT_POST_VAR: + Object v = flowApiService.getProcessInstanceVariable( + processInstanceId, FlowConstant.SELF_DEPT_POST_PREFIX + groupData.getPostId()); + if (v != null) { + candidateIdentity.setCandidateId(v.toString()); + flowMessageCandidateIdentityMapper.insert(candidateIdentity); + } + break; + case FlowConstant.GROUP_TYPE_UP_DEPT_POST_VAR: + Object v2 = flowApiService.getProcessInstanceVariable( + processInstanceId, FlowConstant.UP_DEPT_POST_PREFIX + groupData.getPostId()); + if (v2 != null) { + candidateIdentity.setCandidateId(v2.toString()); + flowMessageCandidateIdentityMapper.insert(candidateIdentity); + } + break; + case FlowConstant.GROUP_TYPE_SIBLING_DEPT_POST_VAR: + Object v3 = flowApiService.getProcessInstanceVariable( + processInstanceId, FlowConstant.SIBLING_DEPT_POST_PREFIX + groupData.getPostId()); + if (v3 != null) { + List candidateIds = StrUtil.split(v3.toString(), ","); + for (String candidateId : candidateIds) { + candidateIdentity.setId(idGenerator.nextLongId()); + candidateIdentity.setCandidateId(candidateId); + flowMessageCandidateIdentityMapper.insert(candidateIdentity); + } + } + break; + default: + break; + } + } + private void saveMessageCandidateIdentity(Long messageId, String candidateType, String candidateId) { + FlowMessageCandidateIdentity candidateIdentity = new FlowMessageCandidateIdentity(); + candidateIdentity.setId(idGenerator.nextLongId()); + candidateIdentity.setMessageId(messageId); + candidateIdentity.setCandidateType(candidateType); + candidateIdentity.setCandidateId(candidateId); + flowMessageCandidateIdentityMapper.insert(candidateIdentity); + } + + private void saveMessageCandidateIdentityList(Long messageId, String candidateType, String identityIds) { + if (StrUtil.isNotBlank(identityIds)) { + for (String identityId : StrUtil.split(identityIds, ',')) { + FlowMessageCandidateIdentity candidateIdentity = new FlowMessageCandidateIdentity(); + candidateIdentity.setId(idGenerator.nextLongId()); + candidateIdentity.setMessageId(messageId); + candidateIdentity.setCandidateType(candidateType); + candidateIdentity.setCandidateId(identityId); + flowMessageCandidateIdentityMapper.insert(candidateIdentity); + } + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowMultiInstanceTransServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowMultiInstanceTransServiceImpl.java new file mode 100644 index 00000000..a94192a3 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowMultiInstanceTransServiceImpl.java @@ -0,0 +1,87 @@ +package com.orangeforms.common.flow.service.impl; + +import com.mybatisflex.core.query.QueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.flow.dao.FlowMultiInstanceTransMapper; +import com.orangeforms.common.flow.model.FlowMultiInstanceTrans; +import com.orangeforms.common.flow.service.FlowMultiInstanceTransService; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; + +/** + * 会签任务操作流水数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("flowMultiInstanceTransService") +public class FlowMultiInstanceTransServiceImpl + extends BaseService implements FlowMultiInstanceTransService { + + @Autowired + private FlowMultiInstanceTransMapper flowMultiInstanceTransMapper; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return flowMultiInstanceTransMapper; + } + + /** + * 保存新增对象。 + * + * @param flowMultiInstanceTrans 新增对象。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public FlowMultiInstanceTrans saveNew(FlowMultiInstanceTrans flowMultiInstanceTrans) { + flowMultiInstanceTrans.setId(idGenerator.nextLongId()); + TokenData tokenData = TokenData.takeFromRequest(); + flowMultiInstanceTrans.setCreateUserId(tokenData.getUserId()); + flowMultiInstanceTrans.setCreateLoginName(tokenData.getLoginName()); + flowMultiInstanceTrans.setCreateUsername(tokenData.getShowName()); + flowMultiInstanceTrans.setCreateTime(new Date()); + flowMultiInstanceTransMapper.insert(flowMultiInstanceTrans); + return flowMultiInstanceTrans; + } + + @Override + public FlowMultiInstanceTrans getByExecutionId(String executionId, String taskId) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(FlowMultiInstanceTrans::getExecutionId, executionId); + queryWrapper.eq(FlowMultiInstanceTrans::getTaskId, taskId); + return flowMultiInstanceTransMapper.selectOneByQuery(queryWrapper); + } + + @Override + public FlowMultiInstanceTrans getWithAssigneeListByMultiInstanceExecId(String multiInstanceExecId) { + if (multiInstanceExecId == null) { + return null; + } + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(FlowMultiInstanceTrans::getMultiInstanceExecId, multiInstanceExecId); + queryWrapper.isNotNull(FlowMultiInstanceTrans::getAssigneeList); + return flowMultiInstanceTransMapper.selectOneByQuery(queryWrapper); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowTaskCommentServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowTaskCommentServiceImpl.java new file mode 100644 index 00000000..41b1e3f3 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowTaskCommentServiceImpl.java @@ -0,0 +1,140 @@ +package com.orangeforms.common.flow.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.mybatisflex.core.paginate.Page; +import com.mybatisflex.core.query.QueryWrapper; +import com.orangeforms.common.flow.service.*; +import com.orangeforms.common.flow.dao.*; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; + +/** + * 流程任务批注数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("flowTaskCommentService") +public class FlowTaskCommentServiceImpl extends BaseService implements FlowTaskCommentService { + + @Autowired + private FlowTaskCommentMapper flowTaskCommentMapper; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return flowTaskCommentMapper; + } + + /** + * 保存新增对象。 + * + * @param flowTaskComment 新增对象。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public FlowTaskComment saveNew(FlowTaskComment flowTaskComment) { + flowTaskComment.setId(idGenerator.nextLongId()); + TokenData tokenData = TokenData.takeFromRequest(); + if (tokenData != null) { + flowTaskComment.setHeadImageUrl(tokenData.getHeadImageUrl()); + flowTaskComment.setCreateUserId(tokenData.getUserId()); + flowTaskComment.setCreateLoginName(tokenData.getLoginName()); + flowTaskComment.setCreateUsername(tokenData.getShowName()); + } + flowTaskComment.setCreateTime(new Date()); + flowTaskCommentMapper.insert(flowTaskComment); + FlowTaskComment.setToRequest(flowTaskComment); + return flowTaskComment; + } + + /** + * 查询指定流程实例Id下的所有审批任务的批注。 + * + * @param processInstanceId 流程实例Id。 + * @return 查询结果集。 + */ + @Override + public List getFlowTaskCommentList(String processInstanceId) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(FlowTaskComment::getProcessInstanceId, processInstanceId); + queryWrapper.orderBy(FlowTaskComment::getId, true); + return flowTaskCommentMapper.selectListByQuery(queryWrapper); + } + + @Override + public List getFlowTaskCommentListByTaskIds(Set taskIdSet) { + QueryWrapper queryWrapper = new QueryWrapper().in(FlowTaskComment::getTaskId, taskIdSet); + queryWrapper.orderBy(FlowTaskComment::getId, false); + return flowTaskCommentMapper.selectListByQuery(queryWrapper); + } + + @Override + public FlowTaskComment getLatestFlowTaskComment(String processInstanceId) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(FlowTaskComment::getProcessInstanceId, processInstanceId); + queryWrapper.orderBy(FlowTaskComment::getId, false); + Page pageData = flowTaskCommentMapper.paginate(new Page<>(1, 1), queryWrapper); + return CollUtil.isEmpty(pageData.getRecords()) ? null : pageData.getRecords().get(0); + } + + @Override + public FlowTaskComment getLatestFlowTaskComment(String processInstanceId, String taskDefinitionKey) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(FlowTaskComment::getProcessInstanceId, processInstanceId); + queryWrapper.eq(FlowTaskComment::getTaskKey, taskDefinitionKey); + queryWrapper.orderBy(FlowTaskComment::getId, false); + Page pageData = flowTaskCommentMapper.paginate(new Page<>(1, 1), queryWrapper); + return CollUtil.isEmpty(pageData.getRecords()) ? null : pageData.getRecords().get(0); + } + + @Override + public FlowTaskComment getFirstFlowTaskComment(String processInstanceId) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(FlowTaskComment::getProcessInstanceId, processInstanceId); + queryWrapper.orderBy(FlowTaskComment::getId, true); + Page pageData = flowTaskCommentMapper.paginate(new Page<>(1, 1), queryWrapper); + return CollUtil.isEmpty(pageData.getRecords()) ? null : pageData.getRecords().get(0); + } + + @Override + public List getFlowTaskCommentListByExecutionId( + String processInstanceId, String taskId, String executionId) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(FlowTaskComment::getProcessInstanceId, processInstanceId); + queryWrapper.eq(FlowTaskComment::getTaskId, taskId); + queryWrapper.eq(FlowTaskComment::getExecutionId, executionId); + queryWrapper.orderBy(FlowTaskComment::getCreateTime, true); + return flowTaskCommentMapper.selectListByQuery(queryWrapper); + } + + @Override + public List getFlowTaskCommentListByMultiInstanceExecId(String multiInstanceExecId) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(FlowTaskComment::getMultiInstanceExecId, multiInstanceExecId); + return flowTaskCommentMapper.selectListByQuery(queryWrapper); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowTaskExtServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowTaskExtServiceImpl.java new file mode 100644 index 00000000..ad2a5a83 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowTaskExtServiceImpl.java @@ -0,0 +1,622 @@ +package com.orangeforms.common.flow.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.mybatisflex.core.query.QueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.core.object.Tuple2; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.flow.constant.FlowApprovalType; +import com.orangeforms.common.flow.constant.FlowConstant; +import com.orangeforms.common.flow.object.FlowElementExtProperty; +import com.orangeforms.common.flow.object.FlowTaskMultiSignAssign; +import com.orangeforms.common.flow.object.FlowUserTaskExtData; +import com.orangeforms.common.flow.service.*; +import com.orangeforms.common.flow.dao.*; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.flow.util.BaseFlowIdentityExtHelper; +import com.orangeforms.common.flow.util.FlowCustomExtFactory; +import com.orangeforms.common.flow.vo.FlowUserInfoVo; +import com.orangeforms.common.flow.vo.TaskInfoVo; +import lombok.extern.slf4j.Slf4j; +import org.flowable.bpmn.model.*; +import org.flowable.bpmn.model.Process; +import org.flowable.task.api.TaskInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; + +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("flowTaskExtService") +public class FlowTaskExtServiceImpl extends BaseService implements FlowTaskExtService { + + @Autowired + private FlowTaskExtMapper flowTaskExtMapper; + @Autowired + private FlowEntryVariableService flowEntryVariableService; + @Autowired + private FlowCustomExtFactory flowCustomExtFactory; + @Autowired + private FlowApiService flowApiService; + @Autowired + private FlowMultiInstanceTransService flowMultiInstanceTransService; + @Autowired + private FlowTaskCommentService flowTaskCommentService; + + private static final String ID = "id"; + private static final String TYPE = "type"; + private static final String LABEL = "label"; + private static final String NAME = "name"; + private static final String VALUE = "value"; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return flowTaskExtMapper; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void saveBatch(List flowTaskExtList) { + if (CollUtil.isNotEmpty(flowTaskExtList)) { + flowTaskExtMapper.insertList(flowTaskExtList); + } + } + + @Override + public FlowTaskExt getByProcessDefinitionIdAndTaskId(String processDefinitionId, String taskId) { + FlowTaskExt filter = new FlowTaskExt(); + filter.setProcessDefinitionId(processDefinitionId); + filter.setTaskId(taskId); + return flowTaskExtMapper.selectOneByQuery(QueryWrapper.create(filter)); + } + + @Override + public List getByProcessDefinitionId(String processDefinitionId) { + FlowTaskExt filter = new FlowTaskExt(); + filter.setProcessDefinitionId(processDefinitionId); + return flowTaskExtMapper.selectListByQuery(QueryWrapper.create(filter)); + } + + @Override + public List getCandidateUserInfoList( + String processInstanceId, + FlowTaskExt flowTaskExt, + TaskInfo taskInfo, + boolean isMultiInstanceTask, + boolean historic) { + List resultUserMapList = new LinkedList<>(); + if (!isMultiInstanceTask && this.buildTransferUserList(taskInfo, resultUserMapList)) { + return resultUserMapList; + } + Set loginNameSet = new HashSet<>(); + this.buildFlowUserInfoListByDeptAndRoleIds(flowTaskExt, loginNameSet, resultUserMapList); + BaseFlowIdentityExtHelper flowIdentityExtHelper = flowCustomExtFactory.getFlowIdentityExtHelper(); + Set usernameSet = new HashSet<>(); + switch (flowTaskExt.getGroupType()) { + case FlowConstant.GROUP_TYPE_ASSIGNEE: + usernameSet.add(taskInfo.getAssignee()); + break; + case FlowConstant.GROUP_TYPE_DEPT_POST_LEADER: + String deptPostLeaderId = flowApiService.getExecutionVariableStringWithSafe( + taskInfo.getExecutionId(), FlowConstant.GROUP_TYPE_DEPT_POST_LEADER_VAR); + List userInfoList = + flowIdentityExtHelper.getUserInfoListByDeptPostIds(CollUtil.newHashSet(deptPostLeaderId)); + this.buildUserMapList(userInfoList, loginNameSet, resultUserMapList); + break; + case FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER: + String upDeptPostLeaderId = flowApiService.getExecutionVariableStringWithSafe( + taskInfo.getExecutionId(), FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER_VAR); + List upUserInfoList = + flowIdentityExtHelper.getUserInfoListByDeptPostIds(CollUtil.newHashSet(upDeptPostLeaderId)); + this.buildUserMapList(upUserInfoList, loginNameSet, resultUserMapList); + break; + default: + break; + } + List candidateUsernames = flowApiService.getCandidateUsernames(flowTaskExt, taskInfo.getId()); + if (CollUtil.isNotEmpty(candidateUsernames)) { + usernameSet.addAll(candidateUsernames); + } + if (isMultiInstanceTask) { + List assigneeList = this.getAssigneeList(taskInfo.getExecutionId(), taskInfo.getId()); + if (CollUtil.isNotEmpty(assigneeList)) { + usernameSet.addAll(assigneeList); + } + } + if (CollUtil.isNotEmpty(usernameSet)) { + List userInfoList = flowIdentityExtHelper.getUserInfoListByUsernameSet(usernameSet); + this.buildUserMapList(userInfoList, loginNameSet, resultUserMapList); + } + Tuple2, Set> tuple2 = + flowApiService.getDeptPostIdAndPostIds(flowTaskExt, processInstanceId, historic); + Set postIdSet = tuple2.getSecond(); + Set deptPostIdSet = tuple2.getFirst(); + if (CollUtil.isNotEmpty(postIdSet)) { + List userInfoList = flowIdentityExtHelper.getUserInfoListByPostIds(postIdSet); + this.buildUserMapList(userInfoList, loginNameSet, resultUserMapList); + } + if (CollUtil.isNotEmpty(deptPostIdSet)) { + List userInfoList = flowIdentityExtHelper.getUserInfoListByDeptPostIds(deptPostIdSet); + this.buildUserMapList(userInfoList, loginNameSet, resultUserMapList); + } + return resultUserMapList; + } + + @Override + public List getCandidateUserInfoList( + String processInstanceId, + String executionId, + FlowTaskExt flowTaskExt) { + List resultUserMapList = new LinkedList<>(); + Set loginNameSet = new HashSet<>(); + this.buildFlowUserInfoListByDeptAndRoleIds(flowTaskExt, loginNameSet, resultUserMapList); + Set usernameSet = new HashSet<>(); + BaseFlowIdentityExtHelper flowIdentityExtHelper = flowCustomExtFactory.getFlowIdentityExtHelper(); + switch (flowTaskExt.getGroupType()) { + case FlowConstant.GROUP_TYPE_DEPT_POST_LEADER: + String deptPostLeaderId = flowApiService.getExecutionVariableStringWithSafe( + executionId, FlowConstant.GROUP_TYPE_DEPT_POST_LEADER_VAR); + List userInfoList = + flowIdentityExtHelper.getUserInfoListByDeptPostIds(CollUtil.newHashSet(deptPostLeaderId)); + this.buildUserMapList(userInfoList, loginNameSet, resultUserMapList); + break; + case FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER: + String upDeptPostLeaderId = flowApiService.getExecutionVariableStringWithSafe( + executionId, FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER_VAR); + List upUserInfoList = + flowIdentityExtHelper.getUserInfoListByDeptPostIds(CollUtil.newHashSet(upDeptPostLeaderId)); + this.buildUserMapList(upUserInfoList, loginNameSet, resultUserMapList); + break; + default: + break; + } + List candidateUsernames; + if (StrUtil.isBlank(flowTaskExt.getCandidateUsernames())) { + candidateUsernames = Collections.emptyList(); + } else { + if (!StrUtil.equals(flowTaskExt.getCandidateUsernames(), "${" + FlowConstant.TASK_APPOINTED_ASSIGNEE_VAR + "}")) { + candidateUsernames = StrUtil.split(flowTaskExt.getCandidateUsernames(), ","); + } else { + Object v = flowApiService.getExecutionVariableStringWithSafe(executionId, FlowConstant.TASK_APPOINTED_ASSIGNEE_VAR); + candidateUsernames = v == null ? null : StrUtil.split(v.toString(), ","); + } + } + if (CollUtil.isNotEmpty(candidateUsernames)) { + usernameSet.addAll(candidateUsernames); + } + if (CollUtil.isNotEmpty(usernameSet)) { + List userInfoList = flowIdentityExtHelper.getUserInfoListByUsernameSet(usernameSet); + this.buildUserMapList(userInfoList, loginNameSet, resultUserMapList); + } + Tuple2, Set> tuple2 = + flowApiService.getDeptPostIdAndPostIds(flowTaskExt, processInstanceId, false); + Set postIdSet = tuple2.getSecond(); + Set deptPostIdSet = tuple2.getFirst(); + if (CollUtil.isNotEmpty(postIdSet)) { + List userInfoList = flowIdentityExtHelper.getUserInfoListByPostIds(postIdSet); + this.buildUserMapList(userInfoList, loginNameSet, resultUserMapList); + } + if (CollUtil.isNotEmpty(deptPostIdSet)) { + List userInfoList = flowIdentityExtHelper.getUserInfoListByDeptPostIds(deptPostIdSet); + this.buildUserMapList(userInfoList, loginNameSet, resultUserMapList); + } + return resultUserMapList; + } + + private void buildUserMapList( + List userInfoList, Set loginNameSet, List userMapList) { + if (CollUtil.isEmpty(userInfoList)) { + return; + } + for (FlowUserInfoVo userInfo : userInfoList) { + if (!loginNameSet.contains(userInfo.getLoginName())) { + loginNameSet.add(userInfo.getLoginName()); + userMapList.add(userInfo); + } + } + } + + @Override + public FlowTaskExt buildTaskExtByUserTask(UserTask userTask) { + FlowTaskExt flowTaskExt = new FlowTaskExt(); + flowTaskExt.setTaskId(userTask.getId()); + String formKey = userTask.getFormKey(); + if (StrUtil.isNotBlank(formKey)) { + TaskInfoVo taskInfoVo = JSON.parseObject(formKey, TaskInfoVo.class); + flowTaskExt.setGroupType(taskInfoVo.getGroupType()); + } + JSONObject extraDataJson = this.buildFlowTaskExtensionData(userTask); + if (extraDataJson != null) { + flowTaskExt.setExtraDataJson(extraDataJson.toJSONString()); + } + Map> extensionMap = userTask.getExtensionElements(); + if (MapUtil.isEmpty(extensionMap)) { + return flowTaskExt; + } + List operationList = this.buildOperationListExtensionElement(extensionMap); + if (CollUtil.isNotEmpty(operationList)) { + flowTaskExt.setOperationListJson(JSON.toJSONString(operationList)); + } + List variableList = this.buildVariableListExtensionElement(extensionMap); + if (CollUtil.isNotEmpty(variableList)) { + flowTaskExt.setVariableListJson(JSON.toJSONString(variableList)); + } + JSONObject assigneeListObject = this.buildAssigneeListExtensionElement(extensionMap); + if (assigneeListObject != null) { + flowTaskExt.setAssigneeListJson(JSON.toJSONString(assigneeListObject)); + } + List deptPostList = this.buildDeptPostListExtensionElement(extensionMap); + if (deptPostList != null) { + flowTaskExt.setDeptPostListJson(JSON.toJSONString(deptPostList)); + } + List copyList = this.buildCopyListExtensionElement(extensionMap); + if (copyList != null) { + flowTaskExt.setCopyListJson(JSON.toJSONString(copyList)); + } + JSONObject candidateGroupObject = this.buildUserCandidateGroupsExtensionElement(extensionMap); + if (candidateGroupObject != null) { + String type = candidateGroupObject.getString(TYPE); + String value = candidateGroupObject.getString(VALUE); + switch (type) { + case "DEPT": + flowTaskExt.setDeptIds(value); + break; + case "ROLE": + flowTaskExt.setRoleIds(value); + break; + case "USERS": + flowTaskExt.setCandidateUsernames(value); + break; + default: + break; + } + } + return flowTaskExt; + } + + @Override + public List buildTaskExtList(BpmnModel bpmnModel) { + List processList = bpmnModel.getProcesses(); + List flowTaskExtList = new LinkedList<>(); + for (Process process : processList) { + for (FlowElement element : process.getFlowElements()) { + this.doBuildTaskExtList(element, flowTaskExtList); + } + } + return flowTaskExtList; + } + + @Override + public List buildOperationListExtensionElement(Map> extensionMap) { + List formOperationElements = + this.getMyExtensionElementList(extensionMap, "operationList", "formOperation"); + if (CollUtil.isEmpty(formOperationElements)) { + return Collections.emptyList(); + } + List resultList = new LinkedList<>(); + for (ExtensionElement e : formOperationElements) { + JSONObject operationJsonData = new JSONObject(); + operationJsonData.put(ID, e.getAttributeValue(null, ID)); + operationJsonData.put(LABEL, e.getAttributeValue(null, LABEL)); + operationJsonData.put(TYPE, e.getAttributeValue(null, TYPE)); + operationJsonData.put("showOrder", e.getAttributeValue(null, "showOrder")); + operationJsonData.put("latestApprovalStatus", e.getAttributeValue(null, "latestApprovalStatus")); + String multiSignAssignee = e.getAttributeValue(null, "multiSignAssignee"); + if (StrUtil.isNotBlank(multiSignAssignee)) { + operationJsonData.put("multiSignAssignee", + JSON.parseObject(multiSignAssignee, FlowTaskMultiSignAssign.class)); + } + resultList.add(operationJsonData); + } + return resultList; + } + + @Override + public List buildVariableListExtensionElement(Map> extensionMap) { + List formVariableElements = + this.getMyExtensionElementList(extensionMap, "variableList", "formVariable"); + if (CollUtil.isEmpty(formVariableElements)) { + return Collections.emptyList(); + } + Set variableIdSet = new HashSet<>(); + for (ExtensionElement e : formVariableElements) { + String id = e.getAttributeValue(null, ID); + variableIdSet.add(Long.parseLong(id)); + } + List variableList = flowEntryVariableService.getInList(variableIdSet); + List resultList = new LinkedList<>(); + for (FlowEntryVariable variable : variableList) { + resultList.add((JSONObject) JSON.toJSON(variable)); + } + return resultList; + } + + @Override + public FlowElementExtProperty buildFlowElementExt(FlowElement element) { + JSONObject propertiesData = this.buildFlowElementExtToJson(element); + return propertiesData == null ? null : propertiesData.toJavaObject(FlowElementExtProperty.class); + } + + @Override + public JSONObject buildFlowElementExtToJson(FlowElement element) { + Map> extensionMap = element.getExtensionElements(); + List propertiesElements = + this.getMyExtensionElementList(extensionMap, "properties", "property"); + if (CollUtil.isEmpty(propertiesElements)) { + return null; + } + JSONObject propertiesData = new JSONObject(); + for (ExtensionElement e : propertiesElements) { + String name = e.getAttributeValue(null, NAME); + String value = e.getAttributeValue(null, VALUE); + propertiesData.put(name, value); + } + return propertiesData; + } + + private void doBuildTaskExtList(FlowElement element, List flowTaskExtList) { + if (element instanceof UserTask) { + FlowTaskExt flowTaskExt = this.buildTaskExtByUserTask((UserTask) element); + flowTaskExtList.add(flowTaskExt); + } else if (element instanceof SubProcess) { + Collection flowElements = ((SubProcess) element).getFlowElements(); + for (FlowElement element1 : flowElements) { + this.doBuildTaskExtList(element1, flowTaskExtList); + } + } + } + + private void buildFlowUserInfoListByDeptAndRoleIds( + FlowTaskExt flowTaskExt, Set loginNameSet, List resultUserMapList) { + BaseFlowIdentityExtHelper flowIdentityExtHelper = flowCustomExtFactory.getFlowIdentityExtHelper(); + if (StrUtil.isNotBlank(flowTaskExt.getDeptIds())) { + Set deptIdSet = CollUtil.newHashSet(StrUtil.split(flowTaskExt.getDeptIds(), ',')); + List userInfoList = flowIdentityExtHelper.getUserInfoListByDeptIds(deptIdSet); + this.buildUserMapList(userInfoList, loginNameSet, resultUserMapList); + } + if (StrUtil.isNotBlank(flowTaskExt.getRoleIds())) { + Set roleIdSet = CollUtil.newHashSet(StrUtil.split(flowTaskExt.getRoleIds(), ',')); + List userInfoList = flowIdentityExtHelper.getUserInfoListByRoleIds(roleIdSet); + this.buildUserMapList(userInfoList, loginNameSet, resultUserMapList); + } + } + + private void buildFlowTaskTimeoutExtensionData( + Map> attributeMap, JSONObject extraDataJson) { + List timeoutHandleWayAttributes = attributeMap.get(FlowConstant.TASK_TIMEOUT_HANDLE_WAY); + if (CollUtil.isNotEmpty(timeoutHandleWayAttributes)) { + String handleWay = timeoutHandleWayAttributes.get(0).getValue(); + extraDataJson.put(FlowConstant.TASK_TIMEOUT_HANDLE_WAY, handleWay); + List timeoutHoursAttributes = attributeMap.get(FlowConstant.TASK_TIMEOUT_HOURS); + if (CollUtil.isEmpty(timeoutHoursAttributes)) { + throw new MyRuntimeException("没有设置任务超时小时数!"); + } + Integer timeoutHours = Integer.valueOf(timeoutHoursAttributes.get(0).getValue()); + extraDataJson.put(FlowConstant.TASK_TIMEOUT_HOURS, timeoutHours); + if (StrUtil.equals(handleWay, FlowUserTaskExtData.TIMEOUT_AUTO_COMPLETE)) { + List defaultAssigneeAttributes = + attributeMap.get(FlowConstant.TASK_TIMEOUT_DEFAULT_ASSIGNEE); + if (CollUtil.isEmpty(defaultAssigneeAttributes)) { + throw new MyRuntimeException("没有设置超时任务处理人!"); + } + extraDataJson.put(FlowConstant.TASK_TIMEOUT_DEFAULT_ASSIGNEE, defaultAssigneeAttributes.get(0).getValue()); + } + } + } + + private void buildFlowTaskEmptyUserExtensionData( + Map> attributeMap, JSONObject extraDataJson) { + List emptyUserHandleWayAttributes = attributeMap.get(FlowConstant.EMPTY_USER_HANDLE_WAY); + if (CollUtil.isNotEmpty(emptyUserHandleWayAttributes)) { + String handleWay = emptyUserHandleWayAttributes.get(0).getValue(); + extraDataJson.put(FlowConstant.EMPTY_USER_HANDLE_WAY, handleWay); + if (StrUtil.equals(handleWay, FlowUserTaskExtData.EMPTY_USER_TO_ASSIGNEE)) { + List emptyUserToAssigneeAttributes = attributeMap.get(FlowConstant.EMPTY_USER_TO_ASSIGNEE); + if (CollUtil.isEmpty(emptyUserToAssigneeAttributes)) { + throw new MyRuntimeException("没有设置空审批人的指定处理人!"); + } + extraDataJson.put(FlowConstant.EMPTY_USER_TO_ASSIGNEE, emptyUserToAssigneeAttributes.get(0).getValue()); + } + } + } + + private JSONObject buildFlowTaskExtensionData(UserTask userTask) { + JSONObject extraDataJson = this.buildFlowElementExtToJson(userTask); + Map> attributeMap = userTask.getAttributes(); + if (MapUtil.isEmpty(attributeMap)) { + return extraDataJson; + } + if (extraDataJson == null) { + extraDataJson = new JSONObject(); + } + this.buildFlowTaskTimeoutExtensionData(attributeMap, extraDataJson); + this.buildFlowTaskEmptyUserExtensionData(attributeMap, extraDataJson); + List rejectTypeAttributes = attributeMap.get(FlowConstant.USER_TASK_REJECT_TYPE_KEY); + if (CollUtil.isNotEmpty(rejectTypeAttributes)) { + extraDataJson.put(FlowConstant.USER_TASK_REJECT_TYPE_KEY, rejectTypeAttributes.get(0).getValue()); + } + List sendMsgTypeAttributes = attributeMap.get("sendMessageType"); + if (CollUtil.isNotEmpty(sendMsgTypeAttributes)) { + ExtensionAttribute attribute = sendMsgTypeAttributes.get(0); + extraDataJson.put(FlowConstant.USER_TASK_NOTIFY_TYPES_KEY, StrUtil.split(attribute.getValue(), ",")); + } + return extraDataJson; + } + + private JSONObject buildUserCandidateGroupsExtensionElement(Map> extensionMap) { + JSONObject jsonData = null; + List elementCandidateGroupsList = extensionMap.get("userCandidateGroups"); + if (CollUtil.isEmpty(elementCandidateGroupsList)) { + return jsonData; + } + jsonData = new JSONObject(); + ExtensionElement ee = elementCandidateGroupsList.get(0); + jsonData.put(TYPE, ee.getAttributeValue(null, TYPE)); + jsonData.put(VALUE, ee.getAttributeValue(null, VALUE)); + return jsonData; + } + + private JSONObject buildAssigneeListExtensionElement(Map> extensionMap) { + JSONObject jsonData = null; + List elementAssigneeList = extensionMap.get("assigneeList"); + if (CollUtil.isEmpty(elementAssigneeList)) { + return jsonData; + } + ExtensionElement ee = elementAssigneeList.get(0); + Map> childExtensionMap = ee.getChildElements(); + if (MapUtil.isEmpty(childExtensionMap)) { + return jsonData; + } + List assigneeElements = childExtensionMap.get("assignee"); + if (CollUtil.isEmpty(assigneeElements)) { + return jsonData; + } + JSONArray assigneeIdArray = new JSONArray(); + for (ExtensionElement e : assigneeElements) { + assigneeIdArray.add(e.getAttributeValue(null, ID)); + } + jsonData = new JSONObject(); + String assigneeType = ee.getAttributeValue(null, TYPE); + jsonData.put("assigneeType", assigneeType); + jsonData.put("assigneeList", assigneeIdArray); + return jsonData; + } + + private List buildDeptPostListExtensionElement(Map> extensionMap) { + List deptPostElements = + this.getMyExtensionElementList(extensionMap, "deptPostList", "deptPost"); + if (CollUtil.isEmpty(deptPostElements)) { + return Collections.emptyList(); + } + List resultList = new LinkedList<>(); + for (ExtensionElement e : deptPostElements) { + JSONObject deptPostJsonData = new JSONObject(); + deptPostJsonData.put(ID, e.getAttributeValue(null, ID)); + deptPostJsonData.put(TYPE, e.getAttributeValue(null, TYPE)); + String postId = e.getAttributeValue(null, "postId"); + if (postId != null) { + deptPostJsonData.put("postId", postId); + } + String deptPostId = e.getAttributeValue(null, "deptPostId"); + if (deptPostId != null) { + deptPostJsonData.put("deptPostId", deptPostId); + } + resultList.add(deptPostJsonData); + } + return resultList; + } + + private List buildCopyListExtensionElement(Map> extensionMap) { + List copyElements = + this.getMyExtensionElementList(extensionMap, "copyItemList", "copyItem"); + if (CollUtil.isEmpty(copyElements)) { + return Collections.emptyList(); + } + List resultList = new LinkedList<>(); + for (ExtensionElement e : copyElements) { + JSONObject copyJsonData = new JSONObject(); + String type = e.getAttributeValue(null, TYPE); + copyJsonData.put(TYPE, type); + if (!StrUtil.equalsAny(type, FlowConstant.GROUP_TYPE_DEPT_POST_LEADER_VAR, + FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER_VAR, + FlowConstant.GROUP_TYPE_USER_VAR, + FlowConstant.GROUP_TYPE_ROLE_VAR, + FlowConstant.GROUP_TYPE_DEPT_VAR, + FlowConstant.GROUP_TYPE_DEPT_POST_VAR, + FlowConstant.GROUP_TYPE_ALL_DEPT_POST_VAR, + FlowConstant.GROUP_TYPE_SIBLING_DEPT_POST_VAR, + FlowConstant.GROUP_TYPE_SELF_DEPT_POST_VAR, + FlowConstant.GROUP_TYPE_UP_DEPT_POST_VAR)) { + throw new MyRuntimeException("Invalid TYPE [" + type + " ] for CopyItenList Extension!"); + } + String id = e.getAttributeValue(null, ID); + if (StrUtil.isNotBlank(id)) { + copyJsonData.put(ID, id); + } + resultList.add(copyJsonData); + } + return resultList; + } + + private List getMyExtensionElementList( + Map> extensionMap, String rootName, String childName) { + if (extensionMap == null) { + return Collections.emptyList(); + } + List elementList = extensionMap.get(rootName); + if (CollUtil.isEmpty(elementList)) { + return Collections.emptyList(); + } + if (StrUtil.isBlank(childName)) { + return elementList; + } + ExtensionElement ee = elementList.get(0); + Map> childExtensionMap = ee.getChildElements(); + if (MapUtil.isEmpty(childExtensionMap)) { + return Collections.emptyList(); + } + List childrenElements = childExtensionMap.get(childName); + if (CollUtil.isEmpty(childrenElements)) { + return Collections.emptyList(); + } + return childrenElements; + } + + private List getAssigneeList(String executionId, String taskId) { + FlowMultiInstanceTrans flowMultiInstanceTrans = + flowMultiInstanceTransService.getByExecutionId(executionId, taskId); + String multiInstanceExecId; + if (flowMultiInstanceTrans == null) { + multiInstanceExecId = flowApiService.getTaskVariableStringWithSafe( + taskId, FlowConstant.MULTI_SIGN_TASK_EXECUTION_ID_VAR); + } else { + multiInstanceExecId = flowMultiInstanceTrans.getMultiInstanceExecId(); + } + flowMultiInstanceTrans = + flowMultiInstanceTransService.getWithAssigneeListByMultiInstanceExecId(multiInstanceExecId); + return flowMultiInstanceTrans == null ? null + : StrUtil.split(flowMultiInstanceTrans.getAssigneeList(), ","); + } + + private boolean buildTransferUserList(TaskInfo taskInfo, List resultUserMapList) { + BaseFlowIdentityExtHelper flowIdentityExtHelper = flowCustomExtFactory.getFlowIdentityExtHelper(); + List taskCommentList = flowTaskCommentService.getFlowTaskCommentListByExecutionId( + taskInfo.getProcessInstanceId(), taskInfo.getId(), taskInfo.getExecutionId()); + if (CollUtil.isEmpty(taskCommentList)) { + return false; + } + FlowTaskComment transferComment = null; + for (int i = taskCommentList.size() - 1; i >= 0; i--) { + FlowTaskComment comment = taskCommentList.get(i); + if (StrUtil.equalsAny(comment.getApprovalType(), + FlowApprovalType.TRANSFER, FlowApprovalType.INTERVENE)) { + transferComment = comment; + break; + } + } + if (transferComment == null || StrUtil.isBlank(transferComment.getDelegateAssignee())) { + return false; + } + Set loginNameSet = new HashSet<>(StrUtil.split(transferComment.getDelegateAssignee(), ",")); + resultUserMapList.addAll(flowIdentityExtHelper.getUserInfoListByUsernameSet(loginNameSet)); + return true; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowWorkOrderServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowWorkOrderServiceImpl.java new file mode 100644 index 00000000..38e7aac6 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowWorkOrderServiceImpl.java @@ -0,0 +1,354 @@ +package com.orangeforms.common.flow.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.mybatisflex.core.query.QueryWrapper; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.common.core.annotation.DisableDataFilter; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.constant.GlobalDeletedFlag; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.flow.constant.FlowTaskStatus; +import com.orangeforms.common.flow.constant.FlowConstant; +import com.orangeforms.common.flow.dao.FlowWorkOrderExtMapper; +import com.orangeforms.common.flow.dao.FlowWorkOrderMapper; +import com.orangeforms.common.flow.dto.FlowWorkOrderDto; +import com.orangeforms.common.flow.model.FlowEntry; +import com.orangeforms.common.flow.model.FlowWorkOrder; +import com.orangeforms.common.flow.model.FlowWorkOrderExt; +import com.orangeforms.common.flow.util.FlowOperationHelper; +import com.orangeforms.common.flow.vo.FlowWorkOrderVo; +import com.orangeforms.common.flow.service.FlowApiService; +import com.orangeforms.common.flow.service.FlowEntryService; +import com.orangeforms.common.flow.service.FlowWorkOrderService; +import com.orangeforms.common.flow.util.BaseFlowIdentityExtHelper; +import com.orangeforms.common.flow.util.FlowCustomExtFactory; +import com.orangeforms.common.redis.util.CommonRedisUtil; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.runtime.ProcessInstance; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("flowWorkOrderService") +public class FlowWorkOrderServiceImpl extends BaseService implements FlowWorkOrderService { + + @Autowired + private FlowWorkOrderMapper flowWorkOrderMapper; + @Autowired + private FlowWorkOrderExtMapper flowWorkOrderExtMapper; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private FlowCustomExtFactory flowCustomExtFactory; + @Autowired + private FlowApiService flowApiService; + @Autowired + private FlowEntryService flowEntryService; + @Autowired + private CommonRedisUtil commonRedisUtil; + @Autowired + private FlowOperationHelper flowOperationHelper; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return flowWorkOrderMapper; + } + + /** + * 保存新增对象。 + * + * @param instance 流程实例对象。 + * @param dataId 流程实例的BusinessKey。 + * @param onlineTableId 在线数据表的主键Id。 + * @param tableName 面向静态表单所使用的表名。 + * @return 新增的工作流工单对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public FlowWorkOrder saveNew(ProcessInstance instance, Object dataId, Long onlineTableId, String tableName) { + // 正常插入流程工单数据。 + FlowWorkOrder flowWorkOrder = this.createWith(instance); + flowWorkOrder.setWorkOrderCode(this.generateWorkOrderCode(instance.getProcessDefinitionKey())); + flowWorkOrder.setBusinessKey(dataId.toString()); + flowWorkOrder.setOnlineTableId(onlineTableId); + flowWorkOrder.setTableName(tableName); + flowWorkOrder.setFlowStatus(FlowTaskStatus.SUBMITTED); + flowWorkOrderMapper.insert(flowWorkOrder); + return flowWorkOrder; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public FlowWorkOrder saveNewWithDraft( + ProcessInstance instance, Long onlineTableId, String tableName, String masterData, String slaveData) { + FlowWorkOrder flowWorkOrder = this.createWith(instance); + flowWorkOrder.setWorkOrderCode(this.generateWorkOrderCode(instance.getProcessDefinitionKey())); + flowWorkOrder.setOnlineTableId(onlineTableId); + flowWorkOrder.setTableName(tableName); + flowWorkOrder.setFlowStatus(FlowTaskStatus.DRAFT); + JSONObject draftData = new JSONObject(); + if (masterData != null) { + draftData.put(FlowConstant.MASTER_DATA_KEY, masterData); + } + if (slaveData != null) { + draftData.put(FlowConstant.SLAVE_DATA_KEY, slaveData); + } + FlowWorkOrderExt flowWorkOrderExt = + BeanUtil.copyProperties(flowWorkOrder, FlowWorkOrderExt.class); + flowWorkOrderExt.setId(idGenerator.nextLongId()); + flowWorkOrderExt.setDraftData(JSON.toJSONString(draftData)); + flowWorkOrderExtMapper.insert(flowWorkOrderExt); + flowWorkOrderMapper.insert(flowWorkOrder); + return flowWorkOrder; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void updateDraft(Long workOrderId, String masterData, String slaveData) { + JSONObject draftData = new JSONObject(); + if (masterData != null) { + draftData.put(FlowConstant.MASTER_DATA_KEY, masterData); + } + if (slaveData != null) { + draftData.put(FlowConstant.SLAVE_DATA_KEY, slaveData); + } + FlowWorkOrderExt flowWorkOrderExt = new FlowWorkOrderExt(); + flowWorkOrderExt.setDraftData(JSON.toJSONString(draftData)); + flowWorkOrderExt.setUpdateTime(new Date()); + flowWorkOrderExtMapper.updateByQuery(flowWorkOrderExt, + new QueryWrapper().eq(FlowWorkOrderExt::getWorkOrderId, workOrderId)); + } + + /** + * 删除指定数据。 + * + * @param workOrderId 主键Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long workOrderId) { + return flowWorkOrderMapper.deleteById(workOrderId) == 1; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void removeByProcessInstanceId(String processInstanceId) { + FlowWorkOrder filter = new FlowWorkOrder(); + filter.setProcessInstanceId(processInstanceId); + super.removeBy(filter); + } + + @Override + public List getFlowWorkOrderList(FlowWorkOrder filter, String orderBy) { + if (filter == null) { + filter = new FlowWorkOrder(); + } + TokenData tokenData = TokenData.takeFromRequest(); + filter.setTenantId(tokenData.getTenantId()); + filter.setAppCode(tokenData.getAppCode()); + return flowWorkOrderMapper.getFlowWorkOrderList(filter, orderBy); + } + + @Override + public List getFlowWorkOrderListWithRelation(FlowWorkOrder filter, String orderBy) { + List resultList = this.getFlowWorkOrderList(filter, orderBy); + this.buildRelationForDataList(resultList, MyRelationParam.dictOnly()); + return resultList; + } + + @Override + public FlowWorkOrder getFlowWorkOrderByProcessInstanceId(String processInstanceId) { + FlowWorkOrder filter = new FlowWorkOrder(); + filter.setProcessInstanceId(processInstanceId); + return flowWorkOrderMapper.selectOneByQuery(QueryWrapper.create(filter)); + } + + @Override + public boolean existByBusinessKey(String tableName, Object businessKey, boolean unfinished) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(FlowWorkOrder::getBusinessKey, businessKey.toString()); + queryWrapper.eq(FlowWorkOrder::getTableName, tableName); + if (unfinished) { + queryWrapper.notIn(FlowWorkOrder::getFlowStatus, + FlowTaskStatus.FINISHED, FlowTaskStatus.CANCELLED, FlowTaskStatus.STOPPED); + } + return flowWorkOrderMapper.selectCountByQuery(queryWrapper) > 0; + } + + @Override + public boolean existUnfinished(String processDefinitionKey, Object businessKey) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(FlowWorkOrder::getBusinessKey, businessKey.toString()); + queryWrapper.eq(FlowWorkOrder::getProcessDefinitionKey, processDefinitionKey); + queryWrapper.notIn(FlowWorkOrder::getFlowStatus, + FlowTaskStatus.FINISHED, FlowTaskStatus.CANCELLED, FlowTaskStatus.STOPPED); + return flowWorkOrderMapper.selectCountByQuery(queryWrapper) > 0; + } + + @DisableDataFilter + @Transactional(rollbackFor = Exception.class) + @Override + public void updateFlowStatusByProcessInstanceId(String processInstanceId, Integer flowStatus) { + if (flowStatus == null) { + return; + } + FlowWorkOrder flowWorkOrder = new FlowWorkOrder(); + flowWorkOrder.setFlowStatus(flowStatus); + if (FlowTaskStatus.FINISHED != flowStatus) { + flowWorkOrder.setUpdateTime(new Date()); + flowWorkOrder.setUpdateUserId(TokenData.takeFromRequest().getUserId()); + } + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq(FlowWorkOrder::getProcessInstanceId, processInstanceId); + flowWorkOrderMapper.updateByQuery(flowWorkOrder, queryWrapper); + } + + @DisableDataFilter + @Transactional(rollbackFor = Exception.class) + @Override + public void updateLatestApprovalStatusByProcessInstanceId(String processInstanceId, Integer approvalStatus) { + if (approvalStatus == null) { + return; + } + FlowWorkOrder flowWorkOrder = this.getFlowWorkOrderByProcessInstanceId(processInstanceId); + flowWorkOrder.setLatestApprovalStatus(approvalStatus); + flowWorkOrder.setUpdateTime(new Date()); + flowWorkOrder.setUpdateUserId(TokenData.takeFromRequest().getUserId()); + flowWorkOrderMapper.update(flowWorkOrder); + // 处理在线表单工作流的自定义状态更新。 + flowCustomExtFactory.getOnlineBusinessDataExtHelper().updateFlowStatus(flowWorkOrder); + } + + @Override + public boolean hasDataPermOnFlowWorkOrder(String processInstanceId) { + // 开启数据权限,并进行验证。 + boolean originalFlag = GlobalThreadLocal.setDataFilter(true); + long count; + try { + FlowWorkOrder filter = new FlowWorkOrder(); + filter.setProcessInstanceId(processInstanceId); + count = flowWorkOrderMapper.selectCountByQuery(QueryWrapper.create(filter)); + } finally { + // 恢复之前的数据权限标记 + GlobalThreadLocal.setDataFilter(originalFlag); + } + return count > 0; + } + + @Override + public void fillUserShowNameByLoginName(List dataList) { + BaseFlowIdentityExtHelper identityExtHelper = flowCustomExtFactory.getFlowIdentityExtHelper(); + Set loginNameSet = dataList.stream() + .map(FlowWorkOrderVo::getSubmitUsername).collect(Collectors.toSet()); + if (CollUtil.isEmpty(loginNameSet)) { + return; + } + Map userNameMap = identityExtHelper.mapUserShowNameByLoginName(loginNameSet); + dataList.forEach(workOrder -> { + if (StrUtil.isNotBlank(workOrder.getSubmitUsername())) { + workOrder.setUserShowName(userNameMap.get(workOrder.getSubmitUsername())); + } + }); + } + + @Override + public FlowWorkOrderExt getFlowWorkOrderExtByWorkOrderId(Long workOrderId) { + return flowWorkOrderExtMapper.selectOneByQuery( + new QueryWrapper().eq(FlowWorkOrderExt::getWorkOrderId, workOrderId)); + } + + @Override + public List getFlowWorkOrderExtByWorkOrderIds(Set workOrderIds) { + return flowWorkOrderExtMapper.selectListByQuery( + new QueryWrapper().in(FlowWorkOrderExt::getWorkOrderId, workOrderIds)); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public CallResult removeDraft(FlowWorkOrder flowWorkOrder) { + CallResult r = flowApiService.stopProcessInstance(flowWorkOrder.getProcessInstanceId(), "撤销草稿", true); + if (!r.isSuccess()) { + return r; + } + flowWorkOrderMapper.deleteById(flowWorkOrder.getWorkOrderId()); + return CallResult.ok(); + } + + @Override + public MyPageData getPagedWorkOrderListAndBuildData( + FlowWorkOrderDto flowWorkOrderDtoFilter, MyPageParam pageParam, MyOrderParam orderParam, String processDefinitionKey) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount()); + String orderBy = MyOrderParam.buildOrderBy(orderParam, FlowWorkOrder.class); + FlowWorkOrder filter = flowOperationHelper.makeWorkOrderFilter(flowWorkOrderDtoFilter, processDefinitionKey); + List flowWorkOrderList = this.getFlowWorkOrderList(filter, orderBy); + MyPageData resultData = + MyPageUtil.makeResponseData(flowWorkOrderList, FlowWorkOrderVo.class); + if (CollUtil.isEmpty(resultData.getDataList())) { + return resultData; + } + flowOperationHelper.buildWorkOrderApprovalStatus(processDefinitionKey, resultData.getDataList()); + // 根据工单的提交用户名获取用户的显示名称,便于前端显示。 + // 同时这也是一个如何通过插件方法,将loginName映射到showName的示例, + this.fillUserShowNameByLoginName(resultData.getDataList()); + // 组装工单中需要返回给前端的流程任务数据。 + flowOperationHelper.buildWorkOrderTaskInfo(resultData.getDataList()); + return resultData; + } + + private FlowWorkOrder createWith(ProcessInstance instance) { + TokenData tokenData = TokenData.takeFromRequest(); + Date now = new Date(); + FlowWorkOrder flowWorkOrder = new FlowWorkOrder(); + flowWorkOrder.setWorkOrderId(idGenerator.nextLongId()); + flowWorkOrder.setProcessDefinitionKey(instance.getProcessDefinitionKey()); + flowWorkOrder.setProcessDefinitionName(instance.getProcessDefinitionName()); + flowWorkOrder.setProcessDefinitionId(instance.getProcessDefinitionId()); + flowWorkOrder.setProcessInstanceId(instance.getId()); + flowWorkOrder.setSubmitUsername(tokenData.getLoginName()); + flowWorkOrder.setDeptId(tokenData.getDeptId()); + flowWorkOrder.setAppCode(tokenData.getAppCode()); + flowWorkOrder.setTenantId(tokenData.getTenantId()); + flowWorkOrder.setCreateUserId(tokenData.getUserId()); + flowWorkOrder.setUpdateUserId(tokenData.getUserId()); + flowWorkOrder.setCreateTime(now); + flowWorkOrder.setUpdateTime(now); + flowWorkOrder.setDeletedFlag(GlobalDeletedFlag.NORMAL); + return flowWorkOrder; + } + + private String generateWorkOrderCode(String processDefinitionKey) { + FlowEntry flowEntry = flowEntryService.getFlowEntryFromCache(processDefinitionKey); + if (StrUtil.isBlank(flowEntry.getEncodedRule())) { + return null; + } + ColumnEncodedRule rule = JSON.parseObject(flowEntry.getEncodedRule(), ColumnEncodedRule.class); + if (rule.getIdWidth() == null) { + rule.setIdWidth(10); + } + return commonRedisUtil.generateTransId( + rule.getPrefix(), rule.getPrecisionTo(), rule.getMiddle(), rule.getIdWidth()); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/BaseFlowIdentityExtHelper.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/BaseFlowIdentityExtHelper.java new file mode 100644 index 00000000..30715c8c --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/BaseFlowIdentityExtHelper.java @@ -0,0 +1,253 @@ +package com.orangeforms.common.flow.util; + +import com.orangeforms.common.flow.listener.DeptPostLeaderListener; +import com.orangeforms.common.flow.listener.UpDeptPostLeaderListener; +import com.orangeforms.common.flow.vo.FlowUserInfoVo; +import org.flowable.engine.delegate.TaskListener; + +import java.util.*; + +/** + * 工作流与用户身份相关的自定义扩展接口,需要业务模块自行实现该接口。也可以根据实际需求扩展该接口的方法。 + * 目前支持的主键类型为字符型和长整型,所以这里提供了两套实现接口。可根据实际情况实现其中一套即可。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface BaseFlowIdentityExtHelper { + + /** + * 根据(字符型)部门Id,获取当前用户部门领导所有的部门岗位Id。 + * + * @param deptId 用户所在部门Id。 + * @return 当前用户部门领导所有的部门岗位Id。 + */ + default String getLeaderDeptPostId(String deptId) { + return null; + } + + /** + * 根据(字符型)部门Id,获取当前用户上级部门领导所有的部门岗位Id。 + * + * @param deptId 用户所在部门Id。 + * @return 当前用户上级部门领导所有的部门岗位Id。 + */ + default String getUpLeaderDeptPostId(String deptId) { + return null; + } + + /** + * 获取(字符型)指定部门上级部门的指定岗位集合的DeptPostId集合。 + * + * @param deptId 指定的部门Id。 + * @param postIdSet 指定的岗位Id集合。 + * @return 与该部门Id上级部门关联的岗位Id集合,key对应参数中的postId,value是与key对应的deptPostId。 + */ + default Map getUpDeptPostIdMap(String deptId, Set postIdSet) { + return null; + } + + /** + * 获取(字符型)指定部门的指定岗位集合的DeptPostId集合。 + * + * @param deptId 指定的部门Id。 + * @param postIdSet 指定的岗位Id集合。 + * @return 与部门关联的岗位Id集合,key对应参数中的postId,value是与key对应的deptPostId。 + */ + default Map getDeptPostIdMap(String deptId, Set postIdSet) { + return null; + } + + /** + * 获取(字符型)指定同级部门的指定岗位集合的DeptPostId集合。 + * + * @param deptId 指定的同级部门Id。 + * @param postIdSet 指定的岗位Id集合。 + * @return 与同级部门关联的岗位Id集合,key对应参数中的postId,value是与key对应的deptPostId。 + */ + default Map getSiblingDeptPostIdMap(String deptId, Set postIdSet) { + return null; + } + + /** + * 根据(长整型)部门Id,获取当前用户部门领导所有的部门岗位Id。 + * + * @param deptId 用户所在部门Id。 + * @return 当前用户部门领导所有的部门岗位Id。 + */ + default Long getLeaderDeptPostId(Long deptId) { + return null; + } + + /** + * 根据(长整型)部门Id,获取当前用户上级部门领导所有的部门岗位Id。 + * + * @param deptId 用户所在部门Id。 + * @return 当前用户上级部门领导所有的部门岗位Id。 + */ + default Long getUpLeaderDeptPostId(Long deptId) { + return null; + } + + /** + * 获取(长整型)指定部门的指定岗位集合的DeptPostId集合。 + * + * @param deptId 指定的部门Id。 + * @param postIdSet 指定的岗位Id集合。 + * @return 与部门关联的岗位Id集合,key对应参数中的postId,value是与key对应的deptPostId。 + */ + default Map getDeptPostIdMap(Long deptId, Set postIdSet) { + return null; + } + + /** + * 获取(长整型)指定同级部门的指定岗位集合的DeptPostId集合。 + * + * @param deptId 指定的同级部门Id。 + * @param postIdSet 指定的岗位Id集合。 + * @return 与同级部门关联的岗位Id集合,key对应参数中的postId,value是与key对应的deptPostId。 + */ + default Map getSiblingDeptPostIdMap(Long deptId, Set postIdSet) { + return null; + } + + /** + * 获取(长整型)指定部门上级部门的指定岗位集合的DeptPostId集合。 + * + * @param deptId 指定的部门Id。 + * @param postIdSet 指定的岗位Id集合。 + * @return 与该部门Id上级部门关联的岗位Id集合,key对应参数中的postId,value是与key对应的deptPostId。 + */ + default Map getUpDeptPostIdMap(Long deptId, Set postIdSet) { + return null; + } + + /** + * 根据角色Id集合,查询所属的用户名列表。 + * + * @param roleIdSet 角色Id集合。 + * @return 所属的用户列表。 + */ + default Set getUsernameListByRoleIds(Set roleIdSet) { + return Collections.emptySet(); + } + + /** + * 根据角色Id集合,查询所属的用户对象信息列表。返回的具体数据,用户可自定义。 + * + * @param roleIdSet 角色Id集合。 + * @return 所属的用户对象信息列表。 + */ + default List getUserInfoListByRoleIds(Set roleIdSet) { + return Collections.emptyList(); + } + + /** + * 根据部门Id集合,查询所属的用户名列表。 + * + * @param deptIdSet 部门Id集合。 + * @return 所属的用户列表。 + */ + default Set getUsernameListByDeptIds(Set deptIdSet) { + return Collections.emptySet(); + } + + /** + * 根据部门Id集合,查询所属的用户对象信息列表。返回的具体数据,用户可自定义。 + * + * @param deptIdSet 部门Id集合。 + * @return 所属的用户对象信息列表。 + */ + default List getUserInfoListByDeptIds(Set deptIdSet) { + return Collections.emptyList(); + } + + /** + * 根据岗位Id集合,查询所属的用户名列表。 + * + * @param postIdSet 岗位Id集合。 + * @return 所属的用户列表。 + */ + default Set getUsernameListByPostIds(Set postIdSet) { + return Collections.emptySet(); + } + + /** + * 根据岗位Id集合,查询所属的用户对象信息列表。返回的具体数据,用户可自定义。 + * + * @param postIdSet 岗位Id集合。 + * @return 所属的用户对象信息列表。 + */ + default List getUserInfoListByPostIds(Set postIdSet) { + return Collections.emptyList(); + } + + /** + * 根据部门岗位Id集合,查询所属的用户名列表。 + * + * @param deptPostIdSet 部门岗位Id集合。 + * @return 所属的用户列表。 + */ + default Set getUsernameListByDeptPostIds(Set deptPostIdSet) { + return Collections.emptySet(); + } + + /** + * 根据部门岗位Id集合,查询所属的用户对象信息列表。返回的具体数据,用户可自定义。 + * + * @param deptPostIdSet 部门岗位Id集合。 + * @return 所属的用户对象信息列表。 + */ + default List getUserInfoListByDeptPostIds(Set deptPostIdSet) { + return Collections.emptyList(); + } + + /** + * 根据用户登录名集合,查询所属的用户对象信息列表。返回的具体数据,用户可自定义。 + * + * @param usernameSet 用户登录名集合。 + * @return 用户对象信息列表。 + */ + default List getUserInfoListByUsernameSet(Set usernameSet) { + return Collections.emptyList(); + } + + /** + * 当前服务是否支持数据权限。 + * + * @return true表示支持,否则false。 + */ + default Boolean supprtDataPerm() { + return false; + } + + /** + * 映射用户的登录名到用户的显示名。 + * + * @param loginNameSet 用户登录名集合。 + * @return 用户登录名和显示名的Map,key为登录名,value是显示名。 + */ + default Map mapUserShowNameByLoginName(Set loginNameSet) { + return new HashMap<>(1); + } + + /** + * 获取任务执行人是当前部门领导岗位的任务监听器。 + * 通常会在没有找到领导部门岗位Id的时候,为当前任务指定其他的指派人、候选人或候选组。 + * + * @return 任务监听器。 + */ + default Class getDeptPostLeaderListener() { + return DeptPostLeaderListener.class; + } + + /** + * 获取任务执行人是上级部门领导岗位的任务监听器。 + * 通常会在没有找到领导部门岗位Id的时候,为当前任务指定其他的指派人、候选人或候选组。 + * + * @return 任务监听器。 + */ + default Class getUpDeptPostLeaderListener() { + return UpDeptPostLeaderListener.class; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/BaseFlowNotifyExtHelper.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/BaseFlowNotifyExtHelper.java new file mode 100644 index 00000000..d90cd432 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/BaseFlowNotifyExtHelper.java @@ -0,0 +1,28 @@ +package com.orangeforms.common.flow.util; + +import com.orangeforms.common.flow.vo.FlowTaskVo; +import com.orangeforms.common.flow.vo.FlowUserInfoVo; +import lombok.extern.slf4j.Slf4j; + +import java.util.List; + +/** + * 流程通知扩展帮助实现类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class BaseFlowNotifyExtHelper { + + /** + * 处理消息。 + * + * @param notifyType 通知类型,具体值可参考FlowUserTaskExtData中NOTIFY_TYPE开头的常量。 + * @param userInfoList 待通知的用户信息列表。 + */ + public void doNotify(String notifyType, List userInfoList, FlowTaskVo taskInfo) { + userInfoList.forEach(u -> log.info( + "The user [{}] of Task [{}] is notified by [{}].", u.getLoginName(), taskInfo.getTaskKey(), notifyType)); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/BaseOnlineBusinessDataExtHelper.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/BaseOnlineBusinessDataExtHelper.java new file mode 100644 index 00000000..76b0e2cb --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/BaseOnlineBusinessDataExtHelper.java @@ -0,0 +1,51 @@ +package com.orangeforms.common.flow.util; + +import cn.hutool.core.lang.Assert; +import com.orangeforms.common.flow.base.service.BaseFlowOnlineService; +import com.orangeforms.common.flow.model.FlowWorkOrder; +import lombok.extern.slf4j.Slf4j; + +/** + * 面向在线表单工作流的业务数据扩展帮助实现类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class BaseOnlineBusinessDataExtHelper { + + private BaseFlowOnlineService onlineBusinessService; + + /** + * 设置在线表单的业务处理服务。 + * + * @param onlineBusinessService 在线表单业务处理服务实现类。 + */ + public void setOnlineBusinessService(BaseFlowOnlineService onlineBusinessService) { + this.onlineBusinessService = onlineBusinessService; + } + + /** + * 更新在线表单主表数据的流程状态字段值。 + * + * @param workOrder 工单对象。 + */ + public void updateFlowStatus(FlowWorkOrder workOrder) { + Assert.notNull(workOrder.getOnlineTableId()); + if (this.onlineBusinessService != null && workOrder.getBusinessKey() != null) { + onlineBusinessService.updateFlowStatus(workOrder); + } + } + + /** + * 根据工单对象级联删除业务数据。 + * + * @param workOrder 工单对象。 + */ + public void deleteBusinessData(FlowWorkOrder workOrder) { + Assert.notNull(workOrder.getOnlineTableId()); + if (this.onlineBusinessService != null && workOrder.getBusinessKey() != null) { + onlineBusinessService.deleteBusinessData(workOrder); + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/CustomChangeActivityStateBuilderImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/CustomChangeActivityStateBuilderImpl.java new file mode 100644 index 00000000..aa05956c --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/CustomChangeActivityStateBuilderImpl.java @@ -0,0 +1,29 @@ +package com.orangeforms.common.flow.util; + +import org.flowable.engine.impl.RuntimeServiceImpl; +import org.flowable.engine.impl.runtime.ChangeActivityStateBuilderImpl; +import org.flowable.engine.runtime.ChangeActivityStateBuilder; + +import java.util.List; + +/** + * 自定义修改活动状态构建器实现。主要用于支持多个源节点向多个目标节点跳转的功能。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class CustomChangeActivityStateBuilderImpl extends ChangeActivityStateBuilderImpl { + + public CustomChangeActivityStateBuilderImpl() { + super(); + } + + public CustomChangeActivityStateBuilderImpl(RuntimeServiceImpl runtimeService) { + super(runtimeService); + } + + public ChangeActivityStateBuilder moveActivityIdsToActivityIds(List activityIds, List moveToActivityIds) { + moveActivityIdList.add(new CustomMoveActivityIdContainer(activityIds, moveToActivityIds)); + return this; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/CustomMoveActivityIdContainer.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/CustomMoveActivityIdContainer.java new file mode 100644 index 00000000..66fa2e7e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/CustomMoveActivityIdContainer.java @@ -0,0 +1,24 @@ +package com.orangeforms.common.flow.util; + +import org.flowable.engine.impl.runtime.MoveActivityIdContainer; + +import java.util.List; + +/** + * 自定义移动任务Id的容器类。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class CustomMoveActivityIdContainer extends MoveActivityIdContainer { + + public CustomMoveActivityIdContainer(String singleActivityId, String moveToActivityId) { + super(singleActivityId, moveToActivityId); + } + + public CustomMoveActivityIdContainer(List activityIds, List moveToActivityIds) { + super(activityIds.get(0), moveToActivityIds.get(0)); + this.activityIds = activityIds; + this.moveToActivityIds = moveToActivityIds; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/FlowCustomExtFactory.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/FlowCustomExtFactory.java new file mode 100644 index 00000000..422e016a --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/FlowCustomExtFactory.java @@ -0,0 +1,67 @@ +package com.orangeforms.common.flow.util; + +import org.springframework.stereotype.Component; + +/** + * 工作流自定义扩展工厂类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class FlowCustomExtFactory { + + private BaseFlowIdentityExtHelper flowIdentityExtHelper; + + private BaseOnlineBusinessDataExtHelper onlineBusinessDataExtHelper = new BaseOnlineBusinessDataExtHelper(); + + private BaseFlowNotifyExtHelper flowNotifyExtHelper; + + /** + * 获取业务模块自行实现的用户身份相关的扩展帮助实现类。 + * + * @return 业务模块自行实现的用户身份相关的扩展帮助实现类。 + */ + public BaseFlowIdentityExtHelper getFlowIdentityExtHelper() { + return flowIdentityExtHelper; + } + + /** + * 注册业务模块自行实现的用户身份扩展帮助实现类。 + * + * @param helper 业务模块自行实现的用户身份扩展帮助实现类。 + */ + public void registerFlowIdentityExtHelper(BaseFlowIdentityExtHelper helper) { + this.flowIdentityExtHelper = helper; + } + + /** + * 获取有关在线表单业务数据的扩展帮助实现类。 + * + * @return 有关业务数据的扩展帮助实现类。 + */ + public BaseOnlineBusinessDataExtHelper getOnlineBusinessDataExtHelper() { + return onlineBusinessDataExtHelper; + } + + /** + * 注册流程通知扩展帮助实现类。 + * + * @param helper 流程通知扩展帮助实现类。 + */ + public void registerNotifyExtHelper(BaseFlowNotifyExtHelper helper) { + this.flowNotifyExtHelper = helper; + } + + /** + * 获取流程通知扩展帮助实现类。 + * + * @return 流程消息通知扩展帮助实现类。 + */ + public BaseFlowNotifyExtHelper getFlowNotifyExtHelper() { + if (this.flowNotifyExtHelper == null) { + this.flowNotifyExtHelper = new BaseFlowNotifyExtHelper(); + } + return flowNotifyExtHelper; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/FlowOperationHelper.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/FlowOperationHelper.java new file mode 100644 index 00000000..3b3ebc8e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/FlowOperationHelper.java @@ -0,0 +1,505 @@ +package com.orangeforms.common.flow.util; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.object.ResponseResult; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.flow.constant.FlowApprovalType; +import com.orangeforms.common.flow.constant.FlowConstant; +import com.orangeforms.common.flow.constant.FlowTaskStatus; +import com.orangeforms.common.flow.dto.FlowTaskCommentDto; +import com.orangeforms.common.flow.dto.FlowWorkOrderDto; +import com.orangeforms.common.flow.model.FlowEntry; +import com.orangeforms.common.flow.model.FlowEntryPublish; +import com.orangeforms.common.flow.model.FlowWorkOrder; +import com.orangeforms.common.flow.model.constant.FlowEntryStatus; +import com.orangeforms.common.flow.object.FlowEntryExtensionData; +import com.orangeforms.common.flow.object.FlowRumtimeObject; +import com.orangeforms.common.flow.service.FlowApiService; +import com.orangeforms.common.flow.service.FlowEntryService; +import com.orangeforms.common.flow.service.FlowWorkOrderService; +import com.orangeforms.common.flow.vo.FlowWorkOrderVo; +import com.orangeforms.common.flow.vo.TaskInfoVo; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.history.HistoricProcessInstance; +import org.flowable.engine.runtime.ProcessInstance; +import org.flowable.task.api.Task; +import org.flowable.task.api.TaskInfo; +import org.flowable.task.api.history.HistoricTaskInstance; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 工作流操作的通用帮助对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Component +public class FlowOperationHelper { + + @Autowired + private FlowEntryService flowEntryService; + @Autowired + private FlowApiService flowApiService; + @Autowired + private FlowWorkOrderService flowWorkOrderService; + @Autowired + private FlowCustomExtFactory flowCustomExtFactory; + + /** + * 验证并获取流程对象。 + * + * @param processDefinitionKey 流程引擎的流程定义标识。 + * @return 流程对象。 + */ + public ResponseResult verifyAndGetFlowEntry(String processDefinitionKey) { + String errorMessage; + FlowEntry flowEntry = flowEntryService.getFlowEntryFromCache(processDefinitionKey); + if (flowEntry == null) { + errorMessage = "数据验证失败,该流程并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!flowEntry.getStatus().equals(FlowEntryStatus.PUBLISHED)) { + errorMessage = "数据验证失败,该流程尚未发布,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + FlowEntryPublish flowEntryPublish = + flowEntryService.getFlowEntryPublishFromCache(flowEntry.getMainEntryPublishId()); + flowEntry.setMainFlowEntryPublish(flowEntryPublish); + return ResponseResult.success(flowEntry); + } + + /** + * 验证并获取流程发布对象。 + * + * @param processDefinitionKey 流程引擎的流程定义标识。 + * @return 流程对象。 + */ + public ResponseResult verifyAndGetFlowEntryPublish(String processDefinitionKey) { + // 1. 验证流程数据的合法性。 + ResponseResult flowEntryResult = this.verifyAndGetFlowEntry(processDefinitionKey); + if (!flowEntryResult.isSuccess()) { + return ResponseResult.errorFrom(flowEntryResult); + } + // 2. 验证流程一个用户任务的合法性。 + FlowEntryPublish flowEntryPublish = flowEntryResult.getData().getMainFlowEntryPublish(); + ResponseResult taskInfoResult = this.verifyAndGetInitialTaskInfo(flowEntryPublish, false); + if (!taskInfoResult.isSuccess()) { + return ResponseResult.errorFrom(taskInfoResult); + } + return ResponseResult.success(flowEntryPublish); + } + + /** + * 工作流静态表单的参数验证工具方法。根据流程定义标识,获取关联的流程并对其进行合法性验证。 + * + * @param processDefinitionKey 流程定义标识。 + * @return 返回流程对象。 + */ + public ResponseResult verifyFullAndGetFlowEntry(String processDefinitionKey) { + String errorMessage; + // 验证流程管理数据状态的合法性。 + ResponseResult flowEntryResult = this.verifyAndGetFlowEntry(processDefinitionKey); + if (!flowEntryResult.isSuccess()) { + return ResponseResult.errorFrom(flowEntryResult); + } + // 验证流程一个用户任务的合法性。 + FlowEntryPublish flowEntryPublish = flowEntryResult.getData().getMainFlowEntryPublish(); + if (BooleanUtil.isFalse(flowEntryPublish.getActiveStatus())) { + errorMessage = "数据验证失败,当前流程发布对象已被挂起,不能启动新流程!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + ResponseResult taskInfoResult = + this.verifyAndGetInitialTaskInfo(flowEntryPublish, true); + if (!taskInfoResult.isSuccess()) { + return ResponseResult.errorFrom(taskInfoResult); + } + return flowEntryResult; + } + + /** + * 工作流静态表单的参数验证工具方法。根据参数验证并获取指定的流程任务对象。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 流程任务Id。 + * @param flowTaskComment 流程审批对象。 + * @return 验证后的流程任务对象。 + */ + public ResponseResult verifySubmitAndGetTask( + String processInstanceId, String taskId, FlowTaskCommentDto flowTaskComment) { + // 验证流程任务的合法性。 + Task task = flowApiService.getProcessInstanceActiveTask(processInstanceId, taskId); + ResponseResult taskInfoResult = this.verifyAndGetRuntimeTaskInfo(task); + if (!taskInfoResult.isSuccess()) { + return ResponseResult.errorFrom(taskInfoResult); + } + CallResult assigneeVerifyResult = flowApiService.verifyAssigneeOrCandidateAndClaim(task); + if (!assigneeVerifyResult.isSuccess()) { + return ResponseResult.errorFrom(assigneeVerifyResult); + } + ProcessInstance instance = flowApiService.getProcessInstance(processInstanceId); + if (StrUtil.isBlank(instance.getBusinessKey())) { + return ResponseResult.success(task); + } + String errorMessage; + if (flowTaskComment != null + && StrUtil.equals(flowTaskComment.getApprovalType(), FlowApprovalType.TRANSFER) + && StrUtil.isBlank(flowTaskComment.getDelegateAssignee())) { + errorMessage = "数据验证失败,加签或转办任务指派人不能为空!!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(task); + } + + /** + * 工作流静态表单的参数验证工具方法。根据参数验证并获取指定的流程任务和流程实例。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 流程任务Id。 + * @param flowTaskComment 流程审批对象。 + * @param processDefinitionKey 流程定义标识。 + * @return 验证后的流程运行时常用对象。 + */ + public ResponseResult verifySubmitWithGetInstanceAndTask( + String processInstanceId, String taskId, FlowTaskCommentDto flowTaskComment, String processDefinitionKey) { + ResponseResult taskResult = this.verifySubmitAndGetTask(processInstanceId, taskId, flowTaskComment); + if (!taskResult.isSuccess()) { + return ResponseResult.errorFrom(taskResult); + } + ProcessInstance instance = flowApiService.getProcessInstance(processInstanceId); + if (!StrUtil.equals(instance.getProcessDefinitionKey(), processDefinitionKey)) { + String errorMessage = "数据验证失败,请求流程标识与流程实例不匹配,请核对!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + FlowRumtimeObject o = new FlowRumtimeObject(); + o.setTask(taskResult.getData()); + o.setInstance(instance); + return ResponseResult.success(o); + } + + /** + * 工作流静态表单的参数验证工具方法。根据参数验证并获取指定的历史流程实例对象。 + * 仅当登录用户为任务的分配人时,才能通过验证。 + * + * @param processInstanceId 历史流程实例Id。 + * @param taskId 历史流程任务Id。 + * @return 验证后并返回的历史流程实例对象。 + */ + public ResponseResult verifyAndGetHistoricProcessInstance(String processInstanceId, String taskId) { + String errorMessage; + // 验证流程实例的合法性。 + HistoricProcessInstance instance = flowApiService.getHistoricProcessInstance(processInstanceId); + if (instance == null) { + errorMessage = "数据验证失败,指定的流程实例Id并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + String loginName = TokenData.takeFromRequest().getLoginName(); + if (StrUtil.isBlank(taskId)) { + if (!StrUtil.equals(loginName, instance.getStartUserId()) + && !flowWorkOrderService.hasDataPermOnFlowWorkOrder(processInstanceId)) { + errorMessage = "数据验证失败,指定历史流程的发起人与当前用户不匹配,或者没有查看该工单详情的数据权限!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } else { + HistoricTaskInstance taskInstance = flowApiService.getHistoricTaskInstance(processInstanceId, taskId); + if (taskInstance == null) { + errorMessage = "数据验证失败,指定的任务Id并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!StrUtil.equals(loginName, taskInstance.getAssignee()) + && !flowWorkOrderService.hasDataPermOnFlowWorkOrder(processInstanceId)) { + errorMessage = "数据验证失败,历史任务的指派人与当前用户不匹配,或者没有查看该工单详情的数据权限!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + return ResponseResult.success(instance); + } + + /** + * 工作流静态表单的参数验证工具方法。根据参数验证并获取指定的历史流程实例对象。 + * 仅当登录用户为任务的分配人时,才能通过验证。 + * + * @param processInstanceId 历史流程实例Id。 + * @param taskId 历史流程任务Id。 + * @param processDefinitionKey 流程定义标识。 + * @return 验证后并返回的历史流程实例对象。 + */ + public ResponseResult verifyAndGetHistoricProcessInstance( + String processInstanceId, String taskId, String processDefinitionKey) { + ResponseResult instanceResult = + this.verifyAndGetHistoricProcessInstance(processInstanceId, taskId); + if (!instanceResult.isSuccess()) { + return ResponseResult.errorFrom(instanceResult); + } + HistoricProcessInstance instance = instanceResult.getData(); + if (!StrUtil.equals(instance.getProcessDefinitionKey(), processDefinitionKey)) { + String errorMessage = "数据验证失败,请求流程标识与流程实例不匹配,请核对!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(instance); + } + + /** + * 验证并获取流程的实时任务信息。 + * + * @param task 流程引擎的任务对象。 + * @return 任务信息对象。 + */ + public ResponseResult verifyAndGetRuntimeTaskInfo(Task task) { + String errorMessage; + if (task == null) { + errorMessage = "数据验证失败,指定的任务Id不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!flowApiService.isAssigneeOrCandidate(task)) { + errorMessage = "数据验证失败,当前用户不是指派人也不是候选人之一!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (StrUtil.isBlank(task.getFormKey())) { + errorMessage = "数据验证失败,指定任务的formKey属性不存在,请重新修改流程图!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + TaskInfoVo taskInfo = JSON.parseObject(task.getFormKey(), TaskInfoVo.class); + taskInfo.setTaskKey(task.getTaskDefinitionKey()); + return ResponseResult.success(taskInfo); + } + + /** + * 验证并获取启动任务的对象信息。 + * + * @param flowEntryPublish 流程发布对象。 + * @param checkStarter 是否检查发起用户。 + * @return 第一个可执行的任务信息。 + */ + public ResponseResult verifyAndGetInitialTaskInfo( + FlowEntryPublish flowEntryPublish, boolean checkStarter) { + String errorMessage; + if (StrUtil.isBlank(flowEntryPublish.getInitTaskInfo())) { + errorMessage = "数据验证失败,当前流程发布的数据中,没有包含初始任务信息!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + TaskInfoVo taskInfo = JSON.parseObject(flowEntryPublish.getInitTaskInfo(), TaskInfoVo.class); + if (checkStarter) { + String loginName = TokenData.takeFromRequest().getLoginName(); + if (!StrUtil.equalsAny(taskInfo.getAssignee(), loginName, FlowConstant.START_USER_NAME_VAR)) { + errorMessage = "数据验证失败,该工作流第一个用户任务的指派人并非当前用户,不能执行该操作!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + return ResponseResult.success(taskInfo); + } + + /** + * 判断当前用户是否有当前流程实例的数据上传或下载权限。 + * 如果taskId为空,则验证当前用户是否为当前流程实例的发起人,否则判断是否为当前任务的指派人或候选人。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 流程任务Id。 + * @return 验证结果。 + */ + public ResponseResult verifyUploadOrDownloadPermission(String processInstanceId, String taskId) { + if (flowApiService.isProcessInstanceStarter(processInstanceId)) { + return ResponseResult.success(); + } + String errorMessage; + if (StrUtil.isBlank(taskId)) { + errorMessage = "数据验证失败,当前用户没有权限下载!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + TaskInfo task = flowApiService.getProcessInstanceActiveTask(processInstanceId, taskId); + if (task == null) { + task = flowApiService.getHistoricTaskInstance(processInstanceId, taskId); + if (task == null) { + errorMessage = "数据验证失败,指定任务Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + } + if (!flowApiService.isAssigneeOrCandidate(task)) { + errorMessage = "数据验证失败,当前用户并非指派人或候选人,因此没有权限下载!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 根据已有的过滤对象,补充添加缺省过滤条件。如流程标识、创建用户等。 + * + * @param filterDto 工单过滤对象。 + * @param processDefinitionKey 流程标识。 + * @return 创建并转换后的流程工单过滤对象。 + */ + public FlowWorkOrder makeWorkOrderFilter(FlowWorkOrderDto filterDto, String processDefinitionKey) { + FlowWorkOrder filter = MyModelUtil.copyTo(filterDto, FlowWorkOrder.class); + if (filter == null) { + filter = new FlowWorkOrder(); + } + filter.setProcessDefinitionKey(processDefinitionKey); + // 下面的方法会帮助构建工单的数据权限过滤条件,和业务希望相比,如果当前系统没有支持数据权限, + // 用户则只能看到自己发起的工单,否则按照数据权限过滤。然而需要特殊处理的是,如果用户的数据 + // 权限中,没有包含能看自己,这里也需要自动给加上。 + BaseFlowIdentityExtHelper flowIdentityExtHelper = flowCustomExtFactory.getFlowIdentityExtHelper(); + if (BooleanUtil.isFalse(flowIdentityExtHelper.supprtDataPerm())) { + filter.setCreateUserId(TokenData.takeFromRequest().getUserId()); + } + return filter; + } + + /** + * 组装工作流工单列表中的流程任务数据。 + * + * @param flowWorkOrderVoList 工作流工单列表。 + */ + public void buildWorkOrderTaskInfo(List flowWorkOrderVoList) { + if (CollUtil.isEmpty(flowWorkOrderVoList)) { + return; + } + Set definitionIdSet = + flowWorkOrderVoList.stream().map(FlowWorkOrderVo::getProcessDefinitionId).collect(Collectors.toSet()); + List flowEntryPublishList = flowEntryService.getFlowEntryPublishList(definitionIdSet); + Map flowEntryPublishMap = + flowEntryPublishList.stream().collect(Collectors.toMap(FlowEntryPublish::getProcessDefinitionId, c -> c)); + for (FlowWorkOrderVo flowWorkOrderVo : flowWorkOrderVoList) { + FlowEntryPublish flowEntryPublish = flowEntryPublishMap.get(flowWorkOrderVo.getProcessDefinitionId()); + flowWorkOrderVo.setInitTaskInfo(flowEntryPublish.getInitTaskInfo()); + } + List unfinishedProcessInstanceIds = flowWorkOrderVoList.stream() + .filter(c -> !c.getFlowStatus().equals(FlowTaskStatus.FINISHED)) + .map(FlowWorkOrderVo::getProcessInstanceId) + .collect(Collectors.toList()); + if (CollUtil.isEmpty(unfinishedProcessInstanceIds)) { + return; + } + List taskList = flowApiService.getTaskListByProcessInstanceIds(unfinishedProcessInstanceIds); + Map> taskMap = + taskList.stream().collect(Collectors.groupingBy(Task::getProcessInstanceId)); + for (FlowWorkOrderVo flowWorkOrderVo : flowWorkOrderVoList) { + List instanceTaskList = taskMap.get(flowWorkOrderVo.getProcessInstanceId()); + if (instanceTaskList == null) { + continue; + } + JSONArray taskArray = new JSONArray(); + for (Task task : instanceTaskList) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("taskId", task.getId()); + jsonObject.put("taskName", task.getName()); + jsonObject.put("taskKey", task.getTaskDefinitionKey()); + jsonObject.put("assignee", task.getAssignee()); + taskArray.add(jsonObject); + } + flowWorkOrderVo.setRuntimeTaskInfoList(taskArray); + } + } + + /** + * 组装工作流工单中的业务数据。 + * + * @param workOrderVoList 工单列表。 + * @param dataList 业务数据列表。 + * @param idGetter 获取业务对象主键字段的返回方法。 + * @param 业务主对象类型。 + * @param 业务主对象的主键字段类型。 + */ + public void buildWorkOrderBusinessData( + List workOrderVoList, List dataList, Function idGetter) { + if (CollUtil.isEmpty(dataList)) { + return; + } + Map dataMap = dataList.stream().collect(Collectors.toMap(idGetter, c -> c)); + K id = idGetter.apply(dataList.get(0)); + for (FlowWorkOrderVo flowWorkOrderVo : workOrderVoList) { + if (StrUtil.isBlank(flowWorkOrderVo.getBusinessKey())) { + continue; + } + Object dataId = flowWorkOrderVo.getBusinessKey(); + if (id instanceof Long) { + dataId = Long.valueOf(flowWorkOrderVo.getBusinessKey()); + } else if (id instanceof Integer) { + dataId = Integer.valueOf(flowWorkOrderVo.getBusinessKey()); + } + T data = dataMap.get(dataId); + if (data != null) { + flowWorkOrderVo.setMasterData(BeanUtil.beanToMap(data)); + } + } + } + + /** + * 验证并根据流程实例Id获取处于草稿状态的流程工单。 + * + * @param processDefinitionKey 流程定义标识。 + * @param processInstanceId 流程实例Id。 + * @return 流程工单。 + */ + public ResponseResult verifyAndGetFlowWorkOrderWithDraft( + String processDefinitionKey, String processInstanceId) { + String errorMessage; + FlowWorkOrder flowWorkOrder = flowWorkOrderService.getFlowWorkOrderByProcessInstanceId(processInstanceId); + if (flowWorkOrder == null) { + errorMessage = "数据验证失败,流程实例关联的工单不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!flowWorkOrder.getFlowStatus().equals(FlowTaskStatus.DRAFT)) { + errorMessage = "数据验证失败,当前流程工单并不处于草稿保存状态!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!flowWorkOrder.getCreateUserId().equals(TokenData.takeFromRequest().getUserId())) { + errorMessage = "数据验证失败,草稿数据保存用户与当前用户不一致!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (processDefinitionKey != null && !flowWorkOrder.getProcessDefinitionKey().equals(processDefinitionKey)) { + errorMessage = "数据验证失败,流程实例和流程定义标识不匹配!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(flowWorkOrder); + } + + /** + * 根据流程定义的扩展数据中的审批状态字典列表数据,组装工单列表中,每个工单对象的审批状态字典数据。 + * @param processDefinitionKey 流程定义标识。 + * @param workOrderVoList 待组装的工单列表。 + */ + public void buildWorkOrderApprovalStatus(String processDefinitionKey, List workOrderVoList) { + FlowEntry flowEntry = flowEntryService.getFlowEntryFromCache(processDefinitionKey); + if (StrUtil.isBlank(flowEntry.getExtensionData())) { + return; + } + FlowEntryExtensionData extensionData = + JSON.parseObject(flowEntry.getExtensionData(), FlowEntryExtensionData.class); + if (CollUtil.isEmpty(extensionData.getApprovalStatusDict())) { + return; + } + Map dictMap = new HashMap<>(extensionData.getApprovalStatusDict().size()); + for (Map m : extensionData.getApprovalStatusDict()) { + dictMap.put(Integer.valueOf(m.get("id")), m.get("name")); + } + for (FlowWorkOrderVo workOrderVo : workOrderVoList) { + if (workOrderVo.getLatestApprovalStatus() != null) { + String name = dictMap.get(workOrderVo.getLatestApprovalStatus()); + if (name != null) { + Map lastestApprovalStatusDictMap = MapUtil.newHashMap(); + lastestApprovalStatusDictMap.put("id", workOrderVo.getLatestApprovalStatus()); + lastestApprovalStatusDictMap.put("name", name); + workOrderVo.setLatestApprovalStatusDictMap(lastestApprovalStatusDictMap); + } + } + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/FlowRedisKeyUtil.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/FlowRedisKeyUtil.java new file mode 100644 index 00000000..b95cd08e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/util/FlowRedisKeyUtil.java @@ -0,0 +1,52 @@ +package com.orangeforms.common.flow.util; + +import cn.hutool.core.util.StrUtil; +import com.orangeforms.common.core.object.TokenData; + +/** + * 工作流 Redis 键生成工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class FlowRedisKeyUtil { + + /** + * 计算流程对象缓存在Redis中的键值。 + * + * @param processDefinitionKey 流程标识。 + * @return 流程对象缓存在Redis中的键值。 + */ + public static String makeFlowEntryKey(String processDefinitionKey) { + String prefix = "FLOW_ENTRY:"; + TokenData tokenData = TokenData.takeFromRequest(); + if (tokenData == null) { + return prefix + processDefinitionKey; + } + String appCode = tokenData.getAppCode(); + if (StrUtil.isBlank(appCode)) { + Long tenantId = tokenData.getTenantId(); + if (tenantId == null) { + return prefix + processDefinitionKey; + } + return prefix + tenantId.toString() + ":" + processDefinitionKey; + } + return prefix + appCode + ":" + processDefinitionKey; + } + + /** + * 流程发布对象缓存在Redis中的键值。 + * + * @param flowEntryPublishId 流程发布主键Id。 + * @return 流程发布对象缓存在Redis中的键值。 + */ + public static String makeFlowEntryPublishKey(Long flowEntryPublishId) { + return "FLOW_ENTRY_PUBLISH:" + flowEntryPublishId; + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowRedisKeyUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowCategoryVo.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowCategoryVo.java new file mode 100644 index 00000000..56894a81 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowCategoryVo.java @@ -0,0 +1,71 @@ +package com.orangeforms.common.flow.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 流程分类的Vo对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "流程分类的Vo对象") +@Data +public class FlowCategoryVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long categoryId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Schema(description = "应用编码") + private String appCode; + + /** + * 显示名称。 + */ + @Schema(description = "显示名称") + private String name; + + /** + * 分类编码。 + */ + @Schema(description = "分类编码") + private String code; + + /** + * 实现顺序。 + */ + @Schema(description = "实现顺序") + private Integer showOrder; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者Id。 + */ + @Schema(description = "更新者Id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者Id。 + */ + @Schema(description = "创建者Id") + private Long createUserId; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowEntryPublishVo.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowEntryPublishVo.java new file mode 100644 index 00000000..53c802fa --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowEntryPublishVo.java @@ -0,0 +1,59 @@ +package com.orangeforms.common.flow.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 流程发布信息的Vo对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "流程发布信息的Vo对象") +@Data +public class FlowEntryPublishVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long entryPublishId; + + /** + * 发布版本。 + */ + @Schema(description = "发布版本") + private Integer publishVersion; + + /** + * 流程引擎中的流程定义Id。 + */ + @Schema(description = "流程引擎中的流程定义Id") + private String processDefinitionId; + + /** + * 激活状态。 + */ + @Schema(description = "激活状态") + private Boolean activeStatus; + + /** + * 是否为主版本。 + */ + @Schema(description = "是否为主版本") + private Boolean mainVersion; + + /** + * 创建者Id。 + */ + @Schema(description = "创建者Id") + private Long createUserId; + + /** + * 发布时间。 + */ + @Schema(description = "发布时间") + private Date publishTime; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowEntryVariableVo.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowEntryVariableVo.java new file mode 100644 index 00000000..68ef4d33 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowEntryVariableVo.java @@ -0,0 +1,77 @@ +package com.orangeforms.common.flow.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 流程变量Vo对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "流程变量Vo对象") +@Data +public class FlowEntryVariableVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long variableId; + + /** + * 流程Id。 + */ + @Schema(description = "流程Id") + private Long entryId; + + /** + * 变量名。 + */ + @Schema(description = "变量名") + private String variableName; + + /** + * 显示名。 + */ + @Schema(description = "显示名") + private String showName; + + /** + * 变量类型。 + */ + @Schema(description = "变量类型") + private Integer variableType; + + /** + * 绑定数据源Id。 + */ + @Schema(description = "绑定数据源Id") + private Long bindDatasourceId; + + /** + * 绑定数据源关联Id。 + */ + @Schema(description = "绑定数据源关联Id") + private Long bindRelationId; + + /** + * 绑定字段Id。 + */ + @Schema(description = "绑定字段Id") + private Long bindColumnId; + + /** + * 是否内置。 + */ + @Schema(description = "是否内置") + private Boolean builtin; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowEntryVo.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowEntryVo.java new file mode 100644 index 00000000..b9cdc945 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowEntryVo.java @@ -0,0 +1,157 @@ +package com.orangeforms.common.flow.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 流程的Vo对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "流程的Vo对象") +@Data +public class FlowEntryVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long entryId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Schema(description = "应用编码") + private String appCode; + + /** + * 流程名称。 + */ + @Schema(description = "流程名称") + private String processDefinitionName; + + /** + * 流程标识Key。 + */ + @Schema(description = "流程标识Key") + private String processDefinitionKey; + + /** + * 流程分类。 + */ + @Schema(description = "流程分类") + private Long categoryId; + + /** + * 工作流部署的发布主版本Id。 + */ + @Schema(description = "工作流部署的发布主版本Id") + private Long mainEntryPublishId; + + /** + * 最新发布时间。 + */ + @Schema(description = "最新发布时间") + private Date latestPublishTime; + + /** + * 流程状态。 + */ + @Schema(description = "流程状态") + private Integer status; + + /** + * 流程定义的xml。 + */ + @Schema(description = "流程定义的xml") + private String bpmnXml; + + /** + * 流程图类型。0: 普通流程图,1: 钉钉风格的流程图。 + */ + @Schema(description = "流程图类型。0: 普通流程图,1: 钉钉风格的流程图") + private Integer diagramType; + + /** + * 绑定表单类型。 + */ + @Schema(description = "绑定表单类型") + private Integer bindFormType; + + /** + * 在线表单的页面Id。 + */ + @Schema(description = "在线表单的页面Id") + private Long pageId; + + /** + * 在线表单Id。 + */ + @Schema(description = "在线表单Id") + private Long defaultFormId; + + /** + * 在线表单的缺省路由名称。 + */ + @Schema(description = "在线表单的缺省路由名称") + private String defaultRouterName; + + /** + * 工单表编码字段的编码规则,如果为空则不计算工单编码。 + */ + @Schema(description = "工单表编码字段的编码规则") + private String encodedRule; + + /** + * 流程的自定义扩展数据(JSON格式)。 + */ + @Schema(description = "流程的自定义扩展数据") + private String extensionData; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者Id。 + */ + @Schema(description = "更新者Id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者Id。 + */ + @Schema(description = "创建者Id") + private Long createUserId; + + /** + * categoryId 的一对一关联数据对象,数据对应类型为FlowCategoryVo。 + */ + @Schema(description = "categoryId 的一对一关联数据对象") + private Map flowCategory; + + /** + * mainEntryPublishId 的一对一关联数据对象,数据对应类型为FlowEntryPublishVo。 + */ + @Schema(description = "mainEntryPublishId 的一对一关联数据对象") + private Map mainFlowEntryPublish; + + /** + * 关联的在线表单列表。 + */ + @Schema(description = "关联的在线表单列表") + private List> formList; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowMessageVo.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowMessageVo.java new file mode 100644 index 00000000..8d7d104b --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowMessageVo.java @@ -0,0 +1,137 @@ +package com.orangeforms.common.flow.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 工作流通知消息Vo对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "工作流通知消息Vo对象") +@Data +public class FlowMessageVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long messageId; + + /** + * 消息类型。 + */ + @Schema(description = "消息类型") + private Integer messageType; + + /** + * 消息内容。 + */ + @Schema(description = "消息内容") + private String messageContent; + + /** + * 催办次数。 + */ + @Schema(description = "催办次数") + private Integer remindCount; + + /** + * 工单Id。 + */ + @Schema(description = "工单Id") + private Long workOrderId; + + /** + * 流程定义Id。 + */ + @Schema(description = "流程定义Id") + private String processDefinitionId; + + /** + * 流程定义标识。 + */ + @Schema(description = "流程定义标识") + private String processDefinitionKey; + + /** + * 流程名称。 + */ + @Schema(description = "流程名称") + private String processDefinitionName; + + /** + * 流程实例Id。 + */ + @Schema(description = "流程实例Id") + private String processInstanceId; + + /** + * 流程实例发起者。 + */ + @Schema(description = "流程实例发起者") + private String processInstanceInitiator; + + /** + * 流程任务Id。 + */ + @Schema(description = "流程任务Id") + private String taskId; + + /** + * 流程任务定义标识。 + */ + @Schema(description = "流程任务定义标识") + private String taskDefinitionKey; + + /** + * 流程任务名称。 + */ + @Schema(description = "流程任务名称") + private String taskName; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date taskStartTime; + + /** + * 业务数据快照。 + */ + @Schema(description = "业务数据快照") + private String businessDataShot; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者Id。 + */ + @Schema(description = "更新者Id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者Id。 + */ + @Schema(description = "创建者Id") + private Long createUserId; + + /** + * 创建者显示名。 + */ + @Schema(description = "创建者显示名") + private String createUsername; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowTaskCommentVo.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowTaskCommentVo.java new file mode 100644 index 00000000..c8328b34 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowTaskCommentVo.java @@ -0,0 +1,113 @@ +package com.orangeforms.common.flow.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * FlowTaskCommentVO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "FlowTaskCommentVO对象") +@Data +public class FlowTaskCommentVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long id; + + /** + * 流程实例Id。 + */ + @Schema(description = "流程实例Id") + private String processInstanceId; + + /** + * 任务Id。 + */ + @Schema(description = "任务Id") + private String taskId; + + /** + * 任务标识。 + */ + @Schema(description = "任务标识") + private String taskKey; + + /** + * 任务名称。 + */ + @Schema(description = "任务名称") + private String taskName; + + /** + * 任务的执行Id。 + */ + @Schema(description = "任务的执行Id") + private String executionId; + + /** + * 会签任务的执行Id。 + */ + @Schema(description = "会签任务的执行Id") + private String multiInstanceExecId; + + /** + * 审批类型。 + */ + @Schema(description = "审批类型") + private String approvalType; + + /** + * 批注内容。 + */ + @Schema(description = "批注内容") + private String taskComment; + + /** + * 委托指定人,比如加签、转办等。 + */ + @Schema(description = "委托指定人,比如加签、转办等") + private String delegateAssignee; + + /** + * 自定义数据。开发者可自行扩展,推荐使用JSON格式数据。 + */ + @Schema(description = "自定义数据") + private String customBusinessData; + + /** + * 审批人头像。 + */ + @Schema(description = "审批人头像") + private String headImageUrl; + + /** + * 创建者Id。 + */ + @Schema(description = "创建者Id") + private Long createUserId; + + /** + * 创建者登录名。 + */ + @Schema(description = "创建者登录名") + private String createLoginName; + + /** + * 创建者显示名。 + */ + @Schema(description = "创建者显示名") + private String createUsername; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowTaskVo.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowTaskVo.java new file mode 100644 index 00000000..35e4c367 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowTaskVo.java @@ -0,0 +1,125 @@ +package com.orangeforms.common.flow.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 流程任务Vo对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "流程任务Vo对象") +@Data +public class FlowTaskVo { + + /** + * 流程任务Id。 + */ + @Schema(description = "流程任务Id") + private String taskId; + + /** + * 流程任务名称。 + */ + @Schema(description = "流程任务名称") + private String taskName; + + /** + * 流程任务标识。 + */ + @Schema(description = "流程任务标识") + private String taskKey; + + /** + * 任务的表单信息。 + */ + @Schema(description = "任务的表单信息") + private String taskFormKey; + + /** + * 待办任务开始时间。 + */ + @Schema(description = "待办任务开始时间") + private Date taskStartTime; + + /** + * 流程Id。 + */ + @Schema(description = "流程Id") + private Long entryId; + + /** + * 流程定义Id。 + */ + @Schema(description = "流程定义Id") + private String processDefinitionId; + + /** + * 流程定义名称。 + */ + @Schema(description = "流程定义名称") + private String processDefinitionName; + + /** + * 流程定义标识。 + */ + @Schema(description = "流程定义标识") + private String processDefinitionKey; + + /** + * 流程定义版本。 + */ + @Schema(description = "流程定义版本") + private Integer processDefinitionVersion; + + /** + * 流程实例Id。 + */ + @Schema(description = "流程实例Id") + private String processInstanceId; + + /** + * 流程实例发起人。 + */ + @Schema(description = "流程实例发起人") + private String processInstanceInitiator; + + /** + * 流程实例发起人显示名。 + */ + @Schema(description = "流程实例发起人显示名") + private String showName; + + /** + * 用户头像信息。 + */ + @Schema(description = "用户头像信息") + private String headImageUrl; + + /** + * 流程实例创建时间。 + */ + @Schema(description = "流程实例创建时间") + private Date processInstanceStartTime; + + /** + * 流程实例主表业务数据主键。 + */ + @Schema(description = "流程实例主表业务数据主键") + private String businessKey; + + /** + * 工单编码。 + */ + @Schema(description = "工单编码") + private String workOrderCode; + + /** + * 是否为草稿状态。 + */ + @Schema(description = "是否为草稿状态") + private Boolean isDraft; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowUserInfoVo.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowUserInfoVo.java new file mode 100644 index 00000000..2ceca1fa --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowUserInfoVo.java @@ -0,0 +1,77 @@ +package com.orangeforms.common.flow.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 流程任务的用户信息。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "流程任务的用户信息") +@Data +public class FlowUserInfoVo { + + /** + * 用户Id。 + */ + @Schema(description = "用户Id") + private Long userId; + + /** + * 用户部门Id。 + */ + @Schema(description = "用户部门Id") + private Long deptId; + + /** + * 登录用户名。 + */ + @Schema(description = "登录用户名") + private String loginName; + + /** + * 用户显示名称。 + */ + @Schema(description = "用户显示名称") + private String showName; + + /** + * 用户头像的Url。 + */ + @Schema(description = "用户头像的Url") + private String headImageUrl; + + /** + * 用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)。 + */ + @Schema(description = "用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)") + private Integer userType; + + /** + * 用户状态(0: 正常 1: 锁定)。 + */ + @Schema(description = "用户状态(0: 正常 1: 锁定)") + private Integer userStatus; + + /** + * 用户邮箱。 + */ + @Schema(description = "用户邮箱") + private String email; + + /** + * 用户手机。 + */ + @Schema(description = "用户手机") + private String mobile; + + /** + * 最后审批时间。 + */ + @Schema(description = "最后审批时间") + private Date lastApprovalTime; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowWorkOrderVo.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowWorkOrderVo.java new file mode 100644 index 00000000..3122ed8f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowWorkOrderVo.java @@ -0,0 +1,158 @@ +package com.orangeforms.common.flow.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import com.alibaba.fastjson.JSONArray; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 工作流工单VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "工作流工单Vo对象") +@Data +public class FlowWorkOrderVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long workOrderId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Schema(description = "应用编码") + private String appCode; + + /** + * 工单编码字段。 + */ + @Schema(description = "工单编码字段") + private String workOrderCode; + + /** + * 流程定义标识。 + */ + @Schema(description = "流程定义标识") + private String processDefinitionKey; + + /** + * 流程名称。 + */ + @Schema(description = "流程名称") + private String processDefinitionName; + + /** + * 流程引擎的定义Id。 + */ + @Schema(description = "流程引擎的定义Id") + private String processDefinitionId; + + /** + * 流程实例Id。 + */ + @Schema(description = "流程实例Id") + private String processInstanceId; + + /** + * 在线表单的主表Id。 + */ + @Schema(description = "在线表单的主表Id") + private Long onlineTableId; + + /** + * 业务主键值。 + */ + @Schema(description = "业务主键值") + private String businessKey; + + /** + * 最近的审批状态。 + */ + @Schema(description = "最近的审批状态") + private Integer latestApprovalStatus; + + /** + * 流程状态。参考FlowTaskStatus常量值对象。 + */ + @Schema(description = "流程状态") + private Integer flowStatus; + + /** + * 提交用户登录名称。 + */ + @Schema(description = "提交用户登录名称") + private String submitUsername; + + /** + * 提交用户所在部门Id。 + */ + @Schema(description = "提交用户所在部门Id") + private Long deptId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者Id。 + */ + @Schema(description = "更新者Id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者Id。 + */ + @Schema(description = "创建者Id") + private Long createUserId; + + /** + * latestApprovalStatus 关联的字典数据。 + */ + @Schema(description = "latestApprovalStatus 常量字典关联数据") + private Map latestApprovalStatusDictMap; + + /** + * flowStatus 常量字典关联数据。 + */ + @Schema(description = "flowStatus 常量字典关联数据") + private Map flowStatusDictMap; + + /** + * 用户的显示名。 + */ + @Schema(description = "用户的显示名") + private String userShowName; + + /** + * FlowEntryPublish对象中的同名字段。 + */ + @Schema(description = "FlowEntryPublish对象中的同名字段") + private String initTaskInfo; + + /** + * 当前实例的运行时任务列表。 + * 正常情况下只有一个,在并行网关下可能存在多个。 + */ + @Schema(description = "实例的运行时任务列表") + private JSONArray runtimeTaskInfoList; + + /** + * 业务主表数据。 + */ + @Schema(description = "业务主表数据") + private Map masterData; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/TaskInfoVo.java b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/TaskInfoVo.java new file mode 100644 index 00000000..2d4f981a --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/TaskInfoVo.java @@ -0,0 +1,85 @@ +package com.orangeforms.common.flow.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import com.alibaba.fastjson.JSONObject; +import lombok.Data; + +import java.util.List; + +/** + * 流程任务信息Vo对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "流程任务信息Vo对象") +@Data +public class TaskInfoVo { + + /** + * 流程节点任务类型。具体值可参考FlowTaskType常量值。 + */ + @Schema(description = "流程节点任务类型") + private Integer taskType; + + /** + * 指定人。 + */ + @Schema(description = "指定人") + private String assignee; + + /** + * 任务标识。 + */ + @Schema(description = "任务标识") + private String taskKey; + + /** + * 是否分配给当前登录用户的标记。 + * 当该值为true时,登录用户启动流程时,就自动完成了第一个用户任务。 + */ + @Schema(description = "是否分配给当前登录用户的标记") + private Boolean assignedMe; + + /** + * 动态表单Id。 + */ + @Schema(description = "动态表单Id") + private Long formId; + + /** + * PC端静态表单路由。 + */ + @Schema(description = "PC端静态表单路由") + private String routerName; + + /** + * 移动端静态表单路由。 + */ + @Schema(description = "移动端静态表单路由") + private String mobileRouterName; + + /** + * 候选组类型。 + */ + @Schema(description = "候选组类型") + private String groupType; + + /** + * 只读标记。 + */ + @Schema(description = "只读标记") + private Boolean readOnly; + + /** + * 前端所需的操作列表。 + */ + @Schema(description = "前端所需的操作列表") + List operationList; + + /** + * 任务节点的自定义变量列表。 + */ + @Schema(description = "任务节点的自定义变量列表") + List variableList; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/resources/META-INF/services/org.flowable.common.engine.impl.EngineConfigurator b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/resources/META-INF/services/org.flowable.common.engine.impl.EngineConfigurator new file mode 100644 index 00000000..eda90b8a --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/resources/META-INF/services/org.flowable.common.engine.impl.EngineConfigurator @@ -0,0 +1 @@ +com.orangeforms.common.flow.config.CustomEngineConfigurator \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..8c6f8611 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-flow/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.orangeforms.common.flow.config.FlowAutoConfig \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-log/pom.xml b/OrangeFormsOpen-MybatisFlex/common/common-log/pom.xml new file mode 100644 index 00000000..4f39b309 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-log/pom.xml @@ -0,0 +1,29 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-log + 1.0.0 + common-log + jar + + + + com.orangeforms + common-sequence + 1.0.0 + + + com.orangeforms + common-swagger + 1.0.0 + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/annotation/IgnoreResponseLog.java b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/annotation/IgnoreResponseLog.java new file mode 100644 index 00000000..00bbe1f6 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/annotation/IgnoreResponseLog.java @@ -0,0 +1,16 @@ +package com.orangeforms.common.log.annotation; + +import java.lang.annotation.*; + +/** + * 忽略接口应答数据记录日志的注解。该注解会被OperationLogAspect处理。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface IgnoreResponseLog { + +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/annotation/OperationLog.java b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/annotation/OperationLog.java new file mode 100644 index 00000000..32f6b591 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/annotation/OperationLog.java @@ -0,0 +1,33 @@ +package com.orangeforms.common.log.annotation; + +import com.orangeforms.common.log.model.constant.SysOperationLogType; + +import java.lang.annotation.*; + +/** + * 操作日志记录注解。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface OperationLog { + + /** + * 描述。 + */ + String description() default ""; + + /** + * 操作类型。 + */ + int type() default SysOperationLogType.OTHER; + + /** + * 是否保存应答结果。 + * 对于类似导出和文件下载之类的接口,该参与应该设置为false。 + */ + boolean saveResponse() default true; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/aop/OperationLogAspect.java b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/aop/OperationLogAspect.java new file mode 100644 index 00000000..b71c5df0 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/aop/OperationLogAspect.java @@ -0,0 +1,265 @@ +package com.orangeforms.common.log.aop; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.BooleanUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.ResponseResult; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.ContextUtil; +import com.orangeforms.common.core.util.IpUtil; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.log.annotation.IgnoreResponseLog; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.config.OperationLogProperties; +import com.orangeforms.common.log.model.SysOperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.log.service.SysOperationLogService; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.Signature; +import org.aspectj.lang.annotation.*; +import org.aspectj.lang.reflect.MethodSignature; +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.util.*; + +/** + * 操作日志记录处理AOP对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Aspect +@Component +@Order(1) +@Slf4j +public class OperationLogAspect { + + @Value("${spring.application.name}") + private String serviceName; + @Autowired + private SysOperationLogService operationLogService; + @Autowired + private OperationLogProperties properties; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 错误信息、请求参数和应答结果字符串的最大长度。 + */ + private static final int MAX_LENGTH = 2000; + + /** + * 所有controller方法。 + */ + @Pointcut("execution(public * com.orangeforms..controller..*(..))") + public void operationLogPointCut() { + // 空注释,避免sonar警告 + } + + @Around("operationLogPointCut()") + public Object around(ProceedingJoinPoint joinPoint) throws Throwable { + // 计时。 + long start = System.currentTimeMillis(); + HttpServletRequest request = ContextUtil.getHttpRequest(); + HttpServletResponse response = ContextUtil.getHttpResponse(); + String traceId = this.getTraceId(request); + request.setAttribute(ApplicationConstant.HTTP_HEADER_TRACE_ID, traceId); + // 将流水号通过应答头返回给前端,便于问题精确定位。 + response.setHeader(ApplicationConstant.HTTP_HEADER_TRACE_ID, traceId); + MDC.put(ApplicationConstant.HTTP_HEADER_TRACE_ID, traceId); + TokenData tokenData = TokenData.takeFromRequest(); + // 为日志框架设定变量,使日志可以输出更多有价值的信息。 + if (tokenData != null) { + MDC.put("sessionId", tokenData.getSessionId()); + MDC.put("userId", tokenData.getUserId().toString()); + } + String[] parameterNames = this.getParameterNames(joinPoint); + Object[] args = joinPoint.getArgs(); + JSONObject jsonArgs = new JSONObject(); + for (int i = 0; i < args.length; i++) { + Object arg = args[i]; + if (this.isNormalArgs(arg)) { + String parameterName = parameterNames[i]; + jsonArgs.put(parameterName, arg); + } + } + String params = jsonArgs.toJSONString(); + SysOperationLog operationLog = null; + OperationLog operationLogAnnotation = null; + boolean saveOperationLog = properties.isEnabled(); + if (saveOperationLog) { + operationLogAnnotation = getMethodAnnotation(joinPoint, OperationLog.class); + saveOperationLog = (operationLogAnnotation != null); + } + if (saveOperationLog) { + operationLog = this.buildSysOperationLog(operationLogAnnotation, joinPoint, params, traceId, tokenData); + } + Object result; + log.info("开始请求,url={}, reqData={}", request.getRequestURI(), params); + try { + // 调用原来的方法 + result = joinPoint.proceed(); + String respData = result == null ? "null" : JSON.toJSONString(result); + Long elapse = System.currentTimeMillis() - start; + if (saveOperationLog) { + this.operationLogPostProcess(operationLogAnnotation, respData, operationLog, result); + } + if (elapse > properties.getSlowLogMs()) { + log.warn("耗时较长的请求完成警告, url={},elapse={}ms reqData={} respData={}", + request.getRequestURI(), elapse, params, respData); + } + if (this.getMethodAnnotation(joinPoint, IgnoreResponseLog.class) == null) { + log.info("请求完成, url={},elapse={}ms, respData={}", request.getRequestURI(), elapse, respData); + } + } catch (Exception e) { + if (saveOperationLog) { + operationLog.setSuccess(false); + operationLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, MAX_LENGTH)); + } + log.error("请求报错,url={}, reqData={}, error={}", request.getRequestURI(), params, e.getMessage()); + throw e; + } finally { + if (saveOperationLog) { + operationLog.setElapse(System.currentTimeMillis() - start); + operationLogService.saveNewAsync(operationLog); + } + MDC.remove(ApplicationConstant.HTTP_HEADER_TRACE_ID); + if (tokenData != null) { + MDC.remove("sessionId"); + MDC.remove("userId"); + } + } + return result; + } + + private SysOperationLog buildSysOperationLog( + OperationLog operationLogAnnotation, + ProceedingJoinPoint joinPoint, + String params, + String traceId, + TokenData tokenData) { + HttpServletRequest request = ContextUtil.getHttpRequest(); + SysOperationLog operationLog = new SysOperationLog(); + operationLog.setLogId(idGenerator.nextLongId()); + operationLog.setTraceId(traceId); + operationLog.setDescription(operationLogAnnotation.description()); + operationLog.setOperationType(operationLogAnnotation.type()); + operationLog.setServiceName(this.serviceName); + operationLog.setApiClass(joinPoint.getTarget().getClass().getName()); + operationLog.setApiMethod(operationLog.getApiClass() + "." + joinPoint.getSignature().getName()); + operationLog.setRequestMethod(request.getMethod()); + operationLog.setRequestUrl(request.getRequestURI()); + if (tokenData != null) { + operationLog.setRequestIp(tokenData.getLoginIp()); + } else { + operationLog.setRequestIp(IpUtil.getRemoteIpAddress(request)); + } + operationLog.setOperationTime(new Date()); + if (params != null) { + if (params.length() <= MAX_LENGTH) { + operationLog.setRequestArguments(params); + } else { + operationLog.setRequestArguments(StringUtils.substring(params, 0, MAX_LENGTH)); + } + } + if (tokenData != null) { + // 对于非多租户系统,该值为空可以忽略。 + operationLog.setTenantId(tokenData.getTenantId()); + operationLog.setSessionId(tokenData.getSessionId()); + operationLog.setOperatorId(tokenData.getUserId()); + operationLog.setOperatorName(tokenData.getLoginName()); + } + return operationLog; + } + + private void operationLogPostProcess( + OperationLog operationLogAnnotation, String respData, SysOperationLog operationLog, Object result) { + if (operationLogAnnotation.saveResponse()) { + if (respData.length() <= MAX_LENGTH) { + operationLog.setResponseResult(respData); + } else { + operationLog.setResponseResult(StringUtils.substring(respData, 0, MAX_LENGTH)); + } + } + // 处理大部分返回ResponseResult的接口。 + if (!(result instanceof ResponseResult)) { + if (ContextUtil.hasRequestContext()) { + operationLog.setSuccess(ContextUtil.getHttpResponse().getStatus() == HttpServletResponse.SC_OK); + } + return; + } + ResponseResult responseResult = (ResponseResult) result; + operationLog.setSuccess(responseResult.isSuccess()); + if (!responseResult.isSuccess()) { + operationLog.setErrorMsg(responseResult.getErrorMessage()); + } + if (operationLog.getOperationType().equals(SysOperationLogType.LOGIN)) { + // 对于登录操作,由于在调用登录方法之前,没有可用的TokenData。 + // 因此如果登录成功,可再次通过TokenData.takeFromRequest()获取TokenData。 + if (BooleanUtil.isTrue(operationLog.getSuccess())) { + // 这里为了保证LoginController.doLogin方法,一定将TokenData存入Request.Attribute之中, + // 我们将不做空值判断,一旦出错,开发者可在调试时立刻发现异常,并根据这里的注释进行修复。 + TokenData tokenData = TokenData.takeFromRequest(); + // 对于非多租户系统,为了保证代码一致性,仍可保留对tenantId的赋值代码。 + operationLog.setTenantId(tokenData.getTenantId()); + operationLog.setSessionId(tokenData.getSessionId()); + operationLog.setOperatorId(tokenData.getUserId()); + operationLog.setOperatorName(tokenData.getLoginName()); + } else { + HttpServletRequest request = ContextUtil.getHttpRequest(); + // 登录操作需要特殊处理,无论是登录成功还是失败,都要记录operator_name字段。 + operationLog.setOperatorName(request.getParameter("loginName")); + } + } + } + + private String[] getParameterNames(ProceedingJoinPoint joinPoint) { + Signature signature = joinPoint.getSignature(); + MethodSignature methodSignature = (MethodSignature) signature; + return methodSignature.getParameterNames(); + } + + private T getMethodAnnotation(JoinPoint joinPoint, Class annotationClazz) { + Signature signature = joinPoint.getSignature(); + MethodSignature methodSignature = (MethodSignature) signature; + Method method = methodSignature.getMethod(); + return method.getAnnotation(annotationClazz); + } + + private String getTraceId(HttpServletRequest request) { + // 获取请求流水号。 + // 对于微服务系统,为了保证traceId在全调用链的唯一性,因此在网关的过滤器中创建了该值。 + String traceId = request.getHeader(ApplicationConstant.HTTP_HEADER_TRACE_ID); + if (StringUtils.isBlank(traceId)) { + traceId = MyCommonUtil.generateUuid(); + } + return traceId; + } + + private boolean isNormalArgs(Object o) { + if (o instanceof List) { + List list = (List) o; + if (CollUtil.isNotEmpty(list)) { + return !(list.get(0) instanceof MultipartFile); + } + } + return !(o instanceof HttpServletRequest) + && !(o instanceof HttpServletResponse) + && !(o instanceof MultipartFile); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/config/CommonLogAutoConfig.java b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/config/CommonLogAutoConfig.java new file mode 100644 index 00000000..54444158 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/config/CommonLogAutoConfig.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.log.config; + +import org.springframework.boot.context.properties.EnableConfigurationProperties; + +/** + * common-log模块的自动配置引导类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EnableConfigurationProperties({OperationLogProperties.class}) +public class CommonLogAutoConfig { +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/config/OperationLogProperties.java b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/config/OperationLogProperties.java new file mode 100644 index 00000000..cd8c95d6 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/config/OperationLogProperties.java @@ -0,0 +1,24 @@ +package com.orangeforms.common.log.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * 操作日志的配置类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ConfigurationProperties(prefix = "common-log.operation-log") +public class OperationLogProperties { + + /** + * 是否采集操作日志。 + */ + private boolean enabled = true; + /** + * 接口调用的毫秒数大于该值后,将输出慢日志警告。 + */ + private long slowLogMs = 50000; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/dao/SysOperationLogMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/dao/SysOperationLogMapper.java new file mode 100644 index 00000000..63e5ec4c --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/dao/SysOperationLogMapper.java @@ -0,0 +1,34 @@ +package com.orangeforms.common.log.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.log.model.SysOperationLog; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 系统操作日志对应的数据访问对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysOperationLogMapper extends BaseDaoMapper { + + /** + * 批量插入。 + * + * @param operationLogList 操作日志列表。 + */ + void insertList(List operationLogList); + + /** + * 根据过滤条件和排序规则,查询操作日志。 + * + * @param sysOperationLogFilter 操作日志的过滤对象。 + * @param orderBy 排序规则。 + * @return 查询列表。 + */ + List getSysOperationLogList( + @Param("sysOperationLogFilter") SysOperationLog sysOperationLogFilter, + @Param("orderBy") String orderBy); +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/dao/mapper/SysOperationLogMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/dao/mapper/SysOperationLogMapper.xml new file mode 100644 index 00000000..f29559f1 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/dao/mapper/SysOperationLogMapper.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_sys_operation_log.operation_type = #{sysOperationLogFilter.operationType} + + + + AND zz_sys_operation_log.request_url LIKE #{safeRequestUrl} + + + AND zz_sys_operation_log.trace_id = #{sysOperationLogFilter.traceId} + + + AND zz_sys_operation_log.success = #{sysOperationLogFilter.success} + + + + AND zz_sys_operation_log.operator_name LIKE #{safeOperatorName} + + + AND zz_sys_operation_log.elapse >= #{sysOperationLogFilter.elapseMin} + + + AND zz_sys_operation_log.elapse <= #{sysOperationLogFilter.elapseMax} + + + AND zz_sys_operation_log.operation_time >= #{sysOperationLogFilter.operationTimeStart} + + + AND zz_sys_operation_log.operation_time <= #{sysOperationLogFilter.operationTimeEnd} + + + + + + INSERT INTO zz_sys_operation_log VALUES + + (#{item.logId}, + #{item.description}, + #{item.operationType}, + #{item.serviceName}, + #{item.apiClass}, + #{item.apiMethod}, + #{item.sessionId}, + #{item.traceId}, + #{item.elapse}, + #{item.requestMethod}, + #{item.requestUrl}, + #{item.requestArguments}, + #{item.responseResult}, + #{item.requestIp}, + #{item.success}, + #{item.errorMsg}, + #{item.tenantId}, + #{item.operatorId}, + #{item.operatorName}, + #{item.operationTime}) + + + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/dto/SysOperationLogDto.java b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/dto/SysOperationLogDto.java new file mode 100644 index 00000000..994f51f0 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/dto/SysOperationLogDto.java @@ -0,0 +1,77 @@ +package com.orangeforms.common.log.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 操作日志记录表 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "操作日志Dto") +@Data +public class SysOperationLogDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long logId; + + /** + * 操作类型。 + * 常量值定义可参考SysOperationLogType对象。 + */ + @Schema(description = "操作类型") + private Integer operationType; + + /** + * 每次请求的Id。 + * 对于微服务之间的调用,在同一个请求的调用链中,该值是相同的。 + */ + @Schema(description = "每次请求的Id") + private String traceId; + + /** + * HTTP 请求地址。 + */ + @Schema(description = "HTTP 请求地址") + private String requestUrl; + + /** + * 应答状态。 + */ + @Schema(description = "应答状态") + private Boolean success; + + /** + * 操作员名称。 + */ + @Schema(description = "操作员名称") + private String operatorName; + + /** + * 调用时长最小值。 + */ + @Schema(description = "调用时长最小值") + private Long elapseMin; + + /** + * 调用时长最大值。 + */ + @Schema(description = "调用时长最大值") + private Long elapseMax; + + /** + * 操作开始时间。 + */ + @Schema(description = "操作开始时间") + private String operationTimeStart; + + /** + * 操作开始时间。 + */ + @Schema(description = "操作开始时间") + private String operationTimeEnd; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/model/SysOperationLog.java b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/model/SysOperationLog.java new file mode 100644 index 00000000..82e9951d --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/model/SysOperationLog.java @@ -0,0 +1,170 @@ +package com.orangeforms.common.log.model; + +import com.mybatisflex.annotation.*; +import com.orangeforms.common.core.annotation.TenantFilterColumn; +import lombok.Data; + +import java.util.Date; + +/** + * 操作日志记录表 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table("zz_sys_operation_log") +public class SysOperationLog { + + /** + * 主键Id。 + */ + @Id(value = "log_id") + private Long logId; + + /** + * 日志描述。 + */ + @Column(value = "description") + private String description; + + /** + * 操作类型。 + * 常量值定义可参考SysOperationLogType对象。 + */ + @Column(value = "operation_type") + private Integer operationType; + + /** + * 接口所在服务名称。 + * 通常为spring.application.name配置项的值。 + */ + @Column(value = "service_name") + private String serviceName; + + /** + * 调用的controller全类名。 + * 之所以为独立字段,是为了便于查询和统计接口的调用频度。 + */ + @Column(value = "api_class") + private String apiClass; + + /** + * 调用的controller中的方法。 + * 格式为:接口类名 + "." + 方法名。 + */ + @Column(value = "api_method") + private String apiMethod; + + /** + * 用户会话sessionId。 + * 主要是为了便于统计,以及跟踪查询定位问题。 + */ + @Column(value = "session_id") + private String sessionId; + + /** + * 每次请求的Id。 + * 对于微服务之间的调用,在同一个请求的调用链中,该值是相同的。 + */ + @Column(value = "trace_id") + private String traceId; + + /** + * 调用时长。 + */ + @Column(value = "elapse") + private Long elapse; + + /** + * HTTP 请求方法,如GET。 + */ + @Column(value = "request_method") + private String requestMethod; + + /** + * HTTP 请求地址。 + */ + @Column(value = "request_url") + private String requestUrl; + + /** + * controller接口参数。 + */ + @Column(value = "request_arguments") + private String requestArguments; + + /** + * controller应答结果。 + */ + @Column(value = "response_result") + private String responseResult; + + /** + * 请求IP。 + */ + @Column(value = "request_ip") + private String requestIp; + + /** + * 应答状态。 + */ + @Column(value = "success") + private Boolean success; + + /** + * 错误信息。 + */ + @Column(value = "error_msg") + private String errorMsg; + + /** + * 租户Id。 + * 仅用于多租户系统,是便于进行对租户的操作查询和统计分析。 + */ + @TenantFilterColumn + @Column(value = "tenant_id") + private Long tenantId; + + /** + * 操作员Id。 + */ + @Column(value = "operator_id") + private Long operatorId; + + /** + * 操作员名称。 + */ + @Column(value = "operator_name") + private String operatorName; + + /** + * 操作时间。 + */ + @Column(value = "operation_time") + private Date operationTime; + + /** + * 调用时长最小值。 + */ + @Column(ignore = true) + private Long elapseMin; + + /** + * 调用时长最大值。 + */ + @Column(ignore = true) + private Long elapseMax; + + /** + * 操作开始时间。 + */ + @Column(ignore = true) + private String operationTimeStart; + + /** + * 操作结束时间。 + */ + @Column(ignore = true) + private String operationTimeEnd; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/model/constant/SysOperationLogType.java b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/model/constant/SysOperationLogType.java new file mode 100644 index 00000000..ec3edaf5 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/model/constant/SysOperationLogType.java @@ -0,0 +1,145 @@ +package com.orangeforms.common.log.model.constant; + +/** + * 操作日志类型常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class SysOperationLogType { + + /** + * 其他。 + */ + public static final int OTHER = -1; + /** + * 登录。 + */ + public static final int LOGIN = 0; + /** + * 登录移动端。 + */ + public static final int LOGIN_MOBILE = 1; + /** + * 登出。 + */ + public static final int LOGOUT = 5; + /** + * 登出移动端。 + */ + public static final int LOGOUT_MOBILE = 6; + /** + * 新增。 + */ + public static final int ADD = 10; + /** + * 修改。 + */ + public static final int UPDATE = 15; + /** + * 删除。 + */ + public static final int DELETE = 20; + /** + * 批量删除。 + */ + public static final int DELETE_BATCH = 21; + /** + * 新增多对多关联。 + */ + public static final int ADD_M2M = 25; + /** + * 移除多对多关联。 + */ + public static final int DELETE_M2M = 30; + /** + * 批量移除多对多关联。 + */ + public static final int DELETE_M2M_BATCH = 31; + /** + * 查询。 + */ + public static final int LIST = 35; + /** + * 分组查询。 + */ + public static final int LIST_WITH_GROUP = 40; + /** + * 导出。 + */ + public static final int EXPORT = 45; + /** + * 导入。 + */ + public static final int IMPORT = 46; + /** + * 上传。 + */ + public static final int UPLOAD = 50; + /** + * 下载。 + */ + public static final int DOWNLOAD = 55; + /** + * 重置缓存。 + */ + public static final int RELOAD_CACHE = 60; + /** + * 发布。 + */ + public static final int PUBLISH = 65; + /** + * 取消发布。 + */ + public static final int UNPUBLISH = 70; + /** + * 暂停。 + */ + public static final int SUSPEND = 75; + /** + * 恢复。 + */ + public static final int RESUME = 80; + /** + * 启动流程。 + */ + public static final int START_FLOW = 100; + /** + * 停止流程。 + */ + public static final int STOP_FLOW = 105; + /** + * 删除流程。 + */ + public static final int DELETE_FLOW = 110; + /** + * 取消流程。 + */ + public static final int CANCEL_FLOW = 115; + /** + * 提交任务。 + */ + public static final int SUBMIT_TASK = 120; + /** + * 催办任务。 + */ + public static final int REMIND_TASK = 125; + /** + * 干预任务。 + */ + public static final int INTERVENE_FLOW = 126; + /** + * 修复流程的业务数据。 + */ + public static final int FIX_FLOW_BUSINESS_DATA = 127; + /** + * 流程复活。 + */ + public static final int REVIVE_FLOW = 128; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private SysOperationLogType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/service/SysOperationLogService.java b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/service/SysOperationLogService.java new file mode 100644 index 00000000..18c1b087 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/service/SysOperationLogService.java @@ -0,0 +1,45 @@ +package com.orangeforms.common.log.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.log.model.SysOperationLog; + +import java.util.List; + +/** + * 操作日志服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysOperationLogService extends IBaseService { + + /** + * 异步的插入一条新操作日志。 + * + * @param operationLog 操作日志对象。 + */ + void saveNewAsync(SysOperationLog operationLog); + + /** + * 插入一条新操作日志。 + * + * @param operationLog 操作日志对象。 + */ + void saveNew(SysOperationLog operationLog); + + /** + * 批量插入。 + * + * @param sysOperationLogList 操作日志列表。 + */ + void batchSave(List sysOperationLogList); + + /** + * 根据过滤条件和排序规则,查询操作日志。 + * + * @param filter 操作日志的过滤对象。 + * @param orderBy 排序规则。 + * @return 查询列表。 + */ + List getSysOperationLogList(SysOperationLog filter, String orderBy); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/service/impl/SysOperationLogServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/service/impl/SysOperationLogServiceImpl.java new file mode 100644 index 00000000..3935df68 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/service/impl/SysOperationLogServiceImpl.java @@ -0,0 +1,84 @@ +package com.orangeforms.common.log.service.impl; + +import com.orangeforms.common.core.annotation.MyDataSource; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.log.dao.SysOperationLogMapper; +import com.orangeforms.common.log.model.SysOperationLog; +import com.orangeforms.common.log.service.SysOperationLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * 操作日志服务实现类。 + * 这里需要重点解释下MyDataSource注解。在单数据源服务中,由于没有DataSourceAspect的切面类,所以该注解不会 + * 有任何作用和影响。然而在多数据源情况下,由于每个服务都有自己的DataSourceType常量对象,表示不同的数据源。 + * 而common-log在公用模块中,不能去依赖业务服务,因此这里给出了一个固定值。我们在业务的DataSourceType中,也要 + * 使用该值ApplicationConstant.OPERATION_LOG_DATASOURCE_TYPE,去关联操作日志所需的数据源配置。 + * + * @author Jerry + * @date 2024-07-02 + */ +@MyDataSource(ApplicationConstant.OPERATION_LOG_DATASOURCE_TYPE) +@Service +public class SysOperationLogServiceImpl extends BaseService implements SysOperationLogService { + + @Autowired + private SysOperationLogMapper sysOperationLogMapper; + + @Override + protected BaseDaoMapper mapper() { + return sysOperationLogMapper; + } + + /** + * 异步插入一条新操作日志。通常用于在橙单中创建的单体工程服务。 + * + * @param operationLog 操作日志对象。 + */ + @Async + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNewAsync(SysOperationLog operationLog) { + sysOperationLogMapper.insert(operationLog); + } + + /** + * 插入一条新操作日志。 + * + * @param operationLog 操作日志对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNew(SysOperationLog operationLog) { + sysOperationLogMapper.insert(operationLog); + } + + /** + * 批量插入。通常用于在橙单中创建的微服务工程服务。 + * + * @param sysOperationLogList 操作日志列表。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void batchSave(List sysOperationLogList) { + sysOperationLogMapper.insertList(sysOperationLogList); + } + + /** + * 根据过滤条件和排序规则,查询操作日志。 + * + * @param filter 操作日志的过滤对象。 + * @param orderBy 排序规则。 + * @return 查询列表。 + */ + @Override + public List getSysOperationLogList(SysOperationLog filter, String orderBy) { + return sysOperationLogMapper.getSysOperationLogList(filter, orderBy); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/vo/SysOperationLogVo.java b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/vo/SysOperationLogVo.java new file mode 100644 index 00000000..983ea9ed --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/java/com/orangeforms/common/log/vo/SysOperationLogVo.java @@ -0,0 +1,144 @@ +package com.orangeforms.common.log.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 操作日志记录表 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "操作日志VO") +@Data +public class SysOperationLogVo { + + /** + * 操作日志主键Id。 + */ + @Schema(description = "操作日志主键Id") + private Long logId; + + /** + * 日志描述。 + */ + @Schema(description = "日志描述") + private String description; + + /** + * 操作类型。 + * 常量值定义可参考SysOperationLogType对象。 + */ + @Schema(description = "操作类型") + private Integer operationType; + + /** + * 接口所在服务名称。 + * 通常为spring.application.name配置项的值。 + */ + @Schema(description = "接口所在服务名称") + private String serviceName; + + /** + * 调用的controller全类名。 + * 之所以为独立字段,是为了便于查询和统计接口的调用频度。 + */ + @Schema(description = "调用的controller全类名") + private String apiClass; + + /** + * 调用的controller中的方法。 + * 格式为:接口类名 + "." + 方法名。 + */ + @Schema(description = "调用的controller中的方法") + private String apiMethod; + + /** + * 用户会话sessionId。 + * 主要是为了便于统计,以及跟踪查询定位问题。 + */ + @Schema(description = "用户会话sessionId") + private String sessionId; + + /** + * 每次请求的Id。 + * 对于微服务之间的调用,在同一个请求的调用链中,该值是相同的。 + */ + @Schema(description = "每次请求的Id") + private String traceId; + + /** + * 调用时长。 + */ + @Schema(description = "调用时长") + private Long elapse; + + /** + * HTTP 请求方法,如GET。 + */ + @Schema(description = "HTTP 请求方法") + private String requestMethod; + + /** + * HTTP 请求地址。 + */ + @Schema(description = "HTTP 请求地址") + private String requestUrl; + + /** + * controller接口参数。 + */ + @Schema(description = "controller接口参数") + private String requestArguments; + + /** + * controller应答结果。 + */ + @Schema(description = "controller应答结果") + private String responseResult; + + /** + * 请求IP。 + */ + @Schema(description = "请求IP") + private String requestIp; + + /** + * 应答状态。 + */ + @Schema(description = "应答状态") + private Boolean success; + + /** + * 错误信息。 + */ + @Schema(description = "错误信息") + private String errorMsg; + + /** + * 租户Id。 + * 仅用于多租户系统,是便于进行对租户的操作查询和统计分析。 + */ + @Schema(description = "租户Id") + private Long tenantId; + + /** + * 操作员Id。 + */ + @Schema(description = "操作员Id") + private Long operatorId; + + /** + * 操作员名称。 + */ + @Schema(description = "操作员名称") + private String operatorName; + + /** + * 操作时间。 + */ + @Schema(description = "操作时间") + private Date operationTime; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..dff1b36f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-log/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.orangeforms.common.log.config.CommonLogAutoConfig \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-minio/pom.xml b/OrangeFormsOpen-MybatisFlex/common/common-minio/pom.xml new file mode 100644 index 00000000..178b8c8e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-minio/pom.xml @@ -0,0 +1,29 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-minio + 1.0.0 + common-minio + jar + + + + io.minio + minio + ${minio.version} + + + com.orangeforms + common-core + 1.0.0 + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-minio/src/main/java/com/orangeforms/common/minio/config/MinioAutoConfiguration.java b/OrangeFormsOpen-MybatisFlex/common/common-minio/src/main/java/com/orangeforms/common/minio/config/MinioAutoConfiguration.java new file mode 100644 index 00000000..d89019ff --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-minio/src/main/java/com/orangeforms/common/minio/config/MinioAutoConfiguration.java @@ -0,0 +1,56 @@ +package com.orangeforms.common.minio.config; + +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.minio.wrapper.MinioTemplate; +import io.minio.BucketExistsArgs; +import io.minio.MakeBucketArgs; +import io.minio.MinioClient; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +/** + * common-minio模块的自动配置引导类。仅当配置项minio.enabled为true的时候加载。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EnableConfigurationProperties(MinioProperties.class) +@ConditionalOnProperty(prefix = "minio", name = "enabled") +public class MinioAutoConfiguration { + + /** + * 将minio原生的客户端类封装成bean对象,便于集成,同时也可以灵活使用客户端的所有功能。 + * + * @param p 属性配置对象。 + * @return minio的原生客户端对象。 + */ + @Bean + @ConditionalOnMissingBean + public MinioClient minioClient(MinioProperties p) { + try { + MinioClient client = MinioClient.builder() + .endpoint(p.getEndpoint()).credentials(p.getAccessKey(), p.getSecretKey()).build(); + if (!client.bucketExists(BucketExistsArgs.builder().bucket(p.getBucketName()).build())) { + client.makeBucket(MakeBucketArgs.builder().bucket(p.getBucketName()).build()); + } + return client; + } catch (Exception e) { + throw new MyRuntimeException(e); + } + } + + /** + * 封装的minio模板类。 + * + * @param p 属性配置对象。 + * @param c minio的原生客户端bean对象。 + * @return minio模板的bean对象。 + */ + @Bean + @ConditionalOnMissingBean + public MinioTemplate minioTemplate(MinioProperties p, MinioClient c) { + return new MinioTemplate(p, c); + } +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-minio/src/main/java/com/orangeforms/common/minio/config/MinioProperties.java b/OrangeFormsOpen-MybatisFlex/common/common-minio/src/main/java/com/orangeforms/common/minio/config/MinioProperties.java new file mode 100644 index 00000000..ecdf253d --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-minio/src/main/java/com/orangeforms/common/minio/config/MinioProperties.java @@ -0,0 +1,32 @@ +package com.orangeforms.common.minio.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * common-minio模块的配置类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ConfigurationProperties(prefix = "minio") +public class MinioProperties { + + /** + * 访问入口地址。 + */ + private String endpoint; + /** + * 访问安全的key。 + */ + private String accessKey; + /** + * 访问安全的密钥。 + */ + private String secretKey; + /** + * 缺省桶名称。 + */ + private String bucketName; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-minio/src/main/java/com/orangeforms/common/minio/util/MinioUpDownloader.java b/OrangeFormsOpen-MybatisFlex/common/common-minio/src/main/java/com/orangeforms/common/minio/util/MinioUpDownloader.java new file mode 100644 index 00000000..9c2c71a7 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-minio/src/main/java/com/orangeforms/common/minio/util/MinioUpDownloader.java @@ -0,0 +1,115 @@ +package com.orangeforms.common.minio.util; + +import cn.hutool.core.io.IoUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.StrUtil; +import com.orangeforms.common.core.upload.UpDownloaderFactory; +import com.orangeforms.common.core.upload.UploadResponseInfo; +import com.orangeforms.common.core.upload.BaseUpDownloader; +import com.orangeforms.common.core.upload.UploadStoreTypeEnum; +import com.orangeforms.common.minio.wrapper.MinioTemplate; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; + +import jakarta.annotation.PostConstruct; +import jakarta.servlet.http.HttpServletResponse; +import java.io.*; + +/** + * 基于Minio上传和下载文件操作的工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Component +@ConditionalOnProperty(prefix = "minio", name = "enabled") +public class MinioUpDownloader extends BaseUpDownloader { + + @Autowired + private MinioTemplate minioTemplate; + @Autowired + private UpDownloaderFactory factory; + + @PostConstruct + public void doRegister() { + factory.registerUpDownloader(UploadStoreTypeEnum.MINIO_SYSTEM, this); + } + + @Override + public UploadResponseInfo doUpload( + String serviceContextPath, + String rootBaseDir, + String modelName, + String fieldName, + Boolean asImage, + MultipartFile uploadFile) throws IOException { + String uploadPath = super.makeFullPath(null, modelName, fieldName, asImage); + return this.doUploadInternally(serviceContextPath, uploadPath, asImage, uploadFile); + } + + @Override + public UploadResponseInfo doUpload( + String serviceContextPath, + String rootBaseDir, + String uriPath, + MultipartFile uploadFile) throws IOException { + String uploadPath = super.makeFullPath(null, uriPath); + return this.doUploadInternally(serviceContextPath, uploadPath, false, uploadFile); + } + + @Override + public void doDownload( + String rootBaseDir, + String modelName, + String fieldName, + String fileName, + Boolean asImage, + HttpServletResponse response) throws IOException { + String uploadPath = this.makeFullPath(null, modelName, fieldName, asImage); + String fullFileanme = uploadPath + "/" + fileName; + this.downloadInternal(fullFileanme, fileName, response); + } + + @Override + public void doDownload( + String rootBaseDir, + String uriPath, + String fileName, + HttpServletResponse response) throws IOException { + StringBuilder pathBuilder = new StringBuilder(128); + if (StrUtil.isNotBlank(uriPath)) { + pathBuilder.append(uriPath); + } + pathBuilder.append("/"); + String fullFileanme = pathBuilder.append(fileName).toString(); + this.downloadInternal(fullFileanme, fileName, response); + } + + private UploadResponseInfo doUploadInternally( + String serviceContextPath, + String uploadPath, + Boolean asImage, + MultipartFile uploadFile) throws IOException { + UploadResponseInfo responseInfo = super.verifyUploadArgument(asImage, uploadFile); + if (BooleanUtil.isTrue(responseInfo.getUploadFailed())) { + return responseInfo; + } + responseInfo.setUploadPath(uploadPath); + super.fillUploadResponseInfo(responseInfo, serviceContextPath, uploadFile.getOriginalFilename()); + minioTemplate.putObject(uploadPath + "/" + responseInfo.getFilename(), uploadFile.getInputStream()); + return responseInfo; + } + + private void downloadInternal(String fullFileanme, String fileName, HttpServletResponse response) throws IOException { + response.setHeader("content-type", "application/octet-stream"); + response.setContentType("application/octet-stream"); + response.setHeader("Content-Disposition", "attachment;filename=" + fileName); + InputStream in = minioTemplate.getStream(fullFileanme); + IoUtil.copy(in, response.getOutputStream()); + in.close(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-minio/src/main/java/com/orangeforms/common/minio/wrapper/MinioTemplate.java b/OrangeFormsOpen-MybatisFlex/common/common-minio/src/main/java/com/orangeforms/common/minio/wrapper/MinioTemplate.java new file mode 100644 index 00000000..dc29310f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-minio/src/main/java/com/orangeforms/common/minio/wrapper/MinioTemplate.java @@ -0,0 +1,199 @@ +package com.orangeforms.common.minio.wrapper; + +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.minio.config.MinioProperties; +import io.minio.*; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.FileUtils; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; + +/** + * 封装的minio客户端模板类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class MinioTemplate { + + private static final String TMP_DIR = System.getProperty("java.io.tmpdir") + File.separator; + private final MinioProperties properties; + private final MinioClient client; + + public MinioTemplate(MinioProperties properties, MinioClient client) { + super(); + this.properties = properties; + this.client = client; + } + + /** + * 判断bucket是否存在。 + * + * @param bucketName 桶名称。 + * @return 存在返回true,否则false。 + */ + public boolean bucketExists(String bucketName) { + try { + return client.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build()); + } catch (Exception e) { + throw new MyRuntimeException(e); + } + } + + /** + * 创建桶。 + * + * @param bucketName 桶名称。 + */ + public void makeBucket(String bucketName) { + try { + if (!client.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build())) { + client.makeBucket(MakeBucketArgs.builder().bucket(bucketName).build()); + } + } catch (Exception e) { + throw new MyRuntimeException(e); + } + } + + /** + * 存放对象。 + * + * @param bucketName 桶名称。 + * @param objectName 对象名称。 + * @param filename 本地上传的文件名称。 + */ + public void putObject(String bucketName, String objectName, String filename) { + try { + this.putObject(bucketName, objectName, new FileInputStream(filename)); + } catch (Exception e) { + throw new MyRuntimeException(e); + } + } + + /** + * 存放对象。桶名称为配置中的桶名称。 + * + * @param objectName 对象名称。 + * @param filename 本地上传的文件名称。 + */ + public void putObject(String objectName, String filename) { + try { + this.putObject(properties.getBucketName(), objectName, filename); + } catch (Exception e) { + throw new MyRuntimeException(e); + } + } + + /** + * 读取输入流并存放。 + * + * @param bucketName 桶名称。 + * @param objectName 对象名称。 + * @param stream 读取后上传的文件流。 + */ + public void putObject(String bucketName, String objectName, InputStream stream) { + try { + client.putObject(PutObjectArgs.builder() + .bucket(bucketName).object(objectName).stream(stream, stream.available(), -1).build()); + } catch (Exception e) { + throw new MyRuntimeException(e); + } finally { + try { + stream.close(); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + } + } + + /** + * 读取输入流并存放。 + * + * @param objectName 对象名称。 + * @param stream 读取后上传的文件流。 + */ + public void putObject(String objectName, InputStream stream) { + this.putObject(properties.getBucketName(), objectName, stream); + } + + /** + * 移除对象。 + * + * @param bucketName 桶名称。 + * @param objectName 对象名称。 + */ + public void removeObject(String bucketName, String objectName) { + try { + client.removeObject(RemoveObjectArgs.builder().bucket(bucketName).object(objectName).build()); + } catch (Exception e) { + throw new MyRuntimeException(e); + } + } + + /** + * 移除对象。桶名称为配置中的桶名称。 + * + * @param objectName 对象名称。 + */ + public void removeObject(String objectName) { + this.removeObject(properties.getBucketName(), objectName); + } + + /** + * 获取文件输入流。 + * + * @param bucket 桶名称。 + * @param objectName 对象名称。 + * @return 文件的输入流。 + */ + public InputStream getStream(String bucket, String objectName) { + try { + return client.getObject(GetObjectArgs.builder().bucket(bucket).object(objectName).build()); + } catch (Exception e) { + throw new MyRuntimeException(e); + } + } + + /** + * 获取文件输入流。 + * + * @param objectName 对象名称。 + * @return 文件的输入流。 + */ + public InputStream getStream(String objectName) { + return this.getStream(properties.getBucketName(), objectName); + } + + /** + * 获取存储的文件对象。 + * + * @param bucket 桶名称。 + * @param objectName 对象名称。 + * @return 读取后存储到文件的文件对象。 + */ + public File getFile(String bucket, String objectName) throws IOException { + InputStream in = getStream(bucket, objectName); + File dir = new File(TMP_DIR); + if (!dir.exists() || dir.isFile()) { + dir.mkdirs(); + } + File file = new File(TMP_DIR + objectName); + FileUtils.copyInputStreamToFile(in, file); + in.close(); + return file; + } + + /** + * 获取存储的文件对象。桶名称为配置中的桶名称。 + * + * @param objectName 对象名称。 + * @return 读取后存储到文件的文件对象。 + */ + public File getFile(String objectName) throws IOException { + return this.getFile(properties.getBucketName(), objectName); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-minio/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/OrangeFormsOpen-MybatisFlex/common/common-minio/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..a7ba3af4 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-minio/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.orangeforms.common.minio.config.MinioAutoConfiguration \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/pom.xml b/OrangeFormsOpen-MybatisFlex/common/common-online/pom.xml new file mode 100644 index 00000000..c653f38f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/pom.xml @@ -0,0 +1,64 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-online + 1.0.0 + common-online + jar + + + + com.orangeforms + common-satoken + 1.0.0 + + + com.orangeforms + common-dbutil + 1.0.0 + + + com.orangeforms + common-dict + 1.0.0 + + + com.orangeforms + common-datafilter + 1.0.0 + + + com.orangeforms + common-redis + 1.0.0 + + + com.orangeforms + common-sequence + 1.0.0 + + + com.orangeforms + common-log + 1.0.0 + + + com.orangeforms + common-minio + 1.0.0 + + + com.orangeforms + common-swagger + 1.0.0 + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/config/OnlineAutoConfig.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/config/OnlineAutoConfig.java new file mode 100644 index 00000000..2f18a739 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/config/OnlineAutoConfig.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.online.config; + +import org.springframework.boot.context.properties.EnableConfigurationProperties; + +/** + * common-online模块的自动配置引导类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EnableConfigurationProperties({OnlineProperties.class}) +public class OnlineAutoConfig { +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/config/OnlineProperties.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/config/OnlineProperties.java new file mode 100644 index 00000000..17308333 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/config/OnlineProperties.java @@ -0,0 +1,59 @@ +package com.orangeforms.common.online.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +import java.util.List; + +/** + * 在线表单的配置对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ConfigurationProperties(prefix = "common-online") +public class OnlineProperties { + + /** + * 脱敏字段的掩码。只能为单个字符。 + */ + private String maskChar = "*"; + /** + * 在调用render接口的时候,是否打开一级缓存加速页面渲染数据的获取。 + */ + private Boolean enableRenderCache = true; + /** + * 业务表和在线表单内置表是否跨库。 + */ + private Boolean enabledMultiDatabaseWrite = true; + /** + * 仅以该前缀开头的数据表才会成为动态表单的候选数据表,如: zz_。如果为空,则所有表均可被选。 + */ + private String tablePrefix; + /** + * 在线表单业务操作的URL前缀。 + */ + private String urlPrefix; + /** + * 在线表单打印接口的路径 + */ + private String printUrlPath; + /** + * 上传文件的根路径。 + */ + private String uploadFileBaseDir; + /** + * 1: minio 2: aliyun-oss 3: qcloud-cos。 + * 0是本地系统,不推荐使用。 + */ + private Integer distributeStoreType; + /** + * 在线表单查看权限的URL列表。 + */ + private List viewUrlList; + /** + * 在线表单编辑权限的URL列表。 + */ + private List editUrlList; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineColumnController.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineColumnController.java new file mode 100644 index 00000000..52c169db --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineColumnController.java @@ -0,0 +1,517 @@ +package com.orangeforms.common.online.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import io.swagger.v3.oas.annotations.tags.Tag; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.EnumUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.constant.MaskFieldTypeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.dbutil.object.SqlTableColumn; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.online.dto.OnlineColumnDto; +import com.orangeforms.common.online.dto.OnlineColumnRuleDto; +import com.orangeforms.common.online.dto.OnlineRuleDto; +import com.orangeforms.common.online.model.*; +import com.orangeforms.common.online.model.constant.FieldKind; +import com.orangeforms.common.online.service.*; +import com.orangeforms.common.online.vo.OnlineColumnRuleVo; +import com.orangeforms.common.online.vo.OnlineColumnVo; +import com.orangeforms.common.online.vo.OnlineRuleVo; +import com.github.pagehelper.page.PageMethod; +import lombok.extern.slf4j.Slf4j; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 在线表单字段数据接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "在线表单字段数据接口") +@Slf4j +@RestController +@RequestMapping("${common-online.urlPrefix}/onlineColumn") +@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true") +public class OnlineColumnController { + + @Autowired + private OnlineColumnService onlineColumnService; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private OnlineVirtualColumnService onlineVirtualColumnService; + @Autowired + private OnlineDblinkService onlineDblinkService; + @Autowired + private OnlineRuleService onlineRuleService; + @Autowired + private OnlineDictService onlineDictService; + + /** + * 根据数据库表字段信息,在指定在线表中添加在线表字段对象。 + * + * @param dblinkId 数据库链接Id。 + * @param tableName 数据库表名称。 + * @param columnName 数据库表字段名。 + * @param tableId 目的表Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add( + @MyRequestBody Long dblinkId, + @MyRequestBody String tableName, + @MyRequestBody String columnName, + @MyRequestBody Long tableId) { + OnlineDblink dblink = onlineDblinkService.getById(dblinkId); + if (dblink == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + String errorMessage; + SqlTableColumn sqlTableColumn = onlineDblinkService.getDblinkTableColumn(dblink, tableName, columnName); + if (sqlTableColumn == null) { + errorMessage = "数据验证失败,指定的数据表字段不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + ResponseResult verifyResult = this.doVerifyTable(tableId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + onlineColumnService.saveNewList(CollUtil.newLinkedList(sqlTableColumn), tableId); + return ResponseResult.success(); + } + + /** + * 更新字段数据数据。 + * + * @param onlineColumnDto 更新对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody OnlineColumnDto onlineColumnDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineColumnDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineColumn onlineColumn = MyModelUtil.copyTo(onlineColumnDto, OnlineColumn.class); + OnlineColumn originalOnlineColumn = onlineColumnService.getById(onlineColumn.getColumnId()); + if (originalOnlineColumn == null) { + errorMessage = "数据验证失败,当前在线表字段并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + ResponseResult verifyColumnResult = this.doVerifyColumn(onlineColumn, originalOnlineColumn); + if (!verifyColumnResult.isSuccess()) { + return ResponseResult.errorFrom(verifyColumnResult); + } + ResponseResult verifyResult = this.doVerifyTable(originalOnlineColumn.getTableId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (!onlineColumnService.update(onlineColumn, originalOnlineColumn)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 删除字段数据数据。 + * + * @param columnId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long columnId) { + String errorMessage; + if (MyCommonUtil.existBlankArgument(columnId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + // 验证关联Id的数据合法性 + OnlineColumn originalOnlineColumn = onlineColumnService.getById(columnId); + if (originalOnlineColumn == null) { + errorMessage = "数据验证失败,当前在线表字段并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + ResponseResult verifyResult = this.doVerifyTable(originalOnlineColumn.getTableId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineVirtualColumn virtualColumnFilter = new OnlineVirtualColumn(); + virtualColumnFilter.setAggregationColumnId(columnId); + List virtualColumnList = + onlineVirtualColumnService.getOnlineVirtualColumnList(virtualColumnFilter, null); + if (CollUtil.isNotEmpty(virtualColumnList)) { + OnlineVirtualColumn virtualColumn = virtualColumnList.get(0); + errorMessage = "数据验证失败,数据源关联正在被虚拟字段 [" + virtualColumn.getColumnPrompt() + "] 使用,不能被删除!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!onlineColumnService.remove(originalOnlineColumn.getTableId(), columnId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的字段数据列表。 + * + * @param onlineColumnDtoFilter 过滤对象。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("onlinePage.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody OnlineColumnDto onlineColumnDtoFilter, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlineColumn onlineColumnFilter = MyModelUtil.copyTo(onlineColumnDtoFilter, OnlineColumn.class); + List onlineColumnList = + onlineColumnService.getOnlineColumnListWithRelation(onlineColumnFilter); + return ResponseResult.success(MyPageUtil.makeResponseData(onlineColumnList, OnlineColumnVo.class)); + } + + /** + * 查看指定字段数据对象详情。 + * + * @param columnId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("onlinePage.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long columnId) { + if (MyCommonUtil.existBlankArgument(columnId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + OnlineColumn onlineColumn = onlineColumnService.getByIdWithRelation(columnId, MyRelationParam.full()); + if (onlineColumn == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(onlineColumn, OnlineColumnVo.class); + } + + /** + * 将数据库中的表字段信息刷新到已经导入的在线表字段信息。 + * + * @param dblinkId 数据库链接Id。 + * @param tableName 数据库表名称。 + * @param columnName 数据库表字段名。 + * @param columnId 被刷新的在线字段Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @PostMapping("/refresh") + public ResponseResult refresh( + @MyRequestBody Long dblinkId, + @MyRequestBody String tableName, + @MyRequestBody String columnName, + @MyRequestBody Long columnId) { + OnlineDblink dblink = onlineDblinkService.getById(dblinkId); + if (dblink == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + String errorMsg; + SqlTableColumn sqlTableColumn = onlineDblinkService.getDblinkTableColumn(dblink, tableName, columnName); + if (sqlTableColumn == null) { + errorMsg = "数据验证失败,指定的数据表字段不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMsg); + } + OnlineColumn onlineColumn = onlineColumnService.getById(columnId); + if (onlineColumn == null) { + errorMsg = "数据验证失败,指定的在线表字段Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMsg); + } + ResponseResult verifyResult = this.doVerifyTable(onlineColumn.getTableId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + onlineColumnService.refresh(sqlTableColumn, onlineColumn); + return ResponseResult.success(); + } + + /** + * 列出不与指定字段数据存在多对多关系的 [验证规则] 列表数据。通常用于查看添加新 [验证规则] 对象的候选列表。 + * + * @param columnId 主表关联字段。 + * @param onlineRuleDtoFilter [验证规则] 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,返回符合条件的数据列表。 + */ + @SaCheckPermission("onlinePage.all") + @PostMapping("/listNotInOnlineColumnRule") + public ResponseResult> listNotInOnlineColumnRule( + @MyRequestBody Long columnId, + @MyRequestBody OnlineRuleDto onlineRuleDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + ResponseResult verifyResult = this.doVerifyColumn(columnId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlineRule filter = MyModelUtil.copyTo(onlineRuleDtoFilter, OnlineRule.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineRule.class); + List onlineRuleList = + onlineRuleService.getNotInOnlineRuleListByColumnId(columnId, filter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(onlineRuleList, OnlineRuleVo.class)); + } + + /** + * 列出与指定字段数据存在多对多关系的 [验证规则] 列表数据。 + * + * @param columnId 主表关联字段。 + * @param onlineRuleDtoFilter [验证规则] 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,返回符合条件的数据列表。 + */ + @SaCheckPermission("onlinePage.all") + @PostMapping("/listOnlineColumnRule") + public ResponseResult> listOnlineColumnRule( + @MyRequestBody Long columnId, + @MyRequestBody OnlineRuleDto onlineRuleDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + ResponseResult verifyResult = this.doVerifyColumn(columnId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlineRule filter = MyModelUtil.copyTo(onlineRuleDtoFilter, OnlineRule.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineRule.class); + List onlineRuleList = + onlineRuleService.getOnlineRuleListByColumnId(columnId, filter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(onlineRuleList, OnlineRuleVo.class)); + } + + /** + * 批量添加字段数据和 [验证规则] 对象的多对多关联关系数据。 + * + * @param columnId 主表主键Id。 + * @param onlineColumnRuleDtoList 关联对象列表。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.ADD_M2M) + @PostMapping("/addOnlineColumnRule") + public ResponseResult addOnlineColumnRule( + @MyRequestBody Long columnId, @MyRequestBody List onlineColumnRuleDtoList) { + if (MyCommonUtil.existBlankArgument(columnId, onlineColumnRuleDtoList)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + String errorMessage; + for (OnlineColumnRuleDto onlineColumnRule : onlineColumnRuleDtoList) { + errorMessage = MyCommonUtil.getModelValidationError(onlineColumnRule); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + ResponseResult verifyResult = this.doVerifyColumn(columnId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + Set ruleIdSet = onlineColumnRuleDtoList.stream() + .map(OnlineColumnRuleDto::getRuleId).collect(Collectors.toSet()); + List ruleList = onlineRuleService.getInList(ruleIdSet); + if (ruleIdSet.size() != ruleList.size()) { + errorMessage = "数据验证失败,参数中存在非法字段规则Id!"; + return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID, errorMessage); + } + for (OnlineRule rule : ruleList) { + if (BooleanUtil.isFalse(rule.getBuiltin()) + && !StrUtil.equals(rule.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + errorMessage = "数据验证失败,参数中存在不属于该应用的字段规则Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + List onlineColumnRuleList = + MyModelUtil.copyCollectionTo(onlineColumnRuleDtoList, OnlineColumnRule.class); + onlineColumnService.addOnlineColumnRuleList(onlineColumnRuleList, columnId); + return ResponseResult.success(); + } + + /** + * 更新指定字段数据和指定 [验证规则] 的多对多关联数据。 + * + * @param onlineColumnRuleDto 对多对中间表对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/updateOnlineColumnRule") + public ResponseResult updateOnlineColumnRule(@MyRequestBody OnlineColumnRuleDto onlineColumnRuleDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineColumnRuleDto); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + ResponseResult verifyResult = this.doVerifyColumn(onlineColumnRuleDto.getColumnId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineColumnRule onlineColumnRule = MyModelUtil.copyTo(onlineColumnRuleDto, OnlineColumnRule.class); + if (!onlineColumnService.updateOnlineColumnRule(onlineColumnRule)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 显示字段数据和指定 [验证规则] 的多对多关联详情数据。 + * + * @param columnId 主表主键Id。 + * @param ruleId 从表主键Id。 + * @return 应答结果对象,包括中间表详情。 + */ + @SaCheckPermission("onlinePage.all") + @GetMapping("/viewOnlineColumnRule") + public ResponseResult viewOnlineColumnRule( + @RequestParam Long columnId, @RequestParam Long ruleId) { + if (MyCommonUtil.existBlankArgument(columnId, ruleId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + ResponseResult verifyResult = this.doVerifyColumn(columnId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineColumnRule onlineColumnRule = onlineColumnService.getOnlineColumnRule(columnId, ruleId); + if (onlineColumnRule == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + OnlineColumnRuleVo onlineColumnRuleVo = MyModelUtil.copyTo(onlineColumnRule, OnlineColumnRuleVo.class); + return ResponseResult.success(onlineColumnRuleVo); + } + + /** + * 移除指定字段数据和指定 [验证规则] 的多对多关联关系。 + * + * @param columnId 主表主键Id。 + * @param ruleId 从表主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.DELETE_M2M) + @PostMapping("/deleteOnlineColumnRule") + public ResponseResult deleteOnlineColumnRule(@MyRequestBody Long columnId, @MyRequestBody Long ruleId) { + if (MyCommonUtil.existBlankArgument(columnId, ruleId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + ResponseResult verifyResult = this.doVerifyColumn(columnId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (!onlineColumnService.removeOnlineColumnRule(columnId, ruleId)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 以字典形式返回全部字段数据数据集合。字典的键值为[columnId, columnName]。 + * 白名单接口,登录用户均可访问。 + * + * @param filter 过滤对象。 + * @return 应答结果对象,包含的数据为 List>,map中包含两条记录,key的值分别是id和name,value对应具体数据。 + */ + @GetMapping("/listDict") + public ResponseResult>> listDict(@ParameterObject OnlineColumnDto filter) { + List resultList = + onlineColumnService.getListByFilter(MyModelUtil.copyTo(filter, OnlineColumn.class)); + return ResponseResult.success( + MyCommonUtil.toDictDataList(resultList, OnlineColumn::getColumnId, OnlineColumn::getColumnName)); + } + + private ResponseResult doVerifyColumn(Long columnId) { + if (MyCommonUtil.existBlankArgument(columnId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + OnlineColumn onlineColumn = onlineColumnService.getById(columnId); + if (onlineColumn == null) { + return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID); + } + ResponseResult verifyResult = this.doVerifyTable(onlineColumn.getTableId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + return ResponseResult.success(); + } + + private ResponseResult doVerifyColumn(OnlineColumn onlineColumn, OnlineColumn originalOnlineColumn) { + String errorMessage; + if (onlineColumn.getDictId() != null + && ObjectUtil.notEqual(onlineColumn.getDictId(), originalOnlineColumn.getDictId())) { + OnlineDict dict = onlineDictService.getById(onlineColumn.getDictId()); + if (dict == null) { + errorMessage = "数据验证失败,关联的字典Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!StrUtil.equals(dict.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + errorMessage = "数据验证失败,关联的字典Id并不属于当前应用!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + } + if (MyCommonUtil.equalsAny(onlineColumn.getFieldKind(), FieldKind.UPLOAD, FieldKind.UPLOAD_IMAGE) + && onlineColumn.getUploadFileSystemType() == null) { + errorMessage = "数据验证失败,上传字段必须设置上传文件系统类型!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (ObjectUtil.equal(onlineColumn.getFieldKind(), FieldKind.MASK_FIELD)) { + if (onlineColumn.getMaskFieldType() == null) { + errorMessage = "数据验证失败,脱敏字段没有设置脱敏类型!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!EnumUtil.contains(MaskFieldTypeEnum.class, onlineColumn.getMaskFieldType())) { + errorMessage = "数据验证失败,脱敏字段设置的脱敏类型并不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + if (!onlineColumn.getTableId().equals(originalOnlineColumn.getTableId())) { + errorMessage = "数据验证失败,字段的所属表Id不能修改!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(); + } + + private ResponseResult doVerifyTable(Long tableId) { + String errorMessage; + OnlineTable table = onlineTableService.getById(tableId); + if (table == null) { + errorMessage = "数据验证失败,指定的数据表Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!StrUtil.equals(table.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + errorMessage = "数据验证失败,当前应用并不包含该字段所在的表!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDatasourceController.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDatasourceController.java new file mode 100644 index 00000000..18831b3b --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDatasourceController.java @@ -0,0 +1,287 @@ +package com.orangeforms.common.online.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.StrUtil; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.core.validator.AddGroup; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.dbutil.object.SqlTable; +import com.orangeforms.common.dbutil.object.SqlTableColumn; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.online.dto.OnlineDatasourceDto; +import com.orangeforms.common.online.model.*; +import com.orangeforms.common.online.model.constant.PageType; +import com.orangeforms.common.online.service.*; +import com.orangeforms.common.online.vo.OnlineDatasourceVo; +import com.orangeforms.common.online.vo.OnlineTableVo; +import com.github.pagehelper.page.PageMethod; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.dao.DuplicateKeyException; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import java.util.List; + +/** + * 在线表单数据源接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "在线表单数据源接口") +@Slf4j +@RestController +@RequestMapping("${common-online.urlPrefix}/onlineDatasource") +@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true") +public class OnlineDatasourceController { + + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private OnlineFormService onlineFormService; + @Autowired + private OnlinePageService onlinePageService; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private OnlineColumnService onlineColumnService; + @Autowired + private OnlineDblinkService onlineDblinkService; + + /** + * 新增数据模型数据。 + * + * @param onlineDatasourceDto 新增对象。 + * @param pageId 关联的页面Id。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"onlineDatasourceDto.datasourceId"}) + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add( + @MyRequestBody OnlineDatasourceDto onlineDatasourceDto, + @MyRequestBody(required = true) Long pageId) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineDatasourceDto, Default.class, AddGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlinePage onlinePage = onlinePageService.getById(pageId); + if (onlinePage == null) { + errorMessage = "数据验证失败,页面Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + String appCode = TokenData.takeFromRequest().getAppCode(); + if (!StrUtil.equals(onlinePage.getAppCode(), appCode)) { + errorMessage = "数据验证失败,当前应用并不存在该页面!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineDatasource onlineDatasource = MyModelUtil.copyTo(onlineDatasourceDto, OnlineDatasource.class); + if (onlineDatasourceService.existByVariableName(onlineDatasource.getVariableName())) { + errorMessage = "数据验证失败,当前数据源变量已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage); + } + OnlineDblink onlineDblink = onlineDblinkService.getById(onlineDatasourceDto.getDblinkId()); + if (onlineDblink == null) { + errorMessage = "数据验证失败,关联的数据库链接Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!StrUtil.equals(onlineDblink.getAppCode(), appCode)) { + errorMessage = "数据验证失败,当前应用并不存在该数据库链接!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + SqlTable sqlTable = onlineDblinkService.getDblinkTable(onlineDblink, onlineDatasourceDto.getMasterTableName()); + if (sqlTable == null) { + errorMessage = "数据验证失败,指定的数据表名不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + ResponseResult verifyResult = this.doVerifyPrimaryKey(sqlTable, onlinePage); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + try { + onlineDatasource = onlineDatasourceService.saveNew(onlineDatasource, sqlTable, pageId); + } catch (DuplicateKeyException e) { + errorMessage = "数据验证失败,当前应用的数据源变量名已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(onlineDatasource.getDatasourceId()); + } + + /** + * 更新数据模型数据。 + * + * @param onlineDatasourceDto 更新对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody OnlineDatasourceDto onlineDatasourceDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineDatasourceDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineDatasource onlineDatasource = MyModelUtil.copyTo(onlineDatasourceDto, OnlineDatasource.class); + ResponseResult verifyResult = this.doVerifyAndGet(onlineDatasource.getDatasourceId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDatasource originalOnlineDatasource = verifyResult.getData(); + if (!onlineDatasource.getDblinkId().equals(originalOnlineDatasource.getDblinkId())) { + errorMessage = "数据验证失败,不能修改数据库链接Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!onlineDatasource.getMasterTableId().equals(originalOnlineDatasource.getMasterTableId())) { + errorMessage = "数据验证失败,不能修改主表Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!StrUtil.equals(onlineDatasource.getVariableName(), originalOnlineDatasource.getVariableName()) + && onlineDatasourceService.existByVariableName(onlineDatasource.getVariableName())) { + errorMessage = "数据验证失败,当前数据源变量已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage); + } + try { + if (!onlineDatasourceService.update(onlineDatasource, originalOnlineDatasource)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + } catch (DuplicateKeyException e) { + errorMessage = "数据验证失败,当前应用的数据源变量名已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 删除数据模型数据。 + * + * @param datasourceId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long datasourceId) { + String errorMessage; + if (MyCommonUtil.existBlankArgument(datasourceId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + ResponseResult verifyResult = this.doVerifyAndGet(datasourceId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + List formList = onlineFormService.getOnlineFormListByDatasourceId(datasourceId); + if (CollUtil.isNotEmpty(formList)) { + errorMessage = "数据验证失败,当前数据源正在被 [" + formList.get(0).getFormName() + "] 表单占用,请先删除关联数据!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!onlineDatasourceService.remove(datasourceId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的数据模型列表。 + * + * @param onlineDatasourceDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("onlinePage.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody OnlineDatasourceDto onlineDatasourceDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlineDatasource onlineDatasourceFilter = MyModelUtil.copyTo(onlineDatasourceDtoFilter, OnlineDatasource.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineDatasource.class); + List onlineDatasourceList = + onlineDatasourceService.getOnlineDatasourceListWithRelation(onlineDatasourceFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(onlineDatasourceList, OnlineDatasourceVo.class)); + } + + /** + * 查看指定数据模型对象详情。 + * + * @param datasourceId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("onlinePage.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long datasourceId) { + ResponseResult verifyResult = this.doVerifyAndGet(datasourceId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDatasource onlineDatasource = + onlineDatasourceService.getByIdWithRelation(datasourceId, MyRelationParam.full()); + OnlineDatasourceVo onlineDatasourceVo = MyModelUtil.copyTo(onlineDatasource, OnlineDatasourceVo.class); + List tableList = onlineTableService.getOnlineTableListByDatasourceId(datasourceId); + if (CollUtil.isNotEmpty(tableList)) { + onlineDatasourceVo.setTableList(MyModelUtil.copyCollectionTo(tableList, OnlineTableVo.class)); + } + return ResponseResult.success(onlineDatasourceVo); + } + + private ResponseResult doVerifyAndGet(Long datasourceId) { + if (MyCommonUtil.existBlankArgument(datasourceId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + OnlineDatasource onlineDatasource = onlineDatasourceService.getById(datasourceId); + if (onlineDatasource == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + if (!StrUtil.equals(onlineDatasource.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, "数据验证失败,当前应用并不存在该数据源!"); + } + return ResponseResult.success(onlineDatasource); + } + + private ResponseResult doVerifyPrimaryKey(SqlTable sqlTable, OnlinePage onlinePage) { + String errorMessage; + boolean hasPrimaryKey = false; + for (SqlTableColumn tableColumn : sqlTable.getColumnList()) { + if (BooleanUtil.isFalse(tableColumn.getPrimaryKey())) { + continue; + } + if (hasPrimaryKey) { + errorMessage = "数据验证失败,数据表只能包含一个主键字段!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + hasPrimaryKey = true; + // 流程表单的主表主键,不能是自增主键。 + if (BooleanUtil.isTrue(tableColumn.getAutoIncrement()) + && onlinePage.getPageType().equals(PageType.FLOW)) { + errorMessage = "数据验证失败,流程页面所关联的主表主键,不能是自增主键!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + CallResult verifyResult = onlineColumnService.verifyPrimaryKey(tableColumn); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + } + if (!hasPrimaryKey) { + errorMessage = "数据验证失败,数据表必须包含主键字段!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDatasourceRelationController.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDatasourceRelationController.java new file mode 100644 index 00000000..31755e57 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDatasourceRelationController.java @@ -0,0 +1,260 @@ +package com.orangeforms.common.online.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.core.validator.AddGroup; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.dbutil.object.SqlTable; +import com.orangeforms.common.dbutil.object.SqlTableColumn; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.online.dto.OnlineDatasourceRelationDto; +import com.orangeforms.common.online.model.*; +import com.orangeforms.common.online.service.*; +import com.orangeforms.common.online.vo.OnlineDatasourceRelationVo; +import com.github.pagehelper.page.PageMethod; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import java.util.List; + +/** + * 在线表单数据源关联接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "在线表单数据源关联接口") +@Slf4j +@RestController +@RequestMapping("${common-online.urlPrefix}/onlineDatasourceRelation") +@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true") +public class OnlineDatasourceRelationController { + + @Autowired + private OnlineDatasourceRelationService onlineDatasourceRelationService; + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private OnlineVirtualColumnService onlineVirtualColumnService; + @Autowired + private OnlineDblinkService onlineDblinkService; + @Autowired + private OnlineFormService onlineFormService; + + /** + * 新增数据关联数据。 + * + * @param onlineDatasourceRelationDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"onlineDatasourceRelationDto.relationId"}) + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody OnlineDatasourceRelationDto onlineDatasourceRelationDto) { + String errorMessage = MyCommonUtil.getModelValidationError( + onlineDatasourceRelationDto, Default.class, AddGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineDatasourceRelation onlineDatasourceRelation = + MyModelUtil.copyTo(onlineDatasourceRelationDto, OnlineDatasourceRelation.class); + OnlineDatasource onlineDatasource = + onlineDatasourceService.getById(onlineDatasourceRelationDto.getDatasourceId()); + if (onlineDatasource == null) { + errorMessage = "数据验证失败,关联的数据源Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + String appCode = TokenData.takeFromRequest().getAppCode(); + if (!StrUtil.equals(onlineDatasource.getAppCode(), appCode)) { + errorMessage = "数据验证失败,当前应用并不包含该数据源Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineDblink onlineDblink = onlineDblinkService.getById(onlineDatasource.getDblinkId()); + SqlTable slaveTable = onlineDblinkService.getDblinkTable( + onlineDblink, onlineDatasourceRelationDto.getSlaveTableName()); + if (slaveTable == null) { + errorMessage = "数据验证失败,指定的数据表不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + SqlTableColumn slaveColumn = null; + for (SqlTableColumn column : slaveTable.getColumnList()) { + if (column.getColumnName().equals(onlineDatasourceRelationDto.getSlaveColumnName())) { + slaveColumn = column; + break; + } + } + if (slaveColumn == null) { + errorMessage = "数据验证失败,指定的数据表字段 [" + onlineDatasourceRelationDto.getSlaveColumnName() + "] 不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + // 验证关联Id的数据合法性 + CallResult callResult = + onlineDatasourceRelationService.verifyRelatedData(onlineDatasourceRelation, null); + if (!callResult.isSuccess()) { + errorMessage = callResult.getErrorMessage(); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + onlineDatasourceRelation = onlineDatasourceRelationService.saveNew(onlineDatasourceRelation, slaveTable, slaveColumn); + return ResponseResult.success(onlineDatasourceRelation.getRelationId()); + } + + /** + * 更新数据关联数据。 + * + * @param onlineDatasourceRelationDto 更新对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody OnlineDatasourceRelationDto onlineDatasourceRelationDto) { + String errorMessage = MyCommonUtil.getModelValidationError( + onlineDatasourceRelationDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineDatasourceRelation onlineDatasourceRelation = + MyModelUtil.copyTo(onlineDatasourceRelationDto, OnlineDatasourceRelation.class); + ResponseResult verifyResult = + this.doVerifyAndGet(onlineDatasourceRelation.getRelationId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDatasourceRelation originalOnlineDatasourceRelation = verifyResult.getData(); + if (!onlineDatasourceRelationDto.getRelationType().equals(originalOnlineDatasourceRelation.getRelationType())) { + errorMessage = "数据验证失败,不能修改关联类型!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!onlineDatasourceRelationDto.getSlaveTableId().equals(originalOnlineDatasourceRelation.getSlaveTableId())) { + errorMessage = "数据验证失败,不能修改从表Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!onlineDatasourceRelationDto.getDatasourceId().equals(originalOnlineDatasourceRelation.getDatasourceId())) { + errorMessage = "数据验证失败,不能修改数据源Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + // 验证关联Id的数据合法性 + CallResult callResult = onlineDatasourceRelationService + .verifyRelatedData(onlineDatasourceRelation, originalOnlineDatasourceRelation); + if (!callResult.isSuccess()) { + errorMessage = callResult.getErrorMessage(); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!onlineDatasourceRelationService.update(onlineDatasourceRelation, originalOnlineDatasourceRelation)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 删除数据关联数据。 + * + * @param relationId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long relationId) { + String errorMessage; + ResponseResult verifyResult = this.doVerifyAndGet(relationId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDatasourceRelation onlineDatasourceRelation = verifyResult.getData(); + OnlineVirtualColumn virtualColumnFilter = new OnlineVirtualColumn(); + virtualColumnFilter.setRelationId(relationId); + List virtualColumnList = + onlineVirtualColumnService.getOnlineVirtualColumnList(virtualColumnFilter, null); + if (CollUtil.isNotEmpty(virtualColumnList)) { + OnlineVirtualColumn virtualColumn = virtualColumnList.get(0); + errorMessage = "数据验证失败,数据源关联正在被虚拟字段 [" + virtualColumn.getColumnPrompt() + "] 使用,不能被删除!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + List formList = + onlineFormService.getOnlineFormListByTableId(onlineDatasourceRelation.getSlaveTableId()); + if (CollUtil.isNotEmpty(formList)) { + errorMessage = "数据验证失败,当前数据源关联正在被 [" + formList.get(0).getFormName() + "] 表单占用,请先删除关联数据!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!onlineDatasourceRelationService.remove(relationId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的数据关联列表。 + * + * @param onlineDatasourceRelationDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分 页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("onlinePage.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody OnlineDatasourceRelationDto onlineDatasourceRelationDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlineDatasourceRelation onlineDatasourceRelationFilter = + MyModelUtil.copyTo(onlineDatasourceRelationDtoFilter, OnlineDatasourceRelation.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineDatasourceRelation.class); + List onlineDatasourceRelationList = + onlineDatasourceRelationService.getOnlineDatasourceRelationListWithRelation(onlineDatasourceRelationFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(onlineDatasourceRelationList, OnlineDatasourceRelationVo.class)); + } + + /** + * 查看指定数据关联对象详情。 + * + * @param relationId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("onlinePage.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long relationId) { + ResponseResult verifyResult = this.doVerifyAndGet(relationId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDatasourceRelation onlineDatasourceRelation = + onlineDatasourceRelationService.getByIdWithRelation(relationId, MyRelationParam.full()); + return ResponseResult.success(onlineDatasourceRelation, OnlineDatasourceRelationVo.class); + } + + private ResponseResult doVerifyAndGet(Long relationId) { + String errorMessage; + if (MyCommonUtil.existBlankArgument(relationId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + OnlineDatasourceRelation relation = + onlineDatasourceRelationService.getByIdWithRelation(relationId, MyRelationParam.full()); + if (relation == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + if (!StrUtil.equals(relation.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + errorMessage = "数据验证失败,当前应用不包含该数据源关联!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(relation); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDblinkController.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDblinkController.java new file mode 100644 index 00000000..60447f1e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDblinkController.java @@ -0,0 +1,276 @@ +package com.orangeforms.common.online.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import io.swagger.v3.oas.annotations.tags.Tag; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.dbutil.object.SqlTable; +import com.orangeforms.common.dbutil.object.SqlTableColumn; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.online.dto.OnlineDblinkDto; +import com.orangeforms.common.online.model.OnlineDblink; +import com.orangeforms.common.online.service.OnlineDblinkService; +import com.orangeforms.common.online.util.OnlineDataSourceUtil; +import com.orangeforms.common.online.vo.OnlineDblinkVo; +import com.github.pagehelper.page.PageMethod; +import lombok.extern.slf4j.Slf4j; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +/** + * 在线表单数据库链接接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "在线表单数据库链接接口") +@Slf4j +@RestController +@RequestMapping("${common-online.urlPrefix}/onlineDblink") +@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true") +public class OnlineDblinkController { + + @Autowired + private OnlineDblinkService onlineDblinkService; + @Autowired + private OnlineDataSourceUtil dataSourceUtil; + + /** + * 新增数据库链接数据。 + * + * @param onlineDblinkDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @SaCheckPermission("onlineDblink.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody OnlineDblinkDto onlineDblinkDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineDblinkDto, false); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineDblink onlineDblink = MyModelUtil.copyTo(onlineDblinkDto, OnlineDblink.class); + onlineDblink = onlineDblinkService.saveNew(onlineDblink); + return ResponseResult.success(onlineDblink.getDblinkId()); + } + + /** + * 更新数据库链接数据。 + * + * @param onlineDblinkDto 更新对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlineDblink.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody OnlineDblinkDto onlineDblinkDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineDblinkDto, true); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineDblink onlineDblink = MyModelUtil.copyTo(onlineDblinkDto, OnlineDblink.class); + ResponseResult verifyResult = this.doVerifyAndGet(onlineDblinkDto.getDblinkId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDblink originalOnlineDblink = verifyResult.getData(); + if (ObjectUtil.notEqual(onlineDblink.getDblinkType(), originalOnlineDblink.getDblinkType())) { + errorMessage = "数据验证失败,不能修改数据库类型!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + String passwdKey = "password"; + JSONObject configJson = JSON.parseObject(onlineDblink.getConfiguration()); + String password = configJson.getString(passwdKey); + if (StrUtil.isNotBlank(password) && StrUtil.isAllCharMatch(password, c -> '*' == c)) { + password = JSON.parseObject(originalOnlineDblink.getConfiguration()).getString(passwdKey); + configJson.put(passwdKey, password); + onlineDblink.setConfiguration(configJson.toJSONString()); + } + if (!onlineDblinkService.update(onlineDblink, originalOnlineDblink)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 删除数据库链接数据。 + * + * @param dblinkId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlineDblink.all") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long dblinkId) { + String errorMessage; + // 验证关联Id的数据合法性 + ResponseResult verifyResult = this.doVerifyAndGet(dblinkId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (!onlineDblinkService.remove(dblinkId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的数据库链接列表。 + * + * @param onlineDblinkDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("onlineDblink.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody OnlineDblinkDto onlineDblinkDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlineDblink onlineDblinkFilter = MyModelUtil.copyTo(onlineDblinkDtoFilter, OnlineDblink.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineDblink.class); + List onlineDblinkList = + onlineDblinkService.getOnlineDblinkListWithRelation(onlineDblinkFilter, orderBy); + for (OnlineDblink dblink : onlineDblinkList) { + this.maskOffPassword(dblink); + } + return ResponseResult.success(MyPageUtil.makeResponseData(onlineDblinkList, OnlineDblinkVo.class)); + } + + /** + * 查看指定数据库链接对象详情。 + * + * @param dblinkId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("onlineDblink.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long dblinkId) { + ResponseResult verifyResult = this.doVerifyAndGet(dblinkId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDblink onlineDblink = verifyResult.getData(); + onlineDblinkService.buildRelationForData(onlineDblink, MyRelationParam.full()); + if (!StrUtil.equals(onlineDblink.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, "数据验证失败,当前应用并不存在该数据库链接!"); + } + this.maskOffPassword(onlineDblink); + return ResponseResult.success(onlineDblink, OnlineDblinkVo.class); + } + + /** + * 获取指定数据库链接下的所有动态表单依赖的数据表列表。 + * + * @param dblinkId 数据库链接Id。 + * @return 所有动态表单依赖的数据表列表 + */ + @SaCheckPermission("onlineDblink.all") + @GetMapping("/listDblinkTables") + public ResponseResult> listDblinkTables(@RequestParam Long dblinkId) { + OnlineDblink dblink = onlineDblinkService.getById(dblinkId); + if (dblink == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(onlineDblinkService.getDblinkTableList(dblink)); + } + + /** + * 获取指定数据库链接下,指定数据表的所有字段信息。 + * + * @param dblinkId 数据库链接Id。 + * @param tableName 表名。 + * @return 该表的所有字段列表。 + */ + @SaCheckPermission("onlineDblink.all") + @GetMapping("/listDblinkTableColumns") + public ResponseResult> listDblinkTableColumns( + @RequestParam Long dblinkId, @RequestParam String tableName) { + OnlineDblink dblink = onlineDblinkService.getById(dblinkId); + if (dblink == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(onlineDblinkService.getDblinkTableColumnList(dblink, tableName)); + } + + /** + * 测试数据库链接的接口。 + * + * @return 应答结果。 + */ + @GetMapping("/testConnection") + public ResponseResult testConnection(@RequestParam Long dblinkId) { + ResponseResult verifyAndGet = this.doVerifyAndGet(dblinkId); + if (!verifyAndGet.isSuccess()) { + return ResponseResult.errorFrom(verifyAndGet); + } + try { + dataSourceUtil.testConnection(dblinkId); + return ResponseResult.success(); + } catch (Exception e) { + log.error("Failed to test connection with ONLINE_DBLINK_ID [" + dblinkId + "]!", e); + return ResponseResult.error(ErrorCodeEnum.DATA_ACCESS_FAILED, "数据库连接失败!"); + } + } + + /** + * 以字典形式返回全部数据库链接数据集合。字典的键值为[dblinkId, dblinkName]。 + * 白名单接口,登录用户均可访问。 + * + * @param filter 过滤对象。 + * @return 应答结果对象,包含的数据为 List>,map中包含两条记录,key的值分别是id和name,value对应具体数据。 + */ + @GetMapping("/listDict") + public ResponseResult>> listDict(@ParameterObject OnlineDblinkDto filter) { + List resultList = + onlineDblinkService.getOnlineDblinkList(MyModelUtil.copyTo(filter, OnlineDblink.class), null); + return ResponseResult.success( + MyCommonUtil.toDictDataList(resultList, OnlineDblink::getDblinkId, OnlineDblink::getDblinkName)); + } + + private ResponseResult doVerifyAndGet(Long dblinkId) { + if (MyCommonUtil.existBlankArgument(dblinkId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + OnlineDblink onlineDblink = onlineDblinkService.getById(dblinkId); + if (onlineDblink == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + if (!StrUtil.equals(onlineDblink.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + return ResponseResult.error( + ErrorCodeEnum.DATA_VALIDATED_FAILED, "数据验证失败,当前应用并不存在该数据库链接!"); + } + return ResponseResult.success(onlineDblink); + } + + private void maskOffPassword(OnlineDblink dblink) { + String passwdKey = "password"; + JSONObject configJson = JSON.parseObject(dblink.getConfiguration()); + if (configJson.containsKey(passwdKey)) { + String password = configJson.getString(passwdKey); + if (StrUtil.isNotBlank(password)) { + configJson.put(passwdKey, StrUtil.repeat('*', password.length())); + dblink.setConfiguration(configJson.toJSONString()); + } + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDictController.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDictController.java new file mode 100644 index 00000000..3b31c21b --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDictController.java @@ -0,0 +1,221 @@ +package com.orangeforms.common.online.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.dict.dto.GlobalDictDto; +import com.orangeforms.common.dict.util.GlobalDictOperationHelper; +import com.orangeforms.common.dict.vo.GlobalDictVo; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.online.dto.OnlineDictDto; +import com.orangeforms.common.online.model.OnlineColumn; +import com.orangeforms.common.online.model.OnlineDict; +import com.orangeforms.common.online.model.OnlineTable; +import com.orangeforms.common.online.service.OnlineColumnService; +import com.orangeforms.common.online.service.OnlineTableService; +import com.orangeforms.common.online.service.OnlineDictService; +import com.orangeforms.common.online.vo.OnlineDictVo; +import com.github.pagehelper.page.PageMethod; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import java.util.List; + +/** + * 在线表单字典接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "在线表单字典接口") +@Slf4j +@RestController +@RequestMapping("${common-online.urlPrefix}/onlineDict") +@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true") +public class OnlineDictController { + + @Autowired + private OnlineDictService onlineDictService; + @Autowired + private OnlineColumnService onlineColumnService; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private GlobalDictOperationHelper globalDictOperationHelper; + + /** + * 新增在线表单字典数据。 + * + * @param onlineDictDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"onlineDictDto.dictId"}) + @SaCheckPermission("onlineDict.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody OnlineDictDto onlineDictDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineDictDto); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineDict onlineDict = MyModelUtil.copyTo(onlineDictDto, OnlineDict.class); + // 验证关联Id的数据合法性 + CallResult callResult = onlineDictService.verifyRelatedData(onlineDict, null); + if (!callResult.isSuccess()) { + errorMessage = callResult.getErrorMessage(); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + onlineDict = onlineDictService.saveNew(onlineDict); + return ResponseResult.success(onlineDict.getDictId()); + } + + /** + * 更新在线表单字典数据。 + * + * @param onlineDictDto 更新对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlineDict.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody OnlineDictDto onlineDictDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineDictDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineDict onlineDict = MyModelUtil.copyTo(onlineDictDto, OnlineDict.class); + ResponseResult verifyResult = this.doVerifyAndGet(onlineDict.getDictId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDict originalOnlineDict = verifyResult.getData(); + // 验证关联Id的数据合法性 + CallResult callResult = onlineDictService.verifyRelatedData(onlineDict, originalOnlineDict); + if (!callResult.isSuccess()) { + errorMessage = callResult.getErrorMessage(); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!onlineDictService.update(onlineDict, originalOnlineDict)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 删除在线表单字典数据。 + * + * @param dictId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlineDict.all") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long dictId) { + String errorMessage; + ResponseResult verifyResult = this.doVerifyAndGet(dictId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineColumn filter = new OnlineColumn(); + filter.setDictId(dictId); + List columns = onlineColumnService.getListByFilter(filter); + if (CollUtil.isNotEmpty(columns)) { + OnlineColumn usingColumn = columns.get(0); + OnlineTable table = onlineTableService.getById(usingColumn.getTableId()); + errorMessage = String.format("数据验证失败,数据表 [%s] 字段 [%s] 正在引用该字典,因此不能直接删除!", + table.getTableName(), usingColumn.getColumnName()); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!onlineDictService.remove(dictId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的在线表单字典列表。 + * + * @param onlineDictDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("onlineDict.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody OnlineDictDto onlineDictDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlineDict onlineDictFilter = MyModelUtil.copyTo(onlineDictDtoFilter, OnlineDict.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineDict.class); + List onlineDictList = onlineDictService.getOnlineDictListWithRelation(onlineDictFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(onlineDictList, OnlineDictVo.class)); + } + + /** + * 查看指定在线表单字典对象详情。 + * + * @param dictId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("onlineDict.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long dictId) { + ResponseResult verifyResult = this.doVerifyAndGet(dictId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDict onlineDict = onlineDictService.getByIdWithRelation(dictId, MyRelationParam.full()); + if (onlineDict == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(onlineDict, OnlineDictVo.class); + } + + /** + * 获取全部编码字典列表。 + * NOTE: 白名单接口。 + * + * @param globalDictDtoFilter 过滤对象。 + * @param pageParam 分页参数。 + * @return 字典的数据列表。 + */ + @PostMapping("/listAllGlobalDict") + public ResponseResult> listAllGlobalDict( + @MyRequestBody GlobalDictDto globalDictDtoFilter, + @MyRequestBody MyPageParam pageParam) { + return globalDictOperationHelper.listAllGlobalDict(globalDictDtoFilter, pageParam); + } + + private ResponseResult doVerifyAndGet(Long dictId) { + if (MyCommonUtil.existBlankArgument(dictId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + OnlineDict originalDict = onlineDictService.getById(dictId); + if (originalDict == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + if (!StrUtil.equals(originalDict.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + return ResponseResult.error( + ErrorCodeEnum.DATA_VALIDATED_FAILED, "数据验证失败,当前应用不存在该在线表单字典!"); + } + return ResponseResult.success(originalDict); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineFormController.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineFormController.java new file mode 100644 index 00000000..921ffee7 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineFormController.java @@ -0,0 +1,428 @@ +package com.orangeforms.common.online.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.cache.CacheConfig; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.online.config.OnlineProperties; +import com.orangeforms.common.online.dto.OnlineFormDto; +import com.orangeforms.common.online.model.*; +import com.orangeforms.common.online.service.*; +import com.orangeforms.common.online.vo.OnlineFormVo; +import com.github.pagehelper.page.PageMethod; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.util.Assert; +import org.springframework.web.bind.annotation.*; + +import jakarta.annotation.Resource; +import jakarta.validation.groups.Default; +import java.util.HashSet; +import java.util.List; +import java.util.LinkedList; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 在线表单表单接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "在线表单表单接口") +@Slf4j +@RestController +@RequestMapping("${common-online.urlPrefix}/onlineForm") +@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true") +public class OnlineFormController { + + @Autowired + private OnlineFormService onlineFormService; + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private OnlineDatasourceRelationService onlineDatasourceRelationService; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private OnlineColumnService onlineColumnService; + @Autowired + private OnlineVirtualColumnService onlineVirtualColumnService; + @Autowired + private OnlineDictService onlineDictService; + @Autowired + private OnlineRuleService onlineRuleService; + @Autowired + private OnlineProperties properties; + @Resource(name = "caffeineCacheManager") + private CacheManager cacheManager; + + /** + * 新增在线表单数据。 + * + * @param onlineFormDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"onlineFormDto.formId"}) + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody OnlineFormDto onlineFormDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineFormDto); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineForm onlineForm = MyModelUtil.copyTo(onlineFormDto, OnlineForm.class); + if (onlineFormService.existByFormCode(onlineForm.getFormCode())) { + errorMessage = "数据验证失败,表单编码已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage); + } + // 验证关联Id的数据合法性 + CallResult callResult = onlineFormService.verifyRelatedData(onlineForm, null); + if (!callResult.isSuccess()) { + errorMessage = callResult.getErrorMessage(); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + Set datasourceIdSet = null; + if (CollUtil.isNotEmpty(onlineFormDto.getDatasourceIdList())) { + ResponseResult> verifyDatasourceIdsResult = + this.doVerifyDatasourceIdsAndGet(onlineFormDto.getDatasourceIdList()); + if (!verifyDatasourceIdsResult.isSuccess()) { + return ResponseResult.errorFrom(verifyDatasourceIdsResult); + } + datasourceIdSet = verifyDatasourceIdsResult.getData(); + } + onlineForm = onlineFormService.saveNew(onlineForm, datasourceIdSet); + return ResponseResult.success(onlineForm.getFormId()); + } + + /** + * 更新在线表单数据。 + * + * @param onlineFormDto 更新对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody OnlineFormDto onlineFormDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineFormDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineForm onlineForm = MyModelUtil.copyTo(onlineFormDto, OnlineForm.class); + ResponseResult verifyResult = this.doVerifyAndGet(onlineForm.getFormId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineForm originalOnlineForm = verifyResult.getData(); + // 验证关联Id的数据合法性 + CallResult callResult = onlineFormService.verifyRelatedData(onlineForm, originalOnlineForm); + if (!callResult.isSuccess()) { + errorMessage = callResult.getErrorMessage(); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!StrUtil.equals(onlineForm.getFormCode(), originalOnlineForm.getFormCode()) + && onlineFormService.existByFormCode(onlineForm.getFormCode())) { + errorMessage = "数据验证失败,表单编码已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage); + } + Set datasourceIdSet = null; + if (CollUtil.isNotEmpty(onlineFormDto.getDatasourceIdList())) { + ResponseResult> verifyDatasourceIdsResult = + this.doVerifyDatasourceIdsAndGet(onlineFormDto.getDatasourceIdList()); + if (!verifyDatasourceIdsResult.isSuccess()) { + return ResponseResult.errorFrom(verifyDatasourceIdsResult); + } + datasourceIdSet = verifyDatasourceIdsResult.getData(); + } + if (!onlineFormService.update(onlineForm, originalOnlineForm, datasourceIdSet)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 删除在线表单数据。 + * + * @param formId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long formId) { + String errorMessage; + ResponseResult verifyResult = this.doVerifyAndGet(formId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (!onlineFormService.remove(formId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 克隆一个在线表单对象。 + * + * @param formId 源表单主键Id。 + * @return 新克隆表单主键Id。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/clone") + public ResponseResult clone(@MyRequestBody Long formId) { + ResponseResult verifyResult = this.doVerifyAndGet(formId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineForm form = verifyResult.getData(); + form.setFormName(form.getFormName() + "_copy"); + form.setFormCode(form.getFormCode() + "_copy_" + System.currentTimeMillis()); + List formDatasourceList = onlineFormService.getFormDatasourceListFromCache(formId); + Set datasourceIdSet = formDatasourceList.stream() + .map(OnlineFormDatasource::getDatasourceId).collect(Collectors.toSet()); + onlineFormService.saveNew(form, datasourceIdSet); + return ResponseResult.success(form.getFormId()); + } + + /** + * 列出符合过滤条件的在线表单列表。 + * + * @param onlineFormDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("onlinePage.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody OnlineFormDto onlineFormDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlineForm onlineFormFilter = MyModelUtil.copyTo(onlineFormDtoFilter, OnlineForm.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineForm.class); + List onlineFormList = + onlineFormService.getOnlineFormListWithRelation(onlineFormFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(onlineFormList, OnlineFormVo.class)); + } + + /** + * 查看指定在线表单对象详情。 + * + * @param formId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("onlinePage.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long formId) { + ResponseResult verifyResult = this.doVerifyAndGet(formId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineForm onlineForm = onlineFormService.getByIdWithRelation(formId, MyRelationParam.full()); + OnlineFormVo onlineFormVo = MyModelUtil.copyTo(onlineForm, OnlineFormVo.class); + List formDatasourceList = onlineFormService.getFormDatasourceListFromCache(formId); + if (CollUtil.isNotEmpty(formDatasourceList)) { + onlineFormVo.setDatasourceIdList(formDatasourceList.stream() + .map(OnlineFormDatasource::getDatasourceId).collect(Collectors.toList())); + } + return ResponseResult.success(onlineFormVo); + } + + /** + * 获取指定在线表单对象在前端渲染时所需的所有数据对象。 + * + * @param formId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @GetMapping("/render") + public ResponseResult render(@RequestParam Long formId) { + String errorMessage; + Cache cache = null; + if (BooleanUtil.isTrue(properties.getEnableRenderCache())) { + cache = cacheManager.getCache(CacheConfig.CacheEnum.ONLINE_FORM_RENDER_CACCHE.name()); + Assert.notNull(cache, "Cache ONLINE_FORM_RENDER_CACCHE can't be NULL"); + JSONObject responseData = cache.get(formId, JSONObject.class); + if (responseData != null) { + Object appCode = responseData.get("appCode"); + if (ObjectUtil.notEqual(appCode, TokenData.takeFromRequest().getAppCode())) { + errorMessage = "数据验证失败,当前应用不包含该表单Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(responseData); + } + } + OnlineForm onlineForm = onlineFormService.getOnlineFormFromCache(formId); + if (onlineForm == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + OnlineFormVo onlineFormVo = MyModelUtil.copyTo(onlineForm, OnlineFormVo.class); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("onlineForm", onlineFormVo); + List formDatasourceList = onlineFormService.getFormDatasourceListFromCache(formId); + if (CollUtil.isEmpty(formDatasourceList)) { + return ResponseResult.success(jsonObject); + } + Set datasourceIdSet = formDatasourceList.stream() + .map(OnlineFormDatasource::getDatasourceId).collect(Collectors.toSet()); + List onlineDatasourceList = + onlineDatasourceService.getOnlineDatasourceListFromCache(datasourceIdSet); + jsonObject.put("onlineDatasourceList", onlineDatasourceList); + Set tableIdSet = onlineDatasourceList.stream() + .map(OnlineDatasource::getMasterTableId).collect(Collectors.toSet()); + List onlineDatasourceRelationList = + onlineDatasourceRelationService.getOnlineDatasourceRelationListFromCache(datasourceIdSet); + if (CollUtil.isNotEmpty(onlineDatasourceRelationList)) { + jsonObject.put("onlineDatasourceRelationList", onlineDatasourceRelationList); + tableIdSet.addAll(onlineDatasourceRelationList.stream() + .map(OnlineDatasourceRelation::getSlaveTableId).collect(Collectors.toList())); + } + List onlineTableList = new LinkedList<>(); + List onlineColumnList = new LinkedList<>(); + for (Long tableId : tableIdSet) { + OnlineTable table = onlineTableService.getOnlineTableFromCache(tableId); + onlineTableList.add(table); + onlineColumnList.addAll(table.getColumnMap().values()); + table.setColumnMap(null); + } + jsonObject.put("onlineTableList", onlineTableList); + jsonObject.put("onlineColumnList", onlineColumnList); + List virtualColumnList = + onlineVirtualColumnService.getOnlineVirtualColumnListByTableIds(tableIdSet); + jsonObject.put("onlineVirtualColumnList", virtualColumnList); + Set dictIdSet = onlineColumnList.stream() + .filter(c -> c.getDictId() != null).map(OnlineColumn::getDictId).collect(Collectors.toSet()); + Set widgetDictIdSet = this.extractDictIdSetFromWidgetJson(onlineForm.getWidgetJson()); + CollUtil.addAll(dictIdSet, widgetDictIdSet); + if (CollUtil.isNotEmpty(dictIdSet)) { + List onlineDictList = onlineDictService.getOnlineDictListFromCache(dictIdSet); + if (onlineDictList.size() != dictIdSet.size()) { + Set columnDictIdSet = onlineDictList.stream().map(OnlineDict::getDictId).collect(Collectors.toSet()); + Long notExistDictId = this.findNotExistDictId(dictIdSet, columnDictIdSet); + Assert.notNull(notExistDictId, "notExistDictId can't be NULL"); + errorMessage = String.format("数据验证失败,字典Id [%s] 不存在!", notExistDictId); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + jsonObject.put("onlineDictList", onlineDictList); + } + Set columnIdSet = onlineColumnList.stream().map(OnlineColumn::getColumnId).collect(Collectors.toSet()); + List colunmRuleList = onlineRuleService.getOnlineColumnRuleListByColumnIds(columnIdSet); + if (CollUtil.isNotEmpty(colunmRuleList)) { + jsonObject.put("onlineColumnRuleList", colunmRuleList); + } + jsonObject.put("appCode", TokenData.takeFromRequest().getAppCode()); + if (BooleanUtil.isTrue(properties.getEnableRenderCache())) { + Assert.notNull(cache, "Cache ONLINE_FORM_RENDER_CACCHE can't be NULL"); + cache.put(formId, jsonObject); + } + return ResponseResult.success(jsonObject); + } + + private Long findNotExistDictId(Set originalDictIdSet, Set dictIdSet) { + return originalDictIdSet.stream().filter(d -> !dictIdSet.contains(d)).findFirst().orElse(null); + } + + private ResponseResult doVerifyAndGet(Long formId) { + String errorMessage; + if (MyCommonUtil.existBlankArgument(formId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + // 验证关联Id的数据合法性 + OnlineForm form = onlineFormService.getById(formId); + if (form == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + if (!StrUtil.equals(form.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + errorMessage = "数据验证失败,当前应用不包含该表单!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (ObjectUtil.notEqual(form.getTenantId(), TokenData.takeFromRequest().getTenantId())) { + errorMessage = "数据验证失败,当前租户不包含该表单!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(form); + } + + private ResponseResult> doVerifyDatasourceIdsAndGet(List datasourceIdList) { + String errorMessage; + Set datasourceIdSet = new HashSet<>(datasourceIdList); + List datasourceList = onlineDatasourceService.getInList(datasourceIdSet); + if (datasourceIdSet.size() != datasourceList.size()) { + errorMessage = "数据验证失败,当前在线表单包含不存在的数据源Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + String appCode = TokenData.takeFromRequest().getAppCode(); + for (OnlineDatasource datasource : datasourceList) { + if (!StrUtil.equals(datasource.getAppCode(), appCode)) { + errorMessage = "数据验证失败,存在不是当前应用的数据源!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + return ResponseResult.success(datasourceIdSet); + } + + private Set extractDictIdSetFromWidgetJson(String widgetJson) { + Set dictIdSet = new HashSet<>(); + if (StrUtil.isBlank(widgetJson)) { + return dictIdSet; + } + JSONObject allData = JSON.parseObject(widgetJson); + JSONObject pcData = allData.getJSONObject("pc"); + if (MapUtil.isEmpty(pcData)) { + return dictIdSet; + } + JSONArray widgetListArray = pcData.getJSONArray("widgetList"); + if (CollUtil.isEmpty(widgetListArray)) { + return dictIdSet; + } + for (int i = 0; i < widgetListArray.size(); i++) { + this.recursiveExtractDictId(widgetListArray.getJSONObject(i), dictIdSet); + } + return dictIdSet; + } + + private void recursiveExtractDictId(JSONObject widgetData, Set dictIdSet) { + JSONObject propsData = widgetData.getJSONObject("props"); + if (MapUtil.isNotEmpty(propsData)) { + JSONObject dictInfoData = propsData.getJSONObject("dictInfo"); + if (MapUtil.isNotEmpty(dictInfoData)) { + Long dictId = dictInfoData.getLong("dictId"); + if (dictId != null) { + dictIdSet.add(dictId); + } + } + } + JSONArray childWidgetArray = widgetData.getJSONArray("childWidgetList"); + if (CollUtil.isNotEmpty(childWidgetArray)) { + for (int i = 0; i < childWidgetArray.size(); i++) { + this.recursiveExtractDictId(childWidgetArray.getJSONObject(i), dictIdSet); + } + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineOperationController.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineOperationController.java new file mode 100644 index 00000000..64786ae1 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineOperationController.java @@ -0,0 +1,1044 @@ +package com.orangeforms.common.online.controller; + +import io.swagger.v3.oas.annotations.tags.Tag; +import cn.hutool.core.text.StrFormatter; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.*; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.constant.DictType; +import com.orangeforms.common.core.constant.ObjectFieldType; +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.*; +import com.orangeforms.common.dict.model.GlobalDictItem; +import com.orangeforms.common.dict.service.GlobalDictService; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.redis.cache.SessionCacheHelper; +import com.orangeforms.common.redis.util.CommonRedisUtil; +import com.orangeforms.common.online.config.OnlineProperties; +import com.orangeforms.common.online.exception.OnlineRuntimeException; +import com.orangeforms.common.online.util.OnlineOperationHelper; +import com.orangeforms.common.online.util.OnlineConstant; +import com.orangeforms.common.online.dto.OnlineFilterDto; +import com.orangeforms.common.online.model.*; +import com.orangeforms.common.online.model.constant.FieldKind; +import com.orangeforms.common.online.model.constant.RelationType; +import com.orangeforms.common.online.model.constant.FieldFilterType; +import com.orangeforms.common.online.service.*; +import com.orangeforms.common.satoken.annotation.SaTokenDenyAuth; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.joda.time.DateTime; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import jakarta.servlet.http.HttpServletResponse; + +import java.io.IOException; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 在线表单数据操作接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "在线表单数据操作接口") +@Slf4j +@RestController +@RequestMapping("${common-online.urlPrefix}/onlineOperation") +@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true") +public class OnlineOperationController { + + @Autowired + private OnlineOperationService onlineOperationService; + @Autowired + private OnlineDictService onlineDictService; + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private OnlineDatasourceRelationService onlineDatasourceRelationService; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private OnlineOperationHelper onlineOperationHelper; + @Autowired + private OnlineVirtualColumnService onlineVirtualColumnService; + @Autowired + private OnlineProperties onlineProperties; + @Autowired + private GlobalDictService globalDictService; + @Autowired + private CommonRedisUtil commonRedisUtil; + @Autowired + private SessionCacheHelper sessionCacheHelper; + + /** + * 新增数据接口。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 主表的数据源Id。 + * @param masterData 主表新增数据。 + * @param slaveData 一对多从表新增数据列表。 + * @return 应答结果。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/addDatasource/{datasourceVariableName}") + public ResponseResult addDatasource( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody(required = true) JSONObject masterData, + @MyRequestBody JSONObject slaveData) { + // 验证数据源的合法性,同时获取主表对象。 + ResponseResult datasourceResult = onlineOperationHelper.verifyAndGetDatasource(datasourceId); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + OnlineDatasource datasource = datasourceResult.getData(); + if (!datasource.getVariableName().equals(datasourceVariableName)) { + ContextUtil.getHttpResponse().setStatus(HttpServletResponse.SC_FORBIDDEN); + return ResponseResult.error(ErrorCodeEnum.NO_OPERATION_PERMISSION); + } + OnlineTable masterTable = datasource.getMasterTable(); + if (slaveData == null) { + onlineOperationService.saveNew(masterTable, masterData); + } else { + ResponseResult>> slaveDataListResult = + onlineOperationHelper.buildSlaveDataList(datasourceId, slaveData); + if (!slaveDataListResult.isSuccess()) { + return ResponseResult.errorFrom(slaveDataListResult); + } + onlineOperationService.saveNewWithRelation(masterTable, masterData, slaveDataListResult.getData()); + } + return ResponseResult.success(); + } + + /** + * 新增一对多从表数据接口。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 主表的数据源Id。 + * @param relationId 一对多的关联Id。 + * @param slaveData 一对多从表的新增数据列表。 + * @return 应答结果。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/addOneToManyRelation/{datasourceVariableName}") + public ResponseResult addOneToManyRelation( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody(required = true) Long relationId, + @MyRequestBody(required = true) JSONObject slaveData) { + ResponseResult verifyResult = + this.doVerifyAndGetRelation(datasourceId, datasourceVariableName, relationId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDatasourceRelation relation = verifyResult.getData(); + onlineOperationService.saveNew(relation.getSlaveTable(), slaveData); + return ResponseResult.success(); + } + + /** + * 更新主数据接口。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 主表数据源Id。 + * @param masterData 表数据。这里没有包含的字段将视为NULL。 + * @param slaveData 从表数据,key是relationId。 + * @return 应该结果。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/updateDatasource/{datasourceVariableName}") + public ResponseResult updateDatasource( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody(required = true) JSONObject masterData, + @MyRequestBody JSONObject slaveData) { + ResponseResult datasourceResult = + onlineOperationHelper.verifyAndGetDatasource(datasourceId); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + OnlineDatasource datasource = datasourceResult.getData(); + if (!datasource.getVariableName().equals(datasourceVariableName)) { + ContextUtil.getHttpResponse().setStatus(HttpServletResponse.SC_FORBIDDEN); + return ResponseResult.error(ErrorCodeEnum.NO_OPERATION_PERMISSION); + } + OnlineTable masterTable = datasource.getMasterTable(); + if (slaveData == null) { + if (!onlineOperationService.update(masterTable, masterData)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + } else { + ResponseResult>> slaveDataListResult = + onlineOperationHelper.buildSlaveDataList(datasourceId, slaveData); + if (!slaveDataListResult.isSuccess()) { + return ResponseResult.errorFrom(slaveDataListResult); + } + onlineOperationService.updateWithRelation( + masterTable, masterData, datasourceId, slaveDataListResult.getData()); + } + return ResponseResult.success(); + } + + /** + * 更新一对多关联数据接口。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 主表数据源Id。 + * @param relationId 一对多关联Id。 + * @param slaveData 一对多关联从表数据。这里没有包含的字段将视为NULL。 + * @return 应该结果。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/updateOneToManyRelation/{datasourceVariableName}") + public ResponseResult updateOneToManyRelation( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody(required = true) Long relationId, + @MyRequestBody(required = true) JSONObject slaveData) { + ResponseResult verifyResult = + this.doVerifyAndGetRelation(datasourceId, datasourceVariableName, relationId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineTable slaveTable = verifyResult.getData().getSlaveTable(); + if (!onlineOperationService.update(slaveTable, slaveData)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 删除主数据接口。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 主表数据源Id。 + * @param dataId 待删除的数据表主键Id。 + * @return 应该结果。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/deleteDatasource/{datasourceVariableName}") + public ResponseResult deleteDatasource( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody(required = true) String dataId) { + return this.doDelete(datasourceVariableName, datasourceId, CollUtil.newArrayList(dataId)); + } + + /** + * 批量删除主数据接口。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 主表数据源Id。 + * @param dataIdList 待删除的数据表主键Id列表。 + * @return 应该结果。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.DELETE_BATCH) + @PostMapping("/deleteBatchDatasource/{datasourceVariableName}") + public ResponseResult deleteBatchDatasource( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody(required = true) List dataIdList) { + return this.doDelete(datasourceVariableName, datasourceId, dataIdList); + } + + /** + * 删除一对多关联表单条数据接口。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 主表数据源Id。 + * @param relationId 一对多关联Id。 + * @param dataId 一对多关联表主键Id。 + * @return 应该结果。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/deleteOneToManyRelation/{datasourceVariableName}") + public ResponseResult deleteOneToManyRelation( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody(required = true) Long relationId, + @MyRequestBody(required = true) String dataId) { + return this.doDelete(datasourceVariableName, datasourceId, relationId, CollUtil.newArrayList(dataId)); + } + + /** + * 批量删除一对多关联表单条数据接口。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 主表数据源Id。 + * @param relationId 一对多关联Id。 + * @param dataIdList 一对多关联表主键Id列表。 + * @return 应该结果。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.DELETE_BATCH) + @PostMapping("/deleteBatchOneToManyRelation/{datasourceVariableName}") + public ResponseResult deleteBatchOneToManyRelation( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody(required = true) Long relationId, + @MyRequestBody(required = true) List dataIdList) { + return this.doDelete(datasourceVariableName, datasourceId, relationId, dataIdList); + } + + /** + * 根据数据源Id为动态表单查询数据详情。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 数据源Id。 + * @param dataId 数据主键Id。 + * @return 详情结果。 + */ + @SaTokenDenyAuth + @GetMapping("/viewByDatasourceId/{datasourceVariableName}") + public ResponseResult> viewByDatasourceId( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @RequestParam Long datasourceId, + @RequestParam String dataId) { + // 验证数据源及其关联 + ResponseResult datasourceResult = + this.doVerifyAndGetDatasource(datasourceId, datasourceVariableName); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + OnlineDatasource datasource = datasourceResult.getData(); + ResponseResult> relationListResult = + onlineOperationHelper.verifyAndGetRelationList(datasourceId, null); + if (!relationListResult.isSuccess()) { + return ResponseResult.errorFrom(relationListResult); + } + List allRelationList = relationListResult.getData(); + List oneToOneRelationList = allRelationList.stream() + .filter(r -> r.getRelationType().equals(RelationType.ONE_TO_ONE)).collect(Collectors.toList()); + Map result = onlineOperationService.getMasterData( + datasource.getMasterTable(), oneToOneRelationList, allRelationList, dataId); + return ResponseResult.success(result); + } + + /** + * 根据数据源关联Id为动态表单查询数据详情。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 数据源Id。 + * @param relationId 一对多关联Id。 + * @param dataId 一对多关联数据主键Id。 + * @return 详情结果。 + */ + @SaTokenDenyAuth + @GetMapping("/viewByOneToManyRelationId/{datasourceVariableName}") + public ResponseResult> viewByOneToManyRelationId( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @RequestParam Long datasourceId, + @RequestParam Long relationId, + @RequestParam String dataId) { + ResponseResult verifyResult = + this.doVerifyAndGetRelation(datasourceId, datasourceVariableName, relationId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + Map result = onlineOperationService.getSlaveData(verifyResult.getData(), dataId); + return ResponseResult.success(result); + } + + /** + * 为数据源主表字段下载文件。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 数据源Id。 + * @param dataId 附件所在记录的主键Id。 + * @param fieldName 数据表字段名。 + * @param asImage 是否为图片文件。 + * @param response Http 应答对象。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.DOWNLOAD, saveResponse = false) + @GetMapping("/downloadDatasource/{datasourceVariableName}") + public void downloadDatasource( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @RequestParam Long datasourceId, + @RequestParam(required = false) String dataId, + @RequestParam String fieldName, + @RequestParam String filename, + @RequestParam Boolean asImage, + HttpServletResponse response) throws IOException { + if (MyCommonUtil.existBlankArgument(fieldName, filename, asImage)) { + response.setStatus(HttpServletResponse.SC_BAD_REQUEST); + return; + } + ResponseResult datasourceResult = + onlineOperationHelper.verifyAndGetDatasource(datasourceId); + if (!datasourceResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, ResponseResult.errorFrom(datasourceResult)); + return; + } + OnlineDatasource datasource = datasourceResult.getData(); + if (!datasource.getVariableName().equals(datasourceVariableName)) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, + ResponseResult.error(ErrorCodeEnum.NO_OPERATION_PERMISSION)); + return; + } + OnlineTable masterTable = datasource.getMasterTable(); + onlineOperationHelper.doDownload(masterTable, dataId, fieldName, filename, asImage, response); + } + + /** + * 为数据源一对多关联的从表字段下载文件。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 数据源Id。 + * @param relationId 数据源的一对多关联Id。 + * @param dataId 附件所在记录的主键Id。 + * @param fieldName 数据表字段名。 + * @param asImage 是否为图片文件。 + * @param response Http 应答对象。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.DOWNLOAD, saveResponse = false) + @GetMapping("/downloadOneToManyRelation/{datasourceVariableName}") + public void downloadOneToManyRelation( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @RequestParam Long datasourceId, + @RequestParam Long relationId, + @RequestParam(required = false) String dataId, + @RequestParam String fieldName, + @RequestParam String filename, + @RequestParam Boolean asImage, + HttpServletResponse response) throws IOException { + ResponseResult relationResult = + this.doVerifyAndGetRelation(datasourceId, datasourceVariableName, relationId); + if (!relationResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, ResponseResult.errorFrom(relationResult)); + return; + } + OnlineTable slaveTable = relationResult.getData().getSlaveTable(); + onlineOperationHelper.doDownload(slaveTable, dataId, fieldName, filename, asImage, response); + } + + /** + * 为数据源主表字段上传文件。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 数据源Id。 + * @param fieldName 数据表字段名。 + * @param asImage 是否为图片文件。 + * @param uploadFile 上传文件对象。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.UPLOAD, saveResponse = false) + @PostMapping("/uploadDatasource/{datasourceVariableName}") + public void uploadDatasource( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @RequestParam Long datasourceId, + @RequestParam String fieldName, + @RequestParam Boolean asImage, + @RequestParam("uploadFile") MultipartFile uploadFile) throws IOException { + ResponseResult datasourceResult = + onlineOperationHelper.verifyAndGetDatasource(datasourceId); + if (!datasourceResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, ResponseResult.errorFrom(datasourceResult)); + return; + } + OnlineDatasource datasource = datasourceResult.getData(); + if (!datasource.getVariableName().equals(datasourceVariableName)) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, + ResponseResult.error(ErrorCodeEnum.NO_OPERATION_PERMISSION)); + return; + } + OnlineTable masterTable = datasource.getMasterTable(); + onlineOperationHelper.doUpload(masterTable, fieldName, asImage, uploadFile); + } + + /** + * 为数据源一对多关联的从表字段上传文件。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 数据源Id。 + * @param relationId 数据源的一对多关联Id。 + * @param fieldName 数据表字段名。 + * @param asImage 是否为图片文件。 + * @param uploadFile 上传文件对象。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.UPLOAD, saveResponse = false) + @PostMapping("/uploadOneToManyRelation/{datasourceVariableName}") + public void uploadOneToManyRelation( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @RequestParam Long datasourceId, + @RequestParam Long relationId, + @RequestParam String fieldName, + @RequestParam Boolean asImage, + @RequestParam("uploadFile") MultipartFile uploadFile) throws IOException { + ResponseResult relationResult = + this.doVerifyAndGetRelation(datasourceId, datasourceVariableName, relationId); + if (!relationResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, ResponseResult.errorFrom(relationResult)); + return; + } + OnlineTable slaveTable = relationResult.getData().getSlaveTable(); + onlineOperationHelper.doUpload(slaveTable, fieldName, asImage, uploadFile); + } + + /** + * 根据数据源Id,以及接口参数,为动态表单查询数据列表。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 数据源Id。 + * @param filterDtoList 多虑数据对象列表。 + * @param orderParam 排序对象。 + * @param pageParam 分页对象。 + */ + @SaTokenDenyAuth + @PostMapping("/listByDatasourceId/{datasourceVariableName}") + public ResponseResult>> listByDatasourceId( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody List filterDtoList, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + // 1. 验证数据源及其关联 + ResponseResult datasourceResult = + this.doVerifyAndGetDatasource(datasourceId, datasourceVariableName); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + OnlineTable masterTable = datasourceResult.getData().getMasterTable(); + ResponseResult> relationListResult = + onlineOperationHelper.verifyAndGetRelationList(datasourceId, null); + if (!relationListResult.isSuccess()) { + return ResponseResult.errorFrom(relationListResult); + } + List allRelationList = relationListResult.getData(); + // 2. 验证数据过滤对象中的表名和字段,确保没有sql注入。 + ResponseResult filterDtoListResult = this.verifyFilterDtoList(filterDtoList); + if (!filterDtoListResult.isSuccess()) { + return ResponseResult.errorFrom(filterDtoListResult); + } + // 3. 解析排序参数,同时确保没有sql注入。 + Map tableMap = new HashMap<>(4); + tableMap.put(masterTable.getTableName(), masterTable); + List oneToOneRelationList = relationListResult.getData().stream() + .filter(r -> r.getRelationType().equals(RelationType.ONE_TO_ONE)).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(oneToOneRelationList)) { + Map relationTableMap = oneToOneRelationList.stream() + .map(OnlineDatasourceRelation::getSlaveTable).collect(Collectors.toMap(OnlineTable::getTableName, c -> c)); + tableMap.putAll(relationTableMap); + } + ResponseResult orderByResult = this.makeOrderBy(orderParam, masterTable, tableMap); + if (!orderByResult.isSuccess()) { + return ResponseResult.errorFrom(orderByResult); + } + String orderBy = orderByResult.getData(); + MyPageData> pageData = onlineOperationService.getMasterDataList( + masterTable, oneToOneRelationList, allRelationList, filterDtoList, orderBy, pageParam); + return ResponseResult.success(pageData); + } + + /** + * 根据数据源Id,以及接口参数,为动态表单导出数据列表。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 数据源Id。 + * @param filterDtoList 多虑数据对象列表。 + * @param orderParam 排序对象。 + * @param exportInfoList 导出字段信息列表。 + */ + @SaTokenDenyAuth + @PostMapping("/exportByDatasourceId/{datasourceVariableName}") + public void exportByDatasourceId( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody List filterDtoList, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody(required = true) List exportInfoList) throws IOException { + // 1. 验证数据源及其关联 + ResponseResult datasourceResult = + onlineOperationHelper.verifyAndGetDatasource(datasourceId); + if (!datasourceResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, datasourceResult); + } + OnlineDatasource datasource = datasourceResult.getData(); + if (!datasource.getVariableName().equals(datasourceVariableName)) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN); + } + OnlineTable masterTable = datasource.getMasterTable(); + ResponseResult> relationListResult = + onlineOperationHelper.verifyAndGetRelationList(datasourceId, null); + if (!relationListResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, relationListResult); + } + List allRelationList = relationListResult.getData(); + // 2. 验证数据过滤对象中的表名和字段,确保没有sql注入。 + ResponseResult filterDtoListResult = this.verifyFilterDtoList(filterDtoList); + if (!filterDtoListResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, filterDtoListResult); + } + // 3. 解析排序参数,同时确保没有sql注入。 + Map tableMap = new HashMap<>(4); + tableMap.put(masterTable.getTableName(), masterTable); + List oneToOneRelationList = relationListResult.getData().stream() + .filter(r -> r.getRelationType().equals(RelationType.ONE_TO_ONE)).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(oneToOneRelationList)) { + Map relationTableMap = oneToOneRelationList.stream() + .map(OnlineDatasourceRelation::getSlaveTable).collect(Collectors.toMap(OnlineTable::getTableName, c -> c)); + tableMap.putAll(relationTableMap); + } + ResponseResult orderByResult = this.makeOrderBy(orderParam, masterTable, tableMap); + if (!orderByResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, orderByResult); + } + String orderBy = orderByResult.getData(); + MyPageData> pageData = onlineOperationService.getMasterDataList( + masterTable, oneToOneRelationList, allRelationList, filterDtoList, orderBy, null); + Map headerMap = this.makeExportHeaderMap(masterTable, allRelationList, exportInfoList); + if (MapUtil.isEmpty(headerMap)) { + ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, + ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, "数据验证失败,没有指定导出头信息!")); + return; + } + this.normalizeExportDataList(pageData.getDataList()); + String filename = datasourceVariableName + "-" + MyDateUtil.toDateTimeString(DateTime.now()) + ".xlsx"; + ExportUtil.doExport(pageData.getDataList(), headerMap, filename); + } + + /** + * 根据数据源Id和数据源关联Id,以及接口参数,为动态表单查询该一对多关联的数据列表。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 数据源Id。 + * @param relationId 数据源的一对多关联Id。 + * @param filterDtoList 多虑数据对象列表。 + * @param orderParam 排序对象。 + * @param pageParam 分页对象。 + * @return 查询结果。 + */ + @SaTokenDenyAuth + @PostMapping("/listByOneToManyRelationId/{datasourceVariableName}") + public ResponseResult>> listByOneToManyRelationId( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody(required = true) Long relationId, + @MyRequestBody List filterDtoList, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + ResponseResult verifyResult = + this.doVerifyAndGetRelation(datasourceId, datasourceVariableName, relationId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDatasourceRelation relation = verifyResult.getData(); + OnlineTable slaveTable = relation.getSlaveTable(); + // 验证数据过滤对象中的表名和字段,确保没有sql注入。 + ResponseResult filterDtoListResult = this.verifyFilterDtoList(filterDtoList); + if (!filterDtoListResult.isSuccess()) { + return ResponseResult.errorFrom(filterDtoListResult); + } + Map tableMap = new HashMap<>(1); + tableMap.put(slaveTable.getTableName(), slaveTable); + if (CollUtil.isNotEmpty(orderParam)) { + for (MyOrderParam.OrderInfo orderInfo : orderParam) { + orderInfo.setFieldName(StrUtil.removePrefix(orderInfo.getFieldName(), + relation.getVariableName() + OnlineConstant.RELATION_TABLE_COLUMN_SEPARATOR)); + } + } + ResponseResult orderByResult = this.makeOrderBy(orderParam, slaveTable, tableMap); + if (!orderByResult.isSuccess()) { + return ResponseResult.errorFrom(orderByResult); + } + String orderBy = orderByResult.getData(); + MyPageData> pageData = + onlineOperationService.getSlaveDataList(relation, filterDtoList, orderBy, pageParam); + return ResponseResult.success(pageData); + } + + /** + * 根据数据源Id和数据源关联Id,以及接口参数,为动态表单查询该一对多关联的数据列表。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 数据源Id。 + * @param relationId 数据源的一对多关联Id。 + * @param filterDtoList 多虑数据对象列表。 + * @param orderParam 排序对象。 + * @param exportInfoList 导出字段信息列表。 + */ + @SaTokenDenyAuth + @PostMapping("/exportByOneToManyRelationId/{datasourceVariableName}") + public void exportByOneToManyRelationId( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody(required = true) Long relationId, + @MyRequestBody List filterDtoList, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody(required = true) List exportInfoList) throws IOException { + ResponseResult relationResult = + this.doVerifyAndGetRelation(datasourceId, datasourceVariableName, relationId); + if (!relationResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, relationResult); + return; + } + OnlineDatasourceRelation relation = relationResult.getData(); + OnlineTable slaveTable = relation.getSlaveTable(); + // 验证数据过滤对象中的表名和字段,确保没有sql注入。 + ResponseResult filterDtoListResult = this.verifyFilterDtoList(filterDtoList); + if (!filterDtoListResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, filterDtoListResult); + return; + } + Map tableMap = new HashMap<>(1); + tableMap.put(slaveTable.getTableName(), slaveTable); + if (CollUtil.isNotEmpty(orderParam)) { + for (MyOrderParam.OrderInfo orderInfo : orderParam) { + orderInfo.setFieldName(StrUtil.removePrefix(orderInfo.getFieldName(), + relation.getVariableName() + OnlineConstant.RELATION_TABLE_COLUMN_SEPARATOR)); + } + } + ResponseResult orderByResult = this.makeOrderBy(orderParam, slaveTable, tableMap); + if (!orderByResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, orderByResult); + return; + } + String orderBy = orderByResult.getData(); + MyPageData> pageData = + onlineOperationService.getSlaveDataList(relation, filterDtoList, orderBy, null); + Map headerMap = + this.makeExportHeaderMap(relation.getSlaveTable(), null, exportInfoList); + if (MapUtil.isEmpty(headerMap)) { + ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, + ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, "数据验证失败,没有指定导出头信息!")); + return; + } + this.normalizeExportDataList(pageData.getDataList()); + String filename = datasourceVariableName + "-relation-" + MyDateUtil.toDateTimeString(DateTime.now()) + ".xlsx"; + ExportUtil.doExport(pageData.getDataList(), headerMap, filename); + } + + /** + * 查询字典数据,并以字典的约定方式,返回数据结果集。 + * + * @param dictId 字典Id。 + * @param filterDtoList 字典的过滤对象列表。 + * @return 字典数据列表。 + */ + @PostMapping("/listDict") + public ResponseResult>> listDict( + @MyRequestBody(required = true) Long dictId, + @MyRequestBody List filterDtoList) { + String errorMessage; + OnlineDict dict = onlineDictService.getOnlineDictFromCache(dictId); + if (dict == null) { + errorMessage = "数据验证失败,字典Id并不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + TokenData tokenData = TokenData.takeFromRequest(); + if (!StrUtil.equals(dict.getAppCode(), tokenData.getAppCode())) { + errorMessage = "数据验证失败,当前应用并不包含该字典Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!dict.getDictType().equals(DictType.TABLE) + && !dict.getDictType().equals(DictType.GLOBAL_DICT)) { + errorMessage = "数据验证失败,该接口仅支持数据表字典和全局编码字典!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (dict.getDictType().equals(DictType.GLOBAL_DICT)) { + List dictItems = + globalDictService.getGlobalDictItemListFromCache(dict.getDictCode(), null); + List> dataMapList = + MyCommonUtil.toDictDataList(dictItems, GlobalDictItem::getItemId, GlobalDictItem::getItemName); + return ResponseResult.success(dataMapList); + } + if (CollUtil.isNotEmpty(filterDtoList)) { + for (OnlineFilterDto filter : filterDtoList) { + if (!this.checkTableAndColumnName(filter.getColumnName())) { + errorMessage = StrFormatter.format( + "数据验证失败,过滤字段名 [{}] 包含 (数字、字母和下划线) 之外的非法字符!", filter.getColumnName()); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + } + List> resultList = onlineOperationService.getDictDataList(dict, filterDtoList); + return ResponseResult.success(resultList); + } + + /** + * 获取在线表单所关联的权限数据,包括权限字列表和权限资源列表。 + * 注:该接口仅用于微服务间调用使用,无需对前端开放。 + * + * @param menuFormIds 菜单关联的表单Id集合。 + * @param viewFormIds 查询权限的表单Id集合。 + * @param editFormIds 编辑权限的表单Id集合。 + * @return 参数中在线表单所关联的权限数据。 + */ + @GetMapping("/calculatePermData") + public ResponseResult> calculatePermData( + @RequestParam Set menuFormIds, + @RequestParam Set viewFormIds, + @RequestParam Set editFormIds) { + return ResponseResult.success(onlineOperationService.calculatePermData(menuFormIds, viewFormIds, editFormIds)); + } + + private ResponseResult doDelete( + String datasourceVariableName, Long datasourceId, List dataIdList) { + ResponseResult datasourceResult = + onlineOperationHelper.verifyAndGetDatasource(datasourceId); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + OnlineDatasource datasource = datasourceResult.getData(); + if (!datasource.getVariableName().equals(datasourceVariableName)) { + ContextUtil.getHttpResponse().setStatus(HttpServletResponse.SC_FORBIDDEN); + return ResponseResult.error(ErrorCodeEnum.NO_OPERATION_PERMISSION); + } + OnlineTable masterTable = datasource.getMasterTable(); + ResponseResult> relationListResult = + onlineOperationHelper.verifyAndGetRelationList(datasourceId, RelationType.ONE_TO_MANY); + if (!relationListResult.isSuccess()) { + return ResponseResult.errorFrom(relationListResult); + } + List relationList = relationListResult.getData(); + for (String dataId : dataIdList) { + if (!onlineOperationService.delete(masterTable, relationList, dataId)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + } + return ResponseResult.success(); + } + + private ResponseResult doDelete( + String datasourceVariableName, Long datasourceId, Long relationId, List dataIdList) { + ResponseResult verifyResult = + this.doVerifyAndGetRelation(datasourceId, datasourceVariableName, relationId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDatasourceRelation relation = verifyResult.getData(); + for (String dataId : dataIdList) { + if (!onlineOperationService.delete(relation.getSlaveTable(), null, dataId)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + } + return ResponseResult.success(); + } + + private ResponseResult doVerifyAndGetDatasource( + Long datasourceId, String datasourceVariableName) { + ResponseResult datasourceResult = + onlineOperationHelper.verifyAndGetDatasource(datasourceId); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + OnlineDatasource datasource = datasourceResult.getData(); + if (!datasource.getVariableName().equals(datasourceVariableName)) { + ContextUtil.getHttpResponse().setStatus(HttpServletResponse.SC_FORBIDDEN); + return ResponseResult.error(ErrorCodeEnum.NO_OPERATION_PERMISSION); + } + return ResponseResult.success(datasource); + } + + private ResponseResult doVerifyAndGetRelation( + Long datasourceId, String datasourceVariableName, Long relationId) { + OnlineDatasource datasource = onlineDatasourceService.getOnlineDatasourceFromCache(datasourceId); + if (datasource == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, "数据验证失败,数据源Id并不存在!"); + } + if (!datasource.getVariableName().equals(datasourceVariableName)) { + ContextUtil.getHttpResponse().setStatus(HttpServletResponse.SC_FORBIDDEN); + return ResponseResult.error(ErrorCodeEnum.NO_OPERATION_PERMISSION); + } + return onlineOperationHelper.verifyAndGetRelation(datasourceId, relationId); + } + + private ResponseResult verifyFilterDtoList(List filterDtoList) { + if (CollUtil.isEmpty(filterDtoList)) { + return ResponseResult.success(); + } + String errorMessage; + for (OnlineFilterDto filter : filterDtoList) { + if (!this.checkTableAndColumnName(filter.getTableName())) { + errorMessage = StrFormatter.format( + "数据验证失败,过滤表名 [{}] 包含 (数字、字母和下划线) 之外的非法字符!", filter.getColumnName()); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!this.checkTableAndColumnName(filter.getColumnName())) { + errorMessage = StrFormatter.format( + "数据验证失败,过滤字段名 [{}] 包含 (数字、字母和下划线) 之外的非法字符!", filter.getColumnName()); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!filter.getFilterType().equals(FieldFilterType.RANGE_FILTER) + && ObjectUtil.isEmpty(filter.getColumnValue())) { + errorMessage = StrFormatter.format( + "数据验证失败,过滤字段名 [{}] 过滤值不能为空!", filter.getColumnName()); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + return ResponseResult.success(); + } + + private boolean checkTableAndColumnName(String name) { + if (StrUtil.isBlank(name)) { + return true; + } + for (int i = 0; i < name.length(); i++) { + char c = name.charAt(i); + if (!CharUtil.isLetterOrNumber(c) && !CharUtil.equals('_', c, false)) { + return false; + } + } + return true; + } + + private ResponseResult makeOrderBy( + MyOrderParam orderParam, OnlineTable masterTable, Map tableMap) { + if (CollUtil.isEmpty(orderParam)) { + return ResponseResult.success(null); + } + String errorMessage; + StringBuilder sb = new StringBuilder(128); + for (MyOrderParam.OrderInfo orderInfo : orderParam) { + String[] orderArray = StrUtil.splitToArray(orderInfo.getFieldName(), '.'); + // 如果没有前缀,我们就可以默认为主表的字段。 + if (orderArray.length == 1) { + try { + sb.append(this.makeOrderByForOrderInfo(masterTable, orderArray[0], orderInfo)); + } catch (OnlineRuntimeException e) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, e.getMessage()); + } + } else { + String tableName = orderArray[0]; + String columnName = orderArray[1]; + OnlineTable table = tableMap.get(tableName); + if (table == null) { + errorMessage = StrFormatter.format( + "数据验证失败,排序字段 [{}] 的数据表 [{}] 并不属于当前数据源!", + orderInfo.getFieldName(), tableName); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + try { + sb.append(this.makeOrderByForOrderInfo(table, columnName, orderInfo)); + } catch (OnlineRuntimeException e) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, e.getMessage()); + } + } + } + return ResponseResult.success(sb.substring(0, sb.length() - 2)); + } + + private String makeOrderByForOrderInfo( + OnlineTable table, String columnName, MyOrderParam.OrderInfo orderInfo) { + StringBuilder sb = new StringBuilder(64); + boolean found = false; + for (OnlineColumn column : table.getColumnMap().values()) { + if (column.getColumnName().equals(columnName)) { + sb.append(table.getTableName()).append(".").append(columnName); + if (BooleanUtil.isFalse(orderInfo.getAsc())) { + sb.append(" DESC"); + } + sb.append(", "); + found = true; + break; + } + } + if (!found) { + String errorMessage = StrFormatter.format( + "数据验证失败,排序字段 [{}] 在数据表 [{}] 中并不存在!", + orderInfo.getFieldName(), table.getTableName()); + throw new OnlineRuntimeException(errorMessage); + } + return sb.toString(); + } + + private int makeImportHeaderInfoByFieldType(String objectFieldType) { + return switch (objectFieldType) { + case ObjectFieldType.INTEGER -> ImportUtil.INT_TYPE; + case ObjectFieldType.LONG -> ImportUtil.LONG_TYPE; + case ObjectFieldType.STRING -> ImportUtil.STRING_TYPE; + case ObjectFieldType.BOOLEAN -> ImportUtil.BOOLEAN_TYPE; + case ObjectFieldType.DATE -> ImportUtil.DATE_TYPE; + case ObjectFieldType.DOUBLE -> ImportUtil.DOUBLE_TYPE; + case ObjectFieldType.BIG_DECIMAL -> ImportUtil.BIG_DECIMAL_TYPE; + default -> throw new MyRuntimeException("Unsupport Import FieldType"); + }; + } + + private Map makeExportHeaderMap( + OnlineTable masterTable, + List allRelationList, + List exportInfoList) { + Map headerMap = new LinkedHashMap<>(16); + Map allRelationMap = null; + if (allRelationList != null) { + allRelationMap = allRelationList.stream() + .collect(Collectors.toMap(OnlineDatasourceRelation::getSlaveTableId, r -> r)); + } + for (ExportInfo exportInfo : exportInfoList) { + if (exportInfo.getVirtualColumnId() != null) { + OnlineVirtualColumn virtualColumn = + onlineVirtualColumnService.getById(exportInfo.getVirtualColumnId()); + if (virtualColumn != null) { + headerMap.put(virtualColumn.getObjectFieldName(), exportInfo.showName); + } + continue; + } + if (masterTable != null && exportInfo.getTableId().equals(masterTable.getTableId())) { + OnlineColumn column = masterTable.getColumnMap().get(exportInfo.getColumnId()); + String columnName = this.appendSuffixForDictColumn(column, column.getColumnName()); + headerMap.put(columnName, exportInfo.getShowName()); + } else { + OnlineDatasourceRelation relation = + MapUtil.get(allRelationMap, exportInfo.getTableId(), OnlineDatasourceRelation.class); + if (relation != null) { + OnlineColumn column = relation.getSlaveTable().getColumnMap().get(exportInfo.getColumnId()); + String columnName = this.appendSuffixForDictColumn( + column, relation.getVariableName() + "." + column.getColumnName()); + headerMap.put(columnName, exportInfo.getShowName()); + } + } + } + return headerMap; + } + + private void normalizeExportDataList(List> dataList) { + for (Map columnData : dataList) { + for (Map.Entry entry : columnData.entrySet()) { + if (entry.getValue() instanceof Long || entry.getValue() instanceof BigDecimal) { + columnData.put(entry.getKey(), entry.getValue() == null ? "" : entry.getValue().toString()); + } + } + } + } + + private String appendSuffixForDictColumn(OnlineColumn column, String columnName) { + if (column.getDictId() != null) { + if (ObjectUtil.equal(column.getFieldKind(), FieldKind.DICT_MULTI_SELECT)) { + columnName += "DictMapList"; + } else { + columnName += "DictMap.name"; + } + } + return columnName; + } + + @Data + public static class ExportInfo { + private Long tableId; + private Long columnId; + private Long virtualColumnId; + private String showName; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlinePageController.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlinePageController.java new file mode 100644 index 00000000..25bbedb9 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlinePageController.java @@ -0,0 +1,386 @@ +package com.orangeforms.common.online.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.online.dto.OnlineDatasourceDto; +import com.orangeforms.common.online.dto.OnlinePageDatasourceDto; +import com.orangeforms.common.online.dto.OnlinePageDto; +import com.orangeforms.common.online.model.OnlineDatasource; +import com.orangeforms.common.online.model.OnlineForm; +import com.orangeforms.common.online.model.OnlinePage; +import com.orangeforms.common.online.model.OnlinePageDatasource; +import com.orangeforms.common.online.model.constant.PageStatus; +import com.orangeforms.common.online.service.OnlineDatasourceService; +import com.orangeforms.common.online.service.OnlineFormService; +import com.orangeforms.common.online.service.OnlinePageService; +import com.orangeforms.common.online.vo.OnlineDatasourceVo; +import com.orangeforms.common.online.vo.OnlinePageDatasourceVo; +import com.orangeforms.common.online.vo.OnlinePageVo; +import com.github.pagehelper.page.PageMethod; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.dao.DuplicateKeyException; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 在线表单页面接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "在线表单页面接口") +@Slf4j +@RestController +@RequestMapping("${common-online.urlPrefix}/onlinePage") +@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true") +public class OnlinePageController { + + @Autowired + private OnlinePageService onlinePageService; + @Autowired + private OnlineFormService onlineFormService; + @Autowired + private OnlineDatasourceService onlineDatasourceService; + + /** + * 新增在线表单页面数据。 + * + * @param onlinePageDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"onlinePageDto.pageId"}) + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody OnlinePageDto onlinePageDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlinePageDto); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlinePage onlinePage = MyModelUtil.copyTo(onlinePageDto, OnlinePage.class); + if (onlinePageService.existByPageCode(onlinePage.getPageCode())) { + errorMessage = "数据验证失败,页面编码已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage); + } + try { + onlinePage = onlinePageService.saveNew(onlinePage); + } catch (DuplicateKeyException e) { + errorMessage = "数据验证失败,当前应用的页面编码已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(onlinePage.getPageId()); + } + + /** + * 更新在线表单页面数据。 + * + * @param onlinePageDto 更新对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody OnlinePageDto onlinePageDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlinePageDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlinePage onlinePage = MyModelUtil.copyTo(onlinePageDto, OnlinePage.class); + ResponseResult verifyResult = this.doVerifyAndGet(onlinePage.getPageId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlinePage originalOnlinePage = verifyResult.getData(); + if (!onlinePage.getPageType().equals(originalOnlinePage.getPageType())) { + errorMessage = "数据验证失败,页面类型不能修改!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!StrUtil.equals(onlinePage.getPageCode(), originalOnlinePage.getPageCode()) + && onlinePageService.existByPageCode(onlinePage.getPageCode())) { + errorMessage = "数据验证失败,页面编码已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage); + } + try { + if (!onlinePageService.update(onlinePage, originalOnlinePage)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + } catch (DuplicateKeyException e) { + errorMessage = "数据验证失败,当前应用的页面编码已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 更新在线表单页面对象的发布状态字段。 + * + * @param pageId 待更新的页面对象主键Id。 + * @param published 发布状态。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/updatePublished") + public ResponseResult updateStatus( + @MyRequestBody(required = true) Long pageId, + @MyRequestBody(required = true) Boolean published) { + String errorMessage; + ResponseResult verifyResult = this.doVerifyAndGet(pageId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlinePage originalOnlinePage = verifyResult.getData(); + if (!published.equals(originalOnlinePage.getPublished())) { + if (BooleanUtil.isTrue(published) && !originalOnlinePage.getStatus().equals(PageStatus.FORM_DESIGN)) { + errorMessage = "数据验证失败,当前页面状态不为 [设计] 状态,因此不能发布!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + onlinePageService.updatePublished(pageId, published); + } + return ResponseResult.success(); + } + + /** + * 删除在线表单页面数据。 + * + * @param pageId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long pageId) { + String errorMessage; + ResponseResult verifyResult = this.doVerifyAndGet(pageId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (!onlinePageService.remove(pageId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的在线表单页面列表。 + * + * @param onlinePageDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("onlinePage.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody OnlinePageDto onlinePageDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlinePage onlinePageFilter = MyModelUtil.copyTo(onlinePageDtoFilter, OnlinePage.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlinePage.class); + List onlinePageList = onlinePageService.getOnlinePageListWithRelation(onlinePageFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(onlinePageList, OnlinePageVo.class)); + } + + /** + * 获取系统中配置的所有Page和表单的列表。 + * + * @return 系统中配置的所有Page和表单的列表。 + */ + @PostMapping("/listAllPageAndForm") + public ResponseResult listAllPageAndForm() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("pageList", onlinePageService.getOnlinePageList(null, null)); + List formList = onlineFormService.getOnlineFormList(null, null); + formList.forEach(f -> f.setWidgetJson(null)); + jsonObject.put("formList", formList); + return ResponseResult.success(jsonObject); + } + + /** + * 查看指定在线表单页面对象详情。 + * + * @param pageId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("onlinePage.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long pageId) { + ResponseResult verifyResult = this.doVerifyAndGet(pageId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlinePage onlinePage = onlinePageService.getByIdWithRelation(pageId, MyRelationParam.full()); + if (onlinePage == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(onlinePage, OnlinePageVo.class); + } + + /** + * 列出与指定在线表单页面存在多对多关系的在线数据源列表数据。 + * + * @param pageId 主表关联字段。 + * @param onlineDatasourceDtoFilter 在线数据源过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,返回符合条件的数据列表。 + */ + @SaCheckPermission("onlinePage.all") + @PostMapping("/listOnlinePageDatasource") + public ResponseResult> listOnlinePageDatasource( + @MyRequestBody Long pageId, + @MyRequestBody OnlineDatasourceDto onlineDatasourceDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + ResponseResult verifyResult = this.doVerifyAndGet(pageId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlineDatasource filter = MyModelUtil.copyTo(onlineDatasourceDtoFilter, OnlineDatasource.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineDatasource.class); + List onlineDatasourceList = + onlineDatasourceService.getOnlineDatasourceListByPageId(pageId, filter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(onlineDatasourceList, OnlineDatasourceVo.class)); + } + + /** + * 批量添加在线表单页面和在线数据源对象的多对多关联关系数据。 + * + * @param pageId 主表主键Id。 + * @param onlinePageDatasourceDtoList 关联对象列表。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.ADD_M2M) + @PostMapping("/addOnlinePageDatasource") + public ResponseResult addOnlinePageDatasource( + @MyRequestBody Long pageId, + @MyRequestBody(value = "onlinePageDatasourceList") List onlinePageDatasourceDtoList) { + String errorMessage; + ResponseResult verifyResult = this.doVerifyAndGet(pageId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (MyCommonUtil.existBlankArgument(onlinePageDatasourceDtoList)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + for (OnlinePageDatasourceDto onlinePageDatasource : onlinePageDatasourceDtoList) { + errorMessage = MyCommonUtil.getModelValidationError(onlinePageDatasource); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + Set datasourceIdSet = onlinePageDatasourceDtoList.stream() + .map(OnlinePageDatasourceDto::getDatasourceId).collect(Collectors.toSet()); + List datasourceList = onlineDatasourceService.getInList(datasourceIdSet); + if (datasourceIdSet.size() != datasourceList.size()) { + errorMessage = "数据验证失败,当前在线表单包含不存在的数据源Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + String appCode = TokenData.takeFromRequest().getAppCode(); + for (OnlineDatasource datasource : datasourceList) { + if (!StrUtil.equals(datasource.getAppCode(), appCode)) { + errorMessage = "数据验证失败,存在不是当前应用的数据源!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + List onlinePageDatasourceList = + MyModelUtil.copyCollectionTo(onlinePageDatasourceDtoList, OnlinePageDatasource.class); + onlinePageService.addOnlinePageDatasourceList(onlinePageDatasourceList, pageId); + return ResponseResult.success(); + } + + /** + * 显示在线表单页面和指定数据源的多对多关联详情数据。 + * + * @param pageId 主表主键Id。 + * @param datasourceId 从表主键Id。 + * @return 应答结果对象,包括中间表详情。 + */ + @SaCheckPermission("onlinePage.all") + @GetMapping("/viewOnlinePageDatasource") + public ResponseResult viewOnlinePageDatasource( + @RequestParam Long pageId, @RequestParam Long datasourceId) { + ResponseResult verifyResult = this.doVerifyAndGet(pageId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlinePageDatasource onlinePageDatasource = onlinePageService.getOnlinePageDatasource(pageId, datasourceId); + if (onlinePageDatasource == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + OnlinePageDatasourceVo onlinePageDatasourceVo = + MyModelUtil.copyTo(onlinePageDatasource, OnlinePageDatasourceVo.class); + return ResponseResult.success(onlinePageDatasourceVo); + } + + /** + * 移除指定在线表单页面和指定数据源的多对多关联关系。 + * + * @param pageId 主表主键Id。 + * @param datasourceId 从表主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.DELETE_M2M) + @PostMapping("/deleteOnlinePageDatasource") + public ResponseResult deleteOnlinePageDatasource( + @MyRequestBody Long pageId, @MyRequestBody(required = true) Long datasourceId) { + ResponseResult verifyResult = this.doVerifyAndGet(pageId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (!onlinePageService.removeOnlinePageDatasource(pageId, datasourceId)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + private ResponseResult doVerifyAndGet(Long pageId) { + String errorMessage; + if (MyCommonUtil.existBlankArgument(pageId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + OnlinePage onlinePage = onlinePageService.getById(pageId); + if (onlinePage == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + TokenData tokenData = TokenData.takeFromRequest(); + if (!StrUtil.equals(onlinePage.getAppCode(), tokenData.getAppCode())) { + errorMessage = "数据验证失败,当前应用不存在该页面!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (ObjectUtil.notEqual(onlinePage.getTenantId(), tokenData.getTenantId())) { + errorMessage = "数据验证失败,当前租户不包含该页面!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(onlinePage); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineRuleController.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineRuleController.java new file mode 100644 index 00000000..b5491b5a --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineRuleController.java @@ -0,0 +1,175 @@ +package com.orangeforms.common.online.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import cn.hutool.core.util.StrUtil; +import cn.hutool.core.util.BooleanUtil; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.online.dto.OnlineRuleDto; +import com.orangeforms.common.online.model.OnlineRule; +import com.orangeforms.common.online.service.OnlineRuleService; +import com.orangeforms.common.online.vo.OnlineRuleVo; +import com.github.pagehelper.page.PageMethod; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import java.util.List; + +/** + * 在线表单字段验证规则接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "在线表单字段验证规则接口") +@Slf4j +@RestController +@RequestMapping("${common-online.urlPrefix}/onlineRule") +@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true") +public class OnlineRuleController { + + @Autowired + private OnlineRuleService onlineRuleService; + + /** + * 新增验证规则数据。 + * + * @param onlineRuleDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"onlineRuleDto.ruleId"}) + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody OnlineRuleDto onlineRuleDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineRuleDto); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineRule onlineRule = MyModelUtil.copyTo(onlineRuleDto, OnlineRule.class); + onlineRule = onlineRuleService.saveNew(onlineRule); + return ResponseResult.success(onlineRule.getRuleId()); + } + + /** + * 更新验证规则数据。 + * + * @param onlineRuleDto 更新对象。 + * @return 应答结果对象。 + */ + @OperationLog(type = SysOperationLogType.UPDATE) + @SaCheckPermission("onlinePage.all") + @PostMapping("/update") + public ResponseResult update(@MyRequestBody OnlineRuleDto onlineRuleDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineRuleDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineRule onlineRule = MyModelUtil.copyTo(onlineRuleDto, OnlineRule.class); + ResponseResult verifyResult = this.doVerifyAndGet(onlineRule.getRuleId(), false); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineRule originalOnlineRule = verifyResult.getData(); + if (!onlineRuleService.update(onlineRule, originalOnlineRule)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 删除验证规则数据。 + * + * @param ruleId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long ruleId) { + String errorMessage; + ResponseResult verifyResult = this.doVerifyAndGet(ruleId, false); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (!onlineRuleService.remove(ruleId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的验证规则列表。 + * + * @param onlineRuleDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("onlinePage.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody OnlineRuleDto onlineRuleDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlineRule onlineRuleFilter = MyModelUtil.copyTo(onlineRuleDtoFilter, OnlineRule.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineRule.class); + List onlineRuleList = onlineRuleService.getOnlineRuleListWithRelation(onlineRuleFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(onlineRuleList, OnlineRuleVo.class)); + } + + /** + * 查看指定验证规则对象详情。 + * + * @param ruleId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("onlinePage.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long ruleId) { + ResponseResult verifyResult = this.doVerifyAndGet(ruleId, true); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineRule onlineRule = verifyResult.getData(); + return ResponseResult.success(onlineRule, OnlineRuleVo.class); + } + + private ResponseResult doVerifyAndGet(Long ruleId, boolean readOnly) { + String errorMessage; + if (MyCommonUtil.existBlankArgument(ruleId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + // 验证关联Id的数据合法性 + OnlineRule rule = onlineRuleService.getById(ruleId); + if (rule == null) { + errorMessage = "数据验证失败,当前在线字段规则并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!readOnly && BooleanUtil.isTrue(rule.getBuiltin())) { + errorMessage = "数据验证失败,内置规则不能删除!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!StrUtil.equals(rule.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + errorMessage = "数据验证失败,当前应用并不包含该规则!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(rule); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineVirtualColumnController.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineVirtualColumnController.java new file mode 100644 index 00000000..f28e81d1 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineVirtualColumnController.java @@ -0,0 +1,195 @@ +package com.orangeforms.common.online.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +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.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.online.dto.OnlineVirtualColumnDto; +import com.orangeforms.common.online.model.OnlineVirtualColumn; +import com.orangeforms.common.online.model.constant.VirtualType; +import com.orangeforms.common.online.service.OnlineVirtualColumnService; +import com.orangeforms.common.online.vo.OnlineVirtualColumnVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; + +import java.util.*; +import jakarta.validation.groups.Default; + +/** + * 在线表单虚拟字段接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "在线表单虚拟字段接口") +@Slf4j +@RestController +@RequestMapping("${common-online.urlPrefix}/onlineVirtualColumn") +@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true") +public class OnlineVirtualColumnController { + + @Autowired + private OnlineVirtualColumnService onlineVirtualColumnService; + + /** + * 新增虚拟字段数据。 + * + * @param onlineVirtualColumnDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"onlineVirtualColumnDto.virtualColumnId"}) + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody OnlineVirtualColumnDto onlineVirtualColumnDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineVirtualColumnDto); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineVirtualColumn onlineVirtualColumn = + MyModelUtil.copyTo(onlineVirtualColumnDto, OnlineVirtualColumn.class); + ResponseResult verifyResult = this.doVerify(onlineVirtualColumn, null); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + onlineVirtualColumn = onlineVirtualColumnService.saveNew(onlineVirtualColumn); + return ResponseResult.success(onlineVirtualColumn.getVirtualColumnId()); + } + + /** + * 更新虚拟字段数据。 + * + * @param onlineVirtualColumnDto 更新对象。 + * @return 应答结果对象。 + */ + @OperationLog(type = SysOperationLogType.UPDATE) + @SaCheckPermission("onlinePage.all") + @PostMapping("/update") + public ResponseResult update(@MyRequestBody OnlineVirtualColumnDto onlineVirtualColumnDto) { + String errorMessage = MyCommonUtil.getModelValidationError( + onlineVirtualColumnDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineVirtualColumn onlineVirtualColumn = + MyModelUtil.copyTo(onlineVirtualColumnDto, OnlineVirtualColumn.class); + OnlineVirtualColumn originalOnlineVirtualColumn = + onlineVirtualColumnService.getById(onlineVirtualColumn.getVirtualColumnId()); + if (originalOnlineVirtualColumn == null) { + errorMessage = "数据验证失败,当前虚拟字段并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + ResponseResult verifyResult = this.doVerify(onlineVirtualColumn, originalOnlineVirtualColumn); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (!onlineVirtualColumnService.update(onlineVirtualColumn, originalOnlineVirtualColumn)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 删除虚拟字段数据。 + * + * @param virtualColumnId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @OperationLog(type = SysOperationLogType.DELETE) + @SaCheckPermission("onlinePage.all") + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long virtualColumnId) { + String errorMessage; + if (MyCommonUtil.existBlankArgument(virtualColumnId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + // 验证关联Id的数据合法性 + OnlineVirtualColumn originalOnlineVirtualColumn = onlineVirtualColumnService.getById(virtualColumnId); + if (originalOnlineVirtualColumn == null) { + errorMessage = "数据验证失败,当前虚拟字段并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!onlineVirtualColumnService.remove(virtualColumnId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的虚拟字段列表。 + * + * @param onlineVirtualColumnDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("onlinePage.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody OnlineVirtualColumnDto onlineVirtualColumnDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlineVirtualColumn onlineVirtualColumnFilter = + MyModelUtil.copyTo(onlineVirtualColumnDtoFilter, OnlineVirtualColumn.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineVirtualColumn.class); + List onlineVirtualColumnList = + onlineVirtualColumnService.getOnlineVirtualColumnListWithRelation(onlineVirtualColumnFilter, orderBy); + MyPageData pageData = + MyPageUtil.makeResponseData(onlineVirtualColumnList, OnlineVirtualColumnVo.class); + return ResponseResult.success(pageData); + } + + /** + * 查看指定虚拟字段对象详情。 + * + * @param virtualColumnId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("onlinePage.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long virtualColumnId) { + if (MyCommonUtil.existBlankArgument(virtualColumnId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + OnlineVirtualColumn onlineVirtualColumn = + onlineVirtualColumnService.getByIdWithRelation(virtualColumnId, MyRelationParam.full()); + if (onlineVirtualColumn == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(onlineVirtualColumn, OnlineVirtualColumnVo.class); + } + + private ResponseResult doVerify( + OnlineVirtualColumn virtualColumn, OnlineVirtualColumn originalVirtualColumn) { + if (!virtualColumn.getVirtualType().equals(VirtualType.AGGREGATION)) { + return ResponseResult.success(); + } + if (MyCommonUtil.existBlankArgument( + virtualColumn.getAggregationColumnId(), + virtualColumn.getAggregationTableId(), + virtualColumn.getDatasourceId(), + virtualColumn.getRelationId(), + virtualColumn.getAggregationType())) { + String errorMessage = "数据验证失败,数据源、关联关系、聚合表、聚合字段和聚合类型,均不能为空!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + CallResult verifyResult = onlineVirtualColumnService.verifyRelatedData(virtualColumn, originalVirtualColumn); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + return ResponseResult.success(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineColumnMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineColumnMapper.java new file mode 100644 index 00000000..fbfc638f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineColumnMapper.java @@ -0,0 +1,24 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineColumn; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 字段数据数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineColumnMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param onlineColumnFilter 主表过滤对象。 + * @return 对象列表。 + */ + List getOnlineColumnList(@Param("onlineColumnFilter") OnlineColumn onlineColumnFilter); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineColumnRuleMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineColumnRuleMapper.java new file mode 100644 index 00000000..84128efd --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineColumnRuleMapper.java @@ -0,0 +1,14 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineColumnRule; + +/** + * 数据字段规则访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineColumnRuleMapper extends BaseDaoMapper { + +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDatasourceMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDatasourceMapper.java new file mode 100644 index 00000000..7f5aaca2 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDatasourceMapper.java @@ -0,0 +1,60 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineDatasource; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 数据模型数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineDatasourceMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param onlineDatasourceFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getOnlineDatasourceList( + @Param("onlineDatasourceFilter") OnlineDatasource onlineDatasourceFilter, @Param("orderBy") String orderBy); + + /** + * 根据关联主表Id,获取关联从表数据列表。 + * + * @param pageId 关联主表Id。 + * @param onlineDatasourceFilter 从表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 从表数据列表。 + */ + List getOnlineDatasourceListByPageId( + @Param("pageId") Long pageId, + @Param("onlineDatasourceFilter") OnlineDatasource onlineDatasourceFilter, + @Param("orderBy") String orderBy); + + /** + * 根据在线表单Id集合,获取关联的在线数据源对象列表。 + * + * @param formIdSet 在线表单Id集合。 + * @return 与参数表单Id关联的数据源列表。 + */ + List getOnlineDatasourceListByFormIds(@Param("formIdSet") Set formIdSet); + + /** + * 获取在线表单页面和在线表单数据源变量名的映射关系。 + * + * @param pageIds 页面Id集合。 + * @return 在线表单页面和在线表单数据源变量名的映射关系。 + */ + @Select("SELECT a.page_id, b.variable_name FROM zz_online_page_datasource a, zz_online_datasource b" + + " WHERE a.page_id in (${pageIds}) AND a.datasource_id = b.datasource_id") + List> getPageIdAndVariableNameMapByPageIds(@Param("pageIds") String pageIds); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDatasourceRelationMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDatasourceRelationMapper.java new file mode 100644 index 00000000..d68c13a2 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDatasourceRelationMapper.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineDatasourceRelation; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 数据关联数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineDatasourceRelationMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getOnlineDatasourceRelationList( + @Param("filter") OnlineDatasourceRelation filter, @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDatasourceTableMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDatasourceTableMapper.java new file mode 100644 index 00000000..a84fbb66 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDatasourceTableMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineDatasourceTable; + +/** + * 数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineDatasourceTableMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDblinkMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDblinkMapper.java new file mode 100644 index 00000000..1941c7f8 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDblinkMapper.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineDblink; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 数据库链接数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineDblinkMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param onlineDblinkFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getOnlineDblinkList( + @Param("onlineDblinkFilter") OnlineDblink onlineDblinkFilter, @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDictMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDictMapper.java new file mode 100644 index 00000000..b22cca72 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDictMapper.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineDict; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 在线表单字典数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineDictMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param onlineDictFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getOnlineDictList( + @Param("onlineDictFilter") OnlineDict onlineDictFilter, @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineFormDatasourceMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineFormDatasourceMapper.java new file mode 100644 index 00000000..a8485da4 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineFormDatasourceMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineFormDatasource; + +/** + * 在线表单与数据源多对多关联的数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineFormDatasourceMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineFormMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineFormMapper.java new file mode 100644 index 00000000..5adbad02 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineFormMapper.java @@ -0,0 +1,36 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineForm; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 在线表单数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineFormMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param onlineFormFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getOnlineFormList( + @Param("onlineFormFilter") OnlineForm onlineFormFilter, @Param("orderBy") String orderBy); + + /** + * 根据数据源Id,返回使用该数据源的OnlineForm对象。 + * + * @param datasourceId 数据源Id。 + * @param onlineFormFilter 主表过滤对象。 + * @return 使用该数据源的表单列表。 + */ + List getOnlineFormListByDatasourceId( + @Param("datasourceId") Long datasourceId, @Param("onlineFormFilter") OnlineForm onlineFormFilter); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineOperationMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineOperationMapper.java new file mode 100644 index 00000000..025e437c --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineOperationMapper.java @@ -0,0 +1,259 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.online.dto.OnlineFilterDto; +import com.orangeforms.common.online.object.ColumnData; +import com.orangeforms.common.online.object.JoinTableInfo; +import org.apache.ibatis.annotations.*; + +import java.util.List; +import java.util.Map; + +/** + * 在线表单运行时数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Mapper +public interface OnlineOperationMapper { + + /** + * 插入新数据。 + * + * @param tableName 数据表名。 + * @param columnNames 字段名列表。 + * @param columnValueList 字段值列表。 + */ + @Insert("") + void insert( + @Param("tableName") String tableName, + @Param("columnNames") String columnNames, + @Param("columnValueList") List columnValueList); + + /** + * 更新表数据。 + * + * @param tableName 数据表名。 + * @param updateColumnList 更新字段列表。 + * @param filterList SQL过滤条件列表。 + * @param dataPermFilter 数据权限过滤字符串。 + * @return 更新行数。 + */ + @Update("") + int update( + @Param("tableName") String tableName, + @Param("updateColumnList") List updateColumnList, + @Param("filterList") List filterList, + @Param("dataPermFilter") String dataPermFilter); + + /** + * 删除指定数据。 + * + * @param tableName 表名。 + * @param filterList SQL过滤条件列表。 + * @param dataPermFilter 数据权限过滤字符串。 + * @return 删除行数。 + */ + @Delete("") + int delete( + @Param("tableName") String tableName, + @Param("filterList") List filterList, + @Param("dataPermFilter") String dataPermFilter); + + /** + * 执行动态查询,并返回查询结果集。 + * + * @param masterTableName 主表名称。 + * @param joinInfoList 关联表信息列表。 + * @param selectFields 返回字段列表,逗号分隔。 + * @param filterList SQL过滤条件列表。 + * @param dataPermFilter 数据权限过滤字符串。 + * @param orderBy 排序字符串。 + * @return 查询结果集。 + */ + @Select("") + List> getList( + @Param("masterTableName") String masterTableName, + @Param("joinInfoList") List joinInfoList, + @Param("selectFields") String selectFields, + @Param("filterList") List filterList, + @Param("dataPermFilter") String dataPermFilter, + @Param("orderBy") String orderBy); + + /** + * 以字典键值对的方式返回数据。 + * + * @param tableName 表名称。 + * @param selectFields 返回字段列表,逗号分隔。 + * @param filterList SQL过滤条件列表。 + * @param dataPermFilter 数据权限过滤字符串。 + * @return 查询结果集。 + */ + @Select("") + List> getDictList( + @Param("tableName") String tableName, + @Param("selectFields") String selectFields, + @Param("filterList") List filterList, + @Param("dataPermFilter") String dataPermFilter); + + /** + * 根据指定的表名、显示字段列表、过滤条件字符串和分组字段,返回聚合计算后的查询结果。 + * + * @param selectTable 表名称。 + * @param selectFields 返回字段列表,逗号分隔。 + * @param whereClause SQL常量形式的条件从句。 + * @param groupBy 分组字段列表,逗号分隔。 + * @return 对象可选字段Map列表。 + */ + @Select("") + List> getGroupedListByCondition( + @Param("selectTable") String selectTable, + @Param("selectFields") String selectFields, + @Param("whereClause") String whereClause, + @Param("groupBy") String groupBy); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlinePageDatasourceMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlinePageDatasourceMapper.java new file mode 100644 index 00000000..d486645d --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlinePageDatasourceMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlinePageDatasource; + +/** + * 在线表单页面和数据源关联对象的数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlinePageDatasourceMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlinePageMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlinePageMapper.java new file mode 100644 index 00000000..7ac0841f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlinePageMapper.java @@ -0,0 +1,36 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlinePage; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 在线表单页面数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlinePageMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param onlinePageFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getOnlinePageList( + @Param("onlinePageFilter") OnlinePage onlinePageFilter, @Param("orderBy") String orderBy); + + /** + /** + * 根据数据源Id,返回使用该数据源的OnlinePage对象。 + * + * @param datasourceId 数据源Id。 + * @return 使用该数据源的页面列表。 + */ + List getOnlinePageListByDatasourceId( + @Param("datasourceId") Long datasourceId, @Param("onlinePageFilter") OnlinePage onlinePageFilter); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineRuleMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineRuleMapper.java new file mode 100644 index 00000000..245ba10b --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineRuleMapper.java @@ -0,0 +1,52 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineRule; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 验证规则数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineRuleMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param onlineRuleFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getOnlineRuleList( + @Param("onlineRuleFilter") OnlineRule onlineRuleFilter, @Param("orderBy") String orderBy); + + /** + * 根据关联主表Id,获取关联从表数据列表。 + * + * @param columnId 关联主表Id。 + * @param onlineRuleFilter 从表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 从表数据列表。 + */ + List getOnlineRuleListByColumnId( + @Param("columnId") Long columnId, + @Param("onlineRuleFilter") OnlineRule onlineRuleFilter, + @Param("orderBy") String orderBy); + + /** + * 根据关联主表Id,获取关联从表中没有和主表建立关联关系的数据列表。 + * + * @param columnId 关联主表Id。 + * @param onlineRuleFilter 过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 与主表没有建立关联的从表数据列表。 + */ + List getNotInOnlineRuleListByColumnId( + @Param("columnId") Long columnId, + @Param("onlineRuleFilter") OnlineRule onlineRuleFilter, + @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineTableMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineTableMapper.java new file mode 100644 index 00000000..238c0bae --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineTableMapper.java @@ -0,0 +1,34 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineTable; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 数据表数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineTableMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param onlineTableFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getOnlineTableList( + @Param("onlineTableFilter") OnlineTable onlineTableFilter, @Param("orderBy") String orderBy); + + /** + * 根据数据源Id,获取该数据源及其关联所引用的数据表列表。 + * + * @param datasourceId 指定的数据源Id。 + * @return 该数据源及其关联所引用的数据表列表。 + */ + List getOnlineTableListByDatasourceId(@Param("datasourceId") Long datasourceId); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineVirtualColumnMapper.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineVirtualColumnMapper.java new file mode 100644 index 00000000..78ca3d20 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineVirtualColumnMapper.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineVirtualColumn; +import org.apache.ibatis.annotations.Param; + +import java.util.*; + +/** + * 虚拟字段数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineVirtualColumnMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param onlineVirtualColumnFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getOnlineVirtualColumnList( + @Param("onlineVirtualColumnFilter") OnlineVirtualColumn onlineVirtualColumnFilter, @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineColumnMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineColumnMapper.xml new file mode 100644 index 00000000..ede95b2e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineColumnMapper.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_online_column.table_id = #{onlineColumnFilter.tableId} + + + AND zz_online_column.column_name = #{onlineColumnFilter.columnName} + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineColumnRuleMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineColumnRuleMapper.xml new file mode 100644 index 00000000..c5afda31 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineColumnRuleMapper.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDatasourceMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDatasourceMapper.xml new file mode 100644 index 00000000..b148a15b --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDatasourceMapper.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_online_datasource.app_code IS NULL + + + AND zz_online_datasource.app_code = #{onlineDatasourceFilter.appCode} + + + AND zz_online_datasource.variable_name = #{onlineDatasourceFilter.variableName} + + + AND zz_online_datasource.datasource_name = #{onlineDatasourceFilter.datasourceName} + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDatasourceRelationMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDatasourceRelationMapper.xml new file mode 100644 index 00000000..c669d3d2 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDatasourceRelationMapper.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_online_datasource_relation.app_code IS NULL + + + AND zz_online_datasource_relation.app_code = #{filter.appCode} + + + AND zz_online_datasource_relation.relation_name = #{filter.relationName} + + + AND zz_online_datasource_relation.datasource_id = #{filter.datasourceId} + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDatasourceTableMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDatasourceTableMapper.xml new file mode 100644 index 00000000..d3ba6aaa --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDatasourceTableMapper.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDblinkMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDblinkMapper.xml new file mode 100644 index 00000000..59f94b1e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDblinkMapper.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_online_dblink.app_code IS NULL + + + AND zz_online_dblink.app_code = #{onlineDblinkFilter.appCode} + + + AND zz_online_dblink.dblink_type = #{onlineDblinkFilter.dblinkType} + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDictMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDictMapper.xml new file mode 100644 index 00000000..cf1fa27e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDictMapper.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_online_dict.dict_id = #{onlineDictFilter.dictId} + + + AND zz_online_dict.app_code IS NULL + + + AND zz_online_dict.app_code = #{onlineDictFilter.appCode} + + + AND zz_online_dict.dict_name = #{onlineDictFilter.dictName} + + + AND zz_online_dict.dict_type = #{onlineDictFilter.dictType} + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineFormDatasourceMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineFormDatasourceMapper.xml new file mode 100644 index 00000000..5d0924ff --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineFormDatasourceMapper.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineFormMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineFormMapper.xml new file mode 100644 index 00000000..a79415be --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineFormMapper.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_online_form.tenant_id IS NULL + + + AND zz_online_form.tenant_id = #{onlineFormFilter.tenantId} + + + AND zz_online_form.app_code IS NULL + + + AND zz_online_form.app_code = #{onlineFormFilter.appCode} + + + AND zz_online_form.page_id = #{onlineFormFilter.pageId} + + + AND zz_online_form.form_code = #{onlineFormFilter.formCode} + + + + AND zz_online_form.form_name LIKE #{safeFormName} + + + AND zz_online_form.form_type = #{onlineFormFilter.formType} + + + AND zz_online_form.master_table_id = #{onlineFormFilter.masterTableId} + + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlinePageDatasourceMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlinePageDatasourceMapper.xml new file mode 100644 index 00000000..47d8b88d --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlinePageDatasourceMapper.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlinePageMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlinePageMapper.xml new file mode 100644 index 00000000..86aeeb21 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlinePageMapper.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_online_page.tenant_id IS NULL + + + AND zz_online_page.tenant_id = #{onlinePageFilter.tenantId} + + + AND zz_online_page.app_code IS NULL + + + AND zz_online_page.app_code = #{onlinePageFilter.appCode} + + + AND zz_online_page.page_code = #{onlinePageFilter.pageCode} + + + + AND zz_online_page.page_name LIKE #{safePageName} + + + AND zz_online_page.page_type = #{onlinePageFilter.pageType} + + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineRuleMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineRuleMapper.xml new file mode 100644 index 00000000..35095622 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineRuleMapper.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + AND (zz_online_rule.app_code IS NULL OR zz_online_rule.builtin = 1) + + + AND (zz_online_rule.app_code = #{onlineRuleFilter.appCode} OR zz_online_rule.builtin = 1) + + + AND zz_online_rule.deleted_flag = ${@com.orangeforms.common.core.constant.GlobalDeletedFlag@NORMAL} + + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineTableMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineTableMapper.xml new file mode 100644 index 00000000..abb2569b --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineTableMapper.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_online_table.app_code IS NULL + + + AND zz_online_table.app_code = #{onlineTableFilter.appCode} + + + AND zz_online_table.table_name = #{onlineTableFilter.tableName} + + + AND zz_online_table.model_name = #{onlineTableFilter.modelName} + + + AND zz_online_table.dblink_id = #{onlineTableFilter.dblinkId} + + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineVirtualColumnMapper.xml b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineVirtualColumnMapper.xml new file mode 100644 index 00000000..1dbc69e8 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineVirtualColumnMapper.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_online_virtual_column.datasource_id = #{onlineVirtualColumnFilter.datasourceId} + + + AND zz_online_virtual_column.relation_id = #{onlineVirtualColumnFilter.relationId} + + + AND zz_online_virtual_column.table_id = #{onlineVirtualColumnFilter.tableId} + + + AND zz_online_virtual_column.aggregation_column_id = #{onlineVirtualColumnFilter.aggregationColumnId} + + + AND zz_online_virtual_column.virtual_type = #{onlineVirtualColumnFilter.virtualType} + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineColumnDto.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineColumnDto.java new file mode 100644 index 00000000..a3713cbf --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineColumnDto.java @@ -0,0 +1,189 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.validator.ConstDictRef; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.online.model.constant.FieldFilterType; +import com.orangeforms.common.online.model.constant.FieldKind; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 在线表单数据表字段Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单数据表字段Dto对象") +@Data +public class OnlineColumnDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long columnId; + + /** + * 字段名。 + */ + @Schema(description = "字段名") + @NotBlank(message = "数据验证失败,字段名不能为空!") + private String columnName; + + /** + * 数据表Id。 + */ + @Schema(description = "数据表Id") + @NotNull(message = "数据验证失败,数据表Id不能为空!") + private Long tableId; + + /** + * 数据表中的字段类型。 + */ + @Schema(description = "数据表中的字段类型") + @NotBlank(message = "数据验证失败,数据表中的字段类型不能为空!") + private String columnType; + + /** + * 数据表中的完整字段类型(包括了精度和刻度)。 + */ + @Schema(description = "数据表中的完整字段类型") + @NotBlank(message = "数据验证失败,数据表中的完整字段类型(包括了精度和刻度)不能为空!") + private String fullColumnType; + + /** + * 是否为主键。 + */ + @Schema(description = "是否为主键") + @NotNull(message = "数据验证失败,是否为主键不能为空!") + private Boolean primaryKey; + + /** + * 是否是自增主键(0: 不是 1: 是)。 + */ + @Schema(description = "是否是自增主键") + @NotNull(message = "数据验证失败,是否是自增主键(0: 不是 1: 是)不能为空!") + private Boolean autoIncrement; + + /** + * 是否可以为空 (0: 不可以为空 1: 可以为空)。 + */ + @Schema(description = "是否可以为空") + @NotNull(message = "数据验证失败,是否可以为空 (0: 不可以为空 1: 可以为空)不能为空!") + private Boolean nullable; + + /** + * 缺省值。 + */ + @Schema(description = "缺省值") + private String columnDefault; + + /** + * 字段在数据表中的显示位置。 + */ + @Schema(description = "字段在数据表中的显示位置") + @NotNull(message = "数据验证失败,字段在数据表中的显示位置不能为空!") + private Integer columnShowOrder; + + /** + * 数据表中的字段注释。 + */ + @Schema(description = "数据表中的字段注释") + private String columnComment; + + /** + * 对象映射字段名称。 + */ + @Schema(description = "对象映射字段名称") + @NotBlank(message = "数据验证失败,对象映射字段名称不能为空!") + private String objectFieldName; + + /** + * 对象映射字段类型。 + */ + @Schema(description = "对象映射字段类型") + @NotBlank(message = "数据验证失败,对象映射字段类型不能为空!") + private String objectFieldType; + + /** + * 数值型字段的精度(目前仅Oracle使用)。 + */ + @Schema(description = "数值型字段的精度") + private Integer numericPrecision; + + /** + * 数值型字段的刻度(小数点后位数,目前仅Oracle使用)。 + */ + @Schema(description = "数值型字段的刻度") + private Integer numericScale; + + /** + * 过滤类型字段。 + */ + @Schema(description = "过滤类型字段") + @NotNull(message = "数据验证失败,过滤类型字段不能为空!", groups = {UpdateGroup.class}) + @ConstDictRef(constDictClass = FieldFilterType.class, message = "数据验证失败,过滤类型字段为无效值!") + private Integer filterType; + + /** + * 是否是主键的父Id。 + */ + @Schema(description = "是否是主键的父Id") + @NotNull(message = "数据验证失败,是否是主键的父Id不能为空!") + private Boolean parentKey; + + /** + * 是否部门过滤字段。 + */ + @Schema(description = "是否部门过滤字段") + @NotNull(message = "数据验证失败,是否部门过滤字段标记不能为空!") + private Boolean deptFilter; + + /** + * 是否用户过滤字段。 + */ + @Schema(description = "是否用户过滤字段") + @NotNull(message = "数据验证失败,是否用户过滤字段标记不能为空!") + private Boolean userFilter; + + /** + * 字段类别。 + */ + @Schema(description = "字段类别") + @ConstDictRef(constDictClass = FieldKind.class, message = "数据验证失败,字段类别为无效值!") + private Integer fieldKind; + + /** + * 包含的文件文件数量,0表示无限制。 + */ + @Schema(description = "包含的文件文件数量,0表示无限制") + private Integer maxFileCount; + + /** + * 上传文件系统类型。 + */ + @Schema(description = "上传文件系统类型") + private Integer uploadFileSystemType; + + /** + * 脱敏字段类型,具体值可参考MaskFieldTypeEnum枚举。 + */ + @Schema(description = "脱敏字段类型") + private String maskFieldType; + + /** + * 编码规则的JSON格式数据。 + */ + @Schema(description = "编码规则的JSON格式数据") + private String encodedRule; + + /** + * 字典Id。 + */ + @Schema(description = "字典Id") + private Long dictId; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineColumnRuleDto.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineColumnRuleDto.java new file mode 100644 index 00000000..d6789157 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineColumnRuleDto.java @@ -0,0 +1,38 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.validator.UpdateGroup; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotNull; + +/** + * 在线表单数据表字段规则和字段多对多关联Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单数据表字段规则和字段多对多关联Dto对象") +@Data +public class OnlineColumnRuleDto { + + /** + * 字段Id。 + */ + @Schema(description = "字段Id") + @NotNull(message = "数据验证失败,字段Id不能为空!", groups = {UpdateGroup.class}) + private Long columnId; + + /** + * 规则Id。 + */ + @Schema(description = "规则Id") + @NotNull(message = "数据验证失败,规则Id不能为空!", groups = {UpdateGroup.class}) + private Long ruleId; + + /** + * 规则属性数据。 + */ + @Schema(description = "规则属性数据") + private String propDataJson; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDatasourceDto.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDatasourceDto.java new file mode 100644 index 00000000..0fbb006d --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDatasourceDto.java @@ -0,0 +1,62 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.validator.AddGroup; +import com.orangeforms.common.core.validator.UpdateGroup; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 在线表单的数据源Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单的数据源Dto对象") +@Data +public class OnlineDatasourceDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long datasourceId; + + /** + * 数据源名称。 + */ + @Schema(description = "数据源名称") + @NotBlank(message = "数据验证失败,数据源名称不能为空!") + private String datasourceName; + + /** + * 数据源变量名,会成为数据访问url的一部分。 + */ + @Schema(description = "数据源变量名,会成为数据访问url的一部分") + @NotBlank(message = "数据验证失败,数据源变量名不能为空!") + private String variableName; + + /** + * 主表所在的数据库链接Id。 + */ + @Schema(description = "主表所在的数据库链接Id") + @NotNull(message = "数据验证失败,数据库链接Id不能为空!") + private Long dblinkId; + + /** + * 主表Id。 + */ + @Schema(description = "主表Id") + @NotNull(message = "数据验证失败,主表Id不能为空!", groups = {UpdateGroup.class}) + private Long masterTableId; + + /** + * 主表表名。 + */ + @Schema(description = "主表表名") + @NotBlank(message = "数据验证失败,主表名不能为空!", groups = {AddGroup.class}) + private String masterTableName; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDatasourceRelationDto.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDatasourceRelationDto.java new file mode 100644 index 00000000..3ad19465 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDatasourceRelationDto.java @@ -0,0 +1,107 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.validator.AddGroup; +import com.orangeforms.common.core.validator.ConstDictRef; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.online.model.constant.RelationType; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 在线表单的数据源关联Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单的数据源关联Dto对象") +@Data +public class OnlineDatasourceRelationDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long relationId; + + /** + * 关联名称。 + */ + @Schema(description = "关联名称") + @NotBlank(message = "数据验证失败,关联名称不能为空!") + private String relationName; + + /** + * 变量名。 + */ + @Schema(description = "变量名") + @NotBlank(message = "数据验证失败,变量名不能为空!") + private String variableName; + + /** + * 主数据源Id。 + */ + @Schema(description = "主数据源Id") + @NotNull(message = "数据验证失败,主数据源Id不能为空!") + private Long datasourceId; + + /** + * 关联类型。 + */ + @Schema(description = "关联类型") + @NotNull(message = "数据验证失败,关联类型不能为空!") + @ConstDictRef(constDictClass = RelationType.class, message = "数据验证失败,关联类型为无效值!") + private Integer relationType; + + /** + * 主表关联字段Id。 + */ + @Schema(description = "主表关联字段Id") + @NotNull(message = "数据验证失败,主表关联字段Id不能为空!") + private Long masterColumnId; + + /** + * 从表Id。 + */ + @Schema(description = "从表Id") + @NotNull(message = "数据验证失败,从表Id不能为空!", groups = {UpdateGroup.class}) + private Long slaveTableId; + + /** + * 从表名。 + */ + @Schema(description = "从表名") + @NotBlank(message = "数据验证失败,从表名不能为空!", groups = {AddGroup.class}) + private String slaveTableName; + + /** + * 从表关联字段Id。 + */ + @Schema(description = "从表关联字段Id") + @NotNull(message = "数据验证失败,从表关联字段Id不能为空!", groups = {UpdateGroup.class}) + private Long slaveColumnId; + + /** + * 从表字段名。 + */ + @Schema(description = "从表字段名") + @NotBlank(message = "数据验证失败,从表字段名不能为空!", groups = {AddGroup.class}) + private String slaveColumnName; + + /** + * 是否级联删除标记。 + */ + @Schema(description = "是否级联删除标记") + @NotNull(message = "数据验证失败,是否级联删除标记不能为空!") + private Boolean cascadeDelete; + + /** + * 是否左连接标记。 + */ + @Schema(description = "是否左连接标记") + @NotNull(message = "数据验证失败,是否左连接标记不能为空!") + private Boolean leftJoin; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDblinkDto.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDblinkDto.java new file mode 100644 index 00000000..2e1f2488 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDblinkDto.java @@ -0,0 +1,53 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.validator.UpdateGroup; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 在线表单数据表所在数据库链接Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单数据表所在数据库链接Dto对象") +@Data +public class OnlineDblinkDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long dblinkId; + + /** + * 链接中文名称。 + */ + @Schema(description = "链接中文名称") + @NotBlank(message = "数据验证失败,链接中文名称不能为空!") + private String dblinkName; + + /** + * 链接描述。 + */ + @Schema(description = "链接中文名称") + private String dblinkDescription; + + /** + * 配置信息。 + */ + @Schema(description = "配置信息") + @NotBlank(message = "数据验证失败,配置信息不能为空!") + private String configuration; + + /** + * 数据库链接类型。 + */ + @Schema(description = "数据库链接类型") + @NotNull(message = "数据验证失败,数据库链接类型不能为空!") + private Integer dblinkType; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDictDto.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDictDto.java new file mode 100644 index 00000000..f25444ce --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDictDto.java @@ -0,0 +1,128 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.validator.ConstDictRef; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.core.constant.DictType; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 在线表单关联的字典Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单关联的字典Dto对象") +@Data +public class OnlineDictDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long dictId; + + /** + * 字典名称。 + */ + @Schema(description = "字典名称") + @NotBlank(message = "数据验证失败,字典名称不能为空!") + private String dictName; + + /** + * 字典类型。 + */ + @Schema(description = "字典类型") + @NotNull(message = "数据验证失败,字典类型不能为空!") + @ConstDictRef(constDictClass = DictType.class, message = "数据验证失败,字典类型为无效值!") + private Integer dictType; + + /** + * 数据库链接Id。 + */ + @Schema(description = "数据库链接Id") + private Long dblinkId; + + /** + * 字典表名称。 + */ + @Schema(description = "字典表名称") + private String tableName; + + /** + * 全局字典编码。 + */ + @Schema(description = "全局字典编码") + private String dictCode; + + /** + * 字典表键字段名称。 + */ + @Schema(description = "字典表键字段名称") + private String keyColumnName; + + /** + * 字典表父键字段名称。 + */ + @Schema(description = "字典表父键字段名称") + private String parentKeyColumnName; + + /** + * 字典值字段名称。 + */ + @Schema(description = "字典值字段名称") + private String valueColumnName; + + /** + * 逻辑删除字段。 + */ + @Schema(description = "逻辑删除字段") + private String deletedColumnName; + + /** + * 用户过滤滤字段名称。 + */ + @Schema(description = "用户过滤滤字段名称") + private String userFilterColumnName; + + /** + * 部门过滤字段名称。 + */ + @Schema(description = "部门过滤字段名称") + private String deptFilterColumnName; + + /** + * 租户过滤字段名称。 + */ + @Schema(description = "租户过滤字段名称") + private String tenantFilterColumnName; + + /** + * 获取字典数据的url。 + */ + @Schema(description = "获取字典数据的url") + private String dictListUrl; + + /** + * 根据主键id批量获取字典数据的url。 + */ + @Schema(description = "根据主键id批量获取字典数据的url") + private String dictIdsUrl; + + /** + * 字典的JSON数据。 + */ + @Schema(description = "字典的JSON数据") + private String dictDataJson; + + /** + * 是否树形标记。 + */ + @Schema(description = "是否树形标记") + @NotNull(message = "数据验证失败,是否树形标记不能为空!") + private Boolean treeFlag; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineFilterDto.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineFilterDto.java new file mode 100644 index 00000000..8d638b90 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineFilterDto.java @@ -0,0 +1,72 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.online.model.constant.FieldFilterType; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.util.Set; + +/** + * 在线表单数据过滤参数对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单数据过滤参数对象") +@Data +public class OnlineFilterDto { + + /** + * 表名。 + */ + @Schema(description = "表名") + private String tableName; + + /** + * 过滤字段名。 + */ + @Schema(description = "过滤字段名") + private String columnName; + + /** + * 过滤值。 + */ + @Schema(description = "过滤值") + private Object columnValue; + + /** + * 范围比较的最小值。 + */ + @Schema(description = "范围比较的最小值") + private Object columnValueStart; + + /** + * 范围比较的最大值。 + */ + @Schema(description = "范围比较的最大值") + private Object columnValueEnd; + + /** + * 仅当操作符为IN的时候使用。 + */ + @Schema(description = "仅当操作符为IN的时候使用") + private Set columnValueList; + + /** + * 过滤类型,参考FieldFilterType常量对象。缺省值就是等于过滤了。 + */ + @Schema(description = "过滤类型") + private Integer filterType = FieldFilterType.EQUAL_FILTER; + + /** + * 是否为字典多选。 + */ + @Schema(description = "是否为字典多选") + private Boolean dictMultiSelect = false; + + /** + * 是否为Oracle的日期类型。 + */ + private Boolean isOracleDate = false; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineFormDto.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineFormDto.java new file mode 100644 index 00000000..2abcde8c --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineFormDto.java @@ -0,0 +1,91 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.validator.ConstDictRef; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.online.model.constant.FormKind; +import com.orangeforms.common.online.model.constant.FormType; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import java.util.List; + +/** + * 在线表单Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单Dto对象") +@Data +public class OnlineFormDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long formId; + + /** + * 页面id。 + */ + @Schema(description = "页面id") + @NotNull(message = "数据验证失败,页面id不能为空!") + private Long pageId; + + /** + * 表单编码。 + */ + @Schema(description = "表单编码") + private String formCode; + + /** + * 表单名称。 + */ + @Schema(description = "表单名称") + @NotBlank(message = "数据验证失败,表单名称不能为空!") + private String formName; + + /** + * 表单类别。 + */ + @Schema(description = "表单类别") + @NotNull(message = "数据验证失败,表单类别不能为空!") + @ConstDictRef(constDictClass = FormKind.class, message = "数据验证失败,表单类别为无效值!") + private Integer formKind; + + /** + * 表单类型。 + */ + @Schema(description = "表单类型") + @NotNull(message = "数据验证失败,表单类型不能为空!") + @ConstDictRef(constDictClass = FormType.class, message = "数据验证失败,表单类型为无效值!") + private Integer formType; + + /** + * 表单主表id。 + */ + @Schema(description = "表单主表id") + @NotNull(message = "数据验证失败,表单主表id不能为空!") + private Long masterTableId; + + /** + * 当前表单关联的数据源Id集合。 + */ + @Schema(description = "当前表单关联的数据源Id集合") + private List datasourceIdList; + + /** + * 表单组件JSON。 + */ + @Schema(description = "表单组件JSON") + private String widgetJson; + + /** + * 表单参数JSON。 + */ + @Schema(description = "表单参数JSON") + private String paramsJson; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlinePageDatasourceDto.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlinePageDatasourceDto.java new file mode 100644 index 00000000..e6a3c3c3 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlinePageDatasourceDto.java @@ -0,0 +1,39 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.validator.UpdateGroup; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotNull; + +/** + * 在线表单页面和数据源多对多关联Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单页面和数据源多对多关联Dto对象") +@Data +public class OnlinePageDatasourceDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long id; + + /** + * 页面主键Id。 + */ + @Schema(description = "页面主键Id") + @NotNull(message = "数据验证失败,页面主键Id不能为空!") + private Long pageId; + + /** + * 数据源主键Id。 + */ + @Schema(description = "数据源主键Id") + @NotNull(message = "数据验证失败,数据源主键Id不能为空!") + private Long datasourceId; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlinePageDto.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlinePageDto.java new file mode 100644 index 00000000..309c3bf4 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlinePageDto.java @@ -0,0 +1,58 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.validator.ConstDictRef; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.online.model.constant.PageStatus; +import com.orangeforms.common.online.model.constant.PageType; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 在线表单所在页面Dto对象。这里我们可以把页面理解为表单的容器。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单所在页面Dto对象") +@Data +public class OnlinePageDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long pageId; + + /** + * 页面编码。 + */ + @Schema(description = "页面编码") + private String pageCode; + + /** + * 页面名称。 + */ + @Schema(description = "页面名称") + @NotBlank(message = "数据验证失败,页面名称不能为空!") + private String pageName; + + /** + * 页面类型。 + */ + @Schema(description = "页面类型") + @NotNull(message = "数据验证失败,页面类型不能为空!") + @ConstDictRef(constDictClass = PageType.class, message = "数据验证失败,页面类型为无效值!") + private Integer pageType; + + /** + * 页面编辑状态。 + */ + @Schema(description = "页面编辑状态") + @NotNull(message = "数据验证失败,状态不能为空!") + @ConstDictRef(constDictClass = PageStatus.class, message = "数据验证失败,状态为无效值!") + private Integer status; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineRuleDto.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineRuleDto.java new file mode 100644 index 00000000..e89517c0 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineRuleDto.java @@ -0,0 +1,56 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.validator.ConstDictRef; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.online.model.constant.RuleType; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 在线表单数据表字段验证规则Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单数据表字段验证规则Dto对象") +@Data +public class OnlineRuleDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long ruleId; + + /** + * 规则名称。 + */ + @Schema(description = "规则名称") + @NotBlank(message = "数据验证失败,规则名称不能为空!") + private String ruleName; + + /** + * 规则类型。 + */ + @Schema(description = "规则类型") + @NotNull(message = "数据验证失败,规则类型不能为空!") + @ConstDictRef(constDictClass = RuleType.class, message = "数据验证失败,规则类型为无效值!") + private Integer ruleType; + + /** + * 内置规则标记。 + */ + @Schema(description = "内置规则标记") + @NotNull(message = "数据验证失败,内置规则标记不能为空!") + private Boolean builtin; + + /** + * 自定义规则的正则表达式。 + */ + @Schema(description = "自定义规则的正则表达式") + private String pattern; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineTableDto.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineTableDto.java new file mode 100644 index 00000000..774f985b --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineTableDto.java @@ -0,0 +1,47 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.validator.UpdateGroup; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 在线表单的数据表Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单的数据表Dto对象") +@Data +public class OnlineTableDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long tableId; + + /** + * 表名称。 + */ + @Schema(description = "表名称") + @NotBlank(message = "数据验证失败,表名称不能为空!") + private String tableName; + + /** + * 实体名称。 + */ + @Schema(description = "实体名称") + @NotBlank(message = "数据验证失败,实体名称不能为空!") + private String modelName; + + /** + * 数据库链接Id。 + */ + @Schema(description = "数据库链接Id") + @NotNull(message = "数据验证失败,数据库链接Id不能为空!") + private Long dblinkId; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineVirtualColumnDto.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineVirtualColumnDto.java new file mode 100644 index 00000000..040850de --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineVirtualColumnDto.java @@ -0,0 +1,102 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.constant.AggregationType; +import com.orangeforms.common.core.validator.ConstDictRef; +import com.orangeforms.common.core.validator.UpdateGroup; +import io.swagger.v3.oas.annotations.media.Schema; + +import com.orangeforms.common.online.model.constant.VirtualType; +import lombok.Data; + +import jakarta.validation.constraints.*; + +/** + * 在线数据表虚拟字段Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线数据表虚拟字段Dto对象") +@Data +public class OnlineVirtualColumnDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long virtualColumnId; + + /** + * 所在表Id。 + */ + @Schema(description = "所在表Id") + private Long tableId; + + /** + * 字段名称。 + */ + @Schema(description = "字段名称") + @NotBlank(message = "数据验证失败,字段名称不能为空!") + private String objectFieldName; + + /** + * 属性类型。 + */ + @Schema(description = "属性类型") + @NotBlank(message = "数据验证失败,属性类型不能为空!") + private String objectFieldType; + + /** + * 字段提示名。 + */ + @Schema(description = "字段提示名") + @NotBlank(message = "数据验证失败,字段提示名不能为空!") + private String columnPrompt; + + /** + * 虚拟字段类型(0: 聚合)。 + */ + @Schema(description = "虚拟字段类型(0: 聚合)") + @ConstDictRef(constDictClass = VirtualType.class, message = "数据验证失败,虚拟字段类型为无效值!") + @NotNull(message = "数据验证失败,虚拟字段类型(0: 聚合)不能为空!") + private Integer virtualType; + + /** + * 关联数据源Id。 + */ + @Schema(description = "关联数据源Id") + @NotNull(message = "数据验证失败,关联数据源Id不能为空!") + private Long datasourceId; + + /** + * 关联Id。 + */ + @Schema(description = "关联Id") + private Long relationId; + + /** + * 聚合字段所在关联表Id。 + */ + @Schema(description = "聚合字段所在关联表Id") + private Long aggregationTableId; + + /** + * 关联表聚合字段Id。 + */ + @Schema(description = "关联表聚合字段Id") + private Long aggregationColumnId; + + /** + * 聚合类型(0: sum 1: count 2: avg 3: min 4: max)。 + */ + @Schema(description = "聚合类型(0: sum 1: count 2: avg 3: min 4: max)") + @ConstDictRef(constDictClass = AggregationType.class, message = "数据验证失败,虚拟字段聚合计算类型为无效值!") + private Integer aggregationType; + + /** + * 存储过滤条件的json。 + */ + @Schema(description = "存储过滤条件的json") + private String whereClauseJson; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/exception/OnlineRuntimeException.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/exception/OnlineRuntimeException.java new file mode 100644 index 00000000..a2ac52f2 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/exception/OnlineRuntimeException.java @@ -0,0 +1,28 @@ +package com.orangeforms.common.online.exception; + +import com.orangeforms.common.core.exception.MyRuntimeException; + +/** + * 在线表单运行时异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class OnlineRuntimeException extends MyRuntimeException { + + /** + * 构造函数。 + */ + public OnlineRuntimeException() { + + } + + /** + * 构造函数。 + * + * @param msg 错误信息。 + */ + public OnlineRuntimeException(String msg) { + super(msg); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineColumn.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineColumn.java new file mode 100644 index 00000000..0c1d2cff --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineColumn.java @@ -0,0 +1,215 @@ +package com.orangeforms.common.online.model; + +import com.mybatisflex.annotation.*; +import com.orangeforms.common.core.annotation.RelationConstDict; +import com.orangeforms.common.core.annotation.RelationOneToOne; +import com.orangeforms.common.online.model.constant.FieldKind; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单数据表字段实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_online_column") +public class OnlineColumn { + + /** + * 主键Id。 + */ + @Id(value = "column_id") + private Long columnId; + + /** + * 字段名。 + */ + @Column(value = "column_name") + private String columnName; + + /** + * 数据表Id。 + */ + @Column(value = "table_id") + private Long tableId; + + /** + * 数据表中的字段类型。 + */ + @Column(value = "column_type") + private String columnType; + + /** + * 数据表中的完整字段类型(包括了精度和刻度)。 + */ + @Column(value = "full_column_type") + private String fullColumnType; + + /** + * 是否为主键。 + */ + @Column(value = "primary_key") + private Boolean primaryKey; + + /** + * 是否是自增主键(0: 不是 1: 是)。 + */ + @Column(value = "auto_incr") + private Boolean autoIncrement; + + /** + * 是否可以为空 (0: 不可以为空 1: 可以为空)。 + */ + @Column(value = "nullable") + private Boolean nullable; + + /** + * 缺省值。 + */ + @Column(value = "column_default") + private String columnDefault; + + /** + * 字段在数据表中的显示位置。 + */ + @Column(value = "column_show_order") + private Integer columnShowOrder; + + /** + * 数据表中的字段注释。 + */ + @Column(value = "column_comment") + private String columnComment; + + /** + * 对象映射字段名称。 + */ + @Column(value = "object_field_name") + private String objectFieldName; + + /** + * 对象映射字段类型。 + */ + @Column(value = "object_field_type") + private String objectFieldType; + + /** + * 数值型字段的精度(目前仅Oracle使用)。 + */ + @Column(value = "numeric_precision") + private Integer numericPrecision; + + /** + * 数值型字段的刻度(小数点后位数,目前仅Oracle使用)。 + */ + @Column(value = "numeric_scale") + private Integer numericScale; + + /** + * 过滤字段类型。 + */ + @Column(value = "filter_type") + private Integer filterType; + + /** + * 是否是主键的父Id。 + */ + @Column(value = "parent_key") + private Boolean parentKey; + + /** + * 是否部门过滤字段。 + */ + @Column(value = "dept_filter") + private Boolean deptFilter; + + /** + * 是否用户过滤字段。 + */ + @Column(value = "user_filter") + private Boolean userFilter; + + /** + * 字段类别。 + */ + @Column(value = "field_kind") + private Integer fieldKind; + + /** + * 包含的文件文件数量,0表示无限制。 + */ + @Column(value = "max_file_count") + private Integer maxFileCount; + + /** + * 上传文件系统类型。 + */ + @Column(value = "upload_file_system_type") + private Integer uploadFileSystemType; + + /** + * 编码规则的JSON格式数据。 + */ + @Column(value = "encoded_rule") + private String encodedRule; + + /** + * 脱敏字段类型,具体值可参考MaskFieldTypeEnum枚举。 + */ + @Column(value = "mask_field_type") + private String maskFieldType; + + /** + * 字典Id。 + */ + @Column(value = "dict_id") + private Long dictId; + + /** + * 创建时间。 + */ + @Column(value = "create_time") + private Date createTime; + + /** + * 创建者。 + */ + @Column(value = "create_user_id") + private Long createUserId; + + /** + * 更新时间。 + */ + @Column(value = "update_time") + private Date updateTime; + + /** + * 更新者。 + */ + @Column(value = "update_user_id") + private Long updateUserId; + + /** + * SQL查询时候使用的别名。 + */ + @Column(ignore = true) + private String columnAliasName; + + @RelationConstDict( + masterIdField = "fieldKind", + constantDictClass = FieldKind.class) + @Column(ignore = true) + private Map fieldKindDictMap; + + @RelationOneToOne( + masterIdField = "dictId", + slaveModelClass = OnlineDict.class, + slaveIdField = "dictId", + loadSlaveDict = false) + @Column(ignore = true) + private OnlineDict dictInfo; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineColumnRule.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineColumnRule.java new file mode 100644 index 00000000..f04517af --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineColumnRule.java @@ -0,0 +1,36 @@ +package com.orangeforms.common.online.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; + +/** + * 在线表单数据表字段规则和字段多对多关联实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_online_column_rule") +public class OnlineColumnRule { + + /** + * 字段Id。 + */ + @Column(value = "column_id") + private Long columnId; + + /** + * 规则Id。 + */ + @Column(value = "rule_id") + private Long ruleId; + + /** + * 规则属性数据。 + */ + @Column(value = "prop_data_json") + private String propDataJson; + + @Column(ignore = true) + private OnlineRule onlineRule; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDatasource.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDatasource.java new file mode 100644 index 00000000..2ac6c3a7 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDatasource.java @@ -0,0 +1,103 @@ +package com.orangeforms.common.online.model; + +import com.mybatisflex.annotation.*; +import com.orangeforms.common.core.annotation.RelationDict; +import lombok.Data; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 在线表单的数据源实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_online_datasource") +public class OnlineDatasource { + + /** + * 主键Id。 + */ + @Id(value = "datasource_id") + private Long datasourceId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Column(value = "app_code") + private String appCode; + + /** + * 数据源名称。 + */ + @Column(value = "datasource_name") + private String datasourceName; + + /** + * 数据源变量名,会成为数据访问url的一部分。 + */ + @Column(value = "variable_name") + private String variableName; + + /** + * 数据库链接Id。 + */ + @Column(value = "dblink_id") + private Long dblinkId; + + /** + * 主表Id。 + */ + @Column(value = "master_table_id") + private Long masterTableId; + + /** + * 创建时间。 + */ + @Column(value = "create_time") + private Date createTime; + + /** + * 创建者。 + */ + @Column(value = "create_user_id") + private Long createUserId; + + /** + * 更新时间。 + */ + @Column(value = "update_time") + private Date updateTime; + + /** + * 更新者。 + */ + @Column(value = "update_user_id") + private Long updateUserId; + + /** + * datasourceId 的多对多关联的数据对象。 + */ + @Column(ignore = true) + private OnlinePageDatasource onlinePageDatasource; + + /** + * datasourceId 的多对多关联的数据对象。 + */ + @Column(ignore = true) + private List onlineFormDatasourceList; + + @RelationDict( + masterIdField = "masterTableId", + slaveModelClass = OnlineTable.class, + slaveIdField = "tableId", + slaveNameField = "tableName") + @Column(ignore = true) + private Map masterTableIdDictMap; + + @Column(ignore = true) + private OnlineTable masterTable; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDatasourceRelation.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDatasourceRelation.java new file mode 100644 index 00000000..be965365 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDatasourceRelation.java @@ -0,0 +1,166 @@ +package com.orangeforms.common.online.model; + +import com.mybatisflex.annotation.*; +import com.orangeforms.common.core.annotation.RelationConstDict; +import com.orangeforms.common.core.annotation.RelationDict; +import com.orangeforms.common.core.annotation.RelationOneToOne; +import com.orangeforms.common.online.model.constant.RelationType; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单的数据源关联实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_online_datasource_relation") +public class OnlineDatasourceRelation { + + /** + * 主键Id。 + */ + @Id(value = "relation_id") + private Long relationId; + + /** + * 应用Id。为空时,表示非第三方应用接入。 + */ + @Column(value = "app_code") + private String appCode; + + /** + * 关联名称。 + */ + @Column(value = "relation_name") + private String relationName; + + /** + * 变量名。 + */ + @Column(value = "variable_name") + private String variableName; + + /** + * 主数据源Id。 + */ + @Column(value = "datasource_id") + private Long datasourceId; + + /** + * 关联类型。 + */ + @Column(value = "relation_type") + private Integer relationType; + + /** + * 主表关联字段Id。 + */ + @Column(value = "master_column_id") + private Long masterColumnId; + + /** + * 从表Id。 + */ + @Column(value = "slave_table_id") + private Long slaveTableId; + + /** + * 从表关联字段Id。 + */ + @Column(value = "slave_column_id") + private Long slaveColumnId; + + /** + * 删除主表的时候是否级联删除一对一和一对多的从表数据,多对多只是删除关联,不受到这个标记的影响。。 + */ + @Column(value = "cascade_delete") + private Boolean cascadeDelete; + + /** + * 是否左连接。 + */ + @Column(value = "left_join") + private Boolean leftJoin; + + /** + * 创建时间。 + */ + @Column(value = "create_time") + private Date createTime; + + /** + * 创建者。 + */ + @Column(value = "create_user_id") + private Long createUserId; + + /** + * 更新时间。 + */ + @Column(value = "update_time") + private Date updateTime; + + /** + * 更新者。 + */ + @Column(value = "update_user_id") + private Long updateUserId; + + @RelationOneToOne( + masterIdField = "masterColumnId", + slaveModelClass = OnlineColumn.class, + slaveIdField = "columnId") + @Column(ignore = true) + private OnlineColumn masterColumn; + + @RelationOneToOne( + masterIdField = "slaveTableId", + slaveModelClass = OnlineTable.class, + slaveIdField = "tableId") + @Column(ignore = true) + private OnlineTable slaveTable; + + @RelationOneToOne( + masterIdField = "slaveColumnId", + slaveModelClass = OnlineColumn.class, + slaveIdField = "columnId") + @Column(ignore = true) + private OnlineColumn slaveColumn; + + @RelationDict( + masterIdField = "masterColumnId", + equalOneToOneRelationField = "onlineColumn", + slaveModelClass = OnlineColumn.class, + slaveIdField = "columnId", + slaveNameField = "columnName") + @Column(ignore = true) + private Map masterColumnIdDictMap; + + @RelationDict( + masterIdField = "slaveTableId", + equalOneToOneRelationField = "onlineTable", + slaveModelClass = OnlineTable.class, + slaveIdField = "tableId", + slaveNameField = "modelName") + @Column(ignore = true) + private Map slaveTableIdDictMap; + + @RelationDict( + masterIdField = "slaveColumnId", + equalOneToOneRelationField = "onlineColumn", + slaveModelClass = OnlineColumn.class, + slaveIdField = "columnId", + slaveNameField = "columnName") + @Column(ignore = true) + private Map slaveColumnIdDictMap; + + @RelationConstDict( + masterIdField = "relationType", + constantDictClass = RelationType.class) + @Column(ignore = true) + private Map relationTypeDictMap; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDatasourceTable.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDatasourceTable.java new file mode 100644 index 00000000..c7bf696f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDatasourceTable.java @@ -0,0 +1,39 @@ +package com.orangeforms.common.online.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; + +/** + * 数据源及其关联所引用的数据表实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_online_datasource_table") +public class OnlineDatasourceTable { + + /** + * 主键Id。 + */ + @Id(value = "id") + private Long id; + + /** + * 数据源Id。 + */ + @Column(value = "datasource_id") + private Long datasourceId; + + /** + * 数据源关联Id。 + */ + @Column(value = "relation_id") + private Long relationId; + + /** + * 数据表Id。 + */ + @Column(value = "table_id") + private Long tableId; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDblink.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDblink.java new file mode 100644 index 00000000..343b6bec --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDblink.java @@ -0,0 +1,85 @@ +package com.orangeforms.common.online.model; + +import com.mybatisflex.annotation.*; +import com.orangeforms.common.core.annotation.RelationConstDict; +import com.orangeforms.common.dbutil.constant.DblinkType; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单数据表所在数据库链接实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_online_dblink") +public class OnlineDblink { + + /** + * 主键Id。 + */ + @Id(value = "dblink_id") + private Long dblinkId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Column(value = "app_code") + private String appCode; + + /** + * 链接中文名称。 + */ + @Column(value = "dblink_name") + private String dblinkName; + + /** + * 链接描述。 + */ + @Column(value = "dblink_description") + private String dblinkDescription; + + /** + * 配置信息。 + */ + private String configuration; + + /** + * 数据库链接类型。 + */ + @Column(value = "dblink_type") + private Integer dblinkType; + + /** + * 创建时间。 + */ + @Column(value = "create_time") + private Date createTime; + + /** + * 创建者。 + */ + @Column(value = "create_user_id") + private Long createUserId; + + /** + * 修改时间。 + */ + @Column(value = "update_time") + private Date updateTime; + + /** + * 更新者。 + */ + @Column(value = "update_user_id") + private Long updateUserId; + + @RelationConstDict( + masterIdField = "dblinkType", + constantDictClass = DblinkType.class) + @Column(ignore = true) + private Map dblinkTypeDictMap; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDict.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDict.java new file mode 100644 index 00000000..c93d97ec --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDict.java @@ -0,0 +1,167 @@ +package com.orangeforms.common.online.model; + +import com.mybatisflex.annotation.*; +import com.orangeforms.common.core.annotation.RelationConstDict; +import com.orangeforms.common.core.annotation.RelationDict; +import com.orangeforms.common.core.constant.DictType; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单关联的字典实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_online_dict") +public class OnlineDict { + + /** + * 主键Id。 + */ + @Id(value = "dict_id") + private Long dictId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Column(value = "app_code") + private String appCode; + + /** + * 字典名称。 + */ + @Column(value = "dict_name") + private String dictName; + + /** + * 字典类型。 + */ + @Column(value = "dict_type") + private Integer dictType; + + /** + * 数据库链接Id。 + */ + @Column(value = "dblink_id") + private Long dblinkId; + + /** + * 字典表名称。 + */ + @Column(value = "table_name") + private String tableName; + + /** + * 全局字典编码。 + */ + @Column(value = "dict_code") + private String dictCode; + + /** + * 字典表键字段名称。 + */ + @Column(value = "key_column_name") + private String keyColumnName; + + /** + * 字典表父键字段名称。 + */ + @Column(value = "parent_key_column_name") + private String parentKeyColumnName; + + /** + * 字典值字段名称。 + */ + @Column(value = "value_column_name") + private String valueColumnName; + + /** + * 逻辑删除字段。 + */ + @Column(value = "deleted_column_name") + private String deletedColumnName; + + /** + * 用户过滤滤字段名称。 + */ + @Column(value = "user_filter_column_name") + private String userFilterColumnName; + + /** + * 部门过滤字段名称。 + */ + @Column(value = "dept_filter_column_name") + private String deptFilterColumnName; + + /** + * 租户过滤字段名称。 + */ + @Column(value = "tenant_filter_column_name") + private String tenantFilterColumnName; + + /** + * 是否树形标记。 + */ + @Column(value = "tree_flag") + private Boolean treeFlag; + + /** + * 获取字典数据的url。 + */ + @Column(value = "dict_list_url") + private String dictListUrl; + + /** + * 根据主键id批量获取字典数据的url。 + */ + @Column(value = "dict_ids_url") + private String dictIdsUrl; + + /** + * 字典的JSON数据。 + */ + @Column(value = "dict_data_json") + private String dictDataJson; + + /** + * 创建时间。 + */ + @Column(value = "create_time") + private Date createTime; + + /** + * 创建者。 + */ + @Column(value = "create_user_id") + private Long createUserId; + + /** + * 更新时间。 + */ + @Column(value = "update_time") + private Date updateTime; + + /** + * 更新者。 + */ + @Column(value = "update_user_id") + private Long updateUserId; + + @RelationConstDict( + masterIdField = "dictType", + constantDictClass = DictType.class) + @Column(ignore = true) + private Map dictTypeDictMap; + + @RelationDict( + masterIdField = "dblinkId", + slaveModelClass = OnlineDblink.class, + slaveIdField = "dblinkId", + slaveNameField = "dblinkName") + @Column(ignore = true) + private Map dblinkIdDictMap; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineForm.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineForm.java new file mode 100644 index 00000000..7b671060 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineForm.java @@ -0,0 +1,134 @@ +package com.orangeforms.common.online.model; + +import com.mybatisflex.annotation.Column; +import com.mybatisflex.annotation.Id; +import com.mybatisflex.annotation.Table; +import com.orangeforms.common.core.annotation.*; +import com.orangeforms.common.online.model.constant.FormType; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_online_form") +public class OnlineForm { + + /** + * 主键Id。 + */ + @Id(value = "form_id") + private Long formId; + + /** + * 租户Id。 + */ + @Column(value = "tenant_id") + private Long tenantId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Column(value = "app_code") + private String appCode; + + /** + * 页面id。 + */ + @Column(value = "page_id") + private Long pageId; + + /** + * 表单编码。 + */ + @Column(value = "form_code") + private String formCode; + + /** + * 表单名称。 + */ + @Column(value = "form_name") + private String formName; + + /** + * 表单类别。 + */ + @Column(value = "form_kind") + private Integer formKind; + + /** + * 表单类型。 + */ + @Column(value = "form_type") + private Integer formType; + + /** + * 表单主表id。 + */ + @Column(value = "master_table_id") + private Long masterTableId; + + /** + * 表单组件JSON。 + */ + @Column(value = "widget_json") + private String widgetJson; + + /** + * 表单参数JSON。 + */ + @Column(value = "params_json") + private String paramsJson; + + /** + * 创建时间。 + */ + @Column(value = "create_time") + private Date createTime; + + /** + * 创建者。 + */ + @Column(value = "create_user_id") + private Long createUserId; + + /** + * 更新时间。 + */ + @Column(value = "update_time") + private Date updateTime; + + /** + * 更新者。 + */ + @Column(value = "update_user_id") + private Long updateUserId; + + @RelationOneToOne( + masterIdField = "masterTableId", + slaveModelClass = OnlineTable.class, + slaveIdField = "tableId") + @Column(ignore = true) + private OnlineTable onlineTable; + + @RelationDict( + masterIdField = "masterTableId", + equalOneToOneRelationField = "onlineTable", + slaveModelClass = OnlineTable.class, + slaveIdField = "tableId", + slaveNameField = "modelName") + @Column(ignore = true) + private Map masterTableIdDictMap; + + @RelationConstDict( + masterIdField = "formType", + constantDictClass = FormType.class) + @Column(ignore = true) + private Map formTypeDictMap; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineFormDatasource.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineFormDatasource.java new file mode 100644 index 00000000..4e756604 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineFormDatasource.java @@ -0,0 +1,33 @@ +package com.orangeforms.common.online.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; + +/** + * 在线表单和数据源多对多关联实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_online_form_datasource") +public class OnlineFormDatasource { + + /** + * 主键Id。 + */ + @Id(value = "id") + private Long id; + + /** + * 表单Id。 + */ + @Column(value = "form_id") + private Long formId; + + /** + * 数据源Id。 + */ + @Column(value = "datasource_id") + private Long datasourceId; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlinePage.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlinePage.java new file mode 100644 index 00000000..a4138a60 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlinePage.java @@ -0,0 +1,105 @@ +package com.orangeforms.common.online.model; + +import com.mybatisflex.annotation.*; +import com.orangeforms.common.core.annotation.RelationConstDict; +import com.orangeforms.common.online.model.constant.PageStatus; +import com.orangeforms.common.online.model.constant.PageType; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单所在页面实体对象。这里我们可以把页面理解为表单的容器。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_online_page") +public class OnlinePage { + + /** + * 主键Id。 + */ + @Id(value = "page_id") + private Long pageId; + + /** + * 租户Id。 + */ + @Column(value = "tenant_id") + private Long tenantId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Column(value = "app_code") + private String appCode; + + /** + * 页面编码。 + */ + @Column(value = "page_code") + private String pageCode; + + /** + * 页面名称。 + */ + @Column(value = "page_name") + private String pageName; + + /** + * 页面类型。 + */ + @Column(value = "page_type") + private Integer pageType; + + /** + * 页面编辑状态。 + */ + @Column(value = "status") + private Integer status; + + /** + * 是否发布。 + */ + @Column(value = "published") + private Boolean published; + + /** + * 创建时间。 + */ + @Column(value = "create_time") + private Date createTime; + + /** + * 创建者。 + */ + @Column(value = "create_user_id") + private Long createUserId; + + /** + * 更新时间。 + */ + @Column(value = "update_time") + private Date updateTime; + + /** + * 更新者。 + */ + @Column(value = "update_user_id") + private Long updateUserId; + + @RelationConstDict( + masterIdField = "pageType", + constantDictClass = PageType.class) + @Column(ignore = true) + private Map pageTypeDictMap; + + @RelationConstDict( + masterIdField = "status", + constantDictClass = PageStatus.class) + @Column(ignore = true) + private Map statusDictMap; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlinePageDatasource.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlinePageDatasource.java new file mode 100644 index 00000000..7326f684 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlinePageDatasource.java @@ -0,0 +1,33 @@ +package com.orangeforms.common.online.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; + +/** + * 在线表单页面和数据源多对多关联实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_online_page_datasource") +public class OnlinePageDatasource { + + /** + * 主键Id。 + */ + @Id(value = "id") + private Long id; + + /** + * 页面主键Id。 + */ + @Column(value = "page_id") + private Long pageId; + + /** + * 数据源主键Id。 + */ + @Column(value = "datasource_id") + private Long datasourceId; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineRule.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineRule.java new file mode 100644 index 00000000..174250ac --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineRule.java @@ -0,0 +1,98 @@ +package com.orangeforms.common.online.model; + +import com.mybatisflex.annotation.*; +import com.orangeforms.common.core.annotation.RelationConstDict; +import com.orangeforms.common.online.model.constant.RuleType; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单数据表字段验证规则实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_online_rule") +public class OnlineRule { + + /** + * 主键Id。 + */ + @Id(value = "rule_id") + private Long ruleId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Column(value = "app_code") + private String appCode; + + /** + * 规则名称。 + */ + @Column(value = "rule_name") + private String ruleName; + + /** + * 规则类型。 + */ + @Column(value = "rule_type") + private Integer ruleType; + + /** + * 内置规则标记。 + */ + @Column(value = "builtin") + private Boolean builtin; + + /** + * 自定义规则的正则表达式。 + */ + @Column(value = "pattern") + private String pattern; + + /** + * 创建时间。 + */ + @Column(value = "create_time") + private Date createTime; + + /** + * 更新时间。 + */ + @Column(value = "update_time") + private Date updateTime; + + /** + * 创建者。 + */ + @Column(value = "create_user_id") + private Long createUserId; + + /** + * 更新者。 + */ + @Column(value = "update_user_id") + private Long updateUserId; + + /** + * 逻辑删除标记字段(1: 正常 -1: 已删除)。 + */ + @Column(value = "deleted_flag", isLogicDelete = true) + private Integer deletedFlag; + + /** + * ruleId 的多对多关联表数据对象。 + */ + @Column(ignore = true) + private OnlineColumnRule onlineColumnRule; + + @RelationConstDict( + masterIdField = "ruleType", + constantDictClass = RuleType.class) + @Column(ignore = true) + private Map ruleTypeDictMap; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineTable.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineTable.java new file mode 100644 index 00000000..c98bb765 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineTable.java @@ -0,0 +1,99 @@ +package com.orangeforms.common.online.model; + +import com.mybatisflex.annotation.*; +import com.orangeforms.common.core.annotation.RelationOneToMany; +import lombok.Data; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 在线表单的数据表实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_online_table") +public class OnlineTable { + + /** + * 主键Id。 + */ + @Id(value = "table_id") + private Long tableId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Column(value = "app_code") + private String appCode; + + /** + * 表名称。 + */ + @Column(value = "table_name") + private String tableName; + + /** + * 实体名称。 + */ + @Column(value = "model_name") + private String modelName; + + /** + * 数据库链接Id。 + */ + @Column(value = "dblink_id") + private Long dblinkId; + + /** + * 创建时间。 + */ + @Column(value = "create_time") + private Date createTime; + + /** + * 创建者。 + */ + @Column(value = "create_user_id") + private Long createUserId; + + /** + * 更新时间。 + */ + @Column(value = "update_time") + private Date updateTime; + + /** + * 更新者。 + */ + @Column(value = "update_user_id") + private Long updateUserId; + + @RelationOneToMany( + masterIdField = "tableId", + slaveModelClass = OnlineColumn.class, + slaveIdField = "tableId") + @Column(ignore = true) + private List columnList; + + /** + * 该字段会被缓存,因此在线表单执行操作时可以从缓存中读取该数据,并可基于columnId进行快速检索。 + */ + @Column(ignore = true) + private Map columnMap; + + /** + * 当前表的主键字段,该字段仅仅用于动态表单运行时的SQL拼装。 + */ + @Column(ignore = true) + private OnlineColumn primaryKeyColumn; + + /** + * 当前表的逻辑删除字段,该字段仅仅用于动态表单运行时的SQL拼装。 + */ + @Column(ignore = true) + private OnlineColumn logicDeleteColumn; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineVirtualColumn.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineVirtualColumn.java new file mode 100644 index 00000000..70aee6ff --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineVirtualColumn.java @@ -0,0 +1,87 @@ +package com.orangeforms.common.online.model; + +import com.mybatisflex.annotation.*; +import lombok.Data; + +/** + * 在线数据表虚拟字段实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Table(value = "zz_online_virtual_column") +public class OnlineVirtualColumn { + + /** + * 主键Id。 + */ + @Id(value = "virtual_column_id") + private Long virtualColumnId; + + /** + * 所在表Id。 + */ + @Column(value = "table_id") + private Long tableId; + + /** + * 字段名称。 + */ + @Column(value = "object_field_name") + private String objectFieldName; + + /** + * 属性类型。 + */ + @Column(value = "object_field_type") + private String objectFieldType; + + /** + * 字段提示名。 + */ + @Column(value = "column_prompt") + private String columnPrompt; + + /** + * 虚拟字段类型(0: 聚合)。 + */ + @Column(value = "virtual_type") + private Integer virtualType; + + /** + * 关联数据源Id。 + */ + @Column(value = "datasource_id") + private Long datasourceId; + + /** + * 关联Id。 + */ + @Column(value = "relation_id") + private Long relationId; + + /** + * 聚合字段所在关联表Id。 + */ + @Column(value = "aggregation_table_id") + private Long aggregationTableId; + + /** + * 关联表聚合字段Id。 + */ + @Column(value = "aggregation_column_id") + private Long aggregationColumnId; + + /** + * 聚合类型(0: count 1: sum 2: avg 3: max 4:min)。 + */ + @Column(value = "aggregation_type") + private Integer aggregationType; + + /** + * 存储过滤条件的json。 + */ + @Column(value = "where_clause_json") + private String whereClauseJson; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FieldFilterType.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FieldFilterType.java new file mode 100644 index 00000000..6287a355 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FieldFilterType.java @@ -0,0 +1,79 @@ +package com.orangeforms.common.online.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 字段过滤类型常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FieldFilterType { + + /** + * 无过滤。 + */ + public static final int NO_FILTER = 0; + /** + * 等于过滤。 + */ + public static final int EQUAL_FILTER = 1; + /** + * 范围过滤。 + */ + public static final int RANGE_FILTER = 2; + /** + * 模糊过滤。 + */ + public static final int LIKE_FILTER = 3; + /** + * IN LIST列表过滤。 + */ + public static final int IN_LIST_FILTER = 4; + /** + * 用OR连接的多个模糊查询。 + */ + public static final int MULTI_LIKE = 5; + /** + * NOT IN LIST列表过滤。 + */ + public static final int NOT_IN_LIST_FILTER = 6; + /** + * NOT IN LIST列表过滤。 + */ + public static final int IS_NULL = 7; + /** + * NOT IN LIST列表过滤。 + */ + public static final int IS_NOT_NULL = 8; + + private static final Map DICT_MAP = new HashMap<>(9); + static { + DICT_MAP.put(NO_FILTER, "无过滤"); + DICT_MAP.put(EQUAL_FILTER, "等于过滤"); + DICT_MAP.put(RANGE_FILTER, "范围过滤"); + DICT_MAP.put(LIKE_FILTER, "模糊过滤"); + DICT_MAP.put(IN_LIST_FILTER, "IN LIST列表过滤"); + DICT_MAP.put(MULTI_LIKE, "用OR连接的多个模糊查询"); + DICT_MAP.put(NOT_IN_LIST_FILTER, "NOT IN LIST列表过滤"); + DICT_MAP.put(IS_NULL, "IS NULL"); + DICT_MAP.put(IS_NOT_NULL, "IS NOT NULL"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FieldFilterType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FieldKind.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FieldKind.java new file mode 100644 index 00000000..d8afef0b --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FieldKind.java @@ -0,0 +1,109 @@ +package com.orangeforms.common.online.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 字段类别常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FieldKind { + + /** + * 文件上传字段。 + */ + public static final int UPLOAD = 1; + /** + * 图片上传字段。 + */ + public static final int UPLOAD_IMAGE = 2; + /** + * 富文本字段。 + */ + public static final int RICH_TEXT = 3; + /** + * 字典多选字段。 + */ + public static final int DICT_MULTI_SELECT = 4; + /** + * 创建人部门Id。 + */ + public static final int CREATE_DEPT_ID = 19; + /** + * 创建时间字段。 + */ + public static final int CREATE_TIME = 20; + /** + * 创建人字段。 + */ + public static final int CREATE_USER_ID = 21; + /** + * 更新时间字段。 + */ + public static final int UPDATE_TIME = 22; + /** + * 更新人字段。 + */ + public static final int UPDATE_USER_ID = 23; + /** + * 包含自动编码。 + */ + public static final int AUTO_CODE = 24; + /** + * 流程最后审批状态。 + */ + public static final int FLOW_APPROVAL_STATUS = 25; + /** + * 流程结束状态。 + */ + public static final int FLOW_FINISHED_STATUS = 26; + /** + * 脱敏字段。 + */ + public static final int MASK_FIELD = 27; + /** + * 租户过滤字段。 + */ + public static final int TENANT_FILTER = 28; + /** + * 逻辑删除字段。 + */ + public static final int LOGIC_DELETE = 31; + + private static final Map DICT_MAP = new HashMap<>(9); + static { + DICT_MAP.put(UPLOAD, "文件上传字段"); + DICT_MAP.put(UPLOAD_IMAGE, "图片上传字段"); + DICT_MAP.put(RICH_TEXT, "富文本字段"); + DICT_MAP.put(DICT_MULTI_SELECT, "字典多选字段"); + DICT_MAP.put(CREATE_DEPT_ID, "创建人部门字段"); + DICT_MAP.put(CREATE_TIME, "创建时间字段"); + DICT_MAP.put(CREATE_USER_ID, "创建人字段"); + DICT_MAP.put(UPDATE_TIME, "更新时间字段"); + DICT_MAP.put(UPDATE_USER_ID, "更新人字段"); + DICT_MAP.put(AUTO_CODE, "自动编码字段"); + DICT_MAP.put(FLOW_APPROVAL_STATUS, "流程最后审批状态"); + DICT_MAP.put(FLOW_FINISHED_STATUS, "流程结束状态"); + DICT_MAP.put(MASK_FIELD, "脱敏字段"); + DICT_MAP.put(TENANT_FILTER, "租户过滤字段"); + DICT_MAP.put(LOGIC_DELETE, "逻辑删除字段"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FieldKind() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FormKind.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FormKind.java new file mode 100644 index 00000000..71b22651 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FormKind.java @@ -0,0 +1,44 @@ +package com.orangeforms.common.online.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 表单类别常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FormKind { + + /** + * 弹框。 + */ + public static final int DIALOG = 1; + /** + * 跳页。 + */ + public static final int NEW_PAGE = 5; + + private static final Map DICT_MAP = new HashMap<>(2); + static { + DICT_MAP.put(DIALOG, "弹框列表"); + DICT_MAP.put(NEW_PAGE, "跳页类别"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FormKind() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FormType.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FormType.java new file mode 100644 index 00000000..6b969c20 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FormType.java @@ -0,0 +1,64 @@ +package com.orangeforms.common.online.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 表单类型常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FormType { + + /** + * 查询表单。 + */ + public static final int QUERY = 1; + /** + * 左树右表表单。 + */ + public static final int ADVANCED_QUERY = 2; + /** + * 一对一关联数据查询。 + */ + public static final int ONE_TO_ONE_QUERY = 3; + /** + * 编辑表单。 + */ + public static final int EDIT_FORM = 5; + /** + * 流程表单。 + */ + public static final int FLOW = 10; + /** + * 流程工单表单。 + */ + public static final int FLOW_WORK_ORDER = 11; + + private static final Map DICT_MAP = new HashMap<>(2); + static { + DICT_MAP.put(QUERY, "查询表单"); + DICT_MAP.put(ADVANCED_QUERY, "左树右表表单"); + DICT_MAP.put(ONE_TO_ONE_QUERY, "一对一关联数据查询"); + DICT_MAP.put(EDIT_FORM, "编辑表单"); + DICT_MAP.put(FLOW, "流程表单"); + DICT_MAP.put(FLOW_WORK_ORDER, "流程工单表单"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FormType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/PageStatus.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/PageStatus.java new file mode 100644 index 00000000..6eed451d --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/PageStatus.java @@ -0,0 +1,49 @@ +package com.orangeforms.common.online.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 页面状态常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class PageStatus { + + /** + * 编辑基础信息。 + */ + public static final int BASIC = 0; + /** + * 编辑数据模型。 + */ + public static final int DATASOURCE = 1; + /** + * 设计表单。 + */ + public static final int FORM_DESIGN = 2; + + private static final Map DICT_MAP = new HashMap<>(4); + static { + DICT_MAP.put(BASIC, "编辑基础信息"); + DICT_MAP.put(DATASOURCE, "编辑数据模型"); + DICT_MAP.put(FORM_DESIGN, "设计表单"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private PageStatus() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/PageType.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/PageType.java new file mode 100644 index 00000000..45e614a5 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/PageType.java @@ -0,0 +1,49 @@ +package com.orangeforms.common.online.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 页面类型常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class PageType { + + /** + * 业务页面。 + */ + public static final int BIZ = 1; + /** + * 统计页面。 + */ + public static final int STATS = 5; + /** + * 流程页面。 + */ + public static final int FLOW = 10; + + private static final Map DICT_MAP = new HashMap<>(2); + static { + DICT_MAP.put(BIZ, "业务页面"); + DICT_MAP.put(STATS, "统计页面"); + DICT_MAP.put(FLOW, "流程页面"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private PageType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/RelationType.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/RelationType.java new file mode 100644 index 00000000..f14289da --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/RelationType.java @@ -0,0 +1,44 @@ +package com.orangeforms.common.online.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 关联类型常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class RelationType { + + /** + * 一对一关联。 + */ + public static final int ONE_TO_ONE = 0; + /** + * 一对多关联。 + */ + public static final int ONE_TO_MANY = 1; + + private static final Map DICT_MAP = new HashMap<>(2); + static { + DICT_MAP.put(ONE_TO_ONE, "一对一关联"); + DICT_MAP.put(ONE_TO_MANY, "一对多关联"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private RelationType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/RuleType.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/RuleType.java new file mode 100644 index 00000000..f2b5ee76 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/RuleType.java @@ -0,0 +1,69 @@ +package com.orangeforms.common.online.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 验证规则类型常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class RuleType { + + /** + * 只允许整数。 + */ + public static final int INTEGER_ONLY = 1; + /** + * 只允许数字。 + */ + public static final int DIGITAL_ONLY = 2; + /** + * 只允许英文字符。 + */ + public static final int LETTER_ONLY = 3; + /** + * 范围验证。 + */ + public static final int RANGE = 4; + /** + * 邮箱格式验证。 + */ + public static final int EMAIL = 5; + /** + * 手机格式验证。 + */ + public static final int MOBILE = 6; + /** + * 自定义验证。 + */ + public static final int CUSTOM = 100; + + private static final Map DICT_MAP = new HashMap<>(7); + static { + DICT_MAP.put(INTEGER_ONLY, "只允许整数"); + DICT_MAP.put(DIGITAL_ONLY, "只允许数字"); + DICT_MAP.put(LETTER_ONLY, "只允许英文字符"); + DICT_MAP.put(RANGE, "范围验证"); + DICT_MAP.put(EMAIL, "邮箱格式验证"); + DICT_MAP.put(MOBILE, "手机格式验证"); + DICT_MAP.put(CUSTOM, "自定义验证"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private RuleType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/VirtualType.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/VirtualType.java new file mode 100644 index 00000000..3d5b9c42 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/VirtualType.java @@ -0,0 +1,39 @@ +package com.orangeforms.common.online.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 在线表单虚拟字段类型常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class VirtualType { + + /** + * 聚合。 + */ + public static final int AGGREGATION = 0; + + private static final Map DICT_MAP = new HashMap<>(2); + static { + DICT_MAP.put(AGGREGATION, "聚合"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private VirtualType() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/object/ColumnData.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/object/ColumnData.java new file mode 100644 index 00000000..8b6291f6 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/object/ColumnData.java @@ -0,0 +1,28 @@ +package com.orangeforms.common.online.object; + +import com.orangeforms.common.online.model.OnlineColumn; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 表字段数据对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ColumnData { + + /** + * 在线表字段对象。 + */ + private OnlineColumn column; + + /** + * 字段值。 + */ + private Object columnValue; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/object/ConstDictInfo.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/object/ConstDictInfo.java new file mode 100644 index 00000000..f99e18d3 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/object/ConstDictInfo.java @@ -0,0 +1,24 @@ +package com.orangeforms.common.online.object; + +import lombok.Data; + +import java.util.List; + +/** + * 在线表单常量字典的数据结构。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class ConstDictInfo { + + private List dictData; + + @Data + public static class ConstDictData { + private String type; + private Object id; + private String name; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/object/JoinTableInfo.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/object/JoinTableInfo.java new file mode 100644 index 00000000..4798b332 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/object/JoinTableInfo.java @@ -0,0 +1,28 @@ +package com.orangeforms.common.online.object; + +import lombok.Data; + +/** + * 连接表信息对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class JoinTableInfo { + + /** + * 是否左连接。 + */ + private Boolean leftJoin; + + /** + * 连接表表名。 + */ + private String joinTableName; + + /** + * 连接条件。 + */ + private String joinCondition; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineColumnService.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineColumnService.java new file mode 100644 index 00000000..a48a487e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineColumnService.java @@ -0,0 +1,147 @@ +package com.orangeforms.common.online.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.dbutil.object.SqlTableColumn; +import com.orangeforms.common.online.model.OnlineColumn; +import com.orangeforms.common.online.model.OnlineColumnRule; + +import java.util.List; +import java.util.Set; + +/** + * 字段数据数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineColumnService extends IBaseService { + + /** + * 保存新增数据表字段列表。 + * + * @param columnList 新增数据表字段对象列表。 + * @param onlineTableId 在线表对象的主键Id。 + * @return 插入的在线表字段数据。 + */ + List saveNewList(List columnList, Long onlineTableId); + + /** + * 更新数据对象。 + * + * @param onlineColumn 更新的对象。 + * @param originalOnlineColumn 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(OnlineColumn onlineColumn, OnlineColumn originalOnlineColumn); + + /** + * 刷新数据库表字段的数据到在线表字段。 + * + * @param sqlTableColumn 源数据库表字段对象。 + * @param onlineColumn 被刷新的在线表字段对象。 + */ + void refresh(SqlTableColumn sqlTableColumn, OnlineColumn onlineColumn); + + /** + * 删除指定数据。 + * + * @param tableId 表Id。 + * @param columnId 字段Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long tableId, Long columnId); + + /** + * 批量添加多对多关联关系。 + * + * @param onlineColumnRuleList 多对多关联表对象集合。 + * @param columnId 主表Id。 + */ + void addOnlineColumnRuleList(List onlineColumnRuleList, Long columnId); + + /** + * 更新中间表数据。 + * + * @param onlineColumnRule 中间表对象。 + * @return 更新成功与否。 + */ + boolean updateOnlineColumnRule(OnlineColumnRule onlineColumnRule); + + /** + * 获取中间表数据。 + * + * @param columnId 主表Id。 + * @param ruleId 从表Id。 + * @return 中间表对象。 + */ + OnlineColumnRule getOnlineColumnRule(Long columnId, Long ruleId); + + /** + * 移除单条多对多关系。 + * + * @param columnId 主表Id。 + * @param ruleId 从表Id。 + * @return 成功返回true,否则false。 + */ + boolean removeOnlineColumnRule(Long columnId, Long ruleId); + + /** + * 当前服务的支持表为从表,根据主表的主键Id,删除一对多的从表数据。 + * + * @param tableId 主表主键Id。 + * @return 删除数量。 + */ + int removeByTableId(Long tableId); + + /** + * 删除指定数据表Id集合中的表字段。 + * + * @param tableIdSet 待删除的数据表Id集合。 + */ + void removeByTableIdSet(Set tableIdSet); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineColumnListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @return 查询结果集。 + */ + List getOnlineColumnList(OnlineColumn filter); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineColumnList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @return 查询结果集。 + */ + List getOnlineColumnListWithRelation(OnlineColumn filter); + + /** + * 获取指定数据表Id集合的字段对象列表。 + * + * @param tableIdSet 指定的数据表Id集合。 + * @return 数据表Id集合所包含的字段对象列表。 + */ + List getOnlineColumnListByTableIds(Set tableIdSet); + + /** + * 根据表Id和字段列名获取指定字段。 + * + * @param tableId 字段所在表Id。 + * @param columnName 字段名。 + * @return 查询出的字段对象。 + */ + OnlineColumn getOnlineColumnByTableIdAndColumnName(Long tableId, String columnName); + + /** + * 验证主键是否正确。 + * + * @param tableColumn 数据库导入的表字段对象。 + * @return 验证结果。 + */ + CallResult verifyPrimaryKey(SqlTableColumn tableColumn); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDatasourceRelationService.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDatasourceRelationService.java new file mode 100644 index 00000000..a96d86b9 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDatasourceRelationService.java @@ -0,0 +1,85 @@ +package com.orangeforms.common.online.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.dbutil.object.SqlTable; +import com.orangeforms.common.dbutil.object.SqlTableColumn; +import com.orangeforms.common.online.model.OnlineDatasourceRelation; + +import java.util.List; +import java.util.Set; + +/** + * 数据关联数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineDatasourceRelationService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param relation 新增对象。 + * @param slaveSqlTable 新增的关联从数据表对象。 + * @param slaveSqlColumn 新增的关联从数据表对象。 + * @return 返回新增对象。 + */ + OnlineDatasourceRelation saveNew( + OnlineDatasourceRelation relation, SqlTable slaveSqlTable, SqlTableColumn slaveSqlColumn); + + /** + * 更新数据对象。 + * + * @param relation 更新的对象。 + * @param originalRelation 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(OnlineDatasourceRelation relation, OnlineDatasourceRelation originalRelation); + + /** + * 删除指定数据。 + * + * @param relationId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long relationId); + + /** + * 当前服务的支持表为从表,根据主表的主键Id,删除一对多的从表数据。 + * + * @param datasourceId 主表主键Id。 + * @return 删除数量。 + */ + int removeByDatasourceId(Long datasourceId); + + /** + * 查询指定数据源Id的数据源关联对象列表。 + * 从缓存中读取,如果不存在会从数据库中读取并同步到Redis中。 + * + * @param datasourceIdSet 数据源Id集合。 + * @return 在线数据源关联对象列表。 + */ + List getOnlineDatasourceRelationListFromCache(Set datasourceIdSet); + + /** + * 查询指定数据源关联对象。 + * 从缓存中读取,如果不存在会从数据库中读取并同步到Redis中。 + * + * @param datasourceId 数据源Id。 + * @param relationId 数据源关联Id。 + * @return 在线数据源关联对象。 + */ + OnlineDatasourceRelation getOnlineDatasourceRelationFromCache(Long datasourceId, Long relationId); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineDatasourceRelationList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineDatasourceRelationListWithRelation( + OnlineDatasourceRelation filter, String orderBy); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDatasourceService.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDatasourceService.java new file mode 100644 index 00000000..f51dddb5 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDatasourceService.java @@ -0,0 +1,134 @@ +package com.orangeforms.common.online.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.dbutil.object.SqlTable; +import com.orangeforms.common.online.model.OnlineDatasource; +import com.orangeforms.common.online.model.OnlineDatasourceTable; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 数据模型数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineDatasourceService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param onlineDatasource 新增对象。 + * @param sqlTable 新增的数据表对象。 + * @param pageId 关联的页面Id。 + * @return 返回新增对象。 + */ + OnlineDatasource saveNew(OnlineDatasource onlineDatasource, SqlTable sqlTable, Long pageId); + + /** + * 更新数据对象。 + * + * @param onlineDatasource 更新的对象。 + * @param originalOnlineDatasource 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(OnlineDatasource onlineDatasource, OnlineDatasource originalOnlineDatasource); + + /** + * 删除指定数据。 + * + * @param datasourceId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long datasourceId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineDatasourceListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineDatasourceList(OnlineDatasource filter, String orderBy); + + /** + * 查询指定数据源Id的数据源对象。 + * 从缓存中读取,如果不存在会从数据库中读取并同步到Redis中。 + * + * @param datasourceId 数据源Id。 + * @return 在线数据源对象。 + */ + OnlineDatasource getOnlineDatasourceFromCache(Long datasourceId); + + /** + * 查询指定数据源Id集合的数据源列表。 + * 从缓存中读取,如果不存在会从数据库中读取并同步到Redis中。 + * + * @param datasourceIdSet 数据源Id集合。 + * @return 在线数据源对象集合。 + */ + List getOnlineDatasourceListFromCache(Set datasourceIdSet); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineDatasourceList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineDatasourceListWithRelation(OnlineDatasource filter, String orderBy); + + /** + * 在多对多关系中,当前Service的数据表为从表,返回与指定主表主键Id存在对多对关系的列表。 + * + * @param pageId 主表主键Id。 + * @param filter 从表的过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineDatasourceListByPageId(Long pageId, OnlineDatasource filter, String orderBy); + + /** + * 获取指定数据源Id集合所关联的在线表关联数据。 + * + * @param datasourceIdSet 数据源Id集合。 + * @return 数据源和数据表的多对多关联列表。 + */ + List getOnlineDatasourceTableList(Set datasourceIdSet); + + /** + * 根据在线表单Id集合,获取关联的在线数据源对象列表。 + * + * @param readFormIdSet 在线表单Id集合。 + * @return 与参数表单Id关联的数据源列表。 + */ + List getOnlineDatasourceListByFormIds(Set readFormIdSet); + + /** + * 根据主表Id获取在线表单数据源对象。 + * + * @param masterTableId 主表Id。 + * @return 在线表单数据源对象。 + */ + OnlineDatasource getOnlineDatasourceByMasterTableId(Long masterTableId); + + /** + * 判断指定数据源变量是否存在。 + * @param variableName 变量名。 + * @return true存在,否则false。 + */ + boolean existByVariableName(String variableName); + + /** + * 获取在线表单页面和在线表单数据源变量名的映射关系。 + * + * @param pageIds 页面Id集合。 + * @return 在线表单页面和在线表单数据源变量名的映射关系。 + */ + Map getPageIdAndVariableNameMapByPageIds(Set pageIds); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDblinkService.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDblinkService.java new file mode 100644 index 00000000..d04ace46 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDblinkService.java @@ -0,0 +1,99 @@ +package com.orangeforms.common.online.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.dbutil.object.SqlTable; +import com.orangeforms.common.dbutil.object.SqlTableColumn; +import com.orangeforms.common.online.model.OnlineDblink; + +import java.util.List; + +/** + * 数据库链接数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineDblinkService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param onlineDblink 新增对象。 + * @return 返回新增对象。 + */ + OnlineDblink saveNew(OnlineDblink onlineDblink); + + /** + * 更新数据对象。 + * + * @param onlineDblink 更新的对象。 + * @param originalOnlineDblink 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(OnlineDblink onlineDblink, OnlineDblink originalOnlineDblink); + + /** + * 删除指定数据。 + * + * @param dblinkId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long dblinkId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineDblinkListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineDblinkList(OnlineDblink filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineDblinkList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineDblinkListWithRelation(OnlineDblink filter, String orderBy); + + /** + * 获取指定DBLink下面的全部数据表。 + * + * @param dblink 数据库链接对象。 + * @return 全部数据表列表。 + */ + List getDblinkTableList(OnlineDblink dblink); + + /** + * 获取指定DBLink下,指定表名的数据表对象,及其关联字段列表。 + * + * @param dblink 数据库链接对象。 + * @param tableName 数据库中的数据表名。 + * @return 数据表对象。 + */ + SqlTable getDblinkTable(OnlineDblink dblink, String tableName); + + /** + * 获取指定DBLink下,指定表名的字段列表。 + * + * @param dblink 数据库链接对象。 + * @param tableName 数据库中的数据表名。 + * @return 表的字段列表。 + */ + List getDblinkTableColumnList(OnlineDblink dblink, String tableName); + + /** + * 获取指定DBLink下,指定表的字段对象。 + * + * @param dblink 数据库链接对象。 + * @param tableName 数据库中的数据表名。 + * @param columnName 数据库中的数据表的字段名。 + * @return 表的字段对象。 + */ + SqlTableColumn getDblinkTableColumn(OnlineDblink dblink, String tableName, String columnName); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDictService.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDictService.java new file mode 100644 index 00000000..4f2c56bd --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDictService.java @@ -0,0 +1,78 @@ +package com.orangeforms.common.online.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.online.model.OnlineDict; + +import java.util.List; +import java.util.Set; + +/** + * 在线表单字典数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineDictService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param onlineDict 新增对象。 + * @return 返回新增对象。 + */ + OnlineDict saveNew(OnlineDict onlineDict); + + /** + * 更新数据对象。 + * + * @param onlineDict 更新的对象。 + * @param originalOnlineDict 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(OnlineDict onlineDict, OnlineDict originalOnlineDict); + + /** + * 删除指定数据。 + * + * @param dictId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long dictId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineDictListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineDictList(OnlineDict filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineDictList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineDictListWithRelation(OnlineDict filter, String orderBy); + + /** + * 从缓存中获取字典数据。 + * + * @param dictId 字典Id。 + * @return 在线字典对象。 + */ + OnlineDict getOnlineDictFromCache(Long dictId); + + /** + * 从缓存中获取字典数据集合。 + * + * @param dictIdSet 字典Id集合。 + * @return 在线字典对象集合。 + */ + List getOnlineDictListFromCache(Set dictIdSet); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineFormService.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineFormService.java new file mode 100644 index 00000000..b6334b8d --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineFormService.java @@ -0,0 +1,122 @@ +package com.orangeforms.common.online.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.online.model.OnlineForm; +import com.orangeforms.common.online.model.OnlineFormDatasource; + +import java.util.List; +import java.util.Set; + +/** + * 在线表单数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineFormService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param onlineForm 新增对象。 + * @param datasourceIdSet 在线表单关联的数据源Id集合。 + * @return 返回新增对象。 + */ + OnlineForm saveNew(OnlineForm onlineForm, Set datasourceIdSet); + + /** + * 更新数据对象。 + * + * @param onlineForm 更新的对象。 + * @param originalOnlineForm 原有数据对象。 + * @param datasourceIdSet 在线表单关联的数据源Id集合。 + * @return 成功返回true,否则false。 + */ + boolean update(OnlineForm onlineForm, OnlineForm originalOnlineForm, Set datasourceIdSet); + + /** + * 删除指定数据。 + * + * @param formId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long formId); + + /** + * 根据PageId,删除其所属的所有表单,以及表单关联的数据源数据。 + * + * @param pageId 指定的pageId。 + * @return 删除数量。 + */ + int removeByPageId(Long pageId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineFormListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineFormList(OnlineForm filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineFormList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineFormListWithRelation(OnlineForm filter, String orderBy); + + /** + * 获取使用指定数据表的表单列表。 + * + * @param tableId 数据表Id。 + * @return 使用该数据表的表单列表。 + */ + List getOnlineFormListByTableId(Long tableId); + + /** + * 获取指定表单的数据源列表。 + * 从缓存中读取,如果缓存中不存在,从数据库读取后同步更新到缓存。 + * + * @param formId 指定的表单。 + * @return 表单和数据源的多对多关联对象列表。 + */ + List getFormDatasourceListFromCache(Long formId); + + /** + * 查询正在使用当前数据源的表单。 + * + * @param datasourceId 数据源Id。 + * @return 正在使用当前数据源的表单列表。 + */ + List getOnlineFormListByDatasourceId(Long datasourceId); + + /** + * 查询指定PageId集合的在线表单列表。 + * + * @param pageIdSet 页面Id集合。 + * @return 在线表单集合。 + */ + List getOnlineFormListByPageIds(Set pageIdSet); + + /** + * 从缓存中获取表单数据。 + * + * @param formId 表单Id。 + * @return 在线表单对象。 + */ + OnlineForm getOnlineFormFromCache(Long formId); + + /** + * 判断指定编码的表单是否存在。 + * + * @param formCode 表单编码。 + * @return true存在,否则false。 + */ + boolean existByFormCode(String formCode); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineOperationService.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineOperationService.java new file mode 100644 index 00000000..9cde49b9 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineOperationService.java @@ -0,0 +1,220 @@ +package com.orangeforms.common.online.service; + +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.object.MyPageData; +import com.orangeforms.common.core.object.MyPageParam; +import com.orangeforms.common.online.dto.OnlineFilterDto; +import com.orangeforms.common.online.model.OnlineColumn; +import com.orangeforms.common.online.model.OnlineDatasourceRelation; +import com.orangeforms.common.online.model.OnlineDict; +import com.orangeforms.common.online.model.OnlineTable; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 在线表单运行时操作的数据服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineOperationService { + + /** + * 待批量插入的所有表数据。 + * + * @param table 在线表对象。 + * @param dataList 数据对象列表。 + */ + void saveNewBatch(OnlineTable table, List dataList); + + /** + * 待插入的所有表数据。 + * + * @param table 在线表对象。 + * @param data 数据对象。 + * @return 主键值。由于自增主键不能获取插入后的主键值,因此返回NULL。 + */ + Object saveNew(OnlineTable table, JSONObject data); + + /** + * 待插入的主表数据和多个从表数据。 + * + * @param masterTable 主表在线表对象。 + * @param masterData 主表数据对象。 + * @param slaveDataListMap 多个从表的数据字段数据。 + * @return 主表的主键值。由于自增主键不能获取插入后的主键值,因此返回NULL。 + */ + Object saveNewWithRelation( + OnlineTable masterTable, + JSONObject masterData, + Map> slaveDataListMap); + + /** + * 更新表数据。 + * + * @param table 在线表对象。 + * @param data 单条表数据。 + * @return true 更新成功,否则false。 + */ + boolean update(OnlineTable table, JSONObject data); + + /** + * 更新流程字段的状态。 + * + * @param table 数据表。 + * @param dataId 主键Id。 + * @param column 更新字段。 + * @param dataValue 新的数据值。 + * @return true 更新成功,否则false。 + */ + boolean updateColumn(OnlineTable table, String dataId, OnlineColumn column, T dataValue); + + /** + * 级联更新主表和从表数据。 + * + * @param masterTable 主表对象。 + * @param masterData 主表数据。 + * @param datasourceId 主表数据源Id。 + * @param slaveDataListMap 关联从表数据。 + */ + void updateWithRelation( + OnlineTable masterTable, + JSONObject masterData, + Long datasourceId, + Map> slaveDataListMap); + + /** + * 更新关联从表的数据。 + * + * @param masterTable 主表对象。 + * @param masterData 主表数据。 + * @param masterDataId 主表主键Id。 + * @param datasourceId 主表数据源Id。 + * @param relationId 关联Id。 + * @param slaveDataList 从表数据。 + */ + void updateRelationData( + OnlineTable masterTable, + Map masterData, + String masterDataId, + Long datasourceId, + Long relationId, + List slaveDataList); + + /** + * 删除主表数据,及其需要级联删除的一对多关联从表数据。 + * + * @param table 表对象。 + * @param relationList 一对多关联对象列表。 + * @param dataId 主表主键Id值。 + * @return true 删除成功,否则false。 + */ + boolean delete(OnlineTable table, List relationList, String dataId); + + /** + * 删除一对多从表数据中的关联数据。 + * 删除所有字段为slaveColumn,数据值为columnValue,但是主键值不在keptIdSet中的从表关联数据。 + * + * @param slaveTable 一对多从表。 + * @param slaveColumn 从表关联字段。 + * @param columnValue 关联字段的值。 + * @param keptIdSet 被保留从表数据的主键Id值。 + */ + void deleteOneToManySlaveData( + OnlineTable slaveTable, OnlineColumn slaveColumn, String columnValue, Set keptIdSet); + + /** + * 根据主键判断当前数据是否存在。 + * + * @param table 主表对象。 + * @param dataId 主表主键Id值。 + * @return 存在返回true,否则false。 + */ + boolean existId(OnlineTable table, String dataId); + + /** + * 从数据源和一对一数据源关联中,动态获取数据。 + * + * @param table 主表对象。 + * @param oneToOneRelationList 数据源一对一关联列表。 + * @param allRelationList 数据源全部关联列表。 + * @param dataId 主表主键Id值。 + * @return 查询结果。 + */ + Map getMasterData( + OnlineTable table, + List oneToOneRelationList, + List allRelationList, + String dataId); + + /** + * 从一对多数据源关联中,动态获取数据。 + * + * @param relation 一对多数据源关联对象。 + * @param dataId 一对多关联数据主键Id值。 + * @return 查询结果。 + */ + Map getSlaveData(OnlineDatasourceRelation relation, String dataId); + + /** + * 从数据源和一对一数据源关联中,动态获取数据列表。 + * + * @param table 主表对象。 + * @param oneToOneRelationList 数据源一对一关联列表。 + * @param allRelationList 数据源全部关联列表。 + * @param filterList 过滤参数列表。 + * @param orderBy 排序字符串。 + * @param pageParam 分页对象。 + * @return 查询结果集。 + */ + MyPageData> getMasterDataList( + OnlineTable table, + List oneToOneRelationList, + List allRelationList, + List filterList, + String orderBy, + MyPageParam pageParam); + + /** + * 从一对多数据源关联中,动态获取数据列表。 + * + * @param relation 一对多数据源关联对象。 + * @param filterList 过滤参数列表。 + * @param orderBy 排序字符串。 + * @param pageParam 分页对象。 + * @return 查询结果集。 + */ + MyPageData> getSlaveDataList( + OnlineDatasourceRelation relation, List filterList, String orderBy, MyPageParam pageParam); + + /** + * 从字典对象指向的数据表中查询数据,并根据参数进行数据过滤。 + * + * @param dict 字典对象。 + * @param filterList 过滤参数列表。 + * @return 查询结果集。 + */ + List> getDictDataList(OnlineDict dict, List filterList); + + /** + * 为主表及其关联表数据绑定字典数据。 + * + * @param masterTable 主表对象。 + * @param relationList 主表依赖的关联列表。 + * @param dataList 数据列表。 + */ + void buildDataListWithDict( + OnlineTable masterTable, List relationList, List> dataList); + + /** + * 获取在线表单所关联的权限数据,包括权限字列表和权限资源列表。 + * + * @param menuFormIds 菜单关联的表单Id集合。 + * @param viewFormIds 查询权限的表单Id集合。 + * @param editFormIds 编辑权限的表单Id集合。 + * @return 在线表单权限数据。 + */ + Map calculatePermData(Set menuFormIds, Set viewFormIds, Set editFormIds); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlinePageService.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlinePageService.java new file mode 100644 index 00000000..2ba8458b --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlinePageService.java @@ -0,0 +1,138 @@ +package com.orangeforms.common.online.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.online.model.OnlinePage; +import com.orangeforms.common.online.model.OnlinePageDatasource; + +import java.util.List; + +/** + * 在线表单页面数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlinePageService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param onlinePage 新增对象。 + * @return 返回新增对象。 + */ + OnlinePage saveNew(OnlinePage onlinePage); + + /** + * 更新数据对象。 + * + * @param onlinePage 更新的对象。 + * @param originalOnlinePage 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(OnlinePage onlinePage, OnlinePage originalOnlinePage); + + /** + * 更新页面对象的发布状态。 + * + * @param pageId 页面对象Id。 + * @param published 新的状态。 + */ + void updatePublished(Long pageId, Boolean published); + + /** + * 删除指定数据,及其包含的表单和数据源等。 + * + * @param pageId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long pageId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlinePageListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlinePageList(OnlinePage filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlinePageList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlinePageListWithRelation(OnlinePage filter, String orderBy); + + /** + * 批量添加多对多关联关系。 + * + * @param onlinePageDatasourceList 多对多关联表对象集合。 + * @param pageId 主表Id。 + */ + void addOnlinePageDatasourceList(List onlinePageDatasourceList, Long pageId); + + /** + * 获取中间表数据。 + * + * @param pageId 主表Id。 + * @param datasourceId 从表Id。 + * @return 中间表对象。 + */ + OnlinePageDatasource getOnlinePageDatasource(Long pageId, Long datasourceId); + + /** + * 获取在线页面和数据源中间表数据列表。 + * + * @param pageId 主表Id。 + * @return 在线页面和数据源中间表对象列表。 + */ + List getOnlinePageDatasourceListByPageId(Long pageId); + + /** + * 根据数据源Id,返回使用该数据源的OnlinePage对象。 + * + * @param datasourceId 数据源Id。 + * @return 使用该数据源的页面列表。 + */ + List getOnlinePageListByDatasourceId(Long datasourceId); + + /** + * 移除单条多对多关系。 + * + * @param pageId 主表Id。 + * @param datasourceId 从表Id。 + * @return 成功返回true,否则false。 + */ + boolean removeOnlinePageDatasource(Long pageId, Long datasourceId); + + /** + * 判断指定编码的页面是否存在。 + * + * @param pageCode 页面编码。 + * @return true存在,否则false。 + */ + boolean existByPageCode(String pageCode); + + /** + * 查询主键Id集合中不存在的,且租户Id为NULL的在线表单页面列表。 + * + * @param pageIds 主键Id集合。 + * @param orderBy 排序字符串。 + * @return 在线表单页面列表。 + */ + List getNotInListWithNonTenant(List pageIds, String orderBy); + + /** + * 查询主键Id集合中存在的,且租户Id为NULL的在线表单页面列表。 + * + * @param pageIds 主键Id集合。 + * @param orderBy 排序字符串。 + * @return 在线表单页面列表。 + */ + List getInListWithNonTenant(List pageIds, String orderBy); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineRuleService.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineRuleService.java new file mode 100644 index 00000000..f381a43d --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineRuleService.java @@ -0,0 +1,91 @@ +package com.orangeforms.common.online.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.online.model.OnlineColumnRule; +import com.orangeforms.common.online.model.OnlineRule; + +import java.util.List; +import java.util.Set; + +/** + * 验证规则数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineRuleService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param onlineRule 新增对象。 + * @return 返回新增对象。 + */ + OnlineRule saveNew(OnlineRule onlineRule); + + /** + * 更新数据对象。 + * + * @param onlineRule 更新的对象。 + * @param originalOnlineRule 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(OnlineRule onlineRule, OnlineRule originalOnlineRule); + + /** + * 删除指定数据。 + * + * @param ruleId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long ruleId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineRuleListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineRuleList(OnlineRule filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineRuleList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineRuleListWithRelation(OnlineRule filter, String orderBy); + + /** + * 在多对多关系中,当前Service的数据表为从表,返回不与指定主表主键Id存在对多对关系的列表。 + * + * @param columnId 主表主键Id。 + * @param filter 从表的过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getNotInOnlineRuleListByColumnId(Long columnId, OnlineRule filter, String orderBy); + + /** + * 在多对多关系中,当前Service的数据表为从表,返回与指定主表主键Id存在对多对关系的列表。 + * + * @param columnId 主表主键Id。 + * @param filter 从表的过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineRuleListByColumnId(Long columnId, OnlineRule filter, String orderBy); + + /** + * 返回指定字段Id列表关联的字段规则对象列表。 + * + * @param columnIdSet 指定的字段Id列表。 + * @return 关联的字段规则对象列表。 + */ + List getOnlineColumnRuleListByColumnIds(Set columnIdSet); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineTableService.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineTableService.java new file mode 100644 index 00000000..e30f7fba --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineTableService.java @@ -0,0 +1,68 @@ +package com.orangeforms.common.online.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.dbutil.object.SqlTable; +import com.orangeforms.common.online.model.OnlineColumn; +import com.orangeforms.common.online.model.OnlineTable; + +import java.util.List; +import java.util.Set; + +/** + * 数据表数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineTableService extends IBaseService { + + /** + * 基于数据库表保存新增对象。 + * + * @param sqlTable 数据库表对象。 + * @return 返回新增对象。 + */ + OnlineTable saveNewFromSqlTable(SqlTable sqlTable); + + /** + * 删除指定表及其关联的字段数据。 + * + * @param tableId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long tableId); + + /** + * 删除指定数据表Id集合中的表,及其关联字段。 + * + * @param tableIdSet 待删除的数据表Id集合。 + */ + void removeByTableIdSet(Set tableIdSet); + + /** + * 根据数据源Id,获取该数据源及其关联所引用的数据表列表。 + * + * @param datasourceId 指定的数据源Id。 + * @return 该数据源及其关联所引用的数据表列表。 + */ + List getOnlineTableListByDatasourceId(Long datasourceId); + + /** + * 从缓存中获取指定的表数据及其关联字段列表。优先从缓存中读取,如果不存在则从数据库中读取,并同步到缓存。 + * 该接口方法仅仅用户在线表单的动态数据操作接口,而非在线表单的配置接口。 + * + * @param tableId 表主键Id。 + * @return 查询后的在线表对象。 + */ + OnlineTable getOnlineTableFromCache(Long tableId); + + /** + * 从缓存中获取指定的表字段。优先从缓存中读取,如果不存在则从数据库中读取,并同步到缓存。 + * 该接口方法仅仅用户在线表单的动态数据操作接口,而非在线表单的配置接口。 + * + * @param tableId 表主键Id。 + * @param columnId 字段Id。 + * @return 查询后的在线表对象。 + */ + OnlineColumn getOnlineColumnFromCache(Long tableId, Long columnId); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineVirtualColumnService.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineVirtualColumnService.java new file mode 100644 index 00000000..710c3a51 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineVirtualColumnService.java @@ -0,0 +1,68 @@ +package com.orangeforms.common.online.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.online.model.OnlineVirtualColumn; + +import java.util.*; + +/** + * 虚拟字段数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineVirtualColumnService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param onlineVirtualColumn 新增对象。 + * @return 返回新增对象。 + */ + OnlineVirtualColumn saveNew(OnlineVirtualColumn onlineVirtualColumn); + + /** + * 更新数据对象。 + * + * @param onlineVirtualColumn 更新的对象。 + * @param originalOnlineVirtualColumn 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(OnlineVirtualColumn onlineVirtualColumn, OnlineVirtualColumn originalOnlineVirtualColumn); + + /** + * 删除指定数据。 + * + * @param virtualColumnId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long virtualColumnId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineVirtualColumnListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineVirtualColumnList(OnlineVirtualColumn filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineVirtualColumnList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineVirtualColumnListWithRelation(OnlineVirtualColumn filter, String orderBy); + + /** + * 根据数据表的集合,查询关联的虚拟字段数据列表。 + * @param tableIdSet 在线数据表Id集合。 + * @return 关联的虚拟字段数据列表。 + */ + List getOnlineVirtualColumnListByTableIds(Set tableIdSet); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineColumnServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineColumnServiceImpl.java new file mode 100644 index 00000000..52b64742 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineColumnServiceImpl.java @@ -0,0 +1,357 @@ +package com.orangeforms.common.online.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.core.lang.Assert; +import com.mybatisflex.core.query.QueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.constant.ObjectFieldType; +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.upload.UploadStoreTypeEnum; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.dbutil.object.SqlTableColumn; +import com.orangeforms.common.dbutil.provider.DataSourceProvider; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.online.util.OnlineDataSourceUtil; +import com.orangeforms.common.online.util.OnlineRedisKeyUtil; +import com.orangeforms.common.online.dao.OnlineColumnMapper; +import com.orangeforms.common.online.dao.OnlineColumnRuleMapper; +import com.orangeforms.common.online.model.OnlineColumn; +import com.orangeforms.common.online.model.OnlineColumnRule; +import com.orangeforms.common.online.model.constant.FieldFilterType; +import com.orangeforms.common.online.service.OnlineColumnService; +import com.github.pagehelper.Page; +import com.google.common.base.CaseFormat; +import lombok.extern.slf4j.Slf4j; +import org.redisson.api.RedissonClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +/** + * 字段数据数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("onlineColumnService") +public class OnlineColumnServiceImpl extends BaseService implements OnlineColumnService { + + @Autowired + private OnlineColumnMapper onlineColumnMapper; + @Autowired + private OnlineColumnRuleMapper onlineColumnRuleMapper; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private RedissonClient redissonClient; + @Autowired + private OnlineDataSourceUtil dataSourceUtil; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return onlineColumnMapper; + } + + /** + * 保存新增数据表字段列表。 + * + * @param columnList 新增数据表字段对象列表。 + * @param onlineTableId 在线表对象的主键Id。 + * @return 插入的在线表字段数据。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public List saveNewList(List columnList, Long onlineTableId) { + List onlineColumnList = new LinkedList<>(); + if (CollUtil.isEmpty(columnList)) { + return onlineColumnList; + } + this.evictTableCache(onlineTableId); + for (SqlTableColumn column : columnList) { + OnlineColumn onlineColumn = new OnlineColumn(); + BeanUtil.copyProperties(column, onlineColumn, false); + onlineColumn.setColumnId(idGenerator.nextLongId()); + onlineColumn.setTableId(onlineTableId); + this.setDefault(column, onlineColumn); + onlineColumnMapper.insert(onlineColumn); + onlineColumnList.add(onlineColumn); + } + return onlineColumnList; + } + + /** + * 更新数据对象。 + * + * @param onlineColumn 更新的对象。 + * @param originalOnlineColumn 原有数据对象。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(OnlineColumn onlineColumn, OnlineColumn originalOnlineColumn) { + this.evictTableCache(onlineColumn.getTableId()); + onlineColumn.setUpdateTime(new Date()); + onlineColumn.setUpdateUserId(TokenData.takeFromRequest().getUserId()); + onlineColumn.setCreateTime(originalOnlineColumn.getCreateTime()); + onlineColumn.setCreateUserId(originalOnlineColumn.getCreateUserId()); + // 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。 + return onlineColumnMapper.update(onlineColumn, false) == 1; + } + + /** + * 刷新数据库表字段的数据到在线表字段。 + * + * @param sqlTableColumn 源数据库表字段对象。 + * @param onlineColumn 被刷新的在线表字段对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void refresh(SqlTableColumn sqlTableColumn, OnlineColumn onlineColumn) { + this.evictTableCache(onlineColumn.getTableId()); + BeanUtil.copyProperties(sqlTableColumn, onlineColumn, false); + String objectFieldName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, onlineColumn.getColumnName()); + onlineColumn.setObjectFieldName(objectFieldName); + String objectFieldType = convertToJavaType(onlineColumn, sqlTableColumn.getDblinkType()); + onlineColumn.setObjectFieldType(objectFieldType); + onlineColumnMapper.update(onlineColumn); + } + + /** + * 删除指定数据。 + * + * @param tableId 表Id。 + * @param columnId 字段Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long tableId, Long columnId) { + this.evictTableCache(tableId); + return onlineColumnMapper.deleteById(columnId) == 1; + } + + /** + * 当前服务的支持表为从表,根据主表的主键Id,删除一对多的从表数据。 + * + * @param tableId 主表主键Id。 + * @return 删除数量。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int removeByTableId(Long tableId) { + return onlineColumnMapper.deleteByQuery(new QueryWrapper().eq(OnlineColumn::getTableId, tableId)); + } + + /** + * 删除指定数据表Id集合中的表字段。 + * + * @param tableIdSet 待删除的数据表Id集合。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void removeByTableIdSet(Set tableIdSet) { + onlineColumnMapper.deleteByQuery(new QueryWrapper().in(OnlineColumn::getTableId, tableIdSet)); + } + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineColumnListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @return 查询结果集。 + */ + @Override + public List getOnlineColumnList(OnlineColumn filter) { + return onlineColumnMapper.getOnlineColumnList(filter); + } + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineColumnList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @return 查询结果集。 + */ + @Override + public List getOnlineColumnListWithRelation(OnlineColumn filter) { + List resultList = onlineColumnMapper.getOnlineColumnList(filter); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + /** + * 获取指定数据表Id集合的字段对象列表。 + * + * @param tableIdSet 指定的数据表Id集合。 + * @return 数据表Id集合所包含的字段对象列表。 + */ + @Override + public List getOnlineColumnListByTableIds(Set tableIdSet) { + return onlineColumnMapper.selectListByQuery(new QueryWrapper().in(OnlineColumn::getTableId, tableIdSet)); + } + + /** + * 根据表Id和字段列名获取指定字段。 + * + * @param tableId 字段所在表Id。 + * @param columnName 字段名。 + * @return 查询出的字段对象。 + */ + @Override + public OnlineColumn getOnlineColumnByTableIdAndColumnName(Long tableId, String columnName) { + OnlineColumn filter = new OnlineColumn(); + filter.setTableId(tableId); + filter.setColumnName(columnName); + return onlineColumnMapper.selectOneByQuery(QueryWrapper.create(filter)); + } + + @Override + public CallResult verifyPrimaryKey(SqlTableColumn tableColumn) { + Assert.isTrue(tableColumn.getPrimaryKey()); + OnlineColumn onlineColumn = new OnlineColumn(); + BeanUtil.copyProperties(tableColumn, onlineColumn, false); + String javaType = this.convertToJavaType(onlineColumn, tableColumn.getDblinkType()); + if (ObjectFieldType.INTEGER.equals(javaType)) { + if (BooleanUtil.isFalse(onlineColumn.getAutoIncrement())) { + return CallResult.error("字段验证失败,整型主键必须是自增主键!"); + } + } else { + if (!StrUtil.equalsAny(javaType, ObjectFieldType.LONG, ObjectFieldType.STRING)) { + return CallResult.error("字段验证失败,不合法的主键类型 [" + tableColumn.getColumnType() + "]!"); + } + } + return CallResult.ok(); + } + + /** + * 批量添加多对多关联关系。 + * + * @param onlineColumnRuleList 多对多关联表对象集合。 + * @param columnId 主表Id。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void addOnlineColumnRuleList(List onlineColumnRuleList, Long columnId) { + this.evictTableCacheByColumnId(columnId); + for (OnlineColumnRule onlineColumnRule : onlineColumnRuleList) { + onlineColumnRule.setColumnId(columnId); + onlineColumnRuleMapper.insert(onlineColumnRule); + } + } + + /** + * 更新中间表数据。 + * + * @param onlineColumnRule 中间表对象。 + * @return 更新成功与否。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean updateOnlineColumnRule(OnlineColumnRule onlineColumnRule) { + this.evictTableCacheByColumnId(onlineColumnRule.getColumnId()); + OnlineColumnRule filter = new OnlineColumnRule(); + filter.setColumnId(onlineColumnRule.getColumnId()); + filter.setRuleId(onlineColumnRule.getRuleId()); + return onlineColumnRuleMapper.updateByQuery(onlineColumnRule, false, QueryWrapper.create(filter)) > 0; + } + + /** + * 获取中间表数据。 + * + * @param columnId 主表Id。 + * @param ruleId 从表Id。 + * @return 中间表对象。 + */ + @Override + public OnlineColumnRule getOnlineColumnRule(Long columnId, Long ruleId) { + OnlineColumnRule filter = new OnlineColumnRule(); + filter.setColumnId(columnId); + filter.setRuleId(ruleId); + return onlineColumnRuleMapper.selectOneByQuery(QueryWrapper.create(filter)); + } + + /** + * 移除单条多对多关系。 + * + * @param columnId 主表Id。 + * @param ruleId 从表Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean removeOnlineColumnRule(Long columnId, Long ruleId) { + this.evictTableCacheByColumnId(columnId); + OnlineColumnRule filter = new OnlineColumnRule(); + filter.setColumnId(columnId); + filter.setRuleId(ruleId); + return onlineColumnRuleMapper.deleteByQuery(QueryWrapper.create(filter)) > 0; + } + + private void setDefault(SqlTableColumn column, OnlineColumn onlineColumn) { + String objectFieldName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, onlineColumn.getColumnName()); + onlineColumn.setObjectFieldName(objectFieldName); + String objectFieldType = convertToJavaType(onlineColumn, column.getDblinkType()); + onlineColumn.setObjectFieldType(objectFieldType); + onlineColumn.setFilterType(FieldFilterType.NO_FILTER); + onlineColumn.setParentKey(false); + onlineColumn.setDeptFilter(false); + onlineColumn.setUserFilter(false); + if (onlineColumn.getAutoIncrement() == null) { + onlineColumn.setAutoIncrement(false); + } + onlineColumn.setUploadFileSystemType(UploadStoreTypeEnum.LOCAL_SYSTEM.ordinal()); + Date now = new Date(); + onlineColumn.setUpdateTime(now); + onlineColumn.setCreateTime(now); + onlineColumn.setCreateUserId(TokenData.takeFromRequest().getUserId()); + onlineColumn.setUpdateUserId(onlineColumn.getCreateUserId()); + } + + private void evictTableCache(Long tableId) { + String tableIdKey = OnlineRedisKeyUtil.makeOnlineTableKey(tableId); + redissonClient.getBucket(tableIdKey).delete(); + } + + private void evictTableCacheByColumnId(Long columnId) { + OnlineColumn column = this.getById(columnId); + if (column != null) { + this.evictTableCache(column.getTableId()); + } + } + + private String convertToJavaType(OnlineColumn column, int dblinkType) { + DataSourceProvider provider = dataSourceUtil.getProvider(dblinkType); + if (provider == null) { + throw new MyRuntimeException("Unsupported Data Type"); + } + return provider.convertColumnTypeToJavaType( + column.getColumnType(), column.getNumericPrecision(), column.getNumericScale()); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDatasourceRelationServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDatasourceRelationServiceImpl.java new file mode 100644 index 00000000..49b46f30 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDatasourceRelationServiceImpl.java @@ -0,0 +1,285 @@ +package com.orangeforms.common.online.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.alibaba.fastjson.JSONArray; +import com.mybatisflex.core.query.QueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.dbutil.object.SqlTable; +import com.orangeforms.common.dbutil.object.SqlTableColumn; +import com.orangeforms.common.redis.util.CommonRedisUtil; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.online.util.OnlineRedisKeyUtil; +import com.orangeforms.common.online.dao.OnlineDatasourceRelationMapper; +import com.orangeforms.common.online.dao.OnlineDatasourceTableMapper; +import com.orangeforms.common.online.model.OnlineColumn; +import com.orangeforms.common.online.model.OnlineDatasourceRelation; +import com.orangeforms.common.online.model.OnlineDatasourceTable; +import com.orangeforms.common.online.model.OnlineTable; +import com.orangeforms.common.online.service.OnlineColumnService; +import com.orangeforms.common.online.service.OnlineDatasourceRelationService; +import com.orangeforms.common.online.service.OnlineDatasourceService; +import com.orangeforms.common.online.service.OnlineTableService; +import com.github.pagehelper.Page; +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.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; + +/** + * 数据源关联数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("onlineDatasourceRelationService") +public class OnlineDatasourceRelationServiceImpl + extends BaseService implements OnlineDatasourceRelationService { + + @Autowired + private OnlineDatasourceRelationMapper onlineDatasourceRelationMapper; + @Autowired + private OnlineDatasourceTableMapper onlineDatasourceTableMapper; + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private OnlineColumnService onlineColumnService; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private RedissonClient redissonClient; + @Autowired + private CommonRedisUtil commonRedisUtil; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return onlineDatasourceRelationMapper; + } + + /** + * 保存新增对象。 + * + * @param relation 新增对象。 + * @param slaveSqlTable 新增的关联从数据表对象。 + * @param slaveSqlColumn 新增的关联从数据表对象。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public OnlineDatasourceRelation saveNew( + OnlineDatasourceRelation relation, SqlTable slaveSqlTable, SqlTableColumn slaveSqlColumn) { + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineDataSourceRelationKey(relation.getDatasourceId())); + // 查找数据源关联的数据表,判断当前关联的从表,是否已经存在于zz_online_datasource_table中了。 + // 对于同一个数据源及其关联,同一个数据表只会被创建一次,如果已经和当前数据源的其他Relation, + // 作为从表绑定了,怎么就可以直接使用这个OnlineTable了,否则就会为这个SqlTable,创建对应的OnlineTable。 + List datasourceTableList = + onlineTableService.getOnlineTableListByDatasourceId(relation.getDatasourceId()); + OnlineTable relationSlaveTable = null; + OnlineColumn relationSlaveColumn = null; + for (OnlineTable onlineTable : datasourceTableList) { + if (onlineTable.getTableName().equals(slaveSqlTable.getTableName())) { + relationSlaveTable = onlineTable; + relationSlaveColumn = onlineColumnService.getOnlineColumnByTableIdAndColumnName( + onlineTable.getTableId(), slaveSqlColumn.getColumnName()); + break; + } + } + if (relationSlaveTable == null) { + relationSlaveTable = onlineTableService.saveNewFromSqlTable(slaveSqlTable); + for (OnlineColumn onlineColumn : relationSlaveTable.getColumnList()) { + if (onlineColumn.getColumnName().equals(slaveSqlColumn.getColumnName())) { + relationSlaveColumn = onlineColumn; + break; + } + } + } + TokenData tokenData = TokenData.takeFromRequest(); + relation.setRelationId(idGenerator.nextLongId()); + relation.setAppCode(tokenData.getAppCode()); + relation.setSlaveTableId(relationSlaveTable.getTableId()); + relation.setSlaveColumnId(relationSlaveColumn == null ? null : relationSlaveColumn.getColumnId()); + Date now = new Date(); + relation.setUpdateTime(now); + relation.setCreateTime(now); + relation.setCreateUserId(tokenData.getUserId()); + relation.setUpdateUserId(tokenData.getUserId()); + onlineDatasourceRelationMapper.insert(relation); + OnlineDatasourceTable datasourceTable = new OnlineDatasourceTable(); + datasourceTable.setId(idGenerator.nextLongId()); + datasourceTable.setDatasourceId(relation.getDatasourceId()); + datasourceTable.setRelationId(relation.getRelationId()); + datasourceTable.setTableId(relation.getSlaveTableId()); + onlineDatasourceTableMapper.insert(datasourceTable); + return relation; + } + + /** + * 更新数据对象。 + * + * @param relation 更新的对象。 + * @param originalRelation 原有数据对象。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(OnlineDatasourceRelation relation, OnlineDatasourceRelation originalRelation) { + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineDataSourceRelationKey(relation.getDatasourceId())); + TokenData tokenData = TokenData.takeFromRequest(); + relation.setAppCode(tokenData.getAppCode()); + relation.setUpdateTime(new Date()); + relation.setUpdateUserId(tokenData.getUserId()); + relation.setCreateTime(originalRelation.getCreateTime()); + relation.setCreateUserId(originalRelation.getCreateUserId()); + // 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。 + return onlineDatasourceRelationMapper.update(relation, false) == 1; + } + + /** + * 删除指定数据。 + * + * @param relationId 主键Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long relationId) { + OnlineDatasourceRelation relation = this.getById(relationId); + if (relation != null) { + commonRedisUtil.evictFormCache( + OnlineRedisKeyUtil.makeOnlineDataSourceRelationKey(relation.getDatasourceId())); + } + if (onlineDatasourceRelationMapper.deleteById(relationId) != 1) { + return false; + } + OnlineDatasourceTable filter = new OnlineDatasourceTable(); + filter.setRelationId(relationId); + QueryWrapper queryWrapper = QueryWrapper.create(filter); + OnlineDatasourceTable datasourceTable = onlineDatasourceTableMapper.selectOneByQuery(queryWrapper); + onlineDatasourceTableMapper.deleteByQuery(queryWrapper); + filter = new OnlineDatasourceTable(); + filter.setDatasourceId(datasourceTable.getDatasourceId()); + filter.setTableId(datasourceTable.getTableId()); + // 不在有引用该表的时候,可以删除该数据源关联引用的从表了。 + if (onlineDatasourceTableMapper.selectCountByQuery(QueryWrapper.create(filter)) == 0) { + onlineTableService.remove(datasourceTable.getTableId()); + } + return true; + } + + /** + * 当前服务的支持表为从表,根据主表的主键Id,删除一对多的从表数据。 + * + * @param datasourceId 主表主键Id。 + * @return 删除数量。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int removeByDatasourceId(Long datasourceId) { + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineDataSourceRelationKey(datasourceId)); + return onlineDatasourceRelationMapper.deleteByQuery( + new QueryWrapper().eq(OnlineDatasourceRelation::getDatasourceId, datasourceId)); + } + + @Override + public List getOnlineDatasourceRelationListFromCache(Set datasourceIdSet) { + List resultList = new LinkedList<>(); + datasourceIdSet.forEach(datasourceId -> { + String key = OnlineRedisKeyUtil.makeOnlineDataSourceRelationKey(datasourceId); + RBucket bucket = redissonClient.getBucket(key); + if (bucket.isExists()) { + resultList.addAll(JSONArray.parseArray(bucket.get(), OnlineDatasourceRelation.class)); + } else { + OnlineDatasourceRelation filter = new OnlineDatasourceRelation(); + filter.setDatasourceId(datasourceId); + List relationList = this.getListByFilter(filter); + if (CollUtil.isNotEmpty(relationList)) { + resultList.addAll(relationList); + bucket.set(JSONArray.toJSONString(relationList)); + } + } + }); + return resultList; + } + + @Override + public OnlineDatasourceRelation getOnlineDatasourceRelationFromCache(Long datasourceId, Long relationId) { + List relationList = + this.getOnlineDatasourceRelationListFromCache(CollUtil.newHashSet(datasourceId)); + if (CollUtil.isEmpty(relationList)) { + return null; + } + return relationList.stream().filter(r -> r.getRelationId().equals(relationId)).findFirst().orElse(null); + } + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineDatasourceRelationList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineDatasourceRelationListWithRelation( + OnlineDatasourceRelation filter, String orderBy) { + if (filter == null) { + filter = new OnlineDatasourceRelation(); + } + filter.setAppCode(TokenData.takeFromRequest().getAppCode()); + List resultList = + onlineDatasourceRelationMapper.getOnlineDatasourceRelationList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + /** + * 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。 + * + * @param relation 最新数据对象。 + * @param originalRelation 原有数据对象。 + * @return 数据全部正确返回true,否则false。 + */ + @Override + public CallResult verifyRelatedData( + OnlineDatasourceRelation relation, OnlineDatasourceRelation originalRelation) { + String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!"; + if (this.needToVerify(relation, originalRelation, OnlineDatasourceRelation::getMasterColumnId) + && !onlineColumnService.existId(relation.getMasterColumnId())) { + return CallResult.error(String.format(errorMessageFormat, "主表关联字段Id")); + } + if (this.needToVerify(relation, originalRelation, OnlineDatasourceRelation::getSlaveTableId) + && !onlineTableService.existId(relation.getSlaveTableId())) { + return CallResult.error(String.format(errorMessageFormat, "从表Id")); + } + if (this.needToVerify(relation, originalRelation, OnlineDatasourceRelation::getSlaveColumnId) + && !onlineColumnService.existId(relation.getSlaveColumnId())) { + return CallResult.error(String.format(errorMessageFormat, "从表关联字段Id")); + } + return CallResult.ok(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDatasourceServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDatasourceServiceImpl.java new file mode 100644 index 00000000..f45b22ef --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDatasourceServiceImpl.java @@ -0,0 +1,266 @@ +package com.orangeforms.common.online.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.mybatisflex.core.query.QueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.dbutil.object.SqlTable; +import com.orangeforms.common.redis.util.CommonRedisUtil; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.online.dao.OnlineDatasourceMapper; +import com.orangeforms.common.online.dao.OnlineDatasourceTableMapper; +import com.orangeforms.common.online.dao.OnlinePageDatasourceMapper; +import com.orangeforms.common.online.model.OnlineDatasource; +import com.orangeforms.common.online.model.OnlineDatasourceTable; +import com.orangeforms.common.online.model.OnlinePageDatasource; +import com.orangeforms.common.online.model.OnlineTable; +import com.orangeforms.common.online.service.OnlineDatasourceRelationService; +import com.orangeforms.common.online.service.OnlineDatasourceService; +import com.orangeforms.common.online.service.OnlineTableService; +import com.orangeforms.common.online.util.OnlineRedisKeyUtil; +import com.github.pagehelper.Page; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 数据模型数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("onlineDatasourceService") +public class OnlineDatasourceServiceImpl extends BaseService implements OnlineDatasourceService { + + @Autowired + private OnlineDatasourceMapper onlineDatasourceMapper; + @Autowired + private OnlinePageDatasourceMapper onlinePageDatasourceMapper; + @Autowired + private OnlineDatasourceTableMapper onlineDatasourceTableMapper; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private OnlineDatasourceRelationService onlineDatasourceRelationService; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private CommonRedisUtil commonRedisUtil; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return onlineDatasourceMapper; + } + + /** + * 保存新增对象。 + * + * @param onlineDatasource 新增对象。 + * @param sqlTable 新增的数据表对象。 + * @param pageId 关联的页面Id。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public OnlineDatasource saveNew(OnlineDatasource onlineDatasource, SqlTable sqlTable, Long pageId) { + TokenData tokenData = TokenData.takeFromRequest(); + OnlineTable onlineTable = onlineTableService.saveNewFromSqlTable(sqlTable); + onlineDatasource.setDatasourceId(idGenerator.nextLongId()); + onlineDatasource.setAppCode(tokenData.getAppCode()); + onlineDatasource.setMasterTableId(onlineTable.getTableId()); + Date now = new Date(); + onlineDatasource.setUpdateTime(now); + onlineDatasource.setCreateTime(now); + onlineDatasource.setCreateUserId(tokenData.getUserId()); + onlineDatasource.setUpdateUserId(tokenData.getUserId()); + onlineDatasourceMapper.insert(onlineDatasource); + OnlineDatasourceTable datasourceTable = new OnlineDatasourceTable(); + datasourceTable.setId(idGenerator.nextLongId()); + datasourceTable.setDatasourceId(onlineDatasource.getDatasourceId()); + datasourceTable.setTableId(onlineDatasource.getMasterTableId()); + onlineDatasourceTableMapper.insert(datasourceTable); + OnlinePageDatasource onlinePageDatasource = new OnlinePageDatasource(); + onlinePageDatasource.setId(idGenerator.nextLongId()); + onlinePageDatasource.setPageId(pageId); + onlinePageDatasource.setDatasourceId(onlineDatasource.getDatasourceId()); + onlinePageDatasourceMapper.insert(onlinePageDatasource); + return onlineDatasource; + } + + /** + * 更新数据对象。 + * + * @param onlineDatasource 更新的对象。 + * @param originalOnlineDatasource 原有数据对象。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(OnlineDatasource onlineDatasource, OnlineDatasource originalOnlineDatasource) { + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineDataSourceKey(onlineDatasource.getDatasourceId())); + TokenData tokenData = TokenData.takeFromRequest(); + onlineDatasource.setAppCode(tokenData.getAppCode()); + onlineDatasource.setUpdateTime(new Date()); + onlineDatasource.setUpdateUserId(tokenData.getUserId()); + onlineDatasource.setCreateTime(originalOnlineDatasource.getCreateTime()); + onlineDatasource.setCreateUserId(originalOnlineDatasource.getCreateUserId()); + // 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。 + return onlineDatasourceMapper.update(onlineDatasource, false) == 1; + } + + /** + * 删除指定数据。 + * + * @param datasourceId 主键Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long datasourceId) { + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineDataSourceKey(datasourceId)); + if (onlineDatasourceMapper.deleteById(datasourceId) == 0) { + return false; + } + onlineDatasourceRelationService.removeByDatasourceId(datasourceId); + // 开始删除多对多父表的关联 + OnlinePageDatasource onlinePageDatasource = new OnlinePageDatasource(); + onlinePageDatasource.setDatasourceId(datasourceId); + onlinePageDatasourceMapper.deleteByQuery(QueryWrapper.create(onlinePageDatasource)); + OnlineDatasourceTable filter = new OnlineDatasourceTable(); + filter.setDatasourceId(datasourceId); + QueryWrapper queryWrapper = QueryWrapper.create(filter); + List datasourceTableList = onlineDatasourceTableMapper.selectListByQuery(queryWrapper); + onlineDatasourceTableMapper.deleteByQuery(queryWrapper); + Set tableIdSet = datasourceTableList.stream() + .map(OnlineDatasourceTable::getTableId).collect(Collectors.toSet()); + onlineTableService.removeByTableIdSet(tableIdSet); + return true; + } + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineDatasourceListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineDatasourceList(OnlineDatasource filter, String orderBy) { + if (filter == null) { + filter = new OnlineDatasource(); + } + filter.setAppCode(TokenData.takeFromRequest().getAppCode()); + return onlineDatasourceMapper.getOnlineDatasourceList(filter, orderBy); + } + + @Override + public OnlineDatasource getOnlineDatasourceFromCache(Long datasourceId) { + String key = OnlineRedisKeyUtil.makeOnlineDataSourceKey(datasourceId); + return commonRedisUtil.getFromCache(key, datasourceId, this::getById, OnlineDatasource.class); + } + + @Override + public List getOnlineDatasourceListFromCache(Set datasourceIdSet) { + List resultList = new LinkedList<>(); + datasourceIdSet.forEach(datasourceId -> resultList.add(this.getOnlineDatasourceFromCache(datasourceId))); + return resultList; + } + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineDatasourceList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineDatasourceListWithRelation(OnlineDatasource filter, String orderBy) { + List resultList = this.getOnlineDatasourceList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + /** + * 在多对多关系中,当前Service的数据表为从表,返回与指定主表主键Id存在对多对关系的列表。 + * + * @param pageId 主表主键Id。 + * @param filter 从表的过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineDatasourceListByPageId(Long pageId, OnlineDatasource filter, String orderBy) { + List resultList = + onlineDatasourceMapper.getOnlineDatasourceListByPageId(pageId, filter, orderBy); + this.buildRelationForDataList(resultList, MyRelationParam.dictOnly()); + return resultList; + } + + /** + * 获取指定数据源Id集合所关联的在线表关联数据。 + * + * @param datasourceIdSet 数据源Id集合。 + * @return 数据源和数据表的多对多关联列表。 + */ + @Override + public List getOnlineDatasourceTableList(Set datasourceIdSet) { + return onlineDatasourceTableMapper.selectListByQuery( + new QueryWrapper().in(OnlineDatasourceTable::getDatasourceId, datasourceIdSet)); + } + + /** + * 根据在线表单Id集合,获取关联的在线数据源对象列表。 + * + * @param formIdSet 在线表单Id集合。 + * @return 与参数表单Id关联的数据源列表。 + */ + @Override + public List getOnlineDatasourceListByFormIds(Set formIdSet) { + return onlineDatasourceMapper.getOnlineDatasourceListByFormIds(formIdSet); + } + + @Override + public OnlineDatasource getOnlineDatasourceByMasterTableId(Long masterTableId) { + return onlineDatasourceMapper.selectOneByQuery( + new QueryWrapper().eq(OnlineDatasource::getMasterTableId, masterTableId)); + } + + @Override + public boolean existByVariableName(String variableName) { + OnlineDatasource filter = new OnlineDatasource(); + filter.setVariableName(variableName); + return CollUtil.isNotEmpty(this.getOnlineDatasourceList(filter, null)); + } + + @Override + public Map getPageIdAndVariableNameMapByPageIds(Set pageIds) { + String ids = CollUtil.join(pageIds, ","); + List> dataList = onlineDatasourceMapper.getPageIdAndVariableNameMapByPageIds(ids); + return dataList.stream() + .collect(Collectors.toMap(c -> (Long) c.get("page_id"), c -> (String) c.get("variable_name"))); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDblinkServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDblinkServiceImpl.java new file mode 100644 index 00000000..d9369859 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDblinkServiceImpl.java @@ -0,0 +1,201 @@ +package com.orangeforms.common.online.service.impl; + +import cn.hutool.core.util.StrUtil; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.dbutil.constant.DblinkType; +import com.orangeforms.common.dbutil.object.SqlTable; +import com.orangeforms.common.dbutil.object.SqlTableColumn; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.online.config.OnlineProperties; +import com.orangeforms.common.online.dao.OnlineDblinkMapper; +import com.orangeforms.common.online.model.OnlineDblink; +import com.orangeforms.common.online.service.OnlineDblinkService; +import com.orangeforms.common.online.util.OnlineDataSourceUtil; +import com.github.pagehelper.Page; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 数据库链接数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("onlineDblinkService") +public class OnlineDblinkServiceImpl extends BaseService implements OnlineDblinkService { + + @Autowired + private OnlineDblinkMapper onlineDblinkMapper; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private OnlineProperties onlineProperties; + @Autowired + private OnlineDataSourceUtil dataSourceUtil; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return onlineDblinkMapper; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public OnlineDblink saveNew(OnlineDblink onlineDblink) { + onlineDblinkMapper.insert(this.buildDefaultValue(onlineDblink)); + return onlineDblink; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(OnlineDblink onlineDblink, OnlineDblink originalOnlineDblink) { + if (!StrUtil.equals(onlineDblink.getConfiguration(), originalOnlineDblink.getConfiguration())) { + dataSourceUtil.removeDataSource(onlineDblink.getDblinkId()); + } + onlineDblink.setAppCode(TokenData.takeFromRequest().getAppCode()); + onlineDblink.setCreateUserId(originalOnlineDblink.getCreateUserId()); + onlineDblink.setUpdateUserId(TokenData.takeFromRequest().getUserId()); + onlineDblink.setCreateTime(originalOnlineDblink.getCreateTime()); + onlineDblink.setUpdateTime(new Date()); + // 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。 + return onlineDblinkMapper.update(onlineDblink, false) == 1; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long dblinkId) { + dataSourceUtil.removeDataSource(dblinkId); + return onlineDblinkMapper.deleteById(dblinkId) == 1; + } + + @Override + public List getOnlineDblinkList(OnlineDblink filter, String orderBy) { + if (filter == null) { + filter = new OnlineDblink(); + } + filter.setAppCode(TokenData.takeFromRequest().getAppCode()); + return onlineDblinkMapper.getOnlineDblinkList(filter, orderBy); + } + + @Override + public List getOnlineDblinkListWithRelation(OnlineDblink filter, String orderBy) { + List resultList = this.getOnlineDblinkList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + @Override + public List getDblinkTableList(OnlineDblink dblink) { + List resultList = dataSourceUtil.getTableList(dblink.getDblinkId(), null); + if (StrUtil.isNotBlank(onlineProperties.getTablePrefix())) { + resultList = resultList.stream() + .filter(t -> StrUtil.startWith(t.getTableName(), onlineProperties.getTablePrefix())) + .collect(Collectors.toList()); + } + resultList.forEach(t -> t.setDblinkId(dblink.getDblinkId())); + return resultList; + } + + @Override + public SqlTable getDblinkTable(OnlineDblink dblink, String tableName) { + SqlTable sqlTable = dataSourceUtil.getTable(dblink.getDblinkId(), tableName); + sqlTable.setDblinkId(dblink.getDblinkId()); + sqlTable.setColumnList(getDblinkTableColumnList(dblink, tableName)); + return sqlTable; + } + + @Override + public List getDblinkTableColumnList(OnlineDblink dblink, String tableName) { + List columnList = dataSourceUtil.getTableColumnList(dblink.getDblinkId(), tableName); + columnList.forEach(c -> this.makeupSqlTableColumn(c, dblink.getDblinkType())); + return columnList; + } + + @Override + public SqlTableColumn getDblinkTableColumn(OnlineDblink dblink, String tableName, String columnName) { + List columnList = dataSourceUtil.getTableColumnList(dblink.getDblinkId(), tableName); + SqlTableColumn sqlTableColumn = columnList.stream() + .filter(c -> c.getColumnName().equals(columnName)).findFirst().orElse(null); + if (sqlTableColumn != null) { + this.makeupSqlTableColumn(sqlTableColumn, dblink.getDblinkType()); + } + return sqlTableColumn; + } + + private void makeupSqlTableColumn(SqlTableColumn sqlTableColumn, int dblinkType) { + sqlTableColumn.setDblinkType(dblinkType); + switch (dblinkType) { + case DblinkType.POSTGRESQL: + case DblinkType.OPENGAUSS: + if (StrUtil.equalsAny(sqlTableColumn.getColumnType(), "char", "varchar")) { + sqlTableColumn.setFullColumnType( + sqlTableColumn.getColumnType() + "(" + sqlTableColumn.getStringPrecision() + ")"); + } else { + sqlTableColumn.setFullColumnType(sqlTableColumn.getColumnType()); + } + break; + case DblinkType.MYSQL: + sqlTableColumn.setAutoIncrement("auto_increment".equals(sqlTableColumn.getExtra())); + break; + case DblinkType.ORACLE: + if (StrUtil.equalsAny(sqlTableColumn.getColumnType(), "VARCHAR2", "NVARCHAR2", "CHAR", "NCHAR")) { + sqlTableColumn.setFullColumnType( + sqlTableColumn.getColumnType() + "(" + sqlTableColumn.getStringPrecision() + ")"); + } else if (StrUtil.equals(sqlTableColumn.getColumnType(), "NUMBER")) { + sqlTableColumn.setFullColumnType(sqlTableColumn.getColumnType() + + "(" + sqlTableColumn.getNumericPrecision() + "," + sqlTableColumn.getNumericScale() + ")"); + } else { + sqlTableColumn.setFullColumnType(sqlTableColumn.getColumnType()); + } + break; + case DblinkType.DAMENG: + case DblinkType.KINGBASE: + if (StrUtil.equalsAnyIgnoreCase(sqlTableColumn.getColumnType(), "VARCHAR", "VARCHAR2", "CHAR")) { + sqlTableColumn.setFullColumnType( + sqlTableColumn.getColumnType() + "(" + sqlTableColumn.getStringPrecision() + ")"); + } else if (StrUtil.equals(sqlTableColumn.getColumnType(), "NUMBER")) { + sqlTableColumn.setFullColumnType(sqlTableColumn.getColumnType() + + "(" + sqlTableColumn.getNumericPrecision() + "," + sqlTableColumn.getNumericScale() + ")"); + } else { + sqlTableColumn.setFullColumnType(sqlTableColumn.getColumnType()); + } + break; + default: + break; + } + } + + private OnlineDblink buildDefaultValue(OnlineDblink onlineDblink) { + onlineDblink.setDblinkId(idGenerator.nextLongId()); + TokenData tokenData = TokenData.takeFromRequest(); + onlineDblink.setCreateUserId(tokenData.getUserId()); + onlineDblink.setUpdateUserId(tokenData.getUserId()); + Date now = new Date(); + onlineDblink.setCreateTime(now); + onlineDblink.setUpdateTime(now); + onlineDblink.setAppCode(tokenData.getAppCode()); + return onlineDblink; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDictServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDictServiceImpl.java new file mode 100644 index 00000000..68c55d13 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDictServiceImpl.java @@ -0,0 +1,187 @@ +package com.orangeforms.common.online.service.impl; + +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.redis.util.CommonRedisUtil; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.online.util.OnlineRedisKeyUtil; +import com.orangeforms.common.online.dao.OnlineDictMapper; +import com.orangeforms.common.online.model.OnlineDict; +import com.orangeforms.common.online.service.OnlineDblinkService; +import com.orangeforms.common.online.service.OnlineDictService; +import com.github.pagehelper.Page; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +/** + * 在线表单字典数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("onlineDictService") +public class OnlineDictServiceImpl extends BaseService implements OnlineDictService { + + @Autowired + private OnlineDictMapper onlineDictMapper; + @Autowired + private OnlineDblinkService dblinkService; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private CommonRedisUtil commonRedisUtil; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return onlineDictMapper; + } + + /** + * 保存新增对象。 + * + * @param onlineDict 新增对象。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public OnlineDict saveNew(OnlineDict onlineDict) { + onlineDict.setDictId(idGenerator.nextLongId()); + TokenData tokenData = TokenData.takeFromRequest(); + onlineDict.setAppCode(tokenData.getAppCode()); + Date now = new Date(); + onlineDict.setUpdateTime(now); + onlineDict.setCreateTime(now); + onlineDict.setCreateUserId(tokenData.getUserId()); + onlineDict.setUpdateUserId(tokenData.getUserId()); + onlineDictMapper.insert(onlineDict); + return onlineDict; + } + + /** + * 更新数据对象。 + * + * @param onlineDict 更新的对象。 + * @param originalOnlineDict 原有数据对象。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(OnlineDict onlineDict, OnlineDict originalOnlineDict) { + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineDictKey(onlineDict.getDictId())); + TokenData tokenData = TokenData.takeFromRequest(); + onlineDict.setAppCode(tokenData.getAppCode()); + onlineDict.setUpdateTime(new Date()); + onlineDict.setUpdateUserId(tokenData.getUserId()); + onlineDict.setCreateTime(originalOnlineDict.getCreateTime()); + onlineDict.setCreateUserId(originalOnlineDict.getCreateUserId()); + // 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。 + return onlineDictMapper.update(onlineDict, false) == 1; + } + + /** + * 删除指定数据。 + * + * @param dictId 主键Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long dictId) { + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineDictKey(dictId)); + return onlineDictMapper.deleteById(dictId) == 1; + } + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineDictListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineDictList(OnlineDict filter, String orderBy) { + if (filter == null) { + filter = new OnlineDict(); + } + filter.setAppCode(TokenData.takeFromRequest().getAppCode()); + return onlineDictMapper.getOnlineDictList(filter, orderBy); + } + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineDictList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineDictListWithRelation(OnlineDict filter, String orderBy) { + List resultList = this.getOnlineDictList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + @Override + public OnlineDict getOnlineDictFromCache(Long dictId) { + String key = OnlineRedisKeyUtil.makeOnlineDictKey(dictId); + return commonRedisUtil.getFromCache(key, dictId, this::getById, OnlineDict.class); + } + + @Override + public List getOnlineDictListFromCache(Set dictIdSet) { + List dictList = new LinkedList<>(); + dictIdSet.forEach(dictId -> { + OnlineDict dict = this.getOnlineDictFromCache(dictId); + if (dict != null) { + dictList.add(dict); + } + }); + return dictList; + } + + /** + * 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。 + * + * @param onlineDict 最新数据对象。 + * @param originalOnlineDict 原有数据对象。 + * @return 数据全部正确返回true,否则false。 + */ + @Override + public CallResult verifyRelatedData(OnlineDict onlineDict, OnlineDict originalOnlineDict) { + String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!"; + //这里是基于字典的验证。 + if (this.needToVerify(onlineDict, originalOnlineDict, OnlineDict::getDblinkId) + && !dblinkService.existId(onlineDict.getDblinkId())) { + return CallResult.error(String.format(errorMessageFormat, "数据库链接主键id")); + } + return CallResult.ok(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineFormServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineFormServiceImpl.java new file mode 100644 index 00000000..bf83cae9 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineFormServiceImpl.java @@ -0,0 +1,306 @@ +package com.orangeforms.common.online.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.alibaba.fastjson.JSONArray; +import com.mybatisflex.core.query.QueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.redis.util.CommonRedisUtil; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.online.dao.OnlineFormDatasourceMapper; +import com.orangeforms.common.online.dao.OnlineFormMapper; +import com.orangeforms.common.online.model.OnlineForm; +import com.orangeforms.common.online.model.OnlineFormDatasource; +import com.orangeforms.common.online.service.OnlineFormService; +import com.orangeforms.common.online.service.OnlinePageService; +import com.orangeforms.common.online.service.OnlineTableService; +import com.orangeforms.common.online.util.OnlineRedisKeyUtil; +import com.github.pagehelper.Page; +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.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 在线表单数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("onlineFormService") +public class OnlineFormServiceImpl extends BaseService implements OnlineFormService { + + @Autowired + private OnlineFormMapper onlineFormMapper; + @Autowired + private OnlineFormDatasourceMapper onlineFormDatasourceMapper; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private OnlinePageService onlinePageService; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private CommonRedisUtil commonRedisUtil; + @Autowired + private RedissonClient redissonClient; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return onlineFormMapper; + } + + /** + * 保存新增对象。 + * + * @param onlineForm 新增对象。 + * @param datasourceIdSet 在线表单关联的数据源Id集合。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public OnlineForm saveNew(OnlineForm onlineForm, Set datasourceIdSet) { + onlineForm.setFormId(idGenerator.nextLongId()); + TokenData tokenData = TokenData.takeFromRequest(); + onlineForm.setAppCode(tokenData.getAppCode()); + onlineForm.setTenantId(tokenData.getTenantId()); + Date now = new Date(); + onlineForm.setUpdateTime(now); + onlineForm.setCreateTime(now); + onlineForm.setCreateUserId(tokenData.getUserId()); + onlineForm.setUpdateUserId(tokenData.getUserId()); + onlineFormMapper.insert(onlineForm); + if (CollUtil.isNotEmpty(datasourceIdSet)) { + for (Long datasourceId : datasourceIdSet) { + OnlineFormDatasource onlineFormDatasource = new OnlineFormDatasource(); + onlineFormDatasource.setId(idGenerator.nextLongId()); + onlineFormDatasource.setFormId(onlineForm.getFormId()); + onlineFormDatasource.setDatasourceId(datasourceId); + onlineFormDatasourceMapper.insert(onlineFormDatasource); + } + } + return onlineForm; + } + + /** + * 更新数据对象。 + * + * @param onlineForm 更新的对象。 + * @param originalOnlineForm 原有数据对象。 + * @param datasourceIdSet 在线表单关联的数据源Id集合。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(OnlineForm onlineForm, OnlineForm originalOnlineForm, Set datasourceIdSet) { + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineFormKey(onlineForm.getFormId())); + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineFormDatasourceKey(onlineForm.getFormId())); + TokenData tokenData = TokenData.takeFromRequest(); + onlineForm.setAppCode(tokenData.getAppCode()); + onlineForm.setTenantId(tokenData.getTenantId()); + onlineForm.setUpdateTime(new Date()); + onlineForm.setUpdateUserId(tokenData.getUserId()); + onlineForm.setCreateTime(originalOnlineForm.getCreateTime()); + onlineForm.setCreateUserId(originalOnlineForm.getCreateUserId()); + // 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。 + if (onlineFormMapper.update(onlineForm, false) != 1) { + return false; + } + OnlineFormDatasource formDatasourceFilter = new OnlineFormDatasource(); + formDatasourceFilter.setFormId(onlineForm.getFormId()); + onlineFormDatasourceMapper.deleteByQuery(QueryWrapper.create(formDatasourceFilter)); + if (CollUtil.isNotEmpty(datasourceIdSet)) { + for (Long datasourceId : datasourceIdSet) { + OnlineFormDatasource onlineFormDatasource = new OnlineFormDatasource(); + onlineFormDatasource.setId(idGenerator.nextLongId()); + onlineFormDatasource.setFormId(onlineForm.getFormId()); + onlineFormDatasource.setDatasourceId(datasourceId); + onlineFormDatasourceMapper.insert(onlineFormDatasource); + } + } + return true; + } + + /** + * 删除指定数据。 + * + * @param formId 主键Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long formId) { + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineFormKey(formId)); + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineFormDatasourceKey(formId)); + if (onlineFormMapper.deleteById(formId) != 1) { + return false; + } + OnlineFormDatasource formDatasourceFilter = new OnlineFormDatasource(); + formDatasourceFilter.setFormId(formId); + onlineFormDatasourceMapper.deleteByQuery(QueryWrapper.create(formDatasourceFilter)); + return true; + } + + /** + * 根据PageId,删除其所属的所有表单,以及表单关联的数据源数据。 + * + * @param pageId 指定的pageId。 + * @return 删除数量。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int removeByPageId(Long pageId) { + OnlineForm filter = new OnlineForm(); + filter.setPageId(pageId); + List formList = onlineFormMapper.selectListByQuery(QueryWrapper.create(filter)); + Set formIdSet = formList.stream().map(OnlineForm::getFormId).collect(Collectors.toSet()); + if (CollUtil.isNotEmpty(formIdSet)) { + onlineFormDatasourceMapper.deleteByQuery(new QueryWrapper().in(OnlineFormDatasource::getFormId, formIdSet)); + for (Long formId : formIdSet) { + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineFormKey(formId)); + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineFormDatasourceKey(formId)); + } + } + return onlineFormMapper.deleteByQuery(QueryWrapper.create(filter)); + } + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineFormListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineFormList(OnlineForm filter, String orderBy) { + if (filter == null) { + filter = new OnlineForm(); + } + TokenData tokenData = TokenData.takeFromRequest(); + filter.setTenantId(tokenData.getTenantId()); + filter.setAppCode(tokenData.getAppCode()); + return onlineFormMapper.getOnlineFormList(filter, orderBy); + } + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineFormList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineFormListWithRelation(OnlineForm filter, String orderBy) { + List resultList = this.getOnlineFormList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + /** + * 获取使用指定数据表的表单列表。 + * + * @param tableId 数据表Id。 + * @return 使用该数据表的表单列表。 + */ + @Override + public List getOnlineFormListByTableId(Long tableId) { + OnlineForm filter = new OnlineForm(); + filter.setMasterTableId(tableId); + return this.getOnlineFormList(filter, null); + } + + @Override + public List getFormDatasourceListFromCache(Long formId) { + String key = OnlineRedisKeyUtil.makeOnlineFormDatasourceKey(formId); + RBucket bucket = redissonClient.getBucket(key); + if (bucket.isExists()) { + return JSONArray.parseArray(bucket.get(), OnlineFormDatasource.class); + } + QueryWrapper queryWrapper = new QueryWrapper().eq(OnlineFormDatasource::getFormId, formId); + List resultList = onlineFormDatasourceMapper.selectListByQuery(queryWrapper); + bucket.set(JSONArray.toJSONString(resultList)); + return resultList; + } + + /** + * 查询正在使用当前数据源的表单。 + * + * @param datasourceId 数据源Id。 + * @return 正在使用当前数据源的表单列表。 + */ + @Override + public List getOnlineFormListByDatasourceId(Long datasourceId) { + OnlineForm filter = new OnlineForm(); + TokenData tokenData = TokenData.takeFromRequest(); + filter.setTenantId(tokenData.getTenantId()); + filter.setAppCode(tokenData.getAppCode()); + return onlineFormMapper.getOnlineFormListByDatasourceId(datasourceId, filter); + } + + @Override + public OnlineForm getOnlineFormFromCache(Long formId) { + String key = OnlineRedisKeyUtil.makeOnlineFormKey(formId); + return commonRedisUtil.getFromCache(key, formId, this::getById, OnlineForm.class); + } + + @Override + public boolean existByFormCode(String formCode) { + OnlineForm filter = new OnlineForm(); + filter.setFormCode(formCode); + return CollUtil.isNotEmpty(this.getOnlineFormList(filter, null)); + } + + @Override + public List getOnlineFormListByPageIds(Set pageIdSet) { + return onlineFormMapper.selectListByQuery(new QueryWrapper().eq(OnlineForm::getPageId, pageIdSet)); + } + + /** + * 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。 + * + * @param onlineForm 最新数据对象。 + * @param originalOnlineForm 原有数据对象。 + * @return 数据全部正确返回true,否则false。 + */ + @Override + public CallResult verifyRelatedData(OnlineForm onlineForm, OnlineForm originalOnlineForm) { + String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!"; + //这里是基于字典的验证。 + if (this.needToVerify(onlineForm, originalOnlineForm, OnlineForm::getMasterTableId) + && !onlineTableService.existId(onlineForm.getMasterTableId())) { + return CallResult.error(String.format(errorMessageFormat, "表单主表id")); + } + //这里是一对多的验证 + if (this.needToVerify(onlineForm, originalOnlineForm, OnlineForm::getPageId) + && !onlinePageService.existId(onlineForm.getPageId())) { + return CallResult.error(String.format(errorMessageFormat, "页面id")); + } + return CallResult.ok(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineOperationServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineOperationServiceImpl.java new file mode 100644 index 00000000..28898e0e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineOperationServiceImpl.java @@ -0,0 +1,1757 @@ +package com.orangeforms.common.online.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.text.StrFormatter; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.TypeReference; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.cache.CacheConfig; +import com.orangeforms.common.core.constant.*; +import com.orangeforms.common.core.exception.NoDataPermException; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.*; +import com.orangeforms.common.core.annotation.MultiDatabaseWriteMethod; +import com.orangeforms.common.datafilter.config.DataFilterProperties; +import com.orangeforms.common.dbutil.constant.DblinkType; +import com.orangeforms.common.dbutil.provider.DataSourceProvider; +import com.orangeforms.common.dict.service.GlobalDictService; +import com.orangeforms.common.online.dao.OnlineOperationMapper; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.redis.util.CommonRedisUtil; +import com.orangeforms.common.online.config.OnlineProperties; +import com.orangeforms.common.online.util.*; +import com.orangeforms.common.online.dto.OnlineFilterDto; +import com.orangeforms.common.online.model.*; +import com.orangeforms.common.online.model.constant.*; +import com.orangeforms.common.online.model.constant.FieldFilterType; +import com.orangeforms.common.online.object.ConstDictInfo; +import com.orangeforms.common.online.object.ColumnData; +import com.orangeforms.common.online.object.JoinTableInfo; +import com.orangeforms.common.online.service.*; +import com.orangeforms.common.online.exception.OnlineRuntimeException; +import com.google.common.collect.LinkedHashMultimap; +import com.google.common.collect.Multimap; +import lombok.Data; +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.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import jakarta.annotation.Resource; +import java.io.Serializable; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("onlineOperationService") +public class OnlineOperationServiceImpl implements OnlineOperationService { + + @Autowired + private OnlineOperationMapper onlineOperationMapper; + @Autowired + private OnlineDblinkService onlineDblinkService; + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private OnlineDictService onlineDictService; + @Autowired + private OnlineVirtualColumnService onlineVirtualColumnService; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private OnlineOperationHelper onlineOperationHelper; + @Autowired + private OnlineProperties onlineProperties; + @Autowired + private OnlineCustomExtFactory customExtFactory; + @Autowired + private GlobalDictService globalDictService; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private RedissonClient redissonClient; + @Autowired + private DataFilterProperties dataFilterProperties; + @Autowired + private CommonRedisUtil commonRedisUtil; + @Resource(name = "caffeineCacheManager") + private CacheManager cacheManager; + @Autowired + private OnlineDataSourceUtil dataSourceUtil; + + private static final String DICT_MAP_SUFFIX = "DictMap"; + private static final String DICT_MAP_LIST_SUFFIX = "DictMapList"; + private static final String SELECT = "SELECT "; + private static final String FROM = " FROM "; + private static final String WHERE = " WHERE "; + private static final String AND = " AND "; + + /** + * 聚合返回数据中,聚合键的常量字段名。 + * 如select groupColumn grouped_key, max(aggregationColumn) aggregated_value。 + */ + private static final String KEY_NAME = "grouped_key"; + /** + * 聚合返回数据中,聚合值的常量字段名。 + * 如select groupColumn grouped_key, max(aggregationColumn) aggregated_value。 + */ + private static final String VALUE_NAME = "aggregated_value"; + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNewBatch(OnlineTable table, List dataList) { + for (JSONObject data : dataList) { + this.saveNew(table, data); + } + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public Object saveNew(OnlineTable table, JSONObject data) { + ResponseResult> columnDataListResult = + onlineOperationHelper.buildTableData(table, data, false, null); + if (!columnDataListResult.isSuccess()) { + throw new OnlineRuntimeException(columnDataListResult.getErrorMessage()); + } + List columnDataList = columnDataListResult.getData(); + String columnNames = this.makeColumnNames(columnDataList); + List columnValueList = new LinkedList<>(); + Object id = null; + // 这里逐个处理每一行数据,特别是非自增主键、createUserId、createTime、逻辑删除等特殊属性的字段。 + for (ColumnData columnData : columnDataList) { + this.makeupColumnValue(columnData); + if (BooleanUtil.isFalse(columnData.getColumn().getAutoIncrement())) { + columnValueList.add(columnData.getColumnValue()); + if (BooleanUtil.isTrue(columnData.getColumn().getPrimaryKey())) { + id = columnData.getColumnValue(); + // 这里必须补齐主键值到JSON对象,后面的从表关联字段值填充可能会用到该值。 + data.put(columnData.getColumn().getColumnName(), id); + } + } + } + onlineOperationMapper.insert(table.getTableName(), columnNames, columnValueList); + return id; + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public Object saveNewWithRelation( + OnlineTable masterTable, + JSONObject masterData, + Map> slaveDataListMap) { + Object id = this.saveNew(masterTable, masterData); + if (slaveDataListMap == null) { + return id; + } + // 迭代多个关联列表。 + for (Map.Entry> entry : slaveDataListMap.entrySet()) { + Long masterColumnId = entry.getKey().getMasterColumnId(); + OnlineColumn masterColumn = masterTable.getColumnMap().get(masterColumnId); + Object columnValue = masterData.get(masterColumn.getColumnName()); + OnlineTable slaveTable = entry.getKey().getSlaveTable(); + OnlineColumn slaveColumn = slaveTable.getColumnMap().get(entry.getKey().getSlaveColumnId()); + // 迭代关联中的数据集合 + for (JSONObject slaveData : entry.getValue()) { + if (!slaveData.containsKey(slaveTable.getPrimaryKeyColumn().getColumnName())) { + slaveData.put(slaveColumn.getColumnName(), columnValue); + this.saveNew(slaveTable, slaveData); + } + } + } + return id; + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(OnlineTable table, JSONObject data) { + ResponseResult> columnDataListResult = + onlineOperationHelper.buildTableData(table, data, true, null); + if (!columnDataListResult.isSuccess()) { + throw new OnlineRuntimeException(columnDataListResult.getErrorMessage()); + } + List columnDataList = columnDataListResult.getData(); + String tableName = table.getTableName(); + List updateColumnList = new LinkedList<>(); + List filterList = new LinkedList<>(); + String dataId = null; + for (ColumnData columnData : columnDataList) { + this.makeupColumnValue(columnData); + // 对于以下几种类型的字段,忽略更新。 + if (BooleanUtil.isTrue(columnData.getColumn().getPrimaryKey()) + || ObjectUtil.equal(columnData.getColumn().getFieldKind(), FieldKind.LOGIC_DELETE)) { + OnlineFilterDto filter = new OnlineFilterDto(); + filter.setTableName(tableName); + filter.setColumnName(columnData.getColumn().getColumnName()); + filter.setColumnValue(columnData.getColumnValue()); + filterList.add(filter); + if (BooleanUtil.isTrue(columnData.getColumn().getPrimaryKey())) { + dataId = columnData.getColumnValue().toString(); + } + continue; + } + if (!MyCommonUtil.equalsAny(columnData.getColumn().getFieldKind(), + FieldKind.CREATE_TIME, FieldKind.CREATE_USER_ID, FieldKind.CREATE_DEPT_ID, FieldKind.TENANT_FILTER)) { + updateColumnList.add(columnData); + } + } + if (CollUtil.isEmpty(updateColumnList)) { + return true; + } + String dataPermFilter = this.buildDataPermFilter(table); + return this.doUpdate(table, updateColumnList, filterList, dataPermFilter); + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public boolean updateColumn(OnlineTable table, String dataId, OnlineColumn column, T dataValue) { + List updateColumnList = new LinkedList<>(); + ColumnData updateColumnData = new ColumnData(); + updateColumnData.setColumn(column); + updateColumnData.setColumnValue(dataValue); + updateColumnList.add(updateColumnData); + List filterList = this.makeDefaultFilter(table, table.getPrimaryKeyColumn(), dataId); + String dataPermFilter = this.buildDataPermFilter(table); + return this.doUpdate(table, updateColumnList, filterList, dataPermFilter); + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public void updateWithRelation( + OnlineTable masterTable, + JSONObject masterData, + Long datasourceId, + Map> slaveDataListMap) { + this.update(masterTable, masterData); + if (slaveDataListMap == null) { + return; + } + String masterDataId = masterData.get(masterTable.getPrimaryKeyColumn().getColumnName()).toString(); + for (Map.Entry> relationEntry : slaveDataListMap.entrySet()) { + Long relationId = relationEntry.getKey().getRelationId(); + this.updateRelationData( + masterTable, masterData, masterDataId, datasourceId, relationId, relationEntry.getValue()); + } + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public void updateRelationData( + OnlineTable masterTable, + Map masterData, + String masterDataId, + Long datasourceId, + Long relationId, + List slaveDataList) { + ResponseResult relationResult = + onlineOperationHelper.verifyAndGetRelation(datasourceId, relationId); + if (!relationResult.isSuccess()) { + throw new OnlineRuntimeException(relationResult.getErrorMessage()); + } + OnlineDatasourceRelation relation = relationResult.getData(); + OnlineTable slaveTable = relation.getSlaveTable(); + if (relation.getRelationType().equals(RelationType.ONE_TO_ONE)) { + JSONObject slaveData = null; + if (CollUtil.isNotEmpty(slaveDataList)) { + slaveData = slaveDataList.get(0); + } + this.saveNewOrUpdateOneToOneRelationData( + masterTable, masterData, masterDataId, slaveTable, slaveData, relation); + } else if (relation.getRelationType().equals(RelationType.ONE_TO_MANY)) { + if (slaveDataList == null) { + return; + } + this.saveNewOrUpdateOneToManyRelationData( + masterTable, masterData, masterDataId, slaveTable, slaveDataList, relation); + } + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public boolean delete(OnlineTable table, List relationList, String dataId) { + List filterList = + this.makeDefaultFilter(table, table.getPrimaryKeyColumn(), dataId); + String dataPermFilter = this.buildDataPermFilter(table); + if (table.getLogicDeleteColumn() == null) { + if (this.doDelete(table, filterList, dataPermFilter) != 1) { + return false; + } + } else { + this.doLogicDelete(table, table.getPrimaryKeyColumn(), dataId, dataPermFilter); + } + if (CollUtil.isEmpty(relationList)) { + return true; + } + Map masterData = getMasterData(table, null, null, dataId); + for (OnlineDatasourceRelation relation : relationList) { + if (BooleanUtil.isFalse(relation.getCascadeDelete())) { + continue; + } + OnlineTable slaveTable = relation.getSlaveTable(); + OnlineColumn slaveColumn = + relation.getSlaveTable().getColumnMap().get(relation.getSlaveColumnId()); + String columnValue = dataId; + if (!relation.getMasterColumnId().equals(table.getPrimaryKeyColumn().getColumnId())) { + OnlineColumn relationMasterColumn = table.getColumnMap().get(relation.getMasterColumnId()); + columnValue = masterData.get(relationMasterColumn.getColumnName()).toString(); + } + List slaveFilterList = + this.makeDefaultFilter(relation.getSlaveTable(), slaveColumn, columnValue); + if (slaveTable.getLogicDeleteColumn() == null) { + this.doDelete(slaveTable, slaveFilterList, null); + } else { + this.doLogicDelete(slaveTable, slaveColumn, columnValue, null); + } + } + return true; + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public void deleteOneToManySlaveData( + OnlineTable table, OnlineColumn column, String columnValue, Set keptIdSet) { + List filterList = this.makeDefaultFilter(table, column, columnValue); + if (CollUtil.isNotEmpty(keptIdSet)) { + OnlineFilterDto keptIdSetFilter = new OnlineFilterDto(); + Set convertedIdSet = + onlineOperationHelper.convertToTypeValue(table.getPrimaryKeyColumn(), keptIdSet); + keptIdSetFilter.setColumnValueList(new HashSet<>(convertedIdSet)); + keptIdSetFilter.setTableName(table.getTableName()); + keptIdSetFilter.setColumnName(table.getPrimaryKeyColumn().getColumnName()); + keptIdSetFilter.setFilterType(FieldFilterType.NOT_IN_LIST_FILTER); + filterList.add(keptIdSetFilter); + } + if (table.getLogicDeleteColumn() == null) { + this.doDelete(table, filterList, null); + } else { + this.doLogicDelete(table, filterList, null); + } + } + + @Override + public boolean existId(OnlineTable table, String dataId) { + return this.getMasterData(table, null, null, dataId) != null; + } + + @Override + public Map getMasterData( + OnlineTable table, + List oneToOneRelationList, + List allRelationList, + String dataId) { + List filterList = + this.makeDefaultFilter(table, table.getPrimaryKeyColumn(), dataId); + // 组件表关联数据。 + List joinInfoList = this.makeJoinInfoList(table, oneToOneRelationList); + // 拼接关联表的select fields字段。 + String selectFields = this.makeSelectFieldsWithRelation(table, oneToOneRelationList); + String dataPermFilter = this.buildDataPermFilter(table); + this.normalizeFiltersSlaveTableAlias(oneToOneRelationList, filterList); + selectFields = this.normalizeSlaveTableAlias(oneToOneRelationList, selectFields); + MyPageData> pageData = this.getList( + table, joinInfoList, selectFields, filterList, dataPermFilter, null, null); + List> resultList = pageData.getDataList(); + this.buildDataListWithDict(resultList, table, oneToOneRelationList); + if (CollUtil.isEmpty(resultList)) { + return null; + } + if (CollUtil.isNotEmpty(allRelationList)) { + // 针对一对多和多对多关联,计算虚拟聚合字段。 + List toManyRelationList = allRelationList.stream() + .filter(r -> !r.getRelationType().equals(RelationType.ONE_TO_ONE)).collect(Collectors.toList()); + this.buildVirtualColumn(resultList, table, toManyRelationList); + } + this.reformatResultListWithOneToOneRelation(resultList, oneToOneRelationList); + return resultList.get(0); + } + + @Override + public Map getSlaveData(OnlineDatasourceRelation relation, String dataId) { + OnlineTable slaveTable = relation.getSlaveTable(); + List filterList = + this.makeDefaultFilter(slaveTable, slaveTable.getPrimaryKeyColumn(), dataId); + // 拼接关联表的select fields字段。 + String selectFields = this.makeSelectFields(slaveTable, null); + String dataPermFilter = this.buildDataPermFilter(slaveTable); + MyPageData> pageData = this.getList( + slaveTable, null, selectFields, filterList, dataPermFilter, null, null); + List> resultList = pageData.getDataList(); + this.buildDataListWithDict(resultList, slaveTable); + return CollUtil.isEmpty(resultList) ? null : resultList.get(0); + } + + @Override + public MyPageData> getMasterDataList( + OnlineTable table, + List oneToOneRelationList, + List allRelationList, + List filterList, + String orderBy, + MyPageParam pageParam) { + this.normalizeFilterList(table, oneToOneRelationList, filterList); + // 组件表关联数据。 + List joinInfoList = this.makeJoinInfoList(table, oneToOneRelationList); + // 拼接关联表的select fields字段。 + String selectFields = this.makeSelectFieldsWithRelation(table, oneToOneRelationList); + String dataPermFilter = this.buildDataPermFilter(table); + this.normalizeFiltersSlaveTableAlias(oneToOneRelationList, filterList); + selectFields = this.normalizeSlaveTableAlias(oneToOneRelationList, selectFields); + orderBy = this.normalizeSlaveTableAlias(oneToOneRelationList, orderBy); + MyPageData> pageData = + this.getList(table, joinInfoList, selectFields, filterList, dataPermFilter, orderBy, pageParam); + List> resultList = pageData.getDataList(); + this.buildDataListWithDict(resultList, table, oneToOneRelationList); + // 针对一对多和多对多关联,计算虚拟聚合字段。 + if (CollUtil.isNotEmpty(allRelationList)) { + List toManyRelationList = allRelationList.stream() + .filter(r -> !r.getRelationType().equals(RelationType.ONE_TO_ONE)).collect(Collectors.toList()); + this.buildVirtualColumn(resultList, table, toManyRelationList); + } + this.reformatResultListWithOneToOneRelation(resultList, oneToOneRelationList); + return pageData; + } + + @Override + public MyPageData> getSlaveDataList( + OnlineDatasourceRelation relation, List filterList, String orderBy, MyPageParam pageParam) { + OnlineTable slaveTable = relation.getSlaveTable(); + this.normalizeFilterList(slaveTable, null, filterList); + // 拼接关联表的select fields字段。 + String selectFields = this.makeSelectFields(slaveTable, null); + String dataPermFilter = this.buildDataPermFilter(slaveTable); + MyPageData> pageData = + this.getList(slaveTable, null, selectFields, filterList, dataPermFilter, orderBy, pageParam); + this.buildDataListWithDict(pageData.getDataList(), slaveTable); + return pageData; + } + + @Override + public List> getDictDataList(OnlineDict dict, List filterList) { + if (StrUtil.isNotBlank(dict.getDeletedColumnName())) { + if (filterList == null) { + filterList = new LinkedList<>(); + } + OnlineFilterDto filter = new OnlineFilterDto(); + filter.setColumnName(dict.getDeletedColumnName()); + filter.setColumnValue(GlobalDeletedFlag.NORMAL); + filterList.add(filter); + } + if (StrUtil.isNotBlank(dict.getTenantFilterColumnName())) { + if (filterList == null) { + filterList = new LinkedList<>(); + } + OnlineFilterDto filter = new OnlineFilterDto(); + filter.setColumnName(dict.getTenantFilterColumnName()); + filter.setColumnValue(TokenData.takeFromRequest().getTenantId()); + filterList.add(filter); + } + String selectFields = this.makeDictSelectFields(dict, false); + String dataPermFilter = this.buildDataPermFilter( + dict.getTableName(), dict.getDeptFilterColumnName(), dict.getUserFilterColumnName()); + return this.getDictList(dict.getDblinkId(), dict.getTableName(), selectFields, filterList, dataPermFilter); + } + + @Override + public void buildDataListWithDict( + OnlineTable masterTable, List relationList, List> dataList) { + this.buildDataListWithDict(dataList, masterTable, relationList); + } + + @Override + public Map calculatePermData(Set menuFormIds, Set viewFormIds, Set editFormIds) { + Map> formMenuPermMap = new HashMap<>(menuFormIds.size()); + for (Long menuFormId : menuFormIds) { + formMenuPermMap.put(menuFormId, new HashSet<>()); + } + Set permCodeSet = new HashSet<>(10); + Set permUrlSet = new HashSet<>(10); + if (CollUtil.isNotEmpty(viewFormIds)) { + List datasourceList = + onlineDatasourceService.getOnlineDatasourceListByFormIds(viewFormIds); + for (OnlineDatasource datasource : datasourceList) { + permCodeSet.add(OnlineUtil.makeViewPermCode(datasource.getVariableName())); + Set permUrls = onlineProperties.getViewUrlList().stream() + .map(url -> url + datasource.getVariableName()).collect(Collectors.toSet()); + permUrlSet.addAll(permUrls); + datasource.getOnlineFormDatasourceList().forEach(formDatasource -> + formMenuPermMap.get(formDatasource.getFormId()).addAll(permUrls)); + } + } + if (CollUtil.isNotEmpty(editFormIds)) { + List datasourceList = + onlineDatasourceService.getOnlineDatasourceListByFormIds(editFormIds); + for (OnlineDatasource datasource : datasourceList) { + permCodeSet.add(OnlineUtil.makeEditPermCode(datasource.getVariableName())); + Set permUrls = onlineProperties.getEditUrlList().stream() + .map(url -> url + datasource.getVariableName()).collect(Collectors.toSet()); + permUrlSet.addAll(permUrls); + datasource.getOnlineFormDatasourceList().forEach(formDatasource -> + formMenuPermMap.get(formDatasource.getFormId()).addAll(permUrls)); + } + } + List onlineWhitelistUrls = CollUtil.newArrayList( + onlineProperties.getUrlPrefix() + "/onlineOperation/listDict", + onlineProperties.getUrlPrefix() + "/onlineForm/render", + onlineProperties.getUrlPrefix() + "/onlineForm/view"); + Map resultMap = new HashMap<>(3); + resultMap.put("permCodeSet", permCodeSet); + resultMap.put("permUrlSet", permUrlSet); + resultMap.put("formMenuPermMap", formMenuPermMap); + resultMap.put("onlineWhitelistUrls", onlineWhitelistUrls); + return resultMap; + } + + private boolean doUpdate( + OnlineTable table, List updateColumns, List filters, String dataPermFilter) { + return onlineOperationMapper.update(table.getTableName(), updateColumns, filters, dataPermFilter) == 1; + } + + private int doDelete(OnlineTable table, List filters, String dataPermFilter) { + return onlineOperationMapper.delete(table.getTableName(), filters, dataPermFilter); + } + + private List> getGroupedListByCondition( + Long dblinkId, String selectTable, String selectFields, String whereClause, String groupBy) { + return onlineOperationMapper.getGroupedListByCondition(selectTable, selectFields, whereClause, groupBy); + } + + private List> getDictList( + Long dblinkId, String tableName, String selectFields, List filterList, String dataPermFilter) { + return onlineOperationMapper.getDictList(tableName, selectFields, filterList, dataPermFilter); + } + + private MyPageData> getList( + OnlineTable table, + List joinInfoList, + String selectFields, + List filterList, + String dataPermFilter, + String orderBy, + MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + List> resultList = onlineOperationMapper.getList( + table.getTableName(), joinInfoList, selectFields, filterList, dataPermFilter, orderBy); + return MyPageUtil.makeResponseData(resultList); + } + + private String makeWhereClause(List filters, String dataPermFilter, List paramList) { + if (CollUtil.isEmpty(filters) && StrUtil.isBlank(dataPermFilter)) { + return ""; + } + StringBuilder where = new StringBuilder(512); + List normalizedFilters = new LinkedList<>(); + if (CollUtil.isNotEmpty(filters)) { + for (OnlineFilterDto filter : filters) { + String filterString = this.makeSubWhereClause(filter, paramList); + if (StrUtil.isNotBlank(filterString)) { + normalizedFilters.add(filterString); + } + } + } + if (CollUtil.isNotEmpty(normalizedFilters)) { + where.append(WHERE); + where.append(CollUtil.join(normalizedFilters, AND)); + } + if (StrUtil.isNotBlank(dataPermFilter)) { + if (CollUtil.isNotEmpty(normalizedFilters)) { + where.append(AND); + } else { + where.append(WHERE); + } + where.append(dataPermFilter); + } + return where.toString(); + } + + private String makeSubWhereClause(OnlineFilterDto filter, List paramList) { + StringBuilder where = new StringBuilder(256); + if (filter.getFilterType().equals(FieldFilterType.EQUAL_FILTER)) { + where.append(this.makeWhereLeftOperator(filter)); + where.append(" = ? "); + paramList.add(filter.getColumnValue()); + } else if (filter.getFilterType().equals(FieldFilterType.RANGE_FILTER)) { + where.append(this.makeRangeFilterClause(filter, paramList)); + } else if (filter.getFilterType().equals(FieldFilterType.LIKE_FILTER)) { + where.append(this.makeWhereLeftOperator(filter)); + where.append(" LIKE ? "); + paramList.add(filter.getColumnValue()); + } else if (filter.getFilterType().equals(FieldFilterType.IN_LIST_FILTER)) { + where.append(this.makeWhereLeftOperator(filter)); + where.append(" IN ( "); + where.append(StrUtil.repeat("?,", filter.getColumnValueList().size())); + where.setLength(where.length() - 1); + where.append(")"); + paramList.addAll(filter.getColumnValueList()); + } else if (filter.getFilterType().equals(FieldFilterType.MULTI_LIKE)) { + where.append("("); + StringBuilder sb = new StringBuilder(128); + sb.append(this.makeWhereLeftOperator(filter)).append(" LIKE ? OR "); + String s = StrUtil.repeat(sb.toString(), filter.getColumnValueList().size()); + where.append(s, 0, s.length() - 4); + where.append(")"); + paramList.addAll(filter.getColumnValueList()); + } else if (filter.getFilterType().equals(FieldFilterType.NOT_IN_LIST_FILTER)) { + where.append(this.makeWhereLeftOperator(filter)); + where.append(" NOT IN ("); + where.append(StrUtil.repeat("?,", filter.getColumnValueList().size())); + where.setLength(where.length() - 1); + where.append(")"); + paramList.addAll(filter.getColumnValueList()); + } else if (filter.getFilterType().equals(FieldFilterType.IS_NULL)) { + where.append(this.makeWhereLeftOperator(filter)); + where.append(" IS NULL "); + } else if (filter.getFilterType().equals(FieldFilterType.IS_NOT_NULL)) { + where.append(this.makeWhereLeftOperator(filter)); + where.append(" IS NOT NULL "); + } + return where.toString(); + } + + private String makeRangeFilterClause(OnlineFilterDto filter, List paramList) { + StringBuilder where = new StringBuilder(256); + if (ObjectUtil.isNotEmpty(filter.getColumnValueStart())) { + where.append(this.makeWhereLeftOperator(filter)); + if (BooleanUtil.isTrue(filter.getIsOracleDate())) { + where.append(" >= ").append(filter.getColumnValueStart()); + } else { + where.append(" >= ? "); + paramList.add(filter.getColumnValueStart()); + } + } + if (ObjectUtil.isNotEmpty(filter.getColumnValueEnd())) { + if (ObjectUtil.isNotEmpty(filter.getColumnValueStart())) { + where.append(AND); + } + where.append(this.makeWhereLeftOperator(filter)); + if (BooleanUtil.isTrue(filter.getIsOracleDate())) { + where.append(" <= ").append(filter.getColumnValueEnd()); + } else { + where.append(" <= ? "); + paramList.add(filter.getColumnValueEnd()); + } + } + return where.toString(); + } + + private String makeWhereLeftOperator(OnlineFilterDto filter) { + if (StrUtil.isBlank(filter.getTableName())) { + return filter.getColumnName(); + } + StringBuilder sb = new StringBuilder(128); + sb.append(filter.getTableName()).append(".").append(filter.getColumnName()); + return sb.toString(); + } + + private void saveNewOrUpdateOneToManyRelationData( + OnlineTable masterTable, + Map masterData, + String masterDataId, + OnlineTable slaveTable, + List relationDataList, + OnlineDatasourceRelation relation) { + if (masterData == null) { + masterData = this.getMasterData(masterTable, null, null, masterDataId); + } + Set idSet = new HashSet<>(relationDataList.size()); + for (JSONObject relationData : relationDataList) { + Object id = relationData.get(relation.getSlaveTable().getPrimaryKeyColumn().getColumnName()); + if (ObjectUtil.isNotEmpty(id)) { + idSet.add(id.toString()); + } + } + // 自动补齐主表关联数据。 + OnlineColumn masterColumn = masterTable.getColumnMap().get(relation.getMasterColumnId()); + Object masterColumnValue = masterData.get(masterColumn.getColumnName()); + OnlineColumn slaveColumn = relation.getSlaveTable().getColumnMap().get(relation.getSlaveColumnId()); + // 在从表中删除本地批量更新不存在的数据。 + this.deleteOneToManySlaveData( + relation.getSlaveTable(), slaveColumn, masterColumnValue.toString(), idSet); + for (JSONObject relationData : relationDataList) { + // 自动补齐主表关联数据。 + relationData.put(slaveColumn.getColumnName(), masterColumnValue); + // 拆解主表和一对多关联从表的输入参数,并构建出数据表的待插入数据列表。 + Object id = relationData.get(relation.getSlaveTable().getPrimaryKeyColumn().getColumnName()); + if (id == null) { + this.saveNew(slaveTable, relationData); + } else { + this.update(slaveTable, relationData); + } + } + } + + private void saveNewOrUpdateOneToOneRelationData( + OnlineTable masterTable, + Map masterData, + String masterDataId, + OnlineTable slaveTable, + JSONObject slaveData, + OnlineDatasourceRelation relation) { + if (MapUtil.isEmpty(slaveData)) { + return; + } + String keyColumnName = slaveTable.getPrimaryKeyColumn().getColumnName(); + String slaveDataId = slaveData.getString(keyColumnName); + if (slaveDataId == null) { + if (masterData == null) { + masterData = this.getMasterData(masterTable, null, null, masterDataId); + } + // 自动补齐主表关联数据。 + OnlineColumn masterColumn = masterTable.getColumnMap().get(relation.getMasterColumnId()); + Object masterColumnValue = masterData.get(masterColumn.getColumnName()); + OnlineColumn slaveColumn = slaveTable.getColumnMap().get(relation.getSlaveColumnId()); + slaveData.put(slaveColumn.getColumnName(), masterColumnValue); + this.saveNew(slaveTable, slaveData); + } else { + Map originalSlaveData = + this.getMasterData(slaveTable, null, null, slaveDataId); + for (Map.Entry entry : originalSlaveData.entrySet()) { + slaveData.putIfAbsent(entry.getKey(), entry.getValue()); + } + if (!this.update(slaveTable, slaveData)) { + throw new OnlineRuntimeException("关联从表 [" + slaveTable.getTableName() + "] 中的更新数据不存在"); + } + } + } + + private void reformatResultListWithOneToOneRelation( + List> resultList, List oneToOneRelationList) { + if (CollUtil.isEmpty(oneToOneRelationList) || CollUtil.isEmpty(resultList)) { + return; + } + for (OnlineDatasourceRelation r : oneToOneRelationList) { + for (Map resultMap : resultList) { + Collection slaveColumnList = r.getSlaveTable().getColumnMap().values(); + Map oneToOneRelationDataMap = new HashMap<>(slaveColumnList.size()); + resultMap.put(r.getVariableName(), oneToOneRelationDataMap); + for (OnlineColumn c : slaveColumnList) { + StringBuilder sb = new StringBuilder(64); + sb.append(r.getVariableName()) + .append(OnlineConstant.RELATION_TABLE_COLUMN_SEPARATOR).append(c.getColumnName()); + Object data = this.removeRelationColumnData(resultMap, sb.toString()); + oneToOneRelationDataMap.put(c.getColumnName(), data); + if (c.getDictId() != null) { + sb.append(DICT_MAP_SUFFIX); + data = this.removeRelationColumnData(resultMap, sb.toString()); + oneToOneRelationDataMap.put(c.getColumnName() + DICT_MAP_SUFFIX, data); + } + } + } + } + } + + private Object removeRelationColumnData(Map resultMap, String name) { + Object data = resultMap.remove(name); + if (data == null) { + data = resultMap.remove("\"" + name + "\""); + } + return data; + } + + private void buildVirtualColumn( + List> resultList, OnlineTable table, List relationList) { + if (CollUtil.isEmpty(resultList) || CollUtil.isEmpty(relationList)) { + return; + } + OnlineVirtualColumn virtualColumnFilter = new OnlineVirtualColumn(); + virtualColumnFilter.setTableId(table.getTableId()); + virtualColumnFilter.setVirtualType(VirtualType.AGGREGATION); + List virtualColumnList = + onlineVirtualColumnService.getOnlineVirtualColumnList(virtualColumnFilter, null); + if (CollUtil.isEmpty(virtualColumnList)) { + return; + } + Map relationMap = + relationList.stream().collect(Collectors.toMap(OnlineDatasourceRelation::getRelationId, r -> r)); + for (OnlineVirtualColumn virtualColumn : virtualColumnList) { + OnlineDatasourceRelation relation = relationMap.get(virtualColumn.getRelationId()); + if (relation.getRelationType().equals(RelationType.ONE_TO_MANY)) { + this.doBuildVirtualColumnForOneToMany(table, resultList, virtualColumn, relation); + } + } + } + + private void doBuildVirtualColumnForOneToMany( + OnlineTable masterTable, + List> resultList, + OnlineVirtualColumn virtualColumn, + OnlineDatasourceRelation relation) { + String slaveTableName = relation.getSlaveTable().getTableName(); + OnlineColumn slaveColumn = + relation.getSlaveTable().getColumnMap().get(relation.getSlaveColumnId()); + String slaveColumnName = slaveColumn.getColumnName(); + OnlineColumn aggregationColumn = + relation.getSlaveTable().getColumnMap().get(virtualColumn.getAggregationColumnId()); + String aggregationColumnName = aggregationColumn.getColumnName(); + Tuple2 selectAndGroupByTuple = makeSelectListAndGroupByClause( + slaveTableName, slaveColumnName, slaveTableName, aggregationColumnName, virtualColumn.getAggregationType()); + String selectList = selectAndGroupByTuple.getFirst(); + String groupBy = selectAndGroupByTuple.getSecond(); + // 开始组装过滤从句。 + List criteriaList = new LinkedList<>(); + // 1. 组装主表数据对从表的过滤条件。 + MyWhereCriteria inlistFilter = new MyWhereCriteria(); + OnlineColumn masterColumn = masterTable.getColumnMap().get(relation.getMasterColumnId()); + String masterColumnName = masterColumn.getColumnName(); + Set masterIdSet = resultList.stream() + .map(r -> r.get(masterColumnName)).filter(Objects::nonNull).collect(Collectors.toSet()); + inlistFilter.setCriteria( + slaveTableName, slaveColumnName, slaveColumn.getObjectFieldType(), MyWhereCriteria.OPERATOR_IN, masterIdSet); + criteriaList.add(inlistFilter); + // 2. 从表逻辑删除字段过滤。 + if (relation.getSlaveTable().getLogicDeleteColumn() != null) { + MyWhereCriteria deleteFilter = new MyWhereCriteria(); + deleteFilter.setCriteria( + slaveTableName, + relation.getSlaveTable().getLogicDeleteColumn().getColumnName(), + relation.getSlaveTable().getLogicDeleteColumn().getObjectFieldType(), + MyWhereCriteria.OPERATOR_EQUAL, + GlobalDeletedFlag.NORMAL); + criteriaList.add(deleteFilter); + } + if (StrUtil.isNotBlank(virtualColumn.getWhereClauseJson())) { + List whereClauseList = + JSONArray.parseArray(virtualColumn.getWhereClauseJson(), VirtualColumnWhereClause.class); + if (CollUtil.isNotEmpty(whereClauseList)) { + for (VirtualColumnWhereClause whereClause : whereClauseList) { + MyWhereCriteria whereClauseFilter = new MyWhereCriteria(); + OnlineColumn c = relation.getSlaveTable().getColumnMap().get(whereClause.getColumnId()); + whereClauseFilter.setCriteria( + slaveTableName, + c.getColumnName(), + c.getObjectFieldType(), + whereClause.getOperatorType(), + whereClause.getValue()); + criteriaList.add(whereClauseFilter); + } + } + } + String criteriaString = MyWhereCriteria.makeCriteriaString(criteriaList); + List> aggregationMapList = + getGroupedListByCondition(masterTable.getDblinkId(), slaveTableName, selectList, criteriaString, groupBy); + this.doMakeAggregationData(resultList, aggregationMapList, masterColumnName, virtualColumn.getObjectFieldName()); + } + + private void doMakeAggregationData( + List> resultList, + List> aggregationMapList, + String masterColumnName, + String virtualColumnName) { + // 根据获取的分组聚合结果集,绑定到主表总的关联字段。 + if (CollUtil.isEmpty(aggregationMapList)) { + return; + } + Map relatedMap = new HashMap<>(aggregationMapList.size()); + for (Map map : aggregationMapList) { + relatedMap.put(map.get(KEY_NAME).toString(), map.get(VALUE_NAME)); + } + for (Map dataObject : resultList) { + String masterIdValue = dataObject.get(masterColumnName).toString(); + if (masterIdValue != null) { + Object value = relatedMap.get(masterIdValue); + if (value != null) { + dataObject.put(virtualColumnName, value); + } + } + } + } + + private Tuple2 makeSelectListAndGroupByClause( + String groupTableName, + String groupColumnName, + String aggregationTableName, + String aggregationColumnName, + Integer aggregationType) { + String aggregationFunc = AggregationType.getAggregationFunction(aggregationType); + // 构建Select List + // 如:r_table.master_id groupedKey, SUM(r_table.aggr_column) aggregated_value + StringBuilder groupedSelectList = new StringBuilder(128); + groupedSelectList.append(groupTableName) + .append(".") + .append(groupColumnName) + .append(" ") + .append(KEY_NAME) + .append(", ") + .append(aggregationFunc) + .append("(") + .append(aggregationTableName) + .append(".") + .append(aggregationColumnName) + .append(") ") + .append(VALUE_NAME) + .append(" "); + StringBuilder groupBy = new StringBuilder(64); + groupBy.append(groupTableName).append(".").append(groupColumnName); + return new Tuple2<>(groupedSelectList.toString(), groupBy.toString()); + } + + private void buildDataListWithDict(List> resultList, OnlineTable slaveTable) { + if (CollUtil.isEmpty(resultList)) { + return; + } + Set dictIdSet = new HashSet<>(); + // 先找主表字段对字典的依赖。 + Multimap dictColumnMap = LinkedHashMultimap.create(); + for (OnlineColumn column : slaveTable.getColumnMap().values()) { + if (column.getDictId() != null) { + dictIdSet.add(column.getDictId()); + column.setColumnAliasName(column.getColumnName()); + dictColumnMap.put(column.getDictId(), column); + } + } + this.doBuildDataListWithDict(resultList, dictIdSet, dictColumnMap); + } + + private void buildDataListWithDict( + List> resultList, + OnlineTable masterTable, + List relationList) { + if (CollUtil.isEmpty(resultList)) { + return; + } + Set dictIdSet = new HashSet<>(); + // 先找主表字段对字典的依赖。 + Multimap dictColumnMap = LinkedHashMultimap.create(); + for (OnlineColumn column : masterTable.getColumnMap().values()) { + if (column.getDictId() != null) { + dictIdSet.add(column.getDictId()); + column.setColumnAliasName(column.getColumnName()); + dictColumnMap.put(column.getDictId(), column); + } + } + // 再找关联表字段对字典的依赖。 + if (CollUtil.isEmpty(relationList)) { + this.doBuildDataListWithDict(resultList, dictIdSet, dictColumnMap); + return; + } + for (OnlineDatasourceRelation relation : relationList) { + for (OnlineColumn column : relation.getSlaveTable().getColumnMap().values()) { + if (column.getDictId() != null) { + dictIdSet.add(column.getDictId()); + String columnAliasName = relation.getVariableName() + + OnlineConstant.RELATION_TABLE_COLUMN_SEPARATOR + column.getColumnName(); + column.setColumnAliasName(columnAliasName); + dictColumnMap.put(column.getDictId(), column); + } + } + } + this.doBuildDataListWithDict(resultList, dictIdSet, dictColumnMap); + } + + private void doBuildDataListWithDict( + List> resultList, Set dictIdSet, Multimap dictColumnMap) { + if (CollUtil.isEmpty(dictIdSet)) { + return; + } + List allDictList = onlineDictService.getOnlineDictListFromCache(dictIdSet); + for (OnlineDict dict : allDictList) { + Collection columnList = dictColumnMap.get(dict.getDictId()); + for (OnlineColumn column : columnList) { + Set dictIdDataSet = this.extractColumnDictIds(resultList, column); + if (CollUtil.isNotEmpty(dictIdDataSet)) { + this.doBindColumnDictData(resultList, column, dict, dictIdDataSet); + } + } + } + } + + private Set extractColumnDictValues(List> dataList, OnlineColumn column) { + Set dictValueDataSet = new HashSet<>(); + for (Map data : dataList) { + String dictValueData = (String) data.get(column.getColumnAliasName()); + if (StrUtil.isNotBlank(dictValueData)) { + if (ObjectUtil.equals(column.getFieldKind(), FieldKind.DICT_MULTI_SELECT)) { + Set dictValueDataList = StrUtil.split(dictValueData, ",") + .stream().filter(StrUtil::isNotBlank).collect(Collectors.toSet()); + CollUtil.addAll(dictValueDataSet, dictValueDataList); + } else { + dictValueDataSet.add(dictValueData); + } + } + } + return dictValueDataSet; + } + + private Set extractColumnDictIds(List> resultList, OnlineColumn column) { + Set dictIdDataSet = new HashSet<>(); + for (Map result : resultList) { + Object dictIdData = result.get(column.getColumnAliasName()); + if (ObjectUtil.isEmpty(dictIdData)) { + continue; + } + if (ObjectUtil.equals(column.getFieldKind(), FieldKind.DICT_MULTI_SELECT)) { + Set dictIdDataList = StrUtil.split(dictIdData.toString(), ",") + .stream().filter(StrUtil::isNotBlank).collect(Collectors.toSet()); + if (ObjectFieldType.LONG.equals(column.getObjectFieldType())) { + dictIdDataList = dictIdDataSet.stream() + .map(c -> (Serializable) Long.valueOf(c.toString())).collect(Collectors.toSet()); + } + CollUtil.addAll(dictIdDataSet, dictIdDataList); + } else { + dictIdDataSet.add((Serializable) dictIdData); + } + } + return dictIdDataSet; + } + + private Map getGlobalDictItemDictMapFromCache(String dictCode, Set itemIds) { + return globalDictService.getGlobalDictItemDictMapFromCache(dictCode, itemIds); + } + + private void doTranslateColumnDictData( + List> dataList, + OnlineColumn column, + OnlineDict dict, + Set dictValueDataSet) { + Map dictResultMap = this.doTranslateColumnDictDataMap(dict, dictValueDataSet); + for (Map data : dataList) { + String dictValueData = (String) data.get(column.getColumnAliasName()); + if (StrUtil.isBlank(dictValueData)) { + continue; + } + if (ObjectUtil.equals(column.getFieldKind(), FieldKind.DICT_MULTI_SELECT)) { + List dictValueDataList = StrUtil.splitTrim(dictValueData, ","); + List dictIdList = dictValueDataList.stream() + .map(dictResultMap::get).filter(Objects::nonNull).collect(Collectors.toList()); + data.put(column.getColumnAliasName(), CollUtil.join(dictIdList, ",")); + } else { + Object dictId = dictResultMap.get(dictValueData); + if (dictId != null) { + data.put(column.getColumnAliasName(), dictId); + } + } + } + } + + private Map doTranslateColumnDictDataMap(OnlineDict dict, Set dictValueDataSet) { + Map dictResultMap = new HashMap<>(dictValueDataSet.size()); + if (dict.getDictType().equals(DictType.CUSTOM)) { + ConstDictInfo dictInfo = + JSONObject.parseObject(dict.getDictDataJson(), ConstDictInfo.class); + List dictDataList = dictInfo.getDictData(); + for (ConstDictInfo.ConstDictData dictData : dictDataList) { + dictResultMap.put(dictData.getName(), dictData.getId()); + } + } else if (dict.getDictType().equals(DictType.GLOBAL_DICT)) { + Map dictDataMap = + this.getGlobalDictItemDictMapFromCache(dict.getDictCode(), null); + dictDataMap.entrySet().stream() + .filter(entry -> dictValueDataSet.contains(entry.getValue())) + .forEach(entry -> dictResultMap.put(entry.getValue(), entry.getKey())); + } else if (dict.getDictType().equals(DictType.TABLE)) { + String selectFields = this.makeDictSelectFields(dict, true); + List filterList = this.createDefaultFilter(dict); + OnlineFilterDto inlistFilter = new OnlineFilterDto(); + inlistFilter.setTableName(dict.getTableName()); + inlistFilter.setColumnName(dict.getValueColumnName()); + inlistFilter.setColumnValueList(dictValueDataSet); + inlistFilter.setFilterType(FieldFilterType.IN_LIST_FILTER); + filterList.add(inlistFilter); + List> dictResultList = + this.getDictList(dict.getDblinkId(), dict.getTableName(), selectFields, filterList, null); + if (CollUtil.isNotEmpty(dictResultList)) { + for (Map dictResult : dictResultList) { + dictResultMap.put(dictResult.get("name").toString(), dictResult.get("id")); + } + } + } else if (dict.getDictType().equals(DictType.URL)) { + this.buildUrlDictDataMap(dict, dictResultMap, false); + } + return dictResultMap; + } + + private Map doBuildColumnDictDataMap(OnlineDict dict, Set dictIdDataSet) { + Map dictResultMap = new HashMap<>(dictIdDataSet.size()); + if (dict.getDictType().equals(DictType.CUSTOM)) { + ConstDictInfo dictInfo = + JSONObject.parseObject(dict.getDictDataJson(), ConstDictInfo.class); + List dictDataList = dictInfo.getDictData(); + for (ConstDictInfo.ConstDictData dictData : dictDataList) { + dictResultMap.put(dictData.getId().toString(), dictData.getName()); + } + } else if (dict.getDictType().equals(DictType.GLOBAL_DICT)) { + Map dictDataMap = + this.getGlobalDictItemDictMapFromCache(dict.getDictCode(), dictIdDataSet); + for (Map.Entry entry : dictDataMap.entrySet()) { + dictResultMap.put(entry.getKey().toString(), entry.getValue()); + } + } else if (dict.getDictType().equals(DictType.TABLE)) { + String selectFields = this.makeDictSelectFields(dict, true); + List filterList = this.createDefaultFilter(dict); + OnlineFilterDto inlistFilter = new OnlineFilterDto(); + inlistFilter.setTableName(dict.getTableName()); + inlistFilter.setColumnName(dict.getKeyColumnName()); + inlistFilter.setColumnValueList(dictIdDataSet); + inlistFilter.setFilterType(FieldFilterType.IN_LIST_FILTER); + filterList.add(inlistFilter); + List> dictResultList = + this.getDictList(dict.getDblinkId(), dict.getTableName(), selectFields, filterList, null); + if (CollUtil.isNotEmpty(dictResultList)) { + for (Map dictResult : dictResultList) { + dictResultMap.put(dictResult.get("id").toString(), dictResult.get("name")); + } + } + } else if (dict.getDictType().equals(DictType.URL)) { + this.buildUrlDictDataMap(dict, dictResultMap, true); + } + return dictResultMap; + } + + private List createDefaultFilter(OnlineDict dict) { + List filterList = new LinkedList<>(); + if (StrUtil.isNotBlank(dict.getDeletedColumnName())) { + OnlineFilterDto filter = new OnlineFilterDto(); + filter.setTableName(dict.getTableName()); + filter.setColumnName(dict.getDeletedColumnName()); + filter.setColumnValue(GlobalDeletedFlag.NORMAL); + filterList.add(filter); + } + return filterList; + } + + private void buildUrlDictDataMap(OnlineDict dict, Map dictResultMap, boolean keyToValue) { + Map param = new HashMap<>(1); + param.put("Authorization", TokenData.takeFromRequest().getToken()); + String responseData = HttpUtil.get(dict.getDictListUrl(), param); + ResponseResult responseResult = + JSON.parseObject(responseData, new TypeReference>() { + }); + if (!responseResult.isSuccess()) { + throw new OnlineRuntimeException(responseResult.getErrorMessage()); + } + JSONArray dictDataArray = responseResult.getData(); + for (int i = 0; i < dictDataArray.size(); i++) { + JSONObject dictData = dictDataArray.getJSONObject(i); + if (keyToValue) { + dictResultMap.put(dictData.getString(dict.getKeyColumnName()), dictData.get(dict.getValueColumnName())); + } else { + dictResultMap.put(dictData.getString(dict.getValueColumnName()), dictData.get(dict.getKeyColumnName())); + } + } + } + + private void doBindColumnDictData( + List> resultList, + OnlineColumn column, + OnlineDict dict, + Set dictIdDataSet) { + Map dictResultMap = this.doBuildColumnDictDataMap(dict, dictIdDataSet); + String dictKeyName; + if (ObjectUtil.equals(column.getFieldKind(), FieldKind.DICT_MULTI_SELECT)) { + dictKeyName = column.getColumnAliasName() + DICT_MAP_LIST_SUFFIX; + } else { + dictKeyName = column.getColumnAliasName() + DICT_MAP_SUFFIX; + } + for (Map result : resultList) { + Object dictIdData = result.get(column.getColumnAliasName()); + if (ObjectUtil.isEmpty(dictIdData)) { + continue; + } + if (ObjectUtil.equals(column.getFieldKind(), FieldKind.DICT_MULTI_SELECT)) { + List dictIdDataList = StrUtil.splitTrim(dictIdData.toString(), ","); + List> dictMapList = new LinkedList<>(); + for (String data : dictIdDataList) { + Object dictNameData = dictResultMap.get(data); + Map dictMap = new HashMap<>(2); + dictMap.put("id", data); + dictMap.put("name", dictNameData); + dictMapList.add(dictMap); + } + result.put(dictKeyName, dictMapList); + } else { + Object dictNameData = dictResultMap.get(dictIdData.toString()); + Map dictMap = new HashMap<>(2); + dictMap.put("id", dictIdData); + dictMap.put("name", dictNameData); + result.put(dictKeyName, dictMap); + } + } + } + + private List makeJoinInfoList( + OnlineTable masterTable, List relationList) { + List joinInfoList = new LinkedList<>(); + if (CollUtil.isEmpty(relationList)) { + return joinInfoList; + } + Map masterTableColumnMap = masterTable.getColumnMap(); + for (OnlineDatasourceRelation relation : relationList) { + JoinTableInfo joinInfo = new JoinTableInfo(); + joinInfo.setLeftJoin(relation.getLeftJoin()); + joinInfo.setJoinTableName(relation.getSlaveTable().getTableName() + " " + relation.getVariableName()); + // 根据配置动态拼接JOIN的关联条件,同时要考虑从表的逻辑删除过滤。 + OnlineColumn masterColumn = masterTableColumnMap.get(relation.getMasterColumnId()); + OnlineColumn slaveColumn = relation.getSlaveTable().getColumnMap().get(relation.getSlaveColumnId()); + StringBuilder conditionBuilder = new StringBuilder(64); + conditionBuilder + .append(masterTable.getTableName()) + .append(".") + .append(masterColumn.getColumnName()) + .append(" = ") + .append(relation.getVariableName()) + .append(".") + .append(slaveColumn.getColumnName()); + if (relation.getSlaveTable().getLogicDeleteColumn() != null) { + conditionBuilder + .append(AND) + .append(relation.getVariableName()) + .append(".") + .append(relation.getSlaveTable().getLogicDeleteColumn().getColumnName()) + .append(" = ") + .append(GlobalDeletedFlag.NORMAL); + } + joinInfo.setJoinCondition(conditionBuilder.toString()); + joinInfoList.add(joinInfo); + } + return joinInfoList; + } + + private String makeSelectFields(OnlineTable table, String relationVariable) { + DataSourceProvider provider = dataSourceUtil.getProvider(table.getDblinkId()); + StringBuilder selectFieldBuider = new StringBuilder(512); + String intString = "SIGNED"; + if (provider.getDblinkType() == DblinkType.POSTGRESQL|| provider.getDblinkType() == DblinkType.OPENGAUSS) { + intString = "INT8"; + } + // 拼装主表的select fields字段。 + for (OnlineColumn column : table.getColumnMap().values()) { + OnlineColumn deletedColumn = table.getLogicDeleteColumn(); + String columnAliasName = column.getColumnName(); + if (relationVariable != null) { + columnAliasName = relationVariable + + OnlineConstant.RELATION_TABLE_COLUMN_SEPARATOR + column.getColumnName(); + } + if (deletedColumn != null && StrUtil.equals(column.getColumnName(), deletedColumn.getColumnName())) { + continue; + } + if (this.castToInteger(column)) { + selectFieldBuider + .append("CAST(") + .append(table.getTableName()) + .append(".") + .append(column.getColumnName()) + .append(" AS ") + .append(intString) + .append(") \"") + .append(columnAliasName) + .append("\","); + } else if ("date".equals(column.getColumnType())) { + selectFieldBuider + .append("CAST(") + .append(table.getTableName()) + .append(".") + .append(column.getColumnName()) + .append(" AS CHAR(10)) \"") + .append(columnAliasName) + .append("\","); + } else { + selectFieldBuider + .append(table.getTableName()) + .append(".") + .append(column.getColumnName()) + .append(" \"") + .append(columnAliasName) + .append("\","); + } + } + return selectFieldBuider.substring(0, selectFieldBuider.length() - 1); + } + + private String makeSelectFieldsWithRelation( + OnlineTable masterTable, List relationList) { + String masterTableSelectFields = this.makeSelectFields(masterTable, null); + if (CollUtil.isEmpty(relationList)) { + return masterTableSelectFields; + } + StringBuilder selectFieldBuider = new StringBuilder(512); + selectFieldBuider.append(masterTableSelectFields).append(","); + for (OnlineDatasourceRelation relation : relationList) { + OnlineTable slaveTable = relation.getSlaveTable(); + String relationTableSelectFields = this.makeSelectFields(slaveTable, relation.getVariableName()); + selectFieldBuider.append(relationTableSelectFields).append(","); + } + return selectFieldBuider.substring(0, selectFieldBuider.length() - 1); + } + + private String makeDictSelectFields(OnlineDict onlineDict, boolean ignoreParentId) { + StringBuilder sb = new StringBuilder(128); + sb.append(onlineDict.getKeyColumnName()).append(" \"id\", "); + sb.append(onlineDict.getValueColumnName()).append(" \"name\""); + if (!ignoreParentId && BooleanUtil.isTrue(onlineDict.getTreeFlag())) { + sb.append(", ").append(onlineDict.getParentKeyColumnName()).append(" \"parentId\""); + } + return sb.toString(); + } + + private boolean castToInteger(OnlineColumn column) { + return "tinyint(1)".equals(column.getFullColumnType()); + } + + private String makeColumnNames(List columnDataList) { + StringBuilder sb = new StringBuilder(512); + for (ColumnData columnData : columnDataList) { + if (BooleanUtil.isTrue(columnData.getColumn().getAutoIncrement())) { + continue; + } + sb.append(columnData.getColumn().getColumnName()).append(","); + } + return sb.substring(0, sb.length() - 1); + } + + private void makeupColumnValue(ColumnData columnData) { + if (BooleanUtil.isTrue(columnData.getColumn().getAutoIncrement())) { + return; + } + if (BooleanUtil.isTrue(columnData.getColumn().getPrimaryKey())) { + if (columnData.getColumnValue() == null + && BooleanUtil.isFalse(columnData.getColumn().getAutoIncrement())) { + if (ObjectFieldType.LONG.equals(columnData.getColumn().getObjectFieldType())) { + columnData.setColumnValue(idGenerator.nextLongId()); + } else { + columnData.setColumnValue(idGenerator.nextStringId()); + } + } + } else if (columnData.getColumn().getFieldKind() != null) { + this.makeupColumnValueForFieldKind(columnData); + } else if (columnData.getColumn().getColumnDefault() != null + && columnData.getColumnValue() == null) { + Object v = onlineOperationHelper.convertToTypeValue( + columnData.getColumn(), columnData.getColumn().getColumnDefault()); + columnData.setColumnValue(v); + } + } + + private void makeupColumnValueForFieldKind(ColumnData columnData) { + switch (columnData.getColumn().getFieldKind()) { + case FieldKind.CREATE_TIME: + case FieldKind.UPDATE_TIME: + columnData.setColumnValue(LocalDateTime.now()); + break; + case FieldKind.CREATE_USER_ID: + case FieldKind.UPDATE_USER_ID: + columnData.setColumnValue(TokenData.takeFromRequest().getUserId()); + break; + case FieldKind.CREATE_DEPT_ID: + columnData.setColumnValue(TokenData.takeFromRequest().getDeptId()); + break; + case FieldKind.LOGIC_DELETE: + columnData.setColumnValue(GlobalDeletedFlag.NORMAL); + break; + default: + break; + } + } + + private List makeDefaultFilter(OnlineTable table, OnlineColumn column, String columnValue) { + List filterList = new LinkedList<>(); + OnlineFilterDto dataIdFilter = new OnlineFilterDto(); + dataIdFilter.setTableName(table.getTableName()); + dataIdFilter.setColumnName(column.getColumnName()); + dataIdFilter.setColumnValue(onlineOperationHelper.convertToTypeValue(column, columnValue)); + filterList.add(dataIdFilter); + if (table.getLogicDeleteColumn() != null) { + OnlineFilterDto filter = new OnlineFilterDto(); + filter.setTableName(table.getTableName()); + filter.setColumnName(table.getLogicDeleteColumn().getColumnName()); + filter.setColumnValue(GlobalDeletedFlag.NORMAL); + filterList.add(filter); + } + return filterList; + } + + private void doLogicDelete( + OnlineTable table, List filterList, String dataPermFilter) { + List updateColumnList = new LinkedList<>(); + ColumnData logicDeleteColumnData = new ColumnData(); + logicDeleteColumnData.setColumn(table.getLogicDeleteColumn()); + logicDeleteColumnData.setColumnValue(GlobalDeletedFlag.DELETED); + updateColumnList.add(logicDeleteColumnData); + this.doUpdate(table, updateColumnList, filterList, dataPermFilter); + } + + private void doLogicDelete( + OnlineTable table, OnlineColumn filterColumn, String filterColumnValue, String dataPermFilter) { + List filterList = new LinkedList<>(); + OnlineFilterDto filter = new OnlineFilterDto(); + filter.setTableName(table.getTableName()); + filter.setColumnName(filterColumn.getColumnName()); + filter.setColumnValue(onlineOperationHelper.convertToTypeValue(filterColumn, filterColumnValue)); + filterList.add(filter); + this.doLogicDelete(table, filterList, dataPermFilter); + } + + private void normalizeFilterList( + OnlineTable table, List oneToOneRelationList, List filterList) { + if (table.getLogicDeleteColumn() != null) { + if (filterList == null) { + filterList = new LinkedList<>(); + } + OnlineFilterDto filter = new OnlineFilterDto(); + filter.setTableName(table.getTableName()); + filter.setColumnName(table.getLogicDeleteColumn().getColumnName()); + filter.setColumnValue(GlobalDeletedFlag.NORMAL); + filterList.add(filter); + } + if (CollUtil.isEmpty(filterList)) { + return; + } + OnlineDblink dblink = onlineDblinkService.getById(table.getDblinkId()); + for (OnlineFilterDto filter : filterList) { + // oracle 日期字段的,后面要重写这段代码,以便具有更好的通用性。 + if (filter.getFilterType().equals(FieldFilterType.RANGE_FILTER)) { + this.makeRangeFilter(dblink, table, oneToOneRelationList, filter); + } + if (BooleanUtil.isTrue(filter.getDictMultiSelect())) { + filter.setFilterType(FieldFilterType.MULTI_LIKE); + List dictValueSet = StrUtil.split(filter.getColumnValue().toString(), ","); + filter.setColumnValueList( + dictValueSet.stream().map(v -> "%" + v + ",%").collect(Collectors.toSet())); + } + if (filter.getFilterType().equals(FieldFilterType.LIKE_FILTER)) { + filter.setColumnValue("%" + filter.getColumnValue() + "%"); + } else if (filter.getFilterType().equals(FieldFilterType.IN_LIST_FILTER) + && ObjectUtil.isNotEmpty(filter.getColumnValue())) { + filter.setColumnValueList( + new HashSet<>(StrUtil.split(filter.getColumnValue().toString(), ","))); + } + } + } + + private String normalizeSlaveTableAlias(List relationList, String s) { + if (CollUtil.isEmpty(relationList) || StrUtil.isBlank(s)) { + return s; + } + for (OnlineDatasourceRelation r : relationList) { + s = StrUtil.replace(s, r.getSlaveTable().getTableName() + ".", r.getVariableName() + "."); + } + return s; + } + + private void normalizeFiltersSlaveTableAlias( + List relationList, List filters) { + if (CollUtil.isEmpty(relationList) || CollUtil.isEmpty(filters)) { + return; + } + for (OnlineDatasourceRelation r : relationList) { + for (OnlineFilterDto filter : filters) { + if (StrUtil.equals(filter.getTableName(), r.getSlaveTable().getTableName())) { + filter.setTableName(r.getVariableName()); + } + } + } + } + + private void makeRangeFilter( + OnlineDblink dblink, + OnlineTable table, + List oneToOneRelationList, + OnlineFilterDto filter) { + if (!dblink.getDblinkType().equals(DblinkType.ORACLE)) { + return; + } + OnlineColumn column = table.getColumnMap().values().stream() + .filter(c -> c.getColumnName().equals(filter.getColumnName())).findFirst().orElse(null); + if (column == null && oneToOneRelationList != null) { + for (OnlineDatasourceRelation r : oneToOneRelationList) { + column = r.getSlaveTable().getColumnMap().values().stream() + .filter(c -> c.getColumnName().equals(filter.getColumnName())).findFirst().orElse(null); + if (column != null) { + break; + } + } + } + org.springframework.util.Assert.notNull(column, "column can't be NULL."); + filter.setIsOracleDate(StrUtil.equals(column.getObjectFieldType(), "Date")); + if (BooleanUtil.isTrue(filter.getIsOracleDate())) { + if (filter.getColumnValueStart() != null) { + filter.setColumnValueStart("TO_DATE('" + filter.getColumnValueStart() + "','YYYY-MM-DD HH24:MI:SS')"); + } + if (filter.getColumnValueEnd() != null) { + filter.setColumnValueEnd("TO_DATE('" + filter.getColumnValueEnd() + "','YYYY-MM-DD HH24:MI:SS')"); + } + } + } + + private String buildDataPermFilter(String tableName, String deptFilterColumnName, String userFilterColumnName) { + if (BooleanUtil.isFalse(dataFilterProperties.getEnabledDataPermFilter())) { + return null; + } + if (!GlobalThreadLocal.enabledDataFilter()) { + return null; + } + return processDataPerm(tableName, deptFilterColumnName, userFilterColumnName); + } + + private String buildDataPermFilter(OnlineTable table) { + if (BooleanUtil.isFalse(dataFilterProperties.getEnabledDataPermFilter())) { + return null; + } + if (!GlobalThreadLocal.enabledDataFilter()) { + return null; + } + String deptFilterColumnName = null; + String userFilterColumnName = null; + for (OnlineColumn column : table.getColumnMap().values()) { + if (BooleanUtil.isTrue(column.getDeptFilter())) { + deptFilterColumnName = column.getColumnName(); + } + if (BooleanUtil.isTrue(column.getUserFilter())) { + userFilterColumnName = column.getColumnName(); + } + } + return processDataPerm(table.getTableName(), deptFilterColumnName, userFilterColumnName); + } + + private String processDataPerm(String tableName, String deptFilterColumnName, String userFilterColumnName) { + TokenData tokenData = TokenData.takeFromRequest(); + if (Boolean.TRUE.equals(tokenData.getIsAdmin())) { + return null; + } + if (StrUtil.isAllBlank(deptFilterColumnName, userFilterColumnName)) { + return null; + } + String dataPermSessionKey = RedisKeyUtil.makeSessionDataPermIdKey(tokenData.getSessionId()); + Object cachedData = this.getCachedData(dataPermSessionKey); + if (cachedData == null) { + throw new NoDataPermException("No Related DataPerm found For OnlineForm Module."); + } + JSONObject allMenuDataPermMap = cachedData instanceof JSONObject + ? (JSONObject) cachedData : JSON.parseObject(cachedData.toString()); + JSONObject menuDataPermMap = this.getAndVerifyMenuDataPerm(allMenuDataPermMap, tableName); + Map dataPermMap = new HashMap<>(8); + for (Map.Entry entry : menuDataPermMap.entrySet()) { + dataPermMap.put(Integer.valueOf(entry.getKey()), entry.getValue().toString()); + } + if (MapUtil.isEmpty(dataPermMap)) { + throw new NoDataPermException(StrFormatter.format( + "No Related OnlineForm DataPerm found for table [{}].", tableName)); + } + if (dataPermMap.containsKey(DataPermRuleType.TYPE_ALL)) { + return null; + } + return doProcessDataPerm(tableName, deptFilterColumnName, userFilterColumnName, dataPermMap); + } + + private JSONObject getAndVerifyMenuDataPerm(JSONObject allMenuDataPermMap, String tableName) { + String menuId = ContextUtil.getHttpRequest().getHeader(ApplicationConstant.HTTP_HEADER_MENU_ID); + if (menuId == null) { + menuId = ContextUtil.getHttpRequest().getParameter(ApplicationConstant.HTTP_HEADER_MENU_ID); + } + if (BooleanUtil.isFalse(dataFilterProperties.getEnableMenuPermVerify()) && menuId == null) { + menuId = ApplicationConstant.DATA_PERM_ALL_MENU_ID; + } + Assert.notNull(menuId); + JSONObject menuDataPermMap = allMenuDataPermMap.getJSONObject(menuId); + if (menuDataPermMap == null) { + menuDataPermMap = allMenuDataPermMap.getJSONObject(ApplicationConstant.DATA_PERM_ALL_MENU_ID); + } + if (menuDataPermMap == null) { + throw new NoDataPermException(StrFormatter.format( + "No Related OnlineForm DataPerm found for menuId [{}] and table [{}].", + menuId, tableName)); + } + if (BooleanUtil.isTrue(dataFilterProperties.getEnableMenuPermVerify())) { + String url = ContextUtil.getHttpRequest().getHeader(ApplicationConstant.HTTP_HEADER_ORIGINAL_REQUEST_URL); + if (StrUtil.isBlank(url)) { + url = ContextUtil.getHttpRequest().getRequestURI(); + } + Assert.notNull(url); + if (!this.verifyMenuPerm(null, url, tableName) && !this.verifyMenuPerm(menuId, url, tableName)) { + String msg = StrFormatter.format("Mismatched OnlineForm DataPerm " + + "for menuId [{}] and url [{}] and SQL_ID [{}].", menuId, url, tableName); + throw new NoDataPermException(msg); + } + } + return menuDataPermMap; + } + + private Object getCachedData(String dataPermSessionKey) { + Object cachedData = null; + Cache cache = cacheManager.getCache(CacheConfig.CacheEnum.DATA_PERMISSION_CACHE.name()); + if (cache == null) { + return cachedData; + } + Cache.ValueWrapper wrapper = cache.get(dataPermSessionKey); + if (wrapper == null) { + cachedData = redissonClient.getBucket(dataPermSessionKey).get(); + if (cachedData != null) { + cache.put(dataPermSessionKey, JSON.parseObject(cachedData.toString())); + } + } else { + cachedData = wrapper.get(); + } + return cachedData; + } + + @SuppressWarnings("unchecked") + private boolean verifyMenuPerm(String menuId, String url, String tableName) { + String sessionId = TokenData.takeFromRequest().getSessionId(); + String menuPermSessionKey; + if (menuId != null) { + menuPermSessionKey = RedisKeyUtil.makeSessionMenuPermKey(sessionId, menuId); + } else { + menuPermSessionKey = RedisKeyUtil.makeSessionWhiteListPermKey(sessionId); + } + Cache cache = cacheManager.getCache(CacheConfig.CacheEnum.MENU_PERM_CACHE.name()); + if (cache == null) { + return false; + } + Cache.ValueWrapper wrapper = cache.get(menuPermSessionKey); + if (wrapper != null) { + Object cacheData = wrapper.get(); + if (cacheData != null) { + return ((Set) cacheData).contains(url); + } + } + RBucket bucket = redissonClient.getBucket(menuPermSessionKey); + if (!bucket.isExists()) { + String msg; + if (menuId == null) { + msg = StrFormatter.format("No Related MenuPerm found " + + "in Redis Cache for WHITE_LIST and tableName [{}] with sessionId [{}].", tableName, sessionId); + } else { + msg = StrFormatter.format("No Related MenuPerm found " + + "in Redis Cache for menuId [{}] and tableName[{}] with sessionId [{}].", menuId, tableName, sessionId); + } + throw new NoDataPermException(msg); + } + Set cachedMenuPermSet = new HashSet<>(JSONArray.parseArray(bucket.get(), String.class)); + cache.put(menuPermSessionKey, cachedMenuPermSet); + return cachedMenuPermSet.contains(url); + } + + private String doProcessDataPerm( + String tableName, String deptFilterColumnName, String userFilterColumnName, Map dataPermMap) { + List criteriaList = new LinkedList<>(); + for (Map.Entry entry : dataPermMap.entrySet()) { + String filterClause = processDataPermRule( + tableName, deptFilterColumnName, userFilterColumnName, entry.getKey(), entry.getValue()); + if (StrUtil.isNotBlank(filterClause)) { + criteriaList.add(filterClause); + } + } + if (CollUtil.isEmpty(criteriaList)) { + return null; + } + StringBuilder filterBuilder = new StringBuilder(128); + filterBuilder.append("("); + filterBuilder.append(CollUtil.join(criteriaList, " OR ")); + filterBuilder.append(")"); + return filterBuilder.toString(); + } + + private String processDataPermRule( + String tableName, String deptFilterColumnName, String userFilterColumnName, Integer ruleType, String dataIds) { + TokenData tokenData = TokenData.takeFromRequest(); + StringBuilder filter = new StringBuilder(128); + if (ruleType != DataPermRuleType.TYPE_USER_ONLY + && ruleType != DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT_USERS + && ruleType != DataPermRuleType.TYPE_DEPT_USERS) { + return this.processDeptDataPermRule(tableName, deptFilterColumnName, ruleType, dataIds); + } + if (StrUtil.isBlank(userFilterColumnName)) { + log.warn("No UserFilterColumn for ONLINE table [{}] but USER_FILTER_DATA_PERM exists", tableName); + return filter.toString(); + } + if (BooleanUtil.isTrue(dataFilterProperties.getAddTableNamePrefix())) { + filter.append(tableName).append("."); + } + if (ruleType == DataPermRuleType.TYPE_USER_ONLY) { + filter.append(userFilterColumnName).append(" = ").append(tokenData.getUserId()); + } else { + filter.append(userFilterColumnName) + .append(" IN (") + .append(dataIds) + .append(") "); + } + return filter.toString(); + } + + private String processDeptDataPermRule( + String tableName, String deptFilterColumnName, Integer ruleType, String deptIds) { + TokenData tokenData = TokenData.takeFromRequest(); + StringBuilder filter = new StringBuilder(256); + if (StrUtil.isBlank(deptFilterColumnName)) { + log.warn("No DeptFilterColumn for ONLINE table [{}] but DEPT_FILTER_DATA_PERM exists", tableName); + return filter.toString(); + } + if (ruleType == DataPermRuleType.TYPE_DEPT_ONLY) { + if (BooleanUtil.isTrue(dataFilterProperties.getAddTableNamePrefix())) { + filter.append(tableName).append("."); + } + filter.append(deptFilterColumnName).append(" = ").append(tokenData.getDeptId()); + } else if (ruleType == DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT) { + filter.append(" EXISTS ") + .append("(SELECT 1 FROM ") + .append(dataFilterProperties.getDeptRelationTablePrefix()) + .append("sys_dept_relation WHERE ") + .append(dataFilterProperties.getDeptRelationTablePrefix()) + .append("sys_dept_relation.parent_dept_id = ") + .append(tokenData.getDeptId()) + .append(AND); + if (BooleanUtil.isTrue(dataFilterProperties.getAddTableNamePrefix())) { + filter.append(tableName).append("."); + } + filter.append(deptFilterColumnName) + .append(" = ") + .append(dataFilterProperties.getDeptRelationTablePrefix()) + .append("sys_dept_relation.dept_id) "); + } else if (ruleType == DataPermRuleType.TYPE_MULTI_DEPT_AND_CHILD_DEPT) { + filter.append(" EXISTS ") + .append("(SELECT 1 FROM ") + .append(dataFilterProperties.getDeptRelationTablePrefix()) + .append("sys_dept_relation WHERE ") + .append(dataFilterProperties.getDeptRelationTablePrefix()) + .append("sys_dept_relation.parent_dept_id IN (") + .append(deptIds) + .append(") AND "); + if (BooleanUtil.isTrue(dataFilterProperties.getAddTableNamePrefix())) { + filter.append(tableName).append("."); + } + filter.append(deptFilterColumnName) + .append(" = ") + .append(dataFilterProperties.getDeptRelationTablePrefix()) + .append("sys_dept_relation.dept_id) "); + } else if (ruleType == DataPermRuleType.TYPE_CUSTOM_DEPT_LIST) { + if (BooleanUtil.isTrue(dataFilterProperties.getAddTableNamePrefix())) { + filter.append(tableName).append("."); + } + filter.append(deptFilterColumnName).append(" IN (").append(deptIds).append(") "); + } + return filter.toString(); + } + + @Data + private static class VirtualColumnWhereClause { + private Long tableId; + private Long columnId; + private Integer operatorType; + private Object value; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlinePageServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlinePageServiceImpl.java new file mode 100644 index 00000000..4b3ddaab --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlinePageServiceImpl.java @@ -0,0 +1,295 @@ +package com.orangeforms.common.online.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.mybatisflex.core.query.QueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.online.dao.OnlinePageDatasourceMapper; +import com.orangeforms.common.online.dao.OnlinePageMapper; +import com.orangeforms.common.online.model.OnlinePage; +import com.orangeforms.common.online.model.OnlinePageDatasource; +import com.orangeforms.common.online.model.constant.PageStatus; +import com.orangeforms.common.online.service.OnlineDatasourceService; +import com.orangeforms.common.online.service.OnlineFormService; +import com.orangeforms.common.online.service.OnlinePageService; +import com.github.pagehelper.Page; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.LinkedList; +import java.util.List; + +/** + * 在线表单页面数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("onlinePageService") +public class OnlinePageServiceImpl extends BaseService implements OnlinePageService { + + @Autowired + private OnlinePageMapper onlinePageMapper; + @Autowired + private OnlinePageDatasourceMapper onlinePageDatasourceMapper; + @Autowired + private OnlineFormService onlineFormService; + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return onlinePageMapper; + } + + /** + * 保存新增对象。 + * + * @param onlinePage 新增对象。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public OnlinePage saveNew(OnlinePage onlinePage) { + TokenData tokenData = TokenData.takeFromRequest(); + onlinePage.setPageId(idGenerator.nextLongId()); + onlinePage.setAppCode(tokenData.getAppCode()); + onlinePage.setTenantId(tokenData.getTenantId()); + Date now = new Date(); + onlinePage.setUpdateTime(now); + onlinePage.setCreateTime(now); + onlinePage.setCreateUserId(tokenData.getUserId()); + onlinePage.setUpdateUserId(tokenData.getUserId()); + onlinePage.setPublished(false); + MyModelUtil.setDefaultValue(onlinePage, "status", PageStatus.BASIC); + onlinePageMapper.insert(onlinePage); + return onlinePage; + } + + /** + * 更新数据对象。 + * + * @param onlinePage 更新的对象。 + * @param originalOnlinePage 原有数据对象。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(OnlinePage onlinePage, OnlinePage originalOnlinePage) { + TokenData tokenData = TokenData.takeFromRequest(); + onlinePage.setAppCode(tokenData.getAppCode()); + onlinePage.setTenantId(tokenData.getTenantId()); + onlinePage.setUpdateTime(new Date()); + onlinePage.setUpdateUserId(tokenData.getUserId()); + onlinePage.setCreateTime(originalOnlinePage.getCreateTime()); + onlinePage.setCreateUserId(originalOnlinePage.getCreateUserId()); + onlinePage.setPublished(originalOnlinePage.getPublished()); + // 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。 + return onlinePageMapper.update(onlinePage, false) == 1; + } + + /** + * 更新页面对象的发布状态。 + * + * @param pageId 页面对象Id。 + * @param published 新的状态。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void updatePublished(Long pageId, Boolean published) { + OnlinePage onlinePage = new OnlinePage(); + onlinePage.setPageId(pageId); + onlinePage.setPublished(published); + onlinePage.setUpdateTime(new Date()); + onlinePage.setUpdateUserId(TokenData.takeFromRequest().getUserId()); + onlinePageMapper.update(onlinePage); + } + + /** + * 删除指定数据,及其包含的表单和数据源等。 + * + * @param pageId 主键Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long pageId) { + if (onlinePageMapper.deleteById(pageId) == 0) { + return false; + } + // 开始删除关联表单。 + onlineFormService.removeByPageId(pageId); + // 先获取出关联的表单和数据源。 + OnlinePageDatasource pageDatasourceFilter = new OnlinePageDatasource(); + pageDatasourceFilter.setPageId(pageId); + List pageDatasourceList = + onlinePageDatasourceMapper.selectListByQuery(QueryWrapper.create(pageDatasourceFilter)); + if (CollUtil.isNotEmpty(pageDatasourceList)) { + for (OnlinePageDatasource pageDatasource : pageDatasourceList) { + onlineDatasourceService.remove(pageDatasource.getDatasourceId()); + } + } + return true; + } + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlinePageListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlinePageList(OnlinePage filter, String orderBy) { + if (filter == null) { + filter = new OnlinePage(); + } + TokenData tokenData = TokenData.takeFromRequest(); + filter.setTenantId(tokenData.getTenantId()); + filter.setAppCode(tokenData.getAppCode()); + return onlinePageMapper.getOnlinePageList(filter, orderBy); + } + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlinePageList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlinePageListWithRelation(OnlinePage filter, String orderBy) { + List resultList = this.getOnlinePageList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + /** + * 批量添加多对多关联关系。 + * + * @param onlinePageDatasourceList 多对多关联表对象集合。 + * @param pageId 主表Id。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void addOnlinePageDatasourceList(List onlinePageDatasourceList, Long pageId) { + for (OnlinePageDatasource onlinePageDatasource : onlinePageDatasourceList) { + onlinePageDatasource.setPageId(pageId); + onlinePageDatasourceMapper.insert(onlinePageDatasource); + } + } + + /** + * 获取中间表数据。 + * + * @param pageId 主表Id。 + * @param datasourceId 从表Id。 + * @return 中间表对象。 + */ + @Override + public OnlinePageDatasource getOnlinePageDatasource(Long pageId, Long datasourceId) { + OnlinePageDatasource filter = new OnlinePageDatasource(); + filter.setPageId(pageId); + filter.setDatasourceId(datasourceId); + return onlinePageDatasourceMapper.selectOneByQuery(QueryWrapper.create(filter)); + } + + @Override + public List getOnlinePageDatasourceListByPageId(Long pageId) { + return onlinePageDatasourceMapper.selectListByQuery( + new QueryWrapper().eq(OnlinePageDatasource::getPageId, pageId)); + } + + /** + * 根据数据源Id,返回使用该数据源的OnlinePage对象。 + * + * @param datasourceId 数据源Id。 + * @return 使用该数据源的页面列表。 + */ + @Override + public List getOnlinePageListByDatasourceId(Long datasourceId) { + OnlinePage filter = new OnlinePage(); + TokenData tokenData = TokenData.takeFromRequest(); + filter.setTenantId(tokenData.getTenantId()); + filter.setAppCode(tokenData.getAppCode()); + return onlinePageMapper.getOnlinePageListByDatasourceId(datasourceId, filter); + } + + /** + * 移除单条多对多关系。 + * + * @param pageId 主表Id。 + * @param datasourceId 从表Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean removeOnlinePageDatasource(Long pageId, Long datasourceId) { + OnlinePageDatasource filter = new OnlinePageDatasource(); + filter.setPageId(pageId); + filter.setDatasourceId(datasourceId); + return onlinePageDatasourceMapper.deleteByQuery(QueryWrapper.create(filter)) > 0; + } + + @Override + public boolean existByPageCode(String pageCode) { + OnlinePage filter = new OnlinePage(); + filter.setPageCode(pageCode); + return CollUtil.isNotEmpty(this.getOnlinePageList(filter, null)); + } + + @Override + public List getNotInListWithNonTenant(List pageIds, String orderBy) { + QueryWrapper queryWrapper = new QueryWrapper(); + if (CollUtil.isNotEmpty(pageIds)) { + queryWrapper.notIn(OnlinePage::getPageId, pageIds); + } + queryWrapper.isNull(OnlinePage::getTenantId); + if (StrUtil.isNotBlank(orderBy)) { + queryWrapper.orderBy(orderBy); + } + return onlinePageMapper.selectListByQuery(queryWrapper); + } + + @Override + public List getInListWithNonTenant(List pageIds, String orderBy) { + if (CollUtil.isEmpty(pageIds)) { + return new LinkedList<>(); + } + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.in(OnlinePage::getPageId, pageIds); + queryWrapper.isNull(OnlinePage::getTenantId); + if (StrUtil.isNotBlank(orderBy)) { + queryWrapper.orderBy(orderBy); + } + return onlinePageMapper.selectListByQuery(queryWrapper); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineRuleServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineRuleServiceImpl.java new file mode 100644 index 00000000..921e7004 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineRuleServiceImpl.java @@ -0,0 +1,245 @@ +package com.orangeforms.common.online.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.alibaba.fastjson.JSONArray; +import com.mybatisflex.core.query.QueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.constant.GlobalDeletedFlag; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.redis.util.CommonRedisUtil; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.online.dao.OnlineColumnRuleMapper; +import com.orangeforms.common.online.dao.OnlineRuleMapper; +import com.orangeforms.common.online.model.OnlineColumnRule; +import com.orangeforms.common.online.model.OnlineRule; +import com.orangeforms.common.online.service.OnlineRuleService; +import com.github.pagehelper.Page; +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.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 验证规则数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("onlineRuleService") +public class OnlineRuleServiceImpl extends BaseService implements OnlineRuleService { + + @Autowired + private OnlineRuleMapper onlineRuleMapper; + @Autowired + private OnlineColumnRuleMapper onlineColumnRuleMapper; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private CommonRedisUtil commonRedisUtil; + @Autowired + private RedissonClient redissonClient; + + /** + * 所有字段规则使用同一个键。 + */ + private static final String ONLINE_RULE_CACHE_KEY = "ONLINE_RULE"; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return onlineRuleMapper; + } + + /** + * 保存新增对象。 + * + * @param onlineRule 新增对象。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public OnlineRule saveNew(OnlineRule onlineRule) { + commonRedisUtil.evictFormCache(ONLINE_RULE_CACHE_KEY); + TokenData tokenData = TokenData.takeFromRequest(); + onlineRule.setRuleId(idGenerator.nextLongId()); + onlineRule.setAppCode(tokenData.getAppCode()); + Date now = new Date(); + onlineRule.setUpdateTime(now); + onlineRule.setCreateTime(now); + onlineRule.setCreateUserId(tokenData.getUserId()); + onlineRule.setUpdateUserId(tokenData.getUserId()); + onlineRule.setBuiltin(false); + onlineRule.setDeletedFlag(GlobalDeletedFlag.NORMAL); + MyModelUtil.setDefaultValue(onlineRule, "pattern", ""); + onlineRuleMapper.insert(onlineRule); + return onlineRule; + } + + /** + * 更新数据对象。 + * + * @param onlineRule 更新的对象。 + * @param originalOnlineRule 原有数据对象。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(OnlineRule onlineRule, OnlineRule originalOnlineRule) { + commonRedisUtil.evictFormCache(ONLINE_RULE_CACHE_KEY); + TokenData tokenData = TokenData.takeFromRequest(); + onlineRule.setAppCode(tokenData.getAppCode()); + onlineRule.setUpdateTime(new Date()); + onlineRule.setUpdateUserId(tokenData.getUserId()); + onlineRule.setCreateTime(originalOnlineRule.getCreateTime()); + onlineRule.setCreateUserId(originalOnlineRule.getCreateUserId()); + return onlineRuleMapper.update(onlineRule, false) == 1; + } + + /** + * 删除指定数据。 + * + * @param ruleId 主键Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long ruleId) { + commonRedisUtil.evictFormCache(ONLINE_RULE_CACHE_KEY); + if (onlineRuleMapper.deleteById(ruleId) == 0) { + return false; + } + // 开始删除多对多父表的关联 + OnlineColumnRule onlineColumnRule = new OnlineColumnRule(); + onlineColumnRule.setRuleId(ruleId); + onlineColumnRuleMapper.deleteByQuery(QueryWrapper.create(onlineColumnRule)); + return true; + } + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineRuleListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineRuleList(OnlineRule filter, String orderBy) { + if (filter == null) { + filter = new OnlineRule(); + } + filter.setAppCode(TokenData.takeFromRequest().getAppCode()); + return onlineRuleMapper.getOnlineRuleList(filter, orderBy); + } + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineRuleList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineRuleListWithRelation(OnlineRule filter, String orderBy) { + List resultList = this.getOnlineRuleList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + /** + * 在多对多关系中,当前Service的数据表为从表,返回不与指定主表主键Id存在对多对关系的列表。 + * + * @param columnId 主表主键Id。 + * @param filter 从表的过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getNotInOnlineRuleListByColumnId(Long columnId, OnlineRule filter, String orderBy) { + if (filter == null) { + filter = new OnlineRule(); + } + filter.setAppCode(TokenData.takeFromRequest().getAppCode()); + List resultList = + onlineRuleMapper.getNotInOnlineRuleListByColumnId(columnId, filter, orderBy); + this.buildRelationForDataList(resultList, MyRelationParam.dictOnly()); + return resultList; + } + + /** + * 在多对多关系中,当前Service的数据表为从表,返回与指定主表主键Id存在对多对关系的列表。 + * + * @param columnId 主表主键Id。 + * @param filter 从表的过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineRuleListByColumnId(Long columnId, OnlineRule filter, String orderBy) { + List resultList = + onlineRuleMapper.getOnlineRuleListByColumnId(columnId, filter, orderBy); + this.buildRelationForDataList(resultList, MyRelationParam.dictOnly()); + return resultList; + } + + /** + * 返回指定字段Id列表关联的字段规则对象列表。 + * + * @param columnIdSet 指定的字段Id列表。 + * @return 关联的字段规则对象列表。 + */ + @Override + public List getOnlineColumnRuleListByColumnIds(Set columnIdSet) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.in(OnlineColumnRule::getColumnId, columnIdSet); + List columnRuleList = onlineColumnRuleMapper.selectListByQuery(queryWrapper); + if (CollUtil.isEmpty(columnRuleList)) { + return columnRuleList; + } + List ruleList; + RBucket bucket = redissonClient.getBucket(ONLINE_RULE_CACHE_KEY); + if (bucket.isExists()) { + ruleList = JSONArray.parseArray(bucket.get(), OnlineRule.class); + } else { + ruleList = this.getAllList(); + if (CollUtil.isNotEmpty(ruleList)) { + bucket.set(JSONArray.toJSONString(ruleList)); + } + } + if (CollUtil.isEmpty(ruleList)) { + return columnRuleList; + } + Map ruleMap = ruleList.stream().collect(Collectors.toMap(OnlineRule::getRuleId, c -> c)); + for (OnlineColumnRule columnRule : columnRuleList) { + columnRule.setOnlineRule(ruleMap.get(columnRule.getRuleId())); + } + return columnRuleList; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineTableServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineTableServiceImpl.java new file mode 100644 index 00000000..06ee87b0 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineTableServiceImpl.java @@ -0,0 +1,194 @@ +package com.orangeforms.common.online.service.impl; + +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSON; +import com.mybatisflex.core.query.QueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.dbutil.object.SqlTable; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.online.dao.OnlineTableMapper; +import com.orangeforms.common.online.model.OnlineColumn; +import com.orangeforms.common.online.model.OnlineTable; +import com.orangeforms.common.online.model.constant.FieldKind; +import com.orangeforms.common.online.service.OnlineColumnService; +import com.orangeforms.common.online.service.OnlineTableService; +import com.orangeforms.common.online.util.OnlineRedisKeyUtil; +import com.google.common.base.CaseFormat; +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.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +/** + * 数据表数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("onlineTableService") +public class OnlineTableServiceImpl extends BaseService implements OnlineTableService { + + @Autowired + private OnlineTableMapper onlineTableMapper; + @Autowired + private OnlineColumnService onlineColumnService; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private RedissonClient redissonClient; + + /** + * 在线对象表的缺省缓存时间(小时)。 + */ + private static final int DEFAULT_CACHED_TABLE_HOURS = 168; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return onlineTableMapper; + } + + /** + * 基于数据库表保存新增对象。 + * + * @param sqlTable 数据库表对象。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public OnlineTable saveNewFromSqlTable(SqlTable sqlTable) { + OnlineTable onlineTable = new OnlineTable(); + TokenData tokenData = TokenData.takeFromRequest(); + onlineTable.setAppCode(tokenData.getAppCode()); + onlineTable.setDblinkId(sqlTable.getDblinkId()); + onlineTable.setTableId(idGenerator.nextLongId()); + onlineTable.setTableName(sqlTable.getTableName()); + String modelName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, sqlTable.getTableName()); + onlineTable.setModelName(modelName); + Date now = new Date(); + onlineTable.setUpdateTime(now); + onlineTable.setCreateTime(now); + onlineTable.setCreateUserId(tokenData.getUserId()); + onlineTable.setUpdateUserId(tokenData.getUserId()); + onlineTableMapper.insert(onlineTable); + List columnList = onlineColumnService.saveNewList(sqlTable.getColumnList(), onlineTable.getTableId()); + onlineTable.setColumnList(columnList); + return onlineTable; + } + + /** + * 删除指定表及其关联的字段数据。 + * + * @param tableId 主键Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long tableId) { + if (onlineTableMapper.deleteById(tableId) == 0) { + return false; + } + this.evictTableCache(tableId); + onlineColumnService.removeByTableId(tableId); + return true; + } + + /** + * 删除指定数据表Id集合中的表,及其关联字段。 + * + * @param tableIdSet 待删除的数据表Id集合。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void removeByTableIdSet(Set tableIdSet) { + tableIdSet.forEach(this::evictTableCache); + onlineTableMapper.deleteByQuery(new QueryWrapper().in(OnlineTable::getTableId, tableIdSet)); + onlineColumnService.removeByTableIdSet(tableIdSet); + } + + /** + * 根据数据源Id,获取该数据源及其关联所引用的数据表列表。 + * + * @param datasourceId 指定的数据源Id。 + * @return 该数据源及其关联所引用的数据表列表。 + */ + @Override + public List getOnlineTableListByDatasourceId(Long datasourceId) { + return onlineTableMapper.getOnlineTableListByDatasourceId(datasourceId); + } + + /** + * 从缓存中获取指定的表数据及其关联字段列表。优先从缓存中读取,如果不存在则从数据库中读取,并同步到缓存。 + * 该接口方法仅仅用户在线表单的动态数据操作接口,而非在线表单的配置接口。 + * + * @param tableId 表主键Id。 + * @return 查询后的在线表对象。 + */ + @Override + public OnlineTable getOnlineTableFromCache(Long tableId) { + String redisKey = OnlineRedisKeyUtil.makeOnlineTableKey(tableId); + RBucket tableBucket = redissonClient.getBucket(redisKey); + if (tableBucket.isExists()) { + String tableInfo = tableBucket.get(); + return JSON.parseObject(tableInfo, OnlineTable.class); + } + OnlineTable table = this.getByIdWithRelation(tableId, MyRelationParam.full()); + if (table == null) { + return null; + } + for (OnlineColumn column : table.getColumnList()) { + if (BooleanUtil.isTrue(column.getPrimaryKey())) { + table.setPrimaryKeyColumn(column); + continue; + } + if (ObjectUtil.equal(column.getFieldKind(), FieldKind.LOGIC_DELETE)) { + table.setLogicDeleteColumn(column); + } + } + Map columnMap = + table.getColumnList().stream().collect(Collectors.toMap(OnlineColumn::getColumnId, c -> c)); + table.setColumnMap(columnMap); + table.setColumnList(null); + tableBucket.set(JSON.toJSONString(table)); + tableBucket.expire(DEFAULT_CACHED_TABLE_HOURS, TimeUnit.HOURS); + return table; + } + + @Override + public OnlineColumn getOnlineColumnFromCache(Long tableId, Long columnId) { + OnlineTable table = this.getOnlineTableFromCache(tableId); + if (table == null) { + return null; + } + return table.getColumnMap().get(columnId); + } + + private void evictTableCache(Long tableId) { + String tableIdKey = OnlineRedisKeyUtil.makeOnlineTableKey(tableId); + redissonClient.getBucket(tableIdKey).delete(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineVirtualColumnServiceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineVirtualColumnServiceImpl.java new file mode 100644 index 00000000..c133ccee --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineVirtualColumnServiceImpl.java @@ -0,0 +1,176 @@ +package com.orangeforms.common.online.service.impl; + +import com.mybatisflex.core.query.QueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.online.dao.OnlineVirtualColumnMapper; +import com.orangeforms.common.online.model.OnlineDatasource; +import com.orangeforms.common.online.model.OnlineVirtualColumn; +import com.orangeforms.common.online.model.constant.VirtualType; +import com.orangeforms.common.online.service.OnlineColumnService; +import com.orangeforms.common.online.service.OnlineDatasourceRelationService; +import com.orangeforms.common.online.service.OnlineDatasourceService; +import com.orangeforms.common.online.service.OnlineVirtualColumnService; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.github.pagehelper.Page; +import lombok.extern.slf4j.Slf4j; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; + +/** + * 虚拟字段数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("onlineVirtualColumnService") +public class OnlineVirtualColumnServiceImpl + extends BaseService implements OnlineVirtualColumnService { + + @Autowired + private OnlineVirtualColumnMapper onlineVirtualColumnMapper; + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private OnlineDatasourceRelationService onlineDatasourceRelationService; + @Autowired + private OnlineColumnService onlineColumnService; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return onlineVirtualColumnMapper; + } + + /** + * 保存新增对象。 + * + * @param virtualColumn 新增对象。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public OnlineVirtualColumn saveNew(OnlineVirtualColumn virtualColumn) { + virtualColumn.setVirtualColumnId(idGenerator.nextLongId()); + if (virtualColumn.getVirtualType().equals(VirtualType.AGGREGATION)) { + OnlineDatasource datasource = onlineDatasourceService.getById(virtualColumn.getDatasourceId()); + virtualColumn.setTableId(datasource.getMasterTableId()); + } + onlineVirtualColumnMapper.insert(virtualColumn); + return virtualColumn; + } + + /** + * 更新数据对象。 + * + * @param virtualColumn 更新的对象。 + * @param originalVirtualColumn 原有数据对象。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(OnlineVirtualColumn virtualColumn, OnlineVirtualColumn originalVirtualColumn) { + if (virtualColumn.getVirtualType().equals(VirtualType.AGGREGATION) + && !virtualColumn.getDatasourceId().equals(originalVirtualColumn.getDatasourceId())) { + OnlineDatasource datasource = onlineDatasourceService.getById(virtualColumn.getDatasourceId()); + virtualColumn.setTableId(datasource.getMasterTableId()); + } + return onlineVirtualColumnMapper.update(virtualColumn, false) == 1; + } + + /** + * 删除指定数据。 + * + * @param virtualColumnId 主键Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long virtualColumnId) { + return onlineVirtualColumnMapper.deleteById(virtualColumnId) == 1; + } + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineVirtualColumnListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineVirtualColumnList(OnlineVirtualColumn filter, String orderBy) { + return onlineVirtualColumnMapper.getOnlineVirtualColumnList(filter, orderBy); + } + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineVirtualColumnList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineVirtualColumnListWithRelation(OnlineVirtualColumn filter, String orderBy) { + List resultList = onlineVirtualColumnMapper.getOnlineVirtualColumnList(filter, orderBy); + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + /** + * 根据数据表的集合,查询关联的虚拟字段数据列表。 + * @param tableIdSet 在线数据表Id集合。 + * @return 关联的虚拟字段数据列表。 + */ + @Override + public List getOnlineVirtualColumnListByTableIds(Set tableIdSet) { + return onlineVirtualColumnMapper.selectListByQuery( + new QueryWrapper().in(OnlineVirtualColumn::getTableId, tableIdSet)); + } + + /** + * 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。 + * + * @param virtualColumn 最新数据对象。 + * @param originalVirtualColumn 原有数据对象。 + * @return 数据全部正确返回true,否则false。 + */ + @Override + public CallResult verifyRelatedData(OnlineVirtualColumn virtualColumn, OnlineVirtualColumn originalVirtualColumn) { + String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!"; + if (this.needToVerify(virtualColumn, originalVirtualColumn, OnlineVirtualColumn::getDatasourceId) + && !onlineDatasourceService.existId(virtualColumn.getDatasourceId())) { + return CallResult.error(String.format(errorMessageFormat, "数据源Id")); + } + if (this.needToVerify(virtualColumn, originalVirtualColumn, OnlineVirtualColumn::getRelationId) + && !onlineDatasourceRelationService.existId(virtualColumn.getRelationId())) { + return CallResult.error(String.format(errorMessageFormat, "数据源关联Id")); + } + if (this.needToVerify(virtualColumn, originalVirtualColumn, OnlineVirtualColumn::getAggregationColumnId) + && !onlineColumnService.existId(virtualColumn.getAggregationColumnId())) { + return CallResult.error(String.format(errorMessageFormat, "聚合字段Id")); + } + return CallResult.ok(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineConstant.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineConstant.java new file mode 100644 index 00000000..f40866dc --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineConstant.java @@ -0,0 +1,21 @@ +package com.orangeforms.common.online.util; + +/** + * 在线表单使用的常量数据。。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class OnlineConstant { + + /** + * 数据源关联变量名和从表字段名之间的连接字符串。 + */ + public static final String RELATION_TABLE_COLUMN_SEPARATOR = "__"; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private OnlineConstant() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineCustomExtFactory.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineCustomExtFactory.java new file mode 100644 index 00000000..a46868b3 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineCustomExtFactory.java @@ -0,0 +1,33 @@ +package com.orangeforms.common.online.util; + +import org.springframework.stereotype.Component; + +/** + * 在线表单自定义扩展工厂类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class OnlineCustomExtFactory { + + private OnlineCustomMaskFieldHandler customMaskFieldHandler = new OnlineCustomMaskFieldHandler(); + + /** + * 设置自定义脱敏规则处理器对象。推荐设置的对象为Bean对象,并在服务启动过程中完成自动注册,运行时直接使用即可。 + * + * @param customMaskFieldHandler 自定义脱敏规则处理器对象。 + */ + public void setCustomMaskFieldHandler(OnlineCustomMaskFieldHandler customMaskFieldHandler) { + this.customMaskFieldHandler = customMaskFieldHandler; + } + + /** + * 返回在线表单的自定义脱敏规则处理器对象。该Bean对象需要在业务代码中实现自行实现。 + * + * @return 在线表单的自定义脱敏规则处理器对象。 + */ + public OnlineCustomMaskFieldHandler getCustomMaskFieldHandler() { + return customMaskFieldHandler; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineCustomMaskFieldHandler.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineCustomMaskFieldHandler.java new file mode 100644 index 00000000..e99b0e58 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineCustomMaskFieldHandler.java @@ -0,0 +1,25 @@ +package com.orangeforms.common.online.util; + +/** + * 在线表单自定义脱敏处理器的默认实现类。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class OnlineCustomMaskFieldHandler { + + /** + * 处理自定义的脱敏数据。可以根据表名和字段名,使用不同的自定义脱敏规则。 + * + * @param appCode 应用编码。如果不是第三方接入的应用,该值可能为null。 + * @param tableName 在线表单对应的表名。 + * @param columnName 在线表单对应的表字段名 + * @param data 待脱敏的数据。 + * @param maskChar 脱敏掩码字符。 + * @return 脱敏后的数据。 + */ + public String handleMask(String appCode, String tableName, String columnName, String data, char maskChar) { + throw new UnsupportedOperationException( + "在运行时抛出该异常,主要为了及时提醒用户提供自己的处理器实现类。请在业务工程中提供该类的具体实现类!"); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineDataSourceUtil.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineDataSourceUtil.java new file mode 100644 index 00000000..a4b765a9 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineDataSourceUtil.java @@ -0,0 +1,47 @@ +package com.orangeforms.common.online.util; + +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.dbutil.provider.DataSourceProvider; +import com.orangeforms.common.dbutil.util.DataSourceUtil; +import com.orangeforms.common.online.model.OnlineDblink; +import com.orangeforms.common.online.service.OnlineDblinkService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 在线表单模块动态加载的数据源工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Component +public class OnlineDataSourceUtil extends DataSourceUtil { + + @Autowired + private OnlineDblinkService dblinkService; + + @Override + protected int getDblinkTypeByDblinkId(Long dblinkId) { + DataSourceProvider provider = this.dblinkProviderMap.get(dblinkId); + if (provider != null) { + return provider.getDblinkType(); + } + OnlineDblink dblink = dblinkService.getById(dblinkId); + if (dblink == null) { + throw new MyRuntimeException("Online DblinkId [" + dblinkId + "] doesn't exist!"); + } + this.dblinkProviderMap.put(dblinkId, this.getProvider(dblink.getDblinkType())); + return dblink.getDblinkType(); + } + + @Override + protected String getDblinkConfigurationByDblinkId(Long dblinkId) { + OnlineDblink dblink = dblinkService.getById(dblinkId); + if (dblink == null) { + throw new MyRuntimeException("Online DblinkId [" + dblinkId + "] doesn't exist!"); + } + return dblink.getConfiguration(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineOperationHelper.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineOperationHelper.java new file mode 100644 index 00000000..4fe6a307 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineOperationHelper.java @@ -0,0 +1,419 @@ +package com.orangeforms.common.online.util; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.constant.ObjectFieldType; +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.upload.BaseUpDownloader; +import com.orangeforms.common.core.upload.UpDownloaderFactory; +import com.orangeforms.common.core.upload.UploadResponseInfo; +import com.orangeforms.common.core.upload.UploadStoreTypeEnum; +import com.orangeforms.common.online.config.OnlineProperties; +import com.orangeforms.common.online.model.OnlineColumn; +import com.orangeforms.common.online.model.OnlineDatasource; +import com.orangeforms.common.online.model.OnlineDatasourceRelation; +import com.orangeforms.common.online.model.OnlineTable; +import com.orangeforms.common.online.model.constant.FieldKind; +import com.orangeforms.common.online.model.constant.RelationType; +import com.orangeforms.common.online.object.ColumnData; +import com.orangeforms.common.online.service.OnlineDatasourceRelationService; +import com.orangeforms.common.online.service.OnlineDatasourceService; +import com.orangeforms.common.online.service.OnlineOperationService; +import com.orangeforms.common.online.service.OnlineTableService; +import com.orangeforms.common.redis.cache.SessionCacheHelper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; + +import jakarta.servlet.http.HttpServletResponse; +import java.io.Serializable; +import java.io.IOException; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 在线表单操作的通用帮助对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Component +public class OnlineOperationHelper { + + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private OnlineDatasourceRelationService onlineDatasourceRelationService; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private OnlineOperationService onlineOperationService; + @Autowired + private OnlineProperties onlineProperties; + @Autowired + private UpDownloaderFactory upDownloaderFactory; + @Autowired + private SessionCacheHelper cacheHelper; + + /** + * 验证并获取数据源数据。 + * + * @param datasourceId 数据源Id。 + * @return 数据源详情数据。 + */ + public ResponseResult verifyAndGetDatasource(Long datasourceId) { + String errorMessage; + OnlineDatasource datasource = onlineDatasourceService.getOnlineDatasourceFromCache(datasourceId); + if (datasource == null) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + if (!StrUtil.equals(datasource.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + errorMessage = "数据验证失败,当前应用不包含该数据源Id"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineTable masterTable = onlineTableService.getOnlineTableFromCache(datasource.getMasterTableId()); + if (masterTable == null) { + errorMessage = "数据验证失败,数据源主表Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + datasource.setMasterTable(masterTable); + return ResponseResult.success(datasource); + } + + /** + * 验证并获取数据源的关联数据。 + * + * @param datasourceId 数据源Id。 + * @param relationId 数据源关联Id。 + * @return 数据源的关联详情数据。 + */ + public ResponseResult verifyAndGetRelation(Long datasourceId, Long relationId) { + String errorMessage; + OnlineDatasourceRelation relation = + onlineDatasourceRelationService.getOnlineDatasourceRelationFromCache(datasourceId, relationId); + if (relation == null || !relation.getDatasourceId().equals(datasourceId)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + if (!StrUtil.equals(relation.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + errorMessage = "数据验证失败,当前应用不包含该数据源关联Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineTable slaveTable = onlineTableService.getOnlineTableFromCache(relation.getSlaveTableId()); + if (slaveTable == null) { + errorMessage = "数据验证失败,数据源关联 [" + relation.getRelationName() + " ] 引用的从表不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + relation.setSlaveTable(slaveTable); + relation.setSlaveColumn(slaveTable.getColumnMap().get(relation.getSlaveColumnId())); + return ResponseResult.success(relation); + } + + /** + * 验证并获取数据源的指定类型关联数据。 + * + * @param datasourceId 数据源Id。 + * @param relationType 数据源关联类型。 + * @return 数据源指定关联类型的关联数据详情列表。 + */ + public ResponseResult> verifyAndGetRelationList( + Long datasourceId, Integer relationType) { + String errorMessage; + List relationList = onlineDatasourceRelationService + .getOnlineDatasourceRelationListFromCache(CollUtil.newHashSet(datasourceId)); + if (relationType != null) { + relationList = relationList.stream() + .filter(r -> r.getRelationType().equals(relationType)).collect(Collectors.toList()); + } + for (OnlineDatasourceRelation relation : relationList) { + OnlineTable slaveTable = onlineTableService.getOnlineTableFromCache(relation.getSlaveTableId()); + if (slaveTable == null) { + errorMessage = "数据验证失败,数据源关联 [" + relation.getRelationName() + "] 的从表Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + relation.setSlaveTable(slaveTable); + } + return ResponseResult.success(relationList); + } + + /** + * 构建在线表的数据记录。 + * + * @param table 在线数据表对象。 + * @param tableData 在线数据表数据。 + * @param forUpdate 是否为更新。 + * @param ignoreSetColumnId 忽略设置的字段Id。 + * @return 在线表的数据记录。 + */ + public ResponseResult> buildTableData( + OnlineTable table, JSONObject tableData, boolean forUpdate, Long ignoreSetColumnId) { + List columnDataList = new LinkedList<>(); + String errorMessage; + for (OnlineColumn column : table.getColumnMap().values()) { + // 判断一下是否为需要自动填入的字段,如果是,这里就都暂时给空值了,后续操作会自动填补。 + // 这里还能避免一次基于tableData的查询,能快几纳秒也是好的。 + if (this.isAutoSettingField(column) || ObjectUtil.equal(column.getColumnId(), ignoreSetColumnId)) { + columnDataList.add(new ColumnData(column, null)); + continue; + } + Object value = this.getColumnValue(tableData, column); + // 对于主键数据的处理。 + if (BooleanUtil.isTrue(column.getPrimaryKey())) { + // 如果是更新则必须包含主键参数。 + if (forUpdate && value == null) { + errorMessage = "数据验证失败,数据表 [" + + table.getTableName() + "] 主键字段 [" + column.getColumnName() + "] 不能为空值!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } else { + if (value == null && !column.getNullable() && StrUtil.isBlank(column.getEncodedRule())) { + errorMessage = "数据验证失败,数据表 [" + + table.getTableName() + "] 字段 [" + column.getColumnName() + "] 不能为空值!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + columnDataList.add(new ColumnData(column, value)); + } + return ResponseResult.success(columnDataList); + } + + /** + * 构建多个一对多从表的数据列表。 + * + * @param datasourceId 数据源Id。 + * @param slaveData 多个一对多从表数据的JSON对象。 + * @return 构建后的多个一对多从表数据列表。 + */ + public ResponseResult>> buildSlaveDataList( + Long datasourceId, JSONObject slaveData) { + if (slaveData == null) { + return ResponseResult.success(null); + } + Map> relationDataMap = new HashMap<>(slaveData.size()); + for (String key : slaveData.keySet()) { + Long relationId = Long.parseLong(key); + ResponseResult relationResult = this.verifyAndGetRelation(datasourceId, relationId); + if (!relationResult.isSuccess()) { + return ResponseResult.errorFrom(relationResult); + } + OnlineDatasourceRelation relation = relationResult.getData(); + List relationDataList = new LinkedList<>(); + relationDataMap.put(relation, relationDataList); + if (relation.getRelationType().equals(RelationType.ONE_TO_MANY)) { + JSONArray slaveObjectArray = slaveData.getJSONArray(key); + for (int i = 0; i < slaveObjectArray.size(); i++) { + relationDataList.add(slaveObjectArray.getJSONObject(i)); + } + } else if (relation.getRelationType().equals(RelationType.ONE_TO_ONE)) { + JSONObject o = slaveData.getJSONObject(key); + if (MapUtil.isNotEmpty(o)) { + relationDataList.add(o); + } + } + } + return ResponseResult.success(relationDataMap); + } + + /** + * 将字符型字段值转换为与参数字段类型匹配的字段值。 + * + * @param column 在线表单字段。 + * @param dataId 字符型字段值。 + * @return 转换后与参数字段类型匹配的字段值。 + */ + public Serializable convertToTypeValue(OnlineColumn column, String dataId) { + if (dataId == null) { + return null; + } + if (column == null) { + return dataId; + } + if ("Long".equals(column.getObjectFieldType())) { + return Long.valueOf(dataId); + } else if ("Integer".equals(column.getObjectFieldType())) { + return Integer.valueOf(dataId); + } + return dataId; + } + + /** + * 将字符型字段值集合转换为与参数字段类型匹配的字段值集合。 + * + * @param column 在线表单字段。 + * @param dataIdSet 字符型字段值集合。 + * @return 转换后与参数字段类型匹配的字段值集合。 + */ + public Set convertToTypeValue(OnlineColumn column, Set dataIdSet) { + Set resultSet = new HashSet<>(); + if (dataIdSet == null) { + return resultSet; + } + if ("Long".equals(column.getObjectFieldType())) { + return dataIdSet.stream().map(Long::valueOf).collect(Collectors.toSet()); + } else if ("Integer".equals(column.getObjectFieldType())) { + return dataIdSet.stream().map(Integer::valueOf).collect(Collectors.toSet()); + } else { + resultSet.addAll(dataIdSet); + } + return resultSet; + } + + /** + * 下载数据。 + * + * @param table 在线表对象。 + * @param dataId 在线表数据主键Id。 + * @param fieldName 数据表字段名。 + * @param filename 下载文件名。 + * @param asImage 是否为图片。 + * @param response HTTP 应对对象。 + */ + public void doDownload( + OnlineTable table, String dataId, String fieldName, String filename, Boolean asImage, HttpServletResponse response) { + // 使用try来捕获异常,是为了保证一旦出现异常可以返回500的错误状态,便于调试。 + // 否则有可能给前端返回的是200的错误码。 + try { + // 如果请求参数中没有包含主键Id,就判断该文件是否为当前session上传的。 + if (ObjectUtil.isEmpty(dataId)) { + if (!cacheHelper.existSessionUploadFile(filename)) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN); + return; + } + } else { + Map dataMap = + onlineOperationService.getMasterData(table, null, null, dataId); + if (dataMap == null) { + ResponseResult.output(HttpServletResponse.SC_NOT_FOUND); + return; + } + String fieldJsonData = (String) dataMap.get(fieldName); + if (!this.canDownload(fieldJsonData, filename)) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN); + return; + } + } + ResponseResult verifyResult = this.doVerifyUpDownloadFileColumn(table, fieldName, asImage); + if (!verifyResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, verifyResult); + return; + } + OnlineColumn downloadColumn = verifyResult.getData(); + if (downloadColumn.getUploadFileSystemType() == null) { + downloadColumn.setUploadFileSystemType(UploadStoreTypeEnum.LOCAL_SYSTEM.ordinal()); + } + if (!downloadColumn.getUploadFileSystemType().equals(UploadStoreTypeEnum.LOCAL_SYSTEM.ordinal())) { + downloadColumn.setUploadFileSystemType(onlineProperties.getDistributeStoreType()); + } + UploadStoreTypeEnum uploadStoreType = + UploadStoreTypeEnum.values()[downloadColumn.getUploadFileSystemType()]; + BaseUpDownloader upDownloader = upDownloaderFactory.get(uploadStoreType); + upDownloader.doDownload(onlineProperties.getUploadFileBaseDir(), + table.getModelName(), fieldName, filename, asImage, response); + } catch (Exception e) { + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + log.error(e.getMessage(), e); + } + } + + /** + * 上传数据。 + * + * @param table 在线表对象。 + * @param fieldName 数据表字段名。 + * @param asImage 是否为图片。 + * @param uploadFile 上传的文件。 + */ + public void doUpload(OnlineTable table, String fieldName, Boolean asImage, MultipartFile uploadFile) + throws IOException { + ResponseResult verifyResult = this.doVerifyUpDownloadFileColumn(table, fieldName, asImage); + if (!verifyResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, verifyResult); + return; + } + OnlineColumn uploadColumn = verifyResult.getData(); + if (uploadColumn.getUploadFileSystemType() == null) { + uploadColumn.setUploadFileSystemType(UploadStoreTypeEnum.LOCAL_SYSTEM.ordinal()); + } + if (!uploadColumn.getUploadFileSystemType().equals(UploadStoreTypeEnum.LOCAL_SYSTEM.ordinal())) { + uploadColumn.setUploadFileSystemType(onlineProperties.getDistributeStoreType()); + } + UploadStoreTypeEnum uploadStoreType = UploadStoreTypeEnum.values()[uploadColumn.getUploadFileSystemType()]; + BaseUpDownloader upDownloader = upDownloaderFactory.get(uploadStoreType); + UploadResponseInfo responseInfo = upDownloader.doUpload(null, + onlineProperties.getUploadFileBaseDir(), table.getModelName(), fieldName, asImage, uploadFile); + if (BooleanUtil.isTrue(responseInfo.getUploadFailed())) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, + ResponseResult.error(ErrorCodeEnum.UPLOAD_FAILED, responseInfo.getErrorMessage())); + return; + } + // 动态表单的下载url和普通表单有所不同,由前端负责动态拼接。 + responseInfo.setDownloadUri(null); + cacheHelper.putSessionUploadFile(responseInfo.getFilename()); + ResponseResult.output(ResponseResult.success(responseInfo)); + } + + private ResponseResult doVerifyUpDownloadFileColumn( + OnlineTable table, String fieldName, Boolean asImage) { + OnlineColumn column = this.getOnlineColumnByName(table, fieldName); + if (column == null) { + return ResponseResult.error(ErrorCodeEnum.INVALID_DATA_FIELD); + } + if (BooleanUtil.isTrue(asImage)) { + if (ObjectUtil.notEqual(column.getFieldKind(), FieldKind.UPLOAD_IMAGE)) { + return ResponseResult.error(ErrorCodeEnum.INVALID_UPLOAD_FIELD); + } + } else { + if (ObjectUtil.notEqual(column.getFieldKind(), FieldKind.UPLOAD)) { + return ResponseResult.error(ErrorCodeEnum.INVALID_UPLOAD_FIELD); + } + } + return ResponseResult.success(column); + } + + private OnlineColumn getOnlineColumnByName(OnlineTable table, String fieldName) { + for (OnlineColumn column : table.getColumnMap().values()) { + if (column.getColumnName().equals(fieldName)) { + return column; + } + } + return null; + } + + private Object getColumnValue(JSONObject tableData, OnlineColumn column) { + Object value = tableData.get(column.getColumnName()); + if (value != null) { + if (ObjectFieldType.LONG.equals(column.getObjectFieldType())) { + value = Long.valueOf(value.toString()); + } else if (ObjectFieldType.DATE.equals(column.getObjectFieldType())) { + value = Convert.toLocalDateTime(value); + } + } + return value; + } + + private boolean isAutoSettingField(OnlineColumn column) { + return ObjectUtil.equal(column.getFieldKind(), FieldKind.CREATE_TIME) + || ObjectUtil.equal(column.getFieldKind(), FieldKind.CREATE_USER_ID) + || ObjectUtil.equal(column.getFieldKind(), FieldKind.UPDATE_TIME) + || ObjectUtil.equal(column.getFieldKind(), FieldKind.UPDATE_USER_ID) + || ObjectUtil.equal(column.getFieldKind(), FieldKind.CREATE_DEPT_ID) + || ObjectUtil.equal(column.getFieldKind(), FieldKind.LOGIC_DELETE); + } + + private boolean canDownload(String fieldJsonData, String filename) { + if (fieldJsonData == null && !cacheHelper.existSessionUploadFile(filename)) { + return false; + } + return BaseUpDownloader.containFile(fieldJsonData, filename) + || cacheHelper.existSessionUploadFile(filename); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineRedisKeyUtil.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineRedisKeyUtil.java new file mode 100644 index 00000000..431ae946 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineRedisKeyUtil.java @@ -0,0 +1,76 @@ +package com.orangeforms.common.online.util; + +/** + * 在线表单 Redis 键生成工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class OnlineRedisKeyUtil { + + /** + * 计算在线表对象缓存在Redis中的键值。 + * + * @param tableId 在线表主键Id。 + * @return 在线表对象缓存在Redis中的键值。 + */ + public static String makeOnlineTableKey(Long tableId) { + return "ONLINE_TABLE:" + tableId; + } + + /** + * 计算在线表单对象缓存在Redis中的键值。 + * + * @param formId 在线表单对象主键Id。 + * @return 在线表单对象缓存在Redis中的键值。 + */ + public static String makeOnlineFormKey(Long formId) { + return "ONLINE_FORM:" + formId; + } + + /** + * 计算在线表单关联数据源对象列表缓存在Redis中的键值。 + * + * @param formId 在线表单对象主键Id。 + * @return 在线表单关联数据源对象列表缓存在Redis中的键值。 + */ + public static String makeOnlineFormDatasourceKey(Long formId) { + return "ONLINE_FORM_DATASOURCE_LIST:" + formId; + } + + /** + * 计算在线数据源对象缓存在Redis中的键值。 + * + * @param datasourceId 在线数据源主键Id。 + * @return 在线数据源对象缓存在Redis中的键值。 + */ + public static String makeOnlineDataSourceKey(Long datasourceId) { + return "ONLINE_DATASOURCE:" + datasourceId; + } + + /** + * 计算在线数据源关联列表对象缓存在Redis中的键值。 + * + * @param datasourceId 在线数据源主键Id。 + * @return 在线数据源关联列表对象缓存在Redis中的键值。 + */ + public static String makeOnlineDataSourceRelationKey(Long datasourceId) { + return "ONLINE_DATASOURCE_RELATION:" + datasourceId; + } + + /** + * 计算在线字典对象缓存在Redis中的键值。 + * + * @param dictId 在线字典主键Id。 + * @return 在线字典对象缓存在Redis中的键值。 + */ + public static String makeOnlineDictKey(Long dictId) { + return "ONLINE_DICT:" + dictId; + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private OnlineRedisKeyUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineUtil.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineUtil.java new file mode 100644 index 00000000..712fe312 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineUtil.java @@ -0,0 +1,36 @@ +package com.orangeforms.common.online.util; + +/** + * 在线表单的工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class OnlineUtil { + + /** + * 根据输入参数,拼接在线表单操作的查看权限字。 + * + * @param datasourceVariableName 数据源变量名。 + * @return 拼接后的在线表单操作的查看权限字。 + */ + public static String makeViewPermCode(String datasourceVariableName) { + return "online:" + datasourceVariableName + ":view"; + } + + /** + * 根据输入参数,拼接在线表单操作的编辑权限字。 + * + * @param datasourceVariableName 数据源变量名。 + * @return 拼接后的在线表单操作的编辑权限字。 + */ + public static String makeEditPermCode(String datasourceVariableName) { + return "online:" + datasourceVariableName + ":edit"; + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private OnlineUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineColumnRuleVo.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineColumnRuleVo.java new file mode 100644 index 00000000..677eb67a --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineColumnRuleVo.java @@ -0,0 +1,33 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 在线表单数据表字段规则和字段多对多关联VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单数据表字段规则和字段多对多关联VO对象") +@Data +public class OnlineColumnRuleVo { + + /** + * 字段Id。 + */ + @Schema(description = "字段Id") + private Long columnId; + + /** + * 规则Id。 + */ + @Schema(description = "规则Id") + private Long ruleId; + + /** + * 规则属性数据。 + */ + @Schema(description = "规则属性数据") + private String propDataJson; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineColumnVo.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineColumnVo.java new file mode 100644 index 00000000..3438eed4 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineColumnVo.java @@ -0,0 +1,204 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单数据表字段规则和字段多对多关联VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单数据表字段规则和字段多对多关联VO对象") +@Data +public class OnlineColumnVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long columnId; + + /** + * 字段名。 + */ + @Schema(description = "字段名") + private String columnName; + + /** + * 数据表Id。 + */ + @Schema(description = "数据表Id") + private Long tableId; + + /** + * 数据表中的字段类型。 + */ + @Schema(description = "数据表中的字段类型") + private String columnType; + + /** + * 数据表中的完整字段类型(包括了精度和刻度)。 + */ + @Schema(description = "数据表中的完整字段类型") + private String fullColumnType; + + /** + * 是否为主键。 + */ + @Schema(description = "是否为主键") + private Boolean primaryKey; + + /** + * 是否是自增主键(0: 不是 1: 是)。 + */ + @Schema(description = "是否是自增主键") + private Boolean autoIncrement; + + /** + * 是否可以为空 (0: 不可以为空 1: 可以为空)。 + */ + @Schema(description = "是否可以为空") + private Boolean nullable; + + /** + * 缺省值。 + */ + @Schema(description = "缺省值") + private String columnDefault; + + /** + * 字段在数据表中的显示位置。 + */ + @Schema(description = "字段在数据表中的显示位置") + private Integer columnShowOrder; + + /** + * 数据表中的字段注释。 + */ + @Schema(description = "数据表中的字段注释") + private String columnComment; + + /** + * 对象映射字段名称。 + */ + @Schema(description = "对象映射字段名称") + private String objectFieldName; + + /** + * 对象映射字段类型。 + */ + @Schema(description = "对象映射字段类型") + private String objectFieldType; + + /** + * 数值型字段的精度(目前仅Oracle使用)。 + */ + @Schema(description = "数值型字段的精度") + private Integer numericPrecision; + + /** + * 数值型字段的刻度(小数点后位数,目前仅Oracle使用)。 + */ + @Schema(description = "数值型字段的刻度") + private Integer numericScale; + + /** + * 过滤类型。 + */ + @Schema(description = "过滤类型") + private Integer filterType; + + /** + * 是否是主键的父Id。 + */ + @Schema(description = "是否是主键的父Id") + private Boolean parentKey; + + /** + * 是否部门过滤字段。 + */ + @Schema(description = "是否部门过滤字段") + private Boolean deptFilter; + + /** + * 是否用户过滤字段。 + */ + @Schema(description = "是否用户过滤字段") + private Boolean userFilter; + + /** + * 字段类别。 + */ + @Schema(description = "字段类别") + private Integer fieldKind; + + /** + * 包含的文件文件数量,0表示无限制。 + */ + @Schema(description = "包含的文件文件数量,0表示无限制") + private Integer maxFileCount; + + /** + * 上传文件系统类型。 + */ + @Schema(description = "上传文件系统类型") + private Integer uploadFileSystemType; + + /** + * 编码规则的JSON格式数据。 + */ + @Schema(description = "编码规则的JSON格式数据") + private String encodedRule; + + /** + * 脱敏字段类型,具体值可参考MaskFieldTypeEnum枚举。 + */ + @Schema(description = "脱敏字段类型") + private String maskFieldType; + + /** + * 字典Id。 + */ + @Schema(description = "字典Id") + private Long dictId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者。 + */ + @Schema(description = "创建者") + private Long createUserId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者。 + */ + @Schema(description = "更新者") + private Long updateUserId; + + /** + * fieldKind 常量字典关联数据。 + */ + @Schema(description = "常量字典关联数据") + private Map fieldKindDictMap; + + /** + * dictId 的一对一关联。 + */ + @Schema(description = "dictId 的一对一关联") + private Map dictInfo; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDatasourceRelationVo.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDatasourceRelationVo.java new file mode 100644 index 00000000..6af755a9 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDatasourceRelationVo.java @@ -0,0 +1,150 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单的数据源关联VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单的数据源关联VO对象") +@Data +public class OnlineDatasourceRelationVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long relationId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Schema(description = "应用编码。为空时,表示非第三方应用接入") + private String appCode; + + /** + * 关联名称。 + */ + @Schema(description = "关联名称") + private String relationName; + + /** + * 变量名。 + */ + @Schema(description = "变量名") + private String variableName; + + /** + * 主数据源Id。 + */ + @Schema(description = "主数据源Id") + private Long datasourceId; + + /** + * 关联类型。 + */ + @Schema(description = "关联类型") + private Integer relationType; + + /** + * 主表关联字段Id。 + */ + @Schema(description = "主表关联字段Id") + private Long masterColumnId; + + /** + * 从表Id。 + */ + @Schema(description = "从表Id") + private Long slaveTableId; + + /** + * 从表关联字段Id。 + */ + @Schema(description = "从表关联字段Id") + private Long slaveColumnId; + + /** + * 删除主表的时候是否级联删除一对一和一对多的从表数据,多对多只是删除关联,不受到这个标记的影响。。 + */ + @Schema(description = "一对多从表级联删除标记") + private Boolean cascadeDelete; + + /** + * 是否左连接。 + */ + @Schema(description = "是否左连接") + private Boolean leftJoin; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者。 + */ + @Schema(description = "创建者") + private Long createUserId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者。 + */ + @Schema(description = "更新者") + private Long updateUserId; + + /** + * masterColumnId 的一对一关联数据对象,数据对应类型为OnlineColumnVo。 + */ + @Schema(description = "masterColumnId字段的一对一关联数据对象") + private Map masterColumn; + + /** + * slaveTableId 的一对一关联数据对象,数据对应类型为OnlineTableVo。 + */ + @Schema(description = "slaveTableId字段的一对一关联数据对象") + private Map slaveTable; + + /** + * slaveColumnId 的一对一关联数据对象,数据对应类型为OnlineColumnVo。 + */ + @Schema(description = "slaveColumnId字段的一对一关联数据对象") + private Map slaveColumn; + + /** + * masterColumnId 字典关联数据。 + */ + @Schema(description = "masterColumnId的字典关联数据") + private Map masterColumnIdDictMap; + + /** + * slaveTableId 字典关联数据。 + */ + @Schema(description = "slaveTableId的字典关联数据") + private Map slaveTableIdDictMap; + + /** + * slaveColumnId 字典关联数据。 + */ + @Schema(description = "slaveColumnId的字典关联数据") + private Map slaveColumnIdDictMap; + + /** + * relationType 常量字典关联数据。 + */ + @Schema(description = "常量字典关联数据") + private Map relationTypeDictMap; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDatasourceVo.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDatasourceVo.java new file mode 100644 index 00000000..bbf8c2bc --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDatasourceVo.java @@ -0,0 +1,98 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 在线表单的数据源VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单的数据源VO对象") +@Data +public class OnlineDatasourceVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long datasourceId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Schema(description = "应用编码。为空时,表示非第三方应用接入") + private String appCode; + + /** + * 数据源名称。 + */ + @Schema(description = "数据源名称") + private String datasourceName; + + /** + * 数据源变量名,会成为数据访问url的一部分。 + */ + @Schema(description = "数据源变量名") + private String variableName; + + /** + * 数据库链接Id。 + */ + @Schema(description = "数据库链接Id") + private Long dblinkId; + + /** + * 主表Id。 + */ + @Schema(description = "主表Id") + private Long masterTableId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者。 + */ + @Schema(description = "创建者") + private Long createUserId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者。 + */ + @Schema(description = "更新者") + private Long updateUserId; + + /** + * datasourceId 的多对多关联表数据对象,数据对应类型为OnlinePageDatasource。 + */ + @Schema(description = "datasourceId 的多对多关联表数据对象,数据对应类型为OnlinePageDatasource") + private Map onlinePageDatasource; + + /** + * masterTableId 字典关联数据。 + */ + @Schema(description = "masterTableId 字典关联数据") + private Map masterTableIdDictMap; + + /** + * 当前数据源及其关联,引用的数据表对象列表。 + */ + @Schema(description = "当前数据源及其关联,引用的数据表对象列表") + private List tableList; +} +//、FlowTaskTimeoutTimer \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDblinkVo.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDblinkVo.java new file mode 100644 index 00000000..6415f31c --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDblinkVo.java @@ -0,0 +1,84 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单数据表所在数据库链接VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单数据表所在数据库链接VO对象") +@Data +public class OnlineDblinkVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long dblinkId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Schema(description = "应用编码。为空时,表示非第三方应用接入") + private String appCode; + + /** + * 链接中文名称。 + */ + @Schema(description = "链接中文名称") + private String dblinkName; + + /** + * 链接描述。 + */ + @Schema(description = "链接描述") + private String dblinkDescription; + + /** + * 配置信息。 + */ + @Schema(description = "配置信息") + private String configuration; + + /** + * 数据库链接类型。 + */ + @Schema(description = "数据库链接类型") + private Integer dblinkType; + + /** + * 更新者。 + */ + @Schema(description = "更新者") + private Long updateUserId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 创建者。 + */ + @Schema(description = "创建者") + private Long createUserId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 数据库链接类型常量字典关联数据。 + */ + @Schema(description = "数据库链接类型常量字典关联数据") + private Map dblinkTypeDictMap; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDictVo.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDictVo.java new file mode 100644 index 00000000..804e5c71 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDictVo.java @@ -0,0 +1,162 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单关联的字典VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单关联的字典VO对象") +@Data +public class OnlineDictVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long dictId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Schema(description = "应用编码。为空时,表示非第三方应用接入") + private String appCode; + + /** + * 字典名称。 + */ + @Schema(description = "字典名称") + private String dictName; + + /** + * 字典类型。 + */ + @Schema(description = "字典类型") + private Integer dictType; + + /** + * 数据库链接Id。 + */ + @Schema(description = "数据库链接Id") + private Long dblinkId; + + /** + * 字典表名称。 + */ + @Schema(description = "字典表名称") + private String tableName; + + /** + * 全局字典编码。 + */ + @Schema(description = "全局字典编码") + private String dictCode; + + /** + * 逻辑删除字段。 + */ + @Schema(description = "逻辑删除字段") + private String deletedColumnName; + + /** + * 用户过滤滤字段名称。 + */ + @Schema(description = "用户过滤滤字段名称") + private String userFilterColumnName; + + /** + * 部门过滤字段名称。 + */ + @Schema(description = "部门过滤字段名称") + private String deptFilterColumnName; + + /** + * 租户过滤字段名称。 + */ + @Schema(description = "租户过滤字段名称") + private String tenantFilterColumnName; + + /** + * 字典表键字段名称。 + */ + @Schema(description = "字典表键字段名称") + private String keyColumnName; + + /** + * 字典表父键字段名称。 + */ + @Schema(description = "字典表父键字段名称") + private String parentKeyColumnName; + + /** + * 字典值字段名称。 + */ + @Schema(description = "字典值字段名称") + private String valueColumnName; + + /** + * 是否树形标记。 + */ + @Schema(description = "是否树形标记") + private Boolean treeFlag; + + /** + * 获取字典数据的url。 + */ + @Schema(description = "获取字典数据的url") + private String dictListUrl; + + /** + * 根据主键id批量获取字典数据的url。 + */ + @Schema(description = "根据主键id批量获取字典数据的url") + private String dictIdsUrl; + + /** + * 字典的JSON数据。 + */ + @Schema(description = "字典的JSON数据") + private String dictDataJson; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者。 + */ + @Schema(description = "创建者") + private Long createUserId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者。 + */ + @Schema(description = "更新者") + private Long updateUserId; + + /** + * dictType 常量字典关联数据。 + */ + @Schema(description = "dictType 常量字典关联数据") + private Map dictTypeDictMap; + + /** + * 数据库链接Id字典关联数据。 + */ + @Schema(description = "数据库链接Id字典关联数据") + private Map dblinkIdDictMap; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineFormVo.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineFormVo.java new file mode 100644 index 00000000..d3373ce8 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineFormVo.java @@ -0,0 +1,127 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 在线表单VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单VO对象") +@Data +public class OnlineFormVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long formId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Schema(description = "应用编码。为空时,表示非第三方应用接入") + private String appCode; + + /** + * 页面Id。 + */ + @Schema(description = "页面Id") + private Long pageId; + + /** + * 表单编码。 + */ + @Schema(description = "表单编码") + private String formCode; + + /** + * 表单名称。 + */ + @Schema(description = "表单名称") + private String formName; + + /** + * 表单类型。 + */ + @Schema(description = "表单类型") + private Integer formType; + + /** + * 表单类别。 + */ + @Schema(description = "表单类别") + private Integer formKind; + + /** + * 表单主表Id。 + */ + @Schema(description = "表单主表Id") + private Long masterTableId; + + /** + * 表单组件JSON。 + */ + @Schema(description = "表单组件JSON") + private String widgetJson; + + /** + * 表单参数JSON。 + */ + @Schema(description = "表单参数JSON") + private String paramsJson; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者。 + */ + @Schema(description = "创建者") + private Long createUserId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者。 + */ + @Schema(description = "更新者") + private Long updateUserId; + + /** + * masterTableId 的一对一关联数据对象,数据对应类型为OnlineTableVo。 + */ + @Schema(description = "asterTableId 的一对一关联数据对象") + private Map onlineTable; + + /** + * masterTableId 字典关联数据。 + */ + @Schema(description = "masterTableId 字典关联数据") + private Map masterTableIdDictMap; + + /** + * formType 常量字典关联数据。 + */ + @Schema(description = "formType 常量字典关联数据") + private Map formTypeDictMap; + + /** + * 当前表单关联的数据源Id集合。 + */ + @Schema(description = "当前表单关联的数据源Id集合") + private List datasourceIdList; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlinePageDatasourceVo.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlinePageDatasourceVo.java new file mode 100644 index 00000000..adb113ff --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlinePageDatasourceVo.java @@ -0,0 +1,33 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 在线表单页面和数据源多对多关联VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单页面和数据源多对多关联VO对象") +@Data +public class OnlinePageDatasourceVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long id; + + /** + * 页面主键Id。 + */ + @Schema(description = "页面主键Id") + private Long pageId; + + /** + * 数据源主键Id。 + */ + @Schema(description = "数据源主键Id") + private Long datasourceId; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlinePageVo.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlinePageVo.java new file mode 100644 index 00000000..bd80de12 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlinePageVo.java @@ -0,0 +1,96 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单所在页面VO对象。这里我们可以把页面理解为表单的容器。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单所在页面VO对象") +@Data +public class OnlinePageVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long pageId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Schema(description = "应用编码。为空时,表示非第三方应用接入") + private String appCode; + + /** + * 页面编码。 + */ + @Schema(description = "页面编码") + private String pageCode; + + /** + * 页面名称。 + */ + @Schema(description = "页面名称") + private String pageName; + + /** + * 页面类型。 + */ + @Schema(description = "页面类型") + private Integer pageType; + + /** + * 页面编辑状态。 + */ + @Schema(description = "页面编辑状态") + private Integer status; + + /** + * 是否发布。 + */ + @Schema(description = "是否发布") + private Boolean published; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者。 + */ + @Schema(description = "创建者") + private Long createUserId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者。 + */ + @Schema(description = "更新者") + private Long updateUserId; + + /** + * pageType 常量字典关联数据。 + */ + @Schema(description = "pageType 常量字典关联数据") + private Map pageTypeDictMap; + + /** + * status 常量字典关联数据。 + */ + @Schema(description = "status 常量字典关联数据") + private Map statusDictMap; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineRuleVo.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineRuleVo.java new file mode 100644 index 00000000..ba88dbec --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineRuleVo.java @@ -0,0 +1,90 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单数据表字段验证规则VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单数据表字段验证规则VO对象") +@Data +public class OnlineRuleVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long ruleId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Schema(description = "应用编码。为空时,表示非第三方应用接入") + private String appCode; + + /** + * 规则名称。 + */ + @Schema(description = "规则名称") + private String ruleName; + + /** + * 规则类型。 + */ + @Schema(description = "规则类型") + private Integer ruleType; + + /** + * 内置规则标记。 + */ + @Schema(description = "内置规则标记") + private Boolean builtin; + + /** + * 自定义规则的正则表达式。 + */ + @Schema(description = "自定义规则的正则表达式") + private String pattern; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者。 + */ + @Schema(description = "创建者") + private Long createUserId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者。 + */ + @Schema(description = "更新者") + private Long updateUserId; + + /** + * ruleId 的多对多关联表数据对象,数据对应类型为OnlineColumnRuleVo。 + */ + @Schema(description = "ruleId 的多对多关联表数据对象") + private Map onlineColumnRule; + + /** + * ruleType 常量字典关联数据。 + */ + @Schema(description = "ruleType 常量字典关联数据") + private Map ruleTypeDictMap; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineTableVo.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineTableVo.java new file mode 100644 index 00000000..66561baf --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineTableVo.java @@ -0,0 +1,71 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 在线表单的数据表VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单的数据表VO对象") +@Data +public class OnlineTableVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long tableId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Schema(description = "应用。为空时,表示非第三方应用接入") + private String appCode; + + /** + * 表名称。 + */ + @Schema(description = "表名称") + private String tableName; + + /** + * 实体名称。 + */ + @Schema(description = "实体名称") + private String modelName; + + /** + * 数据库链接Id。 + */ + @Schema(description = "数据库链接Id") + private Long dblinkId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者。 + */ + @Schema(description = "创建者") + private Long createUserId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者。 + */ + @Schema(description = "更新者") + private Long updateUserId; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineVirtualColumnVo.java b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineVirtualColumnVo.java new file mode 100644 index 00000000..2a4ca215 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineVirtualColumnVo.java @@ -0,0 +1,87 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 在线数据表虚拟字段VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线数据表虚拟字段VO对象") +@Data +public class OnlineVirtualColumnVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long virtualColumnId; + + /** + * 所在表Id。 + */ + @Schema(description = "所在表Id") + private Long tableId; + + /** + * 字段名称。 + */ + @Schema(description = "字段名称") + private String objectFieldName; + + /** + * 属性类型。 + */ + @Schema(description = "属性类型") + private String objectFieldType; + + /** + * 字段提示名。 + */ + @Schema(description = "字段提示名") + private String columnPrompt; + + /** + * 虚拟字段类型(0: 聚合)。 + */ + @Schema(description = "虚拟字段类型(0: 聚合)") + private Integer virtualType; + + /** + * 关联数据源Id。 + */ + @Schema(description = "关联数据源Id") + private Long datasourceId; + + /** + * 关联Id。 + */ + @Schema(description = "关联Id") + private Long relationId; + + /** + * 聚合字段所在关联表Id。 + */ + @Schema(description = "聚合字段所在关联表Id") + private Long aggregationTableId; + + /** + * 关联表聚合字段Id。 + */ + @Schema(description = "关联表聚合字段Id") + private Long aggregationColumnId; + + /** + * 聚合类型(0: count 1: sum 2: avg 3: max 4:min)。 + */ + @Schema(description = "聚合类型(0: count 1: sum 2: avg 3: max 4:min)") + private Integer aggregationType; + + /** + * 存储过滤条件的json。 + */ + @Schema(description = "存储过滤条件的json") + private String whereClauseJson; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..d9cb5fb0 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-online/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.orangeforms.common.online.config.OnlineAutoConfig \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-redis/pom.xml b/OrangeFormsOpen-MybatisFlex/common/common-redis/pom.xml new file mode 100644 index 00000000..c0fe169d --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-redis/pom.xml @@ -0,0 +1,29 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-redis + 1.0.0 + common-redis + jar + + + + com.orangeforms + common-core + 1.0.0 + + + org.redisson + redisson + ${redisson.version} + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/RedisDictionaryCache.java b/OrangeFormsOpen-MybatisFlex/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/RedisDictionaryCache.java new file mode 100644 index 00000000..da1c2fc2 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/RedisDictionaryCache.java @@ -0,0 +1,263 @@ +package com.orangeforms.common.redis.cache; + +import cn.hutool.core.collection.CollUtil; +import com.alibaba.fastjson.JSON; +import com.orangeforms.common.core.cache.DictionaryCache; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.exception.RedisCacheAccessException; +import lombok.extern.slf4j.Slf4j; +import org.redisson.api.RMap; +import org.redisson.api.RedissonClient; + +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 字典数据Redis缓存对象。 + * + * @param 字典表主键类型。 + * @param 字典表对象类型。 + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class RedisDictionaryCache implements DictionaryCache { + + /** + * 字典数据前缀,便于Redis工具分组显示。 + */ + protected static final String DICT_PREFIX = "DICT-TABLE:"; + /** + * redisson客户端。 + */ + protected final RedissonClient redissonClient; + /** + * 数据存储对象。 + */ + protected final RMap dataMap; + /** + * 字典值对象类型。 + */ + protected final Class valueClazz; + /** + * 获取字典主键数据的函数对象。 + */ + protected final Function idGetter; + + /** + * 当前对象的构造器函数。 + * + * @param redissonClient Redisson的客户端对象。 + * @param dictionaryName 字典表的名称。等同于redis hash对象的key。 + * @param valueClazz 值对象的Class对象。 + * @param idGetter 获取当前类主键字段值的函数对象。 + * @param 字典主键类型。 + * @param 字典对象类型 + * @return 实例化后的字典内存缓存对象。 + */ + public static RedisDictionaryCache create( + RedissonClient redissonClient, + String dictionaryName, + Class valueClazz, + Function idGetter) { + if (idGetter == null) { + throw new IllegalArgumentException("IdGetter can't be NULL."); + } + return new RedisDictionaryCache<>(redissonClient, dictionaryName, valueClazz, idGetter); + } + + /** + * 构造函数。 + * + * @param redissonClient Redisson的客户端对象。 + * @param dictionaryName 字典表的名称。等同于redis hash对象的key。确保全局唯一。 + * @param valueClazz 值对象的Class对象。 + * @param idGetter 获取当前类主键字段值的函数对象。 + */ + public RedisDictionaryCache( + RedissonClient redissonClient, + String dictionaryName, + Class valueClazz, + Function idGetter) { + this.redissonClient = redissonClient; + this.dataMap = redissonClient.getMap( + DICT_PREFIX + dictionaryName + ApplicationConstant.DICT_CACHE_NAME_SUFFIX); + this.valueClazz = valueClazz; + this.idGetter = idGetter; + } + + protected RMap getDataMap() { + return dataMap; + } + + @Override + public List getAll() { + Collection dataList; + String exceptionMessage; + try { + dataList = getDataMap().readAllValues(); + } catch (Exception e) { + exceptionMessage = String.format( + "[%s::getAll] encountered EXCEPTION [%s] for DICT [%s].", + this.getClass().getSimpleName(), e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + if (dataList == null) { + return new LinkedList<>(); + } + return dataList.stream() + .map(data -> JSON.parseObject(data, valueClazz)) + .collect(Collectors.toCollection(LinkedList::new)); + } + + @Override + public List getInList(Set keys) { + if (CollUtil.isEmpty(keys)) { + return new LinkedList<>(); + } + Collection dataList; + String exceptionMessage; + try { + dataList = getDataMap().getAll(keys).values(); + } catch (Exception e) { + exceptionMessage = String.format( + "[%s::getInList] encountered EXCEPTION [%s] for DICT [%s].", + this.getClass().getSimpleName(), e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + if (dataList == null) { + return new LinkedList<>(); + } + return dataList.stream() + .map(data -> JSON.parseObject(data, valueClazz)) + .collect(Collectors.toCollection(LinkedList::new)); + } + + @Override + public V get(K id) { + if (id == null) { + return null; + } + String data; + String exceptionMessage; + try { + data = getDataMap().get(id); + } catch (Exception e) { + exceptionMessage = String.format( + "[%s::get] encountered EXCEPTION [%s] for DICT [%s].", + this.getClass().getSimpleName(), e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + if (data == null) { + return null; + } + return JSON.parseObject(data, valueClazz); + } + + @Override + public int getCount() { + return getDataMap().size(); + } + + @Override + public void put(K id, V data) { + if (id == null || data == null) { + return; + } + String exceptionMessage; + try { + getDataMap().fastPut(id, JSON.toJSONString(data)); + } catch (Exception e) { + exceptionMessage = String.format( + "[%s::put] encountered EXCEPTION [%s] for DICT [%s].", + this.getClass().getSimpleName(), e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + } + + @Override + public void reload(List dataList, boolean force) { + String exceptionMessage; + try { + // 如果不强制刷新,需要先判断缓存中是否存在数据。 + if (!force && this.getCount() > 0) { + return; + } + Map map = null; + if (CollUtil.isNotEmpty(dataList)) { + map = dataList.stream().collect(Collectors.toMap(idGetter, JSON::toJSONString)); + } + RMap localDataMap = getDataMap(); + localDataMap.clear(); + if (map != null) { + localDataMap.putAll(map); + } + } catch (Exception e) { + exceptionMessage = String.format( + "[%s::reload] encountered EXCEPTION [%s] for DICT [%s].", + this.getClass().getSimpleName(), e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + } + + @Override + public V invalidate(K id) { + if (id == null) { + return null; + } + String data; + String exceptionMessage; + try { + data = getDataMap().remove(id); + } catch (Exception e) { + exceptionMessage = String.format( + "[%s::invalidate] encountered EXCEPTION [%s] for DICT [%s].", + this.getClass().getSimpleName(), e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + if (data == null) { + return null; + } + return JSON.parseObject(data, valueClazz); + } + + @SuppressWarnings("unchecked") + @Override + public void invalidateSet(Set keys) { + if (CollUtil.isEmpty(keys)) { + return; + } + Object[] keyArray = keys.toArray(new Object[]{}); + String exceptionMessage; + try { + getDataMap().fastRemove((K[]) keyArray); + } catch (Exception e) { + exceptionMessage = String.format( + "[%s::invalidateSet] encountered EXCEPTION [%s] for DICT [%s].", + this.getClass().getSimpleName(), e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + } + + @Override + public void invalidateAll() { + String exceptionMessage; + try { + getDataMap().clear(); + } catch (Exception e) { + exceptionMessage = String.format( + "[%s::invalidateAll] encountered EXCEPTION [%s] for DICT [%s].", + this.getClass().getSimpleName(), e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/RedisTreeDictionaryCache.java b/OrangeFormsOpen-MybatisFlex/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/RedisTreeDictionaryCache.java new file mode 100644 index 00000000..de910c61 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/RedisTreeDictionaryCache.java @@ -0,0 +1,224 @@ +package com.orangeforms.common.redis.cache; + +import cn.hutool.core.collection.CollUtil; +import com.alibaba.fastjson.JSON; +import lombok.extern.slf4j.Slf4j; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.exception.RedisCacheAccessException; +import com.google.common.collect.LinkedListMultimap; +import com.google.common.collect.Multimap; +import org.redisson.api.RListMultimap; +import org.redisson.api.RedissonClient; + +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 树形字典数据Redis缓存对象。 + * + * @param 字典表主键类型。 + * @param 字典表对象类型。 + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class RedisTreeDictionaryCache extends RedisDictionaryCache { + + /** + * 树形数据存储对象。 + */ + private final RListMultimap allTreeMap; + /** + * 获取字典父主键数据的函数对象。 + */ + protected final Function parentIdGetter; + + /** + * 当前对象的构造器函数。 + * + * @param redissonClient Redisson的客户端对象。 + * @param dictionaryName 字典表的名称。等同于redis hash对象的key。 + * @param valueClazz 值对象的Class对象。 + * @param idGetter 获取当前类主键字段值的函数对象。 + * @param parentIdGetter 获取当前类父主键字段值的函数对象。 + * @param 字典主键类型。 + * @param 字典对象类型 + * @return 实例化后的树形字典内存缓存对象。 + */ + public static RedisTreeDictionaryCache create( + RedissonClient redissonClient, + String dictionaryName, + Class valueClazz, + Function idGetter, + Function parentIdGetter) { + if (idGetter == null) { + throw new IllegalArgumentException("IdGetter can't be NULL."); + } + if (parentIdGetter == null) { + throw new IllegalArgumentException("ParentIdGetter can't be NULL."); + } + return new RedisTreeDictionaryCache<>( + redissonClient, dictionaryName, valueClazz, idGetter, parentIdGetter); + } + + /** + * 构造函数。 + * + * @param redissonClient Redisson的客户端对象。 + * @param dictionaryName 字典表的名称。等同于redis hash对象的key。 + * @param valueClazz 值对象的Class对象。 + * @param idGetter 获取当前类主键字段值的函数对象。 + * @param parentIdGetter 获取当前类父主键字段值的函数对象。 + */ + public RedisTreeDictionaryCache( + RedissonClient redissonClient, + String dictionaryName, + Class valueClazz, + Function idGetter, + Function parentIdGetter) { + super(redissonClient, dictionaryName, valueClazz, idGetter); + this.allTreeMap = redissonClient.getListMultimap( + DICT_PREFIX + dictionaryName + ApplicationConstant.TREE_DICT_CACHE_NAME_SUFFIX); + this.parentIdGetter = parentIdGetter; + } + + @Override + public List getListByParentId(K parentId) { + List dataList; + String exceptionMessage; + try { + dataList = allTreeMap.get(parentId); + } catch (Exception e) { + exceptionMessage = String.format( + "Operation of [RedisTreeDictionaryCache::getListByParentId] encountered EXCEPTION [%s] for DICT [%s].", + e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + if (CollUtil.isEmpty(dataList)) { + return new LinkedList<>(); + } + return dataList.stream().map(data -> JSON.parseObject(data, valueClazz)).collect(Collectors.toList()); + } + + @Override + public void reload(List dataList, boolean force) { + String exceptionMessage; + try { + // 如果不强制刷新,需要先判断缓存中是否存在数据。 + if (!force && this.getCount() > 0) { + return; + } + dataMap.clear(); + allTreeMap.clear(); + if (CollUtil.isEmpty(dataList)) { + return; + } + Map map = dataList.stream().collect(Collectors.toMap(idGetter, JSON::toJSONString)); + // 这里现在本地内存构建树形数据关系,然后再批量存入到Redis缓存。 + // 以便减少与Redis的交互,同时提升运行时效率。 + Multimap treeMap = LinkedListMultimap.create(); + for (V data : dataList) { + treeMap.put(parentIdGetter.apply(data), JSON.toJSONString(data)); + } + dataMap.putAll(map, 3000); + for (Map.Entry> entry : treeMap.asMap().entrySet()) { + allTreeMap.putAll(entry.getKey(), entry.getValue()); + } + } catch (Exception e) { + exceptionMessage = String.format( + "Operation of [RedisDictionaryCache::reload] encountered EXCEPTION [%s] for DICT [%s].", + e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + } + + @Override + public void put(K id, V data) { + if (id == null || data == null) { + return; + } + String stringData = JSON.toJSONString(data); + K parentId = parentIdGetter.apply(data); + String exceptionMessage; + try { + String oldData = dataMap.put(id, stringData); + if (oldData != null) { + allTreeMap.remove(parentId, oldData); + } + allTreeMap.put(parentId, stringData); + } catch (Exception e) { + exceptionMessage = String.format( + "Operation of [RedisTreeDictionaryCache::put] encountered EXCEPTION [%s] for DICT [%s].", + e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + } + + @Override + public V invalidate(K id) { + if (id == null) { + return null; + } + V data = null; + String exceptionMessage; + try { + String stringData = dataMap.remove(id); + if (stringData != null) { + data = JSON.parseObject(stringData, valueClazz); + K parentId = parentIdGetter.apply(data); + allTreeMap.remove(parentId, stringData); + } + } catch (Exception e) { + exceptionMessage = String.format( + "Operation of [RedisTreeDictionaryCache::invalidate] encountered EXCEPTION [%s] for DICT [%s].", + e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + return data; + } + + @Override + public void invalidateSet(Set keys) { + if (CollUtil.isEmpty(keys)) { + return; + } + String exceptionMessage; + try { + keys.forEach(id -> { + if (id != null) { + String stringData = dataMap.remove(id); + if (stringData != null) { + K parentId = parentIdGetter.apply(JSON.parseObject(stringData, valueClazz)); + allTreeMap.remove(parentId, stringData); + } + } + }); + } catch (Exception e) { + exceptionMessage = String.format( + "Operation of [RedisTreeDictionaryCache::invalidateSet] encountered EXCEPTION [%s] for DICT [%s].", + e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + } + + @Override + public void invalidateAll() { + String exceptionMessage; + try { + dataMap.clear(); + allTreeMap.clear(); + } catch (Exception e) { + exceptionMessage = String.format( + "Operation of [RedisTreeDictionaryCache::invalidateAll] encountered EXCEPTION [%s] for DICT [%s].", + e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/RedissonCacheConfig.java b/OrangeFormsOpen-MybatisFlex/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/RedissonCacheConfig.java new file mode 100644 index 00000000..5210be88 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/RedissonCacheConfig.java @@ -0,0 +1,73 @@ +package com.orangeforms.common.redis.cache; + +import com.google.common.collect.Maps; +import org.redisson.api.RedissonClient; +import org.redisson.spring.cache.CacheConfig; +import org.redisson.spring.cache.RedissonSpringCacheManager; +import org.springframework.cache.CacheManager; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; + +import java.util.Map; + +/** + * 使用Redisson作为Redis的分布式缓存库。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Configuration +@EnableCaching +public class RedissonCacheConfig { + + private static final int DEFAULT_TTL = 3600000; + + /** + * 定义cache名称、超时时长(毫秒)。 + */ + public enum CacheEnum { + /** + * session下上传文件名的缓存(时间是24小时)。 + */ + UPLOAD_FILENAME_CACHE(86400000), + /** + * session的打印访问令牌缓存(时间是1小时)。 + */ + PRINT_ACCESS_TOKEN_CACHE(3600000), + /** + * 缺省全局缓存(时间是24小时)。 + */ + GLOBAL_CACHE(86400000); + + /** + * 缓存的时长(单位:毫秒) + */ + private int ttl = DEFAULT_TTL; + + CacheEnum() { + } + + CacheEnum(int ttl) { + this.ttl = ttl; + } + + public int getTtl() { + return ttl; + } + } + + /** + * 初始化缓存配置。 + */ + @Bean + @Primary + public CacheManager cacheManager(RedissonClient redissonClient) { + Map config = Maps.newHashMap(); + for (CacheEnum c : CacheEnum.values()) { + config.put(c.name(), new CacheConfig(c.getTtl(), 0)); + } + return new RedissonSpringCacheManager(redissonClient, config); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/SessionCacheHelper.java b/OrangeFormsOpen-MybatisFlex/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/SessionCacheHelper.java new file mode 100644 index 00000000..4c613c7c --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/SessionCacheHelper.java @@ -0,0 +1,179 @@ +package com.orangeforms.common.redis.cache; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.text.StrFormatter; +import com.alibaba.fastjson.JSON; +import com.orangeforms.common.core.object.MyPrintInfo; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.exception.MyRuntimeException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * Session数据缓存辅助类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@SuppressWarnings("unchecked") +@Component +public class SessionCacheHelper { + + @Autowired + private CacheManager cacheManager; + + private static final String NO_CACHE_FORMAT_MSG = "No redisson cache [{}]!"; + + /** + * 缓存当前session内,上传过的文件名。 + * + * @param filename 通常是本地存储的文件名,而不是上传时的原始文件名。 + */ + public void putSessionUploadFile(String filename) { + if (filename != null) { + Set sessionUploadFileSet = null; + Cache cache = cacheManager.getCache(RedissonCacheConfig.CacheEnum.UPLOAD_FILENAME_CACHE.name()); + if (cache == null) { + String msg = StrFormatter.format(NO_CACHE_FORMAT_MSG, + RedissonCacheConfig.CacheEnum.UPLOAD_FILENAME_CACHE.name()); + throw new MyRuntimeException(msg); + } + Cache.ValueWrapper valueWrapper = cache.get(TokenData.takeFromRequest().getSessionId()); + if (valueWrapper != null) { + sessionUploadFileSet = (Set) valueWrapper.get(); + } + if (sessionUploadFileSet == null) { + sessionUploadFileSet = new HashSet<>(); + } + sessionUploadFileSet.add(filename); + cache.put(TokenData.takeFromRequest().getSessionId(), sessionUploadFileSet); + } + } + + /** + * 缓存当前Session可以下载的文件集合。 + * + * @param filenameSet 后台服务本地存储的文件名,而不是上传时的原始文件名。 + */ + public void putSessionDownloadableFileNameSet(Set filenameSet) { + if (CollUtil.isEmpty(filenameSet)) { + return; + } + Set sessionUploadFileSet = null; + Cache cache = cacheManager.getCache(RedissonCacheConfig.CacheEnum.UPLOAD_FILENAME_CACHE.name()); + if (cache == null) { + throw new MyRuntimeException(StrFormatter.format(NO_CACHE_FORMAT_MSG, + RedissonCacheConfig.CacheEnum.UPLOAD_FILENAME_CACHE.name())); + } + Cache.ValueWrapper valueWrapper = cache.get(TokenData.takeFromRequest().getSessionId()); + if (valueWrapper != null) { + sessionUploadFileSet = (Set) valueWrapper.get(); + } + if (sessionUploadFileSet == null) { + sessionUploadFileSet = new HashSet<>(); + } + sessionUploadFileSet.addAll(filenameSet); + cache.put(TokenData.takeFromRequest().getSessionId(), sessionUploadFileSet); + } + + /** + * 判断参数中的文件名,是否有当前session上传。 + * + * @param filename 通常是本地存储的文件名,而不是上传时的原始文件名。 + * @return true表示该文件是由当前session上传并存储在本地的,否则false。 + */ + public boolean existSessionUploadFile(String filename) { + if (filename == null) { + return false; + } + Cache cache = cacheManager.getCache(RedissonCacheConfig.CacheEnum.UPLOAD_FILENAME_CACHE.name()); + if (cache == null) { + String msg = StrFormatter.format(NO_CACHE_FORMAT_MSG, + RedissonCacheConfig.CacheEnum.UPLOAD_FILENAME_CACHE.name()); + throw new MyRuntimeException(msg); + } + Cache.ValueWrapper valueWrapper = cache.get(TokenData.takeFromRequest().getSessionId()); + if (valueWrapper == null) { + return false; + } + Object cachedData = valueWrapper.get(); + if (cachedData == null) { + return false; + } + return ((Set) cachedData).contains(filename); + } + + /** + * 缓存当前session内,可打印的安全令牌。 + * + * @param token 打印安全令牌。 + * @param printInfo 打印参数信息。 + */ + public void putSessionPrintTokenAndInfo(String token, MyPrintInfo printInfo) { + Cache cache = cacheManager.getCache(RedissonCacheConfig.CacheEnum.PRINT_ACCESS_TOKEN_CACHE.name()); + if (cache == null) { + String msg = StrFormatter.format(NO_CACHE_FORMAT_MSG, + RedissonCacheConfig.CacheEnum.PRINT_ACCESS_TOKEN_CACHE.name()); + throw new MyRuntimeException(msg); + } + Map sessionPrintTokenMap = null; + Cache.ValueWrapper valueWrapper = cache.get(TokenData.takeFromRequest().getSessionId()); + if (valueWrapper != null) { + sessionPrintTokenMap = (Map) valueWrapper.get(); + } + if (sessionPrintTokenMap == null) { + sessionPrintTokenMap = new HashMap<>(4); + } + sessionPrintTokenMap.put(token, JSON.toJSONString(printInfo)); + cache.put(TokenData.takeFromRequest().getSessionId(), sessionPrintTokenMap); + } + + /** + * 获取当前session中,指定打印令牌所关联的打印信息。 + * + * @param token 打印安全令牌。 + * @return 当前session中,指定打印令牌所关联的打印信息。不存在返回null。 + */ + public MyPrintInfo getSessionPrintInfoByToken(String token) { + Cache cache = cacheManager.getCache(RedissonCacheConfig.CacheEnum.PRINT_ACCESS_TOKEN_CACHE.name()); + if (cache == null) { + String msg = StrFormatter.format(NO_CACHE_FORMAT_MSG, + RedissonCacheConfig.CacheEnum.PRINT_ACCESS_TOKEN_CACHE.name()); + throw new MyRuntimeException(msg); + } + Cache.ValueWrapper valueWrapper = cache.get(TokenData.takeFromRequest().getSessionId()); + if (valueWrapper == null) { + return null; + } + Object cachedData = valueWrapper.get(); + if (cachedData == null) { + return null; + } + String data = ((Map) cachedData).get(token); + if (data == null) { + return null; + } + return JSON.parseObject(data, MyPrintInfo.class); + } + + /** + * 清除当前session的所有缓存数据。 + * + * @param sessionId 当前会话的SessionId。 + */ + public void removeAllSessionCache(String sessionId) { + for (RedissonCacheConfig.CacheEnum c : RedissonCacheConfig.CacheEnum.values()) { + Cache cache = cacheManager.getCache(c.name()); + if (cache != null) { + cache.evict(sessionId); + } + } + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-redis/src/main/java/com/orangeforms/common/redis/config/RedissonConfig.java b/OrangeFormsOpen-MybatisFlex/common/common-redis/src/main/java/com/orangeforms/common/redis/config/RedissonConfig.java new file mode 100644 index 00000000..fecec4b9 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-redis/src/main/java/com/orangeforms/common/redis/config/RedissonConfig.java @@ -0,0 +1,105 @@ +package com.orangeforms.common.redis.config; + +import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.util.StrUtil; +import com.orangeforms.common.core.exception.InvalidRedisModeException; +import org.redisson.Redisson; +import org.redisson.api.RedissonClient; +import org.redisson.config.Config; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Redisson配置类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Configuration +@ConditionalOnProperty(name = "common-redis.redisson.enabled", havingValue = "true") +public class RedissonConfig { + + @Value("${common-redis.redisson.lockWatchdogTimeout}") + private Integer lockWatchdogTimeout; + + @Value("${common-redis.redisson.mode}") + private String mode; + + /** + * 仅仅用于sentinel模式。 + */ + @Value("${common-redis.redisson.masterName:}") + private String masterName; + + @Value("${common-redis.redisson.address}") + private String address; + + @Value("${common-redis.redisson.timeout}") + private Integer timeout; + + @Value("${common-redis.redisson.password:}") + private String password; + + @Value("${common-redis.redisson.pool.poolSize}") + private Integer poolSize; + + @Value("${common-redis.redisson.pool.minIdle}") + private Integer minIdle; + + @Bean + public RedissonClient redissonClient() { + if (StrUtil.isBlank(password)) { + password = null; + } + Config config = new Config(); + if ("single".equals(mode)) { + config.setLockWatchdogTimeout(lockWatchdogTimeout) + .useSingleServer() + .setPassword(password) + .setAddress(address) + .setConnectionPoolSize(poolSize) + .setConnectionMinimumIdleSize(minIdle) + .setConnectTimeout(timeout); + } else if ("cluster".equals(mode)) { + String[] clusterAddresses = StrUtil.splitToArray(address, ','); + config.setLockWatchdogTimeout(lockWatchdogTimeout) + .useClusterServers() + .setPassword(password) + .addNodeAddress(clusterAddresses) + .setConnectTimeout(timeout) + .setMasterConnectionPoolSize(poolSize) + .setMasterConnectionMinimumIdleSize(minIdle); + } else if ("sentinel".equals(mode)) { + String[] sentinelAddresses = StrUtil.splitToArray(address, ','); + config.setLockWatchdogTimeout(lockWatchdogTimeout) + .useSentinelServers() + .setPassword(password) + .setMasterName(masterName) + .addSentinelAddress(sentinelAddresses) + .setConnectTimeout(timeout) + .setMasterConnectionPoolSize(poolSize) + .setMasterConnectionMinimumIdleSize(minIdle); + } else if ("master-slave".equals(mode)) { + String[] masterSlaveAddresses = StrUtil.splitToArray(address, ','); + if (masterSlaveAddresses.length == 1) { + throw new IllegalArgumentException( + "redis.redisson.address MUST have multiple redis addresses for master-slave mode."); + } + String[] slaveAddresses = new String[masterSlaveAddresses.length - 1]; + ArrayUtil.copy(masterSlaveAddresses, 1, slaveAddresses, 0, slaveAddresses.length); + config.setLockWatchdogTimeout(lockWatchdogTimeout) + .useMasterSlaveServers() + .setPassword(password) + .setMasterAddress(masterSlaveAddresses[0]) + .addSlaveAddress(slaveAddresses) + .setConnectTimeout(timeout) + .setMasterConnectionPoolSize(poolSize) + .setMasterConnectionMinimumIdleSize(minIdle); + } else { + throw new InvalidRedisModeException(mode); + } + return Redisson.create(config); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-redis/src/main/java/com/orangeforms/common/redis/util/CommonRedisUtil.java b/OrangeFormsOpen-MybatisFlex/common/common-redis/src/main/java/com/orangeforms/common/redis/util/CommonRedisUtil.java new file mode 100644 index 00000000..7caae85c --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-redis/src/main/java/com/orangeforms/common/redis/util/CommonRedisUtil.java @@ -0,0 +1,216 @@ +package com.orangeforms.common.redis.util; + +import cn.hutool.core.date.DateField; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.EnumUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.mybatisflex.core.query.QueryWrapper; +import lombok.extern.slf4j.Slf4j; +import org.redisson.api.RAtomicLong; +import org.redisson.api.RBucket; +import org.redisson.api.RedissonClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.io.Serializable; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; + +/** + * Redis的常用工具方法。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Component +public class CommonRedisUtil { + + @Autowired + private RedissonClient redissonClient; + + private static final Integer DEFAULT_EXPIRE_SECOND = 300; + + /** + * 计算流水号前缀部分。 + * + * @param prefix 前缀字符串。 + * @param precisionTo 精确到的时间单元,目前仅仅支持 YEAR/MONTH/DAYS/HOURS/MINUTES/SECONDS。 + * @param middle 日期和流水号之间的字符串。 + * @return 返回计算后的前缀部分。 + */ + public String calculateTransIdPrefix(String prefix, String precisionTo, String middle) { + String key = prefix; + if (key == null) { + key = ""; + } + DateTime dateTime = new DateTime(); + String fmt = "yyyy"; + String fmt2 = fmt + "MMddHH"; + switch (precisionTo) { + case "YEAR": + break; + case "MONTH": + fmt += "MM"; + break; + case "DAYS": + fmt = fmt + "MMdd"; + break; + case "HOURS": + fmt = fmt2; + break; + case "MINUTES": + fmt = fmt2 + "mm"; + break; + case "SECONDS": + fmt = fmt2 + "mmss"; + break; + default: + throw new UnsupportedOperationException("Only Support YEAR/MONTH/DAYS/HOURS/MINUTES/SECONDS"); + } + key += dateTime.toString(fmt); + return middle != null ? key + middle : key; + } + + /** + * 生成基于时间的流水号方法。 + * + * @param prefix 前缀字符串。 + * @param precisionTo 精确到的时间单元,目前仅仅支持 YEAR/MONTH/DAYS/HOURS/MINUTES/SECONDS。 + * @param middle 日期和流水号之间的字符串。 + * @param idWidth 计算出的流水号宽度,前面补充0。比如idWidth = 3, 输出值为 005/012/123。 + * 需要注意的是,流水号值超出idWidth指定宽度,低位会被截取。 + * @return 基于时间的流水号方法。 + */ + public String generateTransId(String prefix, String precisionTo, String middle, int idWidth) { + TimeUnit unit = EnumUtil.fromString(TimeUnit.class, precisionTo, null); + int unitCount = 1; + if (unit == null) { + unit = TimeUnit.DAYS; + DateTime now = DateTime.now(); + if (StrUtil.equals(precisionTo, "MONTH")) { + DateTime endOfMonthDay = DateUtil.endOfMonth(now); + unitCount = endOfMonthDay.getField(DateField.DAY_OF_MONTH) - now.getField(DateField.DAY_OF_MONTH) + 1; + } else if (StrUtil.equals(precisionTo, "YEAR")) { + DateTime endOfYearDay = DateUtil.endOfYear(now); + unitCount = endOfYearDay.getField(DateField.DAY_OF_YEAR) - now.getField(DateField.DAY_OF_YEAR) + 1; + } + } + String key = this.calculateTransIdPrefix(prefix, precisionTo, middle); + RAtomicLong atomicLong = redissonClient.getAtomicLong(key); + long value = atomicLong.incrementAndGet(); + if (value == 1L) { + atomicLong.expire(unitCount, unit); + } + return key + StrUtil.padPre(String.valueOf(value), idWidth, "0"); + } + + /** + * 为指定的键设置流水号的初始值。 + * + * @param key 指定的键。 + * @param initalValue 初始值。 + */ + public void initTransId(String key, Long initalValue) { + RAtomicLong atomicLong = redissonClient.getAtomicLong(key); + atomicLong.set(initalValue); + } + + /** + * 从缓存中获取数据。如果缓存中不存在则从执行指定的方法获取数据,并将得到的数据同步到缓存。 + * + * @param key 缓存的键。 + * @param id 数据Id。 + * @param f 获取数据的方法。 + * @param clazz 数据对象类型。 + * @return 数据对象。 + */ + public M getFromCache(String key, Serializable id, Function f, Class clazz) { + return this.getFromCache(key, id, f, clazz, null); + } + + /** + * 从缓存中获取数据。如果缓存中不存在则从执行指定的方法获取数据,并将得到的数据同步到缓存。 + * + * @param key 缓存的键。 + * @param filter mybatis flex的过滤对象。 + * @param f 获取数据的方法。 + * @param clazz 数据对象类型。 + * @return 数据对象。 + */ + public N getFromCacheWithQueryWrapper(String key, QueryWrapper filter, Function f, Class clazz) { + N m; + RBucket bucket = redissonClient.getBucket(key); + if (!bucket.isExists()) { + m = f.apply(filter); + if (m != null) { + bucket.set(JSON.toJSONString(m), DEFAULT_EXPIRE_SECOND, TimeUnit.SECONDS); + } + } else { + m = JSON.parseObject(bucket.get(), clazz); + } + return m; + } + + /** + * 从缓存中获取数据。如果缓存中不存在则从执行指定的方法获取数据,并将得到的数据同步到缓存。 + * + * @param key 缓存的键。 + * @param filter 过滤对象。 + * @param f 获取数据的方法。 + * @param clazz 数据对象类型。 + * @return 数据对象。 + */ + public N getFromCache(String key, M filter, Function f, Class clazz) { + N m; + RBucket bucket = redissonClient.getBucket(key); + if (!bucket.isExists()) { + m = f.apply(filter); + if (m != null) { + bucket.set(JSON.toJSONString(m), DEFAULT_EXPIRE_SECOND, TimeUnit.SECONDS); + } + } else { + m = JSON.parseObject(bucket.get(), clazz); + } + return m; + } + + /** + * 从缓存中获取数据。如果缓存中不存在则从执行指定的方法获取数据,并将得到的数据同步到缓存。 + * + * @param key 缓存的键。 + * @param id 数据Id。 + * @param f 获取数据的方法。 + * @param clazz 数据对象类型。 + * @param seconds 过期秒数。 + * @return 数据对象。 + */ + public M getFromCache( + String key, Serializable id, Function f, Class clazz, Integer seconds) { + M m; + RBucket bucket = redissonClient.getBucket(key); + if (!bucket.isExists()) { + m = f.apply(id); + if (m != null) { + if (seconds == null) { + seconds = DEFAULT_EXPIRE_SECOND; + } + bucket.set(JSON.toJSONString(m), seconds, TimeUnit.SECONDS); + } + } else { + m = JSON.parseObject(bucket.get(), clazz); + } + return m; + } + + /** + * 移除指定Key。 + * + * @param key 键名。 + */ + public void evictFormCache(String key) { + redissonClient.getBucket(key).delete(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-redis/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/OrangeFormsOpen-MybatisFlex/common/common-redis/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..1cac49fc --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-redis/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.orangeforms.common.redis.config.RedissonConfig \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-satoken/pom.xml b/OrangeFormsOpen-MybatisFlex/common/common-satoken/pom.xml new file mode 100644 index 00000000..d2b782dd --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-satoken/pom.xml @@ -0,0 +1,49 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-satoken + 1.0.0 + common-satoken + jar + + 1.37.0 + + + + + cn.dev33 + sa-token-spring-boot3-starter + ${sa-token.version} + + + + cn.dev33 + sa-token-redis-fastjson + ${sa-token.version} + + + + cn.dev33 + sa-token-alone-redis + ${sa-token.version} + + + + org.apache.commons + commons-pool2 + + + com.orangeforms + common-redis + 1.0.0 + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-satoken/src/main/java/com/orangeforms/common/satoken/annotation/SaTokenDenyAuth.java b/OrangeFormsOpen-MybatisFlex/common/common-satoken/src/main/java/com/orangeforms/common/satoken/annotation/SaTokenDenyAuth.java new file mode 100644 index 00000000..8838858f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-satoken/src/main/java/com/orangeforms/common/satoken/annotation/SaTokenDenyAuth.java @@ -0,0 +1,16 @@ +package com.orangeforms.common.satoken.annotation; + +import java.lang.annotation.*; + +/** + * 所有标记该注解的接口,不能使用SaToken进行权限验证。 + * 必须通过橙单自身的动态验证完成,即基于URL的验证。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface SaTokenDenyAuth { +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-satoken/src/main/java/com/orangeforms/common/satoken/listener/SaTokenPermCodeScanListener.java b/OrangeFormsOpen-MybatisFlex/common/common-satoken/src/main/java/com/orangeforms/common/satoken/listener/SaTokenPermCodeScanListener.java new file mode 100644 index 00000000..662bd7e7 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-satoken/src/main/java/com/orangeforms/common/satoken/listener/SaTokenPermCodeScanListener.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.satoken.listener; + +import com.orangeforms.common.satoken.util.SaTokenUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.ApplicationListener; +import org.springframework.lang.NonNull; +import org.springframework.stereotype.Component; + +/** + * 后台服务启动的时候扫描服务中标有权限字,并同步到Redis,以供接口查询所有使用到的权限字。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class SaTokenPermCodeScanListener implements ApplicationListener { + + @Autowired + private SaTokenUtil saTokenUtil; + + @Override + public void onApplicationEvent(@NonNull ApplicationReadyEvent event) { + saTokenUtil.collectPermCodes(event); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-satoken/src/main/java/com/orangeforms/common/satoken/util/SaTokenUtil.java b/OrangeFormsOpen-MybatisFlex/common/common-satoken/src/main/java/com/orangeforms/common/satoken/util/SaTokenUtil.java new file mode 100644 index 00000000..750c3a4a --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-satoken/src/main/java/com/orangeforms/common/satoken/util/SaTokenUtil.java @@ -0,0 +1,283 @@ +package com.orangeforms.common.satoken.util; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.dev33.satoken.annotation.SaIgnore; +import cn.dev33.satoken.exception.SaTokenException; +import cn.dev33.satoken.session.SaSession; +import cn.dev33.satoken.stp.StpUtil; +import cn.dev33.satoken.strategy.SaStrategy; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.ReflectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.cache.CacheConfig; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.LoginUserInfo; +import com.orangeforms.common.core.object.ResponseResult; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.AopTargetUtil; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.RedisKeyUtil; +import com.orangeforms.common.satoken.annotation.SaTokenDenyAuth; +import org.redisson.api.RMap; +import org.redisson.api.RSet; +import org.redisson.api.RTopic; +import org.redisson.api.RedissonClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.stereotype.Component; +import org.springframework.util.Assert; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.method.HandlerMethod; + +import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import java.lang.reflect.Method; +import java.util.*; + +/** + * 通用工具方法。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class SaTokenUtil { + + @Autowired + private RedissonClient redissonClient; + @Resource(name = "caffeineCacheManager") + private CacheManager cacheManager; + + @Value("${spring.application.name}") + private String applicationName; + + public static final String SA_TOKEN_PERM_CODES_KEY = "SaTokenPermCodes"; + public static final String SA_TOKEN_PERM_CODES_PUBLISH_TOPIC = "SaTokenPermCodesTopic"; + + /** + * 处理免验证接口。目前仅用于微服务的业务服务。 + */ + public void handleNoAuthIntercept() { + if (!StpUtil.isLogin()) { + return; + } + SaSession session = StpUtil.getTokenSession(); + if (session != null) { + TokenData tokenData = JSON.toJavaObject( + (JSONObject) session.get(TokenData.REQUEST_ATTRIBUTE_NAME), TokenData.class); + TokenData.addToRequest(tokenData); + tokenData.setToken(session.getToken()); + } + } + + /** + * 处理权限验证,通常在拦截器中调用。用于微服务中业务服务。 + * + * @param request 当前请求。 + * @param handler 拦截器中的处理器。 + * @return 拦截验证处理结果。 + */ + public ResponseResult handleAuthInterceptEx(HttpServletRequest request, Object handler) { + String appCode = MyCommonUtil.getAppCodeFromRequest(); + if (StrUtil.isNotBlank(appCode)) { + String token = request.getHeader(TokenData.REQUEST_ATTRIBUTE_NAME); + if (StrUtil.isBlank(token)) { + String errorMessage = "第三方登录没有包含Token信息!"; + return ResponseResult.error( + HttpServletResponse.SC_UNAUTHORIZED, ErrorCodeEnum.UNAUTHORIZED_LOGIN, errorMessage); + } + TokenData tokenData = JSON.parseObject(token, TokenData.class); + TokenData.addToRequest(tokenData); + return ResponseResult.success(); + } + String dontAuth = request.getHeader(ApplicationConstant.HTTP_HEADER_DONT_AUTH); + if (BooleanUtil.toBoolean(dontAuth)) { + this.handleNoAuthIntercept(); + return ResponseResult.success(); + } + return this.handleAuthIntercept(request, handler); + } + + /** + * 处理权限验证,通常在拦截器中调用。通常用于单体服务。 + * + * @param request 当前请求。 + * @param handler 拦截器中的处理器。 + * @return 拦截验证处理结果。 + */ + public ResponseResult handleAuthIntercept(HttpServletRequest request, Object handler) { + if (!(handler instanceof HandlerMethod)) { + return ResponseResult.success(); + } + Method method = ((HandlerMethod) handler).getMethod(); + String errorMessage; + //如果没有登录则直接交给satoken注解去验证。 + if (!StpUtil.isLogin()) { + // 如果此 Method 或其所属 Class 标注了 @SaIgnore,则忽略掉鉴权 + if (BooleanUtil.isTrue(SaStrategy.instance.isAnnotationPresent.apply(method, SaIgnore.class))) { + return ResponseResult.success(); + } + errorMessage = "非免登录接口必须包含Token信息!"; + return ResponseResult.error(HttpServletResponse.SC_UNAUTHORIZED, ErrorCodeEnum.UNAUTHORIZED_LOGIN, errorMessage); + } + //对于已经登录的用户一定存在session对象。 + SaSession session = StpUtil.getTokenSession(); + if (session == null) { + errorMessage = "用户会话已过期,请重新登录!"; + return ResponseResult.error(HttpServletResponse.SC_UNAUTHORIZED, ErrorCodeEnum.UNAUTHORIZED_LOGIN, errorMessage); + } + TokenData tokenData = JSON.toJavaObject( + (JSONObject) session.get(TokenData.REQUEST_ATTRIBUTE_NAME), TokenData.class); + TokenData.addToRequest(tokenData); + //将最初前端请求使用的token数据赋值给TokenData对象,以便于再次调用其他API接口时直接使用。 + tokenData.setToken(session.getToken()); + //如果是管理员可以直接跳过验证了。 + //基于橙单内部的权限规则优先验证,主要用于内部的白名单接口,以及在线表单和工作流那些动态接口的权限验证。 + if (Boolean.TRUE.equals(tokenData.getIsAdmin()) + || this.hasPermission(tokenData.getSessionId(), request.getRequestURI())) { + return ResponseResult.success(); + } + //对于应由白名单鉴权的接口,都会添加SaTokenDenyAuth注解,因此这里需要判断一下, + //对于此类接口无需SaToken验证了,而是直接返回未授权,因为基于url的鉴权在上面的hasPermission中完成了。 + if (method.getAnnotation(SaTokenDenyAuth.class) != null) { + return ResponseResult.error(HttpServletResponse.SC_UNAUTHORIZED, ErrorCodeEnum.NO_OPERATION_PERMISSION); + } + try { + //执行基于stoken的注解鉴权。 + SaStrategy.instance.checkMethodAnnotation.accept(method); + } catch (SaTokenException e) { + return ResponseResult.error(HttpServletResponse.SC_UNAUTHORIZED, ErrorCodeEnum.NO_OPERATION_PERMISSION); + } + return ResponseResult.success(); + } + + /** + * 构建satoken的登录Id。 + * + * @return 拼接后的完整登录Id。 + */ + public static String makeLoginId(LoginUserInfo userInfo) { + StringBuilder sb = new StringBuilder(128); + sb.append("SATOKEN_LOGIN:"); + if (userInfo.getTenantId() != null) { + sb.append(userInfo.getTenantId()).append(":"); + } + sb.append(userInfo.getLoginName()).append(":").append(userInfo.getUserId()); + return sb.toString(); + } + + /** + * 获取所有的权限字列表数据。 + * + * @return 所有的权限字列表数据。 + */ + public List getAllPermCodes() { + RMap> permCodeMap = redissonClient.getMap(SA_TOKEN_PERM_CODES_KEY); + if (!permCodeMap.isExists()) { + return CollUtil.empty(String.class); + } + Set permCodeSet = new TreeSet<>(); + for (RMap.Entry> entry : permCodeMap.entrySet()) { + CollUtil.addAll(permCodeSet, permCodeMap.get(entry.getKey())); + } + return new LinkedList<>(permCodeSet); + } + + /** + * 获取所有租户运营应用的权限字列表数据。 + * + * @return 所有的权限字列表数据。 + */ + public List getAllTenantPermCodes() { + RMap> permCodeMap = redissonClient.getMap(SA_TOKEN_PERM_CODES_KEY); + if (!permCodeMap.isExists()) { + return CollUtil.empty(String.class); + } + Set permCodeSet = new TreeSet<>(); + for (RMap.Entry> entry : permCodeMap.entrySet()) { + if (!entry.getKey().equals(ApplicationConstant.TENANT_ADMIN_APP_NAME)) { + CollUtil.addAll(permCodeSet, permCodeMap.get(entry.getKey())); + } + } + return new LinkedList<>(permCodeSet); + } + + /** + * 获取所有租户管理应用的权限字列表数据。 + * + * @return 所有的权限字列表数据。 + */ + public List getAllTenantAdminPermCodes() { + RMap> permCodeMap = redissonClient.getMap(SA_TOKEN_PERM_CODES_KEY); + if (!permCodeMap.isExists()) { + return CollUtil.empty(String.class); + } + Set permCodeSet = new TreeSet<>(); + for (RMap.Entry> entry : permCodeMap.entrySet()) { + if (entry.getKey().equals(ApplicationConstant.TENANT_ADMIN_APP_NAME)) { + CollUtil.addAll(permCodeSet, permCodeMap.get(entry.getKey())); + } + } + return new LinkedList<>(permCodeSet); + } + + /** + * 收集当前服务的SaToken权限字列表,并缓存到Redis,便于统一查询。 + * + * @param event 服务应用的启动事件。 + */ + public void collectPermCodes(ApplicationReadyEvent event) { + redissonClient.getTopic(SA_TOKEN_PERM_CODES_PUBLISH_TOPIC) + .addListener(String.class, (channel, message) -> this.doCollect(event)); + this.doCollect(event); + } + + /** + * 向所有已启动的服务发送权限字同步事件。 + */ + public void publishCollectPermCodes() { + RTopic topic = redissonClient.getTopic(SA_TOKEN_PERM_CODES_PUBLISH_TOPIC); + topic.publish(null); + } + + private void doCollect(ApplicationReadyEvent event) { + Map controllerMap = event.getApplicationContext().getBeansWithAnnotation(RestController.class); + Set permCodes = new HashSet<>(); + for (Map.Entry entry : controllerMap.entrySet()) { + Object targetBean = AopTargetUtil.getTarget(entry.getValue()); + Method[] methods = ReflectUtil.getPublicMethods(targetBean.getClass()); + Arrays.stream(methods) + .map(m -> m.getAnnotation(SaCheckPermission.class)) + .filter(Objects::nonNull) + .forEach(anno -> Collections.addAll(permCodes, anno.value())); + } + RMap> permCodeMap = redissonClient.getMap(SA_TOKEN_PERM_CODES_KEY); + permCodeMap.put(applicationName, permCodes); + } + + @SuppressWarnings("unchecked") + private boolean hasPermission(String sessionId, String url) { + // 为了提升效率,先检索Caffeine的一级缓存,如果不存在,再检索Redis的二级缓存,并将结果存入一级缓存。 + Set localPermSet; + String permKey = RedisKeyUtil.makeSessionPermIdKey(sessionId); + Cache cache = cacheManager.getCache(CacheConfig.CacheEnum.USER_PERMISSION_CACHE.name()); + Assert.notNull(cache, "Cache USER_PERMISSION_CACHE can't be NULL."); + Cache.ValueWrapper wrapper = cache.get(permKey); + if (wrapper == null) { + RSet permSet = redissonClient.getSet(permKey); + localPermSet = permSet.readAll(); + cache.put(permKey, localPermSet); + } else { + localPermSet = (Set) wrapper.get(); + } + return CollUtil.contains(localPermSet, url); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-satoken/src/main/java/com/orangeforms/common/satoken/util/StpInterfaceImpl.java b/OrangeFormsOpen-MybatisFlex/common/common-satoken/src/main/java/com/orangeforms/common/satoken/util/StpInterfaceImpl.java new file mode 100644 index 00000000..d0339da9 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-satoken/src/main/java/com/orangeforms/common/satoken/util/StpInterfaceImpl.java @@ -0,0 +1,62 @@ +package com.orangeforms.common.satoken.util; + +import cn.dev33.satoken.stp.StpInterface; +import com.orangeforms.common.core.cache.CacheConfig; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.RedisKeyUtil; +import org.redisson.api.RSet; +import org.redisson.api.RedissonClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.stereotype.Component; +import org.springframework.util.Assert; + +import jakarta.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** + * 自定义权限加载接口实现类 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class StpInterfaceImpl implements StpInterface { + + @Autowired + private RedissonClient redissonClient; + @Resource(name = "caffeineCacheManager") + private CacheManager cacheManager; + + /** + * 返回一个账号所拥有的权限码集合 + */ + @SuppressWarnings("unchecked") + @Override + public List getPermissionList(Object loginId, String loginType) { + TokenData tokenData = TokenData.takeFromRequest(); + String permCodeKey = RedisKeyUtil.makeSessionPermCodeKey(tokenData.getSessionId()); + Cache cache = cacheManager.getCache(CacheConfig.CacheEnum.USER_PERM_CODE_CACHE.name()); + Assert.notNull(cache, "Cache USER_PERM_CODE_CACHE can't be NULL"); + Cache.ValueWrapper wrapper = cache.get(permCodeKey); + if (wrapper != null) { + return (List) wrapper.get(); + } + RSet permCodeSet = redissonClient.getSet(permCodeKey); + Set localPermCodeSet = permCodeSet.readAll(); + List permCodeList = new ArrayList<>(localPermCodeSet); + cache.put(permCodeKey, permCodeList); + return permCodeList; + } + + /** + * 返回一个账号所拥有的角色标识集合 (权限与角色可分开校验) + */ + @Override + public List getRoleList(Object loginId, String loginType) { + return new ArrayList<>(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-sequence/pom.xml b/OrangeFormsOpen-MybatisFlex/common/common-sequence/pom.xml new file mode 100644 index 00000000..36502af3 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-sequence/pom.xml @@ -0,0 +1,24 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-sequence + 1.0.0 + common-sequence + jar + + + + com.orangeforms + common-core + 1.0.0 + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-sequence/src/main/java/com/orangeforms/common/sequence/config/IdGeneratorAutoConfig.java b/OrangeFormsOpen-MybatisFlex/common/common-sequence/src/main/java/com/orangeforms/common/sequence/config/IdGeneratorAutoConfig.java new file mode 100644 index 00000000..327ce435 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-sequence/src/main/java/com/orangeforms/common/sequence/config/IdGeneratorAutoConfig.java @@ -0,0 +1,14 @@ +package com.orangeforms.common.sequence.config; + +import org.springframework.boot.context.properties.EnableConfigurationProperties; + +/** + * common-sequence模块的自动配置引导类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EnableConfigurationProperties({IdGeneratorProperties.class}) +public class IdGeneratorAutoConfig { + +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-sequence/src/main/java/com/orangeforms/common/sequence/config/IdGeneratorProperties.java b/OrangeFormsOpen-MybatisFlex/common/common-sequence/src/main/java/com/orangeforms/common/sequence/config/IdGeneratorProperties.java new file mode 100644 index 00000000..f20076d8 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-sequence/src/main/java/com/orangeforms/common/sequence/config/IdGeneratorProperties.java @@ -0,0 +1,20 @@ +package com.orangeforms.common.sequence.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * common-sequence模块的配置类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ConfigurationProperties(prefix = "common-sequence") +public class IdGeneratorProperties { + + /** + * 基础版生成器所需的WorkNode参数值。仅当advanceIdGenerator为false时生效。 + */ + private Integer snowflakeWorkNode = 1; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-sequence/src/main/java/com/orangeforms/common/sequence/generator/BasicIdGenerator.java b/OrangeFormsOpen-MybatisFlex/common/common-sequence/src/main/java/com/orangeforms/common/sequence/generator/BasicIdGenerator.java new file mode 100644 index 00000000..fccf75de --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-sequence/src/main/java/com/orangeforms/common/sequence/generator/BasicIdGenerator.java @@ -0,0 +1,47 @@ +package com.orangeforms.common.sequence.generator; + +import cn.hutool.core.lang.Snowflake; + +/** + * 基础版snowflake计算工具类。 + * 和SnowflakeIdGenerator相比,相同点是均为基于Snowflake算法的生成器。不同点在于当前类的 + * WorkNodeId是通过配置文件静态指定的。而SnowflakeIdGenerator的WorkNodeId是由zk生成的。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class BasicIdGenerator implements MyIdGenerator { + + private final Snowflake snowflake; + + /** + * 构造函数。 + * + * @param workNode 工作节点。 + */ + public BasicIdGenerator(Integer workNode) { + snowflake = new Snowflake(workNode, 0); + } + + /** + * 获取基于Snowflake算法的数值型Id。 + * 由于底层实现为synchronized方法,因此计算过程串行化,且线程安全。 + * + * @return 计算后的全局唯一Id。 + */ + @Override + public long nextLongId() { + return this.snowflake.nextId(); + } + + /** + * 获取基于Snowflake算法的字符串Id。 + * 由于底层实现为synchronized方法,因此计算过程串行化,且线程安全。 + * + * @return 计算后的全局唯一Id。 + */ + @Override + public String nextStringId() { + return this.snowflake.nextIdStr(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-sequence/src/main/java/com/orangeforms/common/sequence/generator/MyIdGenerator.java b/OrangeFormsOpen-MybatisFlex/common/common-sequence/src/main/java/com/orangeforms/common/sequence/generator/MyIdGenerator.java new file mode 100644 index 00000000..209d3c8e --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-sequence/src/main/java/com/orangeforms/common/sequence/generator/MyIdGenerator.java @@ -0,0 +1,24 @@ +package com.orangeforms.common.sequence.generator; + +/** + * 分布式Id生成器的统一接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface MyIdGenerator { + + /** + * 获取数值型分布式Id。 + * + * @return 生成后的Id。 + */ + long nextLongId(); + + /** + * 获取字符型分布式Id。 + * + * @return 生成后的Id。 + */ + String nextStringId(); +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-sequence/src/main/java/com/orangeforms/common/sequence/wrapper/IdGeneratorWrapper.java b/OrangeFormsOpen-MybatisFlex/common/common-sequence/src/main/java/com/orangeforms/common/sequence/wrapper/IdGeneratorWrapper.java new file mode 100644 index 00000000..441ba9d9 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-sequence/src/main/java/com/orangeforms/common/sequence/wrapper/IdGeneratorWrapper.java @@ -0,0 +1,52 @@ +package com.orangeforms.common.sequence.wrapper; + +import com.orangeforms.common.sequence.config.IdGeneratorProperties; +import com.orangeforms.common.sequence.generator.BasicIdGenerator; +import com.orangeforms.common.sequence.generator.MyIdGenerator; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import jakarta.annotation.PostConstruct; + +/** + * 分布式Id生成器的封装类。该对象可根据配置选择不同的生成器实现类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class IdGeneratorWrapper { + + @Autowired + private IdGeneratorProperties properties; + /** + * Id生成器接口对象。 + */ + private MyIdGenerator idGenerator; + + /** + * 今后如果支持更多Id生成器时,可以在该函数内实现不同生成器的动态选择。 + */ + @PostConstruct + public void init() { + idGenerator = new BasicIdGenerator(properties.getSnowflakeWorkNode()); + } + + /** + * 由于底层实现为synchronized方法,因此计算过程串行化,且线程安全。 + * + * @return 计算后的全局唯一Id。 + */ + public long nextLongId() { + return idGenerator.nextLongId(); + } + + /** + * 由于底层实现为synchronized方法,因此计算过程串行化,且线程安全。 + * + * @return 计算后的全局唯一Id。 + */ + public String nextStringId() { + return idGenerator.nextStringId(); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-sequence/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/OrangeFormsOpen-MybatisFlex/common/common-sequence/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..f917b714 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-sequence/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.orangeforms.common.sequence.config.IdGeneratorAutoConfig \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-swagger/pom.xml b/OrangeFormsOpen-MybatisFlex/common/common-swagger/pom.xml new file mode 100644 index 00000000..683c9952 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-swagger/pom.xml @@ -0,0 +1,40 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-swagger + 1.0.0 + common-swagger + jar + + + + + com.github.xiaoymin + knife4j-dependencies + ${knife4j.version} + pom + import + + + + + + + com.github.xiaoymin + knife4j-openapi3-jakarta-spring-boot-starter + + + com.orangeforms + common-core + 1.0.0 + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/common-swagger/src/main/java/com/orangeforms/common/swagger/config/SwaggerAutoConfiguration.java b/OrangeFormsOpen-MybatisFlex/common/common-swagger/src/main/java/com/orangeforms/common/swagger/config/SwaggerAutoConfiguration.java new file mode 100644 index 00000000..1ad2a2ae --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-swagger/src/main/java/com/orangeforms/common/swagger/config/SwaggerAutoConfiguration.java @@ -0,0 +1,70 @@ +package com.orangeforms.common.swagger.config; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import org.springdoc.core.models.GroupedOpenApi; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +/** + * 自动加载bean的配置对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EnableConfigurationProperties(SwaggerProperties.class) +@ConditionalOnProperty(prefix = "common-swagger", name = "enabled") +public class SwaggerAutoConfiguration { + + @Bean + public GroupedOpenApi upmsApi(SwaggerProperties p) { + String[] paths = {"/admin/upms/**"}; + String[] packagedToMatch = {p.getServiceBasePackage() + ".upms.controller"}; + return GroupedOpenApi.builder().group("用户权限分组接口") + .pathsToMatch(paths) + .packagesToScan(packagedToMatch).build(); + } + + @Bean + public GroupedOpenApi bizApi(SwaggerProperties p) { + String[] paths = {"/admin/app/**"}; + String[] packagedToMatch = {p.getServiceBasePackage() + ".app.controller"}; + return GroupedOpenApi.builder().group("业务应用分组接口") + .pathsToMatch(paths) + .packagesToScan(packagedToMatch).build(); + } + + @Bean + public GroupedOpenApi workflowApi(SwaggerProperties p) { + String[] paths = {"/admin/flow/**"}; + String[] packagedToMatch = {p.getBasePackage() + ".common.flow.controller"}; + return GroupedOpenApi.builder().group("工作流通用操作接口") + .pathsToMatch(paths) + .packagesToScan(packagedToMatch).build(); + } + + @Bean + public GroupedOpenApi onlineApi(SwaggerProperties p) { + String[] paths = {"/admin/online/**"}; + String[] packagedToMatch = {p.getBasePackage() + ".common.online.controller"}; + return GroupedOpenApi.builder().group("在线表单操作接口") + .pathsToMatch(paths) + .packagesToScan(packagedToMatch).build(); + } + + @Bean + public GroupedOpenApi reportApi(SwaggerProperties p) { + String[] paths = {"/admin/report/**"}; + String[] packagedToMatch = {p.getBasePackage() + ".common.report.controller"}; + return GroupedOpenApi.builder().group("报表打印操作接口") + .pathsToMatch(paths) + .packagesToScan(packagedToMatch).build(); + } + + @Bean + public OpenAPI customOpenApi(SwaggerProperties p) { + Info info = new Info().title(p.getTitle()).version(p.getVersion()).description(p.getDescription()); + return new OpenAPI().info(info); + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-swagger/src/main/java/com/orangeforms/common/swagger/config/SwaggerProperties.java b/OrangeFormsOpen-MybatisFlex/common/common-swagger/src/main/java/com/orangeforms/common/swagger/config/SwaggerProperties.java new file mode 100644 index 00000000..7f84999f --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-swagger/src/main/java/com/orangeforms/common/swagger/config/SwaggerProperties.java @@ -0,0 +1,45 @@ +package com.orangeforms.common.swagger.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * 配置参数对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ConfigurationProperties("common-swagger") +public class SwaggerProperties { + + /** + * 是否开启Swagger。 + */ + private Boolean enabled; + + /** + * Swagger解析的基础包路径。 + **/ + private String basePackage = ""; + + /** + * Swagger解析的服务包路径。 + **/ + private String serviceBasePackage = ""; + + /** + * ApiInfo中的标题。 + **/ + private String title = ""; + + /** + * ApiInfo中的描述信息。 + **/ + private String description = ""; + + /** + * ApiInfo中的版本信息。 + **/ + private String version = ""; +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-swagger/src/main/java/com/orangeforms/common/swagger/plugin/MyGlobalOperationCustomer.java b/OrangeFormsOpen-MybatisFlex/common/common-swagger/src/main/java/com/orangeforms/common/swagger/plugin/MyGlobalOperationCustomer.java new file mode 100644 index 00000000..4bba5b3b --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-swagger/src/main/java/com/orangeforms/common/swagger/plugin/MyGlobalOperationCustomer.java @@ -0,0 +1,194 @@ +package com.orangeforms.common.swagger.plugin; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.util.StrUtil; +import com.orangeforms.common.core.annotation.MyRequestBody; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.models.Operation; +import lombok.extern.slf4j.Slf4j; +import org.springdoc.core.customizers.GlobalOperationCustomizer; +import org.springframework.stereotype.Component; +import org.springframework.web.method.HandlerMethod; + +import java.lang.annotation.Annotation; +import java.lang.reflect.*; +import java.util.*; +import java.util.stream.Stream; + +/** + * @author xiaoymin@foxmail.com + */ +@Slf4j +@Component +public class MyGlobalOperationCustomer implements GlobalOperationCustomizer { + + /** + * 注解包路径名称 + */ + private static final String REF_KEY = "$ref"; + private static final String REF_SCHEMA_PREFIX = "#/components/schemas/"; + private final Map, Set> cacheClassProperties = MapUtil.newHashMap(); + private static final String EXTENSION_ORANGE_FORM_NAME = "x-orangeforms"; + private static final String EXTENSION_ORANGE_FORM_IGNORE_NAME = "x-orangeforms-ignore-parameters"; + + @Override + public Operation customize(Operation operation, HandlerMethod handlerMethod) { + this.handleSummary(operation, handlerMethod); + if (handlerMethod.getMethod().getParameterCount() <= 0) { + return operation; + } + Parameter[] parameters = handlerMethod.getMethod().getParameters(); + if (ArrayUtil.isEmpty(parameters)) { + return operation; + } + Map properties = MapUtil.newHashMap(); + Map extensions = MapUtil.newHashMap(); + Set ignoreFieldName = CollUtil.newHashSet(); + List required = new ArrayList<>(); + Map paramMap = getParameterDescription(handlerMethod.getMethod()); + for (Parameter parameter : parameters) { + Annotation[] annos = parameter.getAnnotations(); + if (ArrayUtil.isEmpty(annos)) { + continue; + } + long count = Stream.of(annos).filter(anno -> anno.annotationType().equals(MyRequestBody.class)).count(); + if (count > 0) { + this.handleParameterDetail(parameter, properties, paramMap, ignoreFieldName, required); + } + } + if (!properties.isEmpty()) { + extensions.put("properties", properties); + extensions.put("type", "object"); + //required字段 + if (!required.isEmpty()) { + extensions.put("required", required); + } + String generateSchemaName = handlerMethod.getMethod().getName() + "DynamicReq"; + Map orangeExtensions = MapUtil.newHashMap(); + orangeExtensions.put(generateSchemaName, extensions); + //增加扩展属性 + operation.addExtension(EXTENSION_ORANGE_FORM_NAME, orangeExtensions); + if (!ignoreFieldName.isEmpty()) { + operation.addExtension(EXTENSION_ORANGE_FORM_IGNORE_NAME, ignoreFieldName); + } + } + return operation; + } + + private void handleSummary(Operation operation, HandlerMethod handlerMethod) { + io.swagger.v3.oas.annotations.Operation operationAnno = + handlerMethod.getMethod().getAnnotation(io.swagger.v3.oas.annotations.Operation.class); + if (operationAnno == null || StrUtil.isBlank(operationAnno.summary())) { + operation.setSummary(handlerMethod.getMethod().getName()); + } + } + + private void handleParameterDetail( + Parameter parameter, + Map properties, + Map paramMap, + Set ignoreFieldName, + List required) { + Class parameterType = parameter.getType(); + String schemaName = parameterType.getSimpleName(); + //添加忽律参数名称 + ignoreFieldName.addAll(getClassFields(parameterType)); + //处理schema注解别名的情况 + Schema schema = parameterType.getAnnotation(Schema.class); + if (schema != null && StrUtil.isNotBlank(schema.name())) { + schemaName = schema.name(); + } + Map value = MapUtil.newHashMap(); + //此处需要判断parameter的基础数据类型 + if (parameterType.isPrimitive() || parameterType.getName().startsWith("java.lang")) { + //基础数据类型 + ignoreFieldName.add(parameter.getName()); + value.put("type", parameterType.getSimpleName().toLowerCase()); + //判断format + } else if (Collection.class.isAssignableFrom(parameterType)) { + //集合类型 + value.put("type", "array"); + //获取泛型 + getGenericType(parameterType, parameter.getParameterizedType()) + .ifPresent(s -> value.put("items", MapUtil.builder(REF_KEY, REF_SCHEMA_PREFIX + s).build())); + } else { + //引用类型 + value.put(REF_KEY, REF_SCHEMA_PREFIX + schemaName); + } + //补一个description + io.swagger.v3.oas.annotations.Parameter paramAnnotation = paramMap.get(parameter.getName()); + if (paramAnnotation != null) { + //忽略该参数 + ignoreFieldName.add(paramAnnotation.name()); + value.put("description", paramAnnotation.description()); + if (StrUtil.isNotBlank(paramAnnotation.example())) { + value.put("default", paramAnnotation.example()); + } + // required参数 + if (paramAnnotation.required()) { + required.add(parameter.getName()); + } + } + properties.put(parameter.getName(), value); + } + + private Optional getGenericType(Class clazz, Type type) { + Type genericSuperclass = clazz.getGenericSuperclass(); + if (genericSuperclass instanceof ParameterizedType || type instanceof ParameterizedType) { + if (type instanceof ParameterizedType) { + genericSuperclass = type; + } + ParameterizedType parameterizedType = (ParameterizedType) genericSuperclass; + Type[] actualTypeArguments = parameterizedType.getActualTypeArguments(); + return Optional.of(((Class) actualTypeArguments[0]).getSimpleName()); + } + return Optional.empty(); + } + + private Set getClassFields(Class parameterType) { + if (parameterType == null) { + return Collections.emptySet(); + } + if (cacheClassProperties.containsKey(parameterType)) { + return cacheClassProperties.get(parameterType); + } + Set fieldNames = new HashSet<>(); + try { + Field[] fields = parameterType.getDeclaredFields(); + if (fields.length > 0) { + for (Field field : fields) { + fieldNames.add(field.getName()); + } + cacheClassProperties.put(parameterType, fieldNames); + return fieldNames; + } + } catch (Exception e) { + //ignore + } + return Collections.emptySet(); + } + + private Map getParameterDescription(Method method) { + Parameters parameters = method.getAnnotation(Parameters.class); + Map resultMap = MapUtil.newHashMap(); + if (parameters != null) { + io.swagger.v3.oas.annotations.Parameter[] parameters1 = parameters.value(); + if (parameters1 != null && parameters1.length > 0) { + for (io.swagger.v3.oas.annotations.Parameter parameter : parameters1) { + resultMap.put(parameter.name(), parameter); + } + return resultMap; + } + } else { + io.swagger.v3.oas.annotations.Parameter parameter = + method.getAnnotation(io.swagger.v3.oas.annotations.Parameter.class); + if (parameter != null) { + resultMap.put(parameter.name(), parameter); + } + } + return resultMap; + } +} diff --git a/OrangeFormsOpen-MybatisFlex/common/common-swagger/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/OrangeFormsOpen-MybatisFlex/common/common-swagger/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..b94a3251 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/common-swagger/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.orangeforms.common.swagger.config.SwaggerAutoConfiguration \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/common/pom.xml b/OrangeFormsOpen-MybatisFlex/common/pom.xml new file mode 100644 index 00000000..9ba52d48 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/common/pom.xml @@ -0,0 +1,30 @@ + + + + com.orangeforms + OrangeFormsOpen + 1.0.0 + + 4.0.0 + + common + pom + + + common-dbutil + common-ext + common-core + common-log + common-dict + common-datafilter + common-satoken + common-online + common-flow-online + common-flow + common-redis + common-minio + common-sequence + common-swagger + + diff --git a/OrangeFormsOpen-MybatisFlex/pom.xml b/OrangeFormsOpen-MybatisFlex/pom.xml new file mode 100644 index 00000000..d3710c3d --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/pom.xml @@ -0,0 +1,176 @@ + + + 4.0.0 + + com.orangeforms + OrangeFormsOpen + 1.0.0 + OrangeFormsOpen + pom + + + 3.1.6 + 3.1.6 + UTF-8 + 17 + 17 + 17 + OrangeFormsOpen + + 2.10.13 + 20.0 + 2.6 + 4.4 + 1.8 + 5.2.2 + 5.0.0 + 5.8.23 + 0.12.3 + 1.2.83 + 1.1.5 + 2.9.3 + 1.18.20 + 8.0.1.Final + 7.0.1 + 3.15.4 + 8.4.5 + 2.0.0 + 4.5.0 + + 1.2.16 + 1.7.7 + 5.3.3 + + + + application-webadmin + common + + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-logging + + + + org.springframework.boot + spring-boot-starter-aop + + + + org.springframework.boot + spring-boot-starter-cache + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + org.springframework.security + spring-security-crypto + + + + org.springframework.boot + spring-boot-starter-actuator + + + + de.codecentric + spring-boot-admin-starter-client + ${spring-boot-admin.version} + + + + org.hibernate.validator + hibernate-validator + ${hibernate-validator.version} + + + + org.projectlombok + lombok + provided + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + mysql + mysql-connector-java + 8.0.22 + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + + + + + + src/main/resources + + **/*.* + + false + + + src/main/java + + **/*.xml + + false + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.0 + + + -parameters + + ${maven.compiler.target} + ${maven.compiler.source} + UTF-8 + + + org.projectlombok + lombok + ${lombok.version} + + + com.mybatis-flex + mybatis-flex-processor + ${mybatisflex.version} + + + + + + + diff --git a/OrangeFormsOpen-MybatisFlex/zz-resource/.DS_Store b/OrangeFormsOpen-MybatisFlex/zz-resource/.DS_Store new file mode 100644 index 00000000..97474e58 Binary files /dev/null and b/OrangeFormsOpen-MybatisFlex/zz-resource/.DS_Store differ diff --git a/OrangeFormsOpen-MybatisFlex/zz-resource/db-scripts/.DS_Store b/OrangeFormsOpen-MybatisFlex/zz-resource/db-scripts/.DS_Store new file mode 100644 index 00000000..5008ddfc Binary files /dev/null and b/OrangeFormsOpen-MybatisFlex/zz-resource/db-scripts/.DS_Store differ diff --git a/OrangeFormsOpen-MybatisFlex/zz-resource/db-scripts/zzdemo-online-open.sql b/OrangeFormsOpen-MybatisFlex/zz-resource/db-scripts/zzdemo-online-open.sql new file mode 100644 index 00000000..c6d3b036 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/zz-resource/db-scripts/zzdemo-online-open.sql @@ -0,0 +1,2888 @@ +/* + Navicat Premium Data Transfer + + Source Server : hw-test + Source Server Type : MySQL + Source Server Version : 80024 + Source Host : 121.37.102.103:3306 + Source Schema : zzdemo-online-open + + Target Server Type : MySQL + Target Server Version : 80024 + File Encoding : 65001 + + Date: 05/07/2024 22:26:38 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for act_evt_log +-- ---------------------------- +DROP TABLE IF EXISTS `act_evt_log`; +CREATE TABLE `act_evt_log` ( + `LOG_NR_` bigint NOT NULL AUTO_INCREMENT, + `TYPE_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TIME_STAMP_` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), + `USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DATA_` longblob, + `LOCK_OWNER_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `LOCK_TIME_` timestamp(3) NULL DEFAULT NULL, + `IS_PROCESSED_` tinyint DEFAULT '0', + PRIMARY KEY (`LOG_NR_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_ge_bytearray +-- ---------------------------- +DROP TABLE IF EXISTS `act_ge_bytearray`; +CREATE TABLE `act_ge_bytearray` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DEPLOYMENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `BYTES_` longblob, + `GENERATED_` tinyint DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_FK_BYTEARR_DEPL` (`DEPLOYMENT_ID_`), + CONSTRAINT `ACT_FK_BYTEARR_DEPL` FOREIGN KEY (`DEPLOYMENT_ID_`) REFERENCES `act_re_deployment` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_ge_bytearray +-- ---------------------------- +BEGIN; +INSERT INTO `act_ge_bytearray` VALUES ('bcd05b07-3aa9-11ef-86ec-acde48001122', 1, 'flowLeave.bpmn', 'bcd05b06-3aa9-11ef-86ec-acde48001122', 0x3C3F786D6C2076657273696F6E3D27312E302720656E636F64696E673D275554462D38273F3E0A3C646566696E6974696F6E7320786D6C6E733D22687474703A2F2F7777772E6F6D672E6F72672F737065632F42504D4E2F32303130303532342F4D4F44454C2220786D6C6E733A7873693D22687474703A2F2F7777772E77332E6F72672F323030312F584D4C536368656D612D696E7374616E63652220786D6C6E733A7873643D22687474703A2F2F7777772E77332E6F72672F323030312F584D4C536368656D612220786D6C6E733A666C6F7761626C653D22687474703A2F2F666C6F7761626C652E6F72672F62706D6E2220786D6C6E733A62706D6E64693D22687474703A2F2F7777772E6F6D672E6F72672F737065632F42504D4E2F32303130303532342F44492220786D6C6E733A6F6D6764633D22687474703A2F2F7777772E6F6D672E6F72672F737065632F44442F32303130303532342F44432220786D6C6E733A6F6D6764693D22687474703A2F2F7777772E6F6D672E6F72672F737065632F44442F32303130303532342F44492220786D6C6E733A62706D6E323D22687474703A2F2F7777772E6F6D672E6F72672F737065632F42504D4E2F32303130303532342F4D4F44454C2220786D6C6E733A64633D22687474703A2F2F7777772E6F6D672E6F72672F737065632F44442F32303130303532342F44432220786D6C6E733A64693D22687474703A2F2F7777772E6F6D672E6F72672F737065632F44442F32303130303532342F44492220747970654C616E67756167653D22687474703A2F2F7777772E77332E6F72672F323030312F584D4C536368656D61222065787072657373696F6E4C616E67756167653D22687474703A2F2F7777772E77332E6F72672F313939392F585061746822207461726765744E616D6573706163653D22687474703A2F2F666C6F7761626C652E6F72672F62706D6E222069643D226469616772616D5F666C6F774C6561766522207873693A736368656D614C6F636174696F6E3D22687474703A2F2F7777772E6F6D672E6F72672F737065632F42504D4E2F32303130303532342F4D4F44454C2042504D4E32302E787364223E0A20203C70726F636573732069643D22666C6F774C6561766522206E616D653D22E8AFB7E58187E794B3E8AFB72220697345786563757461626C653D2274727565223E0A202020203C657874656E73696F6E456C656D656E74733E0A2020202020203C666C6F7761626C653A657865637574696F6E4C697374656E6572206576656E743D22656E642220636C6173733D22636F6D2E6F72616E6765666F726D732E636F6D6D6F6E2E666C6F772E6C697374656E65722E466C6F7746696E69736865644C697374656E6572222F3E0A2020202020203C666C6F7761626C653A70726F706572746965733E0A20202020202020203C666C6F7761626C653A70726F7065727479206E616D653D22244F72616E67654469616772616D54797065222076616C75653D2230222F3E0A2020202020203C2F666C6F7761626C653A70726F706572746965733E0A202020203C2F657874656E73696F6E456C656D656E74733E0A202020203C73746172744576656E742069643D224576656E745F30346233676435222F3E0A202020203C73657175656E6365466C6F772069643D22466C6F775F306438366275772220736F757263655265663D224576656E745F3034623367643522207461726765745265663D2241637469766974795F30766A74763070222F3E0A202020203C73657175656E6365466C6F772069643D22466C6F775F317534306474372220736F757263655265663D2241637469766974795F30766A7476307022207461726765745265663D2241637469766974795F30366731347066222F3E0A202020203C73657175656E6365466C6F772069643D22466C6F775F303573316A306E2220736F757263655265663D2241637469766974795F3036673134706622207461726765745265663D2241637469766974795F30646E37753532222F3E0A202020203C656E644576656E742069643D224576656E745F30697479357767222F3E0A202020203C73657175656E6365466C6F772069643D22466C6F775F31627877637A612220736F757263655265663D2241637469766974795F30646E3775353222207461726765745265663D224576656E745F30697479357767222F3E0A202020203C757365725461736B2069643D2241637469766974795F30766A7476307022206E616D653D22E5BD95E585A52220666C6F7761626C653A61737369676E65653D22247B7374617274557365724E616D657D2220666C6F7761626C653A666F726D4B65793D227B2671756F743B666F726D49642671756F743B3A2671756F743B313830393133323633353633333438373837322671756F743B2C2671756F743B726561644F6E6C792671756F743B3A66616C73652C2671756F743B67726F7570547970652671756F743B3A2671756F743B41535349474E45452671756F743B7D223E0A2020202020203C657874656E73696F6E456C656D656E74733E0A20202020202020203C666C6F7761626C653A7461736B4C697374656E6572206576656E743D226372656174652220636C6173733D22636F6D2E6F72616E6765666F726D732E636F6D6D6F6E2E666C6F772E6C697374656E65722E466C6F77557365725461736B4C697374656E6572222F3E0A20202020202020203C666C6F7761626C653A7461736B4C697374656E6572206576656E743D226372656174652220636C6173733D22636F6D2E6F72616E6765666F726D732E636F6D6D6F6E2E666C6F772E6C697374656E65722E466C6F775461736B4E6F746966794C697374656E6572222F3E0A20202020202020203C666C6F7761626C653A7661726961626C654C6973742F3E0A20202020202020203C666C6F7761626C653A636F70794974656D4C6973742F3E0A20202020202020203C666C6F7761626C653A6F7065726174696F6E4C6973743E0A202020202020202020203C666C6F7761626C653A666F726D4F7065726174696F6E2069643D223137323031363835343036373222206C6162656C3D22E5908CE6848F2220747970653D226167726565222073686F774F726465723D2230222F3E0A20202020202020203C2F666C6F7761626C653A6F7065726174696F6E4C6973743E0A2020202020203C2F657874656E73696F6E456C656D656E74733E0A202020203C2F757365725461736B3E0A202020203C757365725461736B2069643D2241637469766974795F3036673134706622206E616D653D22E5AEA1E689B9412220666C6F7761626C653A61737369676E65653D2261646D696E2220666C6F7761626C653A666F726D4B65793D227B2671756F743B666F726D49642671756F743B3A2671756F743B313830393133323633353633333438373837322671756F743B2C2671756F743B726561644F6E6C792671756F743B3A747275652C2671756F743B67726F7570547970652671756F743B3A2671756F743B41535349474E45452671756F743B7D223E0A2020202020203C657874656E73696F6E456C656D656E74733E0A20202020202020203C666C6F7761626C653A7461736B4C697374656E6572206576656E743D226372656174652220636C6173733D22636F6D2E6F72616E6765666F726D732E636F6D6D6F6E2E666C6F772E6C697374656E65722E466C6F77557365725461736B4C697374656E6572222F3E0A20202020202020203C666C6F7761626C653A7461736B4C697374656E6572206576656E743D226372656174652220636C6173733D22636F6D2E6F72616E6765666F726D732E636F6D6D6F6E2E666C6F772E6C697374656E65722E466C6F775461736B4E6F746966794C697374656E6572222F3E0A20202020202020203C666C6F7761626C653A6F7065726174696F6E4C6973743E0A202020202020202020203C666C6F7761626C653A666F726D4F7065726174696F6E2069643D223137323031363835353530353922206C6162656C3D22E5908CE6848F2220747970653D226167726565222073686F774F726465723D2230222F3E0A202020202020202020203C666C6F7761626C653A666F726D4F7065726174696F6E2069643D223137323031363835353834383522206C6162656C3D22E9A9B3E59B9EE588B0E8B5B7E782B92220747970653D2272656A656374546F5374617274222073686F774F726465723D2230222F3E0A20202020202020203C2F666C6F7761626C653A6F7065726174696F6E4C6973743E0A20202020202020203C666C6F7761626C653A7661726961626C654C6973742F3E0A20202020202020203C666C6F7761626C653A636F70794974656D4C6973742F3E0A2020202020203C2F657874656E73696F6E456C656D656E74733E0A202020203C2F757365725461736B3E0A202020203C757365725461736B2069643D2241637469766974795F30646E3775353222206E616D653D22E5AEA1E689B9422220666C6F7761626C653A61737369676E65653D2261646D696E2220666C6F7761626C653A666F726D4B65793D227B2671756F743B666F726D49642671756F743B3A2671756F743B313830393133323633353633333438373837322671756F743B2C2671756F743B726561644F6E6C792671756F743B3A747275652C2671756F743B67726F7570547970652671756F743B3A2671756F743B41535349474E45452671756F743B7D223E0A2020202020203C657874656E73696F6E456C656D656E74733E0A20202020202020203C666C6F7761626C653A7461736B4C697374656E6572206576656E743D226372656174652220636C6173733D22636F6D2E6F72616E6765666F726D732E636F6D6D6F6E2E666C6F772E6C697374656E65722E466C6F77557365725461736B4C697374656E6572222F3E0A20202020202020203C666C6F7761626C653A7461736B4C697374656E6572206576656E743D226372656174652220636C6173733D22636F6D2E6F72616E6765666F726D732E636F6D6D6F6E2E666C6F772E6C697374656E65722E466C6F775461736B4E6F746966794C697374656E6572222F3E0A20202020202020203C666C6F7761626C653A7661726961626C654C6973742F3E0A20202020202020203C666C6F7761626C653A636F70794974656D4C6973742F3E0A20202020202020203C666C6F7761626C653A6F7065726174696F6E4C6973743E0A202020202020202020203C666C6F7761626C653A666F726D4F7065726174696F6E2069643D223137323031363835373339303322206C6162656C3D22E5908CE6848F2220747970653D226167726565222073686F774F726465723D2230222F3E0A202020202020202020203C666C6F7761626C653A666F726D4F7065726174696F6E2069643D223137323031363835373734393522206C6162656C3D22E9A9B3E59B9E2220747970653D2272656A656374222073686F774F726465723D2230222F3E0A20202020202020203C2F666C6F7761626C653A6F7065726174696F6E4C6973743E0A2020202020203C2F657874656E73696F6E456C656D656E74733E0A202020203C2F757365725461736B3E0A20203C2F70726F636573733E0A20203C62706D6E64693A42504D4E4469616772616D2069643D2242504D4E4469616772616D5F666C6F774C65617665223E0A202020203C62706D6E64693A42504D4E506C616E652062706D6E456C656D656E743D22666C6F774C65617665222069643D2242504D4E506C616E655F666C6F774C65617665223E0A2020202020203C62706D6E64693A42504D4E53686170652062706D6E456C656D656E743D224576656E745F30346233676435222069643D2242504D4E53686170655F4576656E745F30346233676435223E0A20202020202020203C6F6D6764633A426F756E6473206865696768743D2233362E30222077696474683D2233362E302220783D223138322E302220793D223237322E30222F3E0A2020202020203C2F62706D6E64693A42504D4E53686170653E0A2020202020203C62706D6E64693A42504D4E53686170652062706D6E456C656D656E743D224576656E745F30697479357767222069643D2242504D4E53686170655F4576656E745F30697479357767223E0A20202020202020203C6F6D6764633A426F756E6473206865696768743D2233362E30222077696474683D2233362E302220783D223735322E302220793D223237322E30222F3E0A2020202020203C2F62706D6E64693A42504D4E53686170653E0A2020202020203C62706D6E64693A42504D4E53686170652062706D6E456C656D656E743D2241637469766974795F30766A74763070222069643D2242504D4E53686170655F41637469766974795F30766A74763070223E0A20202020202020203C6F6D6764633A426F756E6473206865696768743D2238302E30222077696474683D223130302E302220783D223237302E302220793D223235302E30222F3E0A2020202020203C2F62706D6E64693A42504D4E53686170653E0A2020202020203C62706D6E64693A42504D4E53686170652062706D6E456C656D656E743D2241637469766974795F30366731347066222069643D2242504D4E53686170655F41637469766974795F30366731347066223E0A20202020202020203C6F6D6764633A426F756E6473206865696768743D2238302E30222077696474683D223130302E302220783D223433302E302220793D223235302E30222F3E0A2020202020203C2F62706D6E64693A42504D4E53686170653E0A2020202020203C62706D6E64693A42504D4E53686170652062706D6E456C656D656E743D2241637469766974795F30646E37753532222069643D2242504D4E53686170655F41637469766974795F30646E37753532223E0A20202020202020203C6F6D6764633A426F756E6473206865696768743D2238302E30222077696474683D223130302E302220783D223539302E302220793D223235302E30222F3E0A2020202020203C2F62706D6E64693A42504D4E53686170653E0A2020202020203C62706D6E64693A42504D4E456467652062706D6E456C656D656E743D22466C6F775F30643836627577222069643D2242504D4E456467655F466C6F775F30643836627577223E0A20202020202020203C6F6D6764693A776179706F696E7420783D223231382E302220793D223239302E30222F3E0A20202020202020203C6F6D6764693A776179706F696E7420783D223237302E302220793D223239302E30222F3E0A2020202020203C2F62706D6E64693A42504D4E456467653E0A2020202020203C62706D6E64693A42504D4E456467652062706D6E456C656D656E743D22466C6F775F31753430647437222069643D2242504D4E456467655F466C6F775F31753430647437223E0A20202020202020203C6F6D6764693A776179706F696E7420783D223337302E302220793D223239302E30222F3E0A20202020202020203C6F6D6764693A776179706F696E7420783D223433302E302220793D223239302E30222F3E0A2020202020203C2F62706D6E64693A42504D4E456467653E0A2020202020203C62706D6E64693A42504D4E456467652062706D6E456C656D656E743D22466C6F775F303573316A306E222069643D2242504D4E456467655F466C6F775F303573316A306E223E0A20202020202020203C6F6D6764693A776179706F696E7420783D223533302E302220793D223239302E30222F3E0A20202020202020203C6F6D6764693A776179706F696E7420783D223539302E302220793D223239302E30222F3E0A2020202020203C2F62706D6E64693A42504D4E456467653E0A2020202020203C62706D6E64693A42504D4E456467652062706D6E456C656D656E743D22466C6F775F31627877637A61222069643D2242504D4E456467655F466C6F775F31627877637A61223E0A20202020202020203C6F6D6764693A776179706F696E7420783D223639302E302220793D223239302E30222F3E0A20202020202020203C6F6D6764693A776179706F696E7420783D223735322E302220793D223239302E30222F3E0A2020202020203C2F62706D6E64693A42504D4E456467653E0A202020203C2F62706D6E64693A42504D4E506C616E653E0A20203C2F62706D6E64693A42504D4E4469616772616D3E0A3C2F646566696E6974696F6E733E, 0); +INSERT INTO `act_ge_bytearray` VALUES ('be002878-3aa9-11ef-86ec-acde48001122', 1, 'flowLeave.flowLeave.png', 'bcd05b06-3aa9-11ef-86ec-acde48001122', 0x89504E470D0A1A0A0000000D494844520000031E000001540806000000AA66EA1D0000199149444154785EEDDD79B01C65BD37F00BB85CB7927B8572A554D492F20F4BFFD09257CB7A55AED7124B2C856C040C2698206840B2A86099605C7005028658D79245F00A1AADC06BBD0889318A2C82685834206B02312789D9902472A56FFFBA32A9C93327E19090D3CF99E7F3A9FAD63933D3D3DDC9F9F5FCFA99E9EEF9977F01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080A7A4AAAA67DD77DF7D57DC70C30DFF58B4685175EDB5D7CA30A7FE7F7F62E9D2A58F2C5EBCF8A8F4EFD3EFD45FFB517FEAAFCD945C7F00C5A99BEE95F58B7EB57AF5EA6ACB962DD5B66DDB649813FFEFF1FFBF64C9928D75233E32FD1BF533F5D77ED49FFA6B3325D71F4071E29DBE78D14F9B810C7F56AD5AB5B66EBC37A77FA37EA6FEF289FA93365362FD0114270E2FF04E5F1E89BF43DD78B7A67FA37EA6FEF289FA93365362FD0114278EB14D1B80B497F87BA47FA37EA6FEF28AFA9336535AFD011467A88DF7D10DABAAFB7EF7FDEACEEBCE6A12BFC77DE974B27729ADF1AABFBCA2FE068FFA1B9E94567F00C5194AE3DDBCFEE1EA8E6B3E5FFDF1FF4DDF29715F3C964E2F7B9ED21AAFFACB2BEAAF37EA6FF8525AFD011467288D77C59D0B7B9A6E272BEFBCAA677AD9F394D678D55F5E517FBD517FC397D2EA0FA0384369BC7FFAE5D93D0DB793782C9D5EF63CA5355EF59757D45F6FD4DFF0A5B4FA0328CE501AEF1DD7CEEA69B89DC463E9F4B2E729ADF1AABFBCA2FE7AA3FE862FA5D51F407134DEBC525AE3557F7945FDF546FD0D5F4AAB3F80E20CA5F1C6555CD286DB493C964E2F7B9ED21AAFFACB2BEAAF37EA6FF8525AFD011467288DF79EEBCFEF69B89DC463E9F4B2E729ADF1AABFBCA2FE7AA3FE862FA5D51F407186D278D73DBCACBAE3175FE869BA715F3C964E2F7B9ED21AAFFACB2BEAAF37EA6FF8525AFD011467288D3772FF2D97F434DEB82F9D4EF62EA5355EF59757D4DFE0517FC393D2EA0FA038436ABC5BB756F7FC765E4FE38DFBE2B19EE9658F535AE3557F7945FD0D12F5376C29ADFE008AF3648D37BE99F7EEEBE7F634DD4EE231DFDEFBF4A5B4C6ABFEF28AFADB39EA6F78535AFD011467978D77EBD66AD53D8BABDBFFFFE77A9A6D9A9826A6F5EEDFDEA7B4C6ABFEF28AFADB1EF5D74A4AAB3F80E20CD6789FEC5DBE5DC5BB7F7B9FD21AAFFACB2BEA4FFDB599D2EA0FA0388335DEA1BCCBB7ABC473D3F9C9D0535AE3557F7945FDA9BF36535AFD011467B0C69B36D3A79A747E32F494D678D55F5E517FEAAFCD94567F00C519ACF14A7B29ADF1AABFBCA2FEA4CD94567F7B6AC28409078E1933E6E8D1A3479F57FF5C54E7FE3A8FD5A9B6FF8CDB8BB63F7E744C9FCE03789A6CDCB8F1DF172E5C78D6F9E79FFFC7D9B367AF9D3973E696934E3AE989D820A74C99F2F8B469D3369D71C6190F9D75D659574D9F3EFD7DF553F64BE751128D37AF94D678D55F5E517FD2664AABBFA76AECD8B1FF51EFCB2CA8B36DFB2063A889E917C4F3D379027BE8A69B6E9A72CE39E73C3C79F2E4AA1E6C54575E796575EBADB756F7DE7B6FB56EDDBA2AC4CFB81DF7C7E33366CC7862E2C489DBEA01C835E3C68D3B349D670934DEBC525AE3557F7945FD499B29ADFE86AA1E301C5E0F1C6E1C6440B127B931E6972E0318A265CB96BDFF3BDFF9CE231FFFF8C7AB9FFCE427D59A356B9A41C650C5F4F1BC7A00F28FD34E3BED8A7A833C285D463FD378F34A698D57FDE515F5276DA6B4FA7B3213264CF8D7D1A3475F500F169AA336BA73EAA9A756975D76D96EDF608DC763BAF4B931BF986FCC3F5D26B00BF5F675C0CF7FFEF38531E0B8F8E28BABCD9B37EF3CA2788AE2F9319F7A437C6CFCF8F11F4A97D7AF34DEBC525AE3557F7945FD499B29ADFE76A71E1C1C3276ECD83F760F18C68D1B57CD9F3FBF5AB97265BA0BB35B317D3C2F9E9F0C40FE10CB49970D24EAEDE8C04B2FBDF4EE934F3EB9BAEFBEFBD26D6CAFC4FCEAC1CC96891327CE4E97DB8F34DEBC525AE3557F7945FD499B29ADFE76A51E701C56E7E1EE41C2D9679F5DAD58B122DD65794AE2F9319F64F0B1229697AE03B05DBDED1C78DE79E7AD3FF3CC33ABF5EBD7A7DBD5D322E63B73E6CCC78E3FFEF84BD2E5F71B8D37AF94D678D55F5E517FD2664AABBFC16CFFA463C7A0233EA558B87061BA9BB257627EC9A71F2B7CF20183A8B797032EBDF4D27B62D0112F52FB52CC7FDAB4691B8E3DF6D833D2F5E8271A6F5E29ADF1AABFBCA2FEA4CD94567FA938E7A2FBF0AA134E38A1BAEDB6DBD2DD93A745CC37E6DF35F8F883733E2011E7749C72CA29FBEC938E542C67D2A4499BEA0DF283E9BAF40B8D37AF94D678D55F5E517FD2664AABBFD4F613C9777CD2B1AF061D1D31FFEE4F3E62F9E93A41B1EA0DE4C83891FCE93EA7E3C9C4F2C68F1FBFFE98638E39385DA77EA0F1E695D21AAFFACB2BEA4FDA4C69F5D76DFB2573FFD919045C75D555E9EEC83E11CBE9FAD4E39F2EB50BDBC52573E3AA536D98376FDE23F506796EBA4EFD40E3CD2BA5355EF59757D49FB499D2EAAFDB98AEEFE98813C0875372C2F98DE9BA4171E2CB01E3D38E4D9B36A5DBCBB088E51E77DC711BFBF14B0635DEBC525AE3557F7945FD499B29ADFE3A468D1A754467C73F0E7DDADBAB573D55B1BCEE43AE627DD27584A2C437922F58B020DD5686D525975C726FBD41CE4FD76DA4D378F34A698D57FDE515F5276DA6B4FAEBA8F72D167476FAE3FB36DA10CBEDFAD46341BA8E508C4D9B36BD68CA9429D5C0C040BA9D0CAB7AF9FF336EDCB8D5B366CDDA3F5DC7914CE3CD2BA5355EF59757D49FB499D2EA2FD4FB15FF56EFE86FEBECF40FF7A71D1DB1DCAE81C7B658AF745DA108575F7DF5EC993367A6DB482B264D9AF440BD41FE9F741D7354AFE72FEBFCDFF4FE94C69B57FAA5F1AABF9119F5276DA65FEAAF632875583F7E746787FFD4534F4D773B86552CBF6BF07174BAAE5084B973E7DE7EE59557A6DB472B2EBCF0C23FD41BE357D375CC51D78BC76E5FF834DEBCD22F8D57FD8DCCA83F6933FD527F1D43A9C3FAFEB99DE97EF0831FA4BB1DC32A96DFB5CE73D3758522CC9E3D7BEDADB7DE9A6E1FAD58BA74E9B2D1A3472F4CD731475D2F1EBB7DE1D378F34ABF345EF53732A3FEA4CDF44BFD750CA50EC78E1DBBB8F3F82DB7DC92EE760CAB587E675D62BDBAD7138A3163C68C2DC3FDDD1DBBB27CF9F238D4EA77E93AE6689017BC415FF834DEBCD22F8D7790BA537F2320EA4FDA4CBFD45FC720F5D75387F5CF873AF7B7BDAF13CBEF5AC787927F0E9461CA94294FFCED6F7F4BB78F56AC5BB76E73BD313E9CAE638E0679A14BD3BCF069BC79A55F1AEF20F59646FD6518F5276DA65FEAAF6390BA4B1375F8F7CEEDB6F77562F99D75193B76ECA6F4DF034538EEB8E3AAC71F7F3CDD3E5A51AFC7A6415E384674726FBC5BB76EEDB9AF9F93FE7DFA3D39D7DFF5D75F5F9D7BEEB93DF777F2A73FFDA9FAE94F7FDAFCFEFBDFFFBE5AB9726553AF37DD7453B57AF5EA9EE94742D2BF4FBF27E7FA8B945683E9DFA7B4B4BDAF13CBEF5A9FFF49F7C7A00893274F7EBCED77013AD6AC59F3973123FF138F5F8E1941871A5C7DF5D5D501071C503DFBD9CFEEC9339FF9CC6AC3860D3B4D1F5F3479C8218754AF7CE52BAB97BDEC65715E4ECF3C734EBFBCE33748DD655F7F37DC704375CA29A75453A74E6D72D86187C5DFA28ACB7977EE8BC77FFBDBDF36D3CF9B37AF3AF0C0039BDFA3DEBEFCE52F37BF3FEB59CFAA2EBFFCF29EF98F84A8BF76537A0DF64BFD750C527F3D75189F2C74EE6F7B5FC7271E503BFDF4D337B57DDC63C75D77DD75CB98917B8EC74E0DB723B7C69BE6AF7FFD6B75DA69A7559FFAD4A776CAE1871FDE34E574FA68B673E6CCA93EFAD18F360D7BA435DF7E69BC23B1FE7EF8C31F56FBEDB75F3571E2C426471D755475F0C10757A3478FDE71DFFEFBEFDF5CF9E557BFFA5575C2092754CF7FFEF3AB1FFDE847D5EB5FFFFAEAEB5FFF7A339FE73EF7B9557CE1E9AF7FFDEB6AD9B2653BE61FEF42D7FFE4EA79CF7B5EBC89D1B3FC1CA2FEDACDBEAAC15FFCE2174DED75126FDA1C7AE8A1555C31325D8736D32FF5D731943A1CE31C0FC8CB99679EB92297AB5A5D77DD758B46E055AD7A5EE8BAE5D678BB133B670F3CF04075CE39E754DFFCE637AB6F7FFBDB3BF2E637BFB9FAC0073ED01C5A30D82105314DFDCFAB3EFFF9CFF73C9673FAA5F18EC4FAFBFBDFFF5ECD9831A37AD7BBDE55BDE73DEFA9DEF296B73435F4F6B7BFBDB9FDEE77BFBBFACC673E536DDEBCB9FAD9CF7E567DE4231F6976F0E25098D8E97BEB5BDFDABC231DF78D1F3FBED9B99B3B77EE8EF9C7BBD631BFC879E79DD7B3FC1CA2FEDACDBEAAC16BAEB9A6994FBC667EEB5BDFAA66CF9E5D1D74D041D50B5FF8C2EAB1C71EEB598FB6D22FF5D731943A74552BC8CCAC59B3AECAE57B3CE6CC99B360CCC8F91E8F5DBED075CBADF176A71E74EEF42EDDAE128D3A7DEE11471CD13C16CD387D2CE7F44BE31DA9F53779F2E4EA55AF7A55155F5A7AFCF1C73735F4894F7CA2B91DF7C7E0A133ED77BFFBDDEA452F7A5175CF3DF7347516EF2047C38E9DBE78DEC9279FBC63DA3824300E8979DBDBDED6FC7CE31BDFD8B3EC1CA2FEDACFBEA8C1CEC0E32B5FF94A73FBD1471F6D0633518B31D849D7A1ADF44BFD750CA50EC7F81E0FC84BFD62FB9FF58EE513E906D282C7C78D1BB76CCC08F9E6F2A1CAB1F17672FBEDB737EFE4C5B7A9C6A102175D7451D33C2FB8E0826AE1C285D59BDEF4A6EAFBDFFF7E75C71D77ECF4BCBBEFBEBB391CE1631FFB58337D3C379D77AEE9B7C6FB6472ABBFD8A97BF9CB5FDED4CEFBDFFFFEA67EA209C7ED3867A8B3D377DB6DB755C71E7BEC8EC16D7A98CBA44993769A6FD4694C3B7FFEFCEAC4134F6C7EFFCD6F7ED3B3FCB6A3FEDACFBEA8C1CEC0E3052F7841F5E217BFB8393C2B6EEFEEC4F536525AFD8531197D73F9D4A9539FE81A78F8E672CA346BD6ACFDEB17D06D030303E93632AC56AE5C797DBD21AE8AF549D77124CBB1F176E7B39FFD6CD320E3B081B8824BFC1EE76FBCE31DEF68DEAD5BB26449CF73EA0162F59CE73CA7393F249A719C0B1227CDA5D3E598D21A6F6EF5173B75AF78C52B9A9F1FFEF08777D45EF7FD315D67F0103B7831804877FAE2F8FAEE2BB2BDF39DEF6CA6BFE28A2B9A7390E2F7091326F42CBFEDA8BFF6B32F6AB033F088D7CD38142B5E43E3DC91481CD79FAE435B29ADFE42DDAFFEADDEB7D8D6D9E15FB16245BAFB312C62B95D838E6DB15EE9BA4231A64F9F7E4DBC88B6E98B5FFCE2E5F5C6383F5DB7912EC7C69BE6C73FFE71B3E3F6A52F7DA9699E9138BCE0AEBBEEEA99364ECE8CC7E3B084B81D1F1DC7ED78314DA7CD31A535DEDCEA2F76EA5EFBDAD756B366CD6A4EE4AD57B13AFDF4D39BDBAF79CD6B76ECF4FDF9CF7FAEBEF18D6F347518B707DBE98B01469C6314751A270CC7BCBA93E349E6EAAFFDEC8B1A4C0FB58A9C7FFEF9CD7DF10972BA0E6DA5B4FAEBA8FB531CC6DDF4A9F854B40DB1DCAE81C782741DA128F5C8FBD0FA05F81F9B366D4AB79561B17EFDFA9BEB0D7120D6235DB7912EC7C6DB49FDFFDE0C1CE258E47A55AB4F7FFAD33B06157128559C2819871B74A68FEBD9C76576DFF08637546BD7AEDD717F5C11A6F3BCDCBF17A4B4C69B5BFDC58E5EECC8BDF7BDEF6DCEC7A857B119F4C6EDB8BFFBF095CEF1F5F17BECF4C515866247AFB3D31757631B356A54357DFAF4663E71926F5C0635128FC57D0E7569576EF517D91735D81978BCEF7DEF6B061F5FF8C217AAD7BDEE75CD7DF158BA0E6DA5B4FAEBA8FF46477476FAE313FBE1FED423963776ECD81D8759C5FAA4EB08C5A95F40AFB8F8E28BD3ED6558D4CBFE51BD319E9BAE533FC8B1F176B27CF9F2EA19CF784673B8415C8525AE515FAF7275F3CD37374DF5A52F7D6973D596381724AE7C15EF2AC7C995F7DE7BEF4EF3D9B871E38E435D4E3AE9A49EE5E494D21A6F6EF517971F5DBC78F18EDFEB55ACEEBFFFFEE676AC6BE7FB13E2677CB9695C19280E5D8943FBA2FEEAE6DD1C3F1F173788EF55F8DCE73E57BDE4252F690E69E93E89F7C1071F6CBE9F26CE534AD7A1CDA8BFF6F374D7E019679CD17339DDA8BD18B0447DA6CB6F33A5D55FB77A1FE3C6CE8EFFD9679F9DEE86EC53B1BCAE4F3B6E4CD70D8A74CC31C71C3C61C284C786FB3AD7B7DC724B1C623510CB4FD7A91FE4D878BB133B68F1330E29882F068C01445C9125EE8B4FC0AEBBEEBAE6F7186CC471D0835D5A3712CFF9E4273FD91C9E903E96534A6BBC39D75F9C3FB4AB43FABEF7BDEF55AF7EF5AB9B816C5C7DEDAB5FFD6AF597BFFCA579EC6B5FFB5A75E49147362703C73B89E973738EFACB2BA5D56069F5D7AD1E301E5EEF6BFCB33300B8EAAAABD2DD917D2296D335E8F867AC47BA6E50AC7AC7F24393274FDE1287E00C878181815FD51BE283753E98AE4BBFC8BDF19696D21AAFFACB2BEA4FDA4C69F5971A3D7AF4059D41401C72158712EF4B31FFEE43AC62F9E93A41F1264E9C387BE6CC998FC58BD4BEB475EBD6BBEA0DFF77F546F9D9741DFA89C69B574A6BBCEA2FAFA83F6933A5D55F6AC28409FF5A0F00FED01908C4393BFB6AF011F3AD97B7E31396586E2C3F5D27A076FCF1C75F326DDAB40DFBEA938F8181812531E8A837C4FF4A97DD6F34DEBC525AE3557F7945FD499B29ADFE0653EF771C526745F7271FF1BD554FA7985FF7271DDB977748BA2E4097638F3DF68C8913276E7ABACFF9D87E4EC743FDFE494787C69B574A6BBCEA2FAFA83F6933A5D5DFAED4FB1F87750F3E227102F8DE5EED2A9E9F9C48DE0C3A6279E93A0083A837980F8E1F3F7EFDBC79F31ED9BC7973BA8D3D251B366CB869FBD5AB0662BEE9B2FA95C69B574A6BBCEA2FAFA83F6933A5D5DFEEC4271063BA0EBB8AC4A71FF17D1B2B57AE4C7761762BA68FE7259F72348757C572D26503BB516F4807D51BCEB9C71D77DCC68B2EBAE8DE356BD63C9E6E74BBF1F8C30F3F7CFDECD9B39B2B57C57C627EE932FA99C69B574A6BBCEA2FAFA83F6933A5D5DF9389732EB69F709E0E18AA534F3DB5BAECB2CBAA5B6FBDB5B9AAE3BA75EB9A9D9AF819B7E3FE787CEAD4A93DCF8DF9C57C9DD3017B21BEDCAFDE98E6D7038781134F3CF1C10B2FBCF0B6A54B972E5BBE7CF9436BD7AE7DB4DE1E370F0C0CDC77E79D77DE52BFB85D3B67CE9C05F57396D5CFF96B3CAF1FBF1C702834DEBC525AE3557F7945FD499B29ADFE866AFBA576777CCFC75EE64697CC85A7D77EA3468D7A7BBD617DA51ED12FAC37B2F8D6F1CEB192F1F3E6B83F1E8FE962FA740625D178F34A698D57FDE515F5276DA6B4FA7BAAEAFD96FFA8F76116D4D936C880627789E917C4F3D379020C2B8D37AF94D678D55F5E517FD2664AABBF3D3561C28403EB81C4D1A3478F3EAFFEB9A8CEFD751EDB3EC8889F717BD1F6C78F8EE9D37900B442E3CD2BA5355EF59757D49FB499D2EA0FA0381A6F5E29ADF1AABFBCA2FEA4CD94567F00C5D178F34A698D57FDE515F5276DA6B4FA03288EC69B574A6BBCEA2FAFA83F6933A5D51F407134DEBC525AE3557F7945FD499B29ADFE008AA3F1E695D21AAFFACB2BEA4FDA4C69F507501C8D37AF94D678D55F5E517FD2664AAB3F80E268BC79A5B4C6ABFEF28AFA9336535AFD011447E3CD2BA5355EF59757D49FB499D2EA0FA0381A6F5E29ADF1AABFBCA2FEA4CD94567F00C5D178F34A698D57FDE515F5276DA6B4FA03288EC69B574A6BBCEA2FAFA83F6933A5D51F407134DEBC525AE3557F7945FD499B29ADFE008AA3F1E695D21AAFFACB2BEA4FDA4C69F507501C8D37AF94D678D55F5E517FD2664AAB3F80E268BC79A5B4C6ABFEF28AFA9336535AFD011447E3CD2BA5355EF59757D49FB499D2EA0FA0388B162D7A62CB962D3D0D40863FF5DFE191BAF16E4DFF46FD4CFDE513F5276DA6C4FA0328CED2A54B1F59BD7A754F1390E1CF830F3EF8DF75E3BD39FD1BF533F5974FD49FB49912EB0FA0388B172F3E6AC992251B57AD5AB5D63B7FEDA4FE7F5FF5C0030F5C5E37DD87EA1C99FE8DFA99FA6B3FEA4FFDB59992EB0FA048F1621FEF34D5D916C7D8CAB027FEDFE3FFBFC8A61BFFEEEDFF7EF5D74ED49FFA6B3345D71F000000000000000000000000000000000000000000000000000000C06EFD2FE154B1E7871DBABA0000000049454E44AE426082, 1); +COMMIT; + +-- ---------------------------- +-- Table structure for act_ge_property +-- ---------------------------- +DROP TABLE IF EXISTS `act_ge_property`; +CREATE TABLE `act_ge_property` ( + `NAME_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `VALUE_` varchar(300) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REV_` int DEFAULT NULL, + PRIMARY KEY (`NAME_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_ge_property +-- ---------------------------- +BEGIN; +INSERT INTO `act_ge_property` VALUES ('batch.schema.version', '7.0.1.1', 1); +INSERT INTO `act_ge_property` VALUES ('cfg.execution-related-entities-count', 'true', 1); +INSERT INTO `act_ge_property` VALUES ('cfg.task-related-entities-count', 'true', 1); +INSERT INTO `act_ge_property` VALUES ('common.schema.version', '7.0.1.1', 1); +INSERT INTO `act_ge_property` VALUES ('entitylink.schema.version', '7.0.1.1', 1); +INSERT INTO `act_ge_property` VALUES ('eventsubscription.schema.version', '7.0.1.1', 1); +INSERT INTO `act_ge_property` VALUES ('identitylink.schema.version', '7.0.1.1', 1); +INSERT INTO `act_ge_property` VALUES ('job.schema.version', '7.0.1.1', 1); +INSERT INTO `act_ge_property` VALUES ('next.dbid', '1', 1); +INSERT INTO `act_ge_property` VALUES ('schema.history', 'create(7.0.1.1)', 1); +INSERT INTO `act_ge_property` VALUES ('schema.version', '7.0.1.1', 1); +INSERT INTO `act_ge_property` VALUES ('task.schema.version', '7.0.1.1', 1); +INSERT INTO `act_ge_property` VALUES ('variable.schema.version', '7.0.1.1', 1); +COMMIT; + +-- ---------------------------- +-- Table structure for act_hi_actinst +-- ---------------------------- +DROP TABLE IF EXISTS `act_hi_actinst`; +CREATE TABLE `act_hi_actinst` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT '1', + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CALL_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ACT_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ACT_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `ASSIGNEE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `START_TIME_` datetime(3) NOT NULL, + `END_TIME_` datetime(3) DEFAULT NULL, + `TRANSACTION_ORDER_` int DEFAULT NULL, + `DURATION_` bigint DEFAULT NULL, + `DELETE_REASON_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_HI_ACT_INST_START` (`START_TIME_`), + KEY `ACT_IDX_HI_ACT_INST_END` (`END_TIME_`), + KEY `ACT_IDX_HI_ACT_INST_PROCINST` (`PROC_INST_ID_`,`ACT_ID_`), + KEY `ACT_IDX_HI_ACT_INST_EXEC` (`EXECUTION_ID_`,`ACT_ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_hi_actinst +-- ---------------------------- +BEGIN; +INSERT INTO `act_hi_actinst` VALUES ('0669cc29-3aab-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', '0669cc28-3aab-11ef-86ec-acde48001122', 'Activity_0vjtv0p', '0669cc2a-3aab-11ef-86ec-acde48001122', NULL, '录入', 'userTask', 'admin', '2024-07-05 16:46:09.319', '2024-07-05 16:46:18.402', 1, 9083, NULL, ''); +INSERT INTO `act_hi_actinst` VALUES ('0bd9662c-3aab-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', '0669cc28-3aab-11ef-86ec-acde48001122', 'Flow_1u40dt7', NULL, NULL, NULL, 'sequenceFlow', NULL, '2024-07-05 16:46:18.439', '2024-07-05 16:46:18.439', 1, 0, NULL, ''); +INSERT INTO `act_hi_actinst` VALUES ('0bdf0b7d-3aab-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', '0669cc28-3aab-11ef-86ec-acde48001122', 'Activity_06g14pf', '0bdf328e-3aab-11ef-86ec-acde48001122', NULL, '审批A', 'userTask', 'admin', '2024-07-05 16:46:18.476', NULL, 2, NULL, NULL, ''); +INSERT INTO `act_hi_actinst` VALUES ('e1fbee32-3aaa-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Event_04b3gd5', NULL, NULL, NULL, 'startEvent', NULL, '2024-07-05 16:45:08.201', '2024-07-05 16:45:08.205', 1, 4, NULL, ''); +INSERT INTO `act_hi_actinst` VALUES ('e1fcd893-3aaa-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Flow_0d86buw', NULL, NULL, NULL, 'sequenceFlow', NULL, '2024-07-05 16:45:08.207', '2024-07-05 16:45:08.207', 2, 0, NULL, ''); +INSERT INTO `act_hi_actinst` VALUES ('e1fcd894-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Activity_0vjtv0p', 'e200f745-3aaa-11ef-86ec-acde48001122', NULL, '录入', 'userTask', 'admin', '2024-07-05 16:45:08.207', '2024-07-05 16:45:10.069', 3, 1862, NULL, ''); +INSERT INTO `act_hi_actinst` VALUES ('e31e4e2b-3aaa-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Flow_1u40dt7', NULL, NULL, NULL, 'sequenceFlow', NULL, '2024-07-05 16:45:10.104', '2024-07-05 16:45:10.104', 1, 0, NULL, ''); +INSERT INTO `act_hi_actinst` VALUES ('e322bafc-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Activity_06g14pf', 'e322e20d-3aaa-11ef-86ec-acde48001122', NULL, '审批A', 'userTask', 'admin', '2024-07-05 16:45:10.133', '2024-07-05 16:45:36.454', 2, 26321, NULL, ''); +INSERT INTO `act_hi_actinst` VALUES ('f2d8563f-3aaa-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Flow_05s1j0n', NULL, NULL, NULL, 'sequenceFlow', NULL, '2024-07-05 16:45:36.489', '2024-07-05 16:45:36.489', 1, 0, NULL, ''); +INSERT INTO `act_hi_actinst` VALUES ('f2dcc310-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Activity_0dn7u52', 'f2dcc311-3aaa-11ef-86ec-acde48001122', NULL, '审批B', 'userTask', 'admin', '2024-07-05 16:45:36.518', '2024-07-05 16:45:58.241', 2, 21723, 'Change activity to Activity_06g14pf', ''); +INSERT INTO `act_hi_actinst` VALUES ('ffef78e5-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'ffef51d3-3aaa-11ef-86ec-acde48001122', 'Activity_06g14pf', 'ffef78e6-3aaa-11ef-86ec-acde48001122', NULL, '审批A', 'userTask', 'admin', '2024-07-05 16:45:58.451', '2024-07-05 16:46:09.095', 1, 10644, 'Change activity to Activity_0vjtv0p', ''); +COMMIT; + +-- ---------------------------- +-- Table structure for act_hi_attachment +-- ---------------------------- +DROP TABLE IF EXISTS `act_hi_attachment`; +CREATE TABLE `act_hi_attachment` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DESCRIPTION_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `URL_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CONTENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TIME_` datetime(3) DEFAULT NULL, + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_hi_comment +-- ---------------------------- +DROP TABLE IF EXISTS `act_hi_comment`; +CREATE TABLE `act_hi_comment` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TIME_` datetime(3) NOT NULL, + `USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ACTION_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `MESSAGE_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `FULL_MSG_` longblob, + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_hi_detail +-- ---------------------------- +DROP TABLE IF EXISTS `act_hi_detail`; +CREATE TABLE `act_hi_detail` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ACT_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `VAR_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REV_` int DEFAULT NULL, + `TIME_` datetime(3) NOT NULL, + `BYTEARRAY_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DOUBLE_` double DEFAULT NULL, + `LONG_` bigint DEFAULT NULL, + `TEXT_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TEXT2_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_HI_DETAIL_PROC_INST` (`PROC_INST_ID_`), + KEY `ACT_IDX_HI_DETAIL_ACT_INST` (`ACT_INST_ID_`), + KEY `ACT_IDX_HI_DETAIL_TIME` (`TIME_`), + KEY `ACT_IDX_HI_DETAIL_NAME` (`NAME_`), + KEY `ACT_IDX_HI_DETAIL_TASK_ID` (`TASK_ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_hi_entitylink +-- ---------------------------- +DROP TABLE IF EXISTS `act_hi_entitylink`; +CREATE TABLE `act_hi_entitylink` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `LINK_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` datetime(3) DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PARENT_ELEMENT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REF_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REF_SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REF_SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ROOT_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ROOT_SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HIERARCHY_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_HI_ENT_LNK_SCOPE` (`SCOPE_ID_`,`SCOPE_TYPE_`,`LINK_TYPE_`), + KEY `ACT_IDX_HI_ENT_LNK_REF_SCOPE` (`REF_SCOPE_ID_`,`REF_SCOPE_TYPE_`,`LINK_TYPE_`), + KEY `ACT_IDX_HI_ENT_LNK_ROOT_SCOPE` (`ROOT_SCOPE_ID_`,`ROOT_SCOPE_TYPE_`,`LINK_TYPE_`), + KEY `ACT_IDX_HI_ENT_LNK_SCOPE_DEF` (`SCOPE_DEFINITION_ID_`,`SCOPE_TYPE_`,`LINK_TYPE_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_hi_identitylink +-- ---------------------------- +DROP TABLE IF EXISTS `act_hi_identitylink`; +CREATE TABLE `act_hi_identitylink` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `GROUP_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` datetime(3) DEFAULT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_HI_IDENT_LNK_USER` (`USER_ID_`), + KEY `ACT_IDX_HI_IDENT_LNK_SCOPE` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_HI_IDENT_LNK_SUB_SCOPE` (`SUB_SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_HI_IDENT_LNK_SCOPE_DEF` (`SCOPE_DEFINITION_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_HI_IDENT_LNK_TASK` (`TASK_ID_`), + KEY `ACT_IDX_HI_IDENT_LNK_PROCINST` (`PROC_INST_ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_hi_identitylink +-- ---------------------------- +BEGIN; +INSERT INTO `act_hi_identitylink` VALUES ('06700dbb-3aab-11ef-86ec-acde48001122', NULL, 'assignee', 'admin', '0669cc2a-3aab-11ef-86ec-acde48001122', '2024-07-05 16:46:09.360', NULL, NULL, NULL, NULL, NULL); +INSERT INTO `act_hi_identitylink` VALUES ('0bdf328f-3aab-11ef-86ec-acde48001122', NULL, 'assignee', 'admin', '0bdf328e-3aab-11ef-86ec-acde48001122', '2024-07-05 16:46:18.477', NULL, NULL, NULL, NULL, NULL); +INSERT INTO `act_hi_identitylink` VALUES ('e1fb51eb-3aaa-11ef-86ec-acde48001122', NULL, 'starter', 'admin', NULL, '2024-07-05 16:45:08.198', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL); +INSERT INTO `act_hi_identitylink` VALUES ('e2014566-3aaa-11ef-86ec-acde48001122', NULL, 'assignee', 'admin', 'e200f745-3aaa-11ef-86ec-acde48001122', '2024-07-05 16:45:08.236', NULL, NULL, NULL, NULL, NULL); +INSERT INTO `act_hi_identitylink` VALUES ('e2014567-3aaa-11ef-86ec-acde48001122', NULL, 'participant', 'admin', NULL, '2024-07-05 16:45:08.236', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL); +INSERT INTO `act_hi_identitylink` VALUES ('e2fd319a-3aaa-11ef-86ec-acde48001122', NULL, 'participant', 'admin', NULL, '2024-07-05 16:45:09.887', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL); +INSERT INTO `act_hi_identitylink` VALUES ('e322e20e-3aaa-11ef-86ec-acde48001122', NULL, 'assignee', 'admin', 'e322e20d-3aaa-11ef-86ec-acde48001122', '2024-07-05 16:45:10.134', NULL, NULL, NULL, NULL, NULL); +INSERT INTO `act_hi_identitylink` VALUES ('f2dcea22-3aaa-11ef-86ec-acde48001122', NULL, 'assignee', 'admin', 'f2dcc311-3aaa-11ef-86ec-acde48001122', '2024-07-05 16:45:36.519', NULL, NULL, NULL, NULL, NULL); +INSERT INTO `act_hi_identitylink` VALUES ('ffef78e7-3aaa-11ef-86ec-acde48001122', NULL, 'assignee', 'admin', 'ffef78e6-3aaa-11ef-86ec-acde48001122', '2024-07-05 16:45:58.451', NULL, NULL, NULL, NULL, NULL); +COMMIT; + +-- ---------------------------- +-- Table structure for act_hi_procinst +-- ---------------------------- +DROP TABLE IF EXISTS `act_hi_procinst`; +CREATE TABLE `act_hi_procinst` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT '1', + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `BUSINESS_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `START_TIME_` datetime(3) NOT NULL, + `END_TIME_` datetime(3) DEFAULT NULL, + `DURATION_` bigint DEFAULT NULL, + `START_USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `START_ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `END_ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUPER_PROCESS_INSTANCE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DELETE_REASON_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CALLBACK_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CALLBACK_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REFERENCE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REFERENCE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROPAGATED_STAGE_INST_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `BUSINESS_STATUS_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + UNIQUE KEY `PROC_INST_ID_` (`PROC_INST_ID_`), + KEY `ACT_IDX_HI_PRO_INST_END` (`END_TIME_`), + KEY `ACT_IDX_HI_PRO_I_BUSKEY` (`BUSINESS_KEY_`), + KEY `ACT_IDX_HI_PRO_SUPER_PROCINST` (`SUPER_PROCESS_INSTANCE_ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_hi_procinst +-- ---------------------------- +BEGIN; +INSERT INTO `act_hi_procinst` VALUES ('e1fb2ada-3aaa-11ef-86ec-acde48001122', 1, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', '1809146480452177920', 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', '2024-07-05 16:45:08.196', NULL, NULL, 'admin', 'Event_04b3gd5', NULL, NULL, NULL, '', NULL, NULL, NULL, NULL, NULL, NULL, NULL); +COMMIT; + +-- ---------------------------- +-- Table structure for act_hi_taskinst +-- ---------------------------- +DROP TABLE IF EXISTS `act_hi_taskinst`; +CREATE TABLE `act_hi_taskinst` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT '1', + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROPAGATED_STAGE_INST_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `STATE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PARENT_TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DESCRIPTION_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `OWNER_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ASSIGNEE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `START_TIME_` datetime(3) NOT NULL, + `IN_PROGRESS_TIME_` datetime(3) DEFAULT NULL, + `IN_PROGRESS_STARTED_BY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CLAIM_TIME_` datetime(3) DEFAULT NULL, + `CLAIMED_BY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUSPENDED_TIME_` datetime(3) DEFAULT NULL, + `SUSPENDED_BY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `END_TIME_` datetime(3) DEFAULT NULL, + `COMPLETED_BY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DURATION_` bigint DEFAULT NULL, + `DELETE_REASON_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PRIORITY_` int DEFAULT NULL, + `IN_PROGRESS_DUE_DATE_` datetime(3) DEFAULT NULL, + `DUE_DATE_` datetime(3) DEFAULT NULL, + `FORM_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + `LAST_UPDATED_TIME_` datetime(3) DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_HI_TASK_SCOPE` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_HI_TASK_SUB_SCOPE` (`SUB_SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_HI_TASK_SCOPE_DEF` (`SCOPE_DEFINITION_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_HI_TASK_INST_PROCINST` (`PROC_INST_ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_hi_taskinst +-- ---------------------------- +BEGIN; +INSERT INTO `act_hi_taskinst` VALUES ('0669cc2a-3aab-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', NULL, 'Activity_0vjtv0p', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', '0669cc28-3aab-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, 'completed', '录入', NULL, NULL, NULL, 'admin', '2024-07-05 16:46:09.319', NULL, NULL, NULL, NULL, NULL, NULL, '2024-07-05 16:46:18.298', NULL, 8979, NULL, 50, NULL, NULL, '{\"formId\":\"1809132635633487872\",\"readOnly\":false,\"groupType\":\"ASSIGNEE\"}', NULL, '', '2024-07-05 16:46:18.298'); +INSERT INTO `act_hi_taskinst` VALUES ('0bdf328e-3aab-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', NULL, 'Activity_06g14pf', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', '0669cc28-3aab-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, 'created', '审批A', NULL, NULL, NULL, 'admin', '2024-07-05 16:46:18.476', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 50, NULL, NULL, '{\"formId\":\"1809132635633487872\",\"readOnly\":true,\"groupType\":\"ASSIGNEE\"}', NULL, '', '2024-07-05 16:46:18.477'); +INSERT INTO `act_hi_taskinst` VALUES ('e200f745-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', NULL, 'Activity_0vjtv0p', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, 'completed', '录入', NULL, NULL, NULL, 'admin', '2024-07-05 16:45:08.207', NULL, NULL, NULL, NULL, NULL, NULL, '2024-07-05 16:45:09.922', NULL, 1715, NULL, 50, NULL, NULL, '{\"formId\":\"1809132635633487872\",\"readOnly\":false,\"groupType\":\"ASSIGNEE\"}', NULL, '', '2024-07-05 16:45:09.922'); +INSERT INTO `act_hi_taskinst` VALUES ('e322e20d-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', NULL, 'Activity_06g14pf', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, 'completed', '审批A', NULL, NULL, NULL, 'admin', '2024-07-05 16:45:10.133', NULL, NULL, NULL, NULL, NULL, NULL, '2024-07-05 16:45:36.309', NULL, 26176, NULL, 50, NULL, NULL, '{\"formId\":\"1809132635633487872\",\"readOnly\":true,\"groupType\":\"ASSIGNEE\"}', NULL, '', '2024-07-05 16:45:36.309'); +INSERT INTO `act_hi_taskinst` VALUES ('f2dcc311-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', NULL, 'Activity_0dn7u52', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, 'completed', '审批B', NULL, NULL, NULL, 'admin', '2024-07-05 16:45:36.518', NULL, NULL, NULL, NULL, NULL, NULL, '2024-07-05 16:45:58.349', NULL, 21831, 'Change activity to Activity_06g14pf', 50, NULL, NULL, '{\"formId\":\"1809132635633487872\",\"readOnly\":true,\"groupType\":\"ASSIGNEE\"}', NULL, '', '2024-07-05 16:45:58.349'); +INSERT INTO `act_hi_taskinst` VALUES ('ffef78e6-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', NULL, 'Activity_06g14pf', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'ffef51d3-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, 'completed', '审批A', NULL, NULL, NULL, 'admin', '2024-07-05 16:45:58.451', NULL, NULL, NULL, NULL, NULL, NULL, '2024-07-05 16:46:09.253', NULL, 10802, 'Change activity to Activity_0vjtv0p', 50, NULL, NULL, '{\"formId\":\"1809132635633487872\",\"readOnly\":true,\"groupType\":\"ASSIGNEE\"}', NULL, '', '2024-07-05 16:46:09.253'); +COMMIT; + +-- ---------------------------- +-- Table structure for act_hi_tsk_log +-- ---------------------------- +DROP TABLE IF EXISTS `act_hi_tsk_log`; +CREATE TABLE `act_hi_tsk_log` ( + `ID_` bigint NOT NULL AUTO_INCREMENT, + `TYPE_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `TIME_STAMP_` timestamp(3) NOT NULL, + `USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DATA_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_hi_varinst +-- ---------------------------- +DROP TABLE IF EXISTS `act_hi_varinst`; +CREATE TABLE `act_hi_varinst` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT '1', + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `VAR_TYPE_` varchar(100) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `BYTEARRAY_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DOUBLE_` double DEFAULT NULL, + `LONG_` bigint DEFAULT NULL, + `TEXT_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TEXT2_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `META_INFO_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` datetime(3) DEFAULT NULL, + `LAST_UPDATED_TIME_` datetime(3) DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_HI_PROCVAR_NAME_TYPE` (`NAME_`,`VAR_TYPE_`), + KEY `ACT_IDX_HI_VAR_SCOPE_ID_TYPE` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_HI_VAR_SUB_ID_TYPE` (`SUB_SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_HI_PROCVAR_PROC_INST` (`PROC_INST_ID_`), + KEY `ACT_IDX_HI_PROCVAR_TASK_ID` (`TASK_ID_`), + KEY `ACT_IDX_HI_PROCVAR_EXE` (`EXECUTION_ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_hi_varinst +-- ---------------------------- +BEGIN; +INSERT INTO `act_hi_varinst` VALUES ('e1fb78fc-3aaa-11ef-86ec-acde48001122', 0, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, 'copyDataMap_Activity_0vjtv0p', 'string', NULL, NULL, NULL, NULL, NULL, NULL, '{}', NULL, NULL, '2024-07-05 16:45:08.200', '2024-07-05 16:45:08.200'); +INSERT INTO `act_hi_varinst` VALUES ('e1fbc71d-3aaa-11ef-86ec-acde48001122', 0, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, 'startUserName', 'string', NULL, NULL, NULL, NULL, NULL, NULL, 'admin', NULL, NULL, '2024-07-05 16:45:08.200', '2024-07-05 16:45:08.200'); +INSERT INTO `act_hi_varinst` VALUES ('e1fbc71e-3aaa-11ef-86ec-acde48001122', 0, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, 'initiator', 'string', NULL, NULL, NULL, NULL, NULL, NULL, 'admin', NULL, NULL, '2024-07-05 16:45:08.200', '2024-07-05 16:45:08.200'); +INSERT INTO `act_hi_varinst` VALUES ('e1fbc71f-3aaa-11ef-86ec-acde48001122', 0, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, 'copyDataMap_Activity_06g14pf', 'string', NULL, NULL, NULL, NULL, NULL, NULL, '{}', NULL, NULL, '2024-07-05 16:45:08.200', '2024-07-05 16:45:08.200'); +INSERT INTO `act_hi_varinst` VALUES ('e1fbc720-3aaa-11ef-86ec-acde48001122', 0, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, 'copyDataMap_Activity_0dn7u52', 'string', NULL, NULL, NULL, NULL, NULL, NULL, '{}', NULL, NULL, '2024-07-05 16:45:08.200', '2024-07-05 16:45:08.200'); +INSERT INTO `act_hi_varinst` VALUES ('e2fd0a88-3aaa-11ef-86ec-acde48001122', 2, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, 'submitUser', 'string', NULL, NULL, NULL, NULL, NULL, NULL, 'admin', NULL, NULL, '2024-07-05 16:45:09.886', '2024-07-05 16:46:18.228'); +INSERT INTO `act_hi_varinst` VALUES ('e2fd0a89-3aaa-11ef-86ec-acde48001122', 2, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, 'operationType', 'string', NULL, NULL, NULL, NULL, NULL, NULL, 'agree', NULL, NULL, '2024-07-05 16:45:09.886', '2024-07-05 16:46:18.264'); +INSERT INTO `act_hi_varinst` VALUES ('ffef51d4-3aaa-11ef-86ec-acde48001122', 0, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'ffef51d3-3aaa-11ef-86ec-acde48001122', NULL, 'appointedAssignee', 'string', NULL, NULL, NULL, NULL, NULL, NULL, 'admin', NULL, NULL, '2024-07-05 16:45:58.451', '2024-07-05 16:45:58.451'); +COMMIT; + +-- ---------------------------- +-- Table structure for act_id_bytearray +-- ---------------------------- +DROP TABLE IF EXISTS `act_id_bytearray`; +CREATE TABLE `act_id_bytearray` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `BYTES_` longblob, + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_id_group +-- ---------------------------- +DROP TABLE IF EXISTS `act_id_group`; +CREATE TABLE `act_id_group` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_id_info +-- ---------------------------- +DROP TABLE IF EXISTS `act_id_info`; +CREATE TABLE `act_id_info` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `USER_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TYPE_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `VALUE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PASSWORD_` longblob, + `PARENT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_id_membership +-- ---------------------------- +DROP TABLE IF EXISTS `act_id_membership`; +CREATE TABLE `act_id_membership` ( + `USER_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `GROUP_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + PRIMARY KEY (`USER_ID_`,`GROUP_ID_`), + KEY `ACT_FK_MEMB_GROUP` (`GROUP_ID_`), + CONSTRAINT `ACT_FK_MEMB_GROUP` FOREIGN KEY (`GROUP_ID_`) REFERENCES `act_id_group` (`ID_`), + CONSTRAINT `ACT_FK_MEMB_USER` FOREIGN KEY (`USER_ID_`) REFERENCES `act_id_user` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_id_priv +-- ---------------------------- +DROP TABLE IF EXISTS `act_id_priv`; +CREATE TABLE `act_id_priv` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + PRIMARY KEY (`ID_`), + UNIQUE KEY `ACT_UNIQ_PRIV_NAME` (`NAME_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_id_priv_mapping +-- ---------------------------- +DROP TABLE IF EXISTS `act_id_priv_mapping`; +CREATE TABLE `act_id_priv_mapping` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `PRIV_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `GROUP_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_FK_PRIV_MAPPING` (`PRIV_ID_`), + KEY `ACT_IDX_PRIV_USER` (`USER_ID_`), + KEY `ACT_IDX_PRIV_GROUP` (`GROUP_ID_`), + CONSTRAINT `ACT_FK_PRIV_MAPPING` FOREIGN KEY (`PRIV_ID_`) REFERENCES `act_id_priv` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_id_property +-- ---------------------------- +DROP TABLE IF EXISTS `act_id_property`; +CREATE TABLE `act_id_property` ( + `NAME_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `VALUE_` varchar(300) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REV_` int DEFAULT NULL, + PRIMARY KEY (`NAME_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_id_property +-- ---------------------------- +BEGIN; +INSERT INTO `act_id_property` VALUES ('schema.version', '7.0.1.1', 1); +COMMIT; + +-- ---------------------------- +-- Table structure for act_id_token +-- ---------------------------- +DROP TABLE IF EXISTS `act_id_token`; +CREATE TABLE `act_id_token` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `TOKEN_VALUE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TOKEN_DATE_` timestamp(3) NULL DEFAULT NULL, + `IP_ADDRESS_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `USER_AGENT_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TOKEN_DATA_` varchar(2000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_id_user +-- ---------------------------- +DROP TABLE IF EXISTS `act_id_user`; +CREATE TABLE `act_id_user` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `FIRST_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `LAST_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DISPLAY_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EMAIL_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PWD_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PICTURE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_procdef_info +-- ---------------------------- +DROP TABLE IF EXISTS `act_procdef_info`; +CREATE TABLE `act_procdef_info` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `INFO_JSON_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + UNIQUE KEY `ACT_UNIQ_INFO_PROCDEF` (`PROC_DEF_ID_`), + KEY `ACT_IDX_INFO_PROCDEF` (`PROC_DEF_ID_`), + KEY `ACT_FK_INFO_JSON_BA` (`INFO_JSON_ID_`), + CONSTRAINT `ACT_FK_INFO_JSON_BA` FOREIGN KEY (`INFO_JSON_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_INFO_PROCDEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `act_re_procdef` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_re_deployment +-- ---------------------------- +DROP TABLE IF EXISTS `act_re_deployment`; +CREATE TABLE `act_re_deployment` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + `DEPLOY_TIME_` timestamp(3) NULL DEFAULT NULL, + `DERIVED_FROM_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DERIVED_FROM_ROOT_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PARENT_DEPLOYMENT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ENGINE_VERSION_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_re_deployment +-- ---------------------------- +BEGIN; +INSERT INTO `act_re_deployment` VALUES ('bcd05b06-3aa9-11ef-86ec-acde48001122', '请假申请', 'TEST', 'flowLeave', NULL, '2024-07-05 16:36:56.343', NULL, NULL, 'bcd05b06-3aa9-11ef-86ec-acde48001122', NULL); +COMMIT; + +-- ---------------------------- +-- Table structure for act_re_model +-- ---------------------------- +DROP TABLE IF EXISTS `act_re_model`; +CREATE TABLE `act_re_model` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` timestamp(3) NULL DEFAULT NULL, + `LAST_UPDATE_TIME_` timestamp(3) NULL DEFAULT NULL, + `VERSION_` int DEFAULT NULL, + `META_INFO_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DEPLOYMENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EDITOR_SOURCE_VALUE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EDITOR_SOURCE_EXTRA_VALUE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`), + KEY `ACT_FK_MODEL_SOURCE` (`EDITOR_SOURCE_VALUE_ID_`), + KEY `ACT_FK_MODEL_SOURCE_EXTRA` (`EDITOR_SOURCE_EXTRA_VALUE_ID_`), + KEY `ACT_FK_MODEL_DEPLOYMENT` (`DEPLOYMENT_ID_`), + CONSTRAINT `ACT_FK_MODEL_DEPLOYMENT` FOREIGN KEY (`DEPLOYMENT_ID_`) REFERENCES `act_re_deployment` (`ID_`), + CONSTRAINT `ACT_FK_MODEL_SOURCE` FOREIGN KEY (`EDITOR_SOURCE_VALUE_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_MODEL_SOURCE_EXTRA` FOREIGN KEY (`EDITOR_SOURCE_EXTRA_VALUE_ID_`) REFERENCES `act_ge_bytearray` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_re_procdef +-- ---------------------------- +DROP TABLE IF EXISTS `act_re_procdef`; +CREATE TABLE `act_re_procdef` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `VERSION_` int NOT NULL, + `DEPLOYMENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `RESOURCE_NAME_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DGRM_RESOURCE_NAME_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DESCRIPTION_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HAS_START_FORM_KEY_` tinyint DEFAULT NULL, + `HAS_GRAPHICAL_NOTATION_` tinyint DEFAULT NULL, + `SUSPENSION_STATE_` int DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + `ENGINE_VERSION_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DERIVED_FROM_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DERIVED_FROM_ROOT_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DERIVED_VERSION_` int NOT NULL DEFAULT '0', + PRIMARY KEY (`ID_`), + UNIQUE KEY `ACT_UNIQ_PROCDEF` (`KEY_`,`VERSION_`,`DERIVED_VERSION_`,`TENANT_ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_re_procdef +-- ---------------------------- +BEGIN; +INSERT INTO `act_re_procdef` VALUES ('flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 1, 'http://flowable.org/bpmn', '请假申请', 'flowLeave', 1, 'bcd05b06-3aa9-11ef-86ec-acde48001122', 'flowLeave.bpmn', 'flowLeave.flowLeave.png', NULL, 0, 1, 1, '', NULL, NULL, NULL, 0); +COMMIT; + +-- ---------------------------- +-- Table structure for act_ru_actinst +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_actinst`; +CREATE TABLE `act_ru_actinst` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT '1', + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CALL_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ACT_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ACT_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `ASSIGNEE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `START_TIME_` datetime(3) NOT NULL, + `END_TIME_` datetime(3) DEFAULT NULL, + `DURATION_` bigint DEFAULT NULL, + `TRANSACTION_ORDER_` int DEFAULT NULL, + `DELETE_REASON_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_RU_ACTI_START` (`START_TIME_`), + KEY `ACT_IDX_RU_ACTI_END` (`END_TIME_`), + KEY `ACT_IDX_RU_ACTI_PROC` (`PROC_INST_ID_`), + KEY `ACT_IDX_RU_ACTI_PROC_ACT` (`PROC_INST_ID_`,`ACT_ID_`), + KEY `ACT_IDX_RU_ACTI_EXEC` (`EXECUTION_ID_`), + KEY `ACT_IDX_RU_ACTI_EXEC_ACT` (`EXECUTION_ID_`,`ACT_ID_`), + KEY `ACT_IDX_RU_ACTI_TASK` (`TASK_ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_ru_actinst +-- ---------------------------- +BEGIN; +INSERT INTO `act_ru_actinst` VALUES ('0669cc29-3aab-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', '0669cc28-3aab-11ef-86ec-acde48001122', 'Activity_0vjtv0p', '0669cc2a-3aab-11ef-86ec-acde48001122', NULL, '录入', 'userTask', 'admin', '2024-07-05 16:46:09.319', '2024-07-05 16:46:18.402', 9083, 1, NULL, ''); +INSERT INTO `act_ru_actinst` VALUES ('0bd9662c-3aab-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', '0669cc28-3aab-11ef-86ec-acde48001122', 'Flow_1u40dt7', NULL, NULL, NULL, 'sequenceFlow', NULL, '2024-07-05 16:46:18.439', '2024-07-05 16:46:18.439', 0, 1, NULL, ''); +INSERT INTO `act_ru_actinst` VALUES ('0bdf0b7d-3aab-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', '0669cc28-3aab-11ef-86ec-acde48001122', 'Activity_06g14pf', '0bdf328e-3aab-11ef-86ec-acde48001122', NULL, '审批A', 'userTask', 'admin', '2024-07-05 16:46:18.476', NULL, NULL, 2, NULL, ''); +INSERT INTO `act_ru_actinst` VALUES ('e1fbee32-3aaa-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Event_04b3gd5', NULL, NULL, NULL, 'startEvent', NULL, '2024-07-05 16:45:08.201', '2024-07-05 16:45:08.205', 4, 1, NULL, ''); +INSERT INTO `act_ru_actinst` VALUES ('e1fcd893-3aaa-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Flow_0d86buw', NULL, NULL, NULL, 'sequenceFlow', NULL, '2024-07-05 16:45:08.207', '2024-07-05 16:45:08.207', 0, 2, NULL, ''); +INSERT INTO `act_ru_actinst` VALUES ('e1fcd894-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Activity_0vjtv0p', 'e200f745-3aaa-11ef-86ec-acde48001122', NULL, '录入', 'userTask', 'admin', '2024-07-05 16:45:08.207', '2024-07-05 16:45:10.069', 1862, 3, NULL, ''); +INSERT INTO `act_ru_actinst` VALUES ('e31e4e2b-3aaa-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Flow_1u40dt7', NULL, NULL, NULL, 'sequenceFlow', NULL, '2024-07-05 16:45:10.104', '2024-07-05 16:45:10.104', 0, 1, NULL, ''); +INSERT INTO `act_ru_actinst` VALUES ('e322bafc-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Activity_06g14pf', 'e322e20d-3aaa-11ef-86ec-acde48001122', NULL, '审批A', 'userTask', 'admin', '2024-07-05 16:45:10.133', '2024-07-05 16:45:36.454', 26321, 2, NULL, ''); +INSERT INTO `act_ru_actinst` VALUES ('f2d8563f-3aaa-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Flow_05s1j0n', NULL, NULL, NULL, 'sequenceFlow', NULL, '2024-07-05 16:45:36.489', '2024-07-05 16:45:36.489', 0, 1, NULL, ''); +INSERT INTO `act_ru_actinst` VALUES ('f2dcc310-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Activity_0dn7u52', 'f2dcc311-3aaa-11ef-86ec-acde48001122', NULL, '审批B', 'userTask', 'admin', '2024-07-05 16:45:36.518', '2024-07-05 16:45:58.241', 21723, 2, 'Change activity to Activity_06g14pf', ''); +INSERT INTO `act_ru_actinst` VALUES ('ffef78e5-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'ffef51d3-3aaa-11ef-86ec-acde48001122', 'Activity_06g14pf', 'ffef78e6-3aaa-11ef-86ec-acde48001122', NULL, '审批A', 'userTask', 'admin', '2024-07-05 16:45:58.451', '2024-07-05 16:46:09.095', 10644, 1, 'Change activity to Activity_0vjtv0p', ''); +COMMIT; + +-- ---------------------------- +-- Table structure for act_ru_deadletter_job +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_deadletter_job`; +CREATE TABLE `act_ru_deadletter_job` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `EXCLUSIVE_` tinyint(1) DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROCESS_INSTANCE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ELEMENT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ELEMENT_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CORRELATION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXCEPTION_STACK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXCEPTION_MSG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DUEDATE_` timestamp(3) NULL DEFAULT NULL, + `REPEAT_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_CFG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CUSTOM_VALUES_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` timestamp(3) NULL DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_DEADLETTER_JOB_EXCEPTION_STACK_ID` (`EXCEPTION_STACK_ID_`), + KEY `ACT_IDX_DEADLETTER_JOB_CUSTOM_VALUES_ID` (`CUSTOM_VALUES_ID_`), + KEY `ACT_IDX_DEADLETTER_JOB_CORRELATION_ID` (`CORRELATION_ID_`), + KEY `ACT_IDX_DJOB_SCOPE` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_DJOB_SUB_SCOPE` (`SUB_SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_DJOB_SCOPE_DEF` (`SCOPE_DEFINITION_ID_`,`SCOPE_TYPE_`), + KEY `ACT_FK_DEADLETTER_JOB_EXECUTION` (`EXECUTION_ID_`), + KEY `ACT_FK_DEADLETTER_JOB_PROCESS_INSTANCE` (`PROCESS_INSTANCE_ID_`), + KEY `ACT_FK_DEADLETTER_JOB_PROC_DEF` (`PROC_DEF_ID_`), + CONSTRAINT `ACT_FK_DEADLETTER_JOB_CUSTOM_VALUES` FOREIGN KEY (`CUSTOM_VALUES_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_DEADLETTER_JOB_EXCEPTION` FOREIGN KEY (`EXCEPTION_STACK_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_DEADLETTER_JOB_EXECUTION` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `act_ru_execution` (`ID_`), + CONSTRAINT `ACT_FK_DEADLETTER_JOB_PROC_DEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `act_re_procdef` (`ID_`), + CONSTRAINT `ACT_FK_DEADLETTER_JOB_PROCESS_INSTANCE` FOREIGN KEY (`PROCESS_INSTANCE_ID_`) REFERENCES `act_ru_execution` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_ru_entitylink +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_entitylink`; +CREATE TABLE `act_ru_entitylink` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `CREATE_TIME_` datetime(3) DEFAULT NULL, + `LINK_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PARENT_ELEMENT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REF_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REF_SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REF_SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ROOT_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ROOT_SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HIERARCHY_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_ENT_LNK_SCOPE` (`SCOPE_ID_`,`SCOPE_TYPE_`,`LINK_TYPE_`), + KEY `ACT_IDX_ENT_LNK_REF_SCOPE` (`REF_SCOPE_ID_`,`REF_SCOPE_TYPE_`,`LINK_TYPE_`), + KEY `ACT_IDX_ENT_LNK_ROOT_SCOPE` (`ROOT_SCOPE_ID_`,`ROOT_SCOPE_TYPE_`,`LINK_TYPE_`), + KEY `ACT_IDX_ENT_LNK_SCOPE_DEF` (`SCOPE_DEFINITION_ID_`,`SCOPE_TYPE_`,`LINK_TYPE_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_ru_event_subscr +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_event_subscr`; +CREATE TABLE `act_ru_event_subscr` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `EVENT_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `EVENT_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ACTIVITY_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CONFIGURATION_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATED_` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `LOCK_TIME_` timestamp(3) NULL DEFAULT NULL, + `LOCK_OWNER_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_EVENT_SUBSCR_CONFIG_` (`CONFIGURATION_`), + KEY `ACT_IDX_EVENT_SUBSCR_SCOPEREF_` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_FK_EVENT_EXEC` (`EXECUTION_ID_`), + CONSTRAINT `ACT_FK_EVENT_EXEC` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `act_ru_execution` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_ru_execution +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_execution`; +CREATE TABLE `act_ru_execution` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `BUSINESS_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PARENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUPER_EXEC_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ROOT_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `IS_ACTIVE_` tinyint DEFAULT NULL, + `IS_CONCURRENT_` tinyint DEFAULT NULL, + `IS_SCOPE_` tinyint DEFAULT NULL, + `IS_EVENT_SCOPE_` tinyint DEFAULT NULL, + `IS_MI_ROOT_` tinyint DEFAULT NULL, + `SUSPENSION_STATE_` int DEFAULT NULL, + `CACHED_ENT_STATE_` int DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `START_ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `START_TIME_` datetime(3) DEFAULT NULL, + `START_USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `LOCK_TIME_` timestamp(3) NULL DEFAULT NULL, + `LOCK_OWNER_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `IS_COUNT_ENABLED_` tinyint DEFAULT NULL, + `EVT_SUBSCR_COUNT_` int DEFAULT NULL, + `TASK_COUNT_` int DEFAULT NULL, + `JOB_COUNT_` int DEFAULT NULL, + `TIMER_JOB_COUNT_` int DEFAULT NULL, + `SUSP_JOB_COUNT_` int DEFAULT NULL, + `DEADLETTER_JOB_COUNT_` int DEFAULT NULL, + `EXTERNAL_WORKER_JOB_COUNT_` int DEFAULT NULL, + `VAR_COUNT_` int DEFAULT NULL, + `ID_LINK_COUNT_` int DEFAULT NULL, + `CALLBACK_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CALLBACK_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REFERENCE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REFERENCE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROPAGATED_STAGE_INST_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `BUSINESS_STATUS_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_EXEC_BUSKEY` (`BUSINESS_KEY_`), + KEY `ACT_IDC_EXEC_ROOT` (`ROOT_PROC_INST_ID_`), + KEY `ACT_IDX_EXEC_REF_ID_` (`REFERENCE_ID_`), + KEY `ACT_FK_EXE_PROCINST` (`PROC_INST_ID_`), + KEY `ACT_FK_EXE_PARENT` (`PARENT_ID_`), + KEY `ACT_FK_EXE_SUPER` (`SUPER_EXEC_`), + KEY `ACT_FK_EXE_PROCDEF` (`PROC_DEF_ID_`), + CONSTRAINT `ACT_FK_EXE_PARENT` FOREIGN KEY (`PARENT_ID_`) REFERENCES `act_ru_execution` (`ID_`) ON DELETE CASCADE, + CONSTRAINT `ACT_FK_EXE_PROCDEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `act_re_procdef` (`ID_`), + CONSTRAINT `ACT_FK_EXE_PROCINST` FOREIGN KEY (`PROC_INST_ID_`) REFERENCES `act_ru_execution` (`ID_`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `ACT_FK_EXE_SUPER` FOREIGN KEY (`SUPER_EXEC_`) REFERENCES `act_ru_execution` (`ID_`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_ru_execution +-- ---------------------------- +BEGIN; +INSERT INTO `act_ru_execution` VALUES ('0669cc28-3aab-11ef-86ec-acde48001122', 2, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', NULL, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'Activity_06g14pf', 1, 0, 0, 0, 0, 1, NULL, '', NULL, NULL, '2024-07-05 16:46:09.288', NULL, NULL, NULL, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL); +INSERT INTO `act_ru_execution` VALUES ('e1fb2ada-3aaa-11ef-86ec-acde48001122', 1, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', '1809146480452177920', NULL, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', NULL, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, 1, 0, 1, 0, 0, 1, NULL, '', NULL, 'Event_04b3gd5', '2024-07-05 16:45:08.196', 'admin', NULL, NULL, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL); +COMMIT; + +-- ---------------------------- +-- Table structure for act_ru_external_job +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_external_job`; +CREATE TABLE `act_ru_external_job` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `LOCK_EXP_TIME_` timestamp(3) NULL DEFAULT NULL, + `LOCK_OWNER_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXCLUSIVE_` tinyint(1) DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROCESS_INSTANCE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ELEMENT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ELEMENT_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CORRELATION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `RETRIES_` int DEFAULT NULL, + `EXCEPTION_STACK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXCEPTION_MSG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DUEDATE_` timestamp(3) NULL DEFAULT NULL, + `REPEAT_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_CFG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CUSTOM_VALUES_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` timestamp(3) NULL DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_EXTERNAL_JOB_EXCEPTION_STACK_ID` (`EXCEPTION_STACK_ID_`), + KEY `ACT_IDX_EXTERNAL_JOB_CUSTOM_VALUES_ID` (`CUSTOM_VALUES_ID_`), + KEY `ACT_IDX_EXTERNAL_JOB_CORRELATION_ID` (`CORRELATION_ID_`), + KEY `ACT_IDX_EJOB_SCOPE` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_EJOB_SUB_SCOPE` (`SUB_SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_EJOB_SCOPE_DEF` (`SCOPE_DEFINITION_ID_`,`SCOPE_TYPE_`), + CONSTRAINT `ACT_FK_EXTERNAL_JOB_CUSTOM_VALUES` FOREIGN KEY (`CUSTOM_VALUES_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_EXTERNAL_JOB_EXCEPTION` FOREIGN KEY (`EXCEPTION_STACK_ID_`) REFERENCES `act_ge_bytearray` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_ru_history_job +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_history_job`; +CREATE TABLE `act_ru_history_job` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `LOCK_EXP_TIME_` timestamp(3) NULL DEFAULT NULL, + `LOCK_OWNER_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `RETRIES_` int DEFAULT NULL, + `EXCEPTION_STACK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXCEPTION_MSG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_CFG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CUSTOM_VALUES_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ADV_HANDLER_CFG_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` timestamp(3) NULL DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_ru_identitylink +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_identitylink`; +CREATE TABLE `act_ru_identitylink` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `GROUP_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_IDENT_LNK_USER` (`USER_ID_`), + KEY `ACT_IDX_IDENT_LNK_GROUP` (`GROUP_ID_`), + KEY `ACT_IDX_IDENT_LNK_SCOPE` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_IDENT_LNK_SUB_SCOPE` (`SUB_SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_IDENT_LNK_SCOPE_DEF` (`SCOPE_DEFINITION_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_ATHRZ_PROCEDEF` (`PROC_DEF_ID_`), + KEY `ACT_FK_TSKASS_TASK` (`TASK_ID_`), + KEY `ACT_FK_IDL_PROCINST` (`PROC_INST_ID_`), + CONSTRAINT `ACT_FK_ATHRZ_PROCEDEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `act_re_procdef` (`ID_`), + CONSTRAINT `ACT_FK_IDL_PROCINST` FOREIGN KEY (`PROC_INST_ID_`) REFERENCES `act_ru_execution` (`ID_`), + CONSTRAINT `ACT_FK_TSKASS_TASK` FOREIGN KEY (`TASK_ID_`) REFERENCES `act_ru_task` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_ru_identitylink +-- ---------------------------- +BEGIN; +INSERT INTO `act_ru_identitylink` VALUES ('e1fb51eb-3aaa-11ef-86ec-acde48001122', 1, NULL, 'starter', 'admin', NULL, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL); +INSERT INTO `act_ru_identitylink` VALUES ('e2014567-3aaa-11ef-86ec-acde48001122', 1, NULL, 'participant', 'admin', NULL, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL); +INSERT INTO `act_ru_identitylink` VALUES ('e2fd319a-3aaa-11ef-86ec-acde48001122', 1, NULL, 'participant', 'admin', NULL, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL); +COMMIT; + +-- ---------------------------- +-- Table structure for act_ru_job +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_job`; +CREATE TABLE `act_ru_job` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `LOCK_EXP_TIME_` timestamp(3) NULL DEFAULT NULL, + `LOCK_OWNER_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXCLUSIVE_` tinyint(1) DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROCESS_INSTANCE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ELEMENT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ELEMENT_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CORRELATION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `RETRIES_` int DEFAULT NULL, + `EXCEPTION_STACK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXCEPTION_MSG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DUEDATE_` timestamp(3) NULL DEFAULT NULL, + `REPEAT_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_CFG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CUSTOM_VALUES_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` timestamp(3) NULL DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_JOB_EXCEPTION_STACK_ID` (`EXCEPTION_STACK_ID_`), + KEY `ACT_IDX_JOB_CUSTOM_VALUES_ID` (`CUSTOM_VALUES_ID_`), + KEY `ACT_IDX_JOB_CORRELATION_ID` (`CORRELATION_ID_`), + KEY `ACT_IDX_JOB_SCOPE` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_JOB_SUB_SCOPE` (`SUB_SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_JOB_SCOPE_DEF` (`SCOPE_DEFINITION_ID_`,`SCOPE_TYPE_`), + KEY `ACT_FK_JOB_EXECUTION` (`EXECUTION_ID_`), + KEY `ACT_FK_JOB_PROCESS_INSTANCE` (`PROCESS_INSTANCE_ID_`), + KEY `ACT_FK_JOB_PROC_DEF` (`PROC_DEF_ID_`), + CONSTRAINT `ACT_FK_JOB_CUSTOM_VALUES` FOREIGN KEY (`CUSTOM_VALUES_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_JOB_EXCEPTION` FOREIGN KEY (`EXCEPTION_STACK_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_JOB_EXECUTION` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `act_ru_execution` (`ID_`), + CONSTRAINT `ACT_FK_JOB_PROC_DEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `act_re_procdef` (`ID_`), + CONSTRAINT `ACT_FK_JOB_PROCESS_INSTANCE` FOREIGN KEY (`PROCESS_INSTANCE_ID_`) REFERENCES `act_ru_execution` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_ru_suspended_job +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_suspended_job`; +CREATE TABLE `act_ru_suspended_job` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `EXCLUSIVE_` tinyint(1) DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROCESS_INSTANCE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ELEMENT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ELEMENT_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CORRELATION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `RETRIES_` int DEFAULT NULL, + `EXCEPTION_STACK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXCEPTION_MSG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DUEDATE_` timestamp(3) NULL DEFAULT NULL, + `REPEAT_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_CFG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CUSTOM_VALUES_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` timestamp(3) NULL DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_SUSPENDED_JOB_EXCEPTION_STACK_ID` (`EXCEPTION_STACK_ID_`), + KEY `ACT_IDX_SUSPENDED_JOB_CUSTOM_VALUES_ID` (`CUSTOM_VALUES_ID_`), + KEY `ACT_IDX_SUSPENDED_JOB_CORRELATION_ID` (`CORRELATION_ID_`), + KEY `ACT_IDX_SJOB_SCOPE` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_SJOB_SUB_SCOPE` (`SUB_SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_SJOB_SCOPE_DEF` (`SCOPE_DEFINITION_ID_`,`SCOPE_TYPE_`), + KEY `ACT_FK_SUSPENDED_JOB_EXECUTION` (`EXECUTION_ID_`), + KEY `ACT_FK_SUSPENDED_JOB_PROCESS_INSTANCE` (`PROCESS_INSTANCE_ID_`), + KEY `ACT_FK_SUSPENDED_JOB_PROC_DEF` (`PROC_DEF_ID_`), + CONSTRAINT `ACT_FK_SUSPENDED_JOB_CUSTOM_VALUES` FOREIGN KEY (`CUSTOM_VALUES_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_SUSPENDED_JOB_EXCEPTION` FOREIGN KEY (`EXCEPTION_STACK_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_SUSPENDED_JOB_EXECUTION` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `act_ru_execution` (`ID_`), + CONSTRAINT `ACT_FK_SUSPENDED_JOB_PROC_DEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `act_re_procdef` (`ID_`), + CONSTRAINT `ACT_FK_SUSPENDED_JOB_PROCESS_INSTANCE` FOREIGN KEY (`PROCESS_INSTANCE_ID_`) REFERENCES `act_ru_execution` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_ru_task +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_task`; +CREATE TABLE `act_ru_task` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROPAGATED_STAGE_INST_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `STATE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PARENT_TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DESCRIPTION_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `OWNER_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ASSIGNEE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DELEGATION_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PRIORITY_` int DEFAULT NULL, + `CREATE_TIME_` timestamp(3) NULL DEFAULT NULL, + `IN_PROGRESS_TIME_` datetime(3) DEFAULT NULL, + `IN_PROGRESS_STARTED_BY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CLAIM_TIME_` datetime(3) DEFAULT NULL, + `CLAIMED_BY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUSPENDED_TIME_` datetime(3) DEFAULT NULL, + `SUSPENDED_BY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `IN_PROGRESS_DUE_DATE_` datetime(3) DEFAULT NULL, + `DUE_DATE_` datetime(3) DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUSPENSION_STATE_` int DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + `FORM_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `IS_COUNT_ENABLED_` tinyint DEFAULT NULL, + `VAR_COUNT_` int DEFAULT NULL, + `ID_LINK_COUNT_` int DEFAULT NULL, + `SUB_TASK_COUNT_` int DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_TASK_CREATE` (`CREATE_TIME_`), + KEY `ACT_IDX_TASK_SCOPE` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_TASK_SUB_SCOPE` (`SUB_SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_TASK_SCOPE_DEF` (`SCOPE_DEFINITION_ID_`,`SCOPE_TYPE_`), + KEY `ACT_FK_TASK_EXE` (`EXECUTION_ID_`), + KEY `ACT_FK_TASK_PROCINST` (`PROC_INST_ID_`), + KEY `ACT_FK_TASK_PROCDEF` (`PROC_DEF_ID_`), + CONSTRAINT `ACT_FK_TASK_EXE` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `act_ru_execution` (`ID_`), + CONSTRAINT `ACT_FK_TASK_PROCDEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `act_re_procdef` (`ID_`), + CONSTRAINT `ACT_FK_TASK_PROCINST` FOREIGN KEY (`PROC_INST_ID_`) REFERENCES `act_ru_execution` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_ru_task +-- ---------------------------- +BEGIN; +INSERT INTO `act_ru_task` VALUES ('0bdf328e-3aab-11ef-86ec-acde48001122', 1, '0669cc28-3aab-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, NULL, 'created', '审批A', NULL, NULL, 'Activity_06g14pf', NULL, 'admin', NULL, 50, '2024-07-05 16:46:18.476', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '', '{\"formId\":\"1809132635633487872\",\"readOnly\":true,\"groupType\":\"ASSIGNEE\"}', 1, 0, 0, 0); +COMMIT; + +-- ---------------------------- +-- Table structure for act_ru_timer_job +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_timer_job`; +CREATE TABLE `act_ru_timer_job` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `LOCK_EXP_TIME_` timestamp(3) NULL DEFAULT NULL, + `LOCK_OWNER_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXCLUSIVE_` tinyint(1) DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROCESS_INSTANCE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ELEMENT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ELEMENT_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CORRELATION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `RETRIES_` int DEFAULT NULL, + `EXCEPTION_STACK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXCEPTION_MSG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DUEDATE_` timestamp(3) NULL DEFAULT NULL, + `REPEAT_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_CFG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CUSTOM_VALUES_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` timestamp(3) NULL DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_TIMER_JOB_EXCEPTION_STACK_ID` (`EXCEPTION_STACK_ID_`), + KEY `ACT_IDX_TIMER_JOB_CUSTOM_VALUES_ID` (`CUSTOM_VALUES_ID_`), + KEY `ACT_IDX_TIMER_JOB_CORRELATION_ID` (`CORRELATION_ID_`), + KEY `ACT_IDX_TIMER_JOB_DUEDATE` (`DUEDATE_`), + KEY `ACT_IDX_TJOB_SCOPE` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_TJOB_SUB_SCOPE` (`SUB_SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_TJOB_SCOPE_DEF` (`SCOPE_DEFINITION_ID_`,`SCOPE_TYPE_`), + KEY `ACT_FK_TIMER_JOB_EXECUTION` (`EXECUTION_ID_`), + KEY `ACT_FK_TIMER_JOB_PROCESS_INSTANCE` (`PROCESS_INSTANCE_ID_`), + KEY `ACT_FK_TIMER_JOB_PROC_DEF` (`PROC_DEF_ID_`), + CONSTRAINT `ACT_FK_TIMER_JOB_CUSTOM_VALUES` FOREIGN KEY (`CUSTOM_VALUES_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_TIMER_JOB_EXCEPTION` FOREIGN KEY (`EXCEPTION_STACK_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_TIMER_JOB_EXECUTION` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `act_ru_execution` (`ID_`), + CONSTRAINT `ACT_FK_TIMER_JOB_PROC_DEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `act_re_procdef` (`ID_`), + CONSTRAINT `ACT_FK_TIMER_JOB_PROCESS_INSTANCE` FOREIGN KEY (`PROCESS_INSTANCE_ID_`) REFERENCES `act_ru_execution` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_ru_variable +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_variable`; +CREATE TABLE `act_ru_variable` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `BYTEARRAY_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DOUBLE_` double DEFAULT NULL, + `LONG_` bigint DEFAULT NULL, + `TEXT_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TEXT2_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `META_INFO_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_RU_VAR_SCOPE_ID_TYPE` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_RU_VAR_SUB_ID_TYPE` (`SUB_SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_FK_VAR_BYTEARRAY` (`BYTEARRAY_ID_`), + KEY `ACT_IDX_VARIABLE_TASK_ID` (`TASK_ID_`), + KEY `ACT_FK_VAR_EXE` (`EXECUTION_ID_`), + KEY `ACT_FK_VAR_PROCINST` (`PROC_INST_ID_`), + CONSTRAINT `ACT_FK_VAR_BYTEARRAY` FOREIGN KEY (`BYTEARRAY_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_VAR_EXE` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `act_ru_execution` (`ID_`), + CONSTRAINT `ACT_FK_VAR_PROCINST` FOREIGN KEY (`PROC_INST_ID_`) REFERENCES `act_ru_execution` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_ru_variable +-- ---------------------------- +BEGIN; +INSERT INTO `act_ru_variable` VALUES ('e1fb78fc-3aaa-11ef-86ec-acde48001122', 1, 'string', 'copyDataMap_Activity_0vjtv0p', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{}', NULL, NULL); +INSERT INTO `act_ru_variable` VALUES ('e1fbc71d-3aaa-11ef-86ec-acde48001122', 1, 'string', 'startUserName', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'admin', NULL, NULL); +INSERT INTO `act_ru_variable` VALUES ('e1fbc71e-3aaa-11ef-86ec-acde48001122', 1, 'string', 'initiator', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'admin', NULL, NULL); +INSERT INTO `act_ru_variable` VALUES ('e1fbc71f-3aaa-11ef-86ec-acde48001122', 1, 'string', 'copyDataMap_Activity_06g14pf', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{}', NULL, NULL); +INSERT INTO `act_ru_variable` VALUES ('e1fbc720-3aaa-11ef-86ec-acde48001122', 1, 'string', 'copyDataMap_Activity_0dn7u52', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{}', NULL, NULL); +INSERT INTO `act_ru_variable` VALUES ('e2fd0a88-3aaa-11ef-86ec-acde48001122', 1, 'string', 'submitUser', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'admin', NULL, NULL); +INSERT INTO `act_ru_variable` VALUES ('e2fd0a89-3aaa-11ef-86ec-acde48001122', 1, 'string', 'operationType', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'agree', NULL, NULL); +COMMIT; + +-- ---------------------------- +-- Table structure for flw_channel_definition +-- ---------------------------- +DROP TABLE IF EXISTS `flw_channel_definition`; +CREATE TABLE `flw_channel_definition` ( + `ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `VERSION_` int DEFAULT NULL, + `KEY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `DEPLOYMENT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `CREATE_TIME_` datetime(3) DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `RESOURCE_NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `DESCRIPTION_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `IMPLEMENTATION_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + UNIQUE KEY `ACT_IDX_CHANNEL_DEF_UNIQ` (`KEY_`,`VERSION_`,`TENANT_ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- ---------------------------- +-- Table structure for flw_ev_databasechangelog +-- ---------------------------- +DROP TABLE IF EXISTS `flw_ev_databasechangelog`; +CREATE TABLE `flw_ev_databasechangelog` ( + `ID` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `AUTHOR` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `FILENAME` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `DATEEXECUTED` datetime NOT NULL, + `ORDEREXECUTED` int NOT NULL, + `EXECTYPE` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `MD5SUM` varchar(35) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `DESCRIPTION` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `COMMENTS` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `TAG` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `LIQUIBASE` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `CONTEXTS` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `LABELS` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `DEPLOYMENT_ID` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- ---------------------------- +-- Records of flw_ev_databasechangelog +-- ---------------------------- +BEGIN; +INSERT INTO `flw_ev_databasechangelog` VALUES ('1', 'flowable', 'org/flowable/eventregistry/db/liquibase/flowable-eventregistry-db-changelog.xml', '2024-01-23 14:13:11', 1, 'EXECUTED', '8:1b0c48c9cf7945be799d868a2626d687', 'createTable tableName=FLW_EVENT_DEPLOYMENT; createTable tableName=FLW_EVENT_RESOURCE; createTable tableName=FLW_EVENT_DEFINITION; createIndex indexName=ACT_IDX_EVENT_DEF_UNIQ, tableName=FLW_EVENT_DEFINITION; createTable tableName=FLW_CHANNEL_DEFIN...', '', NULL, '4.20.0', NULL, NULL, '5990391167'); +INSERT INTO `flw_ev_databasechangelog` VALUES ('2', 'flowable', 'org/flowable/eventregistry/db/liquibase/flowable-eventregistry-db-changelog.xml', '2024-01-23 14:13:11', 2, 'EXECUTED', '8:0ea825feb8e470558f0b5754352b9cda', 'addColumn tableName=FLW_CHANNEL_DEFINITION; addColumn tableName=FLW_CHANNEL_DEFINITION', '', NULL, '4.20.0', NULL, NULL, '5990391167'); +INSERT INTO `flw_ev_databasechangelog` VALUES ('3', 'flowable', 'org/flowable/eventregistry/db/liquibase/flowable-eventregistry-db-changelog.xml', '2024-01-23 14:13:11', 3, 'EXECUTED', '8:3c2bb293350b5cbe6504331980c9dcee', 'customChange', '', NULL, '4.20.0', NULL, NULL, '5990391167'); +COMMIT; + +-- ---------------------------- +-- Table structure for flw_ev_databasechangeloglock +-- ---------------------------- +DROP TABLE IF EXISTS `flw_ev_databasechangeloglock`; +CREATE TABLE `flw_ev_databasechangeloglock` ( + `ID` int NOT NULL, + `LOCKED` bit(1) NOT NULL, + `LOCKGRANTED` datetime DEFAULT NULL, + `LOCKEDBY` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- ---------------------------- +-- Records of flw_ev_databasechangeloglock +-- ---------------------------- +BEGIN; +INSERT INTO `flw_ev_databasechangeloglock` VALUES (1, b'0', NULL, NULL); +COMMIT; + +-- ---------------------------- +-- Table structure for flw_event_definition +-- ---------------------------- +DROP TABLE IF EXISTS `flw_event_definition`; +CREATE TABLE `flw_event_definition` ( + `ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `VERSION_` int DEFAULT NULL, + `KEY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `DEPLOYMENT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `RESOURCE_NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `DESCRIPTION_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + UNIQUE KEY `ACT_IDX_EVENT_DEF_UNIQ` (`KEY_`,`VERSION_`,`TENANT_ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- ---------------------------- +-- Table structure for flw_event_deployment +-- ---------------------------- +DROP TABLE IF EXISTS `flw_event_deployment`; +CREATE TABLE `flw_event_deployment` ( + `ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `DEPLOY_TIME_` datetime(3) DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `PARENT_DEPLOYMENT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- ---------------------------- +-- Table structure for flw_event_resource +-- ---------------------------- +DROP TABLE IF EXISTS `flw_event_resource`; +CREATE TABLE `flw_event_resource` ( + `ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `DEPLOYMENT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `RESOURCE_BYTES_` longblob, + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- ---------------------------- +-- Table structure for flw_ru_batch +-- ---------------------------- +DROP TABLE IF EXISTS `flw_ru_batch`; +CREATE TABLE `flw_ru_batch` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `TYPE_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `SEARCH_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SEARCH_KEY2_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` datetime(3) NOT NULL, + `COMPLETE_TIME_` datetime(3) DEFAULT NULL, + `STATUS_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `BATCH_DOC_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for flw_ru_batch_part +-- ---------------------------- +DROP TABLE IF EXISTS `flw_ru_batch_part`; +CREATE TABLE `flw_ru_batch_part` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `BATCH_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TYPE_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `SCOPE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SEARCH_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SEARCH_KEY2_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` datetime(3) NOT NULL, + `COMPLETE_TIME_` datetime(3) DEFAULT NULL, + `STATUS_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `RESULT_DOC_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`), + KEY `FLW_IDX_BATCH_PART` (`BATCH_ID_`), + CONSTRAINT `FLW_FK_BATCH_PART_PARENT` FOREIGN KEY (`BATCH_ID_`) REFERENCES `flw_ru_batch` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for zz_flow_category +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_category`; +CREATE TABLE `zz_flow_category` ( + `category_id` bigint NOT NULL COMMENT '主键Id', + `tenant_id` bigint DEFAULT NULL COMMENT '租户Id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用编码', + `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '显示名称', + `code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '分类编码', + `show_order` int NOT NULL COMMENT '实现顺序', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + PRIMARY KEY (`category_id`) USING BTREE, + KEY `idx_tenant_id` (`tenant_id`) USING BTREE, + KEY `idx_code` (`code`) USING BTREE, + KEY `idx_app_code` (`app_code`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程分类表'; + +-- ---------------------------- +-- Records of zz_flow_category +-- ---------------------------- +BEGIN; +INSERT INTO `zz_flow_category` VALUES (1809051198460792832, NULL, NULL, '测试分类', 'TEST', 1, '2024-07-05 10:26:31', 1809038124504846336, '2024-07-05 10:26:31', 1809038124504846336); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_flow_entry +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_entry`; +CREATE TABLE `zz_flow_entry` ( + `entry_id` bigint NOT NULL COMMENT '主键', + `tenant_id` bigint DEFAULT NULL COMMENT '租户Id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用编码', + `process_definition_name` varchar(200) NOT NULL COMMENT '流程名称', + `process_definition_key` varchar(150) NOT NULL COMMENT '流程标识Key', + `category_id` bigint NOT NULL COMMENT '流程分类', + `main_entry_publish_id` bigint DEFAULT NULL COMMENT '工作流部署的发布主版本Id', + `latest_publish_time` datetime DEFAULT NULL COMMENT '最新发布时间', + `status` int NOT NULL COMMENT '流程状态', + `bpmn_xml` longtext COMMENT '流程定义的xml', + `diagram_type` int NOT NULL COMMENT '流程图类型', + `bind_form_type` int NOT NULL COMMENT '绑定表单类型', + `page_id` bigint DEFAULT NULL COMMENT '在线表单的页面Id', + `default_form_id` bigint DEFAULT NULL COMMENT '在线表单Id', + `default_router_name` varchar(255) DEFAULT NULL COMMENT '静态表单的缺省路由名称', + `encoded_rule` varchar(255) DEFAULT NULL COMMENT '工单表编码字段的编码规则', + `extension_data` varchar(3000) DEFAULT NULL COMMENT '流程的自定义扩展数据', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + PRIMARY KEY (`entry_id`) USING BTREE, + KEY `idx_process_definition_key` (`process_definition_key`) USING BTREE, + KEY `idx_app_code` (`app_code`) USING BTREE, + KEY `idx_category_id` (`category_id`) USING BTREE, + KEY `idx_tenant_id` (`tenant_id`) USING BTREE, + KEY `idx_status` (`status`) USING BTREE, + KEY `idx_process_definition_name` (`process_definition_name`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='流程管理表'; + +-- ---------------------------- +-- Records of zz_flow_entry +-- ---------------------------- +BEGIN; +INSERT INTO `zz_flow_entry` VALUES (1809143991627681792, NULL, NULL, '请假申请', 'flowLeave', 1809051198460792832, 1809144428770627584, '2024-07-05 16:36:59', 1, '\n\n \n \n \n \n \n \n \n Flow_0d86buw\n \n \n \n \n \n Flow_1bxwcza\n \n \n \n \n \n \n \n \n \n \n Flow_0d86buw\n Flow_1u40dt7\n \n \n \n \n \n \n \n \n \n \n Flow_1u40dt7\n Flow_05s1j0n\n \n \n \n \n \n \n \n \n \n \n Flow_05s1j0n\n Flow_1bxwcza\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n', 0, 0, 1809132177523216384, 1809132635633487872, NULL, '{\"middle\":\"DD\",\"idWidth\":5,\"prefix\":\"LL\",\"precisionTo\":\"DAYS\",\"calculateWhenView\":true}', '{\"approvalStatusDict\":[{\"id\":1,\"name\":\"同意\",\"_X_ROW_KEY\":\"row_57\"},{\"id\":2,\"name\":\"拒绝\",\"_X_ROW_KEY\":\"row_58\"},{\"id\":3,\"name\":\"驳回\",\"_X_ROW_KEY\":\"row_59\"},{\"id\":4,\"name\":\"会签同意\",\"_X_ROW_KEY\":\"row_60\"},{\"id\":5,\"name\":\"会签拒绝\",\"_X_ROW_KEY\":\"row_61\"}],\"notifyTypes\":[\"email\"],\"cascadeDeleteBusinessData\":true,\"supportRevive\":false}', '2024-07-05 16:36:39', 1808020007993479168, '2024-07-05 16:35:15', 1808020007993479168); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_flow_entry_publish +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_entry_publish`; +CREATE TABLE `zz_flow_entry_publish` ( + `entry_publish_id` bigint NOT NULL COMMENT '主键Id', + `entry_id` bigint NOT NULL COMMENT '流程Id', + `process_definition_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程引擎的定义Id', + `deploy_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程引擎的部署Id', + `publish_version` int NOT NULL COMMENT '发布版本', + `active_status` bit(1) NOT NULL COMMENT '激活状态', + `main_version` bit(1) NOT NULL COMMENT '是否为主版本', + `extension_data` varchar(3000) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '流程的自定义扩展数据', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + `publish_time` datetime NOT NULL COMMENT '发布时间', + `init_task_info` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '第一个非开始节点任务的附加信息', + `analyzed_node_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '分析后的节点JSON信息', + PRIMARY KEY (`entry_publish_id`) USING BTREE, + UNIQUE KEY `uk_process_definition_id` (`process_definition_id`) USING BTREE, + KEY `idx_entry_id` (`entry_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程发布表'; + +-- ---------------------------- +-- Records of zz_flow_entry_publish +-- ---------------------------- +BEGIN; +INSERT INTO `zz_flow_entry_publish` VALUES (1809144428770627584, 1809143991627681792, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'bcd05b06-3aa9-11ef-86ec-acde48001122', 1, b'1', b'1', '{\"approvalStatusDict\":[{\"id\":1,\"name\":\"同意\",\"_X_ROW_KEY\":\"row_57\"},{\"id\":2,\"name\":\"拒绝\",\"_X_ROW_KEY\":\"row_58\"},{\"id\":3,\"name\":\"驳回\",\"_X_ROW_KEY\":\"row_59\"},{\"id\":4,\"name\":\"会签同意\",\"_X_ROW_KEY\":\"row_60\"},{\"id\":5,\"name\":\"会签拒绝\",\"_X_ROW_KEY\":\"row_61\"}],\"notifyTypes\":[\"email\"],\"cascadeDeleteBusinessData\":true,\"supportRevive\":false}', 1808020007993479168, '2024-07-05 16:36:59', '{\"assignee\":\"${startUserName}\",\"formId\":1809132635633487872,\"groupType\":\"ASSIGNEE\",\"operationList\":[{\"showOrder\":\"0\",\"id\":\"1720168540672\",\"label\":\"同意\",\"type\":\"agree\"}],\"readOnly\":false,\"taskKey\":\"Activity_0vjtv0p\",\"taskType\":1,\"variableList\":[]}', NULL); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_flow_entry_publish_variable +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_entry_publish_variable`; +CREATE TABLE `zz_flow_entry_publish_variable` ( + `variable_id` bigint NOT NULL COMMENT '主键Id', + `entry_publish_id` bigint NOT NULL COMMENT '流程Id', + `variable_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '变量名', + `show_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '显示名', + `variable_type` int NOT NULL COMMENT '变量类型', + `bind_datasource_id` bigint DEFAULT NULL COMMENT '绑定数据源Id', + `bind_relation_id` bigint DEFAULT NULL COMMENT '绑定数据源关联Id', + `bind_column_id` bigint DEFAULT NULL COMMENT '绑定字段Id', + `builtin` bit(1) NOT NULL COMMENT '是否内置', + PRIMARY KEY (`variable_id`) USING BTREE, + KEY `idx_entry_publish_id` (`entry_publish_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程发布变量表'; + +-- ---------------------------- +-- Records of zz_flow_entry_publish_variable +-- ---------------------------- +BEGIN; +INSERT INTO `zz_flow_entry_publish_variable` VALUES (1809144430116999168, 1809144428770627584, 'operationType', '审批类型', 1, NULL, NULL, NULL, b'1'); +INSERT INTO `zz_flow_entry_publish_variable` VALUES (1809144430116999169, 1809144428770627584, 'startUserName', '流程启动用户', 0, NULL, NULL, NULL, b'1'); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_flow_entry_variable +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_entry_variable`; +CREATE TABLE `zz_flow_entry_variable` ( + `variable_id` bigint NOT NULL COMMENT '主键Id', + `entry_id` bigint NOT NULL COMMENT '流程Id', + `variable_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '变量名', + `show_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '显示名', + `variable_type` int NOT NULL COMMENT '变量类型', + `bind_datasource_id` bigint DEFAULT NULL COMMENT '绑定数据源Id', + `bind_relation_id` bigint DEFAULT NULL COMMENT '绑定数据源关联Id', + `bind_column_id` bigint DEFAULT NULL COMMENT '绑定字段Id', + `builtin` bit(1) NOT NULL COMMENT '是否内置', + `create_time` datetime NOT NULL COMMENT '创建时间', + PRIMARY KEY (`variable_id`) USING BTREE, + UNIQUE KEY `uk_entry_id_variable_name` (`entry_id`,`variable_name`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程变量表'; + +-- ---------------------------- +-- Records of zz_flow_entry_variable +-- ---------------------------- +BEGIN; +INSERT INTO `zz_flow_entry_variable` VALUES (1809143992151969793, 1809143991627681792, 'operationType', '审批类型', 1, NULL, NULL, NULL, b'1', '2024-07-05 16:35:15'); +INSERT INTO `zz_flow_entry_variable` VALUES (1809143992630120448, 1809143991627681792, 'startUserName', '流程启动用户', 0, NULL, NULL, NULL, b'1', '2024-07-05 16:35:15'); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_flow_message +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_message`; +CREATE TABLE `zz_flow_message` ( + `message_id` bigint NOT NULL COMMENT '主键Id', + `tenant_id` bigint DEFAULT NULL COMMENT '租户Id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用Id', + `message_type` tinyint NOT NULL COMMENT '消息类型', + `message_content` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '消息内容', + `remind_count` int DEFAULT '0' COMMENT '催办次数', + `work_order_id` bigint DEFAULT NULL COMMENT '工单Id', + `process_definition_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程定义Id', + `process_definition_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程定义标识', + `process_definition_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程定义名称', + `process_instance_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '流程实例Id', + `process_instance_initiator` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '流程实例发起者', + `task_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '流程任务Id', + `task_definition_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '流程任务定义标识', + `task_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '流程任务名称', + `task_start_time` datetime DEFAULT NULL COMMENT '任务开始时间', + `task_finished` bit(1) NOT NULL DEFAULT b'0' COMMENT '任务是否已完成', + `task_assignee` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '任务指派人登录名', + `business_data_shot` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '业务数据快照', + `online_form_data` bit(1) DEFAULT NULL COMMENT '是否为在线表单消息数据', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + `create_username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '创建者显示名', + PRIMARY KEY (`message_id`) USING BTREE, + KEY `idx_tenant_id` (`tenant_id`) USING BTREE, + KEY `idx_app_code` (`app_code`) USING BTREE, + KEY `idx_notified_username` (`task_assignee`) USING BTREE, + KEY `idx_process_instance_id` (`process_instance_id`) USING BTREE, + KEY `idx_message_type` (`message_type`) USING BTREE, + KEY `idx_task_id` (`task_id`) USING BTREE, + KEY `idx_task_finished` (`task_finished`) USING BTREE, + KEY `idx_update_time` (`update_time`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程消息通知表'; + +-- ---------------------------- +-- Table structure for zz_flow_msg_candidate_identity +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_msg_candidate_identity`; +CREATE TABLE `zz_flow_msg_candidate_identity` ( + `id` bigint NOT NULL COMMENT '主键Id', + `message_id` bigint NOT NULL COMMENT '流程任务Id', + `candidate_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '候选身份类型', + `candidate_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '候选身份Id', + PRIMARY KEY (`id`), + KEY `idx_candidate_id` (`candidate_id`) USING BTREE, + KEY `idx_message_id` (`message_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程消息通知候选人表'; + +-- ---------------------------- +-- Table structure for zz_flow_msg_identity_operation +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_msg_identity_operation`; +CREATE TABLE `zz_flow_msg_identity_operation` ( + `id` bigint NOT NULL COMMENT '主键Id', + `message_id` bigint NOT NULL COMMENT '流程任务Id', + `login_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '用户登录名', + `operation_type` int NOT NULL COMMENT '操作类型', + `operation_time` datetime NOT NULL COMMENT '操作时间', + PRIMARY KEY (`id`), + KEY `idx_message_id` (`message_id`) USING BTREE, + KEY `idx_login_name` (`login_name`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程消息候选人操作表'; + +-- ---------------------------- +-- Table structure for zz_flow_multi_instance_trans +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_multi_instance_trans`; +CREATE TABLE `zz_flow_multi_instance_trans` ( + `id` bigint NOT NULL COMMENT '主键Id', + `process_instance_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程实例Id', + `task_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '任务Id', + `task_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '任务标识', + `multi_instance_exec_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '会签任务的执行Id', + `execution_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '任务的执行Id', + `assignee_list` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '会签指派人列表', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + `create_login_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '创建者登录名', + `create_username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '创建者用户名', + `create_time` datetime NOT NULL COMMENT '创建时间', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_execution_id_task_id` (`execution_id`,`task_id`) USING BTREE, + KEY `idx_multi_instance_exec_id` (`multi_instance_exec_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程多实例任务审批流水表'; + +-- ---------------------------- +-- Table structure for zz_flow_task_comment +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_task_comment`; +CREATE TABLE `zz_flow_task_comment` ( + `id` bigint NOT NULL COMMENT '主键Id', + `process_instance_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程实例Id', + `task_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '任务Id', + `task_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '任务标识', + `task_name` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '任务名称', + `target_task_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '目标任务标识', + `execution_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '任务的执行Id', + `multi_instance_exec_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '会签任务的执行Id', + `approval_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '审批类型', + `task_comment` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '批注内容', + `delegate_assignee` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '委托指定人,比如加签、转办等', + `custom_business_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '自定义数据。开发者可自行扩展,推荐使用JSON格式数据', + `head_image_url` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '审批用户头像', + `create_user_id` bigint DEFAULT NULL COMMENT '创建者Id', + `create_login_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '创建者登录名', + `create_username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '创建者用户名', + `create_time` datetime NOT NULL COMMENT '创建时间', + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_multi_instance_exec_id` (`multi_instance_exec_id`) USING BTREE, + KEY `idx_process_instance_id` (`process_instance_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程任务审批表'; + +-- ---------------------------- +-- Records of zz_flow_task_comment +-- ---------------------------- +BEGIN; +INSERT INTO `zz_flow_task_comment` VALUES (1809146487481831424, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e200f745-3aaa-11ef-86ec-acde48001122', 'Activity_0vjtv0p', '录入', NULL, 'e1fbee31-3aaa-11ef-86ec-acde48001122', NULL, 'agree', NULL, NULL, NULL, NULL, 1808020007993479168, 'admin', '管理员', '2024-07-05 16:45:10'); +INSERT INTO `zz_flow_task_comment` VALUES (1809146598064656384, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e322e20d-3aaa-11ef-86ec-acde48001122', 'Activity_06g14pf', '审批A', NULL, 'e1fbee31-3aaa-11ef-86ec-acde48001122', NULL, 'agree', '11', NULL, NULL, NULL, 1808020007993479168, 'admin', '管理员', '2024-07-05 16:45:36'); +INSERT INTO `zz_flow_task_comment` VALUES (1809146699361292288, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'f2dcc311-3aaa-11ef-86ec-acde48001122', 'Activity_0dn7u52', '审批B', NULL, NULL, NULL, 'reject', '11', NULL, NULL, NULL, 1808020007993479168, 'admin', '管理员', '2024-07-05 16:46:00'); +INSERT INTO `zz_flow_task_comment` VALUES (1809146743762194432, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'ffef78e6-3aaa-11ef-86ec-acde48001122', 'Activity_06g14pf', '审批A', NULL, NULL, NULL, 'reject', '33', NULL, NULL, NULL, 1808020007993479168, 'admin', '管理员', '2024-07-05 16:46:11'); +INSERT INTO `zz_flow_task_comment` VALUES (1809146774330281984, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', '0669cc2a-3aab-11ef-86ec-acde48001122', 'Activity_0vjtv0p', '录入', NULL, '0669cc28-3aab-11ef-86ec-acde48001122', NULL, 'agree', '44', NULL, NULL, NULL, 1808020007993479168, 'admin', '管理员', '2024-07-05 16:46:18'); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_flow_task_ext +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_task_ext`; +CREATE TABLE `zz_flow_task_ext` ( + `process_definition_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程引擎的定义Id', + `task_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程引擎任务Id', + `operation_list_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '操作列表JSON', + `variable_list_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '变量列表JSON', + `assignee_list_json` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '存储多实例的assigneeList的JSON', + `group_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '分组类型', + `dept_post_list_json` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '保存岗位相关的数据', + `role_ids` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '保存角色Id数据', + `dept_ids` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '保存部门Id数据', + `candidate_usernames` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '保存候选组用户名数据', + `copy_list_json` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '抄送相关的数据', + `extra_data_json` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '用户任务的扩展属性,存储为JSON的字符串格式', + PRIMARY KEY (`process_definition_id`,`task_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程流程图任务扩展表'; + +-- ---------------------------- +-- Records of zz_flow_task_ext +-- ---------------------------- +BEGIN; +INSERT INTO `zz_flow_task_ext` VALUES ('flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'Activity_06g14pf', '[{\"showOrder\":\"0\",\"id\":\"1720168555059\",\"label\":\"同意\",\"type\":\"agree\"},{\"showOrder\":\"0\",\"id\":\"1720168558485\",\"label\":\"驳回到起点\",\"type\":\"rejectToStart\"}]', NULL, NULL, 'ASSIGNEE', '[]', NULL, NULL, NULL, '[]', '{\"flowNotifyTypeList\":[\"email\"]}'); +INSERT INTO `zz_flow_task_ext` VALUES ('flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'Activity_0dn7u52', '[{\"showOrder\":\"0\",\"id\":\"1720168573903\",\"label\":\"同意\",\"type\":\"agree\"},{\"showOrder\":\"0\",\"id\":\"1720168577495\",\"label\":\"驳回\",\"type\":\"reject\"}]', NULL, NULL, 'ASSIGNEE', '[]', NULL, NULL, NULL, '[]', '{\"flowNotifyTypeList\":[\"email\"]}'); +INSERT INTO `zz_flow_task_ext` VALUES ('flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'Activity_0vjtv0p', '[{\"showOrder\":\"0\",\"id\":\"1720168540672\",\"label\":\"同意\",\"type\":\"agree\"}]', NULL, NULL, 'ASSIGNEE', '[]', NULL, NULL, NULL, '[]', '{\"flowNotifyTypeList\":[\"email\"]}'); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_flow_work_order +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_work_order`; +CREATE TABLE `zz_flow_work_order` ( + `work_order_id` bigint NOT NULL COMMENT '主键Id', + `tenant_id` bigint DEFAULT NULL COMMENT '租户Id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用编码', + `work_order_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '工单编码字段', + `process_definition_key` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程定义标识', + `process_definition_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '流程名称', + `process_definition_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程引擎的定义Id', + `process_instance_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程实例Id', + `online_table_id` bigint DEFAULT NULL COMMENT '在线表单的主表Id', + `table_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '用于静态表单的表名', + `business_key` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '业务主键值', + `task_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '未完成的任务Id', + `task_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '未完成的任务名称', + `task_definition_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '未完成的任务标识', + `latest_approval_status` int DEFAULT NULL COMMENT '最近的审批状态', + `flow_status` int NOT NULL DEFAULT '0' COMMENT '流程状态', + `submit_username` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '提交用户登录名称', + `dept_id` bigint NOT NULL COMMENT '提交用户所在部门Id', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + `deleted_flag` int NOT NULL COMMENT '删除标记(1: 正常 -1: 已删除)', + PRIMARY KEY (`work_order_id`) USING BTREE, + UNIQUE KEY `uk_process_instance_id` (`process_instance_id`) USING BTREE, + UNIQUE KEY `uk_work_order_code` (`work_order_code`) USING BTREE, + KEY `idx_tenant_id` (`tenant_id`) USING BTREE, + KEY `idx_app_code` (`app_code`) USING BTREE, + KEY `idx_process_definition_key` (`process_definition_key`) USING BTREE, + KEY `idx_create_user_id` (`create_user_id`) USING BTREE, + KEY `idx_create_time` (`create_time`) USING BTREE, + KEY `idx_dept_id` (`dept_id`) USING BTREE, + KEY `idx_table_name` (`table_name`) USING BTREE, + KEY `idx_business_key` (`business_key`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程工单表'; + +-- ---------------------------- +-- Records of zz_flow_work_order +-- ---------------------------- +BEGIN; +INSERT INTO `zz_flow_work_order` VALUES (1809146486244511744, NULL, NULL, 'LL20240705DD00001', 'flowLeave', '请假申请', 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 1809132251556876288, NULL, '1809146480452177920', NULL, NULL, NULL, NULL, 1, 'admin', 1808020008341606402, '2024-07-05 16:46:18', 1808020007993479168, '2024-07-05 16:45:09', 1808020007993479168, 1); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_flow_work_order_ext +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_work_order_ext`; +CREATE TABLE `zz_flow_work_order_ext` ( + `id` bigint NOT NULL COMMENT '主键Id', + `work_order_id` bigint NOT NULL COMMENT '工单Id', + `draft_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '草稿数据', + `business_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '业务数据', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + `deleted_flag` int NOT NULL COMMENT '删除标记(1: 正常 -1: 已删除)', + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_work_order_id` (`work_order_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程工单扩展表'; + +-- ---------------------------- +-- Table structure for zz_global_dict +-- ---------------------------- +DROP TABLE IF EXISTS `zz_global_dict`; +CREATE TABLE `zz_global_dict` ( + `dict_id` bigint NOT NULL COMMENT '主键Id', + `dict_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '字典编码', + `dict_name` varchar(2048) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '字典中文名称', + `create_user_id` bigint NOT NULL COMMENT '创建用户Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `update_user_id` bigint NOT NULL COMMENT '更新用户名', + `update_time` datetime NOT NULL COMMENT '更新时间', + `deleted_flag` int NOT NULL COMMENT '逻辑删除字段', + PRIMARY KEY (`dict_id`), + KEY `idx_dict_code` (`dict_code`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='全局字典表'; + +-- ---------------------------- +-- Table structure for zz_global_dict_item +-- ---------------------------- +DROP TABLE IF EXISTS `zz_global_dict_item`; +CREATE TABLE `zz_global_dict_item` ( + `id` bigint NOT NULL COMMENT '主键Id', + `dict_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '字典编码', + `item_id` varchar(64) COLLATE utf8mb4_bin NOT NULL COMMENT '字典数据项Id', + `item_name` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '字典数据项名称', + `show_order` int NOT NULL COMMENT '显示顺序', + `status` int NOT NULL COMMENT '字典状态', + `create_user_id` bigint NOT NULL COMMENT '创建用户Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `update_user_id` bigint NOT NULL COMMENT '更新用户名', + `update_time` datetime NOT NULL COMMENT '更新时间', + `deleted_flag` int NOT NULL COMMENT '逻辑删除字段', + PRIMARY KEY (`id`), + KEY `idx_show_order` (`show_order`) USING BTREE, + KEY `idx_dict_code_item_id` (`dict_code`,`item_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='全局字典项目表'; + +-- ---------------------------- +-- Table structure for zz_online_column +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_column`; +CREATE TABLE `zz_online_column` ( + `column_id` bigint NOT NULL COMMENT '主键Id', + `column_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '字段名', + `table_id` bigint NOT NULL COMMENT '数据表Id', + `column_type` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '数据表中的字段类型', + `full_column_type` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '数据表中的完整字段类型(包括了精度和刻度)', + `primary_key` bit(1) NOT NULL COMMENT '是否为主键', + `auto_incr` bit(1) NOT NULL COMMENT '是否是自增主键(0: 不是 1: 是)', + `nullable` bit(1) NOT NULL COMMENT '是否可以为空 (0: 不可以为空 1: 可以为空)', + `column_default` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT '缺省值', + `column_show_order` int NOT NULL COMMENT '字段在数据表中的显示位置', + `column_comment` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT '数据表中的字段注释', + `object_field_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '对象映射字段名称', + `object_field_type` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '对象映射字段类型', + `numeric_precision` int DEFAULT NULL COMMENT '数值型字段的精度', + `numeric_scale` int DEFAULT NULL COMMENT '数值型字段的刻度', + `filter_type` int NOT NULL DEFAULT '1' COMMENT '字段过滤类型', + `parent_key` bit(1) NOT NULL COMMENT '是否是主键的父Id', + `dept_filter` bit(1) NOT NULL COMMENT '是否部门过滤字段', + `user_filter` bit(1) NOT NULL COMMENT '是否用户过滤字段', + `field_kind` int DEFAULT NULL COMMENT '字段类别', + `max_file_count` int DEFAULT NULL COMMENT '包含的文件文件数量,0表示无限制', + `upload_file_system_type` int DEFAULT '0' COMMENT '上传文件系统类型', + `encoded_rule` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '编码规则的JSON格式数据', + `mask_field_type` varchar(64) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '脱敏字段类型', + `dict_id` bigint DEFAULT NULL COMMENT '字典Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者', + PRIMARY KEY (`column_id`), + KEY `idx_table_id` (`table_id`) USING BTREE, + KEY `idx_dict_id` (`dict_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单字段表'; + +-- ---------------------------- +-- Records of zz_online_column +-- ---------------------------- +BEGIN; +INSERT INTO `zz_online_column` VALUES (1809132252005666816, 'id', 1809132251556876288, 'bigint', 'bigint', b'1', b'0', b'0', NULL, 1, '主键Id', 'id', 'Long', 19, NULL, 0, b'0', b'0', b'0', NULL, NULL, 0, NULL, NULL, NULL, '2024-07-05 15:48:36', 1808020007993479168, '2024-07-05 15:48:36', 1808020007993479168); +INSERT INTO `zz_online_column` VALUES (1809132252425097216, 'user_id', 1809132251556876288, 'bigint', 'bigint', b'0', b'0', b'0', NULL, 2, '请假用户', 'userId', 'Long', 19, NULL, 0, b'0', b'0', b'0', 21, NULL, 0, NULL, NULL, NULL, '2024-07-05 15:48:36', 1808020007993479168, '2024-07-05 15:48:47', 1808020007993479168); +INSERT INTO `zz_online_column` VALUES (1809132252852916224, 'leave_reason', 1809132251556876288, 'varchar', 'varchar(512)', b'0', b'0', b'0', NULL, 3, '请假原因', 'leaveReason', 'String', NULL, NULL, 0, b'0', b'0', b'0', NULL, NULL, 0, NULL, NULL, NULL, '2024-07-05 15:48:36', 1808020007993479168, '2024-07-05 15:53:47', 1808020007993479168); +INSERT INTO `zz_online_column` VALUES (1809132253377204224, 'leave_type', 1809132251556876288, 'int', 'int', b'0', b'0', b'0', NULL, 4, '请假类型', 'leaveType', 'Integer', 10, NULL, 0, b'0', b'0', b'0', NULL, NULL, 0, NULL, NULL, NULL, '2024-07-05 15:48:36', 1808020007993479168, '2024-07-05 15:53:44', 1808020007993479168); +INSERT INTO `zz_online_column` VALUES (1809132253733720064, 'leave_begin_time', 1809132251556876288, 'datetime', 'datetime', b'0', b'0', b'0', NULL, 5, '开始时间', 'leaveBeginTime', 'Date', NULL, NULL, 0, b'0', b'0', b'0', NULL, NULL, 0, NULL, NULL, NULL, '2024-07-05 15:48:36', 1808020007993479168, '2024-07-05 15:53:50', 1808020007993479168); +INSERT INTO `zz_online_column` VALUES (1809132254102818816, 'leave_end_time', 1809132251556876288, 'datetime', 'datetime', b'0', b'0', b'0', NULL, 6, '结束时间', 'leaveEndTime', 'Date', NULL, NULL, 0, b'0', b'0', b'0', NULL, NULL, 0, NULL, NULL, NULL, '2024-07-05 15:48:36', 1808020007993479168, '2024-07-05 15:53:54', 1808020007993479168); +INSERT INTO `zz_online_column` VALUES (1809132254388031488, 'apply_time', 1809132251556876288, 'datetime', 'datetime', b'0', b'0', b'0', NULL, 7, '申请时间', 'applyTime', 'Date', NULL, NULL, 0, b'0', b'0', b'0', 20, NULL, 0, NULL, NULL, NULL, '2024-07-05 15:48:36', 1808020007993479168, '2024-07-05 15:53:57', 1808020007993479168); +INSERT INTO `zz_online_column` VALUES (1809132254782296064, 'approval_status', 1809132251556876288, 'int', 'int', b'0', b'0', b'1', NULL, 8, '最后审批状态', 'approvalStatus', 'Integer', 10, NULL, 0, b'0', b'0', b'0', 26, NULL, 0, NULL, NULL, NULL, '2024-07-05 15:48:36', 1808020007993479168, '2024-07-05 15:53:59', 1808020007993479168); +INSERT INTO `zz_online_column` VALUES (1809132255327555584, 'flow_status', 1809132251556876288, 'int', 'int', b'0', b'0', b'1', NULL, 9, '流程状态', 'flowStatus', 'Integer', 10, NULL, 0, b'0', b'0', b'0', 25, NULL, 0, NULL, NULL, NULL, '2024-07-05 15:48:36', 1808020007993479168, '2024-07-05 15:49:44', 1808020007993479168); +INSERT INTO `zz_online_column` VALUES (1809132255679877120, 'username', 1809132251556876288, 'varchar', 'varchar(255)', b'0', b'0', b'1', NULL, 10, '用户名', 'username', 'String', NULL, NULL, 0, b'0', b'0', b'0', NULL, NULL, 0, NULL, NULL, NULL, '2024-07-05 15:48:36', 1808020007993479168, '2024-07-05 15:49:49', 1808020007993479168); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_online_column_rule +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_column_rule`; +CREATE TABLE `zz_online_column_rule` ( + `column_id` bigint NOT NULL COMMENT '字段Id', + `rule_id` bigint NOT NULL COMMENT '规则Id', + `prop_data_json` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '规则属性数据', + PRIMARY KEY (`column_id`,`rule_id`) USING BTREE, + KEY `idx_rule_id` (`rule_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单字段和字段规则关联中间表'; + +-- ---------------------------- +-- Table structure for zz_online_datasource +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_datasource`; +CREATE TABLE `zz_online_datasource` ( + `datasource_id` bigint NOT NULL COMMENT '主键Id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用编码', + `datasource_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '数据源名称', + `variable_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '数据源变量名', + `dblink_id` bigint NOT NULL COMMENT '数据库链接Id', + `master_table_id` bigint NOT NULL COMMENT '主表Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者', + PRIMARY KEY (`datasource_id`), + UNIQUE KEY `uk_app_code_variable_name` (`app_code`,`variable_name`) USING BTREE, + KEY `idx_master_table_id` (`master_table_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单数据源表'; + +-- ---------------------------- +-- Records of zz_online_datasource +-- ---------------------------- +BEGIN; +INSERT INTO `zz_online_datasource` VALUES (1809132255981867008, NULL, '请假申请', 'dsLeave', 1809055300360081408, 1809132251556876288, '2024-07-05 15:48:37', 1808020007993479168, '2024-07-05 15:48:37', 1808020007993479168); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_online_datasource_relation +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_datasource_relation`; +CREATE TABLE `zz_online_datasource_relation` ( + `relation_id` bigint NOT NULL COMMENT '主键Id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用编码', + `relation_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '关联名称', + `variable_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '变量名', + `datasource_id` bigint NOT NULL COMMENT '主数据源Id', + `relation_type` int NOT NULL COMMENT '关联类型', + `master_column_id` bigint NOT NULL COMMENT '主表关联字段Id', + `slave_table_id` bigint NOT NULL COMMENT '从表Id', + `slave_column_id` bigint NOT NULL COMMENT '从表关联字段Id', + `cascade_delete` bit(1) NOT NULL COMMENT '删除主表的时候是否级联删除一对一和一对多的从表数据,多对多只是删除关联,不受到这个标记的影响。', + `left_join` bit(1) NOT NULL COMMENT '是否左连接', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者', + PRIMARY KEY (`relation_id`) USING BTREE, + UNIQUE KEY `uk_datasource_id_variable_name` (`datasource_id`,`variable_name`) USING BTREE, + KEY `idx_app_code` (`app_code`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单数据源关联表'; + +-- ---------------------------- +-- Table structure for zz_online_datasource_table +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_datasource_table`; +CREATE TABLE `zz_online_datasource_table` ( + `id` bigint NOT NULL COMMENT '主键Id', + `datasource_id` bigint NOT NULL COMMENT '数据源Id', + `relation_id` bigint DEFAULT NULL COMMENT '数据源关联Id', + `table_id` bigint NOT NULL COMMENT '数据表Id', + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_relation_id` (`relation_id`) USING BTREE, + KEY `idx_datasource_id` (`datasource_id`) USING BTREE, + KEY `idx_table_id` (`table_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单数据源和数据表关联的中间表'; + +-- ---------------------------- +-- Records of zz_online_datasource_table +-- ---------------------------- +BEGIN; +INSERT INTO `zz_online_datasource_table` VALUES (1809132256292245504, 1809132255981867008, NULL, 1809132251556876288); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_online_dblink +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_dblink`; +CREATE TABLE `zz_online_dblink` ( + `dblink_id` bigint NOT NULL COMMENT '主键Id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用编码', + `dblink_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '链接中文名称', + `dblink_description` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '链接描述', + `dblink_type` int NOT NULL COMMENT '数据源类型', + `configuration` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '配置信息', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者', + PRIMARY KEY (`dblink_id`), + KEY `idx_dblink_type` (`dblink_type`) USING BTREE, + KEY `idx_app_code` (`app_code`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单数据库链接表'; + +-- ---------------------------- +-- Records of zz_online_dblink +-- ---------------------------- +BEGIN; +INSERT INTO `zz_online_dblink` VALUES (1809055300360081408, NULL, 'mysql-test', NULL, 0, '{\"sid\":true,\"initialPoolSize\":5,\"minPoolSize\":5,\"maxPoolSize\":50,\"host\":\"localhost\",\"port\":3306,\"database\":\"zzdemo-online-open\",\"username\":\"root\",\"password\":\"123456\"}', '2024-07-05 10:42:49', 1809038124504846336, '2024-07-05 10:42:49', 1809038124504846336); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_online_dict +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_dict`; +CREATE TABLE `zz_online_dict` ( + `dict_id` bigint NOT NULL COMMENT '主键Id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用编码', + `dict_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '字典名称', + `dict_type` int NOT NULL COMMENT '字典类型', + `dblink_id` bigint DEFAULT NULL COMMENT '数据库链接Id', + `table_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '字典表名称', + `dict_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '全局字典编码', + `key_column_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '字典表键字段名称', + `parent_key_column_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '字典表父键字段名称', + `value_column_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '字典值字段名称', + `deleted_column_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '逻辑删除字段', + `user_filter_column_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '用户过滤滤字段名称', + `dept_filter_column_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '部门过滤滤字段名称', + `tenant_filter_column_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '租户过滤字段名称', + `tree_flag` bit(1) NOT NULL COMMENT '是否树形标记', + `dict_list_url` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '获取字典列表数据的url', + `dict_ids_url` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '根据主键id批量获取字典数据的url', + `dict_data_json` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '字典的JSON数据', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者', + PRIMARY KEY (`dict_id`) USING BTREE, + KEY `idx_app_code` (`app_code`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单字典表'; + +-- ---------------------------- +-- Table structure for zz_online_form +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_form`; +CREATE TABLE `zz_online_form` ( + `form_id` bigint NOT NULL COMMENT '主键Id', + `tenant_id` bigint DEFAULT NULL COMMENT '租户id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用编码', + `page_id` bigint NOT NULL COMMENT '页面id', + `form_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '表单编码', + `form_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '表单名称', + `form_kind` int NOT NULL COMMENT '表单类别', + `form_type` int NOT NULL COMMENT '表单类型', + `master_table_id` bigint NOT NULL COMMENT '表单主表id', + `widget_json` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '表单组件JSON', + `params_json` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '表单参数JSON', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者', + PRIMARY KEY (`form_id`) USING BTREE, + UNIQUE KEY `uk_page_id_form_code` (`page_id`,`form_code`) USING BTREE, + KEY `idx_tenant_id` (`tenant_id`) USING BTREE, + KEY `idx_app_code` (`app_code`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单表单表'; + +-- ---------------------------- +-- Records of zz_online_form +-- ---------------------------- +BEGIN; +INSERT INTO `zz_online_form` VALUES (1809132635633487872, NULL, NULL, 1809132177523216384, 'formFlowLeave', '请假申请', 5, 10, 1809132251556876288, '{\"pc\":{\"gutter\":20,\"labelWidth\":100,\"labelPosition\":\"right\",\"operationList\":[],\"customFieldList\":[],\"widgetList\":[{\"widgetType\":3,\"bindData\":{\"defaultValue\":{},\"tableId\":\"1809132251556876288\",\"columnId\":\"1809132253377204224\",\"dataType\":0},\"showName\":\"请假类型\",\"variableName\":\"leaveType\",\"props\":{\"span\":24,\"placeholder\":\"\",\"step\":1,\"controls\":true,\"required\":true,\"disabled\":false,\"dictInfo\":{\"paramList\":[]},\"actions\":{}},\"eventList\":[],\"childWidgetList\":[],\"style\":{}},{\"widgetType\":1,\"bindData\":{\"defaultValue\":{},\"tableId\":\"1809132251556876288\",\"columnId\":\"1809132252852916224\",\"dataType\":0},\"showName\":\"请假原因\",\"variableName\":\"leaveReason\",\"props\":{\"span\":24,\"type\":\"text\",\"placeholder\":\"\",\"show-password\":false,\"show-word-limit\":false,\"required\":true,\"disabled\":false,\"dictInfo\":{\"paramList\":[]},\"actions\":{}},\"eventList\":[],\"childWidgetList\":[],\"style\":{}},{\"widgetType\":20,\"bindData\":{\"defaultValue\":{},\"tableId\":\"1809132251556876288\",\"columnId\":\"1809132253733720064\",\"dataType\":0},\"showName\":\"开始时间\",\"variableName\":\"leaveBeginTime\",\"props\":{\"span\":12,\"placeholder\":\"\",\"type\":\"date\",\"required\":true,\"disabled\":false,\"dictInfo\":{\"paramList\":[]},\"actions\":{}},\"eventList\":[],\"childWidgetList\":[],\"style\":{},\"supportOperation\":false},{\"widgetType\":20,\"bindData\":{\"defaultValue\":{},\"tableId\":\"1809132251556876288\",\"columnId\":\"1809132254102818816\",\"dataType\":0},\"showName\":\"结束时间\",\"variableName\":\"leaveEndTime\",\"props\":{\"span\":12,\"placeholder\":\"\",\"type\":\"date\",\"required\":true,\"disabled\":false,\"dictInfo\":{\"paramList\":[]},\"actions\":{}},\"eventList\":[],\"childWidgetList\":[],\"style\":{},\"supportOperation\":false}],\"formEventList\":[],\"maskFieldList\":[],\"width\":800,\"fullscreen\":true}}', NULL, '2024-07-05 15:50:07', 1808020007993479168, '2024-07-05 16:34:21', 1808020007993479168); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_online_form_datasource +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_form_datasource`; +CREATE TABLE `zz_online_form_datasource` ( + `id` bigint NOT NULL COMMENT '主键Id', + `form_id` bigint NOT NULL COMMENT '表单Id', + `datasource_id` bigint NOT NULL COMMENT '数据源Id', + PRIMARY KEY (`id`), + KEY `idx_form_id` (`form_id`) USING BTREE, + KEY `idx_datasource_id` (`datasource_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单表单和数据源关联中间表'; + +-- ---------------------------- +-- Records of zz_online_form_datasource +-- ---------------------------- +BEGIN; +INSERT INTO `zz_online_form_datasource` VALUES (1809143766578106368, 1809132635633487872, 1809132255981867008); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_online_page +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_page`; +CREATE TABLE `zz_online_page` ( + `page_id` bigint NOT NULL COMMENT '主键Id', + `tenant_id` bigint DEFAULT NULL COMMENT '租户id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用编码', + `page_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '页面编码', + `page_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '页面名称', + `page_type` int NOT NULL COMMENT '页面类型', + `status` int NOT NULL COMMENT '页面编辑状态', + `published` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否发布', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者', + PRIMARY KEY (`page_id`) USING BTREE, + KEY `idx_tenant_id` (`tenant_id`) USING BTREE, + KEY `idx_app_code` (`app_code`) USING BTREE, + KEY `idx_page_code` (`page_code`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单页面表'; + +-- ---------------------------- +-- Records of zz_online_page +-- ---------------------------- +BEGIN; +INSERT INTO `zz_online_page` VALUES (1809132177523216384, NULL, NULL, 'flowLeave', '请假申请', 10, 2, b'1', '2024-07-05 15:48:18', 1808020007993479168, '2024-07-05 16:34:27', 1808020007993479168); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_online_page_datasource +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_page_datasource`; +CREATE TABLE `zz_online_page_datasource` ( + `id` bigint NOT NULL COMMENT '主键Id', + `page_id` bigint NOT NULL COMMENT '页面主键Id', + `datasource_id` bigint NOT NULL COMMENT '数据源主键Id', + PRIMARY KEY (`id`), + KEY `idx_page_id` (`page_id`) USING BTREE, + KEY `idx_datasource_id` (`datasource_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单页面和数据源关联中间表'; + +-- ---------------------------- +-- Records of zz_online_page_datasource +-- ---------------------------- +BEGIN; +INSERT INTO `zz_online_page_datasource` VALUES (1809132256564875264, 1809132177523216384, 1809132255981867008); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_online_rule +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_rule`; +CREATE TABLE `zz_online_rule` ( + `rule_id` bigint NOT NULL COMMENT '主键Id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用编码', + `rule_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '规则名称', + `rule_type` int NOT NULL COMMENT '规则类型', + `builtin` bit(1) NOT NULL COMMENT '内置规则标记', + `pattern` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '自定义规则的正则表达式', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者', + `deleted_flag` int NOT NULL COMMENT '逻辑删除标记', + PRIMARY KEY (`rule_id`) USING BTREE, + KEY `idx_app_code` (`app_code`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单字段规则表'; + +-- ---------------------------- +-- Records of zz_online_rule +-- ---------------------------- +BEGIN; +INSERT INTO `zz_online_rule` VALUES (1, NULL, '只允许整数', 1, b'1', NULL, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, 1); +INSERT INTO `zz_online_rule` VALUES (2, NULL, '只允许数字', 2, b'1', NULL, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, 1); +INSERT INTO `zz_online_rule` VALUES (3, NULL, '只允许英文字符', 3, b'1', NULL, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, 1); +INSERT INTO `zz_online_rule` VALUES (4, NULL, '范围验证', 4, b'1', NULL, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, 1); +INSERT INTO `zz_online_rule` VALUES (5, NULL, '邮箱格式验证', 5, b'1', NULL, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, 1); +INSERT INTO `zz_online_rule` VALUES (6, NULL, '手机格式验证', 6, b'1', NULL, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, 1); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_online_table +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_table`; +CREATE TABLE `zz_online_table` ( + `table_id` bigint NOT NULL COMMENT '主键Id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用编码', + `table_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '表名称', + `model_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '实体名称', + `dblink_id` bigint NOT NULL COMMENT '数据库链接Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者', + PRIMARY KEY (`table_id`), + KEY `idx_dblink_id` (`dblink_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单数据表'; + +-- ---------------------------- +-- Records of zz_online_table +-- ---------------------------- +BEGIN; +INSERT INTO `zz_online_table` VALUES (1809132251556876288, NULL, 'zz_test_flow_leave', 'ZzTestFlowLeave', 1809055300360081408, '2024-07-05 15:48:35', 1808020007993479168, '2024-07-05 15:48:35', 1808020007993479168); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_online_virtual_column +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_virtual_column`; +CREATE TABLE `zz_online_virtual_column` ( + `virtual_column_id` bigint NOT NULL COMMENT '主键Id', + `table_id` bigint NOT NULL COMMENT '所在表Id', + `object_field_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '字段名称', + `object_field_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '属性类型', + `column_prompt` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '字段提示名', + `virtual_type` int NOT NULL COMMENT '虚拟字段类型(0: 聚合)', + `datasource_id` bigint NOT NULL COMMENT '关联数据源Id', + `relation_id` bigint DEFAULT NULL COMMENT '关联Id', + `aggregation_table_id` bigint DEFAULT NULL COMMENT '聚合字段所在关联表Id', + `aggregation_column_id` bigint DEFAULT NULL COMMENT '关联表聚合字段Id', + `aggregation_type` int DEFAULT NULL COMMENT '聚合类型(0: sum 1: count 2: avg 3: min 4: max)', + `where_clause_json` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '存储过滤条件的json', + PRIMARY KEY (`virtual_column_id`) USING BTREE, + KEY `idx_database_id` (`datasource_id`) USING BTREE, + KEY `idx_relation_id` (`relation_id`) USING BTREE, + KEY `idx_table_id` (`table_id`) USING BTREE, + KEY `idx_aggregation_column_id` (`aggregation_column_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单虚拟字段表'; + +-- ---------------------------- +-- Table structure for zz_sys_data_perm +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_data_perm`; +CREATE TABLE `zz_sys_data_perm` ( + `data_perm_id` bigint NOT NULL COMMENT '主键', + `data_perm_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '显示名称', + `rule_type` tinyint NOT NULL COMMENT '数据权限规则类型(0: 全部可见 1: 只看自己 2: 只看本部门 3: 本部门及子部门 4: 多部门及子部门 5: 自定义部门列表)。', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `update_user_id` bigint NOT NULL COMMENT '更新者Id', + `update_time` datetime NOT NULL COMMENT '最后更新时间', + PRIMARY KEY (`data_perm_id`) USING BTREE, + KEY `idx_create_time` (`create_time`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='数据权限表'; + +-- ---------------------------- +-- Records of zz_sys_data_perm +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_data_perm` VALUES (1809037881759502336, '查看全部', 0, 1808020007993479168, '2024-07-05 09:33:36', 1808020007993479168, '2024-07-05 09:33:36'); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_data_perm_dept +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_data_perm_dept`; +CREATE TABLE `zz_sys_data_perm_dept` ( + `data_perm_id` bigint NOT NULL COMMENT '数据权限Id', + `dept_id` bigint NOT NULL COMMENT '部门Id', + PRIMARY KEY (`data_perm_id`,`dept_id`), + KEY `idx_dept_id` (`dept_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='数据权限和部门关联表'; + +-- ---------------------------- +-- Table structure for zz_sys_data_perm_menu +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_data_perm_menu`; +CREATE TABLE `zz_sys_data_perm_menu` ( + `data_perm_id` bigint NOT NULL COMMENT '数据权限Id', + `menu_id` bigint NOT NULL COMMENT '菜单Id', + PRIMARY KEY (`data_perm_id`,`menu_id`), + KEY `idx_menu_id` (`menu_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='数据权限和菜单关联表'; + +-- ---------------------------- +-- Table structure for zz_sys_data_perm_user +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_data_perm_user`; +CREATE TABLE `zz_sys_data_perm_user` ( + `data_perm_id` bigint NOT NULL COMMENT '数据权限Id', + `user_id` bigint NOT NULL COMMENT '用户Id', + PRIMARY KEY (`data_perm_id`,`user_id`), + KEY `idx_user_id` (`user_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='数据权限和用户关联表'; + +-- ---------------------------- +-- Records of zz_sys_data_perm_user +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_data_perm_user` VALUES (1809037881759502336, 1809038124504846336); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_dept +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_dept`; +CREATE TABLE `zz_sys_dept` ( + `dept_id` bigint NOT NULL COMMENT '部门Id', + `parent_id` bigint DEFAULT NULL COMMENT '父部门Id', + `dept_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '部门名称', + `show_order` int NOT NULL COMMENT '兄弟部分之间的显示顺序,数字越小越靠前', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `update_user_id` bigint NOT NULL COMMENT '更新者Id', + `update_time` datetime NOT NULL COMMENT '最后更新时间', + `deleted_flag` int NOT NULL COMMENT '删除标记(1: 正常 -1: 已删除)', + PRIMARY KEY (`dept_id`) USING BTREE, + KEY `idx_parent_id` (`parent_id`) USING BTREE, + KEY `idx_show_order` (`show_order`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=COMPACT COMMENT='部门管理表'; + +-- ---------------------------- +-- Records of zz_sys_dept +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_dept` VALUES (1808020008341606402, NULL, '公司总部', 1, 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00', 1); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_dept_post +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_dept_post`; +CREATE TABLE `zz_sys_dept_post` ( + `dept_post_id` bigint NOT NULL COMMENT '主键Id', + `dept_id` bigint NOT NULL COMMENT '部门Id', + `post_id` bigint NOT NULL COMMENT '岗位Id', + `post_show_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '部门岗位显示名称', + PRIMARY KEY (`dept_post_id`) USING BTREE, + KEY `idx_post_id` (`post_id`) USING BTREE, + KEY `idx_dept_id` (`dept_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- ---------------------------- +-- Records of zz_sys_dept_post +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_dept_post` VALUES (1809038003536924672, 1808020008341606402, 1809037927934595072, '领导岗位'); +INSERT INTO `zz_sys_dept_post` VALUES (1809038003968937984, 1808020008341606402, 1809037967663042560, '普通员工'); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_dept_relation +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_dept_relation`; +CREATE TABLE `zz_sys_dept_relation` ( + `parent_dept_id` bigint NOT NULL COMMENT '父部门Id', + `dept_id` bigint NOT NULL COMMENT '部门Id', + PRIMARY KEY (`parent_dept_id`,`dept_id`), + KEY `idx_dept_id` (`dept_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=COMPACT COMMENT='部门关联关系表'; + +-- ---------------------------- +-- Records of zz_sys_dept_relation +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_dept_relation` VALUES (1808020008341606402, 1808020008341606402); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_menu +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_menu`; +CREATE TABLE `zz_sys_menu` ( + `menu_id` bigint NOT NULL COMMENT '主键Id', + `parent_id` bigint DEFAULT NULL COMMENT '父菜单Id,目录菜单的父菜单为null', + `menu_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '菜单显示名称', + `menu_type` int NOT NULL COMMENT '(0: 目录 1: 菜单 2: 按钮 3: UI片段)', + `form_router_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '前端表单路由名称,仅用于menu_type为1的菜单类型', + `online_form_id` bigint DEFAULT NULL COMMENT '在线表单主键Id', + `online_menu_perm_type` int DEFAULT NULL COMMENT '在线表单菜单的权限控制类型', + `report_page_id` bigint DEFAULT NULL COMMENT '统计页面主键Id', + `online_flow_entry_id` bigint DEFAULT NULL COMMENT '仅用于在线表单的流程Id', + `show_order` int NOT NULL COMMENT '菜单显示顺序 (值越小,排序越靠前)', + `icon` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '菜单图标', + `extra_data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '附加信息', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `update_user_id` bigint NOT NULL COMMENT '更新者Id', + `update_time` datetime NOT NULL COMMENT '最后更新时间', + PRIMARY KEY (`menu_id`) USING BTREE, + KEY `idx_show_order` (`show_order`) USING BTREE, + KEY `idx_parent_id` (`parent_id`) USING BTREE, + KEY `idx_menu_type` (`menu_type`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=COMPACT COMMENT='菜单和操作权限管理表'; + +-- ---------------------------- +-- Records of zz_sys_menu +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_menu` VALUES (1392786476428693504, NULL, '在线表单', 0, NULL, NULL, NULL, NULL, NULL, 2, 'el-icon-c-scale-to-original', NULL, 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1392786549942259712, 1392786476428693504, '字典管理', 1, 'formOnlineDict', NULL, NULL, NULL, NULL, 2, NULL, '{\"permCodeList\":[\"onlineDict.all\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1392786950682841088, 1392786476428693504, '表单管理', 1, 'formOnlinePage', NULL, NULL, NULL, NULL, 3, NULL, '{\"permCodeList\":[\"onlinePage.all\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1418057714138877952, NULL, '流程管理', 0, NULL, NULL, NULL, NULL, NULL, 3, 'el-icon-s-operation', NULL, 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1418057835631087616, 1418057714138877952, '流程分类', 1, 'formFlowCategory', NULL, NULL, NULL, NULL, 1, NULL, '{\"permCodeList\":[\"flowCategory.all\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1418058289182150656, 1418057714138877952, '流程设计', 1, 'formFlowEntry', NULL, NULL, NULL, NULL, 2, NULL, '{\"permCodeList\":[\"flowEntry.all\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1418058744037642240, 1418057714138877952, '流程实例', 1, 'formAllInstance', NULL, NULL, NULL, NULL, 3, NULL, '{\"permCodeList\":[\"flowOperation.all\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1418059005175009280, NULL, '任务管理', 0, NULL, NULL, NULL, NULL, NULL, 4, 'el-icon-tickets', NULL, 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1418059167532322816, 1418059005175009280, '待办任务', 1, 'formMyTask', NULL, NULL, NULL, NULL, 1, NULL, NULL, 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1418059283920064512, 1418059005175009280, '历史任务', 1, 'formMyHistoryTask', NULL, NULL, NULL, NULL, 3, NULL, NULL, 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1423161217970606080, 1418059005175009280, '已办任务', 1, 'formMyApprovedTask', NULL, NULL, NULL, NULL, 2, NULL, NULL, 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1634009076981567488, 1392786476428693504, '数据库链接', 1, 'formOnlineDblink', NULL, NULL, NULL, NULL, 1, NULL, '{\"permCodeList\":[\"onlineDblink.all\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020011080486913, NULL, '系统管理', 0, NULL, NULL, NULL, NULL, NULL, 1, 'el-icon-setting', '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020012825317376, 1808020011080486913, '用户管理', 1, 'formSysUser', NULL, NULL, NULL, NULL, 100, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020012825317377, 1808020011080486913, '部门管理', 1, 'formSysDept', NULL, NULL, NULL, NULL, 105, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020012825317378, 1808020011080486913, '角色管理', 1, 'formSysRole', NULL, NULL, NULL, NULL, 110, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020012825317379, 1808020011080486913, '数据权限管理', 1, 'formSysDataPerm', NULL, NULL, NULL, NULL, 115, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020012825317380, 1808020011080486913, '岗位管理', 1, 'formSysPost', NULL, NULL, NULL, NULL, 106, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020012825317381, 1808020011080486913, '菜单管理', 1, 'formSysMenu', NULL, NULL, NULL, NULL, 120, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020012825317384, 1808020011080486913, '字典管理', 1, 'formSysDict', NULL, NULL, NULL, NULL, 135, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020012825317385, 1808020011080486913, '操作日志', 1, 'formSysOperationLog', NULL, NULL, NULL, NULL, 140, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020012825317386, 1808020011080486913, '在线用户', 1, 'formSysLoginUser', NULL, NULL, NULL, NULL, 145, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148866, 1808020012825317376, '显示', 3, NULL, NULL, NULL, NULL, NULL, 1, NULL, '{\"menuCode\":\"formSysUser:fragmentSysUser\",\"permCodeList\":[\"sysUser.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148867, 1808020012825317376, '新增', 3, NULL, NULL, NULL, NULL, NULL, 2, NULL, '{\"menuCode\":\"formSysUser:fragmentSysUser:add\",\"permCodeList\":[\"sysUser.add\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148868, 1808020012825317376, '编辑', 3, NULL, NULL, NULL, NULL, NULL, 3, NULL, '{\"menuCode\":\"formSysUser:fragmentSysUser:update\",\"permCodeList\":[\"sysUser.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148869, 1808020012825317376, '删除', 3, NULL, NULL, NULL, NULL, NULL, 4, NULL, '{\"menuCode\":\"formSysUser:fragmentSysUser:delete\",\"permCodeList\":[\"sysUser.delete\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148870, 1808020012825317376, '重置密码', 3, NULL, NULL, NULL, NULL, NULL, 5, NULL, '{\"menuCode\":\"formSysUser:fragmentSysUser:resetPassword\",\"permCodeList\":[\"sysUser.resetPassword\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148872, 1808020012825317377, '显示', 3, NULL, NULL, NULL, NULL, NULL, 1, NULL, '{\"menuCode\":\"formSysDept:fragmentSysDept\",\"permCodeList\":[\"sysDept.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148873, 1808020012825317377, '新增', 3, NULL, NULL, NULL, NULL, NULL, 2, '', '{\"bindType\":0,\"menuCode\":\"formSysDept:fragmentSysDept:add\",\"permCodeList\":[\"sysDept.add\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-05 09:51:07'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148874, 1808020012825317377, '编辑', 3, NULL, NULL, NULL, NULL, NULL, 3, NULL, '{\"menuCode\":\"formSysDept:fragmentSysDept:update\",\"permCodeList\":[\"sysDept.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148875, 1808020012825317377, '删除', 3, NULL, NULL, NULL, NULL, NULL, 4, NULL, '{\"menuCode\":\"formSysDept:fragmentSysDept:delete\",\"permCodeList\":[\"sysDept.delete\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148876, 1808020012825317377, '设置岗位', 3, NULL, NULL, NULL, NULL, NULL, 5, NULL, '{\"menuCode\":\"formSysDept:fragmentSysDept:editPost\",\"permCodeList\":[\"sysDept.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148877, 1808020012825317377, '查看岗位', 3, NULL, NULL, NULL, NULL, NULL, 6, NULL, '{\"menuCode\":\"formSysDept:fragmentSysDept:viewPost\",\"permCodeList\":[\"sysDept.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148879, 1808020012825317378, '角色管理', 2, NULL, NULL, NULL, NULL, NULL, 1, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148880, 1808020012825317378, '用户授权', 2, NULL, NULL, NULL, NULL, NULL, 2, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148881, 1808020075098148879, '显示', 3, NULL, NULL, NULL, NULL, NULL, 1, NULL, '{\"menuCode\":\"formSysRole:fragmentSysRole\",\"permCodeList\":[\"sysRole.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148882, 1808020075098148879, '新增', 3, NULL, NULL, NULL, NULL, NULL, 2, NULL, '{\"menuCode\":\"formSysRole:fragmentSysRole:add\",\"permCodeList\":[\"sysRole.add\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148883, 1808020075098148879, '编辑', 3, NULL, NULL, NULL, NULL, NULL, 3, NULL, '{\"menuCode\":\"formSysRole:fragmentSysRole:update\",\"permCodeList\":[\"sysRole.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148884, 1808020075098148879, '删除', 3, NULL, NULL, NULL, NULL, NULL, 4, NULL, '{\"menuCode\":\"formSysRole:fragmentSysRole:delete\",\"permCodeList\":[\"sysRole.delete\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148885, 1808020075098148880, '显示', 3, NULL, NULL, NULL, NULL, NULL, 1, NULL, '{\"menuCode\":\"formSysRole:fragmentSysRoleUser\",\"permCodeList\":[\"sysRole.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148886, 1808020075098148880, '授权用户', 3, NULL, NULL, NULL, NULL, NULL, 2, NULL, '{\"menuCode\":\"formSysRole:fragmentSysRoleUser:addUserRole\",\"permCodeList\":[\"sysRole.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148887, 1808020075098148880, '移除用户', 3, NULL, NULL, NULL, NULL, NULL, 3, NULL, '{\"menuCode\":\"formSysRole:fragmentSysRoleUser:deleteUserRole\",\"permCodeList\":[\"sysRole.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148889, 1808020012825317379, '数据权限管理', 2, NULL, NULL, NULL, NULL, NULL, 1, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148890, 1808020012825317379, '用户授权', 2, NULL, NULL, NULL, NULL, NULL, 2, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148891, 1808020075098148889, '显示', 3, NULL, NULL, NULL, NULL, NULL, 1, NULL, '{\"menuCode\":\"formSysDataPerm:fragmentSysDataPerm\",\"permCodeList\":[\"sysDataPerm.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148892, 1808020075098148889, '新增', 3, NULL, NULL, NULL, NULL, NULL, 2, NULL, '{\"menuCode\":\"formSysDataPerm:fragmentSysDataPerm:add\",\"permCodeList\":[\"sysDataPerm.add\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148893, 1808020075098148889, '编辑', 3, NULL, NULL, NULL, NULL, NULL, 3, NULL, '{\"menuCode\":\"formSysDataPerm:fragmentSysDataPerm:update\",\"permCodeList\":[\"sysDataPerm.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148894, 1808020075098148889, '删除', 3, NULL, NULL, NULL, NULL, NULL, 4, NULL, '{\"menuCode\":\"formSysDataPerm:fragmentSysDataPerm:delete\",\"permCodeList\":[\"sysDataPerm.delete\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148895, 1808020075098148890, '显示', 3, NULL, NULL, NULL, NULL, NULL, 1, NULL, '{\"menuCode\":\"formSysDataPerm:fragmentSysDataPermUser\",\"permCodeList\":[\"sysDataPerm.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148896, 1808020075098148890, '授权用户', 3, NULL, NULL, NULL, NULL, NULL, 2, NULL, '{\"menuCode\":\"formSysDataPerm:fragmentSysDataPermUser:addDataPermUser\",\"permCodeList\":[\"sysDataPerm.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148897, 1808020075098148890, '移除用户', 3, NULL, NULL, NULL, NULL, NULL, 3, NULL, '{\"menuCode\":\"formSysDataPerm:fragmentSysDataPermUser:deleteDataPermUser\",\"permCodeList\":[\"sysDataPerm.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148899, 1808020012825317380, '岗位管理', 2, NULL, NULL, NULL, NULL, NULL, 1, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148900, 1808020075098148899, '显示', 3, NULL, NULL, NULL, NULL, NULL, 1, NULL, '{\"menuCode\":\"formSysPost:fragmentSysPost\",\"permCodeList\":[\"sysPost.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148901, 1808020075098148899, '新增', 3, NULL, NULL, NULL, NULL, NULL, 2, NULL, '{\"menuCode\":\"formSysPost:fragmentSysPost:add\",\"permCodeList\":[\"sysPost.add\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148902, 1808020075098148899, '编辑', 3, NULL, NULL, NULL, NULL, NULL, 3, NULL, '{\"menuCode\":\"formSysPost:fragmentSysPost:update\",\"permCodeList\":[\"sysPost.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148903, 1808020075098148899, '删除', 3, NULL, NULL, NULL, NULL, NULL, 4, NULL, '{\"menuCode\":\"formSysPost:fragmentSysPost:delete\",\"permCodeList\":[\"sysPost.delete\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148905, 1808020012825317381, '显示', 3, NULL, NULL, NULL, NULL, NULL, 1, NULL, '{\"menuCode\":\"formSysMenu:fragmentSysMenu\",\"permCodeList\":[\"sysMenu.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148906, 1808020012825317381, '新增', 3, NULL, NULL, NULL, NULL, NULL, 2, NULL, '{\"menuCode\":\"formSysMenu:fragmentSysMenu:add\",\"permCodeList\":[\"sysMenu.add\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148907, 1808020012825317381, '编辑', 3, NULL, NULL, NULL, NULL, NULL, 3, NULL, '{\"menuCode\":\"formSysMenu:fragmentSysMenu:update\",\"permCodeList\":[\"sysMenu.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148908, 1808020012825317381, '删除', 3, NULL, NULL, NULL, NULL, NULL, 4, NULL, '{\"menuCode\":\"formSysMenu:fragmentSysMenu:delete\",\"permCodeList\":[\"sysMenu.delete\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075102343171, 1808020012825317384, '显示', 3, NULL, NULL, NULL, NULL, NULL, 1, NULL, '{\"menuCode\":\"formSysDict:fragmentSysDict\",\"permCodeList\":[\"globalDict.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075102343172, 1808020012825317384, '新增', 3, NULL, NULL, NULL, NULL, NULL, 2, NULL, '{\"menuCode\":\"formSysDict:fragmentSysDict:add\",\"permCodeList\":[\"globalDict.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075102343173, 1808020012825317384, '编辑', 3, NULL, NULL, NULL, NULL, NULL, 3, NULL, '{\"menuCode\":\"formSysDict:fragmentSysDict:update\",\"permCodeList\":[\"globalDict.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075102343174, 1808020012825317384, '删除', 3, NULL, NULL, NULL, NULL, NULL, 4, NULL, '{\"menuCode\":\"formSysDict:fragmentSysDict:delete\",\"permCodeList\":[\"globalDict.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075102343175, 1808020012825317384, '同步缓存', 3, NULL, NULL, NULL, NULL, NULL, 5, NULL, '{\"menuCode\":\"formSysDict:fragmentSysDict:reloadCache\",\"permCodeList\":[\"globalDict.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075102343177, 1808020012825317385, '显示', 3, NULL, NULL, NULL, NULL, NULL, 1, NULL, '{\"menuCode\":\"formSysOperationLog:fragmentSysOperationLog\",\"permCodeList\":[\"sysOperationLog.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075102343179, 1808020012825317386, '显示', 3, NULL, NULL, NULL, NULL, NULL, 1, NULL, '{\"menuCode\":\"formSysLoginUser:fragmentLoginUser\",\"permCodeList\":[\"loginUser.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075102343180, 1808020012825317386, '强制下线', 3, NULL, NULL, NULL, NULL, NULL, 2, NULL, '{\"menuCode\":\"formSysLoginUser:fragmentLoginUser:delete\",\"permCodeList\":[\"loginUser.delete\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_operation_log +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_operation_log`; +CREATE TABLE `zz_sys_operation_log` ( + `log_id` bigint NOT NULL COMMENT '主键Id', + `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '日志描述', + `operation_type` int DEFAULT NULL COMMENT '操作类型', + `service_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '接口所在服务名称', + `api_class` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '调用的controller全类名', + `api_method` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '调用的controller中的方法', + `session_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '用户会话sessionId', + `trace_id` char(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '每次请求的Id', + `elapse` int DEFAULT NULL COMMENT '调用时长', + `request_method` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'HTTP 请求方法,如GET', + `request_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'HTTP 请求地址', + `request_arguments` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT 'controller接口参数', + `response_result` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'controller应答结果', + `request_ip` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '请求IP', + `success` bit(1) DEFAULT NULL COMMENT '应答状态', + `error_msg` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '错误信息', + `tenant_id` bigint DEFAULT NULL COMMENT '租户Id', + `operator_id` bigint DEFAULT NULL COMMENT '操作员Id', + `operator_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '操作员名称', + `operation_time` datetime DEFAULT NULL COMMENT '操作时间', + PRIMARY KEY (`log_id`), + KEY `idx_trace_id_idx` (`trace_id`), + KEY `idx_operation_type_idx` (`operation_type`), + KEY `idx_operation_time_idx` (`operation_time`) USING BTREE, + KEY `idx_success` (`success`) USING BTREE, + KEY `idx_elapse` (`elapse`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='系统操作日志表'; + +-- ---------------------------- +-- Records of zz_sys_operation_log +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_operation_log` VALUES (1809037495178891264, '', 0, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.LoginController', 'com.orangeforms.webadmin.upms.controller.LoginController.doLogin', NULL, 'c5eafaee0e294b3b8fe1ddc47a73aa6f', 526, 'POST', '/admin/upms/login/doLogin', '{\"password\":\"U7kblCgd8NWaoUrEH%2B0j0ocRESztOUkH4L1eMANf40rAVWfgTmw8w1D2QeH2b99bxJQRCoELhiJDo3NbdN8sodZf%2BWa%2BRoH8URHmG1qziSMw4C%2Fc40gR1x4vclxMrq9jN1d3yP2gVljlaxVmMQcVsLqGsgcxfvyucwYzClifRUY%3D\",\"loginName\":\"admin\"}', NULL, '192.168.43.167', b'0', '用户名或密码错误,请重试!', NULL, NULL, NULL, '2024-07-05 09:32:04'); +INSERT INTO `zz_sys_operation_log` VALUES (1809037516607590400, '', 0, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.LoginController', 'com.orangeforms.webadmin.upms.controller.LoginController.doLogin', NULL, 'f1104bc680014a999321a6ca3c240485', 136, 'POST', '/admin/upms/login/doLogin', '{\"password\":\"MYjsPjZgslAadC1%2FhwPRNyG5yvtl%2BRVWJGOj0MfPNNJyTMMBgPrymEsoMsR%2FnSog7TdIborw%2BYgO9o31KFowqf3I3Gw6oI0qXkDbJKBqeDqkKKoOa95J9ITm7TKHKYcKu15xhmQvmU1OIMs59A2w39Cx1Z58I7gtbtHHL34iVJg%3D\",\"loginName\":\"admin\"}', NULL, '192.168.43.167', b'0', '用户名或密码错误,请重试!', NULL, NULL, NULL, '2024-07-05 09:32:09'); +INSERT INTO `zz_sys_operation_log` VALUES (1809037535469375488, '', 0, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.LoginController', 'com.orangeforms.webadmin.upms.controller.LoginController.doLogin', 'Authorization:login:token-session:5fb5b15d-2b4c-4063-ae55-5b0ec195fa39', '58de29f3ec22457d8f4f980a350cf623', 579, 'POST', '/admin/upms/login/doLogin', '{\"password\":\"i%2BcOZFUuWVmCCh%2B1ZhtpXTD8RNG1S4GMABC0dZssCPYckczkR%2FeRSuiYCMlDLaUa1oN%2BPeZRvj3zPKmDcuDyi0Jewxq7kTFyFAy%2Fbrep5MD3i2X%2BtV9B%2FT3CMMdbdOMa1OVP1AUO%2FBbmGdu0iK3UpvL608mJx1vqbpLRynYBazc%3D\",\"loginName\":\"admin\"}', NULL, '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 09:32:13'); +INSERT INTO `zz_sys_operation_log` VALUES (1809037772132978688, '', 10, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.SysRoleController', 'com.orangeforms.webadmin.upms.controller.SysRoleController.add', 'Authorization:login:token-session:5fb5b15d-2b4c-4063-ae55-5b0ec195fa39', 'cd5eb86b69094458881aa6dcb04aa766', 5496, 'POST', '/admin/upms/sysRole/add', '{\"menuIdListString\":\"1392786476428693504,1392786549942259712,1392786950682841088,1634009076981567488,1418057714138877952,1418057835631087616,1418058289182150656,1418058744037642240,1418059005175009280,1418059167532322816,1418059283920064512,1423161217970606080,1808020011080486913,1808020012825317376,1808020075098148866,1808020075098148867,1808020075098148868,1808020075098148869,1808020075098148870,1808020012825317377,1808020075098148872,1808020075098148873,1808020075098148874,1808020075098148875,1808020075098148876,1808020075098148877,1808020012825317378,1808020075098148879,1808020075098148881,1808020075098148882,1808020075098148883,1808020075098148884,1808020075098148880,1808020075098148885,1808020075098148886,1808020075098148887,1808020012825317379,1808020075098148889,1808020075098148891,1808020075098148892,1808020075098148893,1808020075098148894,1808020075098148890,1808020075098148895,1808020075098148896,1808020075098148897,1808020012825317380,1808020075098148899,1808020075098148900,1808020075098148901,1808020075098148902,1808020075098148903,1808020012825317381,1808020075098148905,1808020075098148906,1808020075098148907,1808020075098148908,1808020012825317384,1808020075102343171,1808020075102343172,1808020075102343173,1808020075102343174,1808020075102343175,1808020012825317385,1808020075102343177,1808020012825317386,1808020075102343179,1808020075102343180\",\"sysRoleDto\":{\"roleName\":\"查看全部\"}}', '{\"data\":1809037772728569856,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 09:33:10'); +INSERT INTO `zz_sys_operation_log` VALUES (1809037881738530816, '', 10, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.SysDataPermController', 'com.orangeforms.webadmin.upms.controller.SysDataPermController.add', 'Authorization:login:token-session:5fb5b15d-2b4c-4063-ae55-5b0ec195fa39', '85746a39a3a34191884eb30453ecc237', 220, 'POST', '/admin/upms/sysDataPerm/add', '{\"sysDataPermDto\":{\"dataPermName\":\"查看全部\",\"ruleType\":0},\"menuIdListString\":\"\"}', '{\"data\":1809037881759502336,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 09:33:36'); +INSERT INTO `zz_sys_operation_log` VALUES (1809037927917817856, '', 10, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.SysPostController', 'com.orangeforms.webadmin.upms.controller.SysPostController.add', 'Authorization:login:token-session:5fb5b15d-2b4c-4063-ae55-5b0ec195fa39', 'fa4bf0f0b80748249bdfb4c78bb93b8d', 190, 'POST', '/admin/upms/sysPost/add', '{\"sysPostDto\":{\"leaderPost\":true,\"postLevel\":1,\"postName\":\"领导岗位\"}}', '{\"data\":1809037927934595072,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 09:33:47'); +INSERT INTO `zz_sys_operation_log` VALUES (1809037967658848256, '', 10, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.SysPostController', 'com.orangeforms.webadmin.upms.controller.SysPostController.add', 'Authorization:login:token-session:5fb5b15d-2b4c-4063-ae55-5b0ec195fa39', '04da87ca21294e0296af2e162999e396', 228, 'POST', '/admin/upms/sysPost/add', '{\"sysPostDto\":{\"postLevel\":10,\"postName\":\"普通员工\"}}', '{\"data\":1809037967663042560,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 09:33:56'); +INSERT INTO `zz_sys_operation_log` VALUES (1809038123905060864, '', 10, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.SysUserController', 'com.orangeforms.webadmin.upms.controller.SysUserController.add', 'Authorization:login:token-session:5fb5b15d-2b4c-4063-ae55-5b0ec195fa39', '99bb05eadf944b54a194db3152773b13', 635, 'POST', '/admin/upms/sysUser/add', '{\"sysUserDto\":{\"deptId\":1808020008341606402,\"loginName\":\"userA\",\"password\":\"123456\",\"showName\":\"员工A\",\"userStatus\":0,\"userType\":2},\"dataPermIdListString\":\"1809037881759502336\",\"deptPostIdListString\":\"1809038003968937984\",\"roleIdListString\":\"1809037772728569856\"}', '{\"data\":1809038124504846336,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 09:34:34'); +INSERT INTO `zz_sys_operation_log` VALUES (1809042287854882816, '', 15, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.SysMenuController', 'com.orangeforms.webadmin.upms.controller.SysMenuController.update', 'Authorization:login:token-session:5fb5b15d-2b4c-4063-ae55-5b0ec195fa39', '68dd67ca9821460caee6986c5c3c3354', 420, 'POST', '/admin/upms/sysMenu/update', '{\"sysMenuDto\":{\"extraData\":\"{\\\"bindType\\\":0,\\\"menuCode\\\":\\\"formSysDept:fragmentSysDept:add\\\",\\\"permCodeList\\\":[\\\"sysDept.add\\\"]}\",\"icon\":\"\",\"menuId\":1808020075098148873,\"menuName\":\"新增\",\"menuType\":3,\"parentId\":1808020012825317377,\"showOrder\":2}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 09:51:06'); +INSERT INTO `zz_sys_operation_log` VALUES (1809050375580291072, '', 5, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.LoginController', 'com.orangeforms.webadmin.upms.controller.LoginController.doLogout', 'Authorization:login:token-session:5fb5b15d-2b4c-4063-ae55-5b0ec195fa39', '8611984bfad74113bcc5f5a2d30f0557', 36, 'POST', '/admin/upms/login/doLogout', '{}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 10:23:15'); +INSERT INTO `zz_sys_operation_log` VALUES (1809050381297127424, '', 0, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.LoginController', 'com.orangeforms.webadmin.upms.controller.LoginController.doLogin', NULL, 'bb940a20dbac4f11b7d448ebe11668c4', 466, 'POST', '/admin/upms/login/doLogin', '{\"password\":\"jiRS2mxriWjx778WM%2FJql65bpRfu7BaqVkPrDySclvJ7%2B%2B0KSuAIZ557bEFocQnCWbfLJwRFokTUDastSpEeiFAsd1kwv6oZyQimj4KCyDtin6P6gPsn2GRQrFKACkOKBXY70FeGgQvaVwWBEGo6EzdfJw9adJOGf2WIigrIajk%3D\",\"loginName\":\"admin\"}', NULL, '192.168.43.167', b'0', '用户名或密码错误,请重试!', NULL, NULL, NULL, '2024-07-05 10:23:16'); +INSERT INTO `zz_sys_operation_log` VALUES (1809050432673157120, '', 0, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.LoginController', 'com.orangeforms.webadmin.upms.controller.LoginController.doLogin', NULL, 'ffe77e34ec35454da6e71b0cef7f2ea8', 143, 'POST', '/admin/upms/login/doLogin', '{\"password\":\"Kdkf8xz%2Fay2lKRidpUGWBJM7%2BlvxTVpjdSNLCuL1yx6LbVvTPo7PD5zFBLKMPWeSrtostyAFybz6lAAHpdCnQWjmbBbpMExTmY74O12EQySXOQBwrmH3yltq9MXJI5qRJ24imMxYyTvcX2yDMbEfDF3zcC404GvTgX0gexCmTjs%3D\",\"loginName\":\"userA\"}', NULL, '192.168.43.167', b'0', '用户名或密码错误,请重试!', NULL, NULL, NULL, '2024-07-05 10:23:28'); +INSERT INTO `zz_sys_operation_log` VALUES (1809050456257728512, '', 0, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.LoginController', 'com.orangeforms.webadmin.upms.controller.LoginController.doLogin', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', 'b43789173f9244aa803866db7bafca73', 460, 'POST', '/admin/upms/login/doLogin', '{\"password\":\"gYCq1nWZHSsvg35HCgnRzw23kN3PRTZJY%2Bt2bcZWliYf11o14OHEDhsH12nCC4LYn00UEDoYWbbMdiwNzQFmcgmbJq4%2Fu6uxURokHpI%2BEexZnL5IzWBb2P53hGBwUkOO36jRfbTm%2B0qRtIbpATs74jpc1L%2FFbT18%2Fj%2FN9C3bpq4%3D\",\"loginName\":\"userA\"}', NULL, '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:23:34'); +INSERT INTO `zz_sys_operation_log` VALUES (1809050496074256384, '', 15, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.SysUserController', 'com.orangeforms.webadmin.upms.controller.SysUserController.update', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', '8926e20ea352417aab2234d2de2c1fea', 903, 'POST', '/admin/upms/sysUser/update', '{\"sysUserDto\":{\"deptId\":1808020008341606402,\"loginName\":\"userA\",\"showName\":\"员工A\",\"userId\":1809038124504846336,\"userStatus\":0,\"userType\":2},\"dataPermIdListString\":\"1809037881759502336\",\"deptPostIdListString\":\"1809038003968937984\",\"roleIdListString\":\"1809037772728569856\"}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:23:43'); +INSERT INTO `zz_sys_operation_log` VALUES (1809051198259466240, '', 10, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowCategoryController', 'com.orangeforms.common.flow.controller.FlowCategoryController.add', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', 'cd9d22e5fd194e7dac6c90531cab52dd', 249, 'POST', '/admin/flow/flowCategory/add', '{\"flowCategoryDto\":{\"code\":\"TEST\",\"name\":\"测试分类\",\"showOrder\":1}}', '{\"data\":1809051198460792832,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:26:31'); +INSERT INTO `zz_sys_operation_log` VALUES (1809052045043306496, '', 10, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryController', 'com.orangeforms.common.flow.controller.FlowEntryController.add', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', '66225485743a44df81882b0b70885c69', 478, 'POST', '/admin/flow/flowEntry/add', '{\"flowEntryDto\":{\"bindFormType\":1,\"categoryId\":1809051198460792832,\"defaultRouterName\":\"AAA\",\"diagramType\":0,\"encodedRule\":\"{\\\"middle\\\":\\\"DD\\\",\\\"idWidth\\\":5,\\\"prefix\\\":\\\"AA\\\",\\\"precisionTo\\\":\\\"DAYS\\\",\\\"calculateWhenView\\\":true}\",\"extensionData\":\"{\\\"approvalStatusDict\\\":[{\\\"id\\\":1,\\\"name\\\":\\\"同意\\\"},{\\\"id\\\":2,\\\"name\\\":\\\"拒绝\\\"},{\\\"id\\\":3,\\\"name\\\":\\\"驳回\\\"},{\\\"id\\\":4,\\\"name\\\":\\\"会签同意\\\"},{\\\"id\\\":5,\\\"name\\\":\\\"会签拒绝\\\"}],\\\"notifyTypes\\\":[],\\\"cascadeDeleteBusinessData\\\":false,\\\"supportRevive\\\":false}\",\"processDefinitionKey\":\"AAA\",\"processDefinitionName\":\"AAA\"}}', '{\"data\":1809052045395628032,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:29:53'); +INSERT INTO `zz_sys_operation_log` VALUES (1809052080904605696, '', 10, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryVariableController', 'com.orangeforms.common.flow.controller.FlowEntryVariableController.add', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', 'c7804ebbe24d492b82c23cb5f3b25879', 225, 'POST', '/admin/flow/flowEntryVariable/add', '{\"flowEntryVariableDto\":{\"builtin\":false,\"entryId\":1809052045395628032,\"showName\":\"AAA\",\"variableName\":\"aaa\",\"variableType\":1}}', '{\"data\":1809052080921382912,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:30:01'); +INSERT INTO `zz_sys_operation_log` VALUES (1809052112206696448, '', 15, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryController', 'com.orangeforms.common.flow.controller.FlowEntryController.update', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', '9c28172a4ac74b448439334f0ea44d34', 306, 'POST', '/admin/flow/flowEntry/update', '{\"flowEntryDto\":{\"bindFormType\":1,\"categoryId\":1809051198460792832,\"defaultRouterName\":\"AAA\",\"diagramType\":0,\"encodedRule\":\"{\\\"middle\\\":\\\"DD\\\",\\\"idWidth\\\":5,\\\"prefix\\\":\\\"AA\\\",\\\"precisionTo\\\":\\\"DAYS\\\",\\\"calculateWhenView\\\":true}\",\"entryId\":1809052045395628032,\"extensionData\":\"{\\\"approvalStatusDict\\\":[{\\\"id\\\":1,\\\"name\\\":\\\"同意\\\",\\\"_X_ROW_KEY\\\":\\\"row_28\\\"},{\\\"id\\\":2,\\\"name\\\":\\\"拒绝\\\",\\\"_X_ROW_KEY\\\":\\\"row_29\\\"},{\\\"id\\\":3,\\\"name\\\":\\\"驳回\\\",\\\"_X_ROW_KEY\\\":\\\"row_30\\\"},{\\\"id\\\":4,\\\"name\\\":\\\"会签同意\\\",\\\"_X_ROW_KEY\\\":\\\"row_31\\\"},{\\\"id\\\":5,\\\"name\\\":\\\"会签拒绝\\\",\\\"_X_ROW_KEY\\\":\\\"row_32\\\"},{\\\"name\\\":\\\"AAA\\\",\\\"id\\\":11}],\\\"notifyTypes\\\":[]}\",\"processDefinitionKey\":\"AAA\",\"processDefinitionName\":\"AAA\"}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:30:09'); +INSERT INTO `zz_sys_operation_log` VALUES (1809052122159779840, '', 15, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryController', 'com.orangeforms.common.flow.controller.FlowEntryController.update', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', 'c9af56a061bb4a87a964cb617f4f9c15', 201, 'POST', '/admin/flow/flowEntry/update', '{\"flowEntryDto\":{\"bindFormType\":1,\"categoryId\":1809051198460792832,\"defaultRouterName\":\"AAA\",\"diagramType\":0,\"encodedRule\":\"{\\\"middle\\\":\\\"DD\\\",\\\"idWidth\\\":5,\\\"prefix\\\":\\\"AA\\\",\\\"precisionTo\\\":\\\"DAYS\\\",\\\"calculateWhenView\\\":true}\",\"entryId\":1809052045395628032,\"extensionData\":\"{\\\"approvalStatusDict\\\":[{\\\"id\\\":1,\\\"name\\\":\\\"同意\\\",\\\"_X_ROW_KEY\\\":\\\"row_28\\\"},{\\\"id\\\":2,\\\"name\\\":\\\"拒绝\\\",\\\"_X_ROW_KEY\\\":\\\"row_29\\\"},{\\\"id\\\":3,\\\"name\\\":\\\"驳回\\\",\\\"_X_ROW_KEY\\\":\\\"row_30\\\"},{\\\"id\\\":4,\\\"name\\\":\\\"会签同意\\\",\\\"_X_ROW_KEY\\\":\\\"row_31\\\"},{\\\"id\\\":5,\\\"name\\\":\\\"会签拒绝\\\",\\\"_X_ROW_KEY\\\":\\\"row_32\\\"},{\\\"name\\\":\\\"AAA\\\",\\\"id\\\":11,\\\"_X_ROW_KEY\\\":\\\"row_33\\\"}],\\\"notifyTypes\\\":[],\\\"cascadeDeleteBusinessData\\\":false,\\\"supportRevive\\\":false}\",\"processDefinitionKey\":\"AAA\",\"processDefinitionName\":\"AAA\"}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:30:11'); +INSERT INTO `zz_sys_operation_log` VALUES (1809052746851028992, '', 15, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryController', 'com.orangeforms.common.flow.controller.FlowEntryController.update', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', '6609a8762f6c49af9f570b746a30b8ac', 297, 'POST', '/admin/flow/flowEntry/update', '{\"flowEntryDto\":{\"bindFormType\":1,\"categoryId\":1809051198460792832,\"defaultRouterName\":\"AAA\",\"diagramType\":0,\"encodedRule\":\"{\\\"middle\\\":\\\"DD\\\",\\\"idWidth\\\":5,\\\"prefix\\\":\\\"AA\\\",\\\"precisionTo\\\":\\\"DAYS\\\",\\\"calculateWhenView\\\":true}\",\"entryId\":1809052045395628032,\"extensionData\":\"{\\\"approvalStatusDict\\\":[{\\\"id\\\":1,\\\"name\\\":\\\"同意\\\",\\\"_X_ROW_KEY\\\":\\\"row_28\\\"},{\\\"id\\\":2,\\\"name\\\":\\\"拒绝\\\",\\\"_X_ROW_KEY\\\":\\\"row_29\\\"},{\\\"id\\\":3,\\\"name\\\":\\\"驳回\\\",\\\"_X_ROW_KEY\\\":\\\"row_30\\\"},{\\\"id\\\":4,\\\"name\\\":\\\"会签同意\\\",\\\"_X_ROW_KEY\\\":\\\"row_31\\\"},{\\\"id\\\":5,\\\"name\\\":\\\"会签拒绝\\\",\\\"_X_ROW_KEY\\\":\\\"row_32\\\"},{\\\"name\\\":\\\"AAA\\\",\\\"id\\\":11,\\\"_X_ROW_KEY\\\":\\\"row_33\\\"}],\\\"notifyTypes\\\":[],\\\"cascadeDeleteBusinessData\\\":false,\\\"supportRevive\\\":false}\",\"processDefinitionKey\":\"AAA\",\"processDefinitionName\":\"AAA\",\"status\":0}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:32:40'); +INSERT INTO `zz_sys_operation_log` VALUES (1809052753826156544, '', 15, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryController', 'com.orangeforms.common.flow.controller.FlowEntryController.update', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', 'b1c15eb123b14ae68876d1e026b8f498', 267, 'POST', '/admin/flow/flowEntry/update', '{\"flowEntryDto\":{\"bindFormType\":1,\"categoryId\":1809051198460792832,\"defaultRouterName\":\"AAA\",\"diagramType\":0,\"encodedRule\":\"{\\\"middle\\\":\\\"DD\\\",\\\"idWidth\\\":5,\\\"prefix\\\":\\\"AA\\\",\\\"precisionTo\\\":\\\"DAYS\\\",\\\"calculateWhenView\\\":true}\",\"entryId\":1809052045395628032,\"extensionData\":\"{\\\"approvalStatusDict\\\":[{\\\"id\\\":1,\\\"name\\\":\\\"同意\\\",\\\"_X_ROW_KEY\\\":\\\"row_28\\\"},{\\\"id\\\":2,\\\"name\\\":\\\"拒绝\\\",\\\"_X_ROW_KEY\\\":\\\"row_29\\\"},{\\\"id\\\":3,\\\"name\\\":\\\"驳回\\\",\\\"_X_ROW_KEY\\\":\\\"row_30\\\"},{\\\"id\\\":4,\\\"name\\\":\\\"会签同意\\\",\\\"_X_ROW_KEY\\\":\\\"row_31\\\"},{\\\"id\\\":5,\\\"name\\\":\\\"会签拒绝\\\",\\\"_X_ROW_KEY\\\":\\\"row_32\\\"},{\\\"name\\\":\\\"AAA\\\",\\\"id\\\":11,\\\"_X_ROW_KEY\\\":\\\"row_33\\\"}],\\\"notifyTypes\\\":[],\\\"cascadeDeleteBusinessData\\\":false,\\\"supportRevive\\\":false}\",\"processDefinitionKey\":\"AAA\",\"processDefinitionName\":\"AAA\",\"status\":0}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:32:42'); +INSERT INTO `zz_sys_operation_log` VALUES (1809055300347498496, '', 10, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineDblinkController', 'com.orangeforms.common.online.controller.OnlineDblinkController.add', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', '4552709db33b4ac38520c97cbfbd84fb', 180, 'POST', '/admin/online/onlineDblink/add', '{\"onlineDblinkDto\":{\"configuration\":\"{\\\"sid\\\":true,\\\"initialPoolSize\\\":5,\\\"minPoolSize\\\":5,\\\"maxPoolSize\\\":50,\\\"host\\\":\\\"121.37.102.103\\\",\\\"port\\\":3306,\\\"database\\\":\\\"zzdemo-online-open\\\",\\\"username\\\":\\\"root\\\",\\\"password\\\":\\\"TianLiujielei231\\\"}\",\"dblinkName\":\"mysql-test\",\"dblinkType\":0}}', '{\"data\":1809055300360081408,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:42:49'); +INSERT INTO `zz_sys_operation_log` VALUES (1809055451015286784, '', 10, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlinePageController', 'com.orangeforms.common.online.controller.OnlinePageController.add', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', 'f6a28f34b7d94f0ca0ea0efdb23b59b6', 307, 'POST', '/admin/online/onlinePage/add', '{\"onlinePageDto\":{\"pageCode\":\"test\",\"pageName\":\"test\",\"pageType\":1,\"status\":1}}', '{\"data\":1809055451229196288,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:43:25'); +INSERT INTO `zz_sys_operation_log` VALUES (1809055625460584448, '', 10, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineDatasourceController', 'com.orangeforms.common.online.controller.OnlineDatasourceController.add', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', 'cc233f444b9741e79e85902c6ced44c5', 2989, 'POST', '/admin/online/onlineDatasource/add', '{\"onlineDatasourceDto\":{\"datasourceName\":\"test\",\"dblinkId\":1809055300360081408,\"masterTableName\":\"zz_flow_entry\",\"variableName\":\"test\"},\"pageId\":1809055451229196288}', '{\"data\":1809055636340609024,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:44:06'); +INSERT INTO `zz_sys_operation_log` VALUES (1809055701822083072, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlinePageController', 'com.orangeforms.common.online.controller.OnlinePageController.update', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', 'b9943033448544c5a5dcb93fe450bbeb', 245, 'POST', '/admin/online/onlinePage/update', '{\"onlinePageDto\":{\"pageCode\":\"test\",\"pageId\":1809055451229196288,\"pageName\":\"test\",\"pageType\":1,\"status\":2}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:44:25'); +INSERT INTO `zz_sys_operation_log` VALUES (1809055740065746944, '', 10, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineFormController', 'com.orangeforms.common.online.controller.OnlineFormController.add', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', 'abc44f1518ed471597d38fad6161e8ae', 589, 'POST', '/admin/online/onlineForm/add', '{\"onlineFormDto\":{\"datasourceIdList\":[1809055636340609024],\"formCode\":\"aaa\",\"formKind\":5,\"formName\":\"aaa\",\"formType\":1,\"masterTableId\":1809055626488188928,\"pageId\":1809055451229196288,\"paramsJson\":\"[]\",\"widgetJson\":\"{\\\"pc\\\":{\\\"filterItemWidth\\\":350,\\\"gutter\\\":20,\\\"labelWidth\\\":100,\\\"labelPosition\\\":\\\"right\\\",\\\"tableWidget\\\":{\\\"widgetType\\\":100,\\\"bindData\\\":{\\\"defaultValue\\\":{}},\\\"operationList\\\":[{\\\"id\\\":1,\\\"type\\\":10,\\\"name\\\":\\\"批量删除\\\",\\\"enabled\\\":false,\\\"builtin\\\":true,\\\"rowOperation\\\":false,\\\"btnType\\\":\\\"danger\\\",\\\"plain\\\":true,\\\"readOnly\\\":false,\\\"showOrder\\\":0,\\\"eventList\\\":[]},{\\\"id\\\":2,\\\"type\\\":0,\\\"name\\\":\\\"新建\\\",\\\"enabled\\\":false,\\\"builtin\\\":true,\\\"rowOperation\\\":false,\\\"btnType\\\":\\\"primary\\\",\\\"plain\\\":false,\\\"readOnly\\\":false,\\\"showOrder\\\":1,\\\"eventList\\\":[]},{\\\"id\\\":3,\\\"type\\\":1,\\\"name\\\":\\\"编辑\\\",\\\"enabled\\\":false,\\\"builtin\\\":true,\\\"rowOperation\\\":true,\\\"btnClass\\\":\\\"table-btn success\\\",\\\"readOnly\\\":false,\\\"showOrder\\\":10,\\\"eventList\\\":[]},{\\\"id\\\":4,\\\"type\\\":2,\\\"name\\\":\\\"删除\\\",\\\"enabled\\\":false,\\\"builtin\\\":true,\\\"rowOperation\\\":true,\\\"btnClass\\\":\\\"table-btn delete\\\",\\\"readOnly\\\":false,\\\"showOrder\\\":15,\\\"eventList\\\":[]}],\\\"showName\\\":\\\"表格组件\\\",\\\"variableName\\\":\\\"table1720147467397\\\",\\\"props\\\":{\\\"span\\\":24,\\\"height\\\":300,\\\"paddingBottom\\\":0,\\\"paged\\\":true,\\\"pageSize\\\":10,\\\"operationColumnWidth\\\":160,\\\"tableColumnList\\\":[]},\\\"eventList\\\":[],\\\"childWidgetList\\\":[],\\\"style\\\":{},\\\"supportOperation\\\":true},\\\"leftWidget\\\":{\\\"widgetType\\\":13,\\\"bindData\\\":{\\\"defaultValue\\\":{}},\\\"showName\\\":\\\"树形选择组件\\\",\\\"variableName\\\":\\\"tree1720147467397\\\",\\\"props\\\":{\\\"span\\\":24,\\\"height\\\":300,\\\"dictInfo\\\":{},\\\"required\\\":false,\\\"disabled\\\":false},\\\"eventList\\\":[],\\\"childWidgetList\\\":[],\\\"style\\\":{},\\\"supportOperation\\\":false},\\\"operationList\\\":[{\\\"id\\\":0,\\\"type\\\":3,\\\"name\\\":\\\"导出\\\",\\\"enabled\\\":false,\\\"builtin\\\":true,\\\"rowOperation\\\":false,\\\"btnType\\\":\\\"primary\\\",\\\"plain\\\":true,\\\"paramList\\\":[],\\\"eventList\\\":[],\\\"readOnly\\\":false,\\\"showOrder\\\":0},{\\\"id\\\":1,\\\"type\\\":10,\\\"name\\\":\\\"批量删除\\\",\\\"en', '{\"data\":1809055741093351424,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:44:34'); +INSERT INTO `zz_sys_operation_log` VALUES (1809056459653124096, '', 20, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineFormController', 'com.orangeforms.common.online.controller.OnlineFormController.delete', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', '406cd42f8c3a408fa8928e94a8ebdcc6', 329, 'POST', '/admin/online/onlineForm/delete', '{\"formId\":1809055741093351424}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:47:25'); +INSERT INTO `zz_sys_operation_log` VALUES (1809056484886056960, '', 20, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineFormController', 'com.orangeforms.common.online.controller.OnlineFormController.delete', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', 'ac3418b76d474c99862e49acab906011', 76, 'POST', '/admin/online/onlineForm/delete', '{\"formId\":1809055741093351424}', '{\"errorCode\":\"DATA_NOT_EXIST\",\"errorMessage\":\"数据不存在,请刷新后重试!\",\"success\":false}', '192.168.43.167', b'0', '数据不存在,请刷新后重试!', NULL, 1809038124504846336, 'userA', '2024-07-05 10:47:31'); +INSERT INTO `zz_sys_operation_log` VALUES (1809056769645744128, '', 10, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineFormController', 'com.orangeforms.common.online.controller.OnlineFormController.add', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', '5ac915cc240f4463817134fbcba16d94', 508, 'POST', '/admin/online/onlineForm/add', '{\"onlineFormDto\":{\"datasourceIdList\":[1809055636340609024],\"formCode\":\"aaa\",\"formKind\":5,\"formName\":\"aaa\",\"formType\":1,\"masterTableId\":1809055626488188928,\"pageId\":1809055451229196288,\"paramsJson\":\"[]\",\"widgetJson\":\"{\\\"pc\\\":{\\\"filterItemWidth\\\":350,\\\"gutter\\\":20,\\\"labelWidth\\\":100,\\\"labelPosition\\\":\\\"right\\\",\\\"tableWidget\\\":{\\\"widgetType\\\":100,\\\"bindData\\\":{\\\"defaultValue\\\":{}},\\\"operationList\\\":[{\\\"id\\\":1,\\\"type\\\":10,\\\"name\\\":\\\"批量删除\\\",\\\"enabled\\\":false,\\\"builtin\\\":true,\\\"rowOperation\\\":false,\\\"btnType\\\":\\\"danger\\\",\\\"plain\\\":true,\\\"readOnly\\\":false,\\\"showOrder\\\":0,\\\"eventList\\\":[]},{\\\"id\\\":2,\\\"type\\\":0,\\\"name\\\":\\\"新建\\\",\\\"enabled\\\":false,\\\"builtin\\\":true,\\\"rowOperation\\\":false,\\\"btnType\\\":\\\"primary\\\",\\\"plain\\\":false,\\\"readOnly\\\":false,\\\"showOrder\\\":1,\\\"eventList\\\":[]},{\\\"id\\\":3,\\\"type\\\":1,\\\"name\\\":\\\"编辑\\\",\\\"enabled\\\":false,\\\"builtin\\\":true,\\\"rowOperation\\\":true,\\\"btnClass\\\":\\\"table-btn success\\\",\\\"readOnly\\\":false,\\\"showOrder\\\":10,\\\"eventList\\\":[]},{\\\"id\\\":4,\\\"type\\\":2,\\\"name\\\":\\\"删除\\\",\\\"enabled\\\":false,\\\"builtin\\\":true,\\\"rowOperation\\\":true,\\\"btnClass\\\":\\\"table-btn delete\\\",\\\"readOnly\\\":false,\\\"showOrder\\\":15,\\\"eventList\\\":[]}],\\\"showName\\\":\\\"表格组件\\\",\\\"variableName\\\":\\\"table1720147715974\\\",\\\"props\\\":{\\\"span\\\":24,\\\"height\\\":300,\\\"paddingBottom\\\":0,\\\"paged\\\":true,\\\"pageSize\\\":10,\\\"operationColumnWidth\\\":160,\\\"tableColumnList\\\":[]},\\\"eventList\\\":[],\\\"childWidgetList\\\":[],\\\"style\\\":{},\\\"supportOperation\\\":true},\\\"leftWidget\\\":{\\\"widgetType\\\":13,\\\"bindData\\\":{\\\"defaultValue\\\":{}},\\\"showName\\\":\\\"树形选择组件\\\",\\\"variableName\\\":\\\"tree1720147715974\\\",\\\"props\\\":{\\\"span\\\":24,\\\"height\\\":300,\\\"dictInfo\\\":{},\\\"required\\\":false,\\\"disabled\\\":false},\\\"eventList\\\":[],\\\"childWidgetList\\\":[],\\\"style\\\":{},\\\"supportOperation\\\":false},\\\"operationList\\\":[{\\\"id\\\":0,\\\"type\\\":3,\\\"name\\\":\\\"导出\\\",\\\"enabled\\\":false,\\\"builtin\\\":true,\\\"rowOperation\\\":false,\\\"btnType\\\":\\\"primary\\\",\\\"plain\\\":true,\\\"paramList\\\":[],\\\"eventList\\\":[],\\\"readOnly\\\":false,\\\"showOrder\\\":0},{\\\"id\\\":1,\\\"type\\\":10,\\\"name\\\":\\\"批量删除\\\",\\\"en', '{\"data\":1809056770480410624,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:48:39'); +INSERT INTO `zz_sys_operation_log` VALUES (1809057010251993088, '', 10, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineFormController', 'com.orangeforms.common.online.controller.OnlineFormController.clone', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', '32321e03b4ac418ca5d6fea8ac744a09', 453, 'POST', '/admin/online/onlineForm/clone', '{\"formId\":1809056770480410624}', '{\"data\":1809057010814029824,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:49:37'); +INSERT INTO `zz_sys_operation_log` VALUES (1809057028065202176, '', 20, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineFormController', 'com.orangeforms.common.online.controller.OnlineFormController.delete', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', '45d08665cef04be4b9a20cc8b9e3505d', 302, 'POST', '/admin/online/onlineForm/delete', '{\"formId\":1809057010814029824}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:49:41'); +INSERT INTO `zz_sys_operation_log` VALUES (1809131899889651712, '', 0, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.LoginController', 'com.orangeforms.webadmin.upms.controller.LoginController.doLogin', NULL, '17cfa5afe5374abda116be3f69094fcf', 497, 'POST', '/admin/upms/login/doLogin', '{\"password\":\"ekih%2BFzFR03abVnW2zJLYZJ%2FEHw2EpMZKuW9698GRI6zsXrhLXX1UjKEN11L31%2BrePfnFLvp%2Bk408bZ6CLtfjhTjRR9wbOzPocmtbK063VM%2F7Crw9nAlaSEobYPwWlHuiugw8CcVPPWAAfiSz2yoedg5%2BBbBDx4SnWKKPz7K59Y%3D\",\"loginName\":\"admin\"}', NULL, '192.168.43.167', b'0', '用户名或密码错误,请重试!', NULL, NULL, NULL, '2024-07-05 15:47:12'); +INSERT INTO `zz_sys_operation_log` VALUES (1809131924610879488, '', 0, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.LoginController', 'com.orangeforms.webadmin.upms.controller.LoginController.doLogin', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'd2af8f5c698e4e6b8b610163e5908217', 547, 'POST', '/admin/upms/login/doLogin', '{\"password\":\"n1NyIK3vu4fhzT5kFQRSYQvehBUqZ2RK6VOeDT7NKd7Tj7Z78CV6Yg73TdJSKLH7PtQ1yrzCPE7QijTH3CCPqg6x%2FDE0ndlm0GPAmdcG8c1LKu4RrV%2BM37grdKeOtbCbohG4uishREJ9jovLiZI8twfRGCnzqEs3bKBjPybBdDw%3D\",\"loginName\":\"admin\"}', NULL, '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:47:18'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132075907813376, '', 20, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlinePageController', 'com.orangeforms.common.online.controller.OnlinePageController.delete', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'f9258eaefc164f9db3a6792c03dbaa82', 1429, 'POST', '/admin/online/onlinePage/delete', '{\"pageId\":1809055451229196288}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:47:54'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132176877293568, '', 10, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlinePageController', 'com.orangeforms.common.online.controller.OnlinePageController.add', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'f41bdd39fc984cf38b2cca8ccbefaaa1', 343, 'POST', '/admin/online/onlinePage/add', '{\"onlinePageDto\":{\"pageCode\":\"flowLeave\",\"pageName\":\"请假申请\",\"pageType\":10,\"status\":1}}', '{\"data\":1809132177523216384,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:48:18'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132250441191424, '', 10, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineDatasourceController', 'com.orangeforms.common.online.controller.OnlineDatasourceController.add', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '0db3da9d6b6048bab73a3fe445297ae1', 1653, 'POST', '/admin/online/onlineDatasource/add', '{\"onlineDatasourceDto\":{\"datasourceName\":\"请假申请\",\"dblinkId\":1809055300360081408,\"masterTableName\":\"zz_test_flow_leave\",\"variableName\":\"dsLeave\"},\"pageId\":1809132177523216384}', '{\"data\":1809132255981867008,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:48:35'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132300521181184, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '58819dae9e9f442fb21f5cadb3c5d326', 270, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"请假用户\",\"columnId\":1809132252425097216,\"columnName\":\"user_id\",\"columnShowOrder\":2,\"columnType\":\"bigint\",\"deptFilter\":false,\"fieldKind\":21,\"filterType\":0,\"fullColumnType\":\"bigint\",\"nullable\":false,\"numericPrecision\":19,\"objectFieldName\":\"userId\",\"objectFieldType\":\"Long\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:48:47'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132348223000576, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '4e7166af1f55482ea6189787d6a661fe', 267, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"开始时间\",\"columnId\":1809132253733720064,\"columnName\":\"leave_begin_time\",\"columnShowOrder\":5,\"columnType\":\"datetime\",\"deptFilter\":false,\"filterType\":0,\"fullColumnType\":\"datetime\",\"nullable\":false,\"objectFieldName\":\"leaveBeginTime\",\"objectFieldType\":\"Date\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:48:59'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132364907941888, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '5ea928dfa368402b9bcd8a8259c93097', 256, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"结束时间\",\"columnId\":1809132254102818816,\"columnName\":\"leave_end_time\",\"columnShowOrder\":6,\"columnType\":\"datetime\",\"deptFilter\":false,\"filterType\":0,\"fullColumnType\":\"datetime\",\"nullable\":false,\"objectFieldName\":\"leaveEndTime\",\"objectFieldType\":\"Date\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:49:03'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132399720665088, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'a0c6b421cd5f4f0aa6810db4abe0d301', 683, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"申请时间\",\"columnId\":1809132254388031488,\"columnName\":\"apply_time\",\"columnShowOrder\":7,\"columnType\":\"datetime\",\"deptFilter\":false,\"fieldKind\":20,\"filterType\":0,\"fullColumnType\":\"datetime\",\"nullable\":false,\"objectFieldName\":\"applyTime\",\"objectFieldType\":\"Date\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:49:11'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132453835575296, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '4a0b9a2c8a614820941b95772b82e6ba', 366, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"最后审批状态\",\"columnId\":1809132254782296064,\"columnName\":\"approval_status\",\"columnShowOrder\":8,\"columnType\":\"int\",\"deptFilter\":false,\"fieldKind\":26,\"filterType\":0,\"fullColumnType\":\"int\",\"nullable\":true,\"numericPrecision\":10,\"objectFieldName\":\"approvalStatus\",\"objectFieldType\":\"Integer\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:49:24'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132505723310080, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'e54070a44ae2487bb4810a3d920d7988', 1179, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"流程状态\",\"columnId\":1809132255327555584,\"columnName\":\"flow_status\",\"columnShowOrder\":9,\"columnType\":\"int\",\"deptFilter\":false,\"fieldKind\":26,\"filterType\":0,\"fullColumnType\":\"int\",\"nullable\":true,\"numericPrecision\":10,\"objectFieldName\":\"flowStatus\",\"objectFieldType\":\"Integer\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:49:36'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132536761159680, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '5f0e57d9c5df44a3907bd4878183c68a', 271, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"流程状态\",\"columnId\":1809132255327555584,\"columnName\":\"flow_status\",\"columnShowOrder\":9,\"columnType\":\"int\",\"deptFilter\":false,\"fieldKind\":25,\"filterType\":0,\"fullColumnType\":\"int\",\"nullable\":true,\"numericPrecision\":10,\"objectFieldName\":\"flowStatus\",\"objectFieldType\":\"Integer\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:49:43'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132559511064576, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '28063f6a43804db882504597d2d77353', 306, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"用户名\",\"columnId\":1809132255679877120,\"columnName\":\"username\",\"columnShowOrder\":10,\"columnType\":\"varchar\",\"deptFilter\":false,\"filterType\":0,\"fullColumnType\":\"varchar(255)\",\"nullable\":true,\"objectFieldName\":\"username\",\"objectFieldType\":\"String\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:49:49'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132570206539776, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlinePageController', 'com.orangeforms.common.online.controller.OnlinePageController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '48ce554a01704633a62a3aabbc394b2f', 210, 'POST', '/admin/online/onlinePage/update', '{\"onlinePageDto\":{\"pageCode\":\"flowLeave\",\"pageId\":1809132177523216384,\"pageName\":\"请假申请\",\"pageType\":10,\"status\":2}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:49:51'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132634748489728, '', 10, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineFormController', 'com.orangeforms.common.online.controller.OnlineFormController.add', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '546500c7cc10417d91f89582652f820b', 506, 'POST', '/admin/online/onlineForm/add', '{\"onlineFormDto\":{\"datasourceIdList\":[1809132255981867008],\"formCode\":\"formFlowLeave\",\"formKind\":5,\"formName\":\"请假申请\",\"formType\":10,\"masterTableId\":1809132251556876288,\"pageId\":1809132177523216384,\"paramsJson\":\"[]\",\"widgetJson\":\"{\\\"pc\\\":{\\\"gutter\\\":20,\\\"labelWidth\\\":100,\\\"labelPosition\\\":\\\"right\\\",\\\"customFieldList\\\":[],\\\"widgetList\\\":[],\\\"formEventList\\\":[],\\\"maskFieldList\\\":[],\\\"allowEventList\\\":[\\\"formCreated\\\",\\\"afterLoadFormData\\\",\\\"beforeCommitFormData\\\"],\\\"fullscreen\\\":true,\\\"supportOperation\\\":false,\\\"width\\\":800}}\"}}', '{\"data\":1809132635633487872,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:50:07'); +INSERT INTO `zz_sys_operation_log` VALUES (1809133545088618496, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '413482d6eeac4cdcb05b7423026c3f8d', 306, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"请假类型\",\"columnId\":1809132253377204224,\"columnName\":\"leave_type\",\"columnShowOrder\":4,\"columnType\":\"int\",\"deptFilter\":false,\"filterType\":0,\"fullColumnType\":\"int\",\"nullable\":false,\"numericPrecision\":10,\"objectFieldName\":\"leaveType\",\"objectFieldType\":\"Integer\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:53:44'); +INSERT INTO `zz_sys_operation_log` VALUES (1809133558430699520, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '9dad13d8ce3d4e94b0bf01b544f0c04b', 329, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"请假原因\",\"columnId\":1809132252852916224,\"columnName\":\"leave_reason\",\"columnShowOrder\":3,\"columnType\":\"varchar\",\"deptFilter\":false,\"filterType\":0,\"fullColumnType\":\"varchar(512)\",\"nullable\":false,\"objectFieldName\":\"leaveReason\",\"objectFieldType\":\"String\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:53:47'); +INSERT INTO `zz_sys_operation_log` VALUES (1809133570850033664, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '6573018ce2c547b8ab633c45affb8094', 294, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"开始时间\",\"columnId\":1809132253733720064,\"columnName\":\"leave_begin_time\",\"columnShowOrder\":5,\"columnType\":\"datetime\",\"deptFilter\":false,\"filterType\":0,\"fullColumnType\":\"datetime\",\"nullable\":false,\"objectFieldName\":\"leaveBeginTime\",\"objectFieldType\":\"Date\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:53:50'); +INSERT INTO `zz_sys_operation_log` VALUES (1809133584934506496, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '3c4aad5641704fd991b3b9717d60f039', 386, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"结束时间\",\"columnId\":1809132254102818816,\"columnName\":\"leave_end_time\",\"columnShowOrder\":6,\"columnType\":\"datetime\",\"deptFilter\":false,\"filterType\":0,\"fullColumnType\":\"datetime\",\"nullable\":false,\"objectFieldName\":\"leaveEndTime\",\"objectFieldType\":\"Date\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:53:53'); +INSERT INTO `zz_sys_operation_log` VALUES (1809133598788292608, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '1fd06e9d5bec413a8e1437968ee99920', 327, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"申请时间\",\"columnId\":1809132254388031488,\"columnName\":\"apply_time\",\"columnShowOrder\":7,\"columnType\":\"datetime\",\"deptFilter\":false,\"fieldKind\":20,\"filterType\":0,\"fullColumnType\":\"datetime\",\"nullable\":false,\"objectFieldName\":\"applyTime\",\"objectFieldType\":\"Date\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:53:57'); +INSERT INTO `zz_sys_operation_log` VALUES (1809133609777369088, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '67104da4ba934ce9904d3c5c646b4836', 281, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"最后审批状态\",\"columnId\":1809132254782296064,\"columnName\":\"approval_status\",\"columnShowOrder\":8,\"columnType\":\"int\",\"deptFilter\":false,\"fieldKind\":26,\"filterType\":0,\"fullColumnType\":\"int\",\"nullable\":true,\"numericPrecision\":10,\"objectFieldName\":\"approvalStatus\",\"objectFieldType\":\"Integer\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:53:59'); +INSERT INTO `zz_sys_operation_log` VALUES (1809133618182754304, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlinePageController', 'com.orangeforms.common.online.controller.OnlinePageController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'f3aea6a5c397400eb272d364f6b1870e', 218, 'POST', '/admin/online/onlinePage/update', '{\"onlinePageDto\":{\"pageCode\":\"flowLeave\",\"pageId\":1809132177523216384,\"pageName\":\"请假申请\",\"pageType\":10,\"status\":2}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:54:01'); +INSERT INTO `zz_sys_operation_log` VALUES (1809143621992058880, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineFormController', 'com.orangeforms.common.online.controller.OnlineFormController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'ec8cccdd9b5c42e69b2f100bc1307a59', 636, 'POST', '/admin/online/onlineForm/update', '{\"onlineFormDto\":{\"datasourceIdList\":[1809132255981867008],\"formCode\":\"formFlowLeave\",\"formId\":1809132635633487872,\"formKind\":5,\"formName\":\"请假申请\",\"formType\":10,\"masterTableId\":1809132251556876288,\"pageId\":1809132177523216384,\"widgetJson\":\"{\\\"pc\\\":{\\\"gutter\\\":20,\\\"labelWidth\\\":100,\\\"labelPosition\\\":\\\"right\\\",\\\"operationList\\\":[],\\\"customFieldList\\\":[],\\\"widgetList\\\":[{\\\"widgetType\\\":1,\\\"bindData\\\":{\\\"defaultValue\\\":{},\\\"tableId\\\":\\\"1809132251556876288\\\",\\\"columnId\\\":\\\"1809132252852916224\\\",\\\"dataType\\\":0},\\\"showName\\\":\\\"请假原因\\\",\\\"variableName\\\":\\\"leaveReason\\\",\\\"props\\\":{\\\"span\\\":24,\\\"type\\\":\\\"text\\\",\\\"placeholder\\\":\\\"\\\",\\\"show-password\\\":false,\\\"show-word-limit\\\":false,\\\"required\\\":true,\\\"disabled\\\":false,\\\"dictInfo\\\":{\\\"paramList\\\":[]},\\\"actions\\\":{}},\\\"eventList\\\":[],\\\"childWidgetList\\\":[],\\\"style\\\":{},\\\"supportOperation\\\":false}],\\\"formEventList\\\":[],\\\"maskFieldList\\\":[],\\\"width\\\":800,\\\"fullscreen\\\":true}}\"}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:33:46'); +INSERT INTO `zz_sys_operation_log` VALUES (1809143691172909056, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineFormController', 'com.orangeforms.common.online.controller.OnlineFormController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'dc39d01f441c439fa6f3e36eaf50529b', 405, 'POST', '/admin/online/onlineForm/update', '{\"onlineFormDto\":{\"datasourceIdList\":[1809132255981867008],\"formCode\":\"formFlowLeave\",\"formId\":1809132635633487872,\"formKind\":5,\"formName\":\"请假申请\",\"formType\":10,\"masterTableId\":1809132251556876288,\"pageId\":1809132177523216384,\"widgetJson\":\"{\\\"pc\\\":{\\\"gutter\\\":20,\\\"labelWidth\\\":100,\\\"labelPosition\\\":\\\"right\\\",\\\"operationList\\\":[],\\\"customFieldList\\\":[],\\\"widgetList\\\":[{\\\"widgetType\\\":3,\\\"bindData\\\":{\\\"defaultValue\\\":{},\\\"tableId\\\":\\\"1809132251556876288\\\",\\\"columnId\\\":\\\"1809132253377204224\\\",\\\"dataType\\\":0},\\\"showName\\\":\\\"请假类型\\\",\\\"variableName\\\":\\\"leaveType\\\",\\\"props\\\":{\\\"span\\\":24,\\\"placeholder\\\":\\\"\\\",\\\"step\\\":1,\\\"controls\\\":true,\\\"required\\\":true,\\\"disabled\\\":false,\\\"dictInfo\\\":{\\\"paramList\\\":[]},\\\"actions\\\":{}},\\\"eventList\\\":[],\\\"childWidgetList\\\":[],\\\"style\\\":{},\\\"supportOperation\\\":false},{\\\"widgetType\\\":1,\\\"bindData\\\":{\\\"defaultValue\\\":{},\\\"tableId\\\":\\\"1809132251556876288\\\",\\\"columnId\\\":\\\"1809132252852916224\\\",\\\"dataType\\\":0},\\\"showName\\\":\\\"请假原因\\\",\\\"variableName\\\":\\\"leaveReason\\\",\\\"props\\\":{\\\"span\\\":24,\\\"type\\\":\\\"text\\\",\\\"placeholder\\\":\\\"\\\",\\\"show-password\\\":false,\\\"show-word-limit\\\":false,\\\"required\\\":true,\\\"disabled\\\":false,\\\"dictInfo\\\":{\\\"paramList\\\":[]},\\\"actions\\\":{}},\\\"eventList\\\":[],\\\"childWidgetList\\\":[],\\\"style\\\":{}}],\\\"formEventList\\\":[],\\\"maskFieldList\\\":[],\\\"width\\\":800,\\\"fullscreen\\\":true}}\"}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:34:03'); +INSERT INTO `zz_sys_operation_log` VALUES (1809143765026213888, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineFormController', 'com.orangeforms.common.online.controller.OnlineFormController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '38feac5b0a75448d8557d336ddbbff53', 590, 'POST', '/admin/online/onlineForm/update', '{\"onlineFormDto\":{\"datasourceIdList\":[1809132255981867008],\"formCode\":\"formFlowLeave\",\"formId\":1809132635633487872,\"formKind\":5,\"formName\":\"请假申请\",\"formType\":10,\"masterTableId\":1809132251556876288,\"pageId\":1809132177523216384,\"widgetJson\":\"{\\\"pc\\\":{\\\"gutter\\\":20,\\\"labelWidth\\\":100,\\\"labelPosition\\\":\\\"right\\\",\\\"operationList\\\":[],\\\"customFieldList\\\":[],\\\"widgetList\\\":[{\\\"widgetType\\\":3,\\\"bindData\\\":{\\\"defaultValue\\\":{},\\\"tableId\\\":\\\"1809132251556876288\\\",\\\"columnId\\\":\\\"1809132253377204224\\\",\\\"dataType\\\":0},\\\"showName\\\":\\\"请假类型\\\",\\\"variableName\\\":\\\"leaveType\\\",\\\"props\\\":{\\\"span\\\":24,\\\"placeholder\\\":\\\"\\\",\\\"step\\\":1,\\\"controls\\\":true,\\\"required\\\":true,\\\"disabled\\\":false,\\\"dictInfo\\\":{\\\"paramList\\\":[]},\\\"actions\\\":{}},\\\"eventList\\\":[],\\\"childWidgetList\\\":[],\\\"style\\\":{}},{\\\"widgetType\\\":1,\\\"bindData\\\":{\\\"defaultValue\\\":{},\\\"tableId\\\":\\\"1809132251556876288\\\",\\\"columnId\\\":\\\"1809132252852916224\\\",\\\"dataType\\\":0},\\\"showName\\\":\\\"请假原因\\\",\\\"variableName\\\":\\\"leaveReason\\\",\\\"props\\\":{\\\"span\\\":24,\\\"type\\\":\\\"text\\\",\\\"placeholder\\\":\\\"\\\",\\\"show-password\\\":false,\\\"show-word-limit\\\":false,\\\"required\\\":true,\\\"disabled\\\":false,\\\"dictInfo\\\":{\\\"paramList\\\":[]},\\\"actions\\\":{}},\\\"eventList\\\":[],\\\"childWidgetList\\\":[],\\\"style\\\":{}},{\\\"widgetType\\\":20,\\\"bindData\\\":{\\\"defaultValue\\\":{},\\\"tableId\\\":\\\"1809132251556876288\\\",\\\"columnId\\\":\\\"1809132253733720064\\\",\\\"dataType\\\":0},\\\"showName\\\":\\\"开始时间\\\",\\\"variableName\\\":\\\"leaveBeginTime\\\",\\\"props\\\":{\\\"span\\\":12,\\\"placeholder\\\":\\\"\\\",\\\"type\\\":\\\"date\\\",\\\"required\\\":true,\\\"disabled\\\":false,\\\"dictInfo\\\":{\\\"paramList\\\":[]},\\\"actions\\\":{}},\\\"eventList\\\":[],\\\"childWidgetList\\\":[],\\\"style\\\":{},\\\"supportOperation\\\":false},{\\\"widgetType\\\":20,\\\"bindData\\\":{\\\"defaultValue\\\":{},\\\"tableId\\\":\\\"1809132251556876288\\\",\\\"columnId\\\":\\\"1809132254102818816\\\",\\\"dataType\\\":0},\\\"showName\\\":\\\"结束时间\\\",\\\"variableName\\\":\\\"leaveEndTime\\\",\\\"props\\\":{\\\"span\\\":12,\\\"placeholder\\\":\\\"\\\",\\\"type\\\":\\\"date\\\",\\\"required\\\":true,\\\"disabled\\\":false,\\\"dictInfo\\\":{\\\"paramList\\\":[]},\\\"actions\\\":{}},\\\"eve', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:34:21'); +INSERT INTO `zz_sys_operation_log` VALUES (1809143792943501312, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlinePageController', 'com.orangeforms.common.online.controller.OnlinePageController.updateStatus', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'f373e5187505453b8a73de82f3487b77', 307, 'POST', '/admin/online/onlinePage/updatePublished', '{\"published\":true,\"pageId\":1809132177523216384}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:34:27'); +INSERT INTO `zz_sys_operation_log` VALUES (1809143848773881856, '', 20, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryController', 'com.orangeforms.common.flow.controller.FlowEntryController.delete', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '9a4914d35bed44ad9363c8d9152f09ba', 374, 'POST', '/admin/flow/flowEntry/delete', '{\"entryId\":1809052045395628032}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:34:40'); +INSERT INTO `zz_sys_operation_log` VALUES (1809143990952398848, '', 10, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryController', 'com.orangeforms.common.flow.controller.FlowEntryController.add', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '280442aa890542d8b436c40e8b65c3c8', 564, 'POST', '/admin/flow/flowEntry/add', '{\"flowEntryDto\":{\"bindFormType\":0,\"categoryId\":1809051198460792832,\"defaultFormId\":1809132635633487872,\"diagramType\":0,\"encodedRule\":\"{\\\"middle\\\":\\\"DD\\\",\\\"idWidth\\\":5,\\\"prefix\\\":\\\"LL\\\",\\\"precisionTo\\\":\\\"DAYS\\\",\\\"calculateWhenView\\\":true}\",\"extensionData\":\"{\\\"approvalStatusDict\\\":[{\\\"id\\\":1,\\\"name\\\":\\\"同意\\\"},{\\\"id\\\":2,\\\"name\\\":\\\"拒绝\\\"},{\\\"id\\\":3,\\\"name\\\":\\\"驳回\\\"},{\\\"id\\\":4,\\\"name\\\":\\\"会签同意\\\"},{\\\"id\\\":5,\\\"name\\\":\\\"会签拒绝\\\"}],\\\"notifyTypes\\\":[\\\"email\\\"],\\\"cascadeDeleteBusinessData\\\":true,\\\"supportRevive\\\":false}\",\"pageId\":1809132177523216384,\"processDefinitionKey\":\"flowLeave\",\"processDefinitionName\":\"请假申请\"}}', '{\"data\":1809143991627681792,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:35:14'); +INSERT INTO `zz_sys_operation_log` VALUES (1809144002897776640, '', 15, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryController', 'com.orangeforms.common.flow.controller.FlowEntryController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '059610f822e649e894e551173c416ac0', 249, 'POST', '/admin/flow/flowEntry/update', '{\"flowEntryDto\":{\"bindFormType\":0,\"categoryId\":1809051198460792832,\"defaultFormId\":1809132635633487872,\"diagramType\":0,\"encodedRule\":\"{\\\"middle\\\":\\\"DD\\\",\\\"idWidth\\\":5,\\\"prefix\\\":\\\"LL\\\",\\\"precisionTo\\\":\\\"DAYS\\\",\\\"calculateWhenView\\\":true}\",\"entryId\":1809143991627681792,\"extensionData\":\"{\\\"approvalStatusDict\\\":[{\\\"id\\\":1,\\\"name\\\":\\\"同意\\\",\\\"_X_ROW_KEY\\\":\\\"row_57\\\"},{\\\"id\\\":2,\\\"name\\\":\\\"拒绝\\\",\\\"_X_ROW_KEY\\\":\\\"row_58\\\"},{\\\"id\\\":3,\\\"name\\\":\\\"驳回\\\",\\\"_X_ROW_KEY\\\":\\\"row_59\\\"},{\\\"id\\\":4,\\\"name\\\":\\\"会签同意\\\",\\\"_X_ROW_KEY\\\":\\\"row_60\\\"},{\\\"id\\\":5,\\\"name\\\":\\\"会签拒绝\\\",\\\"_X_ROW_KEY\\\":\\\"row_61\\\"}],\\\"notifyTypes\\\":[\\\"email\\\"],\\\"cascadeDeleteBusinessData\\\":true,\\\"supportRevive\\\":false}\",\"pageId\":1809132177523216384,\"processDefinitionKey\":\"flowLeave\",\"processDefinitionName\":\"请假申请\"}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:35:17'); +INSERT INTO `zz_sys_operation_log` VALUES (1809144278463549440, '', 15, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryController', 'com.orangeforms.common.flow.controller.FlowEntryController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'c0aff90acd7542fc905229d237403dcc', 304, 'POST', '/admin/flow/flowEntry/update', '{\"flowEntryDto\":{\"bindFormType\":0,\"bpmnXml\":\"\\n\\n \\n \\n \\n \\n \\n \\n \\n Flow_0d86buw\\n \\n \\n \\n \\n \\n Flow_1bxwcza\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n\\n \\n \\n \\n \\n \\n \\n \\n Flow_0d86buw\\n \\n \\n \\n \\n \\n Flow_1bxwcza\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n\\n \\n \\n \\n \\n \\n \\n \\n Flow_0d86buw\\n \\n \\n \\n \\n \\n Flow_1bxwcza\\n \\n \\n \\n \\n \\n \\n \\n \\n ', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:36:35'); +INSERT INTO `zz_sys_operation_log` VALUES (1809144345769545728, '', 15, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryController', 'com.orangeforms.common.flow.controller.FlowEntryController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'e16fbd18283347a6bb899a40fac80441', 238, 'POST', '/admin/flow/flowEntry/update', '{\"flowEntryDto\":{\"bindFormType\":0,\"bpmnXml\":\"\\n\\n \\n \\n \\n \\n \\n \\n \\n Flow_0d86buw\\n \\n \\n \\n \\n \\n Flow_1bxwcza\\n \\n \\n \\n \\n \\n \\n \\n \\n ', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:36:39'); +INSERT INTO `zz_sys_operation_log` VALUES (1809144417529892864, '', 65, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryController', 'com.orangeforms.common.flow.controller.FlowEntryController.publish', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'b71e69dbde6b4f868601d8c9a42f0e03', 3149, 'POST', '/admin/flow/flowEntry/publish', '{\"entryId\":1809143991627681792}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:36:56'); +INSERT INTO `zz_sys_operation_log` VALUES (1809146479772700672, '', 100, 'application-webadmin', 'com.orangeforms.common.flow.online.controller.FlowOnlineOperationController', 'com.orangeforms.common.flow.online.controller.FlowOnlineOperationController.startPreview', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '8cd4a46b301a48de878e676ce5aadd47', 3835, 'POST', '/admin/flow/flowOnlineOperation/startPreview', '{\"masterData\":{\"leave_begin_time\":\"2024-07-05 00:00:00\",\"leave_type\":1,\"leave_reason\":\"111\",\"leave_end_time\":\"2024-07-08 00:00:00\"},\"flowTaskCommentDto\":{\"approvalType\":\"agree\"},\"taskVariableData\":{},\"processDefinitionKey\":\"flowLeave\",\"copyData\":{}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:45:08'); +INSERT INTO `zz_sys_operation_log` VALUES (1809146595745206272, '', 120, 'application-webadmin', 'com.orangeforms.common.flow.online.controller.FlowOnlineOperationController', 'com.orangeforms.common.flow.online.controller.FlowOnlineOperationController.submitUserTask', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'eadd3fe01b3244a4826a245ae15c328f', 2462, 'POST', '/admin/flow/flowOnlineOperation/submitUserTask', '{\"processInstanceId\":\"e1fb2ada-3aaa-11ef-86ec-acde48001122\",\"masterData\":{\"leave_begin_time\":\"2024-07-05 00:00:00\",\"leave_type\":1,\"user_id\":\"1808020007993479168\",\"apply_time\":\"2024-07-05 16:45:08\",\"id\":\"1809146480452177920\",\"leave_reason\":\"111\",\"leave_end_time\":\"2024-07-08 00:00:00\"},\"flowTaskCommentDto\":{\"approvalType\":\"agree\",\"taskComment\":\"11\"},\"taskVariableData\":{},\"taskId\":\"e322e20d-3aaa-11ef-86ec-acde48001122\",\"copyData\":{}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:45:35'); +INSERT INTO `zz_sys_operation_log` VALUES (1809146772417679360, '', 120, 'application-webadmin', 'com.orangeforms.common.flow.online.controller.FlowOnlineOperationController', 'com.orangeforms.common.flow.online.controller.FlowOnlineOperationController.submitUserTask', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'bb806b13041349cc8a12fa2d5de5a028', 2310, 'POST', '/admin/flow/flowOnlineOperation/submitUserTask', '{\"processInstanceId\":\"e1fb2ada-3aaa-11ef-86ec-acde48001122\",\"masterData\":{\"leave_begin_time\":\"2024-07-05 00:00:00\",\"leave_type\":1,\"user_id\":\"1808020007993479168\",\"apply_time\":\"2024-07-05 16:45:08\",\"id\":\"1809146480452177920\",\"leave_reason\":\"111\",\"leave_end_time\":\"2024-07-08 00:00:00\"},\"flowTaskCommentDto\":{\"approvalType\":\"agree\",\"taskComment\":\"44\"},\"taskVariableData\":{},\"taskId\":\"0669cc2a-3aab-11ef-86ec-acde48001122\",\"copyData\":{}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:46:18'); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_perm_whitelist +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_perm_whitelist`; +CREATE TABLE `zz_sys_perm_whitelist` ( + `perm_url` varchar(512) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '权限资源的url', + `module_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT '权限资源所属模块名字(通常是Controller的名字)', + `perm_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT '权限的名称', + PRIMARY KEY (`perm_url`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='权限资源白名单表(认证用户均可访问的url资源)'; + +-- ---------------------------- +-- Table structure for zz_sys_post +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_post`; +CREATE TABLE `zz_sys_post` ( + `post_id` bigint NOT NULL COMMENT '岗位Id', + `post_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '岗位名称', + `post_level` int NOT NULL COMMENT '岗位层级,数值越小级别越高', + `leader_post` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否领导岗位', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `update_user_id` bigint NOT NULL COMMENT '更新者Id', + `update_time` datetime NOT NULL COMMENT '最后更新时间', + PRIMARY KEY (`post_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- ---------------------------- +-- Records of zz_sys_post +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_post` VALUES (1809037927934595072, '领导岗位', 1, b'1', 1808020007993479168, '2024-07-05 09:33:47', 1808020007993479168, '2024-07-05 09:33:47'); +INSERT INTO `zz_sys_post` VALUES (1809037967663042560, '普通员工', 10, b'0', 1808020007993479168, '2024-07-05 09:33:56', 1808020007993479168, '2024-07-05 09:33:56'); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_role +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_role`; +CREATE TABLE `zz_sys_role` ( + `role_id` bigint NOT NULL COMMENT '主键Id', + `role_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '角色名称', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `update_user_id` bigint NOT NULL COMMENT '更新者Id', + `update_time` datetime NOT NULL COMMENT '最后更新时间', + PRIMARY KEY (`role_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=COMPACT COMMENT='系统角色表'; + +-- ---------------------------- +-- Records of zz_sys_role +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_role` VALUES (1809037772728569856, '查看全部', 1808020007993479168, '2024-07-05 09:33:10', 1808020007993479168, '2024-07-05 09:33:10'); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_role_menu +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_role_menu`; +CREATE TABLE `zz_sys_role_menu` ( + `role_id` bigint NOT NULL COMMENT '角色Id', + `menu_id` bigint NOT NULL COMMENT '菜单Id', + PRIMARY KEY (`role_id`,`menu_id`) USING BTREE, + KEY `idx_menu_id` (`menu_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=COMPACT COMMENT='角色与菜单对应关系表'; + +-- ---------------------------- +-- Records of zz_sys_role_menu +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1392786476428693504); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1392786549942259712); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1392786950682841088); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1418057714138877952); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1418057835631087616); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1418058289182150656); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1418058744037642240); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1418059005175009280); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1418059167532322816); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1418059283920064512); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1423161217970606080); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1634009076981567488); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020011080486913); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020012825317376); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020012825317377); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020012825317378); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020012825317379); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020012825317380); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020012825317381); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020012825317384); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020012825317385); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020012825317386); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148866); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148867); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148868); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148869); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148870); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148872); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148873); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148874); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148875); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148876); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148877); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148879); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148880); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148881); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148882); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148883); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148884); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148885); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148886); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148887); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148889); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148890); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148891); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148892); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148893); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148894); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148895); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148896); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148897); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148899); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148900); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148901); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148902); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148903); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148905); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148906); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148907); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148908); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075102343171); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075102343172); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075102343173); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075102343174); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075102343175); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075102343177); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075102343179); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075102343180); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_user +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_user`; +CREATE TABLE `zz_sys_user` ( + `user_id` bigint NOT NULL COMMENT '主键Id', + `login_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '用户登录名称', + `password` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '密码', + `show_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '用户显示名称', + `dept_id` bigint NOT NULL COMMENT '用户所在部门Id', + `head_image_url` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '用户头像的Url', + `user_type` int NOT NULL COMMENT '用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)', + `user_status` int NOT NULL COMMENT '状态(0: 正常 1: 锁定)', + `email` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '用户邮箱', + `mobile` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '用户手机', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `update_user_id` bigint NOT NULL COMMENT '更新者Id', + `update_time` datetime NOT NULL COMMENT '最后更新时间', + `deleted_flag` int NOT NULL COMMENT '删除标记(1: 正常 -1: 已删除)', + PRIMARY KEY (`user_id`) USING BTREE, + UNIQUE KEY `uk_login_name` (`login_name`) USING BTREE, + KEY `idx_dept_id` (`dept_id`) USING BTREE, + KEY `idx_status` (`user_status`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=COMPACT COMMENT='系统用户表'; + +-- ---------------------------- +-- Records of zz_sys_user +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_user` VALUES (1808020007993479168, 'admin', '$2a$10$C1/DwnlXP3s.HOFsmL60Resq0juaRt6/WK8JCzcNbgbpueUMs71Um', '管理员', 1808020008341606402, NULL, 0, 0, NULL, NULL, 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00', 1); +INSERT INTO `zz_sys_user` VALUES (1809038124504846336, 'userA', '$2a$10$perpVEYWNTE0.oP0C7L5beiv1EYs3XEn0qkgOKwB8Rm7p/BDGYLEa', '员工A', 1808020008341606402, NULL, 2, 0, NULL, NULL, 1808020007993479168, '2024-07-05 09:34:34', 1809038124504846336, '2024-07-05 10:23:44', 1); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_user_post +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_user_post`; +CREATE TABLE `zz_sys_user_post` ( + `user_id` bigint NOT NULL COMMENT '用户Id', + `dept_post_id` bigint NOT NULL COMMENT '部门岗位Id', + `post_id` bigint NOT NULL COMMENT '岗位Id', + PRIMARY KEY (`user_id`,`dept_post_id`) USING BTREE, + KEY `idx_post_id` (`post_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- ---------------------------- +-- Records of zz_sys_user_post +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_user_post` VALUES (1809038124504846336, 1809038003968937984, 1809037967663042560); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_user_role +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_user_role`; +CREATE TABLE `zz_sys_user_role` ( + `user_id` bigint NOT NULL COMMENT '用户Id', + `role_id` bigint NOT NULL COMMENT '角色Id', + PRIMARY KEY (`user_id`,`role_id`) USING BTREE, + KEY `idx_role_id` (`role_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=COMPACT COMMENT='用户与角色对应关系表'; + +-- ---------------------------- +-- Records of zz_sys_user_role +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_user_role` VALUES (1809038124504846336, 1809037772728569856); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_test_flow_leave +-- ---------------------------- +DROP TABLE IF EXISTS `zz_test_flow_leave`; +CREATE TABLE `zz_test_flow_leave` ( + `id` bigint NOT NULL COMMENT '主键Id', + `user_id` bigint NOT NULL COMMENT '请假用户Id', + `leave_reason` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '请假原因', + `leave_type` int NOT NULL COMMENT '请假类型', + `leave_begin_time` datetime NOT NULL COMMENT '请假开始时间', + `leave_end_time` datetime NOT NULL COMMENT '请假结束时间', + `apply_time` datetime NOT NULL COMMENT '申请时间', + `approval_status` int DEFAULT NULL COMMENT '最后审批状态', + `flow_status` int DEFAULT NULL COMMENT '流程状态', + `username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '用户名', + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_user_id` (`user_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- ---------------------------- +-- Records of zz_test_flow_leave +-- ---------------------------- +BEGIN; +INSERT INTO `zz_test_flow_leave` VALUES (1734132261424467969, 1440911410581213417, '测试', 1, '2023-12-11 00:00:00', '2024-01-02 00:00:00', '2023-12-11 16:45:24', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1734132937084899329, 1440911410581213417, '测试', 1, '2023-12-11 00:00:00', '2024-01-10 00:00:00', '2023-12-11 16:48:05', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1734760286021226497, 1440911410581213417, '22', 2, '2023-12-12 00:00:00', '2023-12-14 00:00:00', '2023-12-13 10:20:57', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1735571074717847553, 1440911410581213417, '123', 1, '2023-12-07 00:00:00', '2023-12-08 00:00:00', '2023-12-15 16:02:44', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1735644235845079041, 1440911410581213417, '111', 1, '2023-12-14 00:00:00', '2023-12-16 00:00:00', '2023-12-15 20:53:27', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1735959007710941185, 1440911410581213417, '123123', 2, '2023-12-16 00:00:00', '2023-12-22 00:00:00', '2023-12-16 17:44:15', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1736002626216005633, 1440911410581213417, '213213', 1, '2023-12-15 00:00:00', '2024-01-18 00:00:00', '2023-12-16 20:37:34', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1736249711238582272, 1440911410581213417, 'qqq', 2, '2023-12-15 00:00:00', '2024-01-17 00:00:00', '2023-12-17 12:59:24', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1736653319645958144, 1440911410581213417, '呃呃呃', 1, '2023-12-18 00:00:00', '2023-12-20 00:00:00', '2023-12-18 15:43:12', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1736916738529824769, 1440911410581213417, '请假', 2, '2023-12-21 00:00:00', '2023-12-23 00:00:00', '2023-12-19 09:09:55', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737101008917499905, 1440911410581213417, 'fff', 3, '2023-12-19 00:00:00', '2023-12-20 00:00:00', '2023-12-19 21:22:09', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737314824108380161, 1440911410581213417, '有事', 1, '2023-12-01 00:00:00', '2023-12-09 00:00:00', '2023-12-20 11:31:46', NULL, 3, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737358381695373313, 1440911410581213417, '123', 2, '2023-12-13 00:00:00', '2024-01-19 00:00:00', '2023-12-20 14:24:51', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737615175483133953, 1440911410581213417, '尴尬', 1, '2023-12-21 00:00:00', '2023-12-22 00:00:00', '2023-12-21 07:25:16', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737641283461058561, 1440911410581213417, '测试', 1, '2023-12-21 00:00:00', '2023-12-28 00:00:00', '2023-12-21 09:09:00', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737646632062685184, 1440911410581213417, '风复古', 1, '2023-12-22 00:00:00', '2023-12-22 00:00:00', '2023-12-21 09:30:16', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737661659834486784, 1440911410581213417, '想咋就咋', 3, '2023-12-22 00:00:00', '2023-12-22 00:00:00', '2023-12-21 10:29:59', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737662716845232128, 1440911410581213417, '黑胡椒', 1, '2023-12-18 00:00:00', '2023-12-22 00:00:00', '2023-12-21 10:34:11', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737666820992667648, 1440911410581213417, '111', 1, '2023-12-22 00:00:00', '2023-12-20 00:00:00', '2023-12-21 10:50:29', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737666823148539905, 1440911410581213417, '111', 1, '2023-12-22 00:00:00', '2023-12-20 00:00:00', '2023-12-21 10:50:30', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737666824016760833, 1440911410581213417, '111', 1, '2023-12-22 00:00:00', '2023-12-20 00:00:00', '2023-12-21 10:50:30', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737666824809484289, 1440911410581213417, '111', 1, '2023-12-22 00:00:00', '2023-12-20 00:00:00', '2023-12-21 10:50:30', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737747164756447233, 1440911410581213417, 'c', 1, '2023-12-23 00:00:00', '2024-01-13 00:00:00', '2023-12-21 16:09:45', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1738557159815254017, 1440911410581213417, '测试新增', 2, '2023-12-22 00:00:00', '2024-01-12 00:00:00', '2023-12-23 21:48:22', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1738586314833399809, 1440911410581213417, '轻机枪', 1, '2023-12-22 00:00:00', '2023-12-29 00:00:00', '2023-12-23 23:44:13', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1738590302731505665, 1440911410581213417, '测试', 2, '2023-12-23 00:00:00', '2024-01-04 00:00:00', '2023-12-24 00:00:04', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1738593079201370113, 1440911410581213417, '测试', 1, '2024-01-04 00:00:00', '2024-01-11 00:00:00', '2023-12-24 00:11:06', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1738597715752783872, 1440911410581213417, '消息 抄送发', 1, '2023-12-13 00:00:00', '2024-01-25 00:00:00', '2023-12-24 00:29:32', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1738598397780168705, 1440911410581213417, ' 额', 1, '2023-12-13 00:00:00', '2023-12-13 00:00:00', '2023-12-24 00:32:14', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1738614127170949120, 1440911410581213417, '超市那个', 1, '2023-12-13 00:00:00', '2023-12-24 00:00:00', '2023-12-24 01:34:44', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1739529776575549440, 1440911410581213417, '33232', 1, '2023-12-07 00:00:00', '2024-01-16 00:00:00', '2023-12-26 14:13:12', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1739534951415549952, 1440911410581213417, '111', 1, '2024-01-25 00:00:00', '2024-01-27 00:00:00', '2023-12-26 14:33:46', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1739860694376910849, 1440911410581213417, '111', 1, '2023-12-27 00:00:00', '2023-12-28 00:00:00', '2023-12-27 12:08:09', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1740031035300646913, 1440911410581213417, '测试抄送', 1, '2024-01-03 00:00:00', '2024-01-11 00:00:00', '2023-12-27 23:25:02', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1741067028283789313, 1440911410581213417, '测试抄送', 1, '2023-12-29 00:00:00', '2024-02-08 00:00:00', '2023-12-30 20:01:42', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1741068565080969217, 1440911410581213417, '亲近抄送', 1, '2024-02-08 00:00:00', '2024-01-19 00:00:00', '2023-12-30 20:07:48', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1741075078512119809, 1440911410581213417, '测试抄送', 1, '2023-12-30 00:00:00', '2024-01-26 00:00:00', '2023-12-30 20:33:41', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1741077243179831297, 1440911410581213417, '测试抄送', 1, '2023-12-30 00:00:00', '2024-01-12 00:00:00', '2023-12-30 20:42:17', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1741082898645127169, 1440911410581213417, '11111', 1, '2023-12-13 00:00:00', '2023-12-29 00:00:00', '2023-12-30 21:04:45', NULL, 3, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1742075427653947392, 1440911410581213417, '6666', 1, '2024-01-02 00:00:00', '2024-01-27 00:00:00', '2024-01-02 14:48:43', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1743138899498110977, 1440911410581213417, '2222', 1, '2024-01-10 00:00:00', '2024-01-10 00:00:00', '2024-01-05 13:14:34', NULL, 3, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1743236528957558784, 1440911410581213417, 'dsfsadffsdf', 1, '2024-01-09 00:00:00', '2024-01-31 00:00:00', '2024-01-05 19:42:31', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1743236847603027968, 1440911410581213417, 'sdfaff', 1, '2024-01-11 00:00:00', '2024-02-06 00:00:00', '2024-01-05 19:43:47', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1743236894344351745, 1440911410581213417, 'dsfsdfasdf', 1, '2024-01-11 00:00:00', '2024-02-14 00:00:00', '2024-01-05 19:43:58', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1743236965743988737, 1440911410581213417, 'zxczxc', 1, '2024-01-20 00:00:00', '2024-02-12 00:00:00', '2024-01-05 19:44:15', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1743529562567872512, 1440911410581213417, '休息', 1, '2024-01-12 00:00:00', '2024-01-13 00:00:00', '2024-01-06 15:06:56', NULL, 3, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1743570048200478721, 1440911410581213417, '是一款..是,', 1, '2024-01-07 00:00:00', '2024-01-31 00:00:00', '2024-01-06 17:47:48', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1743847321545740288, 1440911410581213417, '测试请假', 3, '2024-01-08 00:00:00', '2024-01-24 00:00:00', '2024-01-07 12:09:35', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1743848671104995328, 1440911410581213417, '请假新增测试', 1, '2024-01-15 00:00:00', '2024-01-16 00:00:00', '2024-01-07 12:14:57', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1743894439526404097, 1440911410581213417, '测试', 2, '2024-01-07 00:00:00', '2024-01-24 00:00:00', '2024-01-07 15:16:49', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1745342183466078208, 1440911410581213417, 'asdfasdf', 1, '2024-01-02 00:00:00', '2024-02-02 00:00:00', '2024-01-11 15:09:38', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1745343819995418625, 1440911410581213417, 'adfasd', 1, '2024-01-06 00:00:00', '2024-02-06 00:00:00', '2024-01-11 15:16:08', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1745639100335001600, 1440911410581213417, '1234', 1, '2024-01-12 00:00:00', '2024-01-19 00:00:00', '2024-01-12 10:49:29', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1745641568804540417, 1440911410581213417, '123', 1, '2024-01-12 00:00:00', '2024-01-19 00:00:00', '2024-01-12 10:59:17', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1746710995184652289, 1440911410581213417, '11111111111111', 3, '2024-01-16 00:00:00', '2024-01-25 00:00:00', '2024-01-15 09:48:48', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1746821158071701504, 1440911410581213417, 'sfasdf', 1, '2024-02-14 00:00:00', '2024-02-16 00:00:00', '2024-01-15 17:06:33', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1747175673463574529, 1440911410581213417, '1111', 1, '2024-01-16 00:00:00', '2024-01-17 00:00:00', '2024-01-16 16:35:16', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1784199563469393920, 1779777400603676672, '111', 1, '2024-04-01 00:00:00', '2024-04-04 00:00:00', '2024-04-27 20:34:59', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1784202480981118976, 1779777400603676672, '请假', 1, '2024-04-22 00:00:00', '2024-04-24 00:00:00', '2024-04-27 20:46:35', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1784211196795162625, 1779777400603676672, '请假三天', 1, '2024-04-02 00:00:00', '2024-04-05 00:00:00', '2024-04-27 21:21:13', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1784221100561928192, 1779777400603676672, '请假出去玩', 1, '2024-04-08 00:00:00', '2024-04-15 00:00:00', '2024-04-27 22:00:34', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1784556947194777601, 1779777400603676672, '111', 1, '2024-04-03 00:00:00', '2024-04-11 00:00:00', '2024-04-28 20:15:06', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1785508179405180928, 1779777400603676672, '11', 1, '2024-05-08 00:00:00', '2024-05-10 00:00:00', '2024-05-01 11:14:58', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1787771104035606528, 1779777400603676672, '111', 1, '2024-05-07 00:00:00', '2024-05-08 00:00:00', '2024-05-07 17:07:01', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1787771998559014913, 1779777400603676672, '2222', 1, '2024-05-07 00:00:00', '2024-05-15 00:00:00', '2024-05-07 17:10:34', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1787817506019217408, 1779777400603676672, '111', 1, '2024-05-08 00:00:00', '2024-05-16 00:00:00', '2024-05-07 20:11:24', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1787852380893614081, 1779777400603676672, '1111', 1, '2024-05-14 00:00:00', '2024-05-08 00:00:00', '2024-05-07 22:29:59', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1787853112791273472, 1779777400603676672, '1111', 1, '2024-05-08 00:00:00', '2024-05-16 00:00:00', '2024-05-07 22:32:53', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1788107566534889472, 1779777400603676672, '111', 1, '2024-05-08 00:00:00', '2024-05-09 00:00:00', '2024-05-08 15:24:00', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1788112135096635392, 1779777400603676672, '111', 1, '2024-05-08 00:00:00', '2024-05-09 00:00:00', '2024-05-08 15:42:09', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1788112525678612480, 1779777400603676672, '1111', 2, '2024-05-09 00:00:00', '2024-05-10 00:00:00', '2024-05-08 15:43:42', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1788741582820741120, 1779777400603676672, '秀', 2, '2024-05-07 00:00:00', '2024-05-08 00:00:00', '2024-05-10 09:23:21', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1791767263255203841, 1779777400603676672, '1111', 1, '2024-05-20 00:00:00', '2024-05-21 00:00:00', '2024-05-18 17:46:20', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1792492440158998528, 1779777400603676672, '111222', 2, '2024-05-07 00:00:00', '2024-05-22 00:00:00', '2024-05-20 17:47:55', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1792829634757267456, 1779777400603676672, '1111', 2, '2024-05-14 00:00:00', '2024-05-15 00:00:00', '2024-05-21 16:07:49', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1793489840575090688, 1779777400603676672, '1111', 1, '2024-05-16 00:00:00', '2024-05-24 00:00:00', '2024-05-23 11:51:14', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1795696352311644160, 1779777400603676672, 'dd', 1, '2024-05-02 00:00:00', '2024-05-10 00:00:00', '2024-05-29 13:59:07', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1795992839696420865, 1779777400603676672, 'admin', 1, '2024-05-02 00:00:00', '2024-05-18 00:00:00', '2024-05-30 09:37:16', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1795994391077195776, 1779777400603676672, '1111222', 1, '2024-05-15 00:00:00', '2024-05-16 00:00:00', '2024-05-30 09:43:25', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796109769098924033, 1779777400603676672, '1111', 1, '2024-05-08 00:00:00', '2024-05-10 00:00:00', '2024-05-30 17:21:54', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796110123517612032, 1779777400603676672, '1111222', 1, '2024-05-16 00:00:00', '2024-05-18 00:00:00', '2024-05-30 17:23:18', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796164077765005312, 1779777400603676672, 'admin', 1, '2024-05-10 00:00:00', '2024-06-05 00:00:00', '2024-05-30 20:57:42', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796164941607079936, 1779777400603676672, 'admin', 1, '2024-05-17 00:00:00', '2024-06-12 00:00:00', '2024-05-30 21:01:08', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796173926594777088, 1779777400603676672, 'dd', 1, '2024-05-10 00:00:00', '2024-05-09 00:00:00', '2024-05-30 21:36:50', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796178444468359168, 1779777400603676672, 'x', 1, '2024-05-14 00:00:00', '2024-05-15 00:00:00', '2024-05-30 21:54:47', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796181839363182593, 1779777400603676672, '111', 1, '2024-05-16 00:00:00', '2024-06-18 00:00:00', '2024-05-30 22:08:17', NULL, 4, 'admin'); +INSERT INTO `zz_test_flow_leave` VALUES (1796182559164469249, 1779777400603676672, '4444', 1, '2024-05-08 00:00:00', '2024-05-10 00:00:00', '2024-05-30 22:11:08', NULL, 4, 'admin'); +INSERT INTO `zz_test_flow_leave` VALUES (1796183035536740352, 1779777400603676672, 'dd', 1, '2024-05-18 00:00:00', '2024-05-11 00:00:00', '2024-05-30 22:13:02', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796183248754184192, 1779777400603676672, '11', 1, '2024-05-07 00:00:00', '2024-05-08 00:00:00', '2024-05-30 22:13:53', NULL, 5, 'userTJ2'); +INSERT INTO `zz_test_flow_leave` VALUES (1796185777676226560, 1779777400603676672, 'd', 1, '2024-05-09 00:00:00', '2024-05-09 00:00:00', '2024-05-30 22:23:56', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796187020805017600, 1779777400603676672, 'd', 1, '2024-05-03 00:00:00', '2024-05-03 00:00:00', '2024-05-30 22:28:52', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796188059113361408, 1779777400603676672, 'd', 1, '2024-05-17 00:00:00', '2024-05-17 00:00:00', '2024-05-30 22:33:00', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796188876033757184, 1779777400603676672, 'dd', 1, '2024-05-02 00:00:00', '2024-05-02 00:00:00', '2024-05-30 22:36:14', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796189604152348672, 1779777400603676672, 'dd', 1, '2024-05-03 00:00:00', '2024-05-03 00:00:00', '2024-05-30 22:39:08', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796190467956674560, 1779777400603676672, 'dd', 1, '2024-05-10 00:00:00', '2024-05-16 00:00:00', '2024-05-30 22:42:34', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796191454335340544, 1779777400603676672, 'jk', 1, '2024-05-10 00:00:00', '2024-05-02 00:00:00', '2024-05-30 22:46:29', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796192461547114496, 1779777400603676672, 'd', 1, '2024-05-02 00:00:00', '2024-05-09 00:00:00', '2024-05-30 22:50:29', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796195394187694080, 1779777400603676672, 'dd', 1, '2024-05-03 00:00:00', '2024-05-10 00:00:00', '2024-05-30 23:02:08', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796197180806008832, 1779777400603676672, 'ddd', 1, '2024-05-10 00:00:00', '2024-05-10 00:00:00', '2024-05-30 23:09:14', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796201309611757568, 1779777400603676672, 'dd', 1, '2024-05-17 00:00:00', '2024-05-17 00:00:00', '2024-05-30 23:25:39', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796202010052136960, 1779777400603676672, 'dd', 1, '2024-05-03 00:00:00', '2024-05-03 00:00:00', '2024-05-30 23:28:26', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796204072726958080, 1779777400603676672, 'd', 1, '2024-05-10 00:00:00', '2024-05-10 00:00:00', '2024-05-30 23:36:37', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796354567839944704, 1779777400603676672, 'admin', 1, '2024-05-17 00:00:00', '2024-06-13 00:00:00', '2024-05-31 09:34:38', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796361013583417344, 1779777400603676672, 'admin', 1, '2024-05-11 00:00:00', '2024-06-10 00:00:00', '2024-05-31 10:00:15', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796442194475749377, 1779777400603676672, 'd', 1, '2024-05-10 00:00:00', '2024-06-06 00:00:00', '2024-05-31 15:22:50', NULL, 4, 'admin'); +INSERT INTO `zz_test_flow_leave` VALUES (1796453212681670656, 1779777400603676672, 'admin', 1, '2024-05-18 00:00:00', '2024-06-10 00:00:00', '2024-05-31 16:06:37', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1797540170921152512, 1779777400603676672, '111', 1, '2024-06-04 00:00:00', '2024-06-06 00:00:00', '2024-06-03 16:05:48', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1799012020255723520, 1779777400603676672, '1111', 1, '2024-06-12 00:00:00', '2024-06-14 00:00:00', '2024-06-07 17:34:24', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1800522684333821952, 1779777400603676672, '111', 1, '2024-06-12 00:00:00', '2024-06-12 00:00:00', '2024-06-11 21:37:15', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1800529322327412736, 1799417106157015040, '1111', 1, '2024-06-13 00:00:00', '2024-06-19 00:00:00', '2024-06-11 22:03:37', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1807764854329577473, 1779777400603676672, '111', 1, '2024-07-02 00:00:00', '2024-07-11 00:00:00', '2024-07-01 21:15:03', 11, 1, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1809146480452177920, 1808020007993479168, '111', 1, '2024-07-05 00:00:00', '2024-07-08 00:00:00', '2024-07-05 16:45:08', NULL, NULL, NULL); +COMMIT; + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/OrangeFormsOpen-MybatisFlex/zz-resource/docker-files/.DS_Store b/OrangeFormsOpen-MybatisFlex/zz-resource/docker-files/.DS_Store new file mode 100644 index 00000000..95224700 Binary files /dev/null and b/OrangeFormsOpen-MybatisFlex/zz-resource/docker-files/.DS_Store differ diff --git a/OrangeFormsOpen-MybatisFlex/zz-resource/docker-files/docker-compose.yml b/OrangeFormsOpen-MybatisFlex/zz-resource/docker-files/docker-compose.yml new file mode 100644 index 00000000..1dd97846 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/zz-resource/docker-files/docker-compose.yml @@ -0,0 +1,33 @@ +version: '3.2' + +services: + + redis: + container_name: redis + build: + context: services/redis/ + args: + - REDIS_VER=4 + ports: + - "6379:6379" + volumes: + - ./services/redis/redis.conf:/usr/local/etc/redis/redis.conf:rw + - ./data/redis:/data:rw + - ./logs/redis:/var/log/:rw + +# minio1: +# image: minio/minio:latest +# environment: +# # spring boot服务中的配置项需要与该值相同。 +# # nginx访问页面的登录名和密码。密码不能少于8个字符。 +# - MINIO_ACCESS_KEY=admin +# - MINIO_SECRET_KEY=admin123456 +# volumes: +# - ./data/minio:/data +# - ./services/minio/config:/root/.minio +# ports: +# # 这个是给Java的minio客户端使用的端口。 +# - "19000:9000" +# # 对主机控制台暴露19001接口,nginx需要将请求导入该端口号。 +# - "19001:9001" +# command: server /data --console-address ":9001" diff --git a/OrangeFormsOpen-MybatisFlex/zz-resource/docker-files/services/redis/Dockerfile b/OrangeFormsOpen-MybatisFlex/zz-resource/docker-files/services/redis/Dockerfile new file mode 100644 index 00000000..924bd9d6 --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/zz-resource/docker-files/services/redis/Dockerfile @@ -0,0 +1,13 @@ +ARG REDIS_VER + +FROM redis:${REDIS_VER} + +COPY redis.conf /usr/local/etc/redis/redis.conf +CMD ["redis-server", "/usr/local/etc/redis/redis.conf"] + +# 设置时区为上海 +ENV TZ=Asia/Shanghai +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +# Ubuntu软件源选择中国的服务器 +RUN sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisFlex/zz-resource/docker-files/services/redis/redis.conf b/OrangeFormsOpen-MybatisFlex/zz-resource/docker-files/services/redis/redis.conf new file mode 100644 index 00000000..2eecfa5a --- /dev/null +++ b/OrangeFormsOpen-MybatisFlex/zz-resource/docker-files/services/redis/redis.conf @@ -0,0 +1,1307 @@ +# Redis configuration file example. +# +# Note that in order to read the configuration file, Redis must be +# started with the file path as first argument: +# +# ./redis-server /path/to/redis.conf + +# Note on units: when memory size is needed, it is possible to specify +# it in the usual form of 1k 5GB 4M and so forth: +# +# 1k => 1000 bytes +# 1kb => 1024 bytes +# 1m => 1000000 bytes +# 1mb => 1024*1024 bytes +# 1g => 1000000000 bytes +# 1gb => 1024*1024*1024 bytes +# +# units are case insensitive so 1GB 1Gb 1gB are all the same. + +################################## INCLUDES ################################### + +# Include one or more other config files here. This is useful if you +# have a standard template that goes to all Redis servers but also need +# to customize a few per-server settings. Include files can include +# other files, so use this wisely. +# +# Notice option "include" won't be rewritten by command "CONFIG REWRITE" +# from admin or Redis Sentinel. Since Redis always uses the last processed +# line as value of a configuration directive, you'd better put includes +# at the beginning of this file to avoid overwriting config change at runtime. +# +# If instead you are interested in using includes to override configuration +# options, it is better to use include as the last line. +# +# include /path/to/local.conf +# include /path/to/other.conf + +################################## MODULES ##################################### + +# Load modules at startup. If the server is not able to load modules +# it will abort. It is possible to use multiple loadmodule directives. +# +# loadmodule /path/to/my_module.so +# loadmodule /path/to/other_module.so + +################################## NETWORK ##################################### + +# By default, if no "bind" configuration directive is specified, Redis listens +# for connections from all the network interfaces available on the server. +# It is possible to listen to just one or multiple selected interfaces using +# the "bind" configuration directive, followed by one or more IP addresses. +# +# Examples: +# +# bind 192.168.1.100 10.0.0.1 +# bind 127.0.0.1 ::1 +# +# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the +# internet, binding to all the interfaces is dangerous and will expose the +# instance to everybody on the internet. So by default we uncomment the +# following bind directive, that will force Redis to listen only into +# the IPv4 lookback interface address (this means Redis will be able to +# accept connections only from clients running into the same computer it +# is running). +# +# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES +# JUST COMMENT THE FOLLOWING LINE. +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +bind 0.0.0.0 + +# Protected mode is a layer of security protection, in order to avoid that +# Redis instances left open on the internet are accessed and exploited. +# +# When protected mode is on and if: +# +# 1) The server is not binding explicitly to a set of addresses using the +# "bind" directive. +# 2) No password is configured. +# +# The server only accepts connections from clients connecting from the +# IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain +# sockets. +# +# By default protected mode is enabled. You should disable it only if +# you are sure you want clients from other hosts to connect to Redis +# even if no authentication is configured, nor a specific set of interfaces +# are explicitly listed using the "bind" directive. +protected-mode yes + +# Accept connections on the specified port, default is 6379 (IANA #815344). +# If port 0 is specified Redis will not listen on a TCP socket. +port 6379 + +# TCP listen() backlog. +# +# In high requests-per-second environments you need an high backlog in order +# to avoid slow clients connections issues. Note that the Linux kernel +# will silently truncate it to the value of /proc/sys/net/core/somaxconn so +# make sure to raise both the value of somaxconn and tcp_max_syn_backlog +# in order to get the desired effect. +tcp-backlog 511 + +# Unix socket. +# +# Specify the path for the Unix socket that will be used to listen for +# incoming connections. There is no default, so Redis will not listen +# on a unix socket when not specified. +# +# unixsocket /tmp/redis.sock +# unixsocketperm 700 + +# Close the connection after a client is idle for N seconds (0 to disable) +timeout 0 + +# TCP keepalive. +# +# If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence +# of communication. This is useful for two reasons: +# +# 1) Detect dead peers. +# 2) Take the connection alive from the point of view of network +# equipment in the middle. +# +# On Linux, the specified value (in seconds) is the period used to send ACKs. +# Note that to close the connection the double of the time is needed. +# On other kernels the period depends on the kernel configuration. +# +# A reasonable value for this option is 300 seconds, which is the new +# Redis default starting with Redis 3.2.1. +tcp-keepalive 300 + +################################# GENERAL ##################################### + +# By default Redis does not run as a daemon. Use 'yes' if you need it. +# Note that Redis will write a pid file in /var/run/redis.pid when daemonized. +daemonize no + +# If you run Redis from upstart or systemd, Redis can interact with your +# supervision tree. Options: +# supervised no - no supervision interaction +# supervised upstart - signal upstart by putting Redis into SIGSTOP mode +# supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET +# supervised auto - detect upstart or systemd method based on +# UPSTART_JOB or NOTIFY_SOCKET environment variables +# Note: these supervision methods only signal "process is ready." +# They do not enable continuous liveness pings back to your supervisor. +supervised no + +# If a pid file is specified, Redis writes it where specified at startup +# and removes it at exit. +# +# When the server runs non daemonized, no pid file is created if none is +# specified in the configuration. When the server is daemonized, the pid file +# is used even if not specified, defaulting to "/var/run/redis.pid". +# +# Creating a pid file is best effort: if Redis is not able to create it +# nothing bad happens, the server will start and run normally. +pidfile /var/run/redis_6379.pid + +# Specify the server verbosity level. +# This can be one of: +# debug (a lot of information, useful for development/testing) +# verbose (many rarely useful info, but not a mess like the debug level) +# notice (moderately verbose, what you want in production probably) +# warning (only very important / critical messages are logged) +loglevel notice + +# Specify the log file name. Also the empty string can be used to force +# Redis to log on the standard output. Note that if you use standard +# output for logging but daemonize, logs will be sent to /dev/null +logfile /var/log/redis_6379.log + +# To enable logging to the system logger, just set 'syslog-enabled' to yes, +# and optionally update the other syslog parameters to suit your needs. +# syslog-enabled no + +# Specify the syslog identity. +# syslog-ident redis + +# Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7. +# syslog-facility local0 + +# Set the number of databases. The default database is DB 0, you can select +# a different one on a per-connection basis using SELECT where +# dbid is a number between 0 and 'databases'-1 +databases 16 + +# By default Redis shows an ASCII art logo only when started to log to the +# standard output and if the standard output is a TTY. Basically this means +# that normally a logo is displayed only in interactive sessions. +# +# However it is possible to force the pre-4.0 behavior and always show a +# ASCII art logo in startup logs by setting the following option to yes. +always-show-logo yes + +################################ SNAPSHOTTING ################################ +# +# Save the DB on disk: +# +# save +# +# Will save the DB if both the given number of seconds and the given +# number of write operations against the DB occurred. +# +# In the example below the behaviour will be to save: +# after 900 sec (15 min) if at least 1 key changed +# after 300 sec (5 min) if at least 10 keys changed +# after 60 sec if at least 10000 keys changed +# +# Note: you can disable saving completely by commenting out all "save" lines. +# +# It is also possible to remove all the previously configured save +# points by adding a save directive with a single empty string argument +# like in the following example: +# +# save "" + +save 900 1 +save 300 10 +save 60 10000 + +# By default Redis will stop accepting writes if RDB snapshots are enabled +# (at least one save point) and the latest background save failed. +# This will make the user aware (in a hard way) that data is not persisting +# on disk properly, otherwise chances are that no one will notice and some +# disaster will happen. +# +# If the background saving process will start working again Redis will +# automatically allow writes again. +# +# However if you have setup your proper monitoring of the Redis server +# and persistence, you may want to disable this feature so that Redis will +# continue to work as usual even if there are problems with disk, +# permissions, and so forth. +stop-writes-on-bgsave-error yes + +# Compress string objects using LZF when dump .rdb databases? +# For default that's set to 'yes' as it's almost always a win. +# If you want to save some CPU in the saving child set it to 'no' but +# the dataset will likely be bigger if you have compressible values or keys. +rdbcompression yes + +# Since version 5 of RDB a CRC64 checksum is placed at the end of the file. +# This makes the format more resistant to corruption but there is a performance +# hit to pay (around 10%) when saving and loading RDB files, so you can disable it +# for maximum performances. +# +# RDB files created with checksum disabled have a checksum of zero that will +# tell the loading code to skip the check. +rdbchecksum yes + +# The filename where to dump the DB +dbfilename dump.rdb + +# The working directory. +# +# The DB will be written inside this directory, with the filename specified +# above using the 'dbfilename' configuration directive. +# +# The Append Only File will also be created inside this directory. +# +# Note that you must specify a directory here, not a file name. +dir ./ + +################################# REPLICATION ################################# + +# Master-Slave replication. Use slaveof to make a Redis instance a copy of +# another Redis server. A few things to understand ASAP about Redis replication. +# +# 1) Redis replication is asynchronous, but you can configure a master to +# stop accepting writes if it appears to be not connected with at least +# a given number of slaves. +# 2) Redis slaves are able to perform a partial resynchronization with the +# master if the replication link is lost for a relatively small amount of +# time. You may want to configure the replication backlog size (see the next +# sections of this file) with a sensible value depending on your needs. +# 3) Replication is automatic and does not need user intervention. After a +# network partition slaves automatically try to reconnect to masters +# and resynchronize with them. +# +# slaveof + +# If the master is password protected (using the "requirepass" configuration +# directive below) it is possible to tell the slave to authenticate before +# starting the replication synchronization process, otherwise the master will +# refuse the slave request. +# +# masterauth + +# When a slave loses its connection with the master, or when the replication +# is still in progress, the slave can act in two different ways: +# +# 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will +# still reply to client requests, possibly with out of date data, or the +# data set may just be empty if this is the first synchronization. +# +# 2) if slave-serve-stale-data is set to 'no' the slave will reply with +# an error "SYNC with master in progress" to all the kind of commands +# but to INFO and SLAVEOF. +# +slave-serve-stale-data yes + +# You can configure a slave instance to accept writes or not. Writing against +# a slave instance may be useful to store some ephemeral data (because data +# written on a slave will be easily deleted after resync with the master) but +# may also cause problems if clients are writing to it because of a +# misconfiguration. +# +# Since Redis 2.6 by default slaves are read-only. +# +# Note: read only slaves are not designed to be exposed to untrusted clients +# on the internet. It's just a protection layer against misuse of the instance. +# Still a read only slave exports by default all the administrative commands +# such as CONFIG, DEBUG, and so forth. To a limited extent you can improve +# security of read only slaves using 'rename-command' to shadow all the +# administrative / dangerous commands. +slave-read-only yes + +# Replication SYNC strategy: disk or socket. +# +# ------------------------------------------------------- +# WARNING: DISKLESS REPLICATION IS EXPERIMENTAL CURRENTLY +# ------------------------------------------------------- +# +# New slaves and reconnecting slaves that are not able to continue the replication +# process just receiving differences, need to do what is called a "full +# synchronization". An RDB file is transmitted from the master to the slaves. +# The transmission can happen in two different ways: +# +# 1) Disk-backed: The Redis master creates a new process that writes the RDB +# file on disk. Later the file is transferred by the parent +# process to the slaves incrementally. +# 2) Diskless: The Redis master creates a new process that directly writes the +# RDB file to slave sockets, without touching the disk at all. +# +# With disk-backed replication, while the RDB file is generated, more slaves +# can be queued and served with the RDB file as soon as the current child producing +# the RDB file finishes its work. With diskless replication instead once +# the transfer starts, new slaves arriving will be queued and a new transfer +# will start when the current one terminates. +# +# When diskless replication is used, the master waits a configurable amount of +# time (in seconds) before starting the transfer in the hope that multiple slaves +# will arrive and the transfer can be parallelized. +# +# With slow disks and fast (large bandwidth) networks, diskless replication +# works better. +repl-diskless-sync no + +# When diskless replication is enabled, it is possible to configure the delay +# the server waits in order to spawn the child that transfers the RDB via socket +# to the slaves. +# +# This is important since once the transfer starts, it is not possible to serve +# new slaves arriving, that will be queued for the next RDB transfer, so the server +# waits a delay in order to let more slaves arrive. +# +# The delay is specified in seconds, and by default is 5 seconds. To disable +# it entirely just set it to 0 seconds and the transfer will start ASAP. +repl-diskless-sync-delay 5 + +# Slaves send PINGs to server in a predefined interval. It's possible to change +# this interval with the repl_ping_slave_period option. The default value is 10 +# seconds. +# +# repl-ping-slave-period 10 + +# The following option sets the replication timeout for: +# +# 1) Bulk transfer I/O during SYNC, from the point of view of slave. +# 2) Master timeout from the point of view of slaves (data, pings). +# 3) Slave timeout from the point of view of masters (REPLCONF ACK pings). +# +# It is important to make sure that this value is greater than the value +# specified for repl-ping-slave-period otherwise a timeout will be detected +# every time there is low traffic between the master and the slave. +# +# repl-timeout 60 + +# Disable TCP_NODELAY on the slave socket after SYNC? +# +# If you select "yes" Redis will use a smaller number of TCP packets and +# less bandwidth to send data to slaves. But this can add a delay for +# the data to appear on the slave side, up to 40 milliseconds with +# Linux kernels using a default configuration. +# +# If you select "no" the delay for data to appear on the slave side will +# be reduced but more bandwidth will be used for replication. +# +# By default we optimize for low latency, but in very high traffic conditions +# or when the master and slaves are many hops away, turning this to "yes" may +# be a good idea. +repl-disable-tcp-nodelay no + +# Set the replication backlog size. The backlog is a buffer that accumulates +# slave data when slaves are disconnected for some time, so that when a slave +# wants to reconnect again, often a full resync is not needed, but a partial +# resync is enough, just passing the portion of data the slave missed while +# disconnected. +# +# The bigger the replication backlog, the longer the time the slave can be +# disconnected and later be able to perform a partial resynchronization. +# +# The backlog is only allocated once there is at least a slave connected. +# +# repl-backlog-size 1mb + +# After a master has no longer connected slaves for some time, the backlog +# will be freed. The following option configures the amount of seconds that +# need to elapse, starting from the time the last slave disconnected, for +# the backlog buffer to be freed. +# +# Note that slaves never free the backlog for timeout, since they may be +# promoted to masters later, and should be able to correctly "partially +# resynchronize" with the slaves: hence they should always accumulate backlog. +# +# A value of 0 means to never release the backlog. +# +# repl-backlog-ttl 3600 + +# The slave priority is an integer number published by Redis in the INFO output. +# It is used by Redis Sentinel in order to select a slave to promote into a +# master if the master is no longer working correctly. +# +# A slave with a low priority number is considered better for promotion, so +# for instance if there are three slaves with priority 10, 100, 25 Sentinel will +# pick the one with priority 10, that is the lowest. +# +# However a special priority of 0 marks the slave as not able to perform the +# role of master, so a slave with priority of 0 will never be selected by +# Redis Sentinel for promotion. +# +# By default the priority is 100. +slave-priority 100 + +# It is possible for a master to stop accepting writes if there are less than +# N slaves connected, having a lag less or equal than M seconds. +# +# The N slaves need to be in "online" state. +# +# The lag in seconds, that must be <= the specified value, is calculated from +# the last ping received from the slave, that is usually sent every second. +# +# This option does not GUARANTEE that N replicas will accept the write, but +# will limit the window of exposure for lost writes in case not enough slaves +# are available, to the specified number of seconds. +# +# For example to require at least 3 slaves with a lag <= 10 seconds use: +# +# min-slaves-to-write 3 +# min-slaves-max-lag 10 +# +# Setting one or the other to 0 disables the feature. +# +# By default min-slaves-to-write is set to 0 (feature disabled) and +# min-slaves-max-lag is set to 10. + +# A Redis master is able to list the address and port of the attached +# slaves in different ways. For example the "INFO replication" section +# offers this information, which is used, among other tools, by +# Redis Sentinel in order to discover slave instances. +# Another place where this info is available is in the output of the +# "ROLE" command of a master. +# +# The listed IP and address normally reported by a slave is obtained +# in the following way: +# +# IP: The address is auto detected by checking the peer address +# of the socket used by the slave to connect with the master. +# +# Port: The port is communicated by the slave during the replication +# handshake, and is normally the port that the slave is using to +# list for connections. +# +# However when port forwarding or Network Address Translation (NAT) is +# used, the slave may be actually reachable via different IP and port +# pairs. The following two options can be used by a slave in order to +# report to its master a specific set of IP and port, so that both INFO +# and ROLE will report those values. +# +# There is no need to use both the options if you need to override just +# the port or the IP address. +# +# slave-announce-ip 5.5.5.5 +# slave-announce-port 1234 + +################################## SECURITY ################################### + +# Require clients to issue AUTH before processing any other +# commands. This might be useful in environments in which you do not trust +# others with access to the host running redis-server. +# +# This should stay commented out for backward compatibility and because most +# people do not need auth (e.g. they run their own servers). +# +# Warning: since Redis is pretty fast an outside user can try up to +# 150k passwords per second against a good box. This means that you should +# use a very strong password otherwise it will be very easy to break. +# +# requirepass foobared + +# Command renaming. +# +# It is possible to change the name of dangerous commands in a shared +# environment. For instance the CONFIG command may be renamed into something +# hard to guess so that it will still be available for internal-use tools +# but not available for general clients. +# +# Example: +# +# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52 +# +# It is also possible to completely kill a command by renaming it into +# an empty string: +# +# rename-command CONFIG "" +# +# Please note that changing the name of commands that are logged into the +# AOF file or transmitted to slaves may cause problems. + +################################### CLIENTS #################################### + +# Set the max number of connected clients at the same time. By default +# this limit is set to 10000 clients, however if the Redis server is not +# able to configure the process file limit to allow for the specified limit +# the max number of allowed clients is set to the current file limit +# minus 32 (as Redis reserves a few file descriptors for internal uses). +# +# Once the limit is reached Redis will close all the new connections sending +# an error 'max number of clients reached'. +# +# maxclients 10000 + +############################## MEMORY MANAGEMENT ################################ + +# Set a memory usage limit to the specified amount of bytes. +# When the memory limit is reached Redis will try to remove keys +# according to the eviction policy selected (see maxmemory-policy). +# +# If Redis can't remove keys according to the policy, or if the policy is +# set to 'noeviction', Redis will start to reply with errors to commands +# that would use more memory, like SET, LPUSH, and so on, and will continue +# to reply to read-only commands like GET. +# +# This option is usually useful when using Redis as an LRU or LFU cache, or to +# set a hard memory limit for an instance (using the 'noeviction' policy). +# +# WARNING: If you have slaves attached to an instance with maxmemory on, +# the size of the output buffers needed to feed the slaves are subtracted +# from the used memory count, so that network problems / resyncs will +# not trigger a loop where keys are evicted, and in turn the output +# buffer of slaves is full with DELs of keys evicted triggering the deletion +# of more keys, and so forth until the database is completely emptied. +# +# In short... if you have slaves attached it is suggested that you set a lower +# limit for maxmemory so that there is some free RAM on the system for slave +# output buffers (but this is not needed if the policy is 'noeviction'). +# +# maxmemory + +# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory +# is reached. You can select among five behaviors: +# +# volatile-lru -> Evict using approximated LRU among the keys with an expire set. +# allkeys-lru -> Evict any key using approximated LRU. +# volatile-lfu -> Evict using approximated LFU among the keys with an expire set. +# allkeys-lfu -> Evict any key using approximated LFU. +# volatile-random -> Remove a random key among the ones with an expire set. +# allkeys-random -> Remove a random key, any key. +# volatile-ttl -> Remove the key with the nearest expire time (minor TTL) +# noeviction -> Don't evict anything, just return an error on write operations. +# +# LRU means Least Recently Used +# LFU means Least Frequently Used +# +# Both LRU, LFU and volatile-ttl are implemented using approximated +# randomized algorithms. +# +# Note: with any of the above policies, Redis will return an error on write +# operations, when there are no suitable keys for eviction. +# +# At the date of writing these commands are: set setnx setex append +# incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd +# sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby +# zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby +# getset mset msetnx exec sort +# +# The default is: +# +# maxmemory-policy noeviction + +# LRU, LFU and minimal TTL algorithms are not precise algorithms but approximated +# algorithms (in order to save memory), so you can tune it for speed or +# accuracy. For default Redis will check five keys and pick the one that was +# used less recently, you can change the sample size using the following +# configuration directive. +# +# The default of 5 produces good enough results. 10 Approximates very closely +# true LRU but costs more CPU. 3 is faster but not very accurate. +# +# maxmemory-samples 5 + +############################# LAZY FREEING #################################### + +# Redis has two primitives to delete keys. One is called DEL and is a blocking +# deletion of the object. It means that the server stops processing new commands +# in order to reclaim all the memory associated with an object in a synchronous +# way. If the key deleted is associated with a small object, the time needed +# in order to execute the DEL command is very small and comparable to most other +# O(1) or O(log_N) commands in Redis. However if the key is associated with an +# aggregated value containing millions of elements, the server can block for +# a long time (even seconds) in order to complete the operation. +# +# For the above reasons Redis also offers non blocking deletion primitives +# such as UNLINK (non blocking DEL) and the ASYNC option of FLUSHALL and +# FLUSHDB commands, in order to reclaim memory in background. Those commands +# are executed in constant time. Another thread will incrementally free the +# object in the background as fast as possible. +# +# DEL, UNLINK and ASYNC option of FLUSHALL and FLUSHDB are user-controlled. +# It's up to the design of the application to understand when it is a good +# idea to use one or the other. However the Redis server sometimes has to +# delete keys or flush the whole database as a side effect of other operations. +# Specifically Redis deletes objects independently of a user call in the +# following scenarios: +# +# 1) On eviction, because of the maxmemory and maxmemory policy configurations, +# in order to make room for new data, without going over the specified +# memory limit. +# 2) Because of expire: when a key with an associated time to live (see the +# EXPIRE command) must be deleted from memory. +# 3) Because of a side effect of a command that stores data on a key that may +# already exist. For example the RENAME command may delete the old key +# content when it is replaced with another one. Similarly SUNIONSTORE +# or SORT with STORE option may delete existing keys. The SET command +# itself removes any old content of the specified key in order to replace +# it with the specified string. +# 4) During replication, when a slave performs a full resynchronization with +# its master, the content of the whole database is removed in order to +# load the RDB file just transfered. +# +# In all the above cases the default is to delete objects in a blocking way, +# like if DEL was called. However you can configure each case specifically +# in order to instead release memory in a non-blocking way like if UNLINK +# was called, using the following configuration directives: + +lazyfree-lazy-eviction no +lazyfree-lazy-expire no +lazyfree-lazy-server-del no +slave-lazy-flush no + +############################## APPEND ONLY MODE ############################### + +# By default Redis asynchronously dumps the dataset on disk. This mode is +# good enough in many applications, but an issue with the Redis process or +# a power outage may result into a few minutes of writes lost (depending on +# the configured save points). +# +# The Append Only File is an alternative persistence mode that provides +# much better durability. For instance using the default data fsync policy +# (see later in the config file) Redis can lose just one second of writes in a +# dramatic event like a server power outage, or a single write if something +# wrong with the Redis process itself happens, but the operating system is +# still running correctly. +# +# AOF and RDB persistence can be enabled at the same time without problems. +# If the AOF is enabled on startup Redis will load the AOF, that is the file +# with the better durability guarantees. +# +# Please check http://redis.io/topics/persistence for more information. + +appendonly no + +# The name of the append only file (default: "appendonly.aof") + +appendfilename "appendonly.aof" + +# The fsync() call tells the Operating System to actually write data on disk +# instead of waiting for more data in the output buffer. Some OS will really flush +# data on disk, some other OS will just try to do it ASAP. +# +# Redis supports three different modes: +# +# no: don't fsync, just let the OS flush the data when it wants. Faster. +# always: fsync after every write to the append only log. Slow, Safest. +# everysec: fsync only one time every second. Compromise. +# +# The default is "everysec", as that's usually the right compromise between +# speed and data safety. It's up to you to understand if you can relax this to +# "no" that will let the operating system flush the output buffer when +# it wants, for better performances (but if you can live with the idea of +# some data loss consider the default persistence mode that's snapshotting), +# or on the contrary, use "always" that's very slow but a bit safer than +# everysec. +# +# More details please check the following article: +# http://antirez.com/post/redis-persistence-demystified.html +# +# If unsure, use "everysec". + +# appendfsync always +appendfsync everysec +# appendfsync no + +# When the AOF fsync policy is set to always or everysec, and a background +# saving process (a background save or AOF log background rewriting) is +# performing a lot of I/O against the disk, in some Linux configurations +# Redis may block too long on the fsync() call. Note that there is no fix for +# this currently, as even performing fsync in a different thread will block +# our synchronous write(2) call. +# +# In order to mitigate this problem it's possible to use the following option +# that will prevent fsync() from being called in the main process while a +# BGSAVE or BGREWRITEAOF is in progress. +# +# This means that while another child is saving, the durability of Redis is +# the same as "appendfsync none". In practical terms, this means that it is +# possible to lose up to 30 seconds of log in the worst scenario (with the +# default Linux settings). +# +# If you have latency problems turn this to "yes". Otherwise leave it as +# "no" that is the safest pick from the point of view of durability. + +no-appendfsync-on-rewrite no + +# Automatic rewrite of the append only file. +# Redis is able to automatically rewrite the log file implicitly calling +# BGREWRITEAOF when the AOF log size grows by the specified percentage. +# +# This is how it works: Redis remembers the size of the AOF file after the +# latest rewrite (if no rewrite has happened since the restart, the size of +# the AOF at startup is used). +# +# This base size is compared to the current size. If the current size is +# bigger than the specified percentage, the rewrite is triggered. Also +# you need to specify a minimal size for the AOF file to be rewritten, this +# is useful to avoid rewriting the AOF file even if the percentage increase +# is reached but it is still pretty small. +# +# Specify a percentage of zero in order to disable the automatic AOF +# rewrite feature. + +auto-aof-rewrite-percentage 100 +auto-aof-rewrite-min-size 64mb + +# An AOF file may be found to be truncated at the end during the Redis +# startup process, when the AOF data gets loaded back into memory. +# This may happen when the system where Redis is running +# crashes, especially when an ext4 filesystem is mounted without the +# data=ordered option (however this can't happen when Redis itself +# crashes or aborts but the operating system still works correctly). +# +# Redis can either exit with an error when this happens, or load as much +# data as possible (the default now) and start if the AOF file is found +# to be truncated at the end. The following option controls this behavior. +# +# If aof-load-truncated is set to yes, a truncated AOF file is loaded and +# the Redis server starts emitting a log to inform the user of the event. +# Otherwise if the option is set to no, the server aborts with an error +# and refuses to start. When the option is set to no, the user requires +# to fix the AOF file using the "redis-check-aof" utility before to restart +# the server. +# +# Note that if the AOF file will be found to be corrupted in the middle +# the server will still exit with an error. This option only applies when +# Redis will try to read more data from the AOF file but not enough bytes +# will be found. +aof-load-truncated yes + +# When rewriting the AOF file, Redis is able to use an RDB preamble in the +# AOF file for faster rewrites and recoveries. When this option is turned +# on the rewritten AOF file is composed of two different stanzas: +# +# [RDB file][AOF tail] +# +# When loading Redis recognizes that the AOF file starts with the "REDIS" +# string and loads the prefixed RDB file, and continues loading the AOF +# tail. +# +# This is currently turned off by default in order to avoid the surprise +# of a format change, but will at some point be used as the default. +aof-use-rdb-preamble no + +################################ LUA SCRIPTING ############################### + +# Max execution time of a Lua script in milliseconds. +# +# If the maximum execution time is reached Redis will log that a script is +# still in execution after the maximum allowed time and will start to +# reply to queries with an error. +# +# When a long running script exceeds the maximum execution time only the +# SCRIPT KILL and SHUTDOWN NOSAVE commands are available. The first can be +# used to stop a script that did not yet called write commands. The second +# is the only way to shut down the server in the case a write command was +# already issued by the script but the user doesn't want to wait for the natural +# termination of the script. +# +# Set it to 0 or a negative value for unlimited execution without warnings. +lua-time-limit 5000 + +################################ REDIS CLUSTER ############################### +# +# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# WARNING EXPERIMENTAL: Redis Cluster is considered to be stable code, however +# in order to mark it as "mature" we need to wait for a non trivial percentage +# of users to deploy it in production. +# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# +# Normal Redis instances can't be part of a Redis Cluster; only nodes that are +# started as cluster nodes can. In order to start a Redis instance as a +# cluster node enable the cluster support uncommenting the following: +# +# cluster-enabled yes + +# Every cluster node has a cluster configuration file. This file is not +# intended to be edited by hand. It is created and updated by Redis nodes. +# Every Redis Cluster node requires a different cluster configuration file. +# Make sure that instances running in the same system do not have +# overlapping cluster configuration file names. +# +# cluster-config-file nodes-6379.conf + +# Cluster node timeout is the amount of milliseconds a node must be unreachable +# for it to be considered in failure state. +# Most other internal time limits are multiple of the node timeout. +# +# cluster-node-timeout 15000 + +# A slave of a failing master will avoid to start a failover if its data +# looks too old. +# +# There is no simple way for a slave to actually have an exact measure of +# its "data age", so the following two checks are performed: +# +# 1) If there are multiple slaves able to failover, they exchange messages +# in order to try to give an advantage to the slave with the best +# replication offset (more data from the master processed). +# Slaves will try to get their rank by offset, and apply to the start +# of the failover a delay proportional to their rank. +# +# 2) Every single slave computes the time of the last interaction with +# its master. This can be the last ping or command received (if the master +# is still in the "connected" state), or the time that elapsed since the +# disconnection with the master (if the replication link is currently down). +# If the last interaction is too old, the slave will not try to failover +# at all. +# +# The point "2" can be tuned by user. Specifically a slave will not perform +# the failover if, since the last interaction with the master, the time +# elapsed is greater than: +# +# (node-timeout * slave-validity-factor) + repl-ping-slave-period +# +# So for example if node-timeout is 30 seconds, and the slave-validity-factor +# is 10, and assuming a default repl-ping-slave-period of 10 seconds, the +# slave will not try to failover if it was not able to talk with the master +# for longer than 310 seconds. +# +# A large slave-validity-factor may allow slaves with too old data to failover +# a master, while a too small value may prevent the cluster from being able to +# elect a slave at all. +# +# For maximum availability, it is possible to set the slave-validity-factor +# to a value of 0, which means, that slaves will always try to failover the +# master regardless of the last time they interacted with the master. +# (However they'll always try to apply a delay proportional to their +# offset rank). +# +# Zero is the only value able to guarantee that when all the partitions heal +# the cluster will always be able to continue. +# +# cluster-slave-validity-factor 10 + +# Cluster slaves are able to migrate to orphaned masters, that are masters +# that are left without working slaves. This improves the cluster ability +# to resist to failures as otherwise an orphaned master can't be failed over +# in case of failure if it has no working slaves. +# +# Slaves migrate to orphaned masters only if there are still at least a +# given number of other working slaves for their old master. This number +# is the "migration barrier". A migration barrier of 1 means that a slave +# will migrate only if there is at least 1 other working slave for its master +# and so forth. It usually reflects the number of slaves you want for every +# master in your cluster. +# +# Default is 1 (slaves migrate only if their masters remain with at least +# one slave). To disable migration just set it to a very large value. +# A value of 0 can be set but is useful only for debugging and dangerous +# in production. +# +# cluster-migration-barrier 1 + +# By default Redis Cluster nodes stop accepting queries if they detect there +# is at least an hash slot uncovered (no available node is serving it). +# This way if the cluster is partially down (for example a range of hash slots +# are no longer covered) all the cluster becomes, eventually, unavailable. +# It automatically returns available as soon as all the slots are covered again. +# +# However sometimes you want the subset of the cluster which is working, +# to continue to accept queries for the part of the key space that is still +# covered. In order to do so, just set the cluster-require-full-coverage +# option to no. +# +# cluster-require-full-coverage yes + +# In order to setup your cluster make sure to read the documentation +# available at http://redis.io web site. + +########################## CLUSTER DOCKER/NAT support ######################## + +# In certain deployments, Redis Cluster nodes address discovery fails, because +# addresses are NAT-ted or because ports are forwarded (the typical case is +# Docker and other containers). +# +# In order to make Redis Cluster working in such environments, a static +# configuration where each node knows its public address is needed. The +# following two options are used for this scope, and are: +# +# * cluster-announce-ip +# * cluster-announce-port +# * cluster-announce-bus-port +# +# Each instruct the node about its address, client port, and cluster message +# bus port. The information is then published in the header of the bus packets +# so that other nodes will be able to correctly map the address of the node +# publishing the information. +# +# If the above options are not used, the normal Redis Cluster auto-detection +# will be used instead. +# +# Note that when remapped, the bus port may not be at the fixed offset of +# clients port + 10000, so you can specify any port and bus-port depending +# on how they get remapped. If the bus-port is not set, a fixed offset of +# 10000 will be used as usually. +# +# Example: +# +# cluster-announce-ip 10.1.1.5 +# cluster-announce-port 6379 +# cluster-announce-bus-port 6380 + +################################## SLOW LOG ################################### + +# The Redis Slow Log is a system to log queries that exceeded a specified +# execution time. The execution time does not include the I/O operations +# like talking with the client, sending the reply and so forth, +# but just the time needed to actually execute the command (this is the only +# stage of command execution where the thread is blocked and can not serve +# other requests in the meantime). +# +# You can configure the slow log with two parameters: one tells Redis +# what is the execution time, in microseconds, to exceed in order for the +# command to get logged, and the other parameter is the length of the +# slow log. When a new command is logged the oldest one is removed from the +# queue of logged commands. + +# The following time is expressed in microseconds, so 1000000 is equivalent +# to one second. Note that a negative number disables the slow log, while +# a value of zero forces the logging of every command. +slowlog-log-slower-than 10000 + +# There is no limit to this length. Just be aware that it will consume memory. +# You can reclaim memory used by the slow log with SLOWLOG RESET. +slowlog-max-len 128 + +################################ LATENCY MONITOR ############################## + +# The Redis latency monitoring subsystem samples different operations +# at runtime in order to collect data related to possible sources of +# latency of a Redis instance. +# +# Via the LATENCY command this information is available to the user that can +# print graphs and obtain reports. +# +# The system only logs operations that were performed in a time equal or +# greater than the amount of milliseconds specified via the +# latency-monitor-threshold configuration directive. When its value is set +# to zero, the latency monitor is turned off. +# +# By default latency monitoring is disabled since it is mostly not needed +# if you don't have latency issues, and collecting data has a performance +# impact, that while very small, can be measured under big load. Latency +# monitoring can easily be enabled at runtime using the command +# "CONFIG SET latency-monitor-threshold " if needed. +latency-monitor-threshold 0 + +############################# EVENT NOTIFICATION ############################## + +# Redis can notify Pub/Sub clients about events happening in the key space. +# This feature is documented at http://redis.io/topics/notifications +# +# For instance if keyspace events notification is enabled, and a client +# performs a DEL operation on key "foo" stored in the Database 0, two +# messages will be published via Pub/Sub: +# +# PUBLISH __keyspace@0__:foo del +# PUBLISH __keyevent@0__:del foo +# +# It is possible to select the events that Redis will notify among a set +# of classes. Every class is identified by a single character: +# +# K Keyspace events, published with __keyspace@__ prefix. +# E Keyevent events, published with __keyevent@__ prefix. +# g Generic commands (non-type specific) like DEL, EXPIRE, RENAME, ... +# $ String commands +# l List commands +# s Set commands +# h Hash commands +# z Sorted set commands +# x Expired events (events generated every time a key expires) +# e Evicted events (events generated when a key is evicted for maxmemory) +# A Alias for g$lshzxe, so that the "AKE" string means all the events. +# +# The "notify-keyspace-events" takes as argument a string that is composed +# of zero or multiple characters. The empty string means that notifications +# are disabled. +# +# Example: to enable list and generic events, from the point of view of the +# event name, use: +# +# notify-keyspace-events Elg +# +# Example 2: to get the stream of the expired keys subscribing to channel +# name __keyevent@0__:expired use: +# +# notify-keyspace-events Ex +# +# By default all notifications are disabled because most users don't need +# this feature and the feature has some overhead. Note that if you don't +# specify at least one of K or E, no events will be delivered. +notify-keyspace-events "" + +############################### ADVANCED CONFIG ############################### + +# Hashes are encoded using a memory efficient data structure when they have a +# small number of entries, and the biggest entry does not exceed a given +# threshold. These thresholds can be configured using the following directives. +hash-max-ziplist-entries 512 +hash-max-ziplist-value 64 + +# Lists are also encoded in a special way to save a lot of space. +# The number of entries allowed per internal list node can be specified +# as a fixed maximum size or a maximum number of elements. +# For a fixed maximum size, use -5 through -1, meaning: +# -5: max size: 64 Kb <-- not recommended for normal workloads +# -4: max size: 32 Kb <-- not recommended +# -3: max size: 16 Kb <-- probably not recommended +# -2: max size: 8 Kb <-- good +# -1: max size: 4 Kb <-- good +# Positive numbers mean store up to _exactly_ that number of elements +# per list node. +# The highest performing option is usually -2 (8 Kb size) or -1 (4 Kb size), +# but if your use case is unique, adjust the settings as necessary. +list-max-ziplist-size -2 + +# Lists may also be compressed. +# Compress depth is the number of quicklist ziplist nodes from *each* side of +# the list to *exclude* from compression. The head and tail of the list +# are always uncompressed for fast push/pop operations. Settings are: +# 0: disable all list compression +# 1: depth 1 means "don't start compressing until after 1 node into the list, +# going from either the head or tail" +# So: [head]->node->node->...->node->[tail] +# [head], [tail] will always be uncompressed; inner nodes will compress. +# 2: [head]->[next]->node->node->...->node->[prev]->[tail] +# 2 here means: don't compress head or head->next or tail->prev or tail, +# but compress all nodes between them. +# 3: [head]->[next]->[next]->node->node->...->node->[prev]->[prev]->[tail] +# etc. +list-compress-depth 0 + +# Sets have a special encoding in just one case: when a set is composed +# of just strings that happen to be integers in radix 10 in the range +# of 64 bit signed integers. +# The following configuration setting sets the limit in the size of the +# set in order to use this special memory saving encoding. +set-max-intset-entries 512 + +# Similarly to hashes and lists, sorted sets are also specially encoded in +# order to save a lot of space. This encoding is only used when the length and +# elements of a sorted set are below the following limits: +zset-max-ziplist-entries 128 +zset-max-ziplist-value 64 + +# HyperLogLog sparse representation bytes limit. The limit includes the +# 16 bytes header. When an HyperLogLog using the sparse representation crosses +# this limit, it is converted into the dense representation. +# +# A value greater than 16000 is totally useless, since at that point the +# dense representation is more memory efficient. +# +# The suggested value is ~ 3000 in order to have the benefits of +# the space efficient encoding without slowing down too much PFADD, +# which is O(N) with the sparse encoding. The value can be raised to +# ~ 10000 when CPU is not a concern, but space is, and the data set is +# composed of many HyperLogLogs with cardinality in the 0 - 15000 range. +hll-sparse-max-bytes 3000 + +# Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in +# order to help rehashing the main Redis hash table (the one mapping top-level +# keys to values). The hash table implementation Redis uses (see dict.c) +# performs a lazy rehashing: the more operation you run into a hash table +# that is rehashing, the more rehashing "steps" are performed, so if the +# server is idle the rehashing is never complete and some more memory is used +# by the hash table. +# +# The default is to use this millisecond 10 times every second in order to +# actively rehash the main dictionaries, freeing memory when possible. +# +# If unsure: +# use "activerehashing no" if you have hard latency requirements and it is +# not a good thing in your environment that Redis can reply from time to time +# to queries with 2 milliseconds delay. +# +# use "activerehashing yes" if you don't have such hard requirements but +# want to free memory asap when possible. +activerehashing yes + +# The client output buffer limits can be used to force disconnection of clients +# that are not reading data from the server fast enough for some reason (a +# common reason is that a Pub/Sub client can't consume messages as fast as the +# publisher can produce them). +# +# The limit can be set differently for the three different classes of clients: +# +# normal -> normal clients including MONITOR clients +# slave -> slave clients +# pubsub -> clients subscribed to at least one pubsub channel or pattern +# +# The syntax of every client-output-buffer-limit directive is the following: +# +# client-output-buffer-limit +# +# A client is immediately disconnected once the hard limit is reached, or if +# the soft limit is reached and remains reached for the specified number of +# seconds (continuously). +# So for instance if the hard limit is 32 megabytes and the soft limit is +# 16 megabytes / 10 seconds, the client will get disconnected immediately +# if the size of the output buffers reach 32 megabytes, but will also get +# disconnected if the client reaches 16 megabytes and continuously overcomes +# the limit for 10 seconds. +# +# By default normal clients are not limited because they don't receive data +# without asking (in a push way), but just after a request, so only +# asynchronous clients may create a scenario where data is requested faster +# than it can read. +# +# Instead there is a default limit for pubsub and slave clients, since +# subscribers and slaves receive data in a push fashion. +# +# Both the hard or the soft limit can be disabled by setting them to zero. +client-output-buffer-limit normal 0 0 0 +client-output-buffer-limit slave 256mb 64mb 60 +client-output-buffer-limit pubsub 32mb 8mb 60 + +# Client query buffers accumulate new commands. They are limited to a fixed +# amount by default in order to avoid that a protocol desynchronization (for +# instance due to a bug in the client) will lead to unbound memory usage in +# the query buffer. However you can configure it here if you have very special +# needs, such us huge multi/exec requests or alike. +# +# client-query-buffer-limit 1gb + +# In the Redis protocol, bulk requests, that are, elements representing single +# strings, are normally limited ot 512 mb. However you can change this limit +# here. +# +# proto-max-bulk-len 512mb + +# Redis calls an internal function to perform many background tasks, like +# closing connections of clients in timeout, purging expired keys that are +# never requested, and so forth. +# +# Not all tasks are performed with the same frequency, but Redis checks for +# tasks to perform according to the specified "hz" value. +# +# By default "hz" is set to 10. Raising the value will use more CPU when +# Redis is idle, but at the same time will make Redis more responsive when +# there are many keys expiring at the same time, and timeouts may be +# handled with more precision. +# +# The range is between 1 and 500, however a value over 100 is usually not +# a good idea. Most users should use the default of 10 and raise this up to +# 100 only in environments where very low latency is required. +hz 10 + +# When a child rewrites the AOF file, if the following option is enabled +# the file will be fsync-ed every 32 MB of data generated. This is useful +# in order to commit the file to the disk more incrementally and avoid +# big latency spikes. +aof-rewrite-incremental-fsync yes + +# Redis LFU eviction (see maxmemory setting) can be tuned. However it is a good +# idea to start with the default settings and only change them after investigating +# how to improve the performances and how the keys LFU change over time, which +# is possible to inspect via the OBJECT FREQ command. +# +# There are two tunable parameters in the Redis LFU implementation: the +# counter logarithm factor and the counter decay time. It is important to +# understand what the two parameters mean before changing them. +# +# The LFU counter is just 8 bits per key, it's maximum value is 255, so Redis +# uses a probabilistic increment with logarithmic behavior. Given the value +# of the old counter, when a key is accessed, the counter is incremented in +# this way: +# +# 1. A random number R between 0 and 1 is extracted. +# 2. A probability P is calculated as 1/(old_value*lfu_log_factor+1). +# 3. The counter is incremented only if R < P. +# +# The default lfu-log-factor is 10. This is a table of how the frequency +# counter changes with a different number of accesses with different +# logarithmic factors: +# +# +--------+------------+------------+------------+------------+------------+ +# | factor | 100 hits | 1000 hits | 100K hits | 1M hits | 10M hits | +# +--------+------------+------------+------------+------------+------------+ +# | 0 | 104 | 255 | 255 | 255 | 255 | +# +--------+------------+------------+------------+------------+------------+ +# | 1 | 18 | 49 | 255 | 255 | 255 | +# +--------+------------+------------+------------+------------+------------+ +# | 10 | 10 | 18 | 142 | 255 | 255 | +# +--------+------------+------------+------------+------------+------------+ +# | 100 | 8 | 11 | 49 | 143 | 255 | +# +--------+------------+------------+------------+------------+------------+ +# +# NOTE: The above table was obtained by running the following commands: +# +# redis-benchmark -n 1000000 incr foo +# redis-cli object freq foo +# +# NOTE 2: The counter initial value is 5 in order to give new objects a chance +# to accumulate hits. +# +# The counter decay time is the time, in minutes, that must elapse in order +# for the key counter to be divided by two (or decremented if it has a value +# less <= 10). +# +# The default value for the lfu-decay-time is 1. A Special value of 0 means to +# decay the counter every time it happens to be scanned. +# +# lfu-log-factor 10 +# lfu-decay-time 1 + +########################### ACTIVE DEFRAGMENTATION ####################### +# +# WARNING THIS FEATURE IS EXPERIMENTAL. However it was stress tested +# even in production and manually tested by multiple engineers for some +# time. +# +# What is active defragmentation? +# ------------------------------- +# +# Active (online) defragmentation allows a Redis server to compact the +# spaces left between small allocations and deallocations of data in memory, +# thus allowing to reclaim back memory. +# +# Fragmentation is a natural process that happens with every allocator (but +# less so with Jemalloc, fortunately) and certain workloads. Normally a server +# restart is needed in order to lower the fragmentation, or at least to flush +# away all the data and create it again. However thanks to this feature +# implemented by Oran Agra for Redis 4.0 this process can happen at runtime +# in an "hot" way, while the server is running. +# +# Basically when the fragmentation is over a certain level (see the +# configuration options below) Redis will start to create new copies of the +# values in contiguous memory regions by exploiting certain specific Jemalloc +# features (in order to understand if an allocation is causing fragmentation +# and to allocate it in a better place), and at the same time, will release the +# old copies of the data. This process, repeated incrementally for all the keys +# will cause the fragmentation to drop back to normal values. +# +# Important things to understand: +# +# 1. This feature is disabled by default, and only works if you compiled Redis +# to use the copy of Jemalloc we ship with the source code of Redis. +# This is the default with Linux builds. +# +# 2. You never need to enable this feature if you don't have fragmentation +# issues. +# +# 3. Once you experience fragmentation, you can enable this feature when +# needed with the command "CONFIG SET activedefrag yes". +# +# The configuration parameters are able to fine tune the behavior of the +# defragmentation process. If you are not sure about what they mean it is +# a good idea to leave the defaults untouched. + +# Enabled active defragmentation +# activedefrag yes + +# Minimum amount of fragmentation waste to start active defrag +# active-defrag-ignore-bytes 100mb + +# Minimum percentage of fragmentation to start active defrag +# active-defrag-threshold-lower 10 + +# Maximum percentage of fragmentation at which we use maximum effort +# active-defrag-threshold-upper 100 + +# Minimal effort for defrag in CPU percentage +# active-defrag-cycle-min 25 + +# Maximal effort for defrag in CPU percentage +# active-defrag-cycle-max 75 + diff --git a/OrangeFormsOpen-MybatisPlus/.DS_Store b/OrangeFormsOpen-MybatisPlus/.DS_Store new file mode 100644 index 00000000..fccbcd6b Binary files /dev/null and b/OrangeFormsOpen-MybatisPlus/.DS_Store differ diff --git a/OrangeFormsOpen-MybatisPlus/.gitignore b/OrangeFormsOpen-MybatisPlus/.gitignore new file mode 100644 index 00000000..e3fa94cd --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/.gitignore @@ -0,0 +1,26 @@ +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/ \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/README.md b/OrangeFormsOpen-MybatisPlus/README.md new file mode 100644 index 00000000..980a205f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/README.md @@ -0,0 +1,21 @@ +### 服务接口文档 +--- +- 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) +- Minio + - 版本:8.4.5 + - 控制台URL:需要配置Nginx,将请求导入到我们缺省设置的19000端口,之后可通过浏览器操作minio。 + - 缺省用户名密码:admin/admin123456 diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/pom.xml b/OrangeFormsOpen-MybatisPlus/application-webadmin/pom.xml new file mode 100644 index 00000000..a78c5df9 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/pom.xml @@ -0,0 +1,91 @@ + + + + com.orangeforms + OrangeFormsOpen + 1.0.0 + + 4.0.0 + + application-webadmin + 1.0.0 + application-webadmin + jar + + + + + com.orangeforms + common-satoken + 1.0.0 + + + com.orangeforms + common-ext + 1.0.0 + + + com.orangeforms + common-redis + 1.0.0 + + + com.orangeforms + common-online + 1.0.0 + + + com.orangeforms + common-flow-online + 1.0.0 + + + com.orangeforms + common-log + 1.0.0 + + + com.orangeforms + common-minio + 1.0.0 + + + com.orangeforms + common-sequence + 1.0.0 + + + com.orangeforms + common-datafilter + 1.0.0 + + + com.orangeforms + common-swagger + 1.0.0 + + + com.orangeforms + common-dict + 1.0.0 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + + + repackage + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/WebAdminApplication.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/WebAdminApplication.java new file mode 100644 index 00000000..86a9458a --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/WebAdminApplication.java @@ -0,0 +1,23 @@ +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 2024-07-02 + */ +@EnableAsync +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) +@ComponentScan("com.orangeforms") +public class WebAdminApplication { + + public static void main(String[] args) { + SpringApplication.run(WebAdminApplication.class, args); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/app/util/FlowIdentityExtHelper.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/app/util/FlowIdentityExtHelper.java new file mode 100644 index 00000000..d5198b82 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/app/util/FlowIdentityExtHelper.java @@ -0,0 +1,244 @@ +package com.orangeforms.webadmin.app.util; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import com.orangeforms.common.flow.util.BaseFlowIdentityExtHelper; +import com.orangeforms.common.flow.util.FlowCustomExtFactory; +import com.orangeforms.common.flow.vo.FlowUserInfoVo; +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 jakarta.annotation.PostConstruct; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 为流程提供所需的用户身份相关的等扩展信息的帮助类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@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 deptPostIdList = sysDeptService.getLeaderDeptPostIdList(deptId); + return CollUtil.isEmpty(deptPostIdList) ? null : deptPostIdList.get(0); + } + + @Override + public Long getUpLeaderDeptPostId(Long deptId) { + List deptPostIdList = sysDeptService.getUpLeaderDeptPostIdList(deptId); + return CollUtil.isEmpty(deptPostIdList) ? null : deptPostIdList.get(0); + } + + @Override + public Map getDeptPostIdMap(Long deptId, Set postIdSet) { + Set postIdSet2 = postIdSet.stream().map(Long::valueOf).collect(Collectors.toSet()); + List deptPostList = sysDeptService.getSysDeptPostList(deptId, postIdSet2); + if (CollUtil.isEmpty(deptPostList)) { + return null; + } + Map resultMap = new HashMap<>(deptPostList.size()); + deptPostList.forEach(sysDeptPost -> + resultMap.put(sysDeptPost.getPostId().toString(), sysDeptPost.getDeptPostId().toString())); + return resultMap; + } + + @Override + public Map getSiblingDeptPostIdMap(Long deptId, Set postIdSet) { + Set postIdSet2 = postIdSet.stream().map(Long::valueOf).collect(Collectors.toSet()); + List deptPostList = sysDeptService.getSiblingSysDeptPostList(deptId, postIdSet2); + if (CollUtil.isEmpty(deptPostList)) { + return null; + } + Map resultMap = new HashMap<>(deptPostList.size()); + for (SysDeptPost deptPost : deptPostList) { + String deptPostId = resultMap.get(deptPost.getPostId().toString()); + if (deptPostId != null) { + deptPostId = deptPostId + "," + deptPost.getDeptPostId(); + } else { + deptPostId = deptPost.getDeptPostId().toString(); + } + resultMap.put(deptPost.getPostId().toString(), deptPostId); + } + return resultMap; + } + + @Override + public Map getUpDeptPostIdMap(Long deptId, Set postIdSet) { + SysDept sysDept = sysDeptService.getById(deptId); + if (sysDept == null || sysDept.getParentId() == null) { + return null; + } + return getDeptPostIdMap(sysDept.getParentId(), postIdSet); + } + + @Override + public Set getUsernameListByRoleIds(Set roleIdSet) { + Set usernameSet = new HashSet<>(); + Set roleIdSet2 = roleIdSet.stream().map(Long::valueOf).collect(Collectors.toSet()); + SysUser filter = new SysUser(); + filter.setUserStatus(SysUserStatus.STATUS_NORMAL); + for (Long roleId : roleIdSet2) { + List userList = sysUserService.getSysUserListByRoleId(roleId, filter, null); + this.extractAndAppendUsernameList(usernameSet, userList); + } + return usernameSet; + } + + @Override + public List getUserInfoListByRoleIds(Set roleIdSet) { + List resultList = new LinkedList<>(); + Set roleIdSet2 = roleIdSet.stream().map(Long::valueOf).collect(Collectors.toSet()); + SysUser filter = new SysUser(); + filter.setUserStatus(SysUserStatus.STATUS_NORMAL); + for (Long roleId : roleIdSet2) { + List userList = sysUserService.getSysUserListByRoleId(roleId, filter, null); + if (CollUtil.isNotEmpty(userList)) { + resultList.addAll(BeanUtil.copyToList(userList, FlowUserInfoVo.class)); + } + } + return resultList; + } + + @Override + public Set getUsernameListByDeptIds(Set deptIdSet) { + Set usernameSet = new HashSet<>(); + Set 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 userList = sysUserService.getSysUserList(filter, null); + this.extractAndAppendUsernameList(usernameSet, userList); + } + return usernameSet; + } + + @Override + public List getUserInfoListByDeptIds(Set deptIdSet) { + List resultList = new LinkedList<>(); + Set 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 userList = sysUserService.getSysUserList(filter, null); + if (CollUtil.isNotEmpty(userList)) { + resultList.addAll(BeanUtil.copyToList(userList, FlowUserInfoVo.class)); + } + } + return resultList; + } + + @Override + public Set getUsernameListByPostIds(Set postIdSet) { + Set usernameSet = new HashSet<>(); + Set postIdSet2 = postIdSet.stream().map(Long::valueOf).collect(Collectors.toSet()); + SysUser filter = new SysUser(); + filter.setUserStatus(SysUserStatus.STATUS_NORMAL); + for (Long postId : postIdSet2) { + List userList = sysUserService.getSysUserListByPostId(postId, filter, null); + this.extractAndAppendUsernameList(usernameSet, userList); + } + return usernameSet; + } + + @Override + public List getUserInfoListByPostIds(Set postIdSet) { + List resultList = new LinkedList<>(); + Set postIdSet2 = postIdSet.stream().map(Long::valueOf).collect(Collectors.toSet()); + SysUser filter = new SysUser(); + filter.setUserStatus(SysUserStatus.STATUS_NORMAL); + for (Long postId : postIdSet2) { + List userList = sysUserService.getSysUserListByPostId(postId, filter, null); + if (CollUtil.isNotEmpty(userList)) { + resultList.addAll(BeanUtil.copyToList(userList, FlowUserInfoVo.class)); + } + } + return resultList; + } + + @Override + public Set getUsernameListByDeptPostIds(Set deptPostIdSet) { + Set usernameSet = new HashSet<>(); + Set deptPostIdSet2 = deptPostIdSet.stream().map(Long::valueOf).collect(Collectors.toSet()); + SysUser filter = new SysUser(); + filter.setUserStatus(SysUserStatus.STATUS_NORMAL); + for (Long deptPostId : deptPostIdSet2) { + List userList = sysUserService.getSysUserListByDeptPostId(deptPostId, filter, null); + this.extractAndAppendUsernameList(usernameSet, userList); + } + return usernameSet; + } + + @Override + public List getUserInfoListByDeptPostIds(Set deptPostIdSet) { + List resultList = new LinkedList<>(); + Set deptPostIdSet2 = deptPostIdSet.stream().map(Long::valueOf).collect(Collectors.toSet()); + SysUser filter = new SysUser(); + filter.setUserStatus(SysUserStatus.STATUS_NORMAL); + for (Long deptPostId : deptPostIdSet2) { + List userList = sysUserService.getSysUserListByDeptPostId(deptPostId, filter, null); + if (CollUtil.isNotEmpty(userList)) { + resultList.addAll(BeanUtil.copyToList(userList, FlowUserInfoVo.class)); + } + } + return resultList; + } + + @Override + public List getUserInfoListByUsernameSet(Set usernameSet) { + List resultList = null; + List userList = sysUserService.getInList("loginName", usernameSet); + if (CollUtil.isNotEmpty(userList)) { + resultList = BeanUtil.copyToList(userList, FlowUserInfoVo.class); + } + return resultList; + } + + @Override + public Boolean supprtDataPerm() { + return true; + } + + @Override + public Map mapUserShowNameByLoginName(Set loginNameSet) { + if (CollUtil.isEmpty(loginNameSet)) { + return new HashMap<>(1); + } + Map resultMap = new HashMap<>(loginNameSet.size()); + List userList = sysUserService.getInList("loginName", loginNameSet); + userList.forEach(user -> resultMap.put(user.getLoginName(), user.getShowName())); + return resultMap; + } + + private void extractAndAppendUsernameList(Set resultUsernameList, List userList) { + List usernameList = userList.stream().map(SysUser::getLoginName).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(usernameList)) { + resultUsernameList.addAll(usernameList); + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/config/ApplicationConfig.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/config/ApplicationConfig.java new file mode 100644 index 00000000..dd028f9d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/config/ApplicationConfig.java @@ -0,0 +1,38 @@ +package com.orangeforms.webadmin.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +/** + * 应用程序自定义的程序属性配置文件。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Configuration +@ConfigurationProperties(prefix = "application") +public class ApplicationConfig { + /** + * 用户密码被重置之后的缺省密码 + */ + 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中的过期时间(秒)。一定要和sa-token.timeout + * 缺省值是 one day + */ + private int sessionExpiredSeconds = 86400; + /** + * 是否排他登录。 + */ + private Boolean excludeLogin = false; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/config/DataSourceType.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/config/DataSourceType.java new file mode 100644 index 00000000..4820bda3 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/config/DataSourceType.java @@ -0,0 +1,47 @@ +package com.orangeforms.webadmin.config; + +import com.orangeforms.common.core.constant.ApplicationConstant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 表示数据源类型的常量对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class DataSourceType { + + public static final int MAIN = 0; + /** + * 以下所有数据源的类都型是固定值。如果有冲突,请修改上面定义的业务服务的数据源类型值。 + */ + public static final int OPERATION_LOG = ApplicationConstant.OPERATION_LOG_DATASOURCE_TYPE; + public static final int GLOBAL_DICT = ApplicationConstant.COMMON_GLOBAL_DICT_TYPE; + public static final int COMMON_FLOW_AND_ONLINE = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE; + + private static final Map TYPE_MAP = new HashMap<>(8); + static { + TYPE_MAP.put("main", MAIN); + TYPE_MAP.put("operation-log", OPERATION_LOG); + TYPE_MAP.put("global-dict", GLOBAL_DICT); + TYPE_MAP.put("common-flow-online", COMMON_FLOW_AND_ONLINE); + } + + /** + * 根据名称获取字典类型。 + * + * @param name 数据源在配置中的名称。 + * @return 返回可用于多数据源切换的数据源类型。 + */ + public static Integer getDataSourceTypeByName(String name) { + return TYPE_MAP.get(name); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private DataSourceType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/config/FilterConfig.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/config/FilterConfig.java new file mode 100644 index 00000000..350602db --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/config/FilterConfig.java @@ -0,0 +1,60 @@ +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 jakarta.servlet.Filter; +import java.nio.charset.StandardCharsets; + +/** + * 这里主要配置Web的各种过滤器和监听器等Servlet容器组件。 + * + * @author Jerry + * @date 2024-07-02 + */ +@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.setAllowCredentials(true); + configSource.registerCorsConfiguration("/**", corsConfiguration); + } + return new CorsFilter(configSource); + } + + @Bean + public FilterRegistrationBean characterEncodingFilterRegistration() { + FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean<>( + new org.springframework.web.filter.CharacterEncodingFilter()); + filterRegistrationBean.addUrlPatterns("/*"); + filterRegistrationBean.addInitParameter("encoding", StandardCharsets.UTF_8.name()); + // forceEncoding强制response也被编码,另外即使request中已经设置encoding,forceEncoding也会重新设置 + filterRegistrationBean.addInitParameter("forceEncoding", "true"); + filterRegistrationBean.setAsyncSupported(true); + return filterRegistrationBean; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/config/InterceptorConfig.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/config/InterceptorConfig.java new file mode 100644 index 00000000..1d75ac6d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/config/InterceptorConfig.java @@ -0,0 +1,21 @@ +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 2024-07-02 + */ +@Configuration +public class InterceptorConfig implements WebMvcConfigurer { + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(new AuthenticationInterceptor()).addPathPatterns("/admin/**"); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/config/MultiDataSourceConfig.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/config/MultiDataSourceConfig.java new file mode 100644 index 00000000..bb09bf79 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/config/MultiDataSourceConfig.java @@ -0,0 +1,77 @@ +package com.orangeforms.webadmin.config; + +import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder; +import com.orangeforms.common.core.config.BaseMultiDataSourceConfig; +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 2024-07-02 + */ +@Configuration +@EnableTransactionManagement +@MapperScan(value = {"com.orangeforms.webadmin.*.dao", "com.orangeforms.common.*.dao"}) +public class MultiDataSourceConfig extends BaseMultiDataSourceConfig { + + @Bean(initMethod = "init", destroyMethod = "close") + @ConfigurationProperties(prefix = "spring.datasource.druid.main") + public DataSource mainDataSource() { + return super.applyCommonProps(DruidDataSourceBuilder.create().build()); + } + + /** + * 默认生成的用于保存操作日志的数据源,可根据需求修改。 + * 这里我们还是非常推荐给操作日志使用独立的数据源,这样便于今后的数据迁移。 + */ + @Bean(initMethod = "init", destroyMethod = "close") + @ConfigurationProperties(prefix = "spring.datasource.druid.operation-log") + public DataSource operationLogDataSource() { + return super.applyCommonProps(DruidDataSourceBuilder.create().build()); + } + + /** + * 默认生成的用于全局编码字典的数据源,可根据需求修改。 + */ + @Bean(initMethod = "init", destroyMethod = "close") + @ConfigurationProperties(prefix = "spring.datasource.druid.global-dict") + public DataSource globalDictDataSource() { + return super.applyCommonProps(DruidDataSourceBuilder.create().build()); + } + + /** + * 默认生成的用于在线表单内部表的数据源,可根据需求修改。 + * 这里我们还是非常推荐使用独立数据源,这样便于今后的服务拆分。 + */ + @Bean(initMethod = "init", destroyMethod = "close") + @ConfigurationProperties(prefix = "spring.datasource.druid.common-flow-online") + public DataSource commonFlowAndOnlineDataSource() { + return super.applyCommonProps(DruidDataSourceBuilder.create().build()); + } + + @Bean + @Primary + public DynamicDataSource dataSource() { + Map targetDataSources = new HashMap<>(1); + targetDataSources.put(DataSourceType.MAIN, mainDataSource()); + targetDataSources.put(DataSourceType.OPERATION_LOG, operationLogDataSource()); + targetDataSources.put(DataSourceType.GLOBAL_DICT, globalDictDataSource()); + targetDataSources.put(DataSourceType.COMMON_FLOW_AND_ONLINE, commonFlowAndOnlineDataSource()); + // 如果当前工程支持在线表单,这里请务必保证upms数据表所在数据库为缺省数据源。 + DynamicDataSource dynamicDataSource = new DynamicDataSource(); + dynamicDataSource.setTargetDataSources(targetDataSources); + dynamicDataSource.setDefaultTargetDataSource(mainDataSource()); + return dynamicDataSource; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/config/ThirdPartyAuthConfig.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/config/ThirdPartyAuthConfig.java new file mode 100644 index 00000000..e827057a --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/config/ThirdPartyAuthConfig.java @@ -0,0 +1,66 @@ +package com.orangeforms.webadmin.config; + +import cn.hutool.core.collection.CollUtil; +import lombok.Data; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 第三方应用鉴权配置。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Configuration +@ConfigurationProperties(prefix = "third-party") +public class ThirdPartyAuthConfig implements InitializingBean { + + private List auth; + + private Map applicationMap; + + @Override + public void afterPropertiesSet() throws Exception { + if (CollUtil.isEmpty(auth)) { + applicationMap = new HashMap<>(1); + } else { + applicationMap = auth.stream().collect(Collectors.toMap(AuthProperties::getAppCode, c -> c)); + } + } + + @Data + public static class AuthProperties { + /** + * 应用Id。 + */ + private String appCode; + /** + * 身份验证相关url的base地址。 + */ + private String baseUrl; + /** + * 是否为橙单框架。 + */ + private Boolean orangeFramework = true; + /** + * token的Http Request Header的key + */ + private String tokenHeaderKey; + /** + * 数据权限和用户操作权限缓存过期时间,单位秒。 + */ + private Integer permExpiredSeconds = 86400; + /** + * 用户Token缓存过期时间,单位秒。 + * 如果为0,则每次都要去第三方服务进行验证。 + */ + private Integer tokenExpiredSeconds = 0; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/interceptor/AuthenticationInterceptor.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/interceptor/AuthenticationInterceptor.java new file mode 100644 index 00000000..f2329ff6 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/interceptor/AuthenticationInterceptor.java @@ -0,0 +1,281 @@ +package com.orangeforms.webadmin.interceptor; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.text.StrFormatter; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpResponse; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.orangeforms.common.core.cache.CacheConfig; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.constant.DataPermRuleType; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.exception.MyRuntimeException; +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.RedisKeyUtil; +import com.orangeforms.common.satoken.util.SaTokenUtil; +import com.orangeforms.webadmin.config.ThirdPartyAuthConfig; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.redisson.api.RBucket; +import org.redisson.api.RSet; +import org.redisson.api.RedissonClient; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.util.Assert; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +/** + * 登录用户Token验证、生成和权限验证的拦截器。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class AuthenticationInterceptor implements HandlerInterceptor { + + private final ThirdPartyAuthConfig thirdPartyAuthConfig = + ApplicationContextHolder.getBean("thirdPartyAuthConfig"); + + private final RedissonClient redissonClient = ApplicationContextHolder.getBean(RedissonClient.class); + private final CacheManager cacheManager = ApplicationContextHolder.getBean("caffeineCacheManager"); + + private final SaTokenUtil saTokenUtil = + ApplicationContextHolder.getBean("saTokenUtil"); + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) + throws Exception { + String appCode = this.getAppCodeFromRequest(request); + if (StrUtil.isNotBlank(appCode)) { + return this.handleThirdPartyRequest(appCode, request); + } + ResponseResult result = saTokenUtil.handleAuthIntercept(request, handler); + if (!result.isSuccess()) { + ResponseResult.output(result.getHttpStatus(), result); + return false; + } + 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 String getTokenFromRequest(HttpServletRequest request, String appCode) { + ThirdPartyAuthConfig.AuthProperties prop = thirdPartyAuthConfig.getApplicationMap().get(appCode); + String token = request.getHeader(prop.getTokenHeaderKey()); + if (StrUtil.isBlank(token)) { + token = request.getParameter(prop.getTokenHeaderKey()); + } + if (StrUtil.isBlank(token)) { + token = request.getHeader(ApplicationConstant.HTTP_HEADER_INTERNAL_TOKEN); + } + return token; + } + + private String getAppCodeFromRequest(HttpServletRequest request) { + String appCode = request.getHeader("AppCode"); + if (StrUtil.isBlank(appCode)) { + appCode = request.getParameter("AppCode"); + } + return appCode; + } + + private boolean handleThirdPartyRequest(String appCode, HttpServletRequest request) throws IOException { + String token = this.getTokenFromRequest(request, appCode); + ThirdPartyAuthConfig.AuthProperties authProps = thirdPartyAuthConfig.getApplicationMap().get(appCode); + if (authProps == null) { + String msg = StrFormatter.format("请求的 appCode[{}] 信息,在当前服务中尚未配置!", appCode); + ResponseResult.output(ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, msg)); + return false; + } + ResponseResult result = this.getAndCacheThirdPartyTokenData(authProps, token); + if (!result.isSuccess()) { + ResponseResult.output(result.getHttpStatus(), + ResponseResult.error(ErrorCodeEnum.UNAUTHORIZED_LOGIN, result.getErrorMessage())); + return false; + } + TokenData tokenData = result.getData(); + tokenData.setAppCode(appCode); + tokenData.setSessionId(this.prependAppCode(authProps.getAppCode(), tokenData.getSessionId())); + TokenData.addToRequest(tokenData); + String url = request.getRequestURI(); + if (Boolean.FALSE.equals(tokenData.getIsAdmin()) + && !this.hasThirdPartyPermission(authProps, tokenData, url)) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, ResponseResult.error(ErrorCodeEnum.NO_OPERATION_PERMISSION)); + return false; + } + return true; + } + + private ResponseResult getAndCacheThirdPartyTokenData( + ThirdPartyAuthConfig.AuthProperties authProps, String token) { + if (authProps.getTokenExpiredSeconds() == 0) { + return this.getThirdPartyTokenData(authProps, token); + } + String tokeKey = this.prependAppCode(authProps.getAppCode(), RedisKeyUtil.makeSessionIdKey(token)); + RBucket sessionData = redissonClient.getBucket(tokeKey); + if (sessionData.isExists()) { + return ResponseResult.success(JSON.parseObject(sessionData.get(), TokenData.class)); + } + ResponseResult responseResult = this.getThirdPartyTokenData(authProps, token); + if (responseResult.isSuccess()) { + sessionData.set(JSON.toJSONString(responseResult.getData()), authProps.getTokenExpiredSeconds(), TimeUnit.SECONDS); + } + return responseResult; + } + + private String prependAppCode(String appCode, String key) { + return appCode.toUpperCase() + ":" + key; + } + + private ResponseResult getThirdPartyTokenData( + ThirdPartyAuthConfig.AuthProperties authProps, String token) { + try { + String resultData = this.invokeThirdPartyUrl(authProps.getBaseUrl() + "/getTokenData", token); + return JSON.parseObject(resultData, new TypeReference>() {}); + } catch (MyRuntimeException ex) { + return ResponseResult.error(ErrorCodeEnum.FAILED_TO_INVOKE_THIRDPARTY_URL, ex.getMessage()); + } + } + + private ResponseResult getThirdPartyPermData( + ThirdPartyAuthConfig.AuthProperties authProps, String token) { + try { + String resultData = this.invokeThirdPartyUrl(authProps.getBaseUrl() + "/getPermData", token); + return JSON.parseObject(resultData, new TypeReference>() {}); + } catch (MyRuntimeException ex) { + return ResponseResult.error(ErrorCodeEnum.FAILED_TO_INVOKE_THIRDPARTY_URL, ex.getMessage()); + } + } + + private String invokeThirdPartyUrl(String url, String token) { + Map headerMap = new HashMap<>(1); + headerMap.put("Authorization", token); + StringBuilder fullUrl = new StringBuilder(128); + fullUrl.append(url).append("?token=").append(token); + HttpResponse httpResponse = HttpUtil.createGet(fullUrl.toString()).addHeaders(headerMap).execute(); + if (!httpResponse.isOk()) { + String msg = StrFormatter.format( + "Failed to call [{}] with ERROR HTTP Status [{}] and [{}].", + url, httpResponse.getStatus(), httpResponse.body()); + log.error(msg); + throw new MyRuntimeException(msg); + } + return httpResponse.body(); + } + + @SuppressWarnings("unchecked") + private boolean hasThirdPartyPermission( + ThirdPartyAuthConfig.AuthProperties authProps, TokenData tokenData, String url) { + // 为了提升效率,先检索Caffeine的一级缓存,如果不存在,再检索Redis的二级缓存,并将结果存入一级缓存。 + String permKey = RedisKeyUtil.makeSessionPermIdKey(tokenData.getSessionId()); + Cache cache = cacheManager.getCache(CacheConfig.CacheEnum.USER_PERMISSION_CACHE.name()); + Assert.notNull(cache, "Cache USER_PERMISSION_CACHE can't be NULL"); + Cache.ValueWrapper wrapper = cache.get(permKey); + if (wrapper != null) { + Object cachedData = wrapper.get(); + if (cachedData != null) { + return ((Set) cachedData).contains(url); + } + } + Set localPermSet; + RSet permSet = redissonClient.getSet(permKey); + if (permSet.isExists()) { + localPermSet = permSet.readAll(); + cache.put(permKey, localPermSet); + return localPermSet.contains(url); + } + ResponseResult responseResult = this.getThirdPartyPermData(authProps, tokenData.getToken()); + this.cacheThirdPartyDataPermData(authProps, tokenData, responseResult.getData().getDataPerms()); + if (CollUtil.isEmpty(responseResult.getData().urlPerms)) { + return false; + } + permSet.addAll(responseResult.getData().urlPerms); + permSet.expire(authProps.getPermExpiredSeconds(), TimeUnit.SECONDS); + localPermSet = new HashSet<>(responseResult.getData().urlPerms); + cache.put(permKey, localPermSet); + return localPermSet.contains(url); + } + + private void cacheThirdPartyDataPermData( + ThirdPartyAuthConfig.AuthProperties authProps, TokenData tokenData, List dataPerms) { + if (CollUtil.isEmpty(dataPerms)) { + return; + } + Map> dataPermMap = + dataPerms.stream().collect(Collectors.groupingBy(ThirdPartyAppDataPermData::getRuleType)); + Map> normalizedDataPermMap = new HashMap<>(dataPermMap.size()); + for (Map.Entry> entry : dataPermMap.entrySet()) { + List ruleTypeDataPermDataList; + if (entry.getKey().equals(DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT)) { + ruleTypeDataPermDataList = + normalizedDataPermMap.computeIfAbsent(DataPermRuleType.TYPE_CUSTOM_DEPT_LIST, k -> new LinkedList<>()); + } else { + ruleTypeDataPermDataList = + normalizedDataPermMap.computeIfAbsent(entry.getKey(), k -> new LinkedList<>()); + } + ruleTypeDataPermDataList.addAll(entry.getValue()); + } + Map resultDataPermMap = new HashMap<>(normalizedDataPermMap.size()); + for (Map.Entry> entry : normalizedDataPermMap.entrySet()) { + if (entry.getKey().equals(DataPermRuleType.TYPE_CUSTOM_DEPT_LIST)) { + String deptIds = entry.getValue().stream() + .map(ThirdPartyAppDataPermData::getDeptIds).collect(Collectors.joining(",")); + resultDataPermMap.put(entry.getKey(), deptIds); + } else { + resultDataPermMap.put(entry.getKey(), "null"); + } + } + Map> menuDataPermMap = new HashMap<>(1); + menuDataPermMap.put(ApplicationConstant.DATA_PERM_ALL_MENU_ID, resultDataPermMap); + String dataPermSessionKey = RedisKeyUtil.makeSessionDataPermIdKey(tokenData.getSessionId()); + RBucket bucket = redissonClient.getBucket(dataPermSessionKey); + bucket.set(JSON.toJSONString(menuDataPermMap), authProps.getPermExpiredSeconds(), TimeUnit.SECONDS); + } + + @Data + public static class ThirdPartyAppPermData { + /** + * 当前用户会话可访问的url接口地址列表。 + */ + private List urlPerms; + /** + * 当前用户会话的数据权限列表。 + */ + private List dataPerms; + } + + @Data + public static class ThirdPartyAppDataPermData { + /** + * 数据权限的规则类型。需要按照橙单的约定返回。具体值可参考DataPermRuleType常量类。 + */ + private Integer ruleType; + /** + * 部门Id集合,多个部门Id之间逗号分隔。 + * 注意:仅当ruleType为3、4、5时需要包含该字段值。 + */ + private String deptIds; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/bo/SysMenuExtraData.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/bo/SysMenuExtraData.java new file mode 100644 index 00000000..dbca8a5b --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/bo/SysMenuExtraData.java @@ -0,0 +1,55 @@ +package com.orangeforms.webadmin.upms.bo; + +import lombok.Data; + +import java.util.List; + +/** + * 菜单扩展数据对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class SysMenuExtraData { + + /** + * 路由名称。 + */ + private String formRouterName; + + /** + * 在线表单。 + */ + private Long onlineFormId; + + /** + * 报表页面。 + */ + private Long reportPageId; + + /** + * 流程。 + */ + private Long onlineFlowEntryId; + + /** + * 目标url。 + */ + private String targetUrl; + + /** + * 绑定类型。 + */ + private Integer bindType; + + /** + * 前端使用的菜单编码。仅当选择satoken权限框架时使用。 + */ + private String menuCode; + + /** + * 菜单关联的后台使用的权限字列表。仅当选择satoken权限框架时使用。 + */ + private List permCodeList; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/bo/SysMenuPerm.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/bo/SysMenuPerm.java new file mode 100644 index 00000000..8c429d37 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/bo/SysMenuPerm.java @@ -0,0 +1,66 @@ +package com.orangeforms.webadmin.upms.bo; + +import lombok.Data; + +import java.util.HashSet; +import java.util.Set; + +/** + * 菜单相关的业务对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class SysMenuPerm { + + /** + * 菜单Id。 + */ + private Long menuId; + + /** + * 父菜单Id,目录菜单的父菜单为null + */ + private Long parentId; + + /** + * 菜单显示名称。 + */ + private String menuName; + + /** + * 菜单类型 (0: 目录 1: 菜单 2: 按钮 3: UI片段)。 + */ + private Integer menuType; + + /** + * 在线表单主键Id,仅用于在线表单绑定的菜单。 + */ + private Long onlineFormId; + + /** + * 在线表单菜单的权限控制类型,具体值可参考SysOnlineMenuPermType常量对象。 + */ + private Integer onlineMenuPermType; + + /** + * 统计页面主键Id,仅用于统计页面绑定的菜单。 + */ + private Long reportPageId; + + /** + * 仅用于在线表单的流程Id。 + */ + private Long onlineFlowEntryId; + + /** + * 关联权限URL集合。 + */ + Set permUrlSet = new HashSet<>(); + + /** + * 关联的某一个url。 + */ + String url; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/GlobalDictController.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/GlobalDictController.java new file mode 100644 index 00000000..df90d312 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/GlobalDictController.java @@ -0,0 +1,340 @@ +package com.orangeforms.webadmin.upms.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.MyOrderParam; +import com.orangeforms.common.core.object.MyPageData; +import com.orangeforms.common.core.object.MyPageParam; +import com.orangeforms.common.core.object.ResponseResult; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.dict.dto.GlobalDictDto; +import com.orangeforms.common.dict.dto.GlobalDictItemDto; +import com.orangeforms.common.dict.model.GlobalDict; +import com.orangeforms.common.dict.model.GlobalDictItem; +import com.orangeforms.common.dict.service.GlobalDictItemService; +import com.orangeforms.common.dict.service.GlobalDictService; +import com.orangeforms.common.dict.util.GlobalDictOperationHelper; +import com.orangeforms.common.dict.vo.GlobalDictVo; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.github.pagehelper.Page; +import com.github.pagehelper.page.PageMethod; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 全局通用字典操作接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "全局字典管理接口") +@Slf4j +@RestController +@RequestMapping("/admin/upms/globalDict") +public class GlobalDictController { + + @Autowired + private GlobalDictService globalDictService; + @Autowired + private GlobalDictItemService globalDictItemService; + @Autowired + private GlobalDictOperationHelper globalDictOperationHelper; + + /** + * 新增全局字典接口。 + * + * @param globalDictDto 新增字典对象。 + * @return 保存后的字典对象。 + */ + @ApiOperationSupport(ignoreParameters = {"globalDictDto.dictId"}) + @SaCheckPermission("globalDict.update") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody GlobalDictDto globalDictDto) { + String errorMessage = MyCommonUtil.getModelValidationError(globalDictDto); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + // 这里必须手动校验字典编码是否存在,因为我们缺省的实现是逻辑删除,所以字典编码字段没有设置为唯一索引。 + if (globalDictService.existDictCode(globalDictDto.getDictCode())) { + errorMessage = "数据验证失败,字典编码已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + GlobalDict globalDict = MyModelUtil.copyTo(globalDictDto, GlobalDict.class); + globalDictService.saveNew(globalDict); + return ResponseResult.success(globalDict.getDictId()); + } + + /** + * 更新全局字典操作。 + * + * @param globalDictDto 更新全局字典对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("globalDict.update") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody GlobalDictDto globalDictDto) { + String errorMessage = MyCommonUtil.getModelValidationError(globalDictDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + GlobalDict originalGlobalDict = globalDictService.getById(globalDictDto.getDictId()); + if (originalGlobalDict == null) { + errorMessage = "数据验证失败,当前全局字典并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + GlobalDict globalDict = MyModelUtil.copyTo(globalDictDto, GlobalDict.class); + if (ObjectUtil.notEqual(globalDict.getDictCode(), originalGlobalDict.getDictCode()) + && globalDictService.existDictCode(globalDict.getDictCode())) { + errorMessage = "数据验证失败,字典编码已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!globalDictService.update(globalDict, originalGlobalDict)) { + errorMessage = "更新失败,数据不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 删除指定的全局字典。 + * + * @param dictId 指定全局字典主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("globalDict.update") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody(required = true) Long dictId) { + if (!globalDictService.remove(dictId)) { + String errorMessage = "数据操作失败,全局字典Id不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 查看全局字典列表。 + * + * @param globalDictDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含角色列表。 + */ + @SaCheckPermission("globalDict.view") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody GlobalDictDto globalDictDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + GlobalDict filter = MyModelUtil.copyTo(globalDictDtoFilter, GlobalDict.class); + List globalDictList = + globalDictService.getGlobalDictList(filter, MyOrderParam.buildOrderBy(orderParam, GlobalDict.class)); + List globalDictVoList = + MyModelUtil.copyCollectionTo(globalDictList, GlobalDictVo.class); + long totalCount = 0L; + if (globalDictList instanceof Page) { + totalCount = ((Page) globalDictList).getTotal(); + } + return ResponseResult.success(MyPageUtil.makeResponseData(globalDictVoList, totalCount)); + } + + /** + * 新增全局字典项目接口。 + * + * @param globalDictItemDto 新增字典项目对象。 + * @return 保存后的字典对象。 + */ + @SaCheckPermission("globalDict.update") + @ApiOperationSupport(ignoreParameters = {"globalDictItemDto.id"}) + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/addItem") + public ResponseResult addItem(@MyRequestBody GlobalDictItemDto globalDictItemDto) { + String errorMessage = MyCommonUtil.getModelValidationError(globalDictItemDto); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!globalDictService.existDictCode(globalDictItemDto.getDictCode())) { + errorMessage = "数据验证失败,字典编码不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (globalDictItemService.existDictCodeAndItemId( + globalDictItemDto.getDictCode(), globalDictItemDto.getItemId())) { + errorMessage = "数据验证失败,该字典编码的项目Id已存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + GlobalDictItem globalDictItem = MyModelUtil.copyTo(globalDictItemDto, GlobalDictItem.class); + globalDictItemService.saveNew(globalDictItem); + return ResponseResult.success(globalDictItem.getId()); + } + + /** + * 更新全局字典项目。 + * + * @param globalDictItemDto 更新全局字典项目对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("globalDict.update") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/updateItem") + public ResponseResult updateItem(@MyRequestBody GlobalDictItemDto globalDictItemDto) { + String errorMessage = MyCommonUtil.getModelValidationError(globalDictItemDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + GlobalDictItem originalGlobalDictItem = globalDictItemService.getById(globalDictItemDto.getId()); + if (originalGlobalDictItem == null) { + errorMessage = "数据验证失败,当前全局字典项目并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + GlobalDictItem globalDictItem = MyModelUtil.copyTo(globalDictItemDto, GlobalDictItem.class); + if (ObjectUtil.notEqual(globalDictItem.getDictCode(), originalGlobalDictItem.getDictCode())) { + errorMessage = "数据验证失败,字典项目的字典编码不能修改!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (ObjectUtil.notEqual(globalDictItem.getItemId(), originalGlobalDictItem.getItemId()) + && globalDictItemService.existDictCodeAndItemId(globalDictItem.getDictCode(), globalDictItem.getItemId())) { + errorMessage = "数据验证失败,该字典编码已经包含了该项目Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!globalDictItemService.update(globalDictItem, originalGlobalDictItem)) { + errorMessage = "更新失败,数据不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 更新全局字典项目的状态。 + * + * @param id 更新全局字典项目主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("globalDict.update") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/updateItemStatus") + public ResponseResult updateItemStatus( + @MyRequestBody(required = true) Long id, @MyRequestBody(required = true) Integer status) { + String errorMessage; + GlobalDictItem dictItem = globalDictItemService.getById(id); + if (dictItem == null) { + errorMessage = "数据操作失败,全局字典项目Id不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (ObjectUtil.notEqual(dictItem.getStatus(), status)) { + globalDictItemService.updateStatus(dictItem, status); + } + return ResponseResult.success(); + } + + /** + * 删除指定编码的全局字典项目。 + * + * @param id 主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("globalDict.update") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/deleteItem") + public ResponseResult deleteItem(@MyRequestBody(required = true) Long id) { + String errorMessage; + GlobalDictItem dictItem = globalDictItemService.getById(id); + if (dictItem == null) { + errorMessage = "数据操作失败,全局字典项目Id不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!globalDictItemService.remove(dictItem)) { + errorMessage = "数据操作失败,全局字典项目Id不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 将当前字典表的数据重新加载到缓存中。 + * 由于缓存的数据更新,在add/update/delete等接口均有同步处理。因此该接口仅当同步过程中出现问题时, + * 可手工调用,或者每天晚上定时同步一次。 + */ + @SaCheckPermission("globalDict.view") + @OperationLog(type = SysOperationLogType.RELOAD_CACHE) + @GetMapping("/reloadCachedData") + public ResponseResult reloadCachedData(@RequestParam String dictCode) { + globalDictService.reloadCachedData(dictCode); + return ResponseResult.success(true); + } + + /** + * 获取指定字典编码的全局字典项目。字典的键值为[itemId, itemName]。 + * NOTE: 白名单接口。 + * + * @param dictCode 字典编码。 + * @param itemIdType 字典项目的ItemId值转换到的目标类型。可能值为Integer或Long。 + * @return 应答结果对象。 + */ + @GetMapping("/listDict") + public ResponseResult>> listDict( + @RequestParam String dictCode, @RequestParam(required = false) String itemIdType) { + List resultList = + globalDictService.getGlobalDictItemListFromCache(dictCode, null); + resultList = resultList.stream() + .sorted(Comparator.comparing(GlobalDictItem::getStatus)) + .sorted(Comparator.comparing(GlobalDictItem::getShowOrder)) + .collect(Collectors.toList()); + return ResponseResult.success(globalDictOperationHelper.toDictDataList(resultList, itemIdType)); + } + + /** + * 根据字典Id集合,获取查询后的字典数据。 + * NOTE: 白名单接口。 + * + * @param dictCode 字典编码。 + * @param itemIds 字典项目Id集合。 + * @param itemIdType 字典项目的ItemId值转换到的目标类型。可能值为Integer或Long。 + * @return 应答结果对象,包含字典形式的数据集合。 + */ + @GetMapping("/listDictByIds") + public ResponseResult>> listDictByIds( + @RequestParam String dictCode, + @RequestParam List itemIds, + @RequestParam(required = false) String itemIdType) { + List resultList = + globalDictService.getGlobalDictItemListFromCache(dictCode, new HashSet<>(itemIds)); + return ResponseResult.success(globalDictOperationHelper.toDictDataList(resultList, itemIdType)); + } + + /** + * 白名单接口,登录用户均可访问。以字典形式返回全部字典数据集合。 + * fullResultList中的字典列表全部取自于数据库,而cachedResultList全部取自于缓存,前端负责比对。 + * + * @return 应答结果对象,包含字典形式的数据集合。 + */ + @GetMapping("/listAll") + public ResponseResult listAll(@RequestParam String dictCode) { + List fullResultList = + globalDictItemService.getGlobalDictItemListByDictCode(dictCode); + List cachedList = + globalDictService.getGlobalDictItemListFromCache(dictCode, null); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("fullResultList", globalDictOperationHelper.toDictDataList2(fullResultList)); + jsonObject.put("cachedResultList", globalDictOperationHelper.toDictDataList2(cachedList)); + return ResponseResult.success(jsonObject); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/LoginController.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/LoginController.java new file mode 100644 index 00000000..656c9a38 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/LoginController.java @@ -0,0 +1,475 @@ +package com.orangeforms.webadmin.upms.controller; + +import cn.dev33.satoken.annotation.SaIgnore; +import cn.dev33.satoken.session.SaSession; +import cn.dev33.satoken.stp.StpUtil; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.JSONArray; +import com.github.xiaoymin.knife4j.annotations.ApiSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import com.orangeforms.webadmin.config.ApplicationConfig; +import com.orangeforms.webadmin.upms.bo.SysMenuExtraData; +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.flow.online.service.FlowOnlineOperationService; +import com.orangeforms.common.online.service.OnlineOperationService; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.annotation.DisableDataFilter; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.*; +import com.orangeforms.common.core.upload.*; +import com.orangeforms.common.redis.cache.SessionCacheHelper; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.satoken.util.SaTokenUtil; +import org.redisson.api.RSet; +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 jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +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 2024-07-02 + */ +@ApiSupport(order = 1) +@Tag(name = "用户登录接口") +@DisableDataFilter +@Slf4j +@RestController +@RequestMapping("/admin/upms/login") +public class LoginController { + + @Autowired + private SysUserService sysUserService; + @Autowired + private SysDeptService sysDeptService; + @Autowired + private SysMenuService sysMenuService; + @Autowired + private SysPostService sysPostService; + @Autowired + private SysRoleService sysRoleService; + @Autowired + private SysDataPermService sysDataPermService; + @Autowired + private SysPermWhitelistService sysPermWhitelistService; + @Autowired + private OnlineOperationService onlineOperationService; + @Autowired + private FlowOnlineOperationService flowOnlineOperationService; + @Autowired + private ApplicationConfig appConfig; + @Autowired + private RedissonClient redissonClient; + @Autowired + private SessionCacheHelper cacheHelper; + @Autowired + private PasswordEncoder passwordEncoder; + @Autowired + private UpDownloaderFactory upDownloaderFactory; + @Autowired + private SaTokenUtil saTokenUtil; + + private static final String IS_ADMIN = "isAdmin"; + private static final String SHOW_NAME_FIELD = "showName"; + private static final String SHOW_ORDER_FIELD = "showOrder"; + private static final String HEAD_IMAGE_URL_FIELD = "headImageUrl"; + + /** + * 登录接口。 + * + * @param loginName 登录名。 + * @param password 密码。 + * @return 应答结果对象,其中包括Token数据,以及菜单列表。 + */ + @Parameter(name = "loginName", example = "admin") + @Parameter(name = "password", example = "IP3ccke3GhH45iGHB5qP9p7iZw6xUyj28Ju10rnBiPKOI35sc%2BjI7%2FdsjOkHWMfUwGYGfz8ik31HC2Ruk%2Fhkd9f6RPULTHj7VpFdNdde2P9M4mQQnFBAiPM7VT9iW3RyCtPlJexQ3nAiA09OqG%2F0sIf1kcyveSrulxembARDbDo%3D") + @SaIgnore + @OperationLog(type = SysOperationLogType.LOGIN, saveResponse = false) + @PostMapping("/doLogin") + public ResponseResult doLogin( + @MyRequestBody String loginName, + @MyRequestBody String password) throws UnsupportedEncodingException { + if (MyCommonUtil.existBlankArgument(loginName, password)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + ResponseResult verifyResult = this.verifyAndHandleLoginUser(loginName, password); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + JSONObject jsonData = this.buildLoginDataAndLogin(verifyResult.getData()); + return ResponseResult.success(jsonData); + } + + /** + * 登出操作。同时将Session相关的信息从缓存中删除。 + * + * @return 应答结果对象。 + */ + @OperationLog(type = SysOperationLogType.LOGOUT) + @PostMapping("/doLogout") + public ResponseResult doLogout() { + String sessionId = TokenData.takeFromRequest().getSessionId(); + redissonClient.getBucket(TokenData.takeFromRequest().getMySessionId()).deleteAsync(); + redissonClient.getBucket(RedisKeyUtil.makeSessionPermCodeKey(sessionId)).deleteAsync(); + redissonClient.getBucket(RedisKeyUtil.makeSessionPermIdKey(sessionId)).deleteAsync(); + sysDataPermService.removeDataPermCache(sessionId); + cacheHelper.removeAllSessionCache(sessionId); + StpUtil.logout(); + return ResponseResult.success(); + } + + /** + * 在登录之后,通过token再次获取登录信息。 + * 用于在当前浏览器登录系统后,在新tab页中可以免密登录。 + * + * @return 应答结果对象,其中包括JWT的Token数据,以及菜单列表。 + */ + @GetMapping("/getLoginInfo") + public ResponseResult getLoginInfo() { + TokenData tokenData = TokenData.takeFromRequest(); + JSONObject jsonData = new JSONObject(); + jsonData.put(SHOW_NAME_FIELD, tokenData.getShowName()); + jsonData.put(IS_ADMIN, tokenData.getIsAdmin()); + if (StrUtil.isNotBlank(tokenData.getHeadImageUrl())) { + jsonData.put(HEAD_IMAGE_URL_FIELD, tokenData.getHeadImageUrl()); + } + Collection allMenuList; + if (BooleanUtil.isTrue(tokenData.getIsAdmin())) { + allMenuList = sysMenuService.getAllListByOrder(SHOW_ORDER_FIELD); + } else { + allMenuList = sysMenuService.getMenuListByRoleIds(tokenData.getRoleIds()); + } + List menuCodeList = new LinkedList<>(); + OnlinePermData onlinePermData = this.getOnlineMenuPermData(allMenuList); + CollUtil.addAll(menuCodeList, onlinePermData.permCodeSet); + OnlinePermData onlineFlowPermData = this.getFlowOnlineMenuPermData(allMenuList); + CollUtil.addAll(menuCodeList, onlineFlowPermData.permCodeSet); + allMenuList.stream().filter(m -> m.getExtraData() != null) + .forEach(m -> m.setExtraObject(JSON.parseObject(m.getExtraData(), SysMenuExtraData.class))); + this.appendResponseMenuAndPermCodeData(jsonData, allMenuList, menuCodeList); + return ResponseResult.success(jsonData); + } + + /** + * 返回所有可用的权限字列表。 + * + * @return 整个系统所有可用的权限字列表。 + */ + @GetMapping("/getAllPermCodes") + public ResponseResult> getAllPermCodes() { + List permCodes = saTokenUtil.getAllPermCodes(); + return ResponseResult.success(permCodes); + } + + /** + * 用户修改自己的密码。 + * + * @param oldPass 原有密码。 + * @param newPass 新密码。 + * @return 应答结果对象。 + */ + @PostMapping("/changePassword") + public ResponseResult changePassword( + @MyRequestBody String oldPass, @MyRequestBody String newPass) throws UnsupportedEncodingException { + 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 IOException { + UploadStoreInfo storeInfo = MyModelUtil.getUploadStoreInfo(SysUser.class, HEAD_IMAGE_URL_FIELD); + BaseUpDownloader upDownloader = upDownloaderFactory.get(storeInfo.getStoreType()); + UploadResponseInfo responseInfo = upDownloader.doUpload(null, + appConfig.getUploadFileBaseDir(), SysUser.class.getSimpleName(), HEAD_IMAGE_URL_FIELD, true, uploadFile); + if (BooleanUtil.isTrue(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 { + UploadStoreInfo storeInfo = MyModelUtil.getUploadStoreInfo(SysUser.class, HEAD_IMAGE_URL_FIELD); + BaseUpDownloader upDownloader = upDownloaderFactory.get(storeInfo.getStoreType()); + upDownloader.doDownload(appConfig.getUploadFileBaseDir(), + SysUser.class.getSimpleName(), HEAD_IMAGE_URL_FIELD, filename, true, response); + } catch (Exception e) { + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + log.error(e.getMessage(), e); + } + } + + private ResponseResult verifyAndHandleLoginUser( + String loginName, String password) throws UnsupportedEncodingException { + String 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); + } + if (BooleanUtil.isTrue(appConfig.getExcludeLogin())) { + String deviceType = MyCommonUtil.getDeviceTypeWithString(); + LoginUserInfo userInfo = BeanUtil.copyProperties(user, LoginUserInfo.class); + String loginId = SaTokenUtil.makeLoginId(userInfo); + StpUtil.kickout(loginId, deviceType); + } + return ResponseResult.success(user); + } + + private JSONObject buildLoginDataAndLogin(SysUser user) { + TokenData tokenData = this.loginAndCreateToken(user); + // 这里手动将TokenData存入request,便于OperationLogAspect统一处理操作日志。 + TokenData.addToRequest(tokenData); + JSONObject jsonData = this.createResponseData(user); + Collection allMenuList; + boolean isAdmin = user.getUserType() == SysUserType.TYPE_ADMIN; + if (isAdmin) { + allMenuList = sysMenuService.getAllListByOrder(SHOW_ORDER_FIELD); + } else { + allMenuList = sysMenuService.getMenuListByRoleIds(tokenData.getRoleIds()); + } + allMenuList.stream().filter(m -> m.getExtraData() != null) + .forEach(m -> m.setExtraObject(JSON.parseObject(m.getExtraData(), SysMenuExtraData.class))); + Collection permCodeList = new LinkedList<>(); + allMenuList.stream().filter(m -> m.getExtraObject() != null) + .forEach(m -> CollUtil.addAll(permCodeList, m.getExtraObject().getPermCodeList())); + Set permSet = new HashSet<>(); + if (!isAdmin) { + // 所有登录用户都有白名单接口的访问权限。 + CollUtil.addAll(permSet, sysPermWhitelistService.getWhitelistPermList()); + } + List menuCodeList = new LinkedList<>(); + OnlinePermData onlinePermData = this.getOnlineMenuPermData(allMenuList); + CollUtil.addAll(menuCodeList, onlinePermData.permCodeSet); + OnlinePermData onlineFlowPermData = this.getFlowOnlineMenuPermData(allMenuList); + CollUtil.addAll(menuCodeList, onlineFlowPermData.permCodeSet); + if (!isAdmin) { + permSet.addAll(onlinePermData.permUrlSet); + permSet.addAll(onlineFlowPermData.permUrlSet); + String sessionId = tokenData.getSessionId(); + // 缓存用户的权限资源,这里缓存的是基于URL验证的权限资源,比如在线表单、工作流和数据表中的白名单资源。 + this.putUserSysPermCache(sessionId, permSet); + // 缓存权限字字段,StpInterfaceImpl中会从缓存中读取,并交给satoken进行接口权限的验证。 + this.putUserSysPermCodeCache(sessionId, permCodeList); + sysDataPermService.putDataPermCache(sessionId, user.getUserId(), user.getDeptId()); + } + this.appendResponseMenuAndPermCodeData(jsonData, allMenuList, menuCodeList); + return jsonData; + } + + private TokenData loginAndCreateToken(SysUser user) { + String deviceType = MyCommonUtil.getDeviceTypeWithString(); + LoginUserInfo userInfo = BeanUtil.copyProperties(user, LoginUserInfo.class); + String loginId = SaTokenUtil.makeLoginId(userInfo); + StpUtil.login(loginId, deviceType); + SaSession session = StpUtil.getTokenSession(); + TokenData tokenData = this.buildTokenData(user, session.getId(), StpUtil.getLoginDevice()); + String mySessionId = RedisKeyUtil.getSessionIdPrefix(tokenData, user.getLoginName()) + MyCommonUtil.generateUuid(); + tokenData.setMySessionId(mySessionId); + tokenData.setToken(session.getToken()); + redissonClient.getBucket(mySessionId) + .set(JSON.toJSONString(tokenData), appConfig.getSessionExpiredSeconds(), TimeUnit.SECONDS); + session.set(TokenData.REQUEST_ATTRIBUTE_NAME, tokenData); + return tokenData; + } + + private JSONObject createResponseData(SysUser user) { + JSONObject jsonData = new JSONObject(); + jsonData.put(TokenData.REQUEST_ATTRIBUTE_NAME, StpUtil.getTokenValue()); + jsonData.put(SHOW_NAME_FIELD, user.getShowName()); + jsonData.put(IS_ADMIN, user.getUserType() == SysUserType.TYPE_ADMIN); + if (user.getDeptId() != null) { + SysDept dept = sysDeptService.getById(user.getDeptId()); + jsonData.put("deptName", dept.getDeptName()); + } + if (StrUtil.isNotBlank(user.getHeadImageUrl())) { + jsonData.put(HEAD_IMAGE_URL_FIELD, user.getHeadImageUrl()); + } + return jsonData; + } + + private void appendResponseMenuAndPermCodeData( + JSONObject responseData, Collection allMenuList, Collection menuCodeList) { + allMenuList.stream() + .filter(m -> m.getExtraObject() != null && StrUtil.isNotBlank(m.getExtraObject().getMenuCode())) + .forEach(m -> CollUtil.addAll(menuCodeList, m.getExtraObject().getMenuCode())); + List menuList = allMenuList.stream() + .filter(m -> m.getMenuType() <= SysMenuType.TYPE_MENU).collect(Collectors.toList()); + responseData.put("menuList", menuList); + responseData.put("permCodeList", menuCodeList); + } + + private TokenData buildTokenData(SysUser user, String sessionId, String deviceType) { + 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(user.getUserType().equals(SysUserType.TYPE_ADMIN)); + tokenData.setLoginIp(IpUtil.getRemoteIpAddress(ContextUtil.getHttpRequest())); + tokenData.setLoginTime(new Date()); + tokenData.setDeviceType(deviceType); + tokenData.setHeadImageUrl(user.getHeadImageUrl()); + List userPostList = sysPostService.getSysUserPostListByUserId(user.getUserId()); + if (CollUtil.isNotEmpty(userPostList)) { + Set deptPostIdSet = userPostList.stream().map(SysUserPost::getDeptPostId).collect(Collectors.toSet()); + tokenData.setDeptPostIds(StrUtil.join(",", deptPostIdSet)); + Set postIdSet = userPostList.stream().map(SysUserPost::getPostId).collect(Collectors.toSet()); + tokenData.setPostIds(StrUtil.join(",", postIdSet)); + } + List userRoleList = sysRoleService.getSysUserRoleListByUserId(user.getUserId()); + if (CollUtil.isNotEmpty(userRoleList)) { + Set userRoleIdSet = userRoleList.stream().map(SysUserRole::getRoleId).collect(Collectors.toSet()); + tokenData.setRoleIds(StrUtil.join(",", userRoleIdSet)); + } + return tokenData; + } + + private void putUserSysPermCache(String sessionId, Collection permUrlSet) { + if (CollUtil.isEmpty(permUrlSet)) { + return; + } + String sessionPermKey = RedisKeyUtil.makeSessionPermIdKey(sessionId); + RSet redisPermSet = redissonClient.getSet(sessionPermKey); + redisPermSet.addAll(permUrlSet); + redisPermSet.expire(appConfig.getSessionExpiredSeconds(), TimeUnit.SECONDS); + } + + private void putUserSysPermCodeCache(String sessionId, Collection permCodeSet) { + if (CollUtil.isEmpty(permCodeSet)) { + return; + } + String sessionPermCodeKey = RedisKeyUtil.makeSessionPermCodeKey(sessionId); + RSet redisPermSet = redissonClient.getSet(sessionPermCodeKey); + redisPermSet.addAll(permCodeSet); + redisPermSet.expire(appConfig.getSessionExpiredSeconds(), TimeUnit.SECONDS); + } + + private OnlinePermData getOnlineMenuPermData(Collection allMenuList) { + List onlineMenuList = allMenuList.stream() + .filter(m -> m.getOnlineFormId() != null && m.getMenuType().equals(SysMenuType.TYPE_BUTTON)) + .collect(Collectors.toList()); + if (CollUtil.isEmpty(onlineMenuList)) { + return new OnlinePermData(); + } + Set formIds = allMenuList.stream() + .filter(m -> m.getOnlineFormId() != null + && m.getOnlineFlowEntryId() == null + && m.getMenuType().equals(SysMenuType.TYPE_MENU)) + .map(SysMenu::getOnlineFormId) + .collect(Collectors.toSet()); + Set viewFormIds = onlineMenuList.stream() + .filter(m -> m.getOnlineMenuPermType() == SysOnlineMenuPermType.TYPE_VIEW) + .map(SysMenu::getOnlineFormId) + .collect(Collectors.toSet()); + Set editFormIds = onlineMenuList.stream() + .filter(m -> m.getOnlineMenuPermType() == SysOnlineMenuPermType.TYPE_EDIT) + .map(SysMenu::getOnlineFormId) + .collect(Collectors.toSet()); + Map permDataMap = + onlineOperationService.calculatePermData(formIds, viewFormIds, editFormIds); + OnlinePermData permData = BeanUtil.mapToBean(permDataMap, OnlinePermData.class, false, null); + permData.permUrlSet.addAll(permData.onlineWhitelistUrls); + return permData; + } + + private OnlinePermData getFlowOnlineMenuPermData(Collection allMenuList) { + List flowOnlineMenuList = allMenuList.stream() + .filter(m -> m.getOnlineFlowEntryId() != null).collect(Collectors.toList()); + Set entryIds = flowOnlineMenuList.stream() + .map(SysMenu::getOnlineFlowEntryId).collect(Collectors.toSet()); + List> flowPermDataList = flowOnlineOperationService.calculatePermData(entryIds); + List flowOnlinePermDataList = + MyModelUtil.mapToBeanList(flowPermDataList, OnlineFlowPermData.class); + OnlinePermData permData = new OnlinePermData(); + flowOnlinePermDataList.forEach(perm -> { + permData.permCodeSet.addAll(perm.getPermCodeList()); + permData.permUrlSet.addAll(perm.getPermList()); + }); + return permData; + } + + static class OnlinePermData { + public final Set permCodeSet = new HashSet<>(); + public final Set permUrlSet = new HashSet<>(); + public final List onlineWhitelistUrls = new LinkedList<>(); + } + + @Data + static class OnlineFlowPermData { + private List permCodeList; + private List permList; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/LoginUserController.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/LoginUserController.java new file mode 100644 index 00000000..6e57c15d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/LoginUserController.java @@ -0,0 +1,89 @@ +package com.orangeforms.webadmin.upms.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.dev33.satoken.stp.StpUtil; +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.v3.oas.annotations.tags.Tag; +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 2024-07-02 + */ +@Tag(name = "在线用户接口") +@Slf4j +@RestController +@RequestMapping("/admin/upms/loginUser") +public class LoginUserController { + + @Autowired + private RedissonClient redissonClient; + + /** + * 显示在线用户列表。 + * + * @param loginName 登录名过滤。 + * @param pageParam 分页参数。 + * @return 登录用户信息列表。 + */ + @SaCheckPermission("loginUser.view") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody String loginName, @MyRequestBody MyPageParam pageParam) { + int skipCount = (pageParam.getPageNum() - 1) * pageParam.getPageSize(); + String patternKey; + if (StrUtil.isBlank(loginName)) { + patternKey = RedisKeyUtil.getSessionIdPrefix() + "*"; + } else { + patternKey = RedisKeyUtil.getSessionIdPrefix(loginName) + "*"; + } + List loginUserInfoList = new LinkedList<>(); + Iterable 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 resultList = loginUserInfoList.subList(skipCount, toIndex); + return ResponseResult.success(new MyPageData<>(resultList, (long) loginUserInfoList.size())); + } + + /** + * 强制下线指定登录会话。 + * + * @param sessionId 待强制下线的SessionId。 + * @return 应答结果对象。 + */ + @SaCheckPermission("loginUser.delete") + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody String sessionId) { + RBucket sessionData = redissonClient.getBucket(sessionId); + TokenData tokenData = JSON.parseObject(sessionData.get(), TokenData.class); + StpUtil.kickoutByTokenValue(tokenData.getToken()); + sessionData.delete(); + return ResponseResult.success(); + } + + private LoginUserInfo buildTokenDataByRedisKey(String key) { + RBucket sessionData = redissonClient.getBucket(key); + TokenData tokenData = JSON.parseObject(sessionData.get(), TokenData.class); + LoginUserInfo userInfo = BeanUtil.copyProperties(tokenData, LoginUserInfo.class); + userInfo.setSessionId(tokenData.getMySessionId()); + return userInfo; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysDataPermController.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysDataPermController.java new file mode 100644 index 00000000..e389b0e7 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysDataPermController.java @@ -0,0 +1,337 @@ +package com.orangeforms.webadmin.upms.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import com.alibaba.fastjson.TypeReference; +import com.github.pagehelper.Page; +import com.github.pagehelper.page.PageMethod; +import lombok.extern.slf4j.Slf4j; +import com.orangeforms.webadmin.upms.dto.SysDataPermDto; +import com.orangeforms.webadmin.upms.dto.SysUserDto; +import com.orangeforms.webadmin.upms.vo.SysDataPermVo; +import com.orangeforms.webadmin.upms.vo.SysUserVo; +import com.orangeforms.webadmin.upms.model.SysDataPerm; +import com.orangeforms.webadmin.upms.model.SysUser; +import com.orangeforms.webadmin.upms.service.SysDataPermService; +import com.orangeforms.webadmin.upms.service.SysUserService; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.*; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 数据权限接口控制器对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "数据权限管理接口") +@Slf4j +@RestController +@RequestMapping("/admin/upms/sysDataPerm") +public class SysDataPermController { + + @Autowired + private SysDataPermService sysDataPermService; + @Autowired + private SysUserService sysUserService; + + /** + * 添加新数据权限操作。 + * + * @param sysDataPermDto 新增对象。 + * @param deptIdListString 数据权限关联的部门Id列表,多个之间逗号分隔。 + * @param menuIdListString 数据权限关联的菜单Id列表,多个之间逗号分隔。 + * @return 应答结果对象。包含新增数据权限对象的主键Id。 + */ + @ApiOperationSupport(ignoreParameters = { + "sysDataPermDto.dataPermId", + "sysDataPermDto.createTimeStart", + "sysDataPermDto.createTimeEnd", + "sysDataPermDto.searchString"}) + @SaCheckPermission("sysDataPerm.add") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add( + @MyRequestBody SysDataPermDto sysDataPermDto, + @MyRequestBody String deptIdListString, + @MyRequestBody String menuIdListString) { + 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, menuIdListString); + if (!result.isSuccess()) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage()); + } + Set menuIdSet = null; + if (result.getData() != null) { + menuIdSet = result.getData().getObject("menuIdSet", new TypeReference>(){}); + } + Set deptIdSet = null; + if (result.getData() != null) { + deptIdSet = result.getData().getObject("deptIdSet", new TypeReference>(){}); + } + sysDataPermService.saveNew(sysDataPerm, deptIdSet, menuIdSet); + return ResponseResult.success(sysDataPerm.getDataPermId()); + } + + /** + * 更新数据权限操作。 + * + * @param sysDataPermDto 更新的数据权限对象。 + * @param deptIdListString 数据权限关联的部门Id列表,多个之间逗号分隔。 + * @param menuIdListString 数据权限关联的菜单Id列表,多个之间逗号分隔。 + * @return 应答结果对象。 + */ + @ApiOperationSupport(ignoreParameters = { + "sysDataPermDto.createTimeStart", + "sysDataPermDto.createTimeEnd", + "sysDataPermDto.searchString"}) + @SaCheckPermission("sysDataPerm.update") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update( + @MyRequestBody SysDataPermDto sysDataPermDto, + @MyRequestBody String deptIdListString, + @MyRequestBody String menuIdListString) { + 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, menuIdListString); + if (!result.isSuccess()) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage()); + } + Set deptIdSet = null; + if (result.getData() != null) { + deptIdSet = result.getData().getObject("deptIdSet", new TypeReference>(){}); + } + Set menuIdSet = null; + if (result.getData() != null) { + menuIdSet = result.getData().getObject("menuIdSet", new TypeReference>(){}); + } + if (!sysDataPermService.update(sysDataPerm, originalSysDataPerm, deptIdSet, menuIdSet)) { + errorMessage = "更新失败,数据不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 删除数据权限操作。 + * + * @param dataPermId 待删除数据权限主键Id。 + * @return 应答数据结果。 + */ + @SaCheckPermission("sysDataPerm.delete") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult 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 应答结果对象。包含数据权限列表。 + */ + @SaCheckPermission("sysDataPerm.view") + @PostMapping("/list") + public ResponseResult> 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 dataPermList = sysDataPermService.getSysDataPermListWithRelation(filter, orderBy); + List dataPermVoList = MyModelUtil.copyCollectionTo(dataPermList, SysDataPermVo.class); + long totalCount = 0L; + if (dataPermList instanceof Page) { + totalCount = ((Page) dataPermList).getTotal(); + } + return ResponseResult.success(MyPageUtil.makeResponseData(dataPermVoList, totalCount)); + } + + /** + * 查看单条数据权限详情。 + * + * @param dataPermId 数据权限的主键Id。 + * @return 应答结果对象,包含数据权限的详情。 + */ + @SaCheckPermission("sysDataPerm.view") + @GetMapping("/view") + public ResponseResult 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); + } + + /** + * 拥有指定数据权限的用户列表。 + * + * @param dataPermId 数据权限Id。 + * @param sysUserDtoFilter 用户过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含用户列表数据。 + */ + @SaCheckPermission("sysDataPerm.view") + @PostMapping("/listDataPermUser") + public ResponseResult> listDataPermUser( + @MyRequestBody Long dataPermId, + @MyRequestBody SysUserDto sysUserDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + ResponseResult 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 userList = sysUserService.getSysUserListByDataPermId(dataPermId, filter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(userList, SysUserVo.class)); + } + + /** + * 获取不包含指定数据权限Id的用户列表。 + * 用户和数据权限是多对多关系,当前接口将返回没有赋值指定DataPermId的用户列表。可用于给数据权限添加新用户。 + * + * @param dataPermId 数据权限主键Id。 + * @param sysUserDtoFilter 用户数据的过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含用户列表数据。 + */ + @SaCheckPermission("sysDataPerm.update") + @PostMapping("/listNotInDataPermUser") + public ResponseResult> listNotInDataPermUser( + @MyRequestBody Long dataPermId, + @MyRequestBody SysUserDto sysUserDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + ResponseResult 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 userList = + sysUserService.getNotInSysUserListByDataPermId(dataPermId, filter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(userList, SysUserVo.class)); + } + + /** + * 为指定数据权限添加用户列表。该操作可同时给一批用户赋值数据权限,并在同一事务内完成。 + * + * @param dataPermId 数据权限主键Id。 + * @param userIdListString 逗号分隔的用户Id列表。 + * @return 应答结果对象。 + */ + @SaCheckPermission("sysDataPerm.update") + @OperationLog(type = SysOperationLogType.ADD_M2M) + @PostMapping("/addDataPermUser") + public ResponseResult addDataPermUser( + @MyRequestBody Long dataPermId, @MyRequestBody String userIdListString) { + if (MyCommonUtil.existBlankArgument(dataPermId, userIdListString)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + Set 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 应答数据结果。 + */ + @SaCheckPermission("sysDataPerm.update") + @OperationLog(type = SysOperationLogType.DELETE_M2M) + @PostMapping("/deleteDataPermUser") + public ResponseResult 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(); + } + + /** + * 以字典形式返回全部数据权限管理数据集合。字典的键值为[dataPermId, dataPermName]。 + * 白名单接口,登录用户均可访问。 + * + * @param filter 过滤对象。 + * @return 应答结果对象,包含的数据为 List>,map中包含两条记录,key的值分别是id和name,value对应具体数据。 + */ + @GetMapping("/listDict") + public ResponseResult>> listDict(@ParameterObject SysDataPermDto filter) { + List resultList = + sysDataPermService.getListByFilter(MyModelUtil.copyTo(filter, SysDataPerm.class)); + return ResponseResult.success( + MyCommonUtil.toDictDataList(resultList, SysDataPerm::getDataPermId, SysDataPerm::getDataPermName)); + } + + private ResponseResult 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(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysDeptController.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysDeptController.java new file mode 100644 index 00000000..3c1fb0f8 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysDeptController.java @@ -0,0 +1,428 @@ +package com.orangeforms.webadmin.upms.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.hutool.core.util.StrUtil; +import cn.hutool.core.util.ObjectUtil; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.webadmin.upms.vo.*; +import com.orangeforms.webadmin.upms.dto.*; +import com.orangeforms.webadmin.upms.model.*; +import com.orangeforms.webadmin.upms.service.*; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.*; +import com.orangeforms.common.core.constant.*; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.slf4j.Slf4j; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 部门管理操作控制器类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "部门管理管理接口") +@Slf4j +@RestController +@RequestMapping("/admin/upms/sysDept") +public class SysDeptController { + + @Autowired + private SysPostService sysPostService; + @Autowired + private SysDeptService sysDeptService; + + /** + * 新增部门管理数据。 + * + * @param sysDeptDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"sysDeptDto.deptId"}) + @SaCheckPermission("sysDept.add") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult 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 应答结果对象。 + */ + @SaCheckPermission("sysDept.update") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult 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()) + && ObjectUtil.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 应答结果对象。 + */ + @SaCheckPermission("sysDept.delete") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long deptId) { + if (MyCommonUtil.existBlankArgument(deptId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + return this.doDelete(deptId); + } + + /** + * 批量删除部门管理数据。 + * + * @param deptIdList 待删除对象的主键Id列表。 + * @return 应答结果对象。 + */ + @SaCheckPermission("sysDept.delete") + @OperationLog(type = SysOperationLogType.DELETE_BATCH) + @PostMapping("/deleteBatch") + public ResponseResult deleteBatch(@MyRequestBody List deptIdList) { + if (MyCommonUtil.existBlankArgument(deptIdList)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + for (Long deptId : deptIdList) { + ResponseResult responseResult = this.doDelete(deptId); + if (!responseResult.isSuccess()) { + return responseResult; + } + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的部门管理列表。 + * + * @param sysDeptDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("sysDept.view") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody SysDeptDto sysDeptDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount()); + } + SysDept sysDeptFilter = MyModelUtil.copyTo(sysDeptDtoFilter, SysDept.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, SysDept.class); + List sysDeptList = sysDeptService.getSysDeptListWithRelation(sysDeptFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(sysDeptList, SysDeptVo.class)); + } + + /** + * 查看指定部门管理对象详情。 + * + * @param deptId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("sysDept.view") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long deptId) { + SysDept sysDept = sysDeptService.getByIdWithRelation(deptId, MyRelationParam.full()); + if (sysDept == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + SysDeptVo sysDeptVo = MyModelUtil.copyTo(sysDept, SysDeptVo.class); + return ResponseResult.success(sysDeptVo); + } + + /** + * 列出不与指定部门管理存在多对多关系的 [岗位管理] 列表数据。通常用于查看添加新 [岗位管理] 对象的候选列表。 + * + * @param deptId 主表关联字段。 + * @param sysPostDtoFilter [岗位管理] 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,返回符合条件的数据列表。 + */ + @SaCheckPermission("sysDept.update") + @PostMapping("/listNotInSysDeptPost") + public ResponseResult> 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 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, SysPostVo.class)); + } + + /** + * 列出与指定部门管理存在多对多关系的 [岗位管理] 列表数据。 + * + * @param deptId 主表关联字段。 + * @param sysPostDtoFilter [岗位管理] 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,返回符合条件的数据列表。 + */ + @SaCheckPermission("sysDept.view") + @PostMapping("/listSysDeptPost") + public ResponseResult> 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 sysPostList = sysPostService.getSysPostListByDeptId(deptId, filter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(sysPostList, SysPostVo.class)); + } + + /** + * 批量添加部门管理和 [岗位管理] 对象的多对多关联关系数据。 + * + * @param deptId 主表主键Id。 + * @param sysDeptPostDtoList 关联对象列表。 + * @return 应答结果对象。 + */ + @SaCheckPermission("sysDept.update") + @PostMapping("/addSysDeptPost") + public ResponseResult addSysDeptPost( + @MyRequestBody Long deptId, + @MyRequestBody List 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 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 sysDeptPostList = MyModelUtil.copyCollectionTo(sysDeptPostDtoList, SysDeptPost.class); + sysDeptService.addSysDeptPostList(sysDeptPostList, deptId); + return ResponseResult.success(); + } + + /** + * 更新指定部门管理和指定 [岗位管理] 的多对多关联数据。 + * + * @param sysDeptPostDto 对多对中间表对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("sysDept.update") + @PostMapping("/updateSysDeptPost") + public ResponseResult 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 应答结果对象,包括中间表详情。 + */ + @SaCheckPermission("sysDept.update") + @GetMapping("/viewSysDeptPost") + public ResponseResult viewSysDeptPost(@RequestParam Long deptId, @RequestParam Long postId) { + 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 应答结果对象。 + */ + @SaCheckPermission("sysDept.update") + @PostMapping("/deleteSysDeptPost") + public ResponseResult 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>> listSysDeptPostWithRelation( + @RequestParam(required = false) Long deptId) { + return ResponseResult.success(sysDeptService.getSysDeptPostListWithRelationByDeptId(deptId)); + } + + /** + * 以字典形式返回全部部门管理数据集合。字典的键值为[deptId, deptName]。 + * 白名单接口,登录用户均可访问。 + * + * @param filter 过滤对象。 + * @return 应答结果对象,包含的数据为 List>,map中包含两条记录,key的值分别是id和name,value对应具体数据。 + */ + @GetMapping("/listDict") + public ResponseResult>> listDict(@ParameterObject SysDeptDto filter) { + List resultList = + sysDeptService.getListByFilter(MyModelUtil.copyTo(filter, SysDept.class)); + return ResponseResult.success(MyCommonUtil.toDictDataList( + resultList, SysDept::getDeptId, SysDept::getDeptName, SysDept::getParentId)); + } + + /** + * 根据字典Id集合,获取查询后的字典数据。 + * + * @param dictIds 字典Id集合。 + * @return 应答结果对象,包含字典形式的数据集合。 + */ + @GetMapping("/listDictByIds") + public ResponseResult>> listDictByIds(@RequestParam List dictIds) { + List resultList = sysDeptService.getInList(new HashSet<>(dictIds)); + return ResponseResult.success(MyCommonUtil.toDictDataList( + resultList, SysDept::getDeptId, SysDept::getDeptName, SysDept::getParentId)); + } + + /** + * 根据父主键Id,以字典的形式返回其下级数据列表。 + * 白名单接口,登录用户均可访问。 + * + * @param parentId 父主键Id。 + * @return 按照字典的形式返回下级数据列表。 + */ + @GetMapping("/listDictByParentId") + public ResponseResult>> listDictByParentId(@RequestParam(required = false) Long parentId) { + List resultList = sysDeptService.getListByParentId("parentId", parentId); + return ResponseResult.success(MyCommonUtil.toDictDataList( + resultList, SysDept::getDeptId, SysDept::getDeptName, SysDept::getParentId)); + } + + /** + * 根据父主键Id列表,获取当前部门Id及其所有下级部门Id列表。 + * 白名单接口,登录用户均可访问。 + * + * @param parentIds 父主键Id列表,多个Id之间逗号分隔。 + * @return 获取当前部门Id及其所有下级部门Id列表。 + */ + @GetMapping("/listAllChildDeptIdByParentIds") + public ResponseResult> listAllChildDeptIdByParentIds( + @RequestParam(required = false) String parentIds) { + List parentIdList = StrUtil.split(parentIds, ',') + .stream().map(Long::valueOf).collect(Collectors.toList()); + return ResponseResult.success(sysDeptService.getAllChildDeptIdByParentIds(parentIdList)); + } + + private ResponseResult 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(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysMenuController.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysMenuController.java new file mode 100644 index 00000000..0ea5f339 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysMenuController.java @@ -0,0 +1,231 @@ +package com.orangeforms.webadmin.upms.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +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.SysDataPerm; +import com.orangeforms.webadmin.upms.model.constant.SysMenuType; +import com.orangeforms.webadmin.upms.service.SysMenuService; +import com.orangeforms.webadmin.upms.service.SysDataPermService; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.*; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 菜单管理接口控制器类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "菜单管理接口") +@Slf4j +@RestController +@RequestMapping("/admin/upms/sysMenu") +public class SysMenuController { + + @Autowired + private SysMenuService sysMenuService; + @Autowired + private SysDataPermService sysDataPermService; + + /** + * 添加新菜单操作。 + * + * @param sysMenuDto 新菜单对象。 + * @return 应答结果对象,包含新增菜单的主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"sysMenuDto.menuId"}) + @SaCheckPermission("sysMenu.add") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody SysMenuDto sysMenuDto) { + 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); + if (!result.isSuccess()) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage()); + } + sysMenuService.saveNew(sysMenu); + return ResponseResult.success(sysMenu.getMenuId()); + } + + /** + * 更新菜单数据操作。 + * + * @param sysMenuDto 新菜单对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("sysMenu.update") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody SysMenuDto sysMenuDto) { + 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); + if (!result.isSuccess()) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage()); + } + if (!sysMenuService.update(sysMenu, originalSysMenu)) { + errorMessage = "数据验证失败,当前权限字并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 删除指定菜单操作。 + * + * @param menuId 指定菜单主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("sysMenu.delete") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult 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); + } + List dataPermList = sysDataPermService.getSysDataPermListByMenuId(menuId); + if (CollUtil.isNotEmpty(dataPermList)) { + SysDataPerm dataPerm = dataPermList.get(0); + errorMessage = "数据验证失败,当前菜单正在被数据权限 [" + dataPerm.getDataPermName() + "] 引用,不能直接删除!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!sysMenuService.remove(menu)) { + errorMessage = "数据操作失败,菜单不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 获取全部菜单列表。 + * + * @return 应答结果对象,包含全部菜单数据列表。 + */ + @SaCheckPermission("sysMenu.view") + @PostMapping("/list") + public ResponseResult> list() { + List resultList = this.getAllMenuListByShowOrder(); + return ResponseResult.success(MyModelUtil.copyCollectionTo(resultList, SysMenuVo.class)); + } + + /** + * 查看指定菜单数据详情。 + * + * @param menuId 指定菜单主键Id。 + * @return 应答结果对象,包含菜单详情。 + */ + @SaCheckPermission("sysMenu.view") + @GetMapping("/view") + public ResponseResult 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); + } + + /** + * 以字典形式返回目录和菜单类型的菜单管理数据集合。字典的键值为[menuId, menuName]。 + * 白名单接口,登录用户均可访问。 + * + * @return 应答结果对象,包含的数据为 List>,map中包含两条记录,key的值分别是id和name,value对应具体数据。 + */ + @GetMapping("/listMenuDict") + public ResponseResult>> listMenuDict() { + List resultList = this.getAllMenuListByShowOrder(); + resultList = resultList.stream() + .filter(m -> m.getMenuType() <= SysMenuType.TYPE_MENU).collect(Collectors.toList()); + return ResponseResult.success( + MyCommonUtil.toDictDataList(resultList, SysMenu::getMenuId, SysMenu::getMenuName, SysMenu::getParentId)); + } + + /** + * 以字典形式返回全部的菜单管理数据集合。字典的键值为[menuId, menuName]。 + * 白名单接口,登录用户均可访问。 + * + * @return 应答结果对象,包含的数据为 List>,map中包含两条记录,key的值分别是id和name,value对应具体数据。 + */ + @GetMapping("/listDict") + public ResponseResult>> listDict() { + List resultList = this.getAllMenuListByShowOrder(); + return ResponseResult.success( + MyCommonUtil.toDictDataList(resultList, SysMenu::getMenuId, SysMenu::getMenuName, SysMenu::getParentId)); + } + + private List getAllMenuListByShowOrder() { + return sysMenuService.getAllListByOrder("showOrder"); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysOperationLogController.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysOperationLogController.java new file mode 100644 index 00000000..d7ec940f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysOperationLogController.java @@ -0,0 +1,63 @@ +package com.orangeforms.webadmin.upms.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.pagehelper.Page; +import com.github.pagehelper.page.PageMethod; +import io.swagger.v3.oas.annotations.tags.Tag; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.log.model.SysOperationLog; +import com.orangeforms.common.log.service.SysOperationLogService; +import com.orangeforms.common.log.dto.SysOperationLogDto; +import com.orangeforms.common.log.vo.SysOperationLogVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 操作日志接口控制器对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "操作日志接口") +@Slf4j +@RestController +@RequestMapping("/admin/upms/sysOperationLog") +public class SysOperationLogController { + + @Autowired + private SysOperationLogService operationLogService; + + /** + * 数据权限列表。 + * + * @param sysOperationLogDtoFilter 操作日志查询过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象。包含操作日志列表。 + */ + @SaCheckPermission("sysOperationLog.view") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody SysOperationLogDto sysOperationLogDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + SysOperationLog filter = MyModelUtil.copyTo(sysOperationLogDtoFilter, SysOperationLog.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, SysOperationLog.class); + List operationLogList = operationLogService.getSysOperationLogList(filter, orderBy); + List operationLogVoList = MyModelUtil.copyCollectionTo(operationLogList, SysOperationLogVo.class); + long totalCount = 0L; + if (operationLogList instanceof Page) { + totalCount = ((Page) operationLogList).getTotal(); + } + return ResponseResult.success(MyPageUtil.makeResponseData(operationLogVoList, totalCount)); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysPostController.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysPostController.java new file mode 100644 index 00000000..9f4dcec4 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysPostController.java @@ -0,0 +1,183 @@ +package com.orangeforms.webadmin.upms.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +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 com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import lombok.extern.slf4j.Slf4j; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.*; +import jakarta.validation.groups.Default; + +/** + * 岗位管理操作控制器类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "岗位管理操作管理接口") +@Slf4j +@RestController +@RequestMapping("/admin/upms/sysPost") +public class SysPostController { + + @Autowired + private SysPostService sysPostService; + + /** + * 新增岗位管理数据。 + * + * @param sysPostDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"sysPostDto.postId"}) + @SaCheckPermission("sysPost.add") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult 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 应答结果对象。 + */ + @SaCheckPermission("sysPost.update") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult 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 应答结果对象。 + */ + @SaCheckPermission("sysPost.delete") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult 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 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("sysPost.view") + @PostMapping("/list") + public ResponseResult> 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 sysPostList = sysPostService.getSysPostListWithRelation(sysPostFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(sysPostList, SysPostVo.class)); + } + + /** + * 查看指定岗位管理对象详情。 + * + * @param postId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("sysPost.view") + @GetMapping("/view") + public ResponseResult 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 = MyModelUtil.copyTo(sysPost, SysPostVo.class); + return ResponseResult.success(sysPostVo); + } + + /** + * 以字典形式返回全部岗位管理数据集合。字典的键值为[postId, postName]。 + * 白名单接口,登录用户均可访问。 + * + * @param filter 过滤对象。 + * @return 应答结果对象,包含的数据为 List>,map中包含两条记录,key的值分别是id和name,value对应具体数据。 + */ + @GetMapping("/listDict") + public ResponseResult>> listDict(@ParameterObject SysPostDto filter) { + List resultList = sysPostService.getListByFilter(MyModelUtil.copyTo(filter, SysPost.class)); + return ResponseResult.success(MyCommonUtil.toDictDataList(resultList, SysPost::getPostId, SysPost::getPostName)); + } + + /** + * 根据字典Id集合,获取查询后的字典数据。 + * + * @param postIds 字典Id集合。 + * @return 应答结果对象,包含字典形式的数据集合。 + */ + @GetMapping("/listDictByIds") + public ResponseResult>> listDictByIds(@RequestParam List postIds) { + List resultList = sysPostService.getInList(new HashSet<>(postIds)); + return ResponseResult.success(MyCommonUtil.toDictDataList(resultList, SysPost::getPostId, SysPost::getPostName)); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysRoleController.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysRoleController.java new file mode 100644 index 00000000..25e5c51f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysRoleController.java @@ -0,0 +1,331 @@ +package com.orangeforms.webadmin.upms.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import com.alibaba.fastjson.TypeReference; +import com.github.pagehelper.Page; +import com.github.pagehelper.page.PageMethod; +import lombok.extern.slf4j.Slf4j; +import com.orangeforms.webadmin.upms.dto.SysRoleDto; +import com.orangeforms.webadmin.upms.dto.SysUserDto; +import com.orangeforms.webadmin.upms.vo.SysRoleVo; +import com.orangeforms.webadmin.upms.vo.SysUserVo; +import com.orangeforms.webadmin.upms.model.SysRole; +import com.orangeforms.webadmin.upms.model.SysUser; +import com.orangeforms.webadmin.upms.model.SysUserRole; +import com.orangeforms.webadmin.upms.service.SysRoleService; +import com.orangeforms.webadmin.upms.service.SysUserService; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.*; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 角色管理接口控制器类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "角色管理接口") +@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"}) + @SaCheckPermission("sysRole.add") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult 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 menuIdSet = null; + if (result.getData() != null) { + menuIdSet = result.getData().getObject("menuIdSet", new TypeReference>(){}); + } + sysRoleService.saveNew(sysRole, menuIdSet); + return ResponseResult.success(sysRole.getRoleId()); + } + + /** + * 更新角色操作。 + * + * @param sysRoleDto 更新角色对象。 + * @param menuIdListString 与当前角色Id绑定的menuId列表,多个menuId之间逗号分隔。 + * @return 应答结果对象。 + */ + @ApiOperationSupport(ignoreParameters = {"sysRoleDto.createTimeStart", "sysRoleDto.createTimeEnd"}) + @SaCheckPermission("sysRole.update") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult 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 menuIdSet = null; + if (result.getData() != null) { + menuIdSet = result.getData().getObject("menuIdSet", new TypeReference>(){}); + } + if (!sysRoleService.update(sysRole, originalSysRole, menuIdSet)) { + errorMessage = "更新失败,数据不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 删除指定角色操作。 + * + * @param roleId 指定角色主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("sysRole.delete") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult 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 应答结果对象,包含角色列表。 + */ + @SaCheckPermission("sysRole.view") + @PostMapping("/list") + public ResponseResult> 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 roleList = sysRoleService.getSysRoleList( + filter, MyOrderParam.buildOrderBy(orderParam, SysRole.class)); + List roleVoList = MyModelUtil.copyCollectionTo(roleList, SysRoleVo.class); + long totalCount = 0L; + if (roleList instanceof Page) { + totalCount = ((Page) roleList).getTotal(); + } + return ResponseResult.success(MyPageUtil.makeResponseData(roleVoList, totalCount)); + } + + /** + * 查看角色详情。 + * + * @param roleId 指定角色主键Id。 + * @return 应答结果对象,包含角色详情对象。 + */ + @SaCheckPermission("sysRole.view") + @GetMapping("/view") + public ResponseResult 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); + } + + /** + * 拥有指定角色的用户列表。 + * + * @param roleId 角色主键Id。 + * @param sysUserDtoFilter 用户过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含用户列表数据。 + */ + @SaCheckPermission("sysRole.view") + @PostMapping("/listUserRole") + public ResponseResult> listUserRole( + @MyRequestBody Long roleId, + @MyRequestBody SysUserDto sysUserDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + ResponseResult 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 userList = sysUserService.getSysUserListByRoleId(roleId, filter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(userList, SysUserVo.class)); + } + + /** + * 获取不包含指定角色Id的用户列表。 + * 用户和角色是多对多关系,当前接口将返回没有赋值指定RoleId的用户列表。可用于给角色添加新用户。 + * + * @param roleId 角色主键Id。 + * @param sysUserDtoFilter 用户过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含用户列表数据。 + */ + @SaCheckPermission("sysRole.update") + @PostMapping("/listNotInUserRole") + public ResponseResult> listNotInUserRole( + @MyRequestBody Long roleId, + @MyRequestBody SysUserDto sysUserDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + ResponseResult 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 userList = sysUserService.getNotInSysUserListByRoleId(roleId, filter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(userList, SysUserVo.class)); + } + + /** + * 为指定角色添加用户列表。该操作可同时给一批用户赋值角色,并在同一事务内完成。 + * + * @param roleId 角色主键Id。 + * @param userIdListString 逗号分隔的用户Id列表。 + * @return 应答结果对象。 + */ + @SaCheckPermission("sysRole.update") + @OperationLog(type = SysOperationLogType.ADD_M2M) + @PostMapping("/addUserRole") + public ResponseResult addUserRole(@MyRequestBody Long roleId, @MyRequestBody String userIdListString) { + if (MyCommonUtil.existBlankArgument(roleId, userIdListString)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + Set 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 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 应答数据结果。 + */ + @SaCheckPermission("sysRole.update") + @OperationLog(type = SysOperationLogType.DELETE_M2M) + @PostMapping("/deleteUserRole") + public ResponseResult 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中包含两条记录,key的值分别是id和name,value对应具体数据。 + */ + @GetMapping("/listDict") + public ResponseResult>> listDict(@ParameterObject SysRoleDto filter) { + List resultList = sysRoleService.getListByFilter(MyModelUtil.copyTo(filter, SysRole.class)); + return ResponseResult.success(MyCommonUtil.toDictDataList(resultList, SysRole::getRoleId, SysRole::getRoleName)); + } + + /** + * 根据字典Id集合,获取查询后的字典数据。 + * + * @param dictIds 字典Id集合。 + * @return 应答结果对象,包含字典形式的数据集合。 + */ + @GetMapping("/listDictByIds") + public ResponseResult>> listDictByIds(@RequestParam List dictIds) { + List resultList = sysRoleService.getInList(new HashSet<>(dictIds)); + return ResponseResult.success(MyCommonUtil.toDictDataList(resultList, SysRole::getRoleId, SysRole::getRoleName)); + } + + private ResponseResult 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(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysUserController.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysUserController.java new file mode 100644 index 00000000..406898d2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/controller/SysUserController.java @@ -0,0 +1,378 @@ +package com.orangeforms.webadmin.upms.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.alibaba.fastjson.TypeReference; +import cn.hutool.core.util.ReflectUtil; +import com.orangeforms.common.core.upload.BaseUpDownloader; +import com.orangeforms.common.core.upload.UpDownloaderFactory; +import com.orangeforms.common.core.upload.UploadResponseInfo; +import com.orangeforms.common.core.upload.UploadStoreInfo; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.webadmin.upms.vo.*; +import com.orangeforms.webadmin.upms.dto.*; +import com.orangeforms.webadmin.upms.model.*; +import com.orangeforms.webadmin.upms.service.*; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.*; +import com.orangeforms.common.core.constant.*; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.redis.cache.SessionCacheHelper; +import com.orangeforms.webadmin.config.ApplicationConfig; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.slf4j.Slf4j; +import org.springdoc.core.annotations.ParameterObject; +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 jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.*; + +/** + * 用户管理操作控制器类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "用户管理管理接口") +@Slf4j +@RestController +@RequestMapping("/admin/upms/sysUser") +public class SysUserController { + + @Autowired + private PasswordEncoder passwordEncoder; + @Autowired + private ApplicationConfig appConfig; + @Autowired + private SessionCacheHelper cacheHelper; + @Autowired + private UpDownloaderFactory upDownloaderFactory; + @Autowired + private SysUserService sysUserService; + + /** + * 新增用户操作。 + * + * @param sysUserDto 新增用户对象。 + * @param deptPostIdListString 逗号分隔的部门岗位Id列表。 + * @param dataPermIdListString 逗号分隔的数据权限Id列表。 + * @param roleIdListString 逗号分隔的角色Id列表。 + * @return 应答结果对象,包含新增用户的主键Id。 + */ + @ApiOperationSupport(ignoreParameters = { + "sysUserDto.userId", + "sysUserDto.createTimeStart", + "sysUserDto.createTimeEnd"}) + @SaCheckPermission("sysUser.add") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult 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 deptPostIdSet = result.getData().getObject("deptPostIdSet", new TypeReference>() {}); + Set roleIdSet = result.getData().getObject("roleIdSet", new TypeReference>() {}); + Set dataPermIdSet = result.getData().getObject("dataPermIdSet", new TypeReference>() {}); + 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"}) + @SaCheckPermission("sysUser.update") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult 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 roleIdSet = result.getData().getObject("roleIdSet", new TypeReference>() {}); + Set deptPostIdSet = result.getData().getObject("deptPostIdSet", new TypeReference>() {}); + Set dataPermIdSet = result.getData().getObject("dataPermIdSet", new TypeReference>() {}); + if (!sysUserService.update(sysUser, originalUser, roleIdSet, deptPostIdSet, dataPermIdSet)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 重置密码操作。 + * + * @param userId 指定用户主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("sysUser.resetPassword") + @PostMapping("/resetPassword") + public ResponseResult 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 应答结果对象。 + */ + @SaCheckPermission("sysUser.delete") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long userId) { + if (MyCommonUtil.existBlankArgument(userId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + return this.doDelete(userId); + } + + /** + * 批量删除用户管理数据。 + * + * @param userIdList 待删除对象的主键Id列表。 + * @return 应答结果对象。 + */ + @SaCheckPermission("sysUser.delete") + @OperationLog(type = SysOperationLogType.DELETE_BATCH) + @PostMapping("/deleteBatch") + public ResponseResult deleteBatch(@MyRequestBody List userIdList) { + if (MyCommonUtil.existBlankArgument(userIdList)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + for (Long userId : userIdList) { + ResponseResult responseResult = this.doDelete(userId); + if (!responseResult.isSuccess()) { + return responseResult; + } + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的用户管理列表。 + * + * @param sysUserDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("sysUser.view") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody SysUserDto sysUserDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount()); + } + SysUser sysUserFilter = MyModelUtil.copyTo(sysUserDtoFilter, SysUser.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, SysUser.class); + List sysUserList = sysUserService.getSysUserListWithRelation(sysUserFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(sysUserList, SysUserVo.class)); + } + + /** + * 查看指定用户管理对象详情。 + * + * @param userId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("sysUser.view") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long userId) { + // 这里查看用户数据时候,需要把用户多对多关联的角色和数据权限Id一并查出。 + SysUser sysUser = sysUserService.getByIdWithRelation(userId, MyRelationParam.full()); + if (sysUser == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + SysUserVo sysUserVo = MyModelUtil.copyTo(sysUser, SysUserVo.class); + return ResponseResult.success(sysUserVo); + } + + /** + * 附件文件下载。 + * 这里将图片和其他类型的附件文件放到不同的父目录下,主要为了便于今后图片文件的迁移。 + * + * @param userId 附件所在记录的主键Id。 + * @param fieldName 附件所属的字段名。 + * @param filename 文件名。如果没有提供该参数,就从当前记录的指定字段中读取。 + * @param asImage 下载文件是否为图片。 + * @param response Http 应答对象。 + */ + @SaCheckPermission("sysUser.view") + @OperationLog(type = SysOperationLogType.DOWNLOAD, saveResponse = false) + @GetMapping("/download") + public void download( + @RequestParam(required = false) Long userId, + @RequestParam String fieldName, + @RequestParam String filename, + @RequestParam Boolean asImage, + HttpServletResponse response) { + if (MyCommonUtil.existBlankArgument(fieldName, filename, asImage)) { + response.setStatus(HttpServletResponse.SC_BAD_REQUEST); + return; + } + // 使用try来捕获异常,是为了保证一旦出现异常可以返回500的错误状态,便于调试。 + // 否则有可能给前端返回的是200的错误码。 + try { + // 如果请求参数中没有包含主键Id,就判断该文件是否为当前session上传的。 + if (userId == null) { + if (!cacheHelper.existSessionUploadFile(filename)) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN); + return; + } + } else { + SysUser sysUser = sysUserService.getById(userId); + if (sysUser == null) { + ResponseResult.output(HttpServletResponse.SC_NOT_FOUND); + return; + } + String fieldJsonData = (String) ReflectUtil.getFieldValue(sysUser, fieldName); + if (fieldJsonData == null && !cacheHelper.existSessionUploadFile(filename)) { + ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST); + return; + } + if (!BaseUpDownloader.containFile(fieldJsonData, filename) + && !cacheHelper.existSessionUploadFile(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 上传文件对象。 + */ + @SaCheckPermission("sysUser.view") + @OperationLog(type = SysOperationLogType.UPLOAD, saveResponse = false) + @PostMapping("/upload") + public void upload( + @RequestParam String fieldName, + @RequestParam Boolean asImage, + @RequestParam("uploadFile") MultipartFile uploadFile) throws IOException { + 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 (Boolean.TRUE.equals(responseInfo.getUploadFailed())) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, + ResponseResult.error(ErrorCodeEnum.UPLOAD_FAILED, responseInfo.getErrorMessage())); + return; + } + cacheHelper.putSessionUploadFile(responseInfo.getFilename()); + ResponseResult.output(ResponseResult.success(responseInfo)); + } + + /** + * 以字典形式返回全部用户管理数据集合。字典的键值为[userId, showName]。 + * 白名单接口,登录用户均可访问。 + * + * @param filter 过滤对象。 + * @return 应答结果对象,包含的数据为 List>,map中包含两条记录,key的值分别是id和name,value对应具体数据。 + */ + @GetMapping("/listDict") + public ResponseResult>> listDict(@ParameterObject SysUserDto filter) { + List resultList = + sysUserService.getListByFilter(MyModelUtil.copyTo(filter, SysUser.class)); + return ResponseResult.success( + MyCommonUtil.toDictDataList(resultList, SysUser::getUserId, SysUser::getShowName)); + } + + /** + * 根据字典Id集合,获取查询后的字典数据。 + * + * @param dictIds 字典Id集合。 + * @return 应答结果对象,包含字典形式的数据集合。 + */ + @GetMapping("/listDictByIds") + public ResponseResult>> listDictByIds(@RequestParam List dictIds) { + List resultList = sysUserService.getInList(new HashSet<>(dictIds)); + return ResponseResult.success( + MyCommonUtil.toDictDataList(resultList, SysUser::getUserId, SysUser::getShowName)); + } + + private ResponseResult 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(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermDeptMapper.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermDeptMapper.java new file mode 100644 index 00000000..db58a68f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermDeptMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.webadmin.upms.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.webadmin.upms.model.SysDataPermDept; + +/** + * 数据权限与部门关系数据访问操作接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysDataPermDeptMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermMapper.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermMapper.java new file mode 100644 index 00000000..9483f952 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermMapper.java @@ -0,0 +1,43 @@ +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 2024-07-02 + */ +public interface SysDataPermMapper extends BaseDaoMapper { + + /** + * 获取数据权限列表。 + * + * @param sysDataPermFilter 过滤对象。 + * @param orderBy 排序字符串。 + * @return 过滤后的数据权限列表。 + */ + List getSysDataPermList( + @Param("sysDataPermFilter") SysDataPerm sysDataPermFilter, @Param("orderBy") String orderBy); + + /** + * 获取指定用户的数据权限列表。 + * + * @param userId 用户Id。 + * @return 数据权限列表。 + */ + List getSysDataPermListByUserId(@Param("userId") Long userId); + + /** + * 查询与指定菜单关联的数据权限列表。 + * + * @param menuId 菜单Id。 + * @return 与菜单Id关联的数据权限列表。 + */ + List getSysDataPermListByMenuId(@Param("menuId") Long menuId); +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermMenuMapper.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermMenuMapper.java new file mode 100644 index 00000000..37fa8274 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermMenuMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.webadmin.upms.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.webadmin.upms.model.SysDataPermMenu; + +/** + * 数据权限与菜单关系数据访问操作接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysDataPermMenuMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermUserMapper.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermUserMapper.java new file mode 100644 index 00000000..1ca7d6d3 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDataPermUserMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.webadmin.upms.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.webadmin.upms.model.SysDataPermUser; + +/** + * 数据权限与用户关系数据访问操作接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysDataPermUserMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDeptMapper.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDeptMapper.java new file mode 100644 index 00000000..9f0dc2c2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDeptMapper.java @@ -0,0 +1,33 @@ +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 2024-07-02 + */ +public interface SysDeptMapper extends BaseDaoMapper { + + /** + * 批量插入对象列表。 + * + * @param sysDeptList 新增对象列表。 + */ + void insertList(List sysDeptList); + + /** + * 获取过滤后的对象列表。 + * + * @param sysDeptFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getSysDeptList( + @Param("sysDeptFilter") SysDept sysDeptFilter, @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDeptPostMapper.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDeptPostMapper.java new file mode 100644 index 00000000..93eb328a --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDeptPostMapper.java @@ -0,0 +1,33 @@ +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 2024-07-02 + */ +public interface SysDeptPostMapper extends BaseDaoMapper { + + /** + * 获取指定部门Id的部门岗位多对多关联数据列表,以及关联的部门和岗位数据。 + * + * @param deptId 部门Id。如果参数为空则返回全部数据。 + * @return 部门岗位多对多数据列表。 + */ + List> getSysDeptPostListWithRelationByDeptId(@Param("deptId") Long deptId); + + /** + * 获取指定部门Id的领导部门岗位列表。 + * + * @param deptId 部门Id。 + * @return 指定部门Id的领导部门岗位列表 + */ + List getLeaderDeptPostList(@Param("deptId") Long deptId); +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDeptRelationMapper.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDeptRelationMapper.java new file mode 100644 index 00000000..a0f66281 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysDeptRelationMapper.java @@ -0,0 +1,42 @@ +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 2024-07-02 + */ +public interface SysDeptRelationMapper extends BaseDaoMapper { + + /** + * 将myDeptId的所有子部门,与其父部门parentDeptId解除关联关系。 + * + * @param parentDeptIds myDeptId的父部门Id列表。 + * @param myDeptId 当前部门。 + */ + void removeBetweenChildrenAndParents( + @Param("parentDeptIds") List parentDeptIds, @Param("myDeptId") Long myDeptId); + + /** + * 批量插入部门关联数据。 + * 由于目前版本(3.4.1)的Mybatis Plus没有提供真正的批量插入,为了保证效率需要自己实现。 + * 目前我们仅仅给出MySQL和PostgresSQL的insert list实现作为参考,其他数据库需要自行修改。 + * + * @param deptRelationList 部门关联关系数据列表。 + */ + void insertList(List deptRelationList); + + /** + * 批量插入当前部门的所有父部门列表,包括自己和自己的关系。 + * + * @param parentDeptId myDeptId的父部门Id。 + * @param myDeptId 当前部门。 + */ + void insertParentList(@Param("parentDeptId") Long parentDeptId, @Param("myDeptId") Long myDeptId); +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysMenuMapper.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysMenuMapper.java new file mode 100644 index 00000000..da04a33c --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysMenuMapper.java @@ -0,0 +1,40 @@ +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 2024-07-02 + */ +public interface SysMenuMapper extends BaseDaoMapper { + + /** + * 获取登录用户的菜单列表。 + * + * @param userId 登录用户。 + * @return 菜单列表。 + */ + List getMenuListByUserId(@Param("userId") Long userId); + + /** + * 获取指定角色Id集合的菜单列表。 + * + * @param roleIds 角色Id集合。 + * @return 菜单列表。 + */ + List getMenuListByRoleIds(@Param("roleIds") Set roleIds); + + /** + * 查询包含指定菜单编码的菜单数量,目前仅用于satoken的权限框架。 + * + * @param menuCode 菜单编码。 + * @return 查询数量 + */ + int countMenuCode(@Param("menuCode") String menuCode); +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysPermWhitelistMapper.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysPermWhitelistMapper.java new file mode 100644 index 00000000..52a78fbf --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysPermWhitelistMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.webadmin.upms.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.webadmin.upms.model.SysPermWhitelist; + +/** + * 权限资源白名单数据访问操作接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysPermWhitelistMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysPostMapper.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysPostMapper.java new file mode 100644 index 00000000..4d17cc24 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysPostMapper.java @@ -0,0 +1,52 @@ +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 2024-07-02 + */ +public interface SysPostMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param sysPostFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getSysPostList( + @Param("sysPostFilter") SysPost sysPostFilter, @Param("orderBy") String orderBy); + + /** + * 获取指定部门的岗位列表。 + * + * @param deptId 部门Id。 + * @param sysPostFilter 从表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 岗位数据列表。 + */ + List 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 getNotInSysPostListByDeptId( + @Param("deptId") Long deptId, + @Param("sysPostFilter") SysPost sysPostFilter, + @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysRoleMapper.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysRoleMapper.java new file mode 100644 index 00000000..9187244e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysRoleMapper.java @@ -0,0 +1,25 @@ +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 2024-07-02 + */ +public interface SysRoleMapper extends BaseDaoMapper { + + /** + * 获取对象列表,过滤条件中包含like和between条件。 + * + * @param sysRoleFilter 过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getSysRoleList(@Param("sysRoleFilter") SysRole sysRoleFilter, @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysRoleMenuMapper.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysRoleMenuMapper.java new file mode 100644 index 00000000..38e63912 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysRoleMenuMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.webadmin.upms.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.webadmin.upms.model.SysRoleMenu; + +/** + * 角色与菜单操作关联关系数据访问操作接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysRoleMenuMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysUserMapper.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysUserMapper.java new file mode 100644 index 00000000..055985d9 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysUserMapper.java @@ -0,0 +1,188 @@ +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 2024-07-02 + */ +public interface SysUserMapper extends BaseDaoMapper { + + /** + * 批量插入对象列表。 + * + * @param sysUserList 新增对象列表。 + */ + void insertList(List sysUserList); + + /** + * 获取过滤后的对象列表。 + * + * @param sysUserFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getSysUserList( + @Param("sysUserFilter") SysUser sysUserFilter, @Param("orderBy") String orderBy); + + /** + * 根据部门Id集合,获取关联的用户列表。 + * + * @param deptIds 关联的部门Id集合。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和部门Id集合关联的用户列表。 + */ + List getSysUserListByDeptIds( + @Param("deptIds") Set deptIds, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); + + /** + * 根据登录名集合,获取关联的用户列表。 + * @param loginNames 登录名集合。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和登录名集合关联的用户列表。 + */ + List getSysUserListByLoginNames( + @Param("loginNames") List loginNames, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); + + /** + * 根据角色Id,获取关联的用户列表。 + * + * @param roleId 关联的角色Id。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和角色Id关联的用户列表。 + */ + List getSysUserListByRoleId( + @Param("roleId") Long roleId, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); + + /** + * 根据角色Id集合,获取去重后的用户Id列表。 + * + * @param roleIds 关联的角色Id集合。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和角色Id集合关联的去重后的用户Id列表。 + */ + List getUserIdListByRoleIds( + @Param("roleIds") Set roleIds, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); + + /** + * 根据角色Id,获取和当前角色Id没有建立多对多关联关系的用户列表。 + * + * @param roleId 关联的角色Id。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和RoleId没有建立关联关系的用户列表。 + */ + List getNotInSysUserListByRoleId( + @Param("roleId") Long roleId, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); + + /** + * 根据数据权限Id,获取关联的用户列表。 + * + * @param dataPermId 关联的数据权限Id。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和DataPermId关联的用户列表。 + */ + List getSysUserListByDataPermId( + @Param("dataPermId") Long dataPermId, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); + + /** + * 根据数据权限Id,获取和当前数据权限Id没有建立多对多关联关系的用户列表。 + * + * @param dataPermId 关联的数据权限Id。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和DataPermId没有建立关联关系的用户列表。 + */ + List getNotInSysUserListByDataPermId( + @Param("dataPermId") Long dataPermId, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); + + /** + * 根据部门岗位Id集合,获取关联的去重后的用户Id列表。 + * + * @param deptPostIds 关联的部门岗位Id集合。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和部门岗位Id集合关联的去重后的用户Id列表。 + */ + List getUserIdListByDeptPostIds( + @Param("deptPostIds") Set deptPostIds, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); + + /** + * 根据部门岗位Id,获取关联的用户列表。 + * + * @param deptPostId 关联的部门岗位Id。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和部门岗位Id关联的用户列表。 + */ + List getSysUserListByDeptPostId( + @Param("deptPostId") Long deptPostId, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); + + /** + * 根据部门岗位Id,获取和当前部门岗位Id没有建立多对多关联关系的用户列表。 + * + * @param deptPostId 关联的部门岗位Id。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和deptPostId没有建立关联关系的用户列表。 + */ + List getNotInSysUserListByDeptPostId( + @Param("deptPostId") Long deptPostId, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); + + /** + * 根据岗位Id集合,获取关联的去重后的用户Id列表。 + * + * @param postIds 关联的岗位Id集合。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和岗位Id集合关联的去重后的用户Id列表。 + */ + List getUserIdListByPostIds( + @Param("postIds") Set postIds, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); + + /** + * 根据岗位Id,获取关联的用户列表。 + * + * @param postId 关联的岗位Id。 + * @param sysUserFilter 用户过滤条件对象。 + * @param orderBy order by从句的参数。 + * @return 和岗位Id关联的用户列表。 + */ + List getSysUserListByPostId( + @Param("postId") Long postId, + @Param("sysUserFilter") SysUser sysUserFilter, + @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysUserPostMapper.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysUserPostMapper.java new file mode 100644 index 00000000..6da64992 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysUserPostMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.webadmin.upms.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.webadmin.upms.model.SysUserPost; + +/** + * 用户岗位数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysUserPostMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysUserRoleMapper.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysUserRoleMapper.java new file mode 100644 index 00000000..bf6dcfb8 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/SysUserRoleMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.webadmin.upms.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.webadmin.upms.model.SysUserRole; + +/** + * 用户与角色关联关系数据访问操作接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysUserRoleMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermDeptMapper.xml b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermDeptMapper.xml new file mode 100644 index 00000000..d3b228e6 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermDeptMapper.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermMapper.xml b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermMapper.xml new file mode 100644 index 00000000..02c2e688 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermMapper.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + AND zz_sys_data_perm.rule_type = #{sysDataPermFilter.ruleType} + + + + AND IFNULL(zz_sys_data_perm.data_perm_name, '') LIKE #{safeSearchString} + + + + + + + + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermMenuMapper.xml b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermMenuMapper.xml new file mode 100644 index 00000000..c668302f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermMenuMapper.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermUserMapper.xml b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermUserMapper.xml new file mode 100644 index 00000000..2530c39f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDataPermUserMapper.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDeptMapper.xml b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDeptMapper.xml new file mode 100644 index 00000000..ef63bdc9 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDeptMapper.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + 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 + + (#{item.deptId}, + #{item.deptName}, + #{item.showOrder}, + #{item.parentId}, + #{item.deletedFlag}, + #{item.createUserId}, + #{item.updateUserId}, + #{item.createTime}, + #{item.updateTime}) + + + + + + + + AND zz_sys_dept.deleted_flag = ${@com.orangeforms.common.core.constant.GlobalDeletedFlag@NORMAL} + + + + + + + + AND zz_sys_dept.dept_name LIKE #{safeSysDeptDeptName} + + + AND zz_sys_dept.parent_id = #{sysDeptFilter.parentId} + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDeptPostMapper.xml b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDeptPostMapper.xml new file mode 100644 index 00000000..5d03d88b --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDeptPostMapper.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDeptRelationMapper.xml b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDeptRelationMapper.xml new file mode 100644 index 00000000..37ebd397 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysDeptRelationMapper.xml @@ -0,0 +1,32 @@ + + + + + + + + + + DELETE a FROM zz_sys_dept_relation a + INNER JOIN zz_sys_dept_relation b ON a.dept_id = b.dept_id + WHERE b.parent_dept_id = #{myDeptId} AND a.parent_dept_id IN + + #{item} + + + + + INSERT INTO zz_sys_dept_relation(parent_dept_id, dept_id) VALUES + + (#{item.parentDeptId}, #{item.deptId}) + + + + + 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} + + diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysMenuMapper.xml b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysMenuMapper.xml new file mode 100644 index 00000000..d9ba9e7b --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysMenuMapper.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysPermWhitelistMapper.xml b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysPermWhitelistMapper.xml new file mode 100644 index 00000000..00d0c6d4 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysPermWhitelistMapper.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysPostMapper.xml b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysPostMapper.xml new file mode 100644 index 00000000..50765655 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysPostMapper.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_sys_post.post_name LIKE #{safeSysPostPostName} + + + AND zz_sys_post.leader_post = #{sysPostFilter.leaderPost} + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysRoleMapper.xml b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysRoleMapper.xml new file mode 100644 index 00000000..26b8e587 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysRoleMapper.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + AND role_name LIKE #{safeRoleName} + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysRoleMenuMapper.xml b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysRoleMenuMapper.xml new file mode 100644 index 00000000..6bf30195 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysRoleMenuMapper.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysUserMapper.xml b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysUserMapper.xml new file mode 100644 index 00000000..162d6b2d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysUserMapper.xml @@ -0,0 +1,294 @@ + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO zz_sys_user + (user_id, + login_name, + password, + dept_id, + show_name, + user_type, + head_image_url, + user_status, + email, + mobile, + create_user_id, + update_user_id, + create_time, + update_time, + deleted_flag) + VALUES + + (#{item.userId}, + #{item.loginName}, + #{item.password}, + #{item.deptId}, + #{item.showName}, + #{item.userType}, + #{item.headImageUrl}, + #{item.userStatus}, + #{item.email}, + #{item.mobile}, + #{item.createUserId}, + #{item.updateUserId}, + #{item.createTime}, + #{item.updateTime}, + #{item.deletedFlag}) + + + + + + + + AND zz_sys_user.deleted_flag = ${@com.orangeforms.common.core.constant.GlobalDeletedFlag@NORMAL} + + + + + + + + AND zz_sys_user.login_name LIKE #{safeSysUserLoginName} + + + AND (EXISTS (SELECT 1 FROM zz_sys_dept_relation WHERE + zz_sys_dept_relation.parent_dept_id = #{sysUserFilter.deptId} + AND zz_sys_user.dept_id = zz_sys_dept_relation.dept_id)) + + + + AND zz_sys_user.show_name LIKE #{safeSysUserShowName} + + + AND zz_sys_user.user_status = #{sysUserFilter.userStatus} + + + AND zz_sys_user.create_time >= #{sysUserFilter.createTimeStart} + + + AND zz_sys_user.create_time <= #{sysUserFilter.createTimeEnd} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysUserPostMapper.xml b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysUserPostMapper.xml new file mode 100644 index 00000000..b846ba04 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysUserPostMapper.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysUserRoleMapper.xml b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysUserRoleMapper.xml new file mode 100644 index 00000000..c4993db0 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dao/mapper/SysUserRoleMapper.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDataPermDeptDto.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDataPermDeptDto.java new file mode 100644 index 00000000..69aa2867 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDataPermDeptDto.java @@ -0,0 +1,27 @@ +package com.orangeforms.webadmin.upms.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 数据权限与部门关联Dto。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "数据权限与部门关联Dto") +@Data +public class SysDataPermDeptDto { + + /** + * 数据权限Id。 + */ + @Schema(description = "数据权限Id", requiredMode = Schema.RequiredMode.REQUIRED) + private Long dataPermId; + + /** + * 关联部门Id。 + */ + @Schema(description = "关联部门Id", requiredMode = Schema.RequiredMode.REQUIRED) + private Long deptId; +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDataPermDto.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDataPermDto.java new file mode 100644 index 00000000..725c8068 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDataPermDto.java @@ -0,0 +1,55 @@ +package com.orangeforms.webadmin.upms.dto; + +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.core.validator.ConstDictRef; +import com.orangeforms.common.core.constant.DataPermRuleType; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.*; + +/** + * 数据权限Dto。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "数据权限Dto") +@Data +public class SysDataPermDto { + + /** + * 数据权限Id。 + */ + @Schema(description = "数据权限Id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据权限Id不能为空!", groups = {UpdateGroup.class}) + private Long dataPermId; + + /** + * 显示名称。 + */ + @Schema(description = "显示名称", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "数据权限名称不能为空!") + private String dataPermName; + + /** + * 数据权限规则类型(0: 全部可见 1: 只看自己 2: 只看本部门 3: 本部门及子部门 4: 多部门及子部门 5: 自定义部门列表)。 + */ + @Schema(description = "数据权限规则类型", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据权限规则类型不能为空!") + @ConstDictRef(constDictClass = DataPermRuleType.class) + private Integer ruleType; + + /** + * 部门Id列表(逗号分隔)。 + */ + @Schema(hidden = true) + private String deptIdListString; + + /** + * 搜索字符串。 + */ + @Schema(description = "LIKE 模糊搜索字符串") + private String searchString; +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDataPermMenuDto.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDataPermMenuDto.java new file mode 100644 index 00000000..763e9ddc --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDataPermMenuDto.java @@ -0,0 +1,27 @@ +package com.orangeforms.webadmin.upms.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 数据权限与菜单关联Dto。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "数据权限与菜单关联Dto") +@Data +public class SysDataPermMenuDto { + + /** + * 数据权限Id。 + */ + @Schema(description = "数据权限Id", requiredMode = Schema.RequiredMode.REQUIRED) + private Long dataPermId; + + /** + * 关联菜单Id。 + */ + @Schema(description = "关联菜单Id", requiredMode = Schema.RequiredMode.REQUIRED) + private Long menuId; +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDeptDto.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDeptDto.java new file mode 100644 index 00000000..335f1607 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDeptDto.java @@ -0,0 +1,48 @@ +package com.orangeforms.webadmin.upms.dto; + +import com.orangeforms.common.core.validator.UpdateGroup; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.*; + +/** + * 部门管理Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "SysDeptDto对象") +@Data +public class SysDeptDto { + + /** + * 部门Id。 + */ + @Schema(description = "部门Id。", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,部门Id不能为空!", groups = {UpdateGroup.class}) + private Long deptId; + + /** + * 部门名称。 + * NOTE: 可支持等于操作符的列表数据过滤。 + */ + @Schema(description = "部门名称。可支持等于操作符的列表数据过滤。", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "数据验证失败,部门名称不能为空!") + private String deptName; + + /** + * 显示顺序。 + */ + @Schema(description = "显示顺序。", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,显示顺序不能为空!") + private Integer showOrder; + + /** + * 父部门Id。 + * NOTE: 可支持等于操作符的列表数据过滤。 + */ + @Schema(description = "父部门Id。可支持等于操作符的列表数据过滤。") + private Long parentId; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDeptPostDto.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDeptPostDto.java new file mode 100644 index 00000000..6362ebe8 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysDeptPostDto.java @@ -0,0 +1,47 @@ +package com.orangeforms.webadmin.upms.dto; + +import com.orangeforms.common.core.validator.UpdateGroup; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.*; + +/** + * 部门岗位Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "部门岗位Dto") +@Data +public class SysDeptPostDto { + + /** + * 部门岗位Id。 + */ + @Schema(description = "部门岗位Id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,部门岗位Id不能为空!", groups = {UpdateGroup.class}) + private Long deptPostId; + + /** + * 部门Id。 + */ + @Schema(description = "部门Id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,部门Id不能为空!", groups = {UpdateGroup.class}) + private Long deptId; + + /** + * 岗位Id。 + */ + @Schema(description = "岗位Id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,岗位Id不能为空!", groups = {UpdateGroup.class}) + private Long postId; + + /** + * 部门岗位显示名称。 + */ + @Schema(description = "部门岗位显示名称", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "数据验证失败,部门岗位显示名称不能为空!") + private String postShowName; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysMenuDto.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysMenuDto.java new file mode 100644 index 00000000..986f8dae --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysMenuDto.java @@ -0,0 +1,92 @@ +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.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 菜单Dto。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "菜单Dto") +@Data +public class SysMenuDto { + + /** + * 菜单Id。 + */ + @Schema(description = "菜单Id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "菜单Id不能为空!", groups = {UpdateGroup.class}) + private Long menuId; + + /** + * 父菜单Id,目录菜单的父菜单为null + */ + @Schema(description = "父菜单Id") + private Long parentId; + + /** + * 菜单显示名称。 + */ + @Schema(description = "菜单显示名称", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "菜单显示名称不能为空!") + private String menuName; + + /** + * 菜单类型 (0: 目录 1: 菜单 2: 按钮 3: UI片段)。 + */ + @Schema(description = "菜单类型", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "菜单类型不能为空!") + @ConstDictRef(constDictClass = SysMenuType.class, message = "数据验证失败,菜单类型为无效值!") + private Integer menuType; + + /** + * 前端表单路由名称,仅用于menu_type为1的菜单类型。 + */ + @Schema(description = "前端表单路由名称") + private String formRouterName; + + /** + * 在线表单主键Id,仅用于在线表单绑定的菜单。 + */ + @Schema(description = "在线表单主键Id") + private Long onlineFormId; + + /** + * 统计页面主键Id,仅用于统计页面绑定的菜单。 + */ + @Schema(description = "统计页面主键Id") + private Long reportPageId; + + /** + * 仅用于在线表单的流程Id。 + */ + @Schema(description = "仅用于在线表单的流程Id") + private Long onlineFlowEntryId; + + /** + * 菜单显示顺序 (值越小,排序越靠前)。 + */ + @Schema(description = "菜单显示顺序", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "菜单显示顺序不能为空!") + private Integer showOrder; + + /** + * 菜单图标。 + */ + @Schema(description = "菜单显示图标") + private String icon; + + /** + * 附加信息。 + */ + @Schema(description = "附加信息") + private String extraData; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysPostDto.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysPostDto.java new file mode 100644 index 00000000..c9bef765 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysPostDto.java @@ -0,0 +1,47 @@ +package com.orangeforms.webadmin.upms.dto; + +import com.orangeforms.common.core.validator.UpdateGroup; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.*; + +/** + * 岗位Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "岗位Dto") +@Data +public class SysPostDto { + + /** + * 岗位Id。 + */ + @Schema(description = "岗位Id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,岗位Id不能为空!", groups = {UpdateGroup.class}) + private Long postId; + + /** + * 岗位名称。 + */ + @Schema(description = "岗位名称", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "数据验证失败,岗位名称不能为空!") + private String postName; + + /** + * 岗位层级,数值越小级别越高。 + */ + @Schema(description = "岗位层级", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,岗位层级不能为空!") + private Integer postLevel; + + /** + * 是否领导岗位。 + */ + @Schema(description = "是否领导岗位", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,领导岗位不能为空!", groups = {UpdateGroup.class}) + private Boolean leaderPost; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysRoleDto.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysRoleDto.java new file mode 100644 index 00000000..3a567acd --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysRoleDto.java @@ -0,0 +1,32 @@ +package com.orangeforms.webadmin.upms.dto; + +import com.orangeforms.common.core.validator.UpdateGroup; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.*; + +/** + * 角色Dto。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "角色Dto") +@Data +public class SysRoleDto { + + /** + * 角色Id。 + */ + @Schema(description = "角色Id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "角色Id不能为空!", groups = {UpdateGroup.class}) + private Long roleId; + + /** + * 角色名称。 + */ + @Schema(description = "角色名称", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "角色名称不能为空!") + private String roleName; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysUserDto.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysUserDto.java new file mode 100644 index 00000000..4a993689 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/dto/SysUserDto.java @@ -0,0 +1,110 @@ +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.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.*; + +/** + * 用户管理Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "SysUserDto对象") +@Data +public class SysUserDto { + + /** + * 用户Id。 + */ + @Schema(description = "用户Id。", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,用户Id不能为空!", groups = {UpdateGroup.class}) + private Long userId; + + /** + * 登录用户名。 + * NOTE: 可支持等于操作符的列表数据过滤。 + */ + @Schema(description = "登录用户名。可支持等于操作符的列表数据过滤。", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "数据验证失败,登录用户名不能为空!") + private String loginName; + + /** + * 用户密码。 + */ + @Schema(description = "用户密码。", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "数据验证失败,用户密码不能为空!", groups = {AddGroup.class}) + private String password; + + /** + * 用户部门Id。 + * NOTE: 可支持等于操作符的列表数据过滤。 + */ + @Schema(description = "用户部门Id。可支持等于操作符的列表数据过滤。", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,用户部门Id不能为空!") + private Long deptId; + + /** + * 用户显示名称。 + * NOTE: 可支持等于操作符的列表数据过滤。 + */ + @Schema(description = "用户显示名称。可支持等于操作符的列表数据过滤。", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "数据验证失败,用户显示名称不能为空!") + private String showName; + + /** + * 用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)。 + */ + @Schema(description = "用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)。", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)不能为空!") + @ConstDictRef(constDictClass = SysUserType.class, message = "数据验证失败,用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)为无效值!") + private Integer userType; + + /** + * 用户头像的Url。 + */ + @Schema(description = "用户头像的Url。") + private String headImageUrl; + + /** + * 用户状态(0: 正常 1: 锁定)。 + * NOTE: 可支持等于操作符的列表数据过滤。 + */ + @Schema(description = "用户状态(0: 正常 1: 锁定)。可支持等于操作符的列表数据过滤。", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据验证失败,用户状态(0: 正常 1: 锁定)不能为空!") + @ConstDictRef(constDictClass = SysUserStatus.class, message = "数据验证失败,用户状态(0: 正常 1: 锁定)为无效值!") + private Integer userStatus; + + /** + * 用户邮箱。 + */ + @Schema(description = "用户邮箱。") + private String email; + + /** + * 用户手机。 + */ + @Schema(description = "用户手机。") + private String mobile; + + /** + * createTime 范围过滤起始值(>=)。 + * NOTE: 可支持范围操作符的列表数据过滤。 + */ + @Schema(description = "createTime 范围过滤起始值(>=)。可支持范围操作符的列表数据过滤。") + private String createTimeStart; + + /** + * createTime 范围过滤结束值(<=)。 + * NOTE: 可支持范围操作符的列表数据过滤。 + */ + @Schema(description = "createTime 范围过滤结束值(<=)。可支持范围操作符的列表数据过滤。") + private String createTimeEnd; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPerm.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPerm.java new file mode 100644 index 00000000..c94e725d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPerm.java @@ -0,0 +1,62 @@ +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.model.BaseModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.*; + +/** + * 数据权限实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName(value = "zz_sys_data_perm") +public class SysDataPerm extends BaseModel { + + /** + * 主键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; + + @TableField(exist = false) + private String deptIdListString; + + @RelationManyToMany( + relationMasterIdField = "dataPermId", + relationModelClass = SysDataPermDept.class) + @TableField(exist = false) + private List dataPermDeptList; + + @RelationManyToMany( + relationMasterIdField = "dataPermId", + relationModelClass = SysDataPermMenu.class) + @TableField(exist = false) + private List dataPermMenuList; + + @TableField(exist = false) + private String searchString; + + public void setSearchString(String searchString) { + this.searchString = MyCommonUtil.replaceSqlWildcard(searchString); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPermDept.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPermDept.java new file mode 100644 index 00000000..89acecdb --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPermDept.java @@ -0,0 +1,29 @@ +package com.orangeforms.webadmin.upms.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import lombok.ToString; + +/** + * 数据权限与部门关联实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@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; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPermMenu.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPermMenu.java new file mode 100644 index 00000000..2aad76fa --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPermMenu.java @@ -0,0 +1,29 @@ +package com.orangeforms.webadmin.upms.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import lombok.ToString; + +/** + * 数据权限与菜单关联实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ToString(of = {"menuId"}) +@TableName(value = "zz_sys_data_perm_menu") +public class SysDataPermMenu { + + /** + * 数据权限Id。 + */ + @TableField(value = "data_perm_id") + private Long dataPermId; + + /** + * 关联菜单Id。 + */ + @TableField(value = "menu_id") + private Long menuId; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPermUser.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPermUser.java new file mode 100644 index 00000000..a30867b6 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDataPermUser.java @@ -0,0 +1,27 @@ +package com.orangeforms.webadmin.upms.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +/** + * 数据权限与用户关联实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@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; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDept.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDept.java new file mode 100644 index 00000000..3ce33929 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDept.java @@ -0,0 +1,72 @@ +package com.orangeforms.webadmin.upms.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +import java.util.Date; + +/** + * 部门管理实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@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; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDeptPost.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDeptPost.java new file mode 100644 index 00000000..826f3724 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDeptPost.java @@ -0,0 +1,39 @@ +package com.orangeforms.webadmin.upms.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +/** + * 部门岗位多对多关联实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@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; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDeptRelation.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDeptRelation.java new file mode 100644 index 00000000..9b9c4146 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysDeptRelation.java @@ -0,0 +1,31 @@ +package com.orangeforms.webadmin.upms.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 部门关联实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@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; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysMenu.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysMenu.java new file mode 100644 index 00000000..6f8a8a40 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysMenu.java @@ -0,0 +1,96 @@ +package com.orangeforms.webadmin.upms.model; + +import com.baomidou.mybatisplus.annotation.*; +import com.orangeforms.common.core.base.model.BaseModel; +import com.orangeforms.webadmin.upms.bo.SysMenuExtraData; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 菜单实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName(value = "zz_sys_menu") +public class SysMenu extends BaseModel { + + /** + * 菜单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 = "report_page_id") + private Long reportPageId; + + /** + * 仅用于在线表单的流程Id。 + */ + @TableField(value = "online_flow_entry_id") + private Long onlineFlowEntryId; + + /** + * 菜单显示顺序 (值越小,排序越靠前)。 + */ + @TableField(value = "show_order") + private Integer showOrder; + + /** + * 菜单图标。 + */ + private String icon; + + /** + * 附加信息。 + */ + @TableField(value = "extra_data") + private String extraData; + + /** + * extraData字段解析后的对象数据。 + */ + @TableField(exist = false) + private SysMenuExtraData extraObject; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysPermWhitelist.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysPermWhitelist.java new file mode 100644 index 00000000..3551a831 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysPermWhitelist.java @@ -0,0 +1,33 @@ +package com.orangeforms.webadmin.upms.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +/** + * 白名单实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@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; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysPost.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysPost.java new file mode 100644 index 00000000..4a75033f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysPost.java @@ -0,0 +1,48 @@ +package com.orangeforms.webadmin.upms.model; + +import com.baomidou.mybatisplus.annotation.*; +import com.orangeforms.common.core.base.model.BaseModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 岗位实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName(value = "zz_sys_post") +public class SysPost extends BaseModel { + + /** + * 岗位Id。 + */ + @TableId(value = "post_id") + private Long postId; + + /** + * 岗位名称。 + */ + @TableField(value = "post_name") + private String postName; + + /** + * 岗位层级,数值越小级别越高。 + */ + @TableField(value = "post_level") + private Integer postLevel; + + /** + * 是否领导岗位。 + */ + @TableField(value = "leader_post") + private Boolean leaderPost; + + /** + * postId 的多对多关联表数据对象。 + */ + @TableField(exist = false) + private SysDeptPost sysDeptPost; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysRole.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysRole.java new file mode 100644 index 00000000..a51dabbd --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysRole.java @@ -0,0 +1,39 @@ +package com.orangeforms.webadmin.upms.model; + +import com.baomidou.mybatisplus.annotation.*; +import com.orangeforms.common.core.annotation.RelationManyToMany; +import com.orangeforms.common.core.base.model.BaseModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.*; + +/** + * 角色实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName(value = "zz_sys_role") +public class SysRole extends BaseModel { + + /** + * 角色Id。 + */ + @TableId(value = "role_id") + private Long roleId; + + /** + * 角色名称。 + */ + @TableField(value = "role_name") + private String roleName; + + @RelationManyToMany( + relationMasterIdField = "roleId", + relationModelClass = SysRoleMenu.class) + @TableField(exist = false) + private List sysRoleMenuList; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysRoleMenu.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysRoleMenu.java new file mode 100644 index 00000000..35e065ed --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysRoleMenu.java @@ -0,0 +1,27 @@ +package com.orangeforms.webadmin.upms.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +/** + * 角色菜单实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@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; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysUser.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysUser.java new file mode 100644 index 00000000..372dee3a --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysUser.java @@ -0,0 +1,171 @@ +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 lombok.Data; + +import java.util.Date; +import java.util.Map; +import java.util.List; + +/** + * 用户管理实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@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; + + /** + * 用户部门Id。 + */ + @TableField(value = "dept_id") + private Long deptId; + + /** + * 用户显示名称。 + */ + @TableField(value = "show_name") + private String showName; + + /** + * 用户类型(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; + + /** + * 用户邮箱。 + */ + private String email; + + /** + * 用户手机。 + */ + private String mobile; + + /** + * 创建者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; + + /** + * 逻辑删除标记字段(1: 正常 -1: 已删除)。 + */ + @TableLogic + @TableField(value = "deleted_flag") + private Integer deletedFlag; + + /** + * createTime 范围过滤起始值(>=)。 + */ + @TableField(exist = false) + private String createTimeStart; + + /** + * createTime 范围过滤结束值(<=)。 + */ + @TableField(exist = false) + private String createTimeEnd; + + /** + * 多对多用户部门岗位数据集合。 + */ + @RelationManyToMany( + relationMasterIdField = "userId", + relationModelClass = SysUserPost.class) + @TableField(exist = false) + private List sysUserPostList; + + /** + * 多对多用户角色数据集合。 + */ + @RelationManyToMany( + relationMasterIdField = "userId", + relationModelClass = SysUserRole.class) + @TableField(exist = false) + private List sysUserRoleList; + + /** + * 多对多用户数据权限数据集合。 + */ + @RelationManyToMany( + relationMasterIdField = "userId", + relationModelClass = SysDataPermUser.class) + @TableField(exist = false) + private List sysDataPermUserList; + + @RelationDict( + masterIdField = "deptId", + slaveModelClass = SysDept.class, + slaveIdField = "deptId", + slaveNameField = "deptName") + @TableField(exist = false) + private Map deptIdDictMap; + + @RelationConstDict( + masterIdField = "userType", + constantDictClass = SysUserType.class) + @TableField(exist = false) + private Map userTypeDictMap; + + @RelationConstDict( + masterIdField = "userStatus", + constantDictClass = SysUserStatus.class) + @TableField(exist = false) + private Map userStatusDictMap; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysUserPost.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysUserPost.java new file mode 100644 index 00000000..b696f93e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysUserPost.java @@ -0,0 +1,33 @@ +package com.orangeforms.webadmin.upms.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +/** + * 用户岗位多对多关系实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@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; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysUserRole.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysUserRole.java new file mode 100644 index 00000000..62623c70 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/SysUserRole.java @@ -0,0 +1,27 @@ +package com.orangeforms.webadmin.upms.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +/** + * 用户角色实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@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; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysMenuType.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysMenuType.java new file mode 100644 index 00000000..6108183d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysMenuType.java @@ -0,0 +1,54 @@ +package com.orangeforms.webadmin.upms.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 菜单类型常量对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +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 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() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysOnlineMenuPermType.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysOnlineMenuPermType.java new file mode 100644 index 00000000..752ce7dd --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysOnlineMenuPermType.java @@ -0,0 +1,44 @@ +package com.orangeforms.webadmin.upms.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 菜单关联在线表单的控制权限类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class SysOnlineMenuPermType { + + /** + * 查看。 + */ + public static final int TYPE_VIEW = 0; + /** + * 编辑。 + */ + public static final int TYPE_EDIT = 1; + + private static final Map 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() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysUserStatus.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysUserStatus.java new file mode 100644 index 00000000..b71dd0aa --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysUserStatus.java @@ -0,0 +1,44 @@ +package com.orangeforms.webadmin.upms.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 用户状态常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class SysUserStatus { + + /** + * 正常状态。 + */ + public static final int STATUS_NORMAL = 0; + /** + * 锁定状态。 + */ + public static final int STATUS_LOCKED = 1; + + private static final Map DICT_MAP = new HashMap<>(2); + static { + DICT_MAP.put(STATUS_NORMAL, "正常状态"); + DICT_MAP.put(STATUS_LOCKED, "锁定状态"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private SysUserStatus() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysUserType.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysUserType.java new file mode 100644 index 00000000..ee6fa852 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/model/constant/SysUserType.java @@ -0,0 +1,49 @@ +package com.orangeforms.webadmin.upms.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 用户类型常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class SysUserType { + + /** + * 管理员。 + */ + public static final int TYPE_ADMIN = 0; + /** + * 系统操作员。 + */ + public static final int TYPE_SYSTEM = 1; + /** + * 普通操作员。 + */ + public static final int TYPE_OPERATOR = 2; + + private static final Map DICT_MAP = new HashMap<>(3); + static { + DICT_MAP.put(TYPE_ADMIN, "管理员"); + DICT_MAP.put(TYPE_SYSTEM, "系统操作员"); + DICT_MAP.put(TYPE_OPERATOR, "普通操作员"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private SysUserType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysDataPermService.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysDataPermService.java new file mode 100644 index 00000000..0dff4fa6 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysDataPermService.java @@ -0,0 +1,114 @@ +package com.orangeforms.webadmin.upms.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.webadmin.upms.model.*; + +import java.util.*; + +/** + * 数据权限数据服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysDataPermService extends IBaseService { + + /** + * 保存新增的数据权限对象。 + * + * @param dataPerm 新增的数据权限对象。 + * @param deptIdSet 关联的部门Id列表。 + * @param menuIdSet 关联的菜单Id列表。 + * @return 新增后的数据权限对象。 + */ + SysDataPerm saveNew(SysDataPerm dataPerm, Set deptIdSet, Set menuIdSet); + + /** + * 更新数据权限对象。 + * + * @param dataPerm 更新的数据权限对象。 + * @param originalDataPerm 原有的数据权限对象。 + * @param deptIdSet 关联的部门Id列表。 + * @param menuIdSet 关联的菜单Id列表。 + * @return 更新成功返回true,否则false。 + */ + boolean update(SysDataPerm dataPerm, SysDataPerm originalDataPerm, Set deptIdSet, Set menuIdSet); + + /** + * 删除指定数据权限。 + * + * @param dataPermId 数据权限主键Id。 + * @return 删除成功返回true,否则false。 + */ + boolean remove(Long dataPermId); + + /** + * 获取数据权限列表及其关联数据。 + * + * @param filter 数据权限过滤对象。 + * @param orderBy 排序参数。 + * @return 数据权限查询列表。 + */ + List getSysDataPermListWithRelation(SysDataPerm filter, String orderBy); + + /** + * 将指定用户的指定会话的数据权限集合存入缓存。 + * + * @param sessionId 会话Id。 + * @param userId 用户主键Id。 + * @param deptId 用户所属部门主键Id。 + */ + void putDataPermCache(String sessionId, Long userId, Long deptId); + + /** + * 将指定会话的数据权限集合从缓存中移除。 + * + * @param sessionId 会话Id。 + */ + void removeDataPermCache(String sessionId); + + /** + * 获取指定用户Id的数据权限列表。并基于menuId和权限规则类型进行了一级分组。 + * + * @param userId 指定的用户Id。 + * @param deptId 用户所属部门主键Id。 + * @return 合并优化后的数据权限列表。返回格式为,Map>。 + */ + Map> getSysDataPermListByUserId(Long userId, Long deptId); + + /** + * 查询与指定菜单关联的数据权限列表。 + * + * @param menuId 菜单Id。 + * @return 与菜单Id关联的数据权限列表。 + */ + List getSysDataPermListByMenuId(Long menuId); + + /** + * 添加用户和数据权限之间的多对多关联关系。 + * + * @param dataPermId 数据权限Id。 + * @param userIdSet 关联的用户Id列表。 + */ + void addDataPermUserList(Long dataPermId, Set userIdSet); + + /** + * 移除用户和数据权限之间的多对多关联关系。 + * + * @param dataPermId 数据权限主键Id。 + * @param userId 用户主键Id。 + * @return true移除成功,否则false。 + */ + boolean removeDataPermUser(Long dataPermId, Long userId); + + /** + * 验证数据权限对象关联菜单数据是否都合法。 + * + * @param dataPerm 数据权限关对象。 + * @param deptIdListString 与数据权限关联的部门Id列表。 + * @param menuIdListString 与数据权限关联的菜单Id列表。 + * @return 验证结果。 + */ + CallResult verifyRelatedData(SysDataPerm dataPerm, String deptIdListString, String menuIdListString); +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysDeptService.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysDeptService.java new file mode 100644 index 00000000..2a485df5 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysDeptService.java @@ -0,0 +1,170 @@ +package com.orangeforms.webadmin.upms.service; + +import com.orangeforms.webadmin.upms.model.*; +import com.orangeforms.common.core.base.service.IBaseService; + +import java.util.*; + +/** + * 部门管理数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysDeptService extends IBaseService { + + /** + * 保存新增的部门对象。 + * + * @param sysDept 新增的部门对象。 + * @param parentSysDept 上级部门对象。 + * @return 新增后的部门对象。 + */ + SysDept saveNew(SysDept sysDept, SysDept parentSysDept); + + /** + * 更新部门对象。 + * + * @param sysDept 更新的部门对象。 + * @param originalSysDept 原有的部门对象。 + * @return 更新成功返回true,否则false。 + */ + boolean update(SysDept sysDept, SysDept originalSysDept); + + /** + * 删除指定数据。 + * + * @param deptId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long deptId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getSysDeptListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getSysDeptList(SysDept filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getSysDeptList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getSysDeptListWithRelation(SysDept filter, String orderBy); + + /** + * 判断指定对象是否包含下级对象。 + * + * @param deptId 主键Id。 + * @return 存在返回true,否则false。 + */ + boolean hasChildren(Long deptId); + + /** + * 判断指定部门Id是否包含用户对象。 + * + * @param deptId 部门主键Id。 + * @return 存在返回true,否则false。 + */ + boolean hasChildrenUser(Long deptId); + + /** + * 批量添加多对多关联关系。 + * + * @param sysDeptPostList 多对多关联表对象集合。 + * @param deptId 主表Id。 + */ + void addSysDeptPostList(List sysDeptPostList, Long deptId); + + /** + * 更新中间表数据。 + * + * @param sysDeptPost 中间表对象。 + * @return 更新成功与否。 + */ + boolean updateSysDeptPost(SysDeptPost sysDeptPost); + + /** + * 移除单条多对多关系。 + * + * @param deptId 主表Id。 + * @param postId 从表Id。 + * @return 成功返回true,否则false。 + */ + boolean removeSysDeptPost(Long deptId, Long postId); + + /** + * 获取中间表数据。 + * + * @param deptId 主表Id。 + * @param postId 从表Id。 + * @return 中间表对象。 + */ + SysDeptPost getSysDeptPost(Long deptId, Long postId); + + /** + * 根据部门岗位Id获取部门岗位关联对象。 + * + * @param deptPostId 部门岗位Id。 + * @return 部门岗位对象。 + */ + SysDeptPost getSysDeptPost(Long deptPostId); + + /** + * 获取指定部门Id的部门岗位多对多关联数据列表,以及关联的部门和岗位数据。 + * + * @param deptId 部门Id。如果参数为空则返回全部数据。 + * @return 部门岗位多对多数据列表。 + */ + List> getSysDeptPostListWithRelationByDeptId(Long deptId); + + /** + * 获取指定部门Id和岗位Id集合的部门岗位多对多关联数据列表。 + * + * @param deptId 部门Id。 + * @param postIdSet 指定的岗位Id集合。 + * @return 部门岗位多对多数据列表。 + */ + List getSysDeptPostList(Long deptId, Set postIdSet); + + /** + * 获取与指定部门Id同级部门和岗位Id集合的部门岗位多对多关联数据列表。 + * + * @param deptId 部门Id。 + * @param postIdSet 指定的岗位Id集合。 + * @return 部门岗位多对多数据列表。 + */ + List getSiblingSysDeptPostList(Long deptId, Set postIdSet); + + /** + * 根据部门Id获取该部门领导岗位的部门岗位Id集合。 + * + * @param deptId 部门Id。 + * @return 部门领导岗位的部门岗位Id集合。 + */ + List getLeaderDeptPostIdList(Long deptId); + + /** + * 根据部门Id获取上级部门领导岗位的部门岗位Id集合。 + * + * @param deptId 部门Id。 + * @return 上级部门领导岗位的部门岗位Id集合。 + */ + List getUpLeaderDeptPostIdList(Long deptId); + + /** + * 根据父主键Id列表,获取当前部门Id及其所有下级部门Id列表。 + * + * @param parentIds 父主键Id列表。 + * @return 获取当前部门Id及其所有下级部门Id列表。 + */ + List getAllChildDeptIdByParentIds(List parentIds); +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysMenuService.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysMenuService.java new file mode 100644 index 00000000..7c39d7e8 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysMenuService.java @@ -0,0 +1,72 @@ +package com.orangeforms.webadmin.upms.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.webadmin.upms.model.SysMenu; + +import java.util.*; + +/** + * 菜单数据服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysMenuService extends IBaseService { + + /** + * 保存新增的菜单对象。 + * + * @param sysMenu 新增的菜单对象。 + * @return 新增后的菜单对象。 + */ + SysMenu saveNew(SysMenu sysMenu); + + /** + * 更新菜单对象。 + * + * @param sysMenu 更新的菜单对象。 + * @param originalSysMenu 原有的菜单对象。 + * @return 更新成功返回true,否则false。 + */ + boolean update(SysMenu sysMenu, SysMenu originalSysMenu); + + /** + * 删除指定的菜单。 + * + * @param menu 菜单对象。 + * @return 删除成功返回true,否则false。 + */ + boolean remove(SysMenu menu); + + /** + * 获取指定用户Id的菜单列表,已去重。 + * + * @param userId 用户主键Id。 + * @return 用户关联的菜单列表。 + */ + Collection getMenuListByUserId(Long userId); + + /** + * 根据角色Id集合获取菜单对象列表。 + * + * @param roleIds 逗号分隔的角色Id集合。 + * @return 菜单对象列表。 + */ + Collection getMenuListByRoleIds(String roleIds); + + /** + * 判断当前菜单是否存在子菜单。 + * + * @param menuId 菜单主键Id。 + * @return 存在返回true,否则false。 + */ + boolean hasChildren(Long menuId); + + /** + * 获取指定类型的所有在线表单的菜单。 + * + * @param menuType 菜单类型,NULL则返回全部类型。 + * @return 在线表单关联的菜单列表。 + */ + List getAllOnlineMenuList(Integer menuType); +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysPermWhitelistService.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysPermWhitelistService.java new file mode 100644 index 00000000..84dab9fa --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysPermWhitelistService.java @@ -0,0 +1,23 @@ +package com.orangeforms.webadmin.upms.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.webadmin.upms.model.SysPermWhitelist; + +import java.util.List; + +/** + * 权限资源白名单数据服务接口。 + * 白名单中的权限资源,可以不受权限控制,任何用户皆可访问,一般用于常用的字典数据列表接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysPermWhitelistService extends IBaseService { + + /** + * 获取白名单权限资源的列表。 + * + * @return 白名单权限资源地址列表。 + */ + List getWhitelistPermList(); +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysPostService.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysPostService.java new file mode 100644 index 00000000..71165759 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysPostService.java @@ -0,0 +1,99 @@ +package com.orangeforms.webadmin.upms.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.webadmin.upms.model.SysPost; +import com.orangeforms.webadmin.upms.model.SysUserPost; + +import java.util.*; + +/** + * 岗位管理数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysPostService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param sysPost 新增对象。 + * @return 返回新增对象。 + */ + SysPost saveNew(SysPost sysPost); + + /** + * 更新数据对象。 + * + * @param sysPost 更新的对象。 + * @param originalSysPost 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(SysPost sysPost, SysPost originalSysPost); + + /** + * 删除指定数据。 + * + * @param postId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long postId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getSysPostListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getSysPostList(SysPost filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getSysPostList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getSysPostListWithRelation(SysPost filter, String orderBy); + + /** + * 在多对多关系中,当前Service的数据表为从表,返回不与指定主表主键Id存在对多对关系的列表。 + * + * @param deptId 主表主键Id。 + * @param filter 从表的过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getNotInSysPostListByDeptId(Long deptId, SysPost filter, String orderBy); + + /** + * 获取指定部门的岗位列表。 + * + * @param deptId 部门Id。 + * @param filter 从表的过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getSysPostListByDeptId(Long deptId, SysPost filter, String orderBy); + + /** + * 获取指定用户的用户岗位多对多关联数据列表。 + * + * @param userId 用户Id。 + * @return 用户岗位多对多关联数据列表。 + */ + List getSysUserPostListByUserId(Long userId); + + /** + * 判断指定的部门岗位Id集合是否都属于指定的部门Id。 + * + * @param deptPostIdSet 部门岗位Id集合。 + * @param deptId 部门Id。 + * @return 全部是返回true,否则false。 + */ + boolean existAllPrimaryKeys(Set deptPostIdSet, Long deptId); +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysRoleService.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysRoleService.java new file mode 100644 index 00000000..1f6762d7 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysRoleService.java @@ -0,0 +1,87 @@ +package com.orangeforms.webadmin.upms.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.webadmin.upms.model.SysRole; +import com.orangeforms.webadmin.upms.model.SysUserRole; + +import java.util.*; + +/** + * 角色数据服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysRoleService extends IBaseService { + + /** + * 保存新增的角色对象。 + * + * @param role 新增的角色对象。 + * @param menuIdSet 菜单Id列表。 + * @return 新增后的角色对象。 + */ + SysRole saveNew(SysRole role, Set menuIdSet); + + /** + * 更新角色对象。 + * + * @param role 更新的角色对象。 + * @param originalRole 原有的角色对象。 + * @param menuIdSet 菜单Id列表。 + * @return 更新成功返回true,否则false。 + */ + boolean update(SysRole role, SysRole originalRole, Set menuIdSet); + + /** + * 删除指定角色。 + * + * @param roleId 角色主键Id。 + * @return 删除成功返回true,否则false。 + */ + boolean remove(Long roleId); + + /** + * 获取角色列表。 + * + * @param filter 角色过滤对象。 + * @param orderBy 排序参数。 + * @return 角色列表。 + */ + List getSysRoleList(SysRole filter, String orderBy); + + /** + * 获取用户的用户角色对象列表。 + * + * @param userId 用户Id。 + * @return 用户角色对象列表。 + */ + List getSysUserRoleListByUserId(Long userId); + + /** + * 批量新增用户角色关联。 + * + * @param userRoleList 用户角色关系数据列表。 + */ + void addUserRoleList(List userRoleList); + + /** + * 移除指定用户和指定角色的关联关系。 + * + * @param roleId 角色主键Id。 + * @param userId 用户主键Id。 + * @return 移除成功返回true,否则false。 + */ + boolean removeUserRole(Long roleId, Long userId); + + /** + * 验证角色对象关联的数据是否都合法。 + * + * @param sysRole 当前操作的对象。 + * @param originalSysRole 原有对象。 + * @param menuIdListString 逗号分隔的menuId列表。 + * @return 验证结果。 + */ + CallResult verifyRelatedData(SysRole sysRole, SysRole originalSysRole, String menuIdListString); +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysUserService.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysUserService.java new file mode 100644 index 00000000..15fa2ea2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/SysUserService.java @@ -0,0 +1,176 @@ +package com.orangeforms.webadmin.upms.service; + +import com.orangeforms.webadmin.upms.model.*; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.base.service.IBaseService; + +import java.util.*; + +/** + * 用户管理数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysUserService extends IBaseService { + + /** + * 获取指定登录名的用户对象。 + * + * @param loginName 指定登录用户名。 + * @return 用户对象。 + */ + SysUser getSysUserByLoginName(String loginName); + + /** + * 保存新增的用户对象。 + * + * @param user 新增的用户对象。 + * @param roleIdSet 用户角色Id集合。 + * @param deptPostIdSet 部门岗位Id集合。 + * @param dataPermIdSet 数据权限Id集合。 + * @return 新增后的用户对象。 + */ + SysUser saveNew(SysUser user, Set roleIdSet, Set deptPostIdSet, Set dataPermIdSet); + + /** + * 更新用户对象。 + * + * @param user 更新的用户对象。 + * @param originalUser 原有的用户对象。 + * @param roleIdSet 用户角色Id列表。 + * @param deptPostIdSet 部门岗位Id集合。 + * @param dataPermIdSet 数据权限Id集合。 + * @return 更新成功返回true,否则false。 + */ + boolean update(SysUser user, SysUser originalUser, Set roleIdSet, Set deptPostIdSet, Set dataPermIdSet); + + /** + * 修改用户密码。 + * @param userId 用户主键Id。 + * @param newPass 新密码。 + * @return 成功返回true,否则false。 + */ + boolean changePassword(Long userId, String newPass); + + /** + * 修改用户头像。 + * + * @param userId 用户主键Id。 + * @param newHeadImage 新的头像信息。 + * @return 成功返回true,否则false。 + */ + boolean changeHeadImage(Long userId, String newHeadImage); + + /** + * 删除指定数据。 + * + * @param userId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long userId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getSysUserListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getSysUserList(SysUser filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getSysUserList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getSysUserListWithRelation(SysUser filter, String orderBy); + + /** + * 获取指定角色的用户列表。 + * + * @param roleId 角色主键Id。 + * @param filter 用户过滤对象。 + * @param orderBy 排序参数。 + * @return 用户列表。 + */ + List getSysUserListByRoleId(Long roleId, SysUser filter, String orderBy); + + /** + * 获取不属于指定角色的用户列表。 + * + * @param roleId 角色主键Id。 + * @param filter 用户过滤对象。 + * @param orderBy 排序参数。 + * @return 用户列表。 + */ + List getNotInSysUserListByRoleId(Long roleId, SysUser filter, String orderBy); + + /** + * 获取指定数据权限的用户列表。 + * + * @param dataPermId 数据权限主键Id。 + * @param filter 用户过滤对象。 + * @param orderBy 排序参数。 + * @return 用户列表。 + */ + List getSysUserListByDataPermId(Long dataPermId, SysUser filter, String orderBy); + + /** + * 获取不属于指定数据权限的用户列表。 + * + * @param dataPermId 数据权限主键Id。 + * @param filter 用户过滤对象。 + * @param orderBy 排序参数。 + * @return 用户列表。 + */ + List getNotInSysUserListByDataPermId(Long dataPermId, SysUser filter, String orderBy); + + /** + * 获取指定部门岗位的用户列表。 + * + * @param deptPostId 部门岗位主键Id。 + * @param filter 用户过滤对象。 + * @param orderBy 排序参数。 + * @return 用户列表。 + */ + List getSysUserListByDeptPostId(Long deptPostId, SysUser filter, String orderBy); + + /** + * 获取不属于指定部门岗位的用户列表。 + * + * @param deptPostId 部门岗位主键Id。 + * @param filter 用户过滤对象。 + * @param orderBy 排序参数。 + * @return 用户列表。 + */ + List getNotInSysUserListByDeptPostId(Long deptPostId, SysUser filter, String orderBy); + + /** + * 获取指定岗位的用户列表。 + * + * @param postId 岗位主键Id。 + * @param filter 用户过滤对象。 + * @param orderBy 排序参数。 + * @return 用户列表。 + */ + List getSysUserListByPostId(Long postId, SysUser filter, String orderBy); + + /** + * 验证用户对象关联的数据是否都合法。 + * + * @param sysUser 当前操作的对象。 + * @param originalSysUser 原有对象。 + * @param roleIds 逗号分隔的角色Id列表字符串。 + * @param deptPostIds 逗号分隔的部门岗位Id列表字符串。 + * @param dataPermIds 逗号分隔的数据权限Id列表字符串。 + * @return 验证结果。 + */ + CallResult verifyRelatedData( + SysUser sysUser, SysUser originalSysUser, String roleIds, String deptPostIds, String dataPermIds); +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysDataPermServiceImpl.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysDataPermServiceImpl.java new file mode 100644 index 00000000..6e4a4e61 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysDataPermServiceImpl.java @@ -0,0 +1,345 @@ +package com.orangeforms.webadmin.upms.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.core.constant.DataPermRuleType; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.RedisKeyUtil; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.webadmin.config.ApplicationConfig; +import com.orangeforms.webadmin.upms.dao.SysDataPermDeptMapper; +import com.orangeforms.webadmin.upms.dao.SysDataPermMapper; +import com.orangeforms.webadmin.upms.dao.SysDataPermUserMapper; +import com.orangeforms.webadmin.upms.dao.SysDataPermMenuMapper; +import com.orangeforms.webadmin.upms.model.*; +import com.orangeforms.webadmin.upms.service.SysDataPermService; +import com.orangeforms.webadmin.upms.service.SysDeptService; +import com.orangeforms.webadmin.upms.service.SysMenuService; +import com.orangeforms.webadmin.upms.service.SysUserService; +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.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +/** + * 数据权限数据服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Service("sysDataPermService") +public class SysDataPermServiceImpl extends BaseService implements SysDataPermService { + + @Autowired + private SysDataPermMapper sysDataPermMapper; + @Autowired + private SysDataPermDeptMapper sysDataPermDeptMapper; + @Autowired + private SysDataPermUserMapper sysDataPermUserMapper; + @Autowired + private SysDataPermMenuMapper sysDataPermMenuMapper; + @Autowired + private SysUserService sysUserService; + @Autowired + private SysDeptService sysDeptService; + @Autowired + private SysMenuService sysMenuService; + @Autowired + private RedissonClient redissonClient; + @Autowired + private ApplicationConfig applicationConfig; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回主对象的Mapper对象。 + * + * @return 主对象的Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return sysDataPermMapper; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public SysDataPerm saveNew(SysDataPerm dataPerm, Set deptIdSet, Set menuIdSet) { + dataPerm.setDataPermId(idGenerator.nextLongId()); + MyModelUtil.fillCommonsForInsert(dataPerm); + sysDataPermMapper.insert(dataPerm); + this.insertRelationData(dataPerm, deptIdSet, menuIdSet); + return dataPerm; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update( + SysDataPerm dataPerm, SysDataPerm originalDataPerm, Set deptIdSet, Set menuIdSet) { + MyModelUtil.fillCommonsForUpdate(dataPerm, originalDataPerm); + UpdateWrapper uw = this.createUpdateQueryForNullValue(dataPerm, dataPerm.getDataPermId()); + if (sysDataPermMapper.update(dataPerm, uw) != 1) { + return false; + } + SysDataPermDept dataPermDept = new SysDataPermDept(); + dataPermDept.setDataPermId(dataPerm.getDataPermId()); + sysDataPermDeptMapper.delete(new QueryWrapper<>(dataPermDept)); + SysDataPermMenu dataPermMenu = new SysDataPermMenu(); + dataPermMenu.setDataPermId(dataPerm.getDataPermId()); + sysDataPermMenuMapper.delete(new QueryWrapper<>(dataPermMenu)); + this.insertRelationData(dataPerm, deptIdSet, menuIdSet); + return true; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long dataPermId) { + if (sysDataPermMapper.deleteById(dataPermId) != 1) { + return false; + } + SysDataPermDept dataPermDept = new SysDataPermDept(); + dataPermDept.setDataPermId(dataPermId); + sysDataPermDeptMapper.delete(new QueryWrapper<>(dataPermDept)); + SysDataPermUser dataPermUser = new SysDataPermUser(); + dataPermUser.setDataPermId(dataPermId); + sysDataPermUserMapper.delete(new QueryWrapper<>(dataPermUser)); + SysDataPermMenu dataPermMenu = new SysDataPermMenu(); + dataPermMenu.setDataPermId(dataPermId); + sysDataPermMenuMapper.delete(new QueryWrapper<>(dataPermMenu)); + return true; + } + + @Override + public List getSysDataPermListWithRelation(SysDataPerm filter, String orderBy) { + List resultList = sysDataPermMapper.getSysDataPermList(filter, orderBy); + buildRelationForDataList(resultList, MyRelationParam.full(), CollUtil.newHashSet("dataPermDeptList")); + return resultList; + } + + @Override + public void putDataPermCache(String sessionId, Long userId, Long deptId) { + Map> menuDataPermMap = getSysDataPermListByUserId(userId, deptId); + if (menuDataPermMap.size() > 0) { + String dataPermSessionKey = RedisKeyUtil.makeSessionDataPermIdKey(sessionId); + RBucket bucket = redissonClient.getBucket(dataPermSessionKey); + bucket.set(JSON.toJSONString(menuDataPermMap), + applicationConfig.getSessionExpiredSeconds(), TimeUnit.SECONDS); + } + } + + @Override + public void removeDataPermCache(String sessionId) { + String sessionPermKey = RedisKeyUtil.makeSessionDataPermIdKey(sessionId); + redissonClient.getBucket(sessionPermKey).deleteAsync(); + } + + @Override + public Map> getSysDataPermListByUserId(Long userId, Long deptId) { + List dataPermList = sysDataPermMapper.getSysDataPermListByUserId(userId); + dataPermList.forEach(dataPerm -> { + if (CollUtil.isNotEmpty(dataPerm.getDataPermDeptList())) { + Set deptIdSet = dataPerm.getDataPermDeptList().stream() + .map(SysDataPermDept::getDeptId).collect(Collectors.toSet()); + dataPerm.setDeptIdListString(StrUtil.join(",", deptIdSet)); + } + }); + Map> menuIdMap = new HashMap<>(4); + for (SysDataPerm dataPerm : dataPermList) { + if (CollUtil.isNotEmpty(dataPerm.getDataPermMenuList())) { + for (SysDataPermMenu dataPermMenu : dataPerm.getDataPermMenuList()) { + menuIdMap.computeIfAbsent( + dataPermMenu.getMenuId().toString(), k -> new LinkedList<>()).add(dataPerm); + } + } else { + menuIdMap.computeIfAbsent( + ApplicationConstant.DATA_PERM_ALL_MENU_ID, k -> new LinkedList<>()).add(dataPerm); + } + } + Map> menuResultMap = new HashMap<>(menuIdMap.size()); + for (Map.Entry> entry : menuIdMap.entrySet()) { + Map resultMap = this.mergeAndOptimizeDataPermRule(entry.getValue(), deptId); + menuResultMap.put(entry.getKey(), resultMap); + } + return menuResultMap; + } + + @Override + public List getSysDataPermListByMenuId(Long menuId) { + return sysDataPermMapper.getSysDataPermListByMenuId(menuId); + } + + private Map mergeAndOptimizeDataPermRule(List dataPermList, Long deptId) { + // 为了更方便进行后续的合并优化处理,这里再基于菜单Id和规则类型进行分组。ruleMap的key是规则类型。 + Map> ruleMap = + dataPermList.stream().collect(Collectors.groupingBy(SysDataPerm::getRuleType)); + Map resultMap = new HashMap<>(ruleMap.size()); + // 如有有ALL存在,就可以直接退出了,没有必要在处理后续的规则了。 + if (ruleMap.containsKey(DataPermRuleType.TYPE_ALL)) { + resultMap.put(DataPermRuleType.TYPE_ALL, "null"); + return resultMap; + } + // 这里优先合并最复杂的多部门及子部门场景。 + String deptIds = processMultiDeptAndChildren(ruleMap, deptId); + if (deptIds != null) { + resultMap.put(DataPermRuleType.TYPE_MULTI_DEPT_AND_CHILD_DEPT, deptIds); + } + // 合并当前部门及子部门的优化 + if (ruleMap.get(DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT) != null) { + // 需要与仅仅当前部门规则进行合并。 + ruleMap.remove(DataPermRuleType.TYPE_DEPT_ONLY); + resultMap.put(DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT, "null"); + } + // 合并自定义部门了。 + deptIds = processMultiDept(ruleMap, deptId); + if (deptIds != null) { + resultMap.put(DataPermRuleType.TYPE_CUSTOM_DEPT_LIST, deptIds); + } + // 最后处理当前部门和当前用户。 + if (ruleMap.get(DataPermRuleType.TYPE_DEPT_ONLY) != null) { + resultMap.put(DataPermRuleType.TYPE_DEPT_ONLY, "null"); + } + if (ruleMap.get(DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT_USERS) != null) { + // 合并当前部门用户和当前用户 + ruleMap.remove(DataPermRuleType.TYPE_USER_ONLY); + ruleMap.remove(DataPermRuleType.TYPE_DEPT_USERS); + SysUser filter = new SysUser(); + filter.setDeptId(deptId); + List userList = sysUserService.getSysUserList(filter, null); + Set userIdSet = userList.stream().map(SysUser::getUserId).collect(Collectors.toSet()); + resultMap.put(DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT_USERS, CollUtil.join(userIdSet, ",")); + } + if (ruleMap.get(DataPermRuleType.TYPE_DEPT_USERS) != null) { + SysUser filter = new SysUser(); + filter.setDeptId(deptId); + List userList = sysUserService.getListByFilter(filter); + Set userIdSet = userList.stream().map(SysUser::getUserId).collect(Collectors.toSet()); + // 合并仅当前用户 + ruleMap.remove(DataPermRuleType.TYPE_USER_ONLY); + resultMap.put(DataPermRuleType.TYPE_DEPT_USERS, CollUtil.join(userIdSet, ",")); + } + if (ruleMap.get(DataPermRuleType.TYPE_USER_ONLY) != null) { + resultMap.put(DataPermRuleType.TYPE_USER_ONLY, "null"); + } + return resultMap; + } + + private String processMultiDeptAndChildren(Map> ruleMap, Long deptId) { + List parentDeptList = ruleMap.get(DataPermRuleType.TYPE_MULTI_DEPT_AND_CHILD_DEPT); + if (parentDeptList == null) { + return null; + } + Set deptIdSet = new HashSet<>(); + for (SysDataPerm parentDept : parentDeptList) { + deptIdSet.addAll(StrUtil.split(parentDept.getDeptIdListString(), ',') + .stream().map(Long::valueOf).collect(Collectors.toSet())); + } + // 在合并所有的多父部门Id之后,需要判断是否有本部门及子部门的规则。如果有,就继续合并。 + if (ruleMap.containsKey(DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT)) { + // 如果多父部门列表中包含当前部门,那么可以直接删除该规则了,如果没包含,就加入到多部门的DEPT_ID的IN LIST中。 + deptIdSet.add(deptId); + ruleMap.remove(DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT); + } + // 需要与仅仅当前部门规则进行合并。 + if (ruleMap.containsKey(DataPermRuleType.TYPE_DEPT_ONLY) && deptIdSet.contains(deptId)) { + ruleMap.remove(DataPermRuleType.TYPE_DEPT_ONLY); + } + return StrUtil.join(",", deptIdSet); + } + + private String processMultiDept(Map> ruleMap, Long deptId) { + List customDeptList = ruleMap.get(DataPermRuleType.TYPE_CUSTOM_DEPT_LIST); + if (customDeptList == null) { + return null; + } + Set deptIdSet = new HashSet<>(); + for (SysDataPerm customDept : customDeptList) { + deptIdSet.addAll(StrUtil.split(customDept.getDeptIdListString(), ',') + .stream().map(Long::valueOf).collect(Collectors.toSet())); + } + if (ruleMap.containsKey(DataPermRuleType.TYPE_DEPT_ONLY)) { + deptIdSet.add(deptId); + ruleMap.remove(DataPermRuleType.TYPE_DEPT_ONLY); + } + return StrUtil.join(",", deptIdSet); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void addDataPermUserList(Long dataPermId, Set userIdSet) { + for (Long userId : userIdSet) { + SysDataPermUser dataPermUser = new SysDataPermUser(); + dataPermUser.setDataPermId(dataPermId); + dataPermUser.setUserId(userId); + sysDataPermUserMapper.insert(dataPermUser); + } + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean removeDataPermUser(Long dataPermId, Long userId) { + SysDataPermUser dataPermUser = new SysDataPermUser(); + dataPermUser.setDataPermId(dataPermId); + dataPermUser.setUserId(userId); + return sysDataPermUserMapper.delete(new QueryWrapper<>(dataPermUser)) == 1; + } + + @Override + public CallResult verifyRelatedData(SysDataPerm dataPerm, String deptIdListString, String menuIdListString) { + JSONObject jsonObject = new JSONObject(); + if (dataPerm.getRuleType() == DataPermRuleType.TYPE_MULTI_DEPT_AND_CHILD_DEPT + || dataPerm.getRuleType() == DataPermRuleType.TYPE_CUSTOM_DEPT_LIST) { + if (StrUtil.isBlank(deptIdListString)) { + return CallResult.error("数据验证失败,部门列表不能为空!"); + } + Set deptIdSet = StrUtil.split( + deptIdListString, ",").stream().map(Long::valueOf).collect(Collectors.toSet()); + if (!sysDeptService.existAllPrimaryKeys(deptIdSet)) { + return CallResult.error("数据验证失败,存在不合法的部门数据,请刷新后重试!"); + } + jsonObject.put("deptIdSet", deptIdSet); + } + if (StrUtil.isNotBlank(menuIdListString)) { + Set menuIdSet = StrUtil.split( + menuIdListString, ",").stream().map(Long::valueOf).collect(Collectors.toSet()); + if (!sysMenuService.existAllPrimaryKeys(menuIdSet)) { + return CallResult.error("数据验证失败,存在不合法的菜单数据,请刷新后重试!"); + } + jsonObject.put("menuIdSet", menuIdSet); + } + return CallResult.ok(jsonObject); + } + + private void insertRelationData(SysDataPerm dataPerm, Set deptIdSet, Set menuIdSet) { + if (CollUtil.isNotEmpty(deptIdSet)) { + for (Long deptId : deptIdSet) { + SysDataPermDept dataPermDept = new SysDataPermDept(); + dataPermDept.setDataPermId(dataPerm.getDataPermId()); + dataPermDept.setDeptId(deptId); + sysDataPermDeptMapper.insert(dataPermDept); + } + } + if (CollUtil.isNotEmpty(menuIdSet)) { + for (Long menuId : menuIdSet) { + SysDataPermMenu dataPermMenu = new SysDataPermMenu(); + dataPermMenu.setDataPermId(dataPerm.getDataPermId()); + dataPermMenu.setMenuId(menuId); + sysDataPermMenuMapper.insert(dataPermMenu); + } + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysDeptServiceImpl.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysDeptServiceImpl.java new file mode 100644 index 00000000..a23bd997 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysDeptServiceImpl.java @@ -0,0 +1,316 @@ +package com.orangeforms.webadmin.upms.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.*; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.webadmin.upms.service.*; +import com.orangeforms.webadmin.upms.dao.*; +import com.orangeforms.webadmin.upms.model.*; +import com.orangeforms.common.ext.util.BizWidgetDatasourceExtHelper; +import com.orangeforms.common.ext.base.BizWidgetDatasource; +import com.orangeforms.common.ext.constant.BizWidgetDatasourceType; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.constant.GlobalDeletedFlag; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.github.pagehelper.Page; +import lombok.extern.slf4j.Slf4j; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import jakarta.annotation.PostConstruct; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 部门管理数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Service("sysDeptService") +public class SysDeptServiceImpl extends BaseService implements SysDeptService, BizWidgetDatasource { + + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private SysDeptMapper sysDeptMapper; + @Autowired + private SysDeptRelationMapper sysDeptRelationMapper; + @Autowired + private SysUserService sysUserService; + @Autowired + private SysDeptPostMapper sysDeptPostMapper; + @Autowired + private SysDataPermDeptMapper sysDataPermDeptMapper; + @Autowired + private BizWidgetDatasourceExtHelper bizWidgetDatasourceExtHelper; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return sysDeptMapper; + } + + @PostConstruct + private void registerBizWidgetDatasource() { + bizWidgetDatasourceExtHelper.registerDatasource(BizWidgetDatasourceType.UPMS_DEPT_TYPE, this); + } + + @Override + public MyPageData> getDataList( + String type, Map filter, MyOrderParam orderParam, MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount()); + } + String orderBy = orderParam == null ? null : MyOrderParam.buildOrderBy(orderParam, SysDept.class); + SysDept deptFilter = filter == null ? null : BeanUtil.toBean(filter, SysDept.class); + List deptList = this.getSysDeptList(deptFilter, orderBy); + this.buildRelationForDataList(deptList, MyRelationParam.dictOnly()); + return MyPageUtil.makeResponseData(deptList, BeanUtil::beanToMap); + } + + @Override + public List> getDataListWithInList(String type, String fieldName, List fieldValues) { + List deptList; + if (StrUtil.isBlank(fieldName)) { + deptList = this.getInList(fieldValues.stream().map(Long::valueOf).collect(Collectors.toSet())); + } else { + deptList = this.getInList(fieldName, MyModelUtil.convertToTypeValues(SysDept.class, fieldName, fieldValues)); + } + this.buildRelationForDataList(deptList, MyRelationParam.dictOnly()); + return MyModelUtil.beanToMapList(deptList); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public SysDept saveNew(SysDept sysDept, SysDept parentSysDept) { + sysDept.setDeptId(idGenerator.nextLongId()); + sysDept.setDeletedFlag(GlobalDeletedFlag.NORMAL); + MyModelUtil.fillCommonsForInsert(sysDept); + sysDeptMapper.insert(sysDept); + // 同步插入部门关联关系数据 + if (parentSysDept == null) { + sysDeptRelationMapper.insert(new SysDeptRelation(sysDept.getDeptId(), sysDept.getDeptId())); + } else { + sysDeptRelationMapper.insertParentList(parentSysDept.getDeptId(), sysDept.getDeptId()); + } + return sysDept; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(SysDept sysDept, SysDept originalSysDept) { + MyModelUtil.fillCommonsForUpdate(sysDept, originalSysDept); + UpdateWrapper uw = this.createUpdateQueryForNullValue(sysDept, sysDept.getDeptId()); + if (sysDeptMapper.update(sysDept, uw) == 0) { + return false; + } + if (ObjectUtil.notEqual(sysDept.getParentId(), originalSysDept.getParentId())) { + this.updateParentRelation(sysDept, originalSysDept); + } + return true; + } + + private void updateParentRelation(SysDept sysDept, SysDept originalSysDept) { + List originalParentIdList = null; + // 1. 因为层级关系变化了,所以要先遍历出,当前部门的原有父部门Id列表。 + if (originalSysDept.getParentId() != null) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(SysDeptRelation::getDeptId, sysDept.getDeptId()); + List relationList = sysDeptRelationMapper.selectList(queryWrapper); + originalParentIdList = relationList.stream() + .filter(c -> !c.getParentDeptId().equals(sysDept.getDeptId())) + .map(SysDeptRelation::getParentDeptId).collect(Collectors.toList()); + } + // 2. 毕竟当前部门的上级部门变化了,所以当前部门和他的所有子部门,与当前部门的原有所有上级部门 + // 之间的关联关系就要被移除。 + // 这里先移除当前部门的所有子部门,与当前部门的所有原有上级部门之间的关联关系。 + if (CollUtil.isNotEmpty(originalParentIdList)) { + sysDeptRelationMapper.removeBetweenChildrenAndParents(originalParentIdList, sysDept.getDeptId()); + } + // 这里更进一步,将当前部门Id与其原有所有上级部门Id之间的关联关系删除。 + SysDeptRelation filter = new SysDeptRelation(); + filter.setDeptId(sysDept.getDeptId()); + sysDeptRelationMapper.delete(new QueryWrapper<>(filter)); + // 3. 重新计算当前部门的新上级部门列表。 + List newParentIdList = new LinkedList<>(); + // 这里要重新计算出当前部门所有新的上级部门Id列表。 + if (sysDept.getParentId() != null) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(SysDeptRelation::getDeptId, sysDept.getParentId()); + List relationList = sysDeptRelationMapper.selectList(queryWrapper); + newParentIdList = relationList.stream() + .map(SysDeptRelation::getParentDeptId).collect(Collectors.toList()); + } + // 4. 先查询出当前部门的所有下级子部门Id列表。 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(SysDeptRelation::getParentDeptId, sysDept.getDeptId()); + List childRelationList = sysDeptRelationMapper.selectList(queryWrapper); + // 5. 将当前部门及其所有子部门Id与其新的所有上级部门Id之间,建立关联关系。 + List deptRelationList = new LinkedList<>(); + deptRelationList.add(new SysDeptRelation(sysDept.getDeptId(), sysDept.getDeptId())); + for (Long newParentId : newParentIdList) { + deptRelationList.add(new SysDeptRelation(newParentId, sysDept.getDeptId())); + for (SysDeptRelation childDeptRelation : childRelationList) { + deptRelationList.add(new SysDeptRelation(newParentId, childDeptRelation.getDeptId())); + } + } + // 6. 执行批量插入SQL语句,插入当前部门Id及其所有下级子部门Id,与所有新上级部门Id之间的关联关系。 + sysDeptRelationMapper.insertList(deptRelationList); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long deptId) { + if (sysDeptMapper.deleteById(deptId) == 0) { + return false; + } + // 这里删除当前部门及其父部门的关联关系。 + // 当前部门和子部门的关系无需在这里删除,因为包含子部门时不能删除父部门。 + SysDeptRelation deptRelation = new SysDeptRelation(); + deptRelation.setDeptId(deptId); + sysDeptRelationMapper.delete(new QueryWrapper<>(deptRelation)); + SysDataPermDept dataPermDept = new SysDataPermDept(); + dataPermDept.setDeptId(deptId); + sysDataPermDeptMapper.delete(new QueryWrapper<>(dataPermDept)); + return true; + } + + @Override + public List getSysDeptList(SysDept filter, String orderBy) { + return sysDeptMapper.getSysDeptList(filter, orderBy); + } + + @Override + public List getSysDeptListWithRelation(SysDept filter, String orderBy) { + List resultList = sysDeptMapper.getSysDeptList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + @Override + public boolean hasChildren(Long deptId) { + SysDept filter = new SysDept(); + filter.setParentId(deptId); + return getCountByFilter(filter) > 0; + } + + @Override + public boolean hasChildrenUser(Long deptId) { + SysUser sysUser = new SysUser(); + sysUser.setDeptId(deptId); + return sysUserService.getCountByFilter(sysUser) > 0; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void addSysDeptPostList(List sysDeptPostList, Long deptId) { + for (SysDeptPost sysDeptPost : sysDeptPostList) { + sysDeptPost.setDeptPostId(idGenerator.nextLongId()); + sysDeptPost.setDeptId(deptId); + sysDeptPostMapper.insert(sysDeptPost); + } + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean updateSysDeptPost(SysDeptPost sysDeptPost) { + SysDeptPost filter = new SysDeptPost(); + filter.setDeptPostId(sysDeptPost.getDeptPostId()); + filter.setDeptId(sysDeptPost.getDeptId()); + filter.setPostId(sysDeptPost.getPostId()); + UpdateWrapper uw = + BaseService.createUpdateQueryForNullValue(sysDeptPost, SysDeptPost.class); + uw.setEntity(filter); + return sysDeptPostMapper.update(sysDeptPost, uw) > 0; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean removeSysDeptPost(Long deptId, Long postId) { + SysDeptPost filter = new SysDeptPost(); + filter.setDeptId(deptId); + filter.setPostId(postId); + return sysDeptPostMapper.delete(new QueryWrapper<>(filter)) > 0; + } + + @Override + public SysDeptPost getSysDeptPost(Long deptId, Long postId) { + SysDeptPost filter = new SysDeptPost(); + filter.setDeptId(deptId); + filter.setPostId(postId); + return sysDeptPostMapper.selectOne(new QueryWrapper<>(filter)); + } + + @Override + public SysDeptPost getSysDeptPost(Long deptPostId) { + return sysDeptPostMapper.selectById(deptPostId); + } + + @Override + public List> getSysDeptPostListWithRelationByDeptId(Long deptId) { + return sysDeptPostMapper.getSysDeptPostListWithRelationByDeptId(deptId); + } + + @Override + public List getSysDeptPostList(Long deptId, Set postIdSet) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(SysDeptPost::getDeptId, deptId); + queryWrapper.in(SysDeptPost::getPostId, postIdSet); + return sysDeptPostMapper.selectList(queryWrapper); + } + + @Override + public List getSiblingSysDeptPostList(Long deptId, Set postIdSet) { + SysDept sysDept = this.getById(deptId); + if (sysDept == null) { + return new LinkedList<>(); + } + List deptList = this.getListByParentId("parentId", sysDept.getParentId()); + Set deptIdSet = deptList.stream().map(SysDept::getDeptId).collect(Collectors.toSet()); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.in(SysDeptPost::getDeptId, deptIdSet); + queryWrapper.in(SysDeptPost::getPostId, postIdSet); + return sysDeptPostMapper.selectList(queryWrapper); + } + + @Override + public List getLeaderDeptPostIdList(Long deptId) { + List resultList = sysDeptPostMapper.getLeaderDeptPostList(deptId); + return resultList.stream().map(SysDeptPost::getDeptPostId).collect(Collectors.toList()); + } + + @Override + public List getUpLeaderDeptPostIdList(Long deptId) { + SysDept sysDept = this.getById(deptId); + if (sysDept.getParentId() == null) { + return new LinkedList<>(); + } + return this.getLeaderDeptPostIdList(sysDept.getParentId()); + } + + @Override + public List getAllChildDeptIdByParentIds(List parentIds) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.in(SysDeptRelation::getParentDeptId, parentIds); + return sysDeptRelationMapper.selectList(queryWrapper) + .stream().map(SysDeptRelation::getDeptId).collect(Collectors.toList()); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysMenuServiceImpl.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysMenuServiceImpl.java new file mode 100644 index 00000000..35c70a11 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysMenuServiceImpl.java @@ -0,0 +1,239 @@ +package com.orangeforms.webadmin.upms.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.webadmin.upms.bo.SysMenuExtraData; +import com.orangeforms.webadmin.upms.dao.SysMenuMapper; +import com.orangeforms.webadmin.upms.dao.SysRoleMenuMapper; +import com.orangeforms.webadmin.upms.model.SysMenu; +import com.orangeforms.webadmin.upms.model.SysRoleMenu; +import com.orangeforms.webadmin.upms.model.constant.SysMenuType; +import com.orangeforms.webadmin.upms.model.constant.SysOnlineMenuPermType; +import com.orangeforms.webadmin.upms.service.SysMenuService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 菜单数据服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Service("sysMenuService") +public class SysMenuServiceImpl extends BaseService implements SysMenuService { + + @Autowired + private SysMenuMapper sysMenuMapper; + @Autowired + private SysRoleMenuMapper sysRoleMenuMapper; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回主对象的Mapper对象。 + * + * @return 主对象的Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return sysMenuMapper; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public SysMenu saveNew(SysMenu sysMenu) { + sysMenu.setMenuId(idGenerator.nextLongId()); + MyModelUtil.fillCommonsForInsert(sysMenu); + sysMenuMapper.insert(sysMenu); + // 判断当前菜单是否为指向在线表单的菜单,并将根据约定,动态插入两个子菜单。 + if (sysMenu.getOnlineFormId() != null && sysMenu.getOnlineFlowEntryId() == null) { + SysMenu viewSubMenu = new SysMenu(); + viewSubMenu.setMenuId(idGenerator.nextLongId()); + viewSubMenu.setParentId(sysMenu.getMenuId()); + viewSubMenu.setMenuType(SysMenuType.TYPE_BUTTON); + viewSubMenu.setMenuName("查看"); + viewSubMenu.setShowOrder(0); + viewSubMenu.setOnlineFormId(sysMenu.getOnlineFormId()); + viewSubMenu.setOnlineMenuPermType(SysOnlineMenuPermType.TYPE_VIEW); + MyModelUtil.fillCommonsForInsert(viewSubMenu); + sysMenuMapper.insert(viewSubMenu); + SysMenu editSubMenu = new SysMenu(); + editSubMenu.setMenuId(idGenerator.nextLongId()); + editSubMenu.setParentId(sysMenu.getMenuId()); + editSubMenu.setMenuType(SysMenuType.TYPE_BUTTON); + editSubMenu.setMenuName("编辑"); + editSubMenu.setShowOrder(1); + editSubMenu.setOnlineFormId(sysMenu.getOnlineFormId()); + editSubMenu.setOnlineMenuPermType(SysOnlineMenuPermType.TYPE_EDIT); + MyModelUtil.fillCommonsForInsert(editSubMenu); + sysMenuMapper.insert(editSubMenu); + } + return sysMenu; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(SysMenu sysMenu, SysMenu originalSysMenu) { + MyModelUtil.fillCommonsForUpdate(sysMenu, originalSysMenu); + sysMenu.setMenuType(originalSysMenu.getMenuType()); + UpdateWrapper uw = this.createUpdateQueryForNullValue(sysMenu, sysMenu.getMenuId()); + if (sysMenuMapper.update(sysMenu, uw) != 1) { + return false; + } + // 如果当前菜单的在线表单Id变化了,就需要同步更新他的内置子菜单也同步更新。 + if (ObjectUtil.notEqual(originalSysMenu.getOnlineFormId(), sysMenu.getOnlineFormId())) { + SysMenu onlineSubMenu = new SysMenu(); + onlineSubMenu.setOnlineFormId(sysMenu.getOnlineFormId()); + sysMenuMapper.update(onlineSubMenu, + new QueryWrapper().lambda().eq(SysMenu::getParentId, sysMenu.getMenuId())); + } + return true; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(SysMenu menu) { + Long menuId = menu.getMenuId(); + if (sysMenuMapper.delete(new LambdaQueryWrapper().eq(SysMenu::getMenuId, menuId)) != 1) { + return false; + } + SysRoleMenu roleMenu = new SysRoleMenu(); + roleMenu.setMenuId(menuId); + sysRoleMenuMapper.delete(new QueryWrapper<>(roleMenu)); + // 如果为指向在线表单的菜单,则连同删除子菜单 + if (menu.getOnlineFormId() != null) { + SysMenu filter = new SysMenu(); + filter.setParentId(menuId); + List childMenus = sysMenuMapper.selectList(new QueryWrapper<>(filter)); + sysMenuMapper.delete(new LambdaQueryWrapper().eq(SysMenu::getParentId, menuId)); + if (CollUtil.isNotEmpty(childMenus)) { + List childMenuIds = childMenus.stream().map(SysMenu::getMenuId).collect(Collectors.toList()); + LambdaQueryWrapper qw = new LambdaQueryWrapper<>(); + qw.in(SysRoleMenu::getMenuId, childMenuIds); + sysRoleMenuMapper.delete(qw); + } + } + return true; + } + + @Override + public Collection getMenuListByUserId(Long userId) { + List menuList = sysMenuMapper.getMenuListByUserId(userId); + return this.distinctMenuList(menuList); + } + + @Override + public Collection getMenuListByRoleIds(String roleIds) { + if (StrUtil.isBlank(roleIds)) { + return CollUtil.empty(Long.class); + } + Set roleIdSet = StrUtil.split(roleIds, ",").stream().map(Long::valueOf).collect(Collectors.toSet()); + List menuList = sysMenuMapper.getMenuListByRoleIds(roleIdSet); + return this.distinctMenuList(menuList); + } + + @Override + public boolean hasChildren(Long menuId) { + SysMenu menu = new SysMenu(); + menu.setParentId(menuId); + return this.getCountByFilter(menu) > 0; + } + + @Override + public CallResult verifyRelatedData(SysMenu sysMenu, SysMenu originalSysMenu) { + // menu、ui fragment和button类型的menu不能没有parentId + if (sysMenu.getParentId() == null && sysMenu.getMenuType() != SysMenuType.TYPE_DIRECTORY) { + return CallResult.error("数据验证失败,当前类型菜单项的上级菜单不能为空!"); + } + if (this.needToVerify(sysMenu, originalSysMenu, SysMenu::getParentId)) { + String errorMessage = checkErrorOfNonDirectoryMenu(sysMenu); + if (errorMessage != null) { + return CallResult.error(errorMessage); + } + } + if (!this.verifyMenuCode(sysMenu, originalSysMenu)) { + return CallResult.error("数据验证失败,菜单编码已存在,不能重复使用!"); + } + return CallResult.ok(); + } + + @Override + public List getAllOnlineMenuList(Integer menuType) { + LambdaQueryWrapper queryWrapper = + new QueryWrapper().lambda().isNotNull(SysMenu::getOnlineFormId); + if (menuType != null) { + queryWrapper.eq(SysMenu::getMenuType, menuType); + } + return sysMenuMapper.selectList(queryWrapper); + } + + private boolean verifyMenuCode(SysMenu sysMenu, SysMenu originalSysMenu) { + if (sysMenu.getExtraData() == null) { + return true; + } + String menuCode = JSON.parseObject(sysMenu.getExtraData(), SysMenuExtraData.class).getMenuCode(); + if (StrUtil.isBlank(menuCode)) { + return true; + } + String originalMenuCode = ""; + if (originalSysMenu != null && originalSysMenu.getExtraData() != null) { + originalMenuCode = JSON.parseObject(originalSysMenu.getExtraData(), SysMenuExtraData.class).getMenuCode(); + } + return StrUtil.equals(menuCode, originalMenuCode) + || sysMenuMapper.countMenuCode("\"menuCode\":\"" + menuCode + "\"") == 0; + } + + private String checkErrorOfNonDirectoryMenu(SysMenu sysMenu) { + // 判断父节点是否存在 + SysMenu parentSysMenu = getById(sysMenu.getParentId()); + if (parentSysMenu == null) { + return "数据验证失败,关联的上级菜单并不存在,请刷新后重试!"; + } + // 逐个判断每种类型的菜单,他的父菜单的合法性,先从目录类型和菜单类型开始 + if (sysMenu.getMenuType() == SysMenuType.TYPE_DIRECTORY + || sysMenu.getMenuType() == SysMenuType.TYPE_MENU) { + // 他们的上级只能是目录 + if (parentSysMenu.getMenuType() != SysMenuType.TYPE_DIRECTORY) { + return "数据验证失败,当前类型菜单项的上级菜单只能是目录类型!"; + } + } else if (sysMenu.getMenuType() == SysMenuType.TYPE_UI_FRAGMENT) { + // ui fragment的上级只能是menu类型 + if (parentSysMenu.getMenuType() != SysMenuType.TYPE_MENU) { + return "数据验证失败,当前类型菜单项的上级菜单只能是菜单类型和按钮类型!"; + } + } else if (sysMenu.getMenuType() == SysMenuType.TYPE_BUTTON) { + // button的上级只能是menu和ui fragment + if (parentSysMenu.getMenuType() != SysMenuType.TYPE_MENU + && parentSysMenu.getMenuType() != SysMenuType.TYPE_UI_FRAGMENT) { + return "数据验证失败,当前类型菜单项的上级菜单只能是菜单类型和UI片段类型!"; + } + } else { + return "数据验证失败,不支持的菜单类型!"; + } + return null; + } + + private Collection distinctMenuList(List menuList) { + LinkedHashMap menuMap = new LinkedHashMap<>(); + for (SysMenu menu : menuList) { + menuMap.put(menu.getMenuId(), menu); + } + return menuMap.values(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysPermWhitelistServiceImpl.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysPermWhitelistServiceImpl.java new file mode 100644 index 00000000..69c4abb6 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysPermWhitelistServiceImpl.java @@ -0,0 +1,47 @@ +package com.orangeforms.webadmin.upms.service.impl; + +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.webadmin.upms.dao.SysPermWhitelistMapper; +import com.orangeforms.webadmin.upms.model.SysPermWhitelist; +import com.orangeforms.webadmin.upms.service.SysPermWhitelistService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 权限资源白名单数据服务类。 + * 白名单中的权限资源,可以不受权限控制,任何用户皆可访问,一般用于常用的字典数据列表接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Service("sysPermWhitelistService") +public class SysPermWhitelistServiceImpl extends BaseService implements SysPermWhitelistService { + + @Autowired + private SysPermWhitelistMapper sysPermWhitelistMapper; + + /** + * 返回主对象的Mapper对象。 + * + * @return 主对象的Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return sysPermWhitelistMapper; + } + + @Override + public List getWhitelistPermList() { + List dataList = this.getAllList(); + Function getterFunc = SysPermWhitelist::getPermUrl; + return dataList.stream() + .filter(x -> getterFunc.apply(x) != null).map(getterFunc).collect(Collectors.toList()); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysPostServiceImpl.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysPostServiceImpl.java new file mode 100644 index 00000000..edac3465 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysPostServiceImpl.java @@ -0,0 +1,186 @@ +package com.orangeforms.webadmin.upms.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.github.pagehelper.Page; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.object.MyOrderParam; +import com.orangeforms.common.core.object.MyPageData; +import com.orangeforms.common.core.object.MyPageParam; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.ext.base.BizWidgetDatasource; +import com.orangeforms.common.ext.constant.BizWidgetDatasourceType; +import com.orangeforms.common.ext.util.BizWidgetDatasourceExtHelper; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.webadmin.upms.dao.SysDeptPostMapper; +import com.orangeforms.webadmin.upms.dao.SysPostMapper; +import com.orangeforms.webadmin.upms.dao.SysUserPostMapper; +import com.orangeforms.webadmin.upms.model.SysDeptPost; +import com.orangeforms.webadmin.upms.model.SysPost; +import com.orangeforms.webadmin.upms.model.SysUserPost; +import com.orangeforms.webadmin.upms.service.SysDeptService; +import com.orangeforms.webadmin.upms.service.SysPostService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.Assert; + +import jakarta.annotation.PostConstruct; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 岗位管理数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Service("sysPostService") +public class SysPostServiceImpl extends BaseService implements SysPostService, BizWidgetDatasource { + + @Autowired + private SysPostMapper sysPostMapper; + @Autowired + private SysUserPostMapper sysUserPostMapper; + @Autowired + private SysDeptPostMapper sysDeptPostMapper; + @Autowired + private SysDeptService sysDeptService; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private BizWidgetDatasourceExtHelper bizWidgetDatasourceExtHelper; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return sysPostMapper; + } + + @PostConstruct + private void registerBizWidgetDatasource() { + bizWidgetDatasourceExtHelper.registerDatasource(BizWidgetDatasourceType.UPMS_POST_TYPE, this); + bizWidgetDatasourceExtHelper.registerDatasource(BizWidgetDatasourceType.UPMS_DEPT_POST_TYPE, this); + } + + @Override + public MyPageData> getDataList( + String type, Map filter, MyOrderParam orderParam, MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount()); + } + String orderBy = orderParam == null ? null : MyOrderParam.buildOrderBy(orderParam, SysPost.class); + SysPost postFilter = filter == null ? null : BeanUtil.toBean(filter, SysPost.class); + if (StrUtil.equals(type, BizWidgetDatasourceType.UPMS_POST_TYPE)) { + List postList = this.getSysPostList(postFilter, orderBy); + return MyPageUtil.makeResponseData(postList, BeanUtil::beanToMap); + } + Assert.notNull(filter, "filter can't be NULL."); + Long deptId = (Long) filter.get("deptId"); + List> dataList = sysDeptService.getSysDeptPostListWithRelationByDeptId(deptId); + return MyPageUtil.makeResponseData(dataList); + } + + @Override + public List> getDataListWithInList(String type, String fieldName, List fieldValues) { + List postList; + if (StrUtil.isBlank(fieldName)) { + postList = this.getInList(fieldValues.stream().map(Long::valueOf).collect(Collectors.toSet())); + } else { + postList = this.getInList(fieldName, MyModelUtil.convertToTypeValues(SysPost.class, fieldName, fieldValues)); + } + return MyModelUtil.beanToMapList(postList); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public SysPost saveNew(SysPost sysPost) { + sysPost.setPostId(idGenerator.nextLongId()); + MyModelUtil.fillCommonsForInsert(sysPost); + MyModelUtil.setDefaultValue(sysPost, "leaderPost", false); + sysPostMapper.insert(sysPost); + return sysPost; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(SysPost sysPost, SysPost originalSysPost) { + MyModelUtil.fillCommonsForUpdate(sysPost, originalSysPost); + // 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。 + UpdateWrapper uw = this.createUpdateQueryForNullValue(sysPost, sysPost.getPostId()); + return sysPostMapper.update(sysPost, uw) == 1; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long postId) { + if (sysPostMapper.deleteById(postId) != 1) { + return false; + } + // 开始删除多对多父表的关联 + SysUserPost sysUserPost = new SysUserPost(); + sysUserPost.setPostId(postId); + sysUserPostMapper.delete(new QueryWrapper<>(sysUserPost)); + SysDeptPost sysDeptPost = new SysDeptPost(); + sysDeptPost.setPostId(postId); + sysDeptPostMapper.delete(new QueryWrapper<>(sysDeptPost)); + return true; + } + + @Override + public List getSysPostList(SysPost filter, String orderBy) { + return sysPostMapper.getSysPostList(filter, orderBy); + } + + @Override + public List getSysPostListWithRelation(SysPost filter, String orderBy) { + List resultList = sysPostMapper.getSysPostList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + @Override + public List getNotInSysPostListByDeptId(Long deptId, SysPost filter, String orderBy) { + List resultList = sysPostMapper.getNotInSysPostListByDeptId(deptId, filter, orderBy); + this.buildRelationForDataList(resultList, MyRelationParam.dictOnly()); + return resultList; + } + + @Override + public List getSysPostListByDeptId(Long deptId, SysPost filter, String orderBy) { + List resultList = sysPostMapper.getSysPostListByDeptId(deptId, filter, orderBy); + this.buildRelationForDataList(resultList, MyRelationParam.dictOnly()); + return resultList; + } + + @Override + public List getSysUserPostListByUserId(Long userId) { + SysUserPost filter = new SysUserPost(); + filter.setUserId(userId); + return sysUserPostMapper.selectList(new QueryWrapper<>(filter)); + } + + @Override + public boolean existAllPrimaryKeys(Set deptPostIdSet, Long deptId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(SysDeptPost::getDeptId, deptId); + queryWrapper.in(SysDeptPost::getDeptPostId, deptPostIdSet); + return sysDeptPostMapper.selectCount(queryWrapper) == deptPostIdSet.size(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysRoleServiceImpl.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysRoleServiceImpl.java new file mode 100644 index 00000000..1edc6b44 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysRoleServiceImpl.java @@ -0,0 +1,192 @@ +package com.orangeforms.webadmin.upms.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.alibaba.fastjson.JSONObject; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.ext.base.BizWidgetDatasource; +import com.orangeforms.common.ext.constant.BizWidgetDatasourceType; +import com.orangeforms.common.ext.util.BizWidgetDatasourceExtHelper; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.webadmin.upms.dao.SysRoleMapper; +import com.orangeforms.webadmin.upms.dao.SysRoleMenuMapper; +import com.orangeforms.webadmin.upms.dao.SysUserRoleMapper; +import com.orangeforms.webadmin.upms.model.SysRole; +import com.orangeforms.webadmin.upms.model.SysRoleMenu; +import com.orangeforms.webadmin.upms.model.SysUserRole; +import com.orangeforms.webadmin.upms.service.SysMenuService; +import com.orangeforms.webadmin.upms.service.SysRoleService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import jakarta.annotation.PostConstruct; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 角色数据服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Service("sysRoleService") +public class SysRoleServiceImpl extends BaseService implements SysRoleService, BizWidgetDatasource { + + @Autowired + private SysRoleMapper sysRoleMapper; + @Autowired + private SysRoleMenuMapper sysRoleMenuMapper; + @Autowired + private SysUserRoleMapper sysUserRoleMapper; + @Autowired + private SysMenuService sysMenuService; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private BizWidgetDatasourceExtHelper bizWidgetDatasourceExtHelper; + + /** + * 返回主对象的Mapper对象。 + * + * @return 主对象的Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return sysRoleMapper; + } + + @PostConstruct + private void registerBizWidgetDatasource() { + bizWidgetDatasourceExtHelper.registerDatasource(BizWidgetDatasourceType.UPMS_ROLE_TYPE, this); + } + + @Override + public MyPageData> getDataList( + String type, Map filter, MyOrderParam orderParam, MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount()); + } + String orderBy = orderParam == null ? null : MyOrderParam.buildOrderBy(orderParam, SysRole.class); + SysRole roleFilter = filter == null ? null : BeanUtil.toBean(filter, SysRole.class); + List roleList = this.getSysRoleList(roleFilter, orderBy); + return MyPageUtil.makeResponseData(roleList, BeanUtil::beanToMap); + } + + @Override + public List> getDataListWithInList(String type, String fieldName, List fieldValues) { + List roleList; + if (StrUtil.isBlank(fieldName)) { + roleList = this.getInList(fieldValues.stream().map(Long::valueOf).collect(Collectors.toSet())); + } else { + roleList = this.getInList(fieldName, MyModelUtil.convertToTypeValues(SysRole.class, fieldName, fieldValues)); + } + return MyModelUtil.beanToMapList(roleList); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public SysRole saveNew(SysRole role, Set menuIdSet) { + role.setRoleId(idGenerator.nextLongId()); + MyModelUtil.fillCommonsForInsert(role); + sysRoleMapper.insert(role); + if (menuIdSet != null) { + for (Long menuId : menuIdSet) { + SysRoleMenu roleMenu = new SysRoleMenu(); + roleMenu.setRoleId(role.getRoleId()); + roleMenu.setMenuId(menuId); + sysRoleMenuMapper.insert(roleMenu); + } + } + return role; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(SysRole role, SysRole originalRole, Set menuIdSet) { + MyModelUtil.fillCommonsForUpdate(role, originalRole); + if (sysRoleMapper.updateById(role) != 1) { + return false; + } + SysRoleMenu deletedRoleMenu = new SysRoleMenu(); + deletedRoleMenu.setRoleId(role.getRoleId()); + sysRoleMenuMapper.delete(new QueryWrapper<>(deletedRoleMenu)); + if (menuIdSet != null) { + for (Long menuId : menuIdSet) { + SysRoleMenu roleMenu = new SysRoleMenu(); + roleMenu.setRoleId(role.getRoleId()); + roleMenu.setMenuId(menuId); + sysRoleMenuMapper.insert(roleMenu); + } + } + return true; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long roleId) { + if (sysRoleMapper.deleteById(roleId) != 1) { + return false; + } + SysRoleMenu roleMenu = new SysRoleMenu(); + roleMenu.setRoleId(roleId); + sysRoleMenuMapper.delete(new QueryWrapper<>(roleMenu)); + SysUserRole userRole = new SysUserRole(); + userRole.setRoleId(roleId); + sysUserRoleMapper.delete(new QueryWrapper<>(userRole)); + return true; + } + + @Override + public List getSysRoleList(SysRole filter, String orderBy) { + return sysRoleMapper.getSysRoleList(filter, orderBy); + } + + @Override + public List getSysUserRoleListByUserId(Long userId) { + SysUserRole filter = new SysUserRole(); + filter.setUserId(userId); + return sysUserRoleMapper.selectList(new QueryWrapper<>(filter)); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void addUserRoleList(List userRoleList) { + for (SysUserRole userRole : userRoleList) { + sysUserRoleMapper.insert(userRole); + } + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean removeUserRole(Long roleId, Long userId) { + SysUserRole userRole = new SysUserRole(); + userRole.setRoleId(roleId); + userRole.setUserId(userId); + return sysUserRoleMapper.delete(new QueryWrapper<>(userRole)) == 1; + } + + @Override + public CallResult verifyRelatedData(SysRole sysRole, SysRole originalSysRole, String menuIdListString) { + JSONObject jsonObject = null; + if (StringUtils.isNotBlank(menuIdListString)) { + Set menuIdSet = Arrays.stream( + menuIdListString.split(",")).map(Long::valueOf).collect(Collectors.toSet()); + if (!sysMenuService.existAllPrimaryKeys(menuIdSet)) { + return CallResult.error("数据验证失败,存在不合法的菜单权限,请刷新后重试!"); + } + jsonObject = new JSONObject(); + jsonObject.put("menuIdSet", menuIdSet); + } + return CallResult.ok(jsonObject); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysUserServiceImpl.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysUserServiceImpl.java new file mode 100644 index 00000000..4e806bbe --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/service/impl/SysUserServiceImpl.java @@ -0,0 +1,384 @@ +package com.orangeforms.webadmin.upms.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.*; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.webadmin.upms.service.*; +import com.orangeforms.webadmin.upms.dao.*; +import com.orangeforms.webadmin.upms.model.*; +import com.orangeforms.webadmin.upms.model.constant.SysUserStatus; +import com.orangeforms.common.ext.util.BizWidgetDatasourceExtHelper; +import com.orangeforms.common.ext.base.BizWidgetDatasource; +import com.orangeforms.common.ext.constant.BizWidgetDatasourceType; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.constant.UserFilterGroup; +import com.orangeforms.common.core.constant.GlobalDeletedFlag; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.github.pagehelper.Page; +import lombok.extern.slf4j.Slf4j; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import jakarta.annotation.PostConstruct; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 用户管理数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Service("sysUserService") +public class SysUserServiceImpl extends BaseService implements SysUserService, BizWidgetDatasource { + + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private SysUserMapper sysUserMapper; + @Autowired + private SysUserRoleMapper sysUserRoleMapper; + @Autowired + private SysUserPostMapper sysUserPostMapper; + @Autowired + private SysDataPermUserMapper sysDataPermUserMapper; + @Autowired + private SysDeptService sysDeptService; + @Autowired + private SysRoleService sysRoleService; + @Autowired + private SysDataPermService sysDataPermService; + @Autowired + private SysPostService sysPostService; + @Autowired + private PasswordEncoder passwordEncoder; + @Autowired + private BizWidgetDatasourceExtHelper bizWidgetDatasourceExtHelper; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return sysUserMapper; + } + + @PostConstruct + private void registerBizWidgetDatasource() { + bizWidgetDatasourceExtHelper.registerDatasource(BizWidgetDatasourceType.UPMS_USER_TYPE, this); + } + + @Override + public MyPageData> getDataList( + String type, Map filter, MyOrderParam orderParam, MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount()); + } + List userList = null; + String orderBy = MyOrderParam.buildOrderBy(orderParam, SysUser.class, false); + SysUser userFilter = BeanUtil.toBean(filter, SysUser.class); + if (filter != null) { + Object group = filter.get("USER_FILTER_GROUP"); + if (group != null) { + JSONObject filterGroupJson = JSON.parseObject(group.toString()); + String groupType = filterGroupJson.getString("type"); + String values = filterGroupJson.getString("values"); + if (UserFilterGroup.USER.equals(groupType)) { + List loginNames = StrUtil.splitTrim(values, ","); + userList = sysUserMapper.getSysUserListByLoginNames(loginNames, userFilter, orderBy); + } else { + Set groupIds = StrUtil.splitTrim(values, ",") + .stream().map(Long::valueOf).collect(Collectors.toSet()); + userList = this.getUserListByGroupIds(groupType, groupIds, userFilter, orderBy); + } + } + } + if (userList == null) { + userList = this.getSysUserList(userFilter, orderBy); + } + this.buildRelationForDataList(userList, MyRelationParam.dictOnly()); + return MyPageUtil.makeResponseData(userList, BeanUtil::beanToMap); + } + + private List getUserListByGroupIds(String groupType, Set groupIds, SysUser filter, String orderBy) { + if (groupType.equals(UserFilterGroup.DEPT)) { + return sysUserMapper.getSysUserListByDeptIds(groupIds, filter, orderBy); + } + List userIds = null; + switch (groupType) { + case UserFilterGroup.ROLE: + userIds = sysUserMapper.getUserIdListByRoleIds(groupIds, filter, orderBy); + break; + case UserFilterGroup.POST: + userIds = sysUserMapper.getUserIdListByPostIds(groupIds, filter, orderBy); + break; + case UserFilterGroup.DEPT_POST: + userIds = sysUserMapper.getUserIdListByDeptPostIds(groupIds, filter, orderBy); + break; + default: + break; + } + if (CollUtil.isEmpty(userIds)) { + return CollUtil.empty(SysUser.class); + } + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.in(SysUser::getUserId, userIds); + if (StrUtil.isNotBlank(orderBy)) { + queryWrapper.last(" ORDER BY " + orderBy); + } + return sysUserMapper.selectList(queryWrapper); + } + + @Override + public List> getDataListWithInList(String type, String fieldName, List fieldValues) { + List userList; + if (StrUtil.isBlank(fieldName)) { + userList = this.getInList(fieldValues.stream().map(Long::valueOf).collect(Collectors.toSet())); + } else { + userList = this.getInList(fieldName, MyModelUtil.convertToTypeValues(SysUser.class, fieldName, fieldValues)); + } + this.buildRelationForDataList(userList, MyRelationParam.dictOnly()); + return MyModelUtil.beanToMapList(userList); + } + + /** + * 获取指定登录名的用户对象。 + * + * @param loginName 指定登录用户名。 + * @return 用户对象。 + */ + @Override + public SysUser getSysUserByLoginName(String loginName) { + SysUser filter = new SysUser(); + filter.setLoginName(loginName); + return sysUserMapper.selectOne(new QueryWrapper<>(filter)); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public SysUser saveNew(SysUser user, Set roleIdSet, Set deptPostIdSet, Set dataPermIdSet) { + user.setUserId(idGenerator.nextLongId()); + user.setPassword(passwordEncoder.encode(user.getPassword())); + user.setUserStatus(SysUserStatus.STATUS_NORMAL); + user.setDeletedFlag(GlobalDeletedFlag.NORMAL); + MyModelUtil.fillCommonsForInsert(user); + sysUserMapper.insert(user); + if (CollUtil.isNotEmpty(deptPostIdSet)) { + for (Long deptPostId : deptPostIdSet) { + SysDeptPost deptPost = sysDeptService.getSysDeptPost(deptPostId); + SysUserPost userPost = new SysUserPost(); + userPost.setUserId(user.getUserId()); + userPost.setDeptPostId(deptPostId); + userPost.setPostId(deptPost.getPostId()); + sysUserPostMapper.insert(userPost); + } + } + if (CollUtil.isNotEmpty(roleIdSet)) { + for (Long roleId : roleIdSet) { + SysUserRole userRole = new SysUserRole(); + userRole.setUserId(user.getUserId()); + userRole.setRoleId(roleId); + sysUserRoleMapper.insert(userRole); + } + } + if (CollUtil.isNotEmpty(dataPermIdSet)) { + for (Long dataPermId : dataPermIdSet) { + SysDataPermUser dataPermUser = new SysDataPermUser(); + dataPermUser.setDataPermId(dataPermId); + dataPermUser.setUserId(user.getUserId()); + sysDataPermUserMapper.insert(dataPermUser); + } + } + return user; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(SysUser user, SysUser originalUser, Set roleIdSet, Set deptPostIdSet, Set dataPermIdSet) { + user.setLoginName(originalUser.getLoginName()); + user.setPassword(originalUser.getPassword()); + MyModelUtil.fillCommonsForUpdate(user, originalUser); + UpdateWrapper uw = this.createUpdateQueryForNullValue(user, user.getUserId()); + if (sysUserMapper.update(user, uw) != 1) { + return false; + } + // 先删除原有的User-Post关联关系,再重新插入新的关联关系 + SysUserPost deletedUserPost = new SysUserPost(); + deletedUserPost.setUserId(user.getUserId()); + sysUserPostMapper.delete(new QueryWrapper<>(deletedUserPost)); + if (CollUtil.isNotEmpty(deptPostIdSet)) { + for (Long deptPostId : deptPostIdSet) { + SysDeptPost deptPost = sysDeptService.getSysDeptPost(deptPostId); + SysUserPost userPost = new SysUserPost(); + userPost.setUserId(user.getUserId()); + userPost.setDeptPostId(deptPostId); + userPost.setPostId(deptPost.getPostId()); + sysUserPostMapper.insert(userPost); + } + } + // 先删除原有的User-Role关联关系,再重新插入新的关联关系 + SysUserRole deletedUserRole = new SysUserRole(); + deletedUserRole.setUserId(user.getUserId()); + sysUserRoleMapper.delete(new QueryWrapper<>(deletedUserRole)); + if (CollUtil.isNotEmpty(roleIdSet)) { + for (Long roleId : roleIdSet) { + SysUserRole userRole = new SysUserRole(); + userRole.setUserId(user.getUserId()); + userRole.setRoleId(roleId); + sysUserRoleMapper.insert(userRole); + } + } + // 先删除原有的DataPerm-User关联关系,在重新插入新的关联关系 + SysDataPermUser deletedDataPermUser = new SysDataPermUser(); + deletedDataPermUser.setUserId(user.getUserId()); + sysDataPermUserMapper.delete(new QueryWrapper<>(deletedDataPermUser)); + if (CollUtil.isNotEmpty(dataPermIdSet)) { + for (Long dataPermId : dataPermIdSet) { + SysDataPermUser dataPermUser = new SysDataPermUser(); + dataPermUser.setDataPermId(dataPermId); + dataPermUser.setUserId(user.getUserId()); + sysDataPermUserMapper.insert(dataPermUser); + } + } + return true; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean changePassword(Long userId, String newPass) { + SysUser updatedUser = new SysUser(); + updatedUser.setUserId(userId); + updatedUser.setPassword(passwordEncoder.encode(newPass)); + return sysUserMapper.updateById(updatedUser) == 1; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean changeHeadImage(Long userId, String newHeadImage) { + SysUser updatedUser = new SysUser(); + updatedUser.setUserId(userId); + updatedUser.setHeadImageUrl(newHeadImage); + return sysUserMapper.updateById(updatedUser) == 1; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long userId) { + if (sysUserMapper.deleteById(userId) == 0) { + return false; + } + SysUserRole userRole = new SysUserRole(); + userRole.setUserId(userId); + sysUserRoleMapper.delete(new QueryWrapper<>(userRole)); + SysUserPost userPost = new SysUserPost(); + userPost.setUserId(userId); + sysUserPostMapper.delete(new QueryWrapper<>(userPost)); + SysDataPermUser dataPermUser = new SysDataPermUser(); + dataPermUser.setUserId(userId); + sysDataPermUserMapper.delete(new QueryWrapper<>(dataPermUser)); + return true; + } + + @Override + public List getSysUserList(SysUser filter, String orderBy) { + return sysUserMapper.getSysUserList(filter, orderBy); + } + + @Override + public List getSysUserListWithRelation(SysUser filter, String orderBy) { + List resultList = sysUserMapper.getSysUserList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + @Override + public List getSysUserListByRoleId(Long roleId, SysUser filter, String orderBy) { + return sysUserMapper.getSysUserListByRoleId(roleId, filter, orderBy); + } + + @Override + public List getNotInSysUserListByRoleId(Long roleId, SysUser filter, String orderBy) { + return sysUserMapper.getNotInSysUserListByRoleId(roleId, filter, orderBy); + } + + @Override + public List getSysUserListByDataPermId(Long dataPermId, SysUser filter, String orderBy) { + return sysUserMapper.getSysUserListByDataPermId(dataPermId, filter, orderBy); + } + + @Override + public List getNotInSysUserListByDataPermId(Long dataPermId, SysUser filter, String orderBy) { + return sysUserMapper.getNotInSysUserListByDataPermId(dataPermId, filter, orderBy); + } + + @Override + public List getSysUserListByDeptPostId(Long deptPostId, SysUser filter, String orderBy) { + return sysUserMapper.getSysUserListByDeptPostId(deptPostId, filter, orderBy); + } + + @Override + public List getNotInSysUserListByDeptPostId(Long deptPostId, SysUser filter, String orderBy) { + return sysUserMapper.getNotInSysUserListByDeptPostId(deptPostId, filter, orderBy); + } + + @Override + public List getSysUserListByPostId(Long postId, SysUser filter, String orderBy) { + return sysUserMapper.getSysUserListByPostId(postId, filter, orderBy); + } + + @Override + public CallResult verifyRelatedData( + SysUser sysUser, SysUser originalSysUser, String roleIds, String deptPostIds, String dataPermIds) { + JSONObject jsonObject = new JSONObject(); + if (StrUtil.isBlank(deptPostIds)) { + return CallResult.error("数据验证失败,用户的部门岗位数据不能为空!"); + } + Set deptPostIdSet = + Arrays.stream(deptPostIds.split(",")).map(Long::valueOf).collect(Collectors.toSet()); + if (!sysPostService.existAllPrimaryKeys(deptPostIdSet, sysUser.getDeptId())) { + return CallResult.error("数据验证失败,存在不合法的用户岗位,请刷新后重试!"); + } + jsonObject.put("deptPostIdSet", deptPostIdSet); + if (StrUtil.isBlank(roleIds)) { + return CallResult.error("数据验证失败,用户的角色数据不能为空!"); + } + Set roleIdSet = Arrays.stream( + roleIds.split(",")).map(Long::valueOf).collect(Collectors.toSet()); + if (!sysRoleService.existAllPrimaryKeys(roleIdSet)) { + return CallResult.error("数据验证失败,存在不合法的用户角色,请刷新后重试!"); + } + jsonObject.put("roleIdSet", roleIdSet); + if (StrUtil.isBlank(dataPermIds)) { + return CallResult.error("数据验证失败,用户的数据权限不能为空!"); + } + Set dataPermIdSet = Arrays.stream( + dataPermIds.split(",")).map(Long::valueOf).collect(Collectors.toSet()); + if (!sysDataPermService.existAllPrimaryKeys(dataPermIdSet)) { + return CallResult.error("数据验证失败,存在不合法的数据权限,请刷新后重试!"); + } + jsonObject.put("dataPermIdSet", dataPermIdSet); + //这里是基于字典的验证。 + if (this.needToVerify(sysUser, originalSysUser, SysUser::getDeptId) + && !sysDeptService.existId(sysUser.getDeptId())) { + return CallResult.error("数据验证失败,关联的用户部门Id并不存在,请刷新后重试!"); + } + return CallResult.ok(jsonObject); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDataPermDeptVo.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDataPermDeptVo.java new file mode 100644 index 00000000..601dc7c2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDataPermDeptVo.java @@ -0,0 +1,27 @@ +package com.orangeforms.webadmin.upms.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 数据权限与部门关联VO。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "数据权限与部门关联VO") +@Data +public class SysDataPermDeptVo { + + /** + * 数据权限Id。 + */ + @Schema(description = "数据权限Id") + private Long dataPermId; + + /** + * 关联部门Id。 + */ + @Schema(description = "关联部门Id") + private Long deptId; +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDataPermMenuVo.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDataPermMenuVo.java new file mode 100644 index 00000000..7e4bc12c --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDataPermMenuVo.java @@ -0,0 +1,27 @@ +package com.orangeforms.webadmin.upms.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 数据权限与菜单关联VO。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "数据权限与菜单关联VO") +@Data +public class SysDataPermMenuVo { + + /** + * 数据权限Id。 + */ + @Schema(description = "数据权限Id") + private Long dataPermId; + + /** + * 关联菜单Id。 + */ + @Schema(description = "关联菜单Id") + private Long menuId; +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDataPermVo.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDataPermVo.java new file mode 100644 index 00000000..e07af624 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDataPermVo.java @@ -0,0 +1,57 @@ +package com.orangeforms.webadmin.upms.vo; + +import com.orangeforms.common.core.base.vo.BaseVo; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; +import java.util.Map; + +/** + * 数据权限VO。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "数据权限VO") +@Data +@EqualsAndHashCode(callSuper = true) +public class SysDataPermVo extends BaseVo { + + /** + * 数据权限Id。 + */ + @Schema(description = "数据权限Id") + private Long dataPermId; + + /** + * 显示名称。 + */ + @Schema(description = "显示名称") + private String dataPermName; + + /** + * 数据权限规则类型(0: 全部可见 1: 只看自己 2: 只看本部门 3: 本部门及子部门 4: 多部门及子部门 5: 自定义部门列表)。 + */ + @Schema(description = "数据权限规则类型") + private Integer ruleType; + + /** + * 部门Id列表(逗号分隔)。 + */ + @Schema(description = "部门Id列表") + private String deptIdListString; + + /** + * 数据权限与部门关联对象列表。 + */ + @Schema(description = "数据权限与部门关联对象列表") + private List> dataPermDeptList; + + /** + * 数据权限与菜单关联对象列表。 + */ + @Schema(description = "数据权限与菜单关联对象列表") + private List> dataPermMenuList; +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDeptPostVo.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDeptPostVo.java new file mode 100644 index 00000000..6e502095 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDeptPostVo.java @@ -0,0 +1,39 @@ +package com.orangeforms.webadmin.upms.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 部门岗位VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "部门岗位VO") +@Data +public class SysDeptPostVo { + + /** + * 部门岗位Id。 + */ + @Schema(description = "部门岗位Id") + private Long deptPostId; + + /** + * 部门Id。 + */ + @Schema(description = "部门Id") + private Long deptId; + + /** + * 岗位Id。 + */ + @Schema(description = "岗位Id") + private Long postId; + + /** + * 部门岗位显示名称。 + */ + @Schema(description = "部门岗位显示名称") + private String postShowName; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDeptVo.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDeptVo.java new file mode 100644 index 00000000..1f08901f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysDeptVo.java @@ -0,0 +1,65 @@ +package com.orangeforms.webadmin.upms.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 部门管理VO视图对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "SysDeptVO视图对象") +@Data +public class SysDeptVo { + + /** + * 部门Id。 + */ + @Schema(description = "部门Id") + private Long deptId; + + /** + * 部门名称。 + */ + @Schema(description = "部门名称") + private String deptName; + + /** + * 显示顺序。 + */ + @Schema(description = "显示顺序") + private Integer showOrder; + + /** + * 父部门Id。 + */ + @Schema(description = "父部门Id") + private Long parentId; + + /** + * 创建者Id。 + */ + @Schema(description = "创建者Id") + private Long createUserId; + + /** + * 更新者Id。 + */ + @Schema(description = "更新者Id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysMenuVo.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysMenuVo.java new file mode 100644 index 00000000..e278c859 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysMenuVo.java @@ -0,0 +1,90 @@ +package com.orangeforms.webadmin.upms.vo; + +import com.orangeforms.common.core.base.vo.BaseVo; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 菜单VO。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "菜单VO") +@Data +@EqualsAndHashCode(callSuper = true) +public class SysMenuVo extends BaseVo { + + /** + * 菜单Id。 + */ + @Schema(description = "菜单Id") + private Long menuId; + + /** + * 父菜单Id,目录菜单的父菜单为null + */ + @Schema(description = "父菜单Id") + private Long parentId; + + /** + * 菜单显示名称。 + */ + @Schema(description = "菜单显示名称") + private String menuName; + + /** + * 菜单类型 (0: 目录 1: 菜单 2: 按钮 3: UI片段)。 + */ + @Schema(description = "菜单类型") + private Integer menuType; + + /** + * 前端表单路由名称,仅用于menu_type为1的菜单类型。 + */ + @Schema(description = "前端表单路由名称") + private String formRouterName; + + /** + * 在线表单主键Id,仅用于在线表单绑定的菜单。 + */ + @Schema(description = "在线表单主键Id") + private Long onlineFormId; + + /** + * 在线表单菜单的权限控制类型,具体值可参考SysOnlineMenuPermType常量对象。 + */ + @Schema(description = "在线表单菜单的权限控制类型") + private Integer onlineMenuPermType; + + /** + * 统计页面主键Id,仅用于统计页面绑定的菜单。 + */ + @Schema(description = "统计页面主键Id") + private Long reportPageId; + + /** + * 仅用于在线表单的流程Id。 + */ + @Schema(description = "仅用于在线表单的流程Id") + private Long onlineFlowEntryId; + + /** + * 菜单显示顺序 (值越小,排序越靠前)。 + */ + @Schema(description = "菜单显示顺序") + private Integer showOrder; + + /** + * 菜单图标。 + */ + @Schema(description = "菜单显示图标") + private String icon; + + /** + * 附加信息。 + */ + @Schema(description = "附加信息") + private String extraData; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysPostVo.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysPostVo.java new file mode 100644 index 00000000..15a5f2c7 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysPostVo.java @@ -0,0 +1,50 @@ +package com.orangeforms.webadmin.upms.vo; + +import com.orangeforms.common.core.base.vo.BaseVo; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Map; + +/** + * 岗位VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "岗位VO") +@Data +@EqualsAndHashCode(callSuper = true) +public class SysPostVo extends BaseVo { + + /** + * 岗位Id。 + */ + @Schema(description = "岗位Id") + private Long postId; + + /** + * 岗位名称。 + */ + @Schema(description = "岗位名称") + private String postName; + + /** + * 岗位层级,数值越小级别越高。 + */ + @Schema(description = "岗位层级,数值越小级别越高") + private Integer postLevel; + + /** + * 是否领导岗位。 + */ + @Schema(description = "是否领导岗位") + private Boolean leaderPost; + + /** + * postId 的多对多关联表数据对象,数据对应类型为SysDeptPostVo。 + */ + @Schema(description = "postId 的多对多关联表数据对象") + private Map sysDeptPost; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysRoleVo.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysRoleVo.java new file mode 100644 index 00000000..0aaf0358 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysRoleVo.java @@ -0,0 +1,39 @@ +package com.orangeforms.webadmin.upms.vo; + +import com.orangeforms.common.core.base.vo.BaseVo; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; +import java.util.Map; + +/** + * 角色VO。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "角色VO") +@Data +@EqualsAndHashCode(callSuper = true) +public class SysRoleVo extends BaseVo { + + /** + * 角色Id。 + */ + @Schema(description = "角色Id") + private Long roleId; + + /** + * 角色名称。 + */ + @Schema(description = "角色名称") + private String roleName; + + /** + * 角色与菜单关联对象列表。 + */ + @Schema(description = "角色与菜单关联对象列表") + private List> sysRoleMenuList; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysUserVo.java b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysUserVo.java new file mode 100644 index 00000000..194e8d86 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/java/com/orangeforms/webadmin/upms/vo/SysUserVo.java @@ -0,0 +1,133 @@ +package com.orangeforms.webadmin.upms.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; +import java.util.Map; +import java.util.List; + +/** + * 用户管理VO视图对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "SysUserVO视图对象") +@Data +public class SysUserVo { + + /** + * 用户Id。 + */ + @Schema(description = "用户Id") + private Long userId; + + /** + * 登录用户名。 + */ + @Schema(description = "登录用户名") + private String loginName; + + /** + * 用户部门Id。 + */ + @Schema(description = "用户部门Id") + private Long deptId; + + /** + * 用户显示名称。 + */ + @Schema(description = "用户显示名称") + private String showName; + + /** + * 用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)。 + */ + @Schema(description = "用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)") + private Integer userType; + + /** + * 用户头像的Url。 + */ + @Schema(description = "用户头像的Url") + private String headImageUrl; + + /** + * 用户状态(0: 正常 1: 锁定)。 + */ + @Schema(description = "用户状态(0: 正常 1: 锁定)") + private Integer userStatus; + + /** + * 用户邮箱。 + */ + @Schema(description = "用户邮箱") + private String email; + + /** + * 用户手机。 + */ + @Schema(description = "用户手机") + private String mobile; + + /** + * 创建者Id。 + */ + @Schema(description = "创建者Id") + private Long createUserId; + + /** + * 更新者Id。 + */ + @Schema(description = "更新者Id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 多对多用户岗位数据集合。 + */ + @Schema(description = "多对多用户岗位数据集合") + private List> sysUserPostList; + + /** + * 多对多用户角色数据集合。 + */ + @Schema(description = "多对多用户角色数据集合") + private List> sysUserRoleList; + + /** + * 多对多用户数据权限数据集合。 + */ + @Schema(description = "多对多用户数据权限数据集合") + private List> sysDataPermUserList; + + /** + * deptId 字典关联数据。 + */ + @Schema(description = "deptId 字典关联数据") + private Map deptIdDictMap; + + /** + * userType 常量字典关联数据。 + */ + @Schema(description = "userType 常量字典关联数据") + private Map userTypeDictMap; + + /** + * userStatus 常量字典关联数据。 + */ + @Schema(description = "userStatus 常量字典关联数据") + private Map userStatusDictMap; +} diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/resources/application-dev.yml b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/resources/application-dev.yml new file mode 100644 index 00000000..1e8f3091 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/resources/application-dev.yml @@ -0,0 +1,169 @@ +spring: + datasource: + type: com.alibaba.druid.pool.DruidDataSource + druid: + # 数据库链接 [主数据源] + main: + url: jdbc:mysql://localhost:3306/zzdemo-online-open?characterEncoding=utf8&useSSL=true&serverTimezone=Asia/Shanghai + username: root + password: 123456 + # 默认生成的操作日志数据源配置。 + operation-log: + url: jdbc:mysql://localhost:3306/zzdemo-online-open?characterEncoding=utf8&useSSL=true&serverTimezone=Asia/Shanghai + username: root + password: 123456 + # 默认生成的全局编码字典数据源配置。 + global-dict: + url: jdbc:mysql://localhost:3306/zzdemo-online-open?characterEncoding=utf8&useSSL=true&serverTimezone=Asia/Shanghai + username: root + password: 123456 + # 默认生成的工作流及在线表单数据源配置。 + common-flow-online: + url: jdbc:mysql://localhost:3306/zzdemo-online-open?characterEncoding=utf8&useSSL=true&serverTimezone=Asia/Shanghai + username: root + password: 123456 + driverClassName: com.mysql.cj.jdbc.Driver + name: application-webadmin + initialSize: 10 + minIdle: 10 + maxActive: 50 + maxWait: 60000 + timeBetweenEvictionRunsMillis: 60000 + minEvictableIdleTimeMillis: 300000 + poolPreparedStatements: true + maxPoolPreparedStatementPerConnectionSize: 20 + maxOpenPreparedStatements: 20 + validationQuery: SELECT 'x' + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 + filters: stat,wall + useGlobalDataSourceStat: true + web-stat-filter: + enabled: true + url-pattern: /* + exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*,/actuator/*" + stat-view-servlet: + enabled: true + urlPattern: /druid/* + resetEnable: true + +application: + # 初始化密码。 + defaultUserPassword: 123456 + # 缺省的文件上传根目录。 + uploadFileBaseDir: ./zz-resource/upload-files/app + # 跨域的IP(http://192.168.10.10:8086)白名单列表,多个IP之间逗号分隔(* 表示全部信任,空白表示禁用跨域信任)。 + credentialIpList: "*" + # Session的用户和数据权限在Redis中的过期时间(秒)。一定要和sa-token.timeout + sessionExpiredSeconds: 86400 + # 是否排他登录。 + excludeLogin: false + +# 这里仅仅是一个第三方配置的示例,如果没有接入斯三方系统, +# 这里的配置项也不会影响到系统的行为,如果觉得多余,也可以手动删除。 +third-party: + # 第三方系统接入的用户鉴权配置。 + auth: + - appCode: ruoyi + # 访问第三方系统接口的URL前缀,橙单会根据功能添加接口路径的其余部分, + # 比如获取用户Token的接口 http://localhost:8083/orangePluginTest/getTokenData + baseUrl: http://localhost:8083/orangePlugin + # 第三方返回的用户Token数据的缓存过期时长,单位秒。 + # 如果为0,则不缓存,每次涉及第三方的请求,都会发出http请求,交由第三方验证,这样对系统性能会有影响。 + tokenExpiredSeconds: 60 + # 第三方返回的权限数据的缓存过期时长,单位秒。 + permExpiredSeconds: 86400 + +# 这里仅仅是一个第三方配置的示例,如果没有接入斯三方系统, +# 这里的配置项也不会影响到系统的行为,如果觉得多余,也可以手动删除。 +common-ext: + urlPrefix: /admin/commonext + # 这里可以配置多个第三方应用,这里的应用数量,通常会和上面third-party.auth的配置数量一致。 + apps: + # 应用唯一编码,尽量不要使用中文。 + - appCode: ruoyi + # 业务组件的数据源配置。 + bizWidgetDatasources: + # 组件的类型,多个类型之间可以逗号分隔。 + - types: upms_user,upms_dept,upms_role,upms_post,upms_dept_post + # 组件获取列表数据的接口地址。 + listUrl: http://localhost:8083/orangePlugin/listBizWidgetData + # 组件获取详情数据的接口地址。 + viewUrl: http://localhost:8083/orangePlugin/viewBizWidgetData + +common-sequence: + # Snowflake 分布式Id生成算法所需的WorkNode参数值。 + snowflakeWorkNode: 1 + +# 存储session数据的Redis,所有服务均需要,因此放到公共配置中。 +# 根据实际情况,该Redis也可以用于存储其他数据。 +common-redis: + # redisson的配置。每个服务可以自己的配置文件中覆盖此选项。 + redisson: + # 如果该值为false,系统将不会创建RedissionClient的bean。 + enabled: true + # mode的可用值为,single/cluster/sentinel/master-slave + mode: single + # single: 单机模式 + # address: redis://localhost:6379 + # cluster: 集群模式 + # 每个节点逗号分隔,同时每个节点前必须以redis://开头。 + # address: redis://localhost:6379,redis://localhost:6378,... + # sentinel: + # 每个节点逗号分隔,同时每个节点前必须以redis://开头。 + # address: redis://localhost:6379,redis://localhost:6378,... + # master-slave: + # 每个节点逗号分隔,第一个为主节点,其余为从节点。同时每个节点前必须以redis://开头。 + # address: redis://localhost:6379,redis://localhost:6378,... + address: redis://localhost:6379 + # 链接超时,单位毫秒。 + timeout: 6000 + # 单位毫秒。分布式锁的超时检测时长。 + # 如果一次锁内操作超该毫秒数,或在释放锁之前异常退出,Redis会在该时长之后主动删除该锁使用的key。 + lockWatchdogTimeout: 60000 + # redis 密码,空可以不填。 + password: + pool: + # 连接池数量。 + poolSize: 20 + # 连接池中最小空闲数量。 + minIdle: 5 + +minio: + enabled: false + endpoint: http://localhost:19000 + accessKey: admin + secretKey: admin123456 + bucketName: application + +sa-token: + # token 名称(同时也是 cookie 名称) + token-name: Authorization + # token 有效期(单位:秒) 默认30天,-1 代表永久有效 + timeout: ${application.sessionExpiredSeconds} + # token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结 + active-timeout: -1 + # 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录) + is-concurrent: true + # 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token) + is-share: false + # token 风格(默认可取值:uuid、simple-uuid、random-32、random-64、random-128、tik) + token-style: uuid + # 是否输出操作日志 + is-log: true + # 配置 Sa-Token 单独使用的 Redis 连接 + alone-redis: + # Redis数据库索引(默认为0) + database: 0 + # Redis服务器地址 + host: localhost + # Redis服务器连接端口 + port: 6379 + # Redis服务器连接密码(默认为空) + password: + # 连接超时时间 + timeout: 10s + is-read-header: true + is-read-cookie: false diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/resources/application.yml b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/resources/application.yml new file mode 100644 index 00000000..098e90a4 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/resources/application.yml @@ -0,0 +1,165 @@ +logging: + level: + # 这里设置的日志级别优先于logback-spring.xml文件Loggers中的日志级别。 + com.orangeforms: info + config: classpath:logback-spring.xml + +server: + port: 8082 + tomcat: + uri-encoding: UTF-8 + threads: + max: 100 + min-spare: 10 + servlet: + encoding: + force: true + charset: UTF-8 + enabled: true + +# spring相关配置 +spring: + application: + name: application-webadmin + profiles: + active: dev + servlet: + multipart: + max-file-size: 50MB + max-request-size: 50MB + mvc: + converters: + preferred-json-mapper: fastjson + main: + allow-circular-references: true + groovy: + template: + check-template-location: false + +flowable: + async-executor-activate: false + database-schema-update: false + +mybatis-plus: + mapper-locations: classpath:com/orangeforms/webadmin/*/dao/mapper/*Mapper.xml,com/orangeforms/common/log/dao/mapper/*Mapper.xml,com/orangeforms/common/online/dao/mapper/*Mapper.xml,com/orangeforms/common/flow/dao/mapper/*Mapper.xml + type-aliases-package: com.orangeforms.webadmin.*.model,com.orangeforms.common.log.model,com.orangeforms.common.online.model,com.orangeforms.common.flow.model + global-config: + db-config: + logic-delete-value: -1 + logic-not-delete-value: 1 + +# 自动分页的配置 +pagehelper: + helperDialect: mysql + reasonable: true + supportMethodsArguments: false + params: count=countSql + +common-core: + # 可选值为 mysql / postgresql / oracle / dm8 / kingbase / opengauss + databaseType: mysql + +common-online: + # 注意不要以反斜杠(/)结尾。 + urlPrefix: /admin/online + # 打印接口的路径,不要以反斜杠(/)结尾。 + printUrlPath: /admin/report/reportPrint/print + # 在线表单业务数据上传资源路径 + uploadFileBaseDir: ./zz-resource/upload-files/online + # 如果为false,在线表单模块中所有Controller接口将不能使用。 + operationEnabled: true + # 1: minio 2: aliyun-oss 3: qcloud-cos。 + distributeStoreType: 1 + # 调用render接口时候,是否打开一级缓存加速。 + enableRenderCache: false + # 业务表和在线表单内置表是否跨库。 + enabledMultiDatabaseWrite: true + # 脱敏字段的掩码字符,只能为单个字符。 + maskChar: '*' + # 下面的url列表,请保持反斜杠(/)结尾。 + viewUrlList: + - ${common-online.urlPrefix}/onlineOperation/viewByDatasourceId/ + - ${common-online.urlPrefix}/onlineOperation/viewByOneToManyRelationId/ + - ${common-online.urlPrefix}/onlineOperation/listByDatasourceId/ + - ${common-online.urlPrefix}/onlineOperation/listByOneToManyRelationId/ + - ${common-online.urlPrefix}/onlineOperation/exportByDatasourceId/ + - ${common-online.urlPrefix}/onlineOperation/exportByOneToManyRelationId/ + - ${common-online.urlPrefix}/onlineOperation/downloadDatasource/ + - ${common-online.urlPrefix}/onlineOperation/downloadOneToManyRelation/ + - ${common-online.urlPrefix}/onlineOperation/print/ + editUrlList: + - ${common-online.urlPrefix}/onlineOperation/addDatasource/ + - ${common-online.urlPrefix}/onlineOperation/addOneToManyRelation/ + - ${common-online.urlPrefix}/onlineOperation/updateDatasource/ + - ${common-online.urlPrefix}/onlineOperation/updateOneToManyRelation/ + - ${common-online.urlPrefix}/onlineOperation/deleteDatasource/ + - ${common-online.urlPrefix}/onlineOperation/deleteOneToManyRelation/ + - ${common-online.urlPrefix}/onlineOperation/deleteBatchDatasource/ + - ${common-online.urlPrefix}/onlineOperation/deleteBatchOneToManyRelation/ + - ${common-online.urlPrefix}/onlineOperation/uploadDatasource/ + - ${common-online.urlPrefix}/onlineOperation/uploadOneToManyRelation/ + - ${common-online.urlPrefix}/onlineOperation/importDatasource/ + +common-flow: + # 请慎重修改urlPrefix的缺省配置,注意不要以反斜杠(/)结尾。如必须修改其他路径,请同步修改数据库脚本。 + urlPrefix: /admin/flow + # 如果为false,流程模块的所有Controller中的接口将不能使用。 + operationEnabled: true + +common-swagger: + # 当enabled为false的时候,则可禁用swagger。 + enabled: true + # 工程的基础包名。 + basePackage: com.orangeforms + # 工程服务的基础包名。 + serviceBasePackage: com.orangeforms.webadmin + title: 橙单单体服务工程 + description: 橙单单体服务工程详情 + version: 1.0 + +springdoc: + swagger-ui: + path: /swagger-ui.html + tags-sorter: alpha + #operations-sorter: order + api-docs: + path: /v3/api-docs + default-flat-param-object: false + +common-datafilter: + tenant: + # 对于单体服务,该值始终为false。 + enabled: false + dataperm: + enabled: true + # 在拼接数据权限过滤的SQL时,我们会用到sys_dept_relation表,该表的前缀由此配置项指定。 + # 如果没有前缀,请使用 "" 。 + deptRelationTablePrefix: zz_ + # 是否在每次执行数据权限查询过滤时,都要进行菜单Id和URL之间的越权验证。如果使用SaToken权限框架,该参数必须为false。 + enableMenuPermVerify: false + +# 暴露监控端点 +management: + endpoints: + web: + exposure: + include: '*' + jmx: + exposure: + include: '*' + endpoint: + # 与中间件相关的健康详情也会被展示 + health: + show-details: always + configprops: + # 在/actuator/configprops中,所有包含password的配置,将用 * 隐藏。 + # 如果不想隐藏任何配置项的值,可以直接使用如下被注释的空值。 + # keys-to-sanitize: + keys-to-sanitize: password + server: + base-path: "/" + +common-log: + # 操作日志配置,对应配置文件common-log/OperationLogProperties.java + operation-log: + enabled: true diff --git a/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/resources/logback-spring.xml b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/resources/logback-spring.xml new file mode 100644 index 00000000..6bc0eafb --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/application-webadmin/src/main/resources/logback-spring.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + ${LOG_PATTERN} + + + + + + + ${LOG_HOME}/${LOG_NAME}.log + true + + + ${LOG_HOME}/${LOG_NAME}-%d{yyyy-MM-dd}-%i.log + + + 31 + + + 20MB + + + + + ${LOG_PATTERN_EX} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/.DS_Store b/OrangeFormsOpen-MybatisPlus/common/.DS_Store new file mode 100644 index 00000000..dcc80517 Binary files /dev/null and b/OrangeFormsOpen-MybatisPlus/common/.DS_Store differ diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/pom.xml b/OrangeFormsOpen-MybatisPlus/common/common-core/pom.xml new file mode 100644 index 00000000..08b735a1 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/pom.xml @@ -0,0 +1,115 @@ + + + + com.orangeforms + common + 1.0.0 + + 4.0.0 + + common-core + 1.0.0 + common-core + jar + + + + + com.google.guava + guava + ${guava.version} + + + org.apache.commons + commons-lang3 + + + commons-io + commons-io + ${commons-io.version} + + + org.apache.httpcomponents.client5 + httpclient5 + ${httpclient5.version} + + + joda-time + joda-time + ${joda-time.version} + + + org.apache.commons + commons-collections4 + ${commons-collections4.version} + + + org.apache.commons + commons-csv + ${common-csv.version} + + + cn.hutool + hutool-all + ${hutool.version} + + + io.jsonwebtoken + jjwt + ${jjwt.version} + + + com.alibaba + fastjson + ${fastjson.version} + + + com.github.ben-manes.caffeine + caffeine + ${caffeine.version} + + + cn.jimmyshi + bean-query + ${bean.query.version} + + + + org.apache.poi + poi-ooxml + ${poi-ooxml.version} + + + + mysql + mysql-connector-java + 8.0.22 + + + com.alibaba + druid-spring-boot-starter + ${druid.version} + + + com.sun + jconsole + + + com.sun + tools + + + + + com.baomidou + mybatis-plus-boot-starter + ${mybatisplus.version} + + + com.github.pagehelper + pagehelper-spring-boot-starter + ${pagehelper.version} + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/advice/MyControllerAdvice.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/advice/MyControllerAdvice.java new file mode 100644 index 00000000..8d781115 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/advice/MyControllerAdvice.java @@ -0,0 +1,31 @@ +package com.orangeforms.common.core.advice; + +import com.orangeforms.common.core.util.MyDateUtil; +import org.springframework.beans.propertyeditors.CustomDateEditor; +import org.springframework.web.bind.WebDataBinder; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.InitBinder; + +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * Controller的环绕拦截类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@ControllerAdvice +public class MyControllerAdvice { + + /** + * 转换前端传入的日期变量参数为指定格式。 + * + * @param binder 数据绑定参数。 + */ + @InitBinder + public void initBinder(WebDataBinder binder) { + binder.registerCustomEditor(Date.class, + new CustomDateEditor(new SimpleDateFormat(MyDateUtil.COMMON_SHORT_DATETIME_FORMAT), false)); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/advice/MyExceptionHandler.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/advice/MyExceptionHandler.java new file mode 100644 index 00000000..c39771f7 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/advice/MyExceptionHandler.java @@ -0,0 +1,167 @@ +package com.orangeforms.common.core.advice; + +import com.orangeforms.common.core.exception.*; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.ResponseResult; +import com.orangeforms.common.core.util.ContextUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.ibatis.exceptions.PersistenceException; +import org.springframework.dao.DataAccessException; +import org.springframework.dao.DuplicateKeyException; +import org.springframework.dao.PermissionDeniedDataAccessException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import java.util.concurrent.TimeoutException; + +/** + * 业务层的异常处理类,这里只是给出最通用的Exception的捕捉,今后可以根据业务需要, + * 用不同的函数,处理不同类型的异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@RestControllerAdvice("com.orangeforms") +public class MyExceptionHandler { + + /** + * 通用异常处理方法。 + * + * @param ex 异常对象。 + * @param request http请求。 + * @return 应答对象。 + */ + @ExceptionHandler(value = Exception.class) + public ResponseResult exceptionHandle(Exception ex, HttpServletRequest request) { + log.error("Unhandled exception from URL [" + request.getRequestURI() + "]", ex); + ContextUtil.getHttpResponse().setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + return ResponseResult.error(ErrorCodeEnum.UNHANDLED_EXCEPTION, ex.getMessage()); + } + + /** + * 无效的实体对象异常。 + * + * @param ex 异常对象。 + * @param request http请求。 + * @return 应答对象。 + */ + @ExceptionHandler(value = InvalidDataModelException.class) + public ResponseResult invalidDataModelExceptionHandle(Exception ex, HttpServletRequest request) { + log.error("InvalidDataModelException exception from URL [" + request.getRequestURI() + "]", ex); + return ResponseResult.error(ErrorCodeEnum.INVALID_DATA_MODEL); + } + + /** + * 无效的实体对象字段异常。 + * + * @param ex 异常对象。 + * @param request http请求。 + * @return 应答对象。 + */ + @ExceptionHandler(value = InvalidDataFieldException.class) + public ResponseResult invalidDataFieldExceptionHandle(Exception ex, HttpServletRequest request) { + log.error("InvalidDataFieldException exception from URL [" + request.getRequestURI() + "]", ex); + return ResponseResult.error(ErrorCodeEnum.INVALID_DATA_FIELD); + } + + /** + * 无效类字段异常。 + * + * @param ex 异常对象。 + * @param request http请求。 + * @return 应答对象。 + */ + @ExceptionHandler(value = InvalidClassFieldException.class) + public ResponseResult invalidClassFieldExceptionHandle(Exception ex, HttpServletRequest request) { + log.error("InvalidClassFieldException exception from URL [" + request.getRequestURI() + "]", ex); + return ResponseResult.error(ErrorCodeEnum.INVALID_CLASS_FIELD); + } + + /** + * 重复键异常处理方法。 + * + * @param ex 异常对象。 + * @param request http请求。 + * @return 应答对象。 + */ + @ExceptionHandler(value = DuplicateKeyException.class) + public ResponseResult duplicateKeyExceptionHandle(Exception ex, HttpServletRequest request) { + log.error("DuplicateKeyException exception from URL [" + request.getRequestURI() + "]", ex); + return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY); + } + + /** + * 数据访问失败异常处理方法。 + * + * @param ex 异常对象。 + * @param request http请求。 + * @return 应答对象。 + */ + @ExceptionHandler(value = DataAccessException.class) + public ResponseResult dataAccessExceptionHandle(Exception ex, HttpServletRequest request) { + log.error("DataAccessException exception from URL [" + request.getRequestURI() + "]", ex); + if (ex.getCause() instanceof PersistenceException + && ex.getCause().getCause() instanceof PermissionDeniedDataAccessException) { + return ResponseResult.error(ErrorCodeEnum.DATA_PERM_ACCESS_FAILED); + } + return ResponseResult.error(ErrorCodeEnum.DATA_ACCESS_FAILED); + } + + /** + * 操作不存在或已逻辑删除数据的异常处理方法。 + * + * @param ex 异常对象。 + * @param request http请求。 + * @return 应答对象。 + */ + @ExceptionHandler(value = NoDataAffectException.class) + public ResponseResult noDataEffectExceptionHandle(Exception ex, HttpServletRequest request) { + log.error("NoDataAffectException exception from URL [" + request.getRequestURI() + "]", ex); + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + + /** + * 数据权限异常。 + * + * @param ex 异常对象。 + * @param request http请求。 + * @return 应答对象。 + */ + @ExceptionHandler(value = NoDataPermException.class) + public ResponseResult noDataPermExceptionHandle(Exception ex, HttpServletRequest request) { + log.error("NoDataPermException exception from URL [" + request.getRequestURI() + "]", ex); + return ResponseResult.error(ErrorCodeEnum.DATA_PERM_ACCESS_FAILED, ex.getMessage()); + } + + /** + * 自定义运行时异常。 + * + * @param ex 异常对象。 + * @param request http请求。 + * @return 应答对象。 + */ + @ExceptionHandler(value = MyRuntimeException.class) + public ResponseResult myRuntimeExceptionHandle(Exception ex, HttpServletRequest request) { + log.error("MyRuntimeException exception from URL [" + request.getRequestURI() + "]", ex); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, ex.getMessage()); + } + + /** + * Redis缓存访问异常处理方法。 + * + * @param ex 异常对象。 + * @param request http请求。 + * @return 应答对象。 + */ + @ExceptionHandler(value = RedisCacheAccessException.class) + public ResponseResult redisCacheAccessExceptionHandle(Exception ex, HttpServletRequest request) { + log.error("RedisCacheAccessException exception from URL [" + request.getRequestURI() + "]", ex); + if (ex.getCause() instanceof TimeoutException) { + return ResponseResult.error(ErrorCodeEnum.REDIS_CACHE_ACCESS_TIMEOUT); + } + return ResponseResult.error(ErrorCodeEnum.REDIS_CACHE_ACCESS_STATE_ERROR); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/DeptFilterColumn.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/DeptFilterColumn.java new file mode 100644 index 00000000..595e6463 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/DeptFilterColumn.java @@ -0,0 +1,16 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 主要用于标记数据权限中基于DeptId进行过滤的字段。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface DeptFilterColumn { + +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/DisableDataFilter.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/DisableDataFilter.java new file mode 100644 index 00000000..a2f5f028 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/DisableDataFilter.java @@ -0,0 +1,17 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 作为DisableDataFilterAspect的切点。 + * 该注解标记的方法内所有的查询语句,均不会被Mybatis拦截器过滤数据。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface DisableDataFilter { + +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/DisableTenantFilter.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/DisableTenantFilter.java new file mode 100644 index 00000000..f9a89810 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/DisableTenantFilter.java @@ -0,0 +1,28 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 仅用于微服务的多租户项目。 + * 用于注解DAO层Mapper对象的租户过滤规则。被包含的方法将不会进行租户Id的过滤。 + * 对于tk mapper和mybatis plus中的内置方法,可以直接指定方法名即可,如:selectOne。 + * 需要说明的是,在大多数场景下,只要在实体对象中指定了租户Id字段,基于该主表的绝大部分增删改操作, + * 都需要经过租户Id过滤,仅当查询非常复杂,或者主表不在SQL语句之中的时候,可以通过该注解禁用该SQL, + * 并根据需求通过手动的方式实现租户过滤。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface DisableTenantFilter { + + /** + * 包含的方法名称数组。该值不能为空,因为如想取消所有方法的租户过滤, + * 可以通过在实体对象中不指定租户Id字段注解的方式实现。 + * + * @return 被包括的方法名称数组。 + */ + String[] includeMethodName(); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/EnableDataPerm.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/EnableDataPerm.java new file mode 100644 index 00000000..cd2f6a36 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/EnableDataPerm.java @@ -0,0 +1,35 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 用于注解DAO层Mapper对象的数据权限规则。 + * 由于框架使用了tk.mapper,所以并非所有的Mapper接口均在当前Mapper对象中定义,有一部分被tk.mapper封装,如selectAll等。 + * 如果需要排除tk.mapper中的方法,可以直接使用tk.mapper基类所声明的方法名称即可。 + * 另外,比较特殊的场景是,因为tk.mapper是通用框架,所以同样的selectAll方法,可以获取不同的数据集合,因此在service中如果 + * 出现两个不同的方法调用Mapper的selectAll方法,但是一个需要参与过滤,另外一个不需要参与,那么就需要修改当前类的Mapper方法, + * 将其中一个方法重新定义一个具体的接口方法,并重新设定其是否参与数据过滤。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface EnableDataPerm { + + /** + * 排除的方法名称数组。如果为空,所有的方法均会被Mybaits拦截注入权限过滤条件。 + * + * @return 被排序的方法名称数据。 + */ + String[] excluseMethodName() default {}; + + /** + * 必须包含能看用户自己数据的数据过滤条件,如果当前用户的数据过滤中,没有DataPermRuleType.TYPE_USER_ONLY, + * 在进行数据权限过滤时,会自动包含该权限。 + * + * @return 是否必须包含DataPermRuleType.TYPE_USER_ONLY类型的数据权限。 + */ + boolean mustIncludeUserRule() default false; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/FlowLatestApprovalStatusColumn.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/FlowLatestApprovalStatusColumn.java new file mode 100644 index 00000000..6132c47a --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/FlowLatestApprovalStatusColumn.java @@ -0,0 +1,16 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 业务表中记录流程最后审批状态标记的字段。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface FlowLatestApprovalStatusColumn { + +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/FlowStatusColumn.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/FlowStatusColumn.java new file mode 100644 index 00000000..670a9083 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/FlowStatusColumn.java @@ -0,0 +1,16 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 业务表中记录流程实例结束标记的字段。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface FlowStatusColumn { + +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/JobUpdateTimeColumn.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/JobUpdateTimeColumn.java new file mode 100644 index 00000000..5546fa00 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/JobUpdateTimeColumn.java @@ -0,0 +1,16 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 主要用于标记Job实体对象的更新时间字段。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface JobUpdateTimeColumn { + +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MaskField.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MaskField.java new file mode 100644 index 00000000..301d5427 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MaskField.java @@ -0,0 +1,50 @@ +package com.orangeforms.common.core.annotation; + +import com.orangeforms.common.core.constant.MaskFieldTypeEnum; +import com.orangeforms.common.core.util.MaskFieldHandler; + +import java.lang.annotation.*; + +/** + * 脱敏字段注解。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface MaskField { + + /** + * 脱敏类型。 + * + * @return 脱敏类型。 + */ + MaskFieldTypeEnum maskType(); + /** + * 掩码符号。 + * + * @return 掩码符号。 + */ + char maskChar() default '*'; + /** + * 前面noMaskPrefix数量的字符不被掩码。 + * 掩码类型为MaskFieldTypeEnum.ID_CARD时可用。 + * + * @return 从1开始计算,前面不被掩码的字符数。 + */ + int noMaskPrefix() default 1; + /** + * 末尾noMaskSuffix数量的字符不被掩码。 + * 掩码类型为MaskFieldTypeEnum.ID_CARD时可用。 + * + * @return 从1开始计算,末尾不被掩码的字符数。 + */ + int noMaskSuffix() default 1; + /** + * 自定义脱敏处理器接口的Class。 + * @return 自定义脱敏处理器接口的Class。 + */ + Class handler() default MaskFieldHandler.class; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MultiDatabaseWriteMethod.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MultiDatabaseWriteMethod.java new file mode 100644 index 00000000..f12218e7 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MultiDatabaseWriteMethod.java @@ -0,0 +1,18 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 该注解通常标记于Service中的事务方法,并且会和@Transactional注解同时存在。 + * 被注解标注的方法内代码,通常通过mybatis,并在同一个事务内访问数据库。与此同时还会存在基于 + * JDBC的跨库操作。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface MultiDatabaseWriteMethod { + +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MyDataSource.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MyDataSource.java new file mode 100644 index 00000000..6d516240 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MyDataSource.java @@ -0,0 +1,21 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 主要用于标记Service所依赖的数据源类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface MyDataSource { + + /** + * 标注的数据源类型 + * @return 当前标注的数据源类型。 + */ + int value(); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MyDataSourceResolver.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MyDataSourceResolver.java new file mode 100644 index 00000000..41b80f8a --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MyDataSourceResolver.java @@ -0,0 +1,35 @@ +package com.orangeforms.common.core.annotation; + +import com.orangeforms.common.core.util.DataSourceResolver; + +import java.lang.annotation.*; + +/** + * 基于自定义解析规则的多数据源注解。主要用于标注Service的实现类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface MyDataSourceResolver { + + /** + * 多数据源路由键解析接口的Class。 + * @return 多数据源路由键解析接口的Class。 + */ + Class resolver(); + + /** + * DataSourceResolver.resovle方法的入参。 + * @return DataSourceResolver.resovle方法的入参。 + */ + String arg() default ""; + + /** + * 数值型参数。 + * @return DataSourceResolver.resovle方法的入参。 + */ + int intArg() default -1; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MyRequestBody.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MyRequestBody.java new file mode 100644 index 00000000..4aa12b98 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/MyRequestBody.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 标记Controller中的方法参数,参数解析器会根据该注解将请求中的JSON数据,映射到参数中的绑定字段。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +public @interface MyRequestBody { + + /** + * 是否必须出现的参数。 + */ + boolean required() default false; + /** + * 解析时用到的JSON的key。 + */ + String value() default ""; +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/NoAuthInterface.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/NoAuthInterface.java new file mode 100644 index 00000000..1c832ac2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/NoAuthInterface.java @@ -0,0 +1,15 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 主要用于标记无需Token验证的接口 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface NoAuthInterface { +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationConstDict.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationConstDict.java new file mode 100644 index 00000000..5b695fb0 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationConstDict.java @@ -0,0 +1,29 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 标识Model和常量字典之间的关联关系。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RelationConstDict { + + /** + * 当前对象的关联Id字段名称。 + * + * @return 当前对象的关联Id字段名称。 + */ + String masterIdField(); + + /** + * 被关联的常量字典的Class对象。 + * + * @return 关联的常量字典的Class对象。 + */ + Class constantDictClass(); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationDict.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationDict.java new file mode 100644 index 00000000..7b592496 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationDict.java @@ -0,0 +1,71 @@ +package com.orangeforms.common.core.annotation; + +import com.orangeforms.common.core.object.DummyClass; + +import java.lang.annotation.*; + +/** + * 标识Model之间的字典关联关系。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RelationDict { + + /** + * 当前对象的关联Id字段名称。 + * + * @return 当前对象的关联Id字段名称。 + */ + String masterIdField(); + + /** + * 被关联Model对象的Class对象。 + * + * @return 被关联Model对象的Class对象。 + */ + Class slaveModelClass(); + + /** + * 被关联Model对象的关联Id字段名称。 + * + * @return 被关联Model对象的关联Id字段名称。 + */ + String slaveIdField(); + + /** + * 被关联Model对象的关联Name字段名称。 + * + * @return 被关联Model对象的关联Name字段名称。 + */ + String slaveNameField(); + + /** + * 被关联的本地Service对象名称。 + * 该参数的优先级低于 slaveServiceClass(), + * 如果是空字符串,BaseService会自动拼接为 slaveModelClass().getSimpleName() + "Service"。 + * + * @return 被关联的本地Service对象名称。 + */ + String slaveServiceName() default ""; + + /** + * 被关联的本地Service对象CLass类型。 + * + * @return 被关联的本地Service对象CLass类型。 + */ + Class slaveServiceClass() default DummyClass.class; + + /** + * 在同一个实体对象中,如果有一对一关联和字典关联,都是基于相同的主表字段,并关联到 + * 相同关联表的同一关联字段时,可以在字典关联的注解中引用被一对一注解标准的对象属性。 + * 从而在数据整合时,当前字典的数据可以直接取自"equalOneToOneRelationField"指定 + * 的字段,从而避免一次没必要的数据库查询操作,提升了加载显示的效率。 + * + * @return 与该字典字段引用关系完全相同的一对一关联属性名称。 + */ + String equalOneToOneRelationField() default ""; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationGlobalDict.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationGlobalDict.java new file mode 100644 index 00000000..65ab2a5a --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationGlobalDict.java @@ -0,0 +1,29 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 全局字典关联。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RelationGlobalDict { + + /** + * 当前对象的关联Id字段名称。 + * + * @return 当前对象的关联Id字段名称。 + */ + String masterIdField(); + + /** + * 全局字典编码。 + * + * @return 全局字典编码。空表示为不使用全局字典。 + */ + String dictCode(); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationManyToMany.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationManyToMany.java new file mode 100644 index 00000000..bee48192 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationManyToMany.java @@ -0,0 +1,39 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 标注多对多的Model关系。 + * 重要提示:由于多对多关联表数据,很多时候都不需要跟随主表数据返回,所以该注解不会在 + * 生成的时候自动添加到实体类字段上,需要的时候,用户可自行手动添加。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RelationManyToMany { + + /** + * 多对多中间表的Mapper对象名称。 + * 如果是空字符串,BaseService会自动拼接为 relationModelClass().getSimpleName() + "Mapper"。 + * + * @return 被关联的本地Service对象名称。 + */ + String relationMapperName() default ""; + + /** + * 多对多关联表Model对象的Class对象。 + * + * @return 被关联Model对象的Class对象。 + */ + Class relationModelClass(); + + /** + * 多对多关联表Model对象中与主表关联的Id字段名称。 + * + * @return 被关联Model对象的关联Id字段名称。 + */ + String relationMasterIdField(); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationManyToManyAggregation.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationManyToManyAggregation.java new file mode 100644 index 00000000..cfa48e2f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationManyToManyAggregation.java @@ -0,0 +1,96 @@ +package com.orangeforms.common.core.annotation; + +import com.orangeforms.common.core.object.DummyClass; + +import java.lang.annotation.*; + +/** + * 主要用于多对多的Model关系。标注通过从表关联字段或者关联表关联字段计算主表聚合计算字段的规则。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RelationManyToManyAggregation { + + /** + * 当前对象的关联Id字段名称。 + * + * @return 当前对象的关联Id字段名称。 + */ + String masterIdField(); + + /** + * 被关联的本地Service对象名称。 + * 该参数的优先级低于 slaveServiceClass(), + * 如果是空字符串,BaseService会自动拼接为 slaveModelClass().getSimpleName() + "Service"。 + * + * @return 被关联的本地Service对象名称。 + */ + String slaveServiceName() default ""; + + /** + * 被关联的本地Service对象CLass类型。 + * + * @return 被关联的本地Service对象CLass类型。 + */ + Class slaveServiceClass() default DummyClass.class; + + /** + * 多对多从表Model对象的Class对象。 + * + * @return 被关联Model对象的Class对象。 + */ + Class slaveModelClass(); + + /** + * 多对多从表Model对象的关联Id字段名称。 + * + * @return 被关联Model对象的关联Id字段名称。 + */ + String slaveIdField(); + + /** + * 多对多关联表Model对象的Class对象。 + * + * @return 被关联Model对象的Class对象。 + */ + Class relationModelClass(); + + /** + * 多对多关联表Model对象中与主表关联的Id字段名称。 + * + * @return 被关联Model对象的关联Id字段名称。 + */ + String relationMasterIdField(); + + /** + * 多对多关联表Model对象中与从表关联的Id字段名称。 + * + * @return 被关联Model对象的关联Id字段名称。 + */ + String relationSlaveIdField(); + + /** + * 聚合计算所在的Model。 + * + * @return 聚合计算所在Model的Class。 + */ + Class aggregationModelClass(); + + /** + * 聚合类型。具体数值参考AggregationType对象。 + * + * @return 聚合类型。 + */ + int aggregationType(); + + /** + * 聚合计算所在Model的字段名称。 + * + * @return 聚合计算所在Model的字段名称。 + */ + String aggregationField(); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationOneToMany.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationOneToMany.java new file mode 100644 index 00000000..5a5d6e16 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationOneToMany.java @@ -0,0 +1,54 @@ +package com.orangeforms.common.core.annotation; + +import com.orangeforms.common.core.object.DummyClass; + +import java.lang.annotation.*; + +/** + * 标识Model之间的一对多关联关系。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RelationOneToMany { + + /** + * 当前对象的关联Id字段名称。 + * + * @return 当前对象的关联Id字段名称。 + */ + String masterIdField(); + + /** + * 被关联Model对象的Class对象。 + * + * @return 被关联Model对象的Class对象。 + */ + Class slaveModelClass(); + + /** + * 被关联Model对象的关联Id字段名称。 + * + * @return 被关联Model对象的关联Id字段名称。 + */ + String slaveIdField(); + + /** + * 被关联的本地Service对象名称。 + * 该参数的优先级低于 slaveServiceClass(), + * 如果是空字符串,BaseService会自动拼接为 slaveModelClass().getSimpleName() + "Service"。 + * + * @return 被关联的本地Service对象名称。 + */ + String slaveServiceName() default ""; + + /** + * 被关联的本地Service对象CLass类型。 + * + * @return 被关联的本地Service对象CLass类型。 + */ + Class slaveServiceClass() default DummyClass.class; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationOneToManyAggregation.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationOneToManyAggregation.java new file mode 100644 index 00000000..61befd73 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationOneToManyAggregation.java @@ -0,0 +1,68 @@ +package com.orangeforms.common.core.annotation; + +import com.orangeforms.common.core.object.DummyClass; + +import java.lang.annotation.*; + +/** + * 主要用于一对多的Model关系。标注通过从表关联字段计算主表聚合计算字段的规则。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RelationOneToManyAggregation { + + /** + * 当前对象的关联Id字段名称。 + * + * @return 当前对象的关联Id字段名称。 + */ + String masterIdField(); + + /** + * 被关联的本地Service对象名称。 + * 该参数的优先级低于 slaveServiceClass(), + * 如果是空字符串,BaseService会自动拼接为 slaveModelClass().getSimpleName() + "Service"。 + * + * @return 被关联的本地Service对象名称。 + */ + String slaveServiceName() default ""; + + /** + * 被关联的本地Service对象CLass类型。 + * + * @return 被关联的本地Service对象CLass类型。 + */ + Class slaveServiceClass() default DummyClass.class; + + /** + * 被关联Model对象的Class对象。 + * + * @return 被关联Model对象的Class对象。 + */ + Class slaveModelClass(); + + /** + * 被关联Model对象的关联Id字段名称。 + * + * @return 被关联Model对象的关联Id字段名称。 + */ + String slaveIdField(); + + /** + * 被关联Model对象中参与计算的聚合类型。具体数值参考AggregationType对象。 + * + * @return 被关联Model对象中参与计算的聚合类型。 + */ + int aggregationType(); + + /** + * 被关联Model对象中参与聚合计算的字段名称。 + * + * @return 被关联Model对象中参与计算字段的名称。 + */ + String aggregationField(); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationOneToOne.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationOneToOne.java new file mode 100644 index 00000000..fd38ca49 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/RelationOneToOne.java @@ -0,0 +1,61 @@ +package com.orangeforms.common.core.annotation; + +import com.orangeforms.common.core.object.DummyClass; + +import java.lang.annotation.*; + +/** + * 标识Model之间的一对一关联关系。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RelationOneToOne { + + /** + * 当前对象的关联Id字段名称。 + * + * @return 当前对象的关联Id字段名称。 + */ + String masterIdField(); + + /** + * 被关联Model对象的Class对象。 + * + * @return 被关联Model对象的Class对象。 + */ + Class slaveModelClass(); + + /** + * 被关联Model对象的关联Id字段名称。 + * + * @return 被关联Model对象的关联Id字段名称。 + */ + String slaveIdField(); + + /** + * 被关联的本地Service对象名称。 + * 该参数的优先级低于 slaveServiceClass(), + * 如果是空字符串,BaseService会自动拼接为 slaveModelClass().getSimpleName() + "Service"。 + * + * @return 被关联的本地Service对象名称。 + */ + String slaveServiceName() default ""; + + /** + * 被关联的本地Service对象CLass类型。 + * + * @return 被关联的本地Service对象CLass类型。 + */ + Class slaveServiceClass() default DummyClass.class; + + /** + * 在一对一关联时,是否加载从表的字典关联。 + * + * @return 是否加载从表的字典关联。true关联,false则只返回从表自身数据。 + */ + boolean loadSlaveDict() default true; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/TenantFilterColumn.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/TenantFilterColumn.java new file mode 100644 index 00000000..368a9ea2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/TenantFilterColumn.java @@ -0,0 +1,16 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 主要用于标记通过租户Id进行过滤的字段。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface TenantFilterColumn { + +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/UploadFlagColumn.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/UploadFlagColumn.java new file mode 100644 index 00000000..c01e6a16 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/UploadFlagColumn.java @@ -0,0 +1,24 @@ +package com.orangeforms.common.core.annotation; + +import com.orangeforms.common.core.upload.UploadStoreTypeEnum; + +import java.lang.annotation.*; + +/** + * 用于标记支持数据上传和下载的字段。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface UploadFlagColumn { + + /** + * 上传数据存储类型。 + * + * @return 上传数据存储类型。 + */ + UploadStoreTypeEnum storeType(); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/UserFilterColumn.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/UserFilterColumn.java new file mode 100644 index 00000000..af9275e2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/annotation/UserFilterColumn.java @@ -0,0 +1,16 @@ +package com.orangeforms.common.core.annotation; + +import java.lang.annotation.*; + +/** + * 主要用于标记数据权限中基于UserId进行过滤的字段。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface UserFilterColumn { + +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/aop/DataSourceAspect.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/aop/DataSourceAspect.java new file mode 100644 index 00000000..5acff1a2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/aop/DataSourceAspect.java @@ -0,0 +1,48 @@ +package com.orangeforms.common.core.aop; + +import com.orangeforms.common.core.annotation.MyDataSource; +import com.orangeforms.common.core.config.DataSourceContextHolder; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +/** + * 多数据源AOP切面处理类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Aspect +@Component +@Order(1) +@Slf4j +public class DataSourceAspect { + + /** + * 所有配置MyDataSource注解的Service实现类。 + */ + @Pointcut("execution(public * com.orangeforms..service..*(..)) " + + "&& @target(com.orangeforms.common.core.annotation.MyDataSource)") + public void datasourcePointCut() { + // 空注释,避免sonar警告 + } + + @Around("datasourcePointCut()") + public Object around(ProceedingJoinPoint point) throws Throwable { + Class clazz = point.getTarget().getClass(); + MyDataSource ds = clazz.getAnnotation(MyDataSource.class); + // 通过判断 DataSource 中的值来判断当前方法应用哪个数据源 + Integer originalType = DataSourceContextHolder.setDataSourceType(ds.value()); + log.debug("set datasource is " + ds.value()); + try { + return point.proceed(); + } finally { + DataSourceContextHolder.unset(originalType); + log.debug("unset datasource is " + originalType); + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/aop/DataSourceResolveAspect.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/aop/DataSourceResolveAspect.java new file mode 100644 index 00000000..f2697a64 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/aop/DataSourceResolveAspect.java @@ -0,0 +1,73 @@ +package com.orangeforms.common.core.aop; + +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.util.DataSourceResolver; +import com.orangeforms.common.core.config.DataSourceContextHolder; +import com.orangeforms.common.core.util.ApplicationContextHolder; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.Signature; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * 基于自定义解析规则的多数据源AOP切面处理类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Aspect +@Component +@Order(1) +@Slf4j +public class DataSourceResolveAspect { + + private final Map, DataSourceResolver> resolverMap = new ConcurrentHashMap<>(); + + /** + * 所有配置MyDataSourceResovler注解的Service实现类。 + */ + @Pointcut("execution(public * com.orangeforms..service..*(..)) " + + "&& @target(com.orangeforms.common.core.annotation.MyDataSourceResolver)") + public void datasourceResolverPointCut() { + // 空注释,避免sonar警告 + } + + @Around("datasourceResolverPointCut()") + public Object around(ProceedingJoinPoint point) throws Throwable { + Class clazz = point.getTarget().getClass(); + MyDataSourceResolver dsr = clazz.getAnnotation(MyDataSourceResolver.class); + Class resolverClass = dsr.resolver(); + DataSourceResolver resolver = + resolverMap.computeIfAbsent(resolverClass, ApplicationContextHolder::getBean); + Integer type = resolver.resolve(dsr.arg(), dsr.intArg(), this.getMethodName(point), point.getArgs()); + Integer originalType = null; + if (type != null) { + // 通过判断 DataSource 中的值来判断当前方法应用哪个数据源 + originalType = DataSourceContextHolder.setDataSourceType(type); + log.debug("set datasource is " + type); + } + try { + return point.proceed(); + } finally { + if (type != null) { + DataSourceContextHolder.unset(originalType); + log.debug("unset datasource is " + originalType); + } + } + } + + private String getMethodName(JoinPoint joinPoint) { + Signature signature = joinPoint.getSignature(); + MethodSignature methodSignature = (MethodSignature) signature; + return methodSignature.getMethod().getName(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/dao/BaseDaoMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/dao/BaseDaoMapper.java new file mode 100644 index 00000000..8da1978e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/dao/BaseDaoMapper.java @@ -0,0 +1,87 @@ +package com.orangeforms.common.core.base.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; +import java.util.Map; + +/** + * 数据访问对象的基类。 + * + * @param 主Model实体对象。 + * @author Jerry + * @date 2024-07-02 + */ +public interface BaseDaoMapper extends BaseMapper { + + /** + * 根据指定的表名、显示字段列表、过滤条件字符串和分组字段,返回聚合计算后的查询结果。 + * + * @param selectTable 表名称。 + * @param selectFields 返回字段列表,逗号分隔。 + * @param whereClause SQL常量形式的条件从句。 + * @param groupBy 分组字段列表,逗号分隔。 + * @return 对象可选字段Map列表。 + */ + @Select("") + List> getGroupedListByCondition( + @Param("selectTable") String selectTable, + @Param("selectFields") String selectFields, + @Param("whereClause") String whereClause, + @Param("groupBy") String groupBy); + + /** + * 根据指定的表名、显示字段列表、过滤条件字符串和排序字符串,返回查询结果。 + * + * @param selectTable 表名称。 + * @param selectFields 选择的字段列表。 + * @param whereClause 过滤字符串。 + * @param orderBy 排序字符串。 + * @return 查询结果。 + */ + @Select("") + List> getListByCondition( + @Param("selectTable") String selectTable, + @Param("selectFields") String selectFields, + @Param("whereClause") String whereClause, + @Param("orderBy") String orderBy); + + /** + * 用指定过滤条件,计算记录数量。 + * + * @param selectTable 表名称。 + * @param whereClause 过滤字符串。 + * @return 返回过滤后的数据数量。 + */ + @Select("") + int getCountByCondition(@Param("selectTable") String selectTable, @Param("whereClause") String whereClause); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/mapper/BaseModelMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/mapper/BaseModelMapper.java new file mode 100644 index 00000000..0713d5e4 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/mapper/BaseModelMapper.java @@ -0,0 +1,124 @@ +package com.orangeforms.common.core.base.mapper; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * Model对象到Domain类型对象的相互转换。实现类通常声明在Model实体类中。 + * + * @param Domain域对象类型。 + * @param Model实体对象类型。 + * @author Jerry + * @date 2024-07-02 + */ +public interface BaseModelMapper { + + /** + * 转换Model实体对象到Domain域对象。 + * + * @param model Model实体对象。 + * @return Domain域对象。 + */ + D fromModel(M model); + + /** + * 转换Model实体对象列表到Domain域对象列表。 + * + * @param modelList Model实体对象列表。 + * @return Domain域对象列表。 + */ + List fromModelList(List modelList); + + /** + * 转换Domain域对象到Model实体对象。 + * + * @param domain Domain域对象。 + * @return Model实体对象。 + */ + M toModel(D domain); + + /** + * 转换Domain域对象列表到Model实体对象列表。 + * + * @param domainList Domain域对象列表。 + * @return Model实体对象列表。 + */ + List toModelList(List domainList); + + /** + * 转换bean到map + * + * @param bean bean对象。 + * @param ignoreNullValue 值为null的字段是否转换到Map。 + * @param bean类型。 + * @return 转换后的map对象。 + */ + default Map beanToMap(T bean, boolean ignoreNullValue) { + return BeanUtil.beanToMap(bean, false, ignoreNullValue); + } + + /** + * 转换bean集合到map集合 + * + * @param dataList bean对象集合。 + * @param ignoreNullValue 值为null的字段是否转换到Map。 + * @param bean类型。 + * @return 转换后的map对象集合。 + */ + default List> beanToMap(List dataList, boolean ignoreNullValue) { + if (CollUtil.isEmpty(dataList)) { + return new LinkedList<>(); + } + return dataList.stream() + .map(o -> BeanUtil.beanToMap(o, false, ignoreNullValue)) + .collect(Collectors.toList()); + } + + /** + * 转换map到bean。 + * + * @param map map对象。 + * @param beanClazz bean的Class对象。 + * @param bean类型。 + * @return 转换后的bean对象。 + */ + default T mapToBean(Map map, Class beanClazz) { + return BeanUtil.toBeanIgnoreError(map, beanClazz); + } + + /** + * 转换map集合到bean集合。 + * + * @param mapList map对象集合。 + * @param beanClazz bean的Class对象。 + * @param bean类型。 + * @return 转换后的bean对象集合。 + */ + default List mapToBean(List> mapList, Class beanClazz) { + if (CollUtil.isEmpty(mapList)) { + return new LinkedList<>(); + } + return mapList.stream() + .map(m -> BeanUtil.toBeanIgnoreError(m, beanClazz)) + .collect(Collectors.toList()); + } + + /** + * 对于Map字段到Map字段的映射场景,MapStruct会根据方法签名自动选择该函数 + * 作为对象copy的函数。由于该函数是直接返回的,因此没有对象copy,效率更高。 + * 如果没有该函数,MapStruct会生成如下代码: + * Map map = courseDto.getTeacherIdDictMap(); + * if ( map != null ) { + * course.setTeacherIdDictMap( new HashMap( map ) ); + * } + * + * @param map map对象。 + * @return 直接返回的map。 + */ + default Map mapToMap(Map map) { + return map; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/mapper/DummyModelMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/mapper/DummyModelMapper.java new file mode 100644 index 00000000..3052c396 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/mapper/DummyModelMapper.java @@ -0,0 +1,58 @@ +package com.orangeforms.common.core.base.mapper; + +import java.util.List; + +/** + * 哑元占位对象。Model实体对象和Domain域对象相同的场景下使用。 + * 由于没有实际的数据转换,因此同时保证了代码统一和执行效率。 + * + * @param 数据类型。 + * @author Jerry + * @date 2024-07-02 + */ +public class DummyModelMapper implements BaseModelMapper { + + /** + * 不转换直接返回。 + * + * @param model Model实体对象。 + * @return Domain域对象。 + */ + @Override + public M fromModel(M model) { + return model; + } + + /** + * 不转换直接返回。 + * + * @param modelList Model实体对象列表。 + * @return Domain域对象列表。 + */ + @Override + public List fromModelList(List modelList) { + return modelList; + } + + /** + * 不转换直接返回。 + * + * @param domain Domain域对象。 + * @return Model实体对象。 + */ + @Override + public M toModel(M domain) { + return domain; + } + + /** + * 不转换直接返回。 + * + * @param domainList Domain域对象列表。 + * @return Model实体对象列表。 + */ + @Override + public List toModelList(List domainList) { + return domainList; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/model/BaseModel.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/model/BaseModel.java new file mode 100644 index 00000000..6421b726 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/model/BaseModel.java @@ -0,0 +1,40 @@ +package com.orangeforms.common.core.base.model; + +import com.baomidou.mybatisplus.annotation.TableField; +import lombok.Data; + +import java.util.Date; + +/** + * 实体对象的公共基类,所有子类均必须包含基类定义的数据表字段和实体对象字段。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class BaseModel { + + /** + * 创建者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; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/service/BaseDictService.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/service/BaseDictService.java new file mode 100644 index 00000000..d10aa029 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/service/BaseDictService.java @@ -0,0 +1,229 @@ +package com.orangeforms.common.core.base.service; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ReflectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.orangeforms.common.core.constant.GlobalDeletedFlag; +import com.orangeforms.common.core.cache.DictionaryCache; +import com.orangeforms.common.core.object.TokenData; +import lombok.extern.slf4j.Slf4j; +import org.springframework.transaction.annotation.Transactional; + +import java.io.Serializable; +import java.util.*; + +/** + * 带有缓存功能的字典Service基类,需要留意的是,由于缓存基于Key/Value方式存储, + * 目前仅支持基于主键字段的缓存查找,其他条件的查找仍然从数据源获取。 + * + * @param Model实体对象的类型。 + * @param Model对象主键的类型。 + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public abstract class BaseDictService + extends BaseService implements IBaseDictService { + + /** + * 缓存池对象。 + */ + protected DictionaryCache dictionaryCache; + + /** + * 构造函数使用缺省缓存池对象。 + */ + protected BaseDictService() { + super(); + } + + /** + * 重新加载数据库中所有当前表数据到系统内存。 + * + * @param force true则强制刷新,如果false,当缓存中存在数据时不刷新。 + */ + @Override + public void reloadCachedData(boolean force) { + // 在非强制刷新情况下。 + // 先行判断缓存中是否存在数据,如果有就不加载了。 + if (!force && dictionaryCache.getCount() > 0) { + return; + } + List allList = super.getAllList(); + dictionaryCache.reload(allList, force); + } + + /** + * 保存新增对象。 + * + * @param data 新增对象。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public M saveNew(M data) { + // 清空全部缓存 + dictionaryCache.invalidateAll(); + if (deletedFlagFieldName != null) { + ReflectUtil.setFieldValue(data, deletedFlagFieldName, GlobalDeletedFlag.NORMAL); + } + if (tenantIdField != null) { + ReflectUtil.setFieldValue(data, tenantIdField, TokenData.takeFromRequest().getTenantId()); + } + mapper().insert(data); + return data; + } + + /** + * 更新数据对象。 + * + * @param data 更新的对象。 + * @param originalData 原有数据对象。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(M data, M originalData) { + dictionaryCache.invalidateAll(); + if (tenantIdField != null) { + ReflectUtil.setFieldValue(data, tenantIdField, TokenData.takeFromRequest().getTenantId()); + } + return mapper().updateById(data) == 1; + } + + /** + * 删除指定数据。 + * + * @param id 主键Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(K id) { + dictionaryCache.invalidateAll(); + return mapper().deleteById(id) == 1; + } + + /** + * 直接从缓存池中获取主键Id关联的数据。如果缓存中不存在,再从数据库中取出并回写到缓存。 + * + * @param id 主键Id。 + * @return 主键关联的数据,不存在返回null。 + */ + @SuppressWarnings("unchecked") + @Override + public M getById(Serializable id) { + M data = dictionaryCache.get((K) id); + if (data != null) { + return data; + } + if (dictionaryCache.getCount() != 0) { + return data; + } + this.reloadCachedData(true); + return dictionaryCache.get((K) id); + } + + /** + * 直接从缓存池中获取所有数据。 + * + * @return 返回所有数据。 + */ + @Override + public List getAllListFromCache() { + List resultList = dictionaryCache.getAll(); + if (CollUtil.isNotEmpty(resultList)) { + return resultList; + } + this.reloadCachedData(true); + return dictionaryCache.getAll(); + } + + /** + * 直接从缓存池中返回符合主键 in (idValues) 条件的所有数据。 + * 对于缓存中不存在的数据,从数据库中获取并回写入缓存。 + * + * @param idValues 主键值列表。 + * @return 检索后的数据列表。 + */ + @Override + public List getInList(Set idValues) { + List resultList = dictionaryCache.getInList(idValues); + // 如果从缓存中获取与请求的id完全相同就直接返回。 + if (resultList.size() == idValues.size()) { + return resultList; + } + // 如果此时缓存中存在数据,说明有部分id是不存在的。也可以直接返回了。 + if (dictionaryCache.getCount() != 0) { + return resultList; + } + // 执行到这里,说明缓存是空的,所有需要重新加载并再次从缓存中读取并返回。 + this.reloadCachedData(true); + return dictionaryCache.getInList(idValues); + } + + @Override + public List getListByParentId(K parentId) { + List resultList = dictionaryCache.getListByParentId(parentId); + // 如果包含数据就直接返回了 + if (CollUtil.isNotEmpty(resultList)) { + return resultList; + } + // 如果缓存中存在该字典数据,说明该parentId下子对象列表为空,也可以直接返回了。 + if (this.getCachedCount() != 0) { + return resultList; + } + // 执行到这里就需要重新加载全部缓存了。 + this.reloadCachedData(true); + return dictionaryCache.getListByParentId(parentId); + } + + /** + * 返回符合 inFilterField in (inFilterValues) 条件的所有数据。属性property是主键,则从缓存中读取。 + * + * @param inFilterField 参与(In-list)过滤的Java字段。 + * @param inFilterValues 参与(In-list)过滤的Java字段值集合。 + * @return 检索后的数据列表。 + */ + @SuppressWarnings("unchecked") + @Override + public List getInList(String inFilterField, Set inFilterValues) { + if (inFilterField.equals(this.idFieldName)) { + return this.getInList((Set) inFilterValues); + } + return super.getInList(inFilterField, inFilterValues); + } + + /** + * 判断参数值列表中的所有数据,是否全部存在。另外,keyName字段在数据表中必须是唯一键值,否则返回结果会出现误判。 + * + * @param inFilterField 待校验的数据字段,这里使用Java对象中的属性,如courseId,而不是数据字段名course_id。 + * @param inFilterValues 数据值集合。 + * @return 全部存在返回true,否则false。 + */ + @SuppressWarnings("unchecked") + @Override + public boolean existUniqueKeyList(String inFilterField, Set inFilterValues) { + if (CollUtil.isEmpty(inFilterValues)) { + return true; + } + if (inFilterField.equals(this.idFieldName)) { + List dataList = this.getInList((Set) inFilterValues); + return dataList.size() == inFilterValues.size(); + } + String columnName = this.safeMapToColumnName(inFilterField); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.in(columnName, inFilterValues); + return mapper().selectCount(queryWrapper) == inFilterValues.size(); + } + + /** + * 获取缓存中的数据数量。 + * + * @return 缓存中的数据总量。 + */ + @Override + public int getCachedCount() { + return dictionaryCache.getCount(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/service/BaseService.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/service/BaseService.java new file mode 100644 index 00000000..ef6c5a7d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/service/BaseService.java @@ -0,0 +1,2368 @@ +package com.orangeforms.common.core.base.service; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.text.StrFormatter; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.core.util.ReflectUtil; +import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.orangeforms.common.core.annotation.*; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.constant.AggregationType; +import com.orangeforms.common.core.constant.GlobalDeletedFlag; +import com.orangeforms.common.core.constant.MaskFieldTypeEnum; +import com.orangeforms.common.core.exception.InvalidDataFieldException; +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.*; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.Assert; + +import java.io.Serializable; +import java.lang.reflect.Modifier; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import java.util.function.Function; + +import static java.util.stream.Collectors.*; + +/** + * 所有Service的基类。 + * + * @param Model对象的类型。 + * @param Model对象主键的类型。 + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public abstract class BaseService extends ServiceImpl, M> implements IBaseService { + + /** + * 当前Service关联的主Model实体对象的Class。 + */ + protected final Class modelClass; + /** + * 当前Service关联的主Model实体对象主键字段的Class。 + */ + protected final Class idFieldClass; + /** + * 当前Service关联的主Model实体对象的实际表名称。 + */ + protected final String tableName; + /** + * 当前Service关联的主Model对象主键字段名称。 + */ + protected String idFieldName; + /** + * 当前Service关联的主数据表中主键列名称。 + */ + protected String idColumnName; + /** + * 当前Service关联的主Model对象逻辑删除字段名称。 + */ + protected String deletedFlagFieldName; + /** + * 当前Service关联的主数据表中逻辑删除字段名称。 + */ + protected String deletedFlagColumnName; + /** + * 当前Service关联的主Model对象租户Id字段。 + */ + protected Field tenantIdField; + /** + * 流程实例状态字段。 + */ + protected Field flowStatusField; + /** + * 流程最后审批状态字段 + */ + protected Field flowLatestApprovalStatusField; + /** + * 脱敏字段列表。 + */ + protected List maskFieldList; + /** + * 当前Service关联的主Model对象租户Id字段名称。 + */ + protected String tenantIdFieldName; + /** + * 当前Service关联的主数据表中租户Id列名称。 + */ + protected String tenantIdColumnName; + /** + * 当前Job服务源主表Model对象最后更新时间字段名称。 + */ + protected String jobUpdateTimeFieldName; + /** + * 当前Job服务源主表Model对象最后更新时间列名称。 + */ + protected String jobUpdateTimeColumnName; + /** + * 当前业务服务源主表Model对象最后更新时间字段名称。 + */ + protected String updateTimeFieldName; + /** + * 当前业务服务源主表Model对象最后更新时间列名称。 + */ + protected String updateTimeColumnName; + /** + * 当前业务服务源主表Model对象最后更新用户Id字段名称。 + */ + protected String updateUserIdFieldName; + /** + * 当前业务服务源主表Model对象最后更新用户Id列名称。 + */ + protected String updateUserIdColumnName; + /** + * 当前Service关联的主Model对象主键字段赋值方法的反射对象。 + */ + protected Method setIdFieldMethod; + /** + * 当前Service关联的主Model对象主键字段访问方法的反射对象。 + */ + protected Method getIdFieldMethod; + /** + * 当前Service关联的主Model对象逻辑删除字段赋值方法的反射对象。 + */ + protected Method setDeletedFlagMethod; + /** + * 当前Service关联的全局字典对象的结构列表,该字段在系统启动阶段一次性预加载,提升运行时效率。 + */ + protected final List relationGlobalDictStructList = new LinkedList<>(); + /** + * 当前Service关联的主Model对象的所有常量字典关联的结构列表,该字段在系统启动阶段一次性预加载,提升运行时效率。 + */ + protected final List relationConstDictStructList = new LinkedList<>(); + /** + * 当前Service关联的主Model对象的所有字典关联的结构列表,该字段在系统启动阶段一次性预加载,提升运行时效率。 + */ + protected final List localRelationDictStructList = new LinkedList<>(); + /** + * 当前Service关联的主Model对象的所有一对一关联的结构列表,该字段在系统启动阶段一次性预加载,提升运行时效率。 + */ + protected final List localRelationOneToOneStructList = new LinkedList<>(); + /** + * 当前Service关联的主Model对象的所有一对多关联的结构列表,该字段在系统启动阶段一次性预加载,提升运行时效率。 + */ + protected final List localRelationOneToManyStructList = new LinkedList<>(); + /** + * 当前Service关联的主Model对象的所有多对多关联的结构列表,该字段在系统启动阶段一次性预加载,提升运行时效率。 + */ + protected final List localRelationManyToManyStructList = new LinkedList<>(); + /** + * 当前Service关联的主Model对象的所有一对多聚合关联的结构列表,该字段在系统启动阶段一次性预加载,提升运行时效率。 + */ + protected final List localRelationOneToManyAggrStructList = new LinkedList<>(); + /** + * 当前Service关联的主Model对象的所有多对多聚合关联的结构列表,该字段在系统启动阶段一次性预加载,提升运行时效率。 + */ + protected final List localRelationManyToManyAggrStructList = new LinkedList<>(); + /** + * 基础表的实体对象及表信息。 + */ + protected final TableModelInfo tableModelInfo = new TableModelInfo(); + private final Map, MaskFieldHandler> maskFieldHandlerMap = new ConcurrentHashMap<>(); + + private static final String GROUPED_KEY = "GROUPED_KEY"; + private static final String AGGREGATED_VALUE = "AGGREGATED_VALUE"; + private static final String AND_OP = " AND "; + private static final String ORDER_BY = " ORDER BY "; + + @Override + public BaseDaoMapper getBaseMapper() { + return mapper(); + } + + /** + * 构造函数,在实例化的时候,一次性完成所有有关主Model对象信息的加载。 + */ + @SuppressWarnings("unchecked") + protected BaseService() { + Class type = getClass(); + while (!(type.getGenericSuperclass() instanceof ParameterizedType)) { + type = type.getSuperclass(); + } + modelClass = (Class) ((ParameterizedType) type.getGenericSuperclass()).getActualTypeArguments()[0]; + idFieldClass = (Class) ((ParameterizedType) type.getGenericSuperclass()).getActualTypeArguments()[1]; + this.tableName = modelClass.getAnnotation(TableName.class).value(); + Field[] fields = ReflectUtil.getFields(modelClass); + for (Field field : fields) { + initializeField(field); + } + tableModelInfo.setModelName(modelClass.getSimpleName()); + tableModelInfo.setTableName(this.tableName); + tableModelInfo.setKeyFieldName(idFieldName); + tableModelInfo.setKeyColumnName(idColumnName); + } + + @Override + public TableModelInfo getTableModelInfo() { + return this.tableModelInfo; + } + + private void initializeField(Field field) { + if (idFieldName == null && null != field.getAnnotation(TableId.class)) { + idFieldName = field.getName(); + TableId c = field.getAnnotation(TableId.class); + idColumnName = c == null ? idFieldName : c.value(); + setIdFieldMethod = ReflectUtil.getMethod( + modelClass, "set" + StrUtil.upperFirst(idFieldName), idFieldClass); + getIdFieldMethod = ReflectUtil.getMethod( + modelClass, "get" + StrUtil.upperFirst(idFieldName)); + } + if (null != field.getAnnotation(JobUpdateTimeColumn.class)) { + jobUpdateTimeFieldName = field.getName(); + jobUpdateTimeColumnName = this.safeMapToColumnName(jobUpdateTimeFieldName); + } + if (null != field.getAnnotation(TableLogic.class)) { + deletedFlagFieldName = field.getName(); + deletedFlagColumnName = this.safeMapToColumnName(deletedFlagFieldName); + setDeletedFlagMethod = ReflectUtil.getMethod( + modelClass, "set" + StrUtil.upperFirst(deletedFlagFieldName), Integer.class); + } + if (null != field.getAnnotation(TenantFilterColumn.class)) { + tenantIdField = field; + tenantIdFieldName = field.getName(); + tenantIdColumnName = this.safeMapToColumnName(tenantIdFieldName); + } + if (null != field.getAnnotation(FlowStatusColumn.class)) { + flowStatusField = field; + } + if (null != field.getAnnotation(FlowLatestApprovalStatusColumn.class)) { + flowLatestApprovalStatusField = field; + } + if (null != field.getAnnotation(MaskField.class)) { + if (maskFieldList == null) { + maskFieldList = new LinkedList<>(); + } + maskFieldList.add(field); + } + } + + /** + * 获取子类中注入的Mapper类。 + * + * @return 子类中注入的Mapper类。 + */ + protected abstract BaseDaoMapper mapper(); + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean saveBatch(Collection dataList) { + dataList.forEach(baseMapper::insert); + return true; + } + + @SuppressWarnings("unchecked") + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNewOrUpdate(M data, Consumer saveNew, BiConsumer update) { + if (data == null) { + return; + } + K id = (K) ReflectUtil.getFieldValue(data, idFieldName); + if (id == null) { + saveNew.accept(data); + } else { + update.accept(data, this.getById(id)); + } + } + + @SuppressWarnings("unchecked") + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNewOrUpdateBatch(List dataList, Consumer> saveNewBatch, BiConsumer update) { + if (CollUtil.isEmpty(dataList)) { + return; + } + List saveNewDataList = dataList.stream() + .filter(c -> ReflectUtil.getFieldValue(c, idFieldName) == null).collect(toList()); + if (CollUtil.isNotEmpty(saveNewDataList)) { + saveNewBatch.accept(saveNewDataList); + } + List updateDataList = dataList.stream() + .filter(c -> ReflectUtil.getFieldValue(c, idFieldName) != null).collect(toList()); + if (CollUtil.isNotEmpty(updateDataList)) { + for (M data : updateDataList) { + K id = (K) ReflectUtil.getFieldValue(data, idFieldName); + update.accept(data, this.getById(id)); + } + } + } + + /** + * 根据过滤条件删除数据。 + * + * @param filter 过滤对象。 + * @return 删除数量。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public Integer removeBy(M filter) { + return mapper().delete(new QueryWrapper<>(filter)); + } + + @Transactional(rollbackFor = Exception.class) + public boolean remove(K id) { + return mapper().deleteById(id) > 0; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void updateBatchOneToManyRelation( + String relationFieldName, + Object relationFieldValue, + String updateUserIdFieldName, + String updateTimeFieldName, + List dataList, + Consumer> batchInserter) { + // 删除在现有数据列表dataList中不存在的从表数据。 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(this.safeMapToColumnName(relationFieldName), relationFieldValue); + if (CollUtil.isNotEmpty(dataList)) { + Set keptIdSet = dataList.stream() + .filter(c -> ReflectUtil.getFieldValue(c, idFieldName) != null) + .map(c -> ReflectUtil.getFieldValue(c, idFieldName)).collect(toSet()); + if (CollUtil.isNotEmpty(keptIdSet)) { + queryWrapper.notIn(idColumnName, keptIdSet); + } + } + mapper().delete(queryWrapper); + if (CollUtil.isEmpty(dataList)) { + return; + } + // 没有包含主键的对象被视为新对象,为了效率最优化,这里执行批量插入。 + List newDataList = dataList.stream() + .filter(c -> ReflectUtil.getFieldValue(c, idFieldName) == null).collect(toList()); + if (CollUtil.isNotEmpty(newDataList)) { + newDataList.forEach(o -> ReflectUtil.setFieldValue(o, relationFieldName, relationFieldValue)); + batchInserter.accept(newDataList); + } + // 对于主键已经存在的数据,我们视为已存在数据,这里执行逐条更新操作。 + List updateDataList = + dataList.stream().filter(c -> ReflectUtil.getFieldValue(c, idFieldName) != null).toList(); + for (M updateData : updateDataList) { + // 如果前端将更新用户Id置空,这里使用当前用户更新该字段。 + if (updateUserIdFieldName != null) { + ReflectUtil.setFieldValue(updateData, updateUserIdFieldName, TokenData.takeFromRequest().getUserId()); + } + // 如果前端将更新时间置空,这里使用当前时间更新该字段。 + if (updateTimeFieldName != null) { + ReflectUtil.setFieldValue(updateData, updateTimeFieldName, new Date()); + } + if (this.tenantIdField != null) { + ReflectUtil.setFieldValue(updateData, tenantIdField, TokenData.takeFromRequest().getTenantId()); + } + if (this.deletedFlagFieldName != null) { + ReflectUtil.setFieldValue(updateData, deletedFlagFieldName, GlobalDeletedFlag.NORMAL); + } + @SuppressWarnings("unchecked") + K id = (K) ReflectUtil.getFieldValue(updateData, idFieldName); + this.compareAndSetMaskFieldData(updateData, id); + mapper().updateById(updateData); + } + } + + /** + * 判断指定字段的数据是否存在,且仅仅存在一条记录。 + * 如果是基于主键的过滤,会直接调用existId过滤函数,提升性能。在有缓存的场景下,也可以利用缓存。 + * + * @param fieldName 待过滤的字段名(Java 字段)。 + * @param fieldValue 字段值。 + * @return 存在且仅存在一条返回true,否则false。 + */ + @SuppressWarnings("unchecked") + @Override + public boolean existOne(String fieldName, Object fieldValue) { + if (fieldName.equals(this.idFieldName)) { + return this.existId((K) fieldValue); + } + String columnName = MyModelUtil.mapToColumnName(fieldName, modelClass); + return mapper().selectCount(new QueryWrapper().eq(columnName, fieldValue)) == 1; + } + + /** + * 判断主键Id关联的数据是否存在。 + * + * @param id 主键Id。 + * @return 存在返回true,否则false。 + */ + @Override + public boolean existId(K id) { + return getById(id) != null; + } + + @Override + public M getOne(M filter) { + return mapper().selectOne(new QueryWrapper<>(filter)); + } + + /** + * 返回符合 filterField = filterValue 条件的一条数据。 + * + * @param filterField 过滤的Java字段。 + * @param filterValue 过滤的Java字段值。 + * @return 查询后的数据对象。 + */ + @SuppressWarnings("unchecked") + @Override + public M getOne(String filterField, Object filterValue) { + if (filterField.equals(idFieldName)) { + return this.getById((K) filterValue); + } + String columnName = this.safeMapToColumnName(filterField); + QueryWrapper queryWrapper = new QueryWrapper().eq(columnName, filterValue); + return mapper().selectOne(queryWrapper); + } + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * + * @param id 主表主键Id。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @return 查询结果对象。 + */ + @Override + public M getByIdWithRelation(K id, MyRelationParam relationParam) { + M dataObject = this.getById(id); + this.buildRelationForData(dataObject, relationParam); + return dataObject; + } + + @Override + public M getById(Serializable id) { + return this.mapper().selectById(id); + } + + /** + * 获取所有数据。 + * + * @return 返回所有数据。 + */ + @Override + public List getAllList() { + return mapper().selectList(Wrappers.emptyWrapper()); + } + + /** + * 获取排序后所有数据。 + * + * @param orderByProperties 需要排序的字段属性,这里使用Java对象中的属性名,而不是数据库字段名。 + * @return 返回排序后所有数据。 + */ + @Override + public List getAllListByOrder(String... orderByProperties) { + List columns = new ArrayList<>(orderByProperties.length); + for (String orderByProperty : orderByProperties) { + columns.add(this.safeMapToColumnName(orderByProperty)); + } + return mapper().selectList(new QueryWrapper().orderByAsc(columns)); + } + + /** + * 判断参数值主键集合中的所有数据,是否全部存在 + * + * @param idSet 待校验的主键集合。 + * @return 全部存在返回true,否则false。 + */ + @Override + public boolean existAllPrimaryKeys(Set idSet) { + if (CollUtil.isEmpty(idSet)) { + return true; + } + return this.existUniqueKeyList(idFieldName, idSet); + } + + /** + * 判断参数值列表中的所有数据,是否全部存在。另外,keyName字段在数据表中必须是唯一键值,否则返回结果会出现误判。 + * + * @param inFilterField 待校验的数据字段,这里使用Java对象中的属性,如courseId,而不是数据字段名course_id + * @param inFilterValues 数据值列表。 + * @return 全部存在返回true,否则false。 + */ + @Override + public boolean existUniqueKeyList(String inFilterField, Set inFilterValues) { + if (CollUtil.isEmpty(inFilterValues)) { + return true; + } + String column = this.safeMapToColumnName(inFilterField); + return mapper().selectCount(new QueryWrapper().in(column, inFilterValues)) == inFilterValues.size(); + } + + @Override + public List notExist(String filterField, Set filterSet, boolean findFirst) { + List notExistIdList = new LinkedList<>(); + int start = 0; + int count = 1000; + if (filterSet.size() > count) { + do { + int end = Math.min(filterSet.size(), start + count); + List subFilterList = CollUtil.sub(filterSet, start, end); + doNotExistQuery(filterField, subFilterList, findFirst, notExistIdList); + if ((findFirst && CollUtil.isNotEmpty(notExistIdList)) || end == filterSet.size()) { + break; + } + start += count; + } while (true); + } else { + doNotExistQuery(filterField, filterSet, findFirst, notExistIdList); + } + return notExistIdList; + } + + private void doNotExistQuery( + String filterField, Collection filterSet, boolean findFirst, List notExistIdList) { + String columnName = this.safeMapToColumnName(filterField); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.in(columnName, filterSet); + queryWrapper.select(columnName); + Set existIdSet = mapper().selectList(queryWrapper).stream() + .map(c -> ReflectUtil.getFieldValue(c, filterField)).collect(toSet()); + for (R filterData : filterSet) { + if (!existIdSet.contains(filterData)) { + notExistIdList.add(filterData); + if (findFirst) { + break; + } + } + } + } + + @Override + public List getInList(Set idValues) { + return this.getInList(idFieldName, idValues, null); + } + + @Override + public List getInList(String inFilterField, Set inFilterValues) { + return this.getInList(inFilterField, inFilterValues, null); + } + + @Override + public List getInList(String inFilterField, Set inFilterValues, String orderBy) { + if (CollUtil.isEmpty(inFilterValues)) { + return new LinkedList<>(); + } + String column = this.safeMapToColumnName(inFilterField); + QueryWrapper queryWrapper = new QueryWrapper().in(column, inFilterValues); + if (StrUtil.isNotBlank(orderBy)) { + queryWrapper.last(ORDER_BY + orderBy); + } + return mapper().selectList(queryWrapper); + } + + @Override + public List getInListWithRelation(Set idValues, MyRelationParam relationParam) { + List resultList = this.getInList(idValues); + this.buildRelationForDataList(resultList, relationParam); + return resultList; + } + + @Override + public List getInListWithRelation(String inFilterField, Set inFilterValues, MyRelationParam relationParam) { + List resultList = this.getInList(inFilterField, inFilterValues); + this.buildRelationForDataList(resultList, relationParam); + return resultList; + } + + @Override + public List getInListWithRelation( + String inFilterField, Set inFilterValues, String orderBy, MyRelationParam relationParam) { + List resultList = this.getInList(inFilterField, inFilterValues, orderBy); + this.buildRelationForDataList(resultList, relationParam); + return resultList; + } + + @Override + public List getNotInList(Set idValues) { + return this.getNotInList(idFieldName, idValues, null); + } + + @Override + public List getNotInList(String inFilterField, Set inFilterValues) { + return this.getNotInList(inFilterField, inFilterValues, null); + } + + @Override + public List getNotInList(String inFilterField, Set inFilterValues, String orderBy) { + QueryWrapper queryWrapper; + if (CollUtil.isEmpty(inFilterValues)) { + queryWrapper = new QueryWrapper<>(); + } else { + String column = this.safeMapToColumnName(inFilterField); + queryWrapper = new QueryWrapper().notIn(column, inFilterValues); + } + if (StrUtil.isNotBlank(orderBy)) { + queryWrapper.last(ORDER_BY + orderBy); + } + return mapper().selectList(queryWrapper); + } + + @Override + public List getNotInListWithRelation(Set idValues, MyRelationParam relationParam) { + List resultList = this.getNotInList(idValues); + this.buildRelationForDataList(resultList, relationParam); + return resultList; + } + + @Override + public List getNotInListWithRelation( + String inFilterField, Set inFilterValues, MyRelationParam relationParam) { + List resultList = this.getNotInList(inFilterField, inFilterValues); + this.buildRelationForDataList(resultList, relationParam); + return resultList; + } + + @Override + public List getNotInListWithRelation( + String inFilterField, Set inFilterValues, String orderBy, MyRelationParam relationParam) { + List resultList = this.getNotInList(inFilterField, inFilterValues, orderBy); + this.buildRelationForDataList(resultList, relationParam); + return resultList; + } + + @Override + public long getCountByFilter(M filter) { + return mapper().selectCount(new QueryWrapper<>(filter)); + } + + @Override + public boolean existByFilter(M filter) { + return this.getCountByFilter(filter) > 0; + } + + @Override + public List getListByFilter(M filter) { + return mapper().selectList(new QueryWrapper<>(filter)); + } + + @Override + public List getListWithRelationByFilter(M filter, String orderBy, MyRelationParam relationParam) { + QueryWrapper queryWrapper = new QueryWrapper<>(filter); + if (StrUtil.isNotBlank(orderBy)) { + queryWrapper.last(ORDER_BY + orderBy); + } + List resultList = mapper().selectList(queryWrapper); + this.buildRelationForDataList(resultList, relationParam); + return resultList; + } + + /** + * 获取父主键Id下的所有子数据列表。 + * + * @param parentIdFieldName 父主键字段名字,如"courseId"。 + * @param parentId 父主键的值。 + * @return 父主键Id下的所有子数据列表。 + */ + @Override + public List getListByParentId(String parentIdFieldName, K parentId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + String parentIdColumn = this.safeMapToColumnName(parentIdFieldName); + if (parentId != null) { + queryWrapper.eq(parentIdColumn, parentId); + } else { + queryWrapper.isNull(parentIdColumn); + } + return mapper().selectList(queryWrapper); + } + + /** + * 根据指定的显示字段列表、过滤条件字符串和分组字符串,返回聚合计算后的查询结果。(基本是内部框架使用,不建议外部接口直接使用)。 + * + * @param selectFields 选择的字段列表,多个字段逗号分隔。 + * NOTE: 如果数据表字段和Java对象字段名字不同,Java对象字段应该以别名的形式出现。 + * 如: table_column_name modelFieldName。否则无法被反射回Bean对象。 + * @param whereClause SQL常量形式的条件从句。 + * @param groupBy SQL常量形式分组字段列表,逗号分隔。 + * @return 聚合计算后的数据结果集。 + */ + @Override + public List> getGroupedListByCondition( + String selectFields, String whereClause, String groupBy) { + return mapper().getGroupedListByCondition(tableName, selectFields, whereClause, groupBy); + } + + /** + * 根据指定的显示字段列表、过滤条件字符串和排序字符串,返回查询结果。(基本是内部框架使用,不建议外部接口直接使用)。 + * + * @param selectList 选择的Java字段列表。如果为空表示返回全部字段。 + * @param filter 过滤对象。 + * @param whereClause SQL常量形式的条件从句。 + * @param orderBy SQL常量形式排序字段列表,逗号分隔。 + * @return 查询结果。 + */ + @Override + public List getListByCondition(List selectList, M filter, String whereClause, String orderBy) { + QueryWrapper queryWrapper = new QueryWrapper<>(filter); + if (CollUtil.isNotEmpty(selectList)) { + String[] columns = new String[selectList.size()]; + for (int i = 0; i < selectList.size(); i++) { + columns[i] = this.safeMapToColumnName(selectList.get(i)); + } + queryWrapper.select(columns); + } + if (StrUtil.isNotBlank(whereClause)) { + queryWrapper.apply(whereClause); + } + if (StrUtil.isNotBlank(orderBy)) { + queryWrapper.last(ORDER_BY + orderBy); + } + return mapper().selectList(queryWrapper); + } + + /** + * 用指定过滤条件,计算记录数量。(基本是内部框架使用,不建议外部接口直接使用)。 + * + * @param whereClause SQL常量形式的条件从句。 + * @return 返回过滤后的数据数量。 + */ + @Override + public Integer getCountByCondition(String whereClause) { + return mapper().getCountByCondition(this.tableName, whereClause); + } + + @Override + public void maskFieldData(M data, Set ignoreFieldSet) { + if (data != null) { + this.maskFieldDataList(CollUtil.newArrayList(data), ignoreFieldSet); + } + } + + @Override + public void maskFieldDataList(List dataList, Set ignoreFieldSet) { + if (CollUtil.isEmpty(maskFieldList)) { + return; + } + for (Field maskField : maskFieldList) { + if (!CollUtil.contains(ignoreFieldSet, maskField.getName())) { + MaskField anno = maskField.getAnnotation(MaskField.class); + for (M data : dataList) { + Object maskedValue = this.doMaskFieldData(data, maskField, anno); + ReflectUtil.setFieldValue(data, maskField, maskedValue); + } + } + } + } + + @Override + public void compareAndSetMaskFieldData(M data, M originalData) { + if (CollUtil.isEmpty(maskFieldList)) { + return; + } + for (Field maskField : maskFieldList) { + Object value = ReflectUtil.getFieldValue(data, maskField); + if (value == null) { + continue; + } + MaskField anno = maskField.getAnnotation(MaskField.class); + String maskChar = String.valueOf(anno.maskChar()); + // 如果此时包含了掩码字符,说明数据没有变化,就要和原字段值脱敏后的结果比对。 + // 如果一致就用脱敏前的原值,覆盖当前提交的(包含掩码的)值,否则说明进行了部分 + // 修改,但是字段值中仍然含有掩码字符,这是不允许的。 + if (value.toString().contains(maskChar)) { + Object maskedOriginalValue = this.doMaskFieldData(originalData, maskField, anno); + if (ObjectUtil.notEqual(value, maskedOriginalValue)) { + throw new MyRuntimeException("数据验证失败,不能仅修改部分脱敏数据!"); + } + Object originalValue = ReflectUtil.getFieldValue(originalData, maskField); + ReflectUtil.setFieldValue(data, maskField, originalValue); + } + } + } + + @Override + public void verifyMaskFieldData(M data) { + if (CollUtil.isEmpty(maskFieldList)) { + return; + } + for (Field field : maskFieldList) { + Object value = ReflectUtil.getFieldValue(data, field); + if (value != null) { + String maskChar = String.valueOf(field.getAnnotation(MaskField.class).maskChar()); + if (value.toString().contains(maskChar)) { + throw new MyRuntimeException("数据验证失败,字段 [" + field.getName() + "] 数据存在脱敏掩码字符!"); + } + } + } + } + + @Override + public CallResult verifyRelatedData(M data, M originalData) { + return CallResult.ok(); + } + + @SuppressWarnings("unchecked") + @Override + public CallResult verifyRelatedData(M data) { + if (data == null) { + return CallResult.ok(); + } + Object id = ReflectUtil.getFieldValue(data, idFieldName); + if (id == null) { + return this.verifyRelatedData(data, null); + } + M originalData = this.getById((K) id); + if (originalData == null) { + return CallResult.error("数据验证失败,源数据不存在!"); + } + return this.verifyRelatedData(data, originalData); + } + + @SuppressWarnings("unchecked") + @Override + public CallResult verifyRelatedData(List dataList) { + if (CollUtil.isEmpty(dataList)) { + return CallResult.ok(); + } + // 1. 先过滤出数据列表中的主键Id集合。 + Set idList = dataList.stream() + .filter(c -> ReflectUtil.getFieldValue(c, idFieldName) != null) + .map(c -> (K) ReflectUtil.getFieldValue(c, idFieldName)).collect(toSet()); + // 2. 列表中,我们目前仅支持全部是更新数据,或全部新增数据,不能混着。如果有主键值,说明当前全是更新数据。 + if (CollUtil.isNotEmpty(idList)) { + // 3. 这里是批量读取的优化,用一个主键值得in list查询,一步获取全部原有数据。然后再在内存中基于Map排序。 + List originalList = this.getInList(idList); + Map originalMap = originalList.stream() + .collect(toMap(c -> ReflectUtil.getFieldValue(c, idFieldName), c2 -> c2)); + // 迭代列表,传入当前最新数据和更新前数据进行比对,如果关联数据变化了,就对新数据进行合法性验证。 + for (M data : dataList) { + CallResult result = this.verifyRelatedData( + data, originalMap.get(ReflectUtil.getFieldValue(data, idFieldName))); + if (!result.isSuccess()) { + return result; + } + } + } else { + // 4. 迭代列表,传入当前最新数据,对关联数据进行合法性验证。 + for (M data : dataList) { + CallResult result = this.verifyRelatedData(data, null); + if (!result.isSuccess()) { + return result; + } + } + } + return CallResult.ok(); + } + + @Override + public CallResult verifyImportForConstDict(List dataList, String fieldName, Function idGetter) { + if (CollUtil.isEmpty(dataList)) { + return CallResult.ok(); + } + // 这里均为内部调用方法,因此出现任何错误均为代码BUG,所以我们会及时抛出异常。 + Field field = ReflectUtil.getField(modelClass, fieldName); + if (field == null) { + String errorMessage = StrFormatter.format("FieldName [{}] doesn't exist", fieldName); + throw new MyRuntimeException(errorMessage); + } + RelationConstDict relationConstDict = field.getAnnotation(RelationConstDict.class); + if (relationConstDict == null) { + String errorMessage = StrFormatter.format("FieldName [{}] doesn't have RelationConstDict.", fieldName); + throw new MyRuntimeException(errorMessage); + } + Method m = ReflectUtil.getMethodByName(relationConstDict.constantDictClass(), "isValid"); + for (M data : dataList) { + R id = idGetter.apply(data); + if (id != null) { + boolean ok = ReflectUtil.invokeStatic(m, id); + if (!ok) { + String errorMessage = String.format("数据验证失败,字段 [%s] 存在无效的常量字典值 [%s]!", + relationConstDict.masterIdField(), id); + return CallResult.error(errorMessage, data); + } + } + } + return CallResult.ok(); + } + + @Override + public CallResult verifyImportForGlobalDict(List dataList, String fieldName, Function idGetter) { + if (CollUtil.isEmpty(dataList)) { + return CallResult.ok(); + } + // 这里均为内部调用方法,因此出现任何错误均为代码BUG,所以我们会及时抛出异常。 + Field field = ReflectUtil.getField(modelClass, fieldName); + if (field == null) { + throw new MyRuntimeException(StrFormatter.format("FieldName [{}] does not exist.", fieldName)); + } + RelationGlobalDict relationGlobalDict = field.getAnnotation(RelationGlobalDict.class); + if (relationGlobalDict == null) { + throw new MyRuntimeException( + StrFormatter.format("FieldName [{}] doesn't have RelationGlobalDict.", fieldName)); + } + RelationStruct relationStruct = this.relationGlobalDictStructList.stream() + .filter(c -> c.relationField.getName().equals(fieldName)).findFirst().orElse(null); + Assert.notNull(relationStruct, "GlobalDictRelationStruct for [" + fieldName + "] can't be NULL"); + Map dictMap = ReflectUtil.invoke( + relationStruct.service, + relationStruct.globalDictMethd, + relationStruct.relationGlobalDict.dictCode(), null); + for (M data : dataList) { + R id = idGetter.apply(data); + if (id != null && !dictMap.containsKey(id.toString())) { + String errorMessage = String.format("数据验证失败,字段 [%s] 存在无效的全局编码字典值 [%s]!", + relationGlobalDict.masterIdField(), id); + return CallResult.error(errorMessage, data); + } + } + return CallResult.ok(); + } + + @Override + public CallResult verifyImportForDict(List dataList, String fieldName, Function idGetter) { + if (CollUtil.isEmpty(dataList)) { + return CallResult.ok(); + } + // 这里均为内部调用方法,因此出现任何错误均为代码BUG,所以我们会及时抛出异常。 + Field field = ReflectUtil.getField(modelClass, fieldName); + if (field == null) { + throw new MyRuntimeException(StrFormatter.format("FieldName [{}] does not exist.", fieldName)); + } + RelationDict relationDict = field.getAnnotation(RelationDict.class); + if (relationDict == null) { + throw new MyRuntimeException( + StrFormatter.format("FieldName [{}] doesn't have RelationDict.", fieldName)); + } + BaseService service = ApplicationContextHolder.getBean( + this.getNormalizedSlaveServiceName(relationDict.slaveServiceName(), relationDict.slaveModelClass())); + Set dictIdSet = service.getAllList().stream() + .map(c -> ReflectUtil.getFieldValue(c, relationDict.slaveIdField())).collect(toSet()); + for (M data : dataList) { + R id = idGetter.apply(data); + if (id != null && !dictIdSet.contains(id)) { + String errorMessage = String.format("数据验证失败,字段 [%s] 存在无效的字典表字典值 [%s]!", + relationDict.masterIdField(), id); + return CallResult.error(errorMessage, data); + } + } + return CallResult.ok(); + } + + @Override + public CallResult verifyImportForDatasourceDict(List dataList, String fieldName, Function idGetter) { + if (CollUtil.isEmpty(dataList)) { + return CallResult.ok(); + } + // 这里均为内部调用方法,因此出现任何错误均为代码BUG,所以我们会及时抛出异常。 + Field field = ReflectUtil.getField(modelClass, fieldName); + if (field == null) { + throw new MyRuntimeException(StrFormatter.format("FieldName [{}] doesn't exist.", fieldName)); + } + RelationDict relationDict = field.getAnnotation(RelationDict.class); + if (relationDict == null) { + throw new MyRuntimeException( + StrFormatter.format("FieldName [{}] doesn't have RelationDict.", fieldName)); + } + // 验证数据源字典Id,由于被依赖的数据表,可能包含大量业务数据,因此还是分批做存在性比对更为高效。 + Set idSet = dataList.stream() + .filter(c -> idGetter.apply(c) != null).map(idGetter).collect(toSet()); + if (CollUtil.isNotEmpty(idSet)) { + if (idSet.iterator().next() instanceof String) { + idSet = idSet.stream().filter(c -> StrUtil.isNotBlank((String) c)).collect(toSet()); + } + BaseService slaveService = ApplicationContextHolder.getBean( + this.getNormalizedSlaveServiceName(relationDict.slaveServiceName(), relationDict.slaveModelClass())); + List notExistIdList = slaveService.notExist(relationDict.slaveIdField(), idSet, true); + if (CollUtil.isNotEmpty(notExistIdList)) { + R notExistId = notExistIdList.get(0); + String errorMessage = String.format("数据验证失败,字段 [%s] 存在无效的数据源表字典值 [%s]!", + relationDict.masterIdField(), notExistId); + M data = dataList.stream() + .filter(c -> ObjectUtil.equals(idGetter.apply(c), notExistId)).findFirst().orElse(null); + return CallResult.error(errorMessage, data); + } + } + return CallResult.ok(); + } + + @Override + public CallResult verifyImportForOneToOneRelation(List dataList, String fieldName, Function idGetter) { + if (CollUtil.isEmpty(dataList)) { + return CallResult.ok(); + } + // 这里均为内部调用方法,因此出现任何错误均为代码BUG,所以我们会及时抛出异常。 + Field field = ReflectUtil.getField(modelClass, fieldName); + if (field == null) { + throw new MyRuntimeException(StrFormatter.format("FieldName [{}] doesn't exist", fieldName)); + } + RelationOneToOne relationOneToOne = field.getAnnotation(RelationOneToOne.class); + if (relationOneToOne == null) { + throw new MyRuntimeException( + StrFormatter.format("FieldName [{}] doesn't have RelationOneToOne.", fieldName)); + } + // 验证一对一关联Id,由于被依赖的数据表,可能包含大量业务数据,因此还是分批做存在性比对更为高效。 + Set idSet = dataList.stream() + .filter(c -> idGetter.apply(c) != null).map(idGetter).collect(toSet()); + if (CollUtil.isNotEmpty(idSet)) { + BaseService slaveService = ApplicationContextHolder.getBean( + this.getNormalizedSlaveServiceName(relationOneToOne.slaveServiceName(), relationOneToOne.slaveModelClass())); + List notExistIdList = slaveService.notExist(relationOneToOne.slaveIdField(), idSet, true); + if (CollUtil.isNotEmpty(notExistIdList)) { + R notExistId = notExistIdList.get(0); + String errorMessage = String.format("数据验证失败,字段 [%s] 存在无效的一对一关联值 [%s]!", + relationOneToOne.masterIdField(), notExistId); + M data = dataList.stream() + .filter(c -> ObjectUtil.equals(idGetter.apply(c), notExistId)).findFirst().orElse(null); + return CallResult.error(errorMessage, data); + } + } + return CallResult.ok(); + } + + /** + * 集成所有与主表实体对象相关的关联数据列表。包括本地和远程服务的一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param resultList 主表实体对象列表。数据集成将直接作用于该对象列表。 + * @param relationParam 实体对象数据组装的参数构建器。 + */ + @Override + public void buildRelationForDataList(List resultList, MyRelationParam relationParam) { + this.buildRelationForDataList(resultList, relationParam, null); + } + + /** + * 集成所有与主表实体对象相关的关联数据列表。包括一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param resultList 主表实体对象列表。数据集成将直接作用于该对象列表。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + @Override + public void buildRelationForDataList( + List resultList, MyRelationParam relationParam, Set ignoreFields) { + if (relationParam == null || CollUtil.isEmpty(resultList)) { + return; + } + boolean dataFilterValue = GlobalThreadLocal.setDataFilter(false); + try { + // 集成本地一对一和字段级别的数据关联。 + boolean buildOneToOne = relationParam.isBuildOneToOne() || relationParam.isBuildOneToOneWithDict(); + // 这里集成一对一关联。 + if (buildOneToOne) { + this.buildOneToOneForDataList(resultList, relationParam, ignoreFields); + } + // 集成一对多关联 + if (relationParam.isBuildOneToMany()) { + this.buildOneToManyForDataList(resultList, relationParam, ignoreFields); + } + // 这里集成多对多关联。 + if (relationParam.isBuildRelationManyToMany()) { + this.buildManyToManyForDataList(resultList, ignoreFields); + } + // 这里集成字典关联 + if (relationParam.isBuildDict()) { + // 构建全局字典关联关系 + this.buildGlobalDictForDataList(resultList, ignoreFields); + // 构建常量字典关联关系 + this.buildConstDictForDataList(resultList, ignoreFields); + this.buildDictForDataList(resultList, buildOneToOne, ignoreFields); + } + // 组装本地聚合计算关联数据 + if (relationParam.isBuildRelationAggregation()) { + // 处理多对多场景下,根据主表的结果,进行从表聚合数据的计算。 + this.buildManyToManyAggregationForDataList(resultList, buildAggregationAdditionalWhereCriteria(), ignoreFields); + // 处理多一多场景下,根据主表的结果,进行从表聚合数据的计算。 + this.buildOneToManyAggregationForDataList(resultList, buildAggregationAdditionalWhereCriteria(), ignoreFields); + } + } finally { + GlobalThreadLocal.setDataFilter(dataFilterValue); + } + } + + /** + * 该函数主要用于对查询结果的批量导出。不同于支持分页的列表查询,批量导出没有分页机制, + * 因此在导出数据量较大的情况下,很容易给数据库的内存、CPU和IO带来较大的压力。而通过 + * 我们的分批处理,可以极大的规避该问题的出现几率。调整batchSize的大小,也可以有效的 + * 改善运行效率。 + * 我们目前的处理机制是,先从主表取出所有符合条件的主表数据,这样可以避免分批处理时, + * 后面几批数据,因为skip过多而带来的效率问题。因为是单表过滤,不会给数据库带来过大的压力。 + * 之后再在主表结果集数据上进行分批级联处理。 + * 集成所有与主表实体对象相关的关联数据列表。包括一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param resultList 主表实体对象列表。数据集成将直接作用于该对象列表。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @param batchSize 每批集成的记录数量。小于等于0时将不做分批处理。 + */ + @Override + public void buildRelationForDataList(List resultList, MyRelationParam relationParam, int batchSize) { + this.buildRelationForDataList(resultList, relationParam, batchSize, null); + } + + /** + * 该函数主要用于对查询结果的批量导出。不同于支持分页的列表查询,批量导出没有分页机制, + * 因此在导出数据量较大的情况下,很容易给数据库的内存、CPU和IO带来较大的压力。而通过 + * 我们的分批处理,可以极大的规避该问题的出现几率。调整batchSize的大小,也可以有效的 + * 改善运行效率。 + * 我们目前的处理机制是,先从主表取出所有符合条件的主表数据,这样可以避免分批处理时, + * 后面几批数据,因为skip过多而带来的效率问题。因为是单表过滤,不会给数据库带来过大的压力。 + * 之后再在主表结果集数据上进行分批级联处理。 + * 集成所有与主表实体对象相关的关联数据列表。包括一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param resultList 主表实体对象列表。数据集成将直接作用于该对象列表。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @param batchSize 每批集成的记录数量。小于等于0时将不做分批处理。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + @Override + public void buildRelationForDataList( + List resultList, MyRelationParam relationParam, int batchSize, Set ignoreFields) { + if (CollUtil.isEmpty(resultList)) { + return; + } + if (batchSize <= 0) { + this.buildRelationForDataList(resultList, relationParam); + return; + } + int totalCount = resultList.size(); + int fromIndex = 0; + int toIndex = Math.min(batchSize, totalCount); + while (toIndex > fromIndex) { + List subResultList = resultList.subList(fromIndex, toIndex); + this.buildRelationForDataList(subResultList, relationParam, ignoreFields); + fromIndex = toIndex; + toIndex = Math.min(batchSize + fromIndex, totalCount); + } + } + + /** + * 集成所有与主表实体对象相关的关联数据对象。包括本地和远程服务的一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param dataObject 主表实体对象。数据集成将直接作用于该对象。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @param 实体对象类型。 + */ + @Override + public void buildRelationForData(T dataObject, MyRelationParam relationParam) { + this.buildRelationForData(dataObject, relationParam, null); + } + + /** + * 集成所有与主表实体对象相关的关联数据对象。包括一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param dataObject 主表实体对象。数据集成将直接作用于该对象。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + * @param 实体对象类型。 + */ + @Override + public void buildRelationForData(T dataObject, MyRelationParam relationParam, Set ignoreFields) { + if (dataObject == null || relationParam == null) { + return; + } + boolean dataFilterValue = GlobalThreadLocal.setDataFilter(false); + try { + // 集成本地一对一和字段级别的数据关联。 + boolean buildOneToOne = relationParam.isBuildOneToOne() || relationParam.isBuildOneToOneWithDict(); + if (buildOneToOne) { + this.buildOneToOneForData(dataObject, relationParam, ignoreFields); + } + // 集成一对多关联 + if (relationParam.isBuildOneToMany()) { + this.buildOneToManyForData(dataObject, relationParam, ignoreFields); + } + if (relationParam.isBuildDict()) { + // 构建全局字典关联关系 + this.buildGlobalDictForData(dataObject, ignoreFields); + // 构建常量字典关联关系 + this.buildConstDictForData(dataObject, ignoreFields); + // 构建本地数据字典关联关系。 + this.buildDictForData(dataObject, buildOneToOne, ignoreFields); + } + // 组装本地聚合计算关联数据 + if (relationParam.isBuildRelationAggregation()) { + // 开始处理多对多场景。 + buildManyToManyAggregationForData(dataObject, buildAggregationAdditionalWhereCriteria(), ignoreFields); + // 构建一对多场景 + buildOneToManyAggregationForData(dataObject, buildAggregationAdditionalWhereCriteria(), ignoreFields); + } + if (relationParam.isBuildRelationManyToMany()) { + this.buildRelationManyToMany(dataObject, ignoreFields); + } + } finally { + GlobalThreadLocal.setDataFilter(dataFilterValue); + } + } + + protected void buildLocalOneToOneDictOnly(T dataObject) { + if (dataObject == null || CollUtil.isEmpty(this.localRelationOneToOneStructList)) { + return; + } + for (RelationStruct relationStruct : this.localRelationOneToOneStructList) { + BaseService relationService = relationStruct.service; + Object relationObject = ReflectUtil.getFieldValue(dataObject, relationStruct.relationField); + if (relationObject != null) { + @SuppressWarnings("unchecked") + BaseService proxyTarget = + (BaseService) AopTargetUtil.getTarget(relationService); + // 关联本地字典 + proxyTarget.buildDictForData(relationObject, false, null); + // 关联全局字典 + proxyTarget.buildGlobalDictForData(relationObject, null); + // 关联常量字典 + proxyTarget.buildConstDictForData(relationObject, null); + } + } + } + + /** + * 集成主表和多对多中间表之间的关联关系。 + * + * @param dataObject 关联后的主表数据对象。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildRelationManyToMany(T dataObject, Set ignoreFields) { + if (dataObject == null || CollUtil.isEmpty(this.localRelationManyToManyStructList)) { + return; + } + for (RelationStruct relationStruct : this.localRelationManyToManyStructList) { + if (ignoreFields != null && ignoreFields.contains(relationStruct.relationField.getName())) { + continue; + } + RelationManyToMany r = relationStruct.relationManyToMany; + String masterIdColumn = MyModelUtil.safeMapToColumnName(r.relationMasterIdField(), r.relationModelClass()); + Object masterIdValue = ReflectUtil.getFieldValue(dataObject, idFieldName); + Map filterMap = new HashMap<>(1); + filterMap.put(masterIdColumn, masterIdValue); + List manyToManyList = relationStruct.manyToManyMapper.selectByMap(filterMap); + ReflectUtil.setFieldValue(dataObject, relationStruct.relationField, manyToManyList); + } + } + + /** + * 为实体对象参数列表数据集成本地静态字典关联数据。 + * + * @param resultList 主表数据列表。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildConstDictForDataList(List resultList, Set ignoreFields) { + if (CollUtil.isEmpty(this.relationConstDictStructList) || CollUtil.isEmpty(resultList)) { + return; + } + for (RelationStruct relationStruct : this.relationConstDictStructList) { + if (ignoreFields != null && ignoreFields.contains(relationStruct.relationField.getName())) { + continue; + } + for (M dataObject : resultList) { + Object id = ReflectUtil.getFieldValue(dataObject, relationStruct.masterIdField); + if (id != null) { + String name = MapUtil.get(relationStruct.dictMap, id, String.class); + if (name != null) { + Map dictMap = new HashMap<>(2); + dictMap.put("id", id); + dictMap.put("name", name); + ReflectUtil.setFieldValue(dataObject, relationStruct.relationField, dictMap); + } + } + } + } + } + + /** + * 为实体对象参数列表数据集成全局字典关联数据。 + * + * @param resultList 主表数据列表。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildGlobalDictForDataList(List resultList, Set ignoreFields) { + if (CollUtil.isEmpty(this.relationGlobalDictStructList) || CollUtil.isEmpty(resultList)) { + return; + } + for (RelationStruct relationStruct : this.relationGlobalDictStructList) { + if (ignoreFields != null && ignoreFields.contains(relationStruct.relationField.getName())) { + continue; + } + Set masterIdSet = resultList.stream() + .map(obj -> ReflectUtil.getFieldValue(obj, relationStruct.masterIdField)) + .filter(Objects::nonNull) + .collect(toSet()); + if (CollUtil.isNotEmpty(masterIdSet)) { + Map dictMap = ReflectUtil.invoke( + relationStruct.service, + relationStruct.globalDictMethd, + relationStruct.relationGlobalDict.dictCode(), masterIdSet); + MyModelUtil.makeGlobalDictRelation( + modelClass, resultList, dictMap, relationStruct.relationField.getName()); + } + } + } + + /** + * 为参数实体对象数据集成本地静态字典关联数据。 + * + * @param dataObject 实体对象。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildConstDictForData(T dataObject, Set ignoreFields) { + if (dataObject == null || CollUtil.isEmpty(this.relationConstDictStructList)) { + return; + } + for (RelationStruct relationStruct : this.relationConstDictStructList) { + if (ignoreFields != null && ignoreFields.contains(relationStruct.relationField.getName())) { + continue; + } + Object id = ReflectUtil.getFieldValue(dataObject, relationStruct.masterIdField); + if (id != null) { + String name = MapUtil.get(relationStruct.dictMap, id, String.class); + if (name != null) { + Map dictMap = new HashMap<>(2); + dictMap.put("id", id); + dictMap.put("name", name); + ReflectUtil.setFieldValue(dataObject, relationStruct.relationField, dictMap); + } + } + } + } + + /** + * 为参数实体对象数据集成全局字典关联数据。 + * + * @param dataObject 实体对象。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildGlobalDictForData(T dataObject, Set ignoreFields) { + if (dataObject == null || CollUtil.isEmpty(this.relationGlobalDictStructList)) { + return; + } + for (RelationStruct relationStruct : this.relationGlobalDictStructList) { + if (ignoreFields != null && ignoreFields.contains(relationStruct.relationField.getName())) { + continue; + } + Object id = ReflectUtil.getFieldValue(dataObject, relationStruct.masterIdField); + if (id != null) { + Map dictMap = ReflectUtil.invoke( + relationStruct.service, + relationStruct.globalDictMethd, + relationStruct.relationGlobalDict.dictCode(), CollUtil.newHashSet(id)); + String name = dictMap.get(id.toString()); + if (name != null) { + Map reulstDictMap = new HashMap<>(2); + reulstDictMap.put("id", id); + reulstDictMap.put("name", name); + ReflectUtil.setFieldValue(dataObject, relationStruct.relationField, reulstDictMap); + } + } + } + } + + /** + * 为实体对象参数列表数据集成本地字典关联数据。 + * + * @param resultList 实体对象数据列表。 + * @param hasBuiltOneToOne 性能优化参数。如果该值为true,同时注解参数RelationDict.equalOneToOneRelationField + * 不为空,则直接从已经完成一对一数据关联的从表对象中获取数据,减少一次数据库交互。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildDictForDataList(List resultList, boolean hasBuiltOneToOne, Set ignoreFields) { + if (CollUtil.isEmpty(this.localRelationDictStructList) || CollUtil.isEmpty(resultList)) { + return; + } + for (RelationStruct relationStruct : this.localRelationDictStructList) { + if (ignoreFields != null && ignoreFields.contains(relationStruct.relationField.getName())) { + continue; + } + List relationList = null; + if (hasBuiltOneToOne && relationStruct.equalOneToOneRelationField != null) { + relationList = resultList.stream() + .map(obj -> ReflectUtil.getFieldValue(obj, relationStruct.equalOneToOneRelationField)) + .filter(Objects::nonNull) + .collect(toList()); + } else { + String slaveId = relationStruct.relationDict.slaveIdField(); + Set masterIdSet = resultList.stream() + .map(obj -> ReflectUtil.getFieldValue(obj, relationStruct.masterIdField)) + .filter(Objects::nonNull) + .collect(toSet()); + if (CollUtil.isNotEmpty(masterIdSet)) { + relationList = relationStruct.service.getInList(slaveId, masterIdSet); + } + } + MyModelUtil.makeDictRelation( + modelClass, resultList, relationList, relationStruct.relationField.getName()); + } + } + + /** + * 为实体对象数据集成本地数据字典关联数据。 + * + * @param dataObject 实体对象。 + * @param hasBuiltOneToOne 性能优化参数。如果该值为true,同时注解参数RelationDict.equalOneToOneRelationField + * 不为空,则直接从已经完成一对一数据关联的从表对象中获取数据,减少一次数据库交互。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildDictForData(T dataObject, boolean hasBuiltOneToOne, Set ignoreFields) { + if (dataObject == null || CollUtil.isEmpty(this.localRelationDictStructList)) { + return; + } + for (RelationStruct relationStruct : this.localRelationDictStructList) { + if (ignoreFields != null && ignoreFields.contains(relationStruct.relationField.getName())) { + continue; + } + Object relationObject = null; + if (hasBuiltOneToOne && relationStruct.equalOneToOneRelationField != null) { + relationObject = ReflectUtil.getFieldValue(dataObject, relationStruct.equalOneToOneRelationField); + } else { + Object id = ReflectUtil.getFieldValue(dataObject, relationStruct.masterIdField); + if (id != null) { + relationObject = relationStruct.service.getOne(relationStruct.relationDict.slaveIdField(), id); + } + } + MyModelUtil.makeDictRelation( + modelClass, dataObject, relationObject, relationStruct.relationField.getName()); + } + } + + /** + * 为实体对象参数列表数据集成本地一对一关联数据。 + * + * @param resultList 实体对象数据列表。 + * @param relationParam 关联从参数对象。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildOneToOneForDataList(List resultList, MyRelationParam relationParam, Set ignoreFields) { + if (CollUtil.isEmpty(this.localRelationOneToOneStructList) || CollUtil.isEmpty(resultList)) { + return; + } + boolean withDict = relationParam.isBuildOneToOneWithDict(); + for (RelationStruct relationStruct : this.localRelationOneToOneStructList) { + if (CollUtil.contains(ignoreFields, relationStruct.relationField.getName())) { + continue; + } + Set masterIdSet = resultList.stream() + .map(obj -> ReflectUtil.getFieldValue(obj, relationStruct.masterIdField)) + .filter(Objects::nonNull) + .collect(toSet()); + // 从主表集合中,抽取主表关联字段的集合,再以in list形式去从表中查询。 + if (CollUtil.isNotEmpty(masterIdSet)) { + BaseService relationService = relationStruct.service; + List relationList = + relationService.getInList(relationStruct.relationOneToOne.slaveIdField(), masterIdSet); + Set igoreMaskFieldSet = null; + if (relationParam.getIgnoreMaskFieldMap() != null) { + igoreMaskFieldSet = relationParam.getIgnoreMaskFieldMap() + .get(relationStruct.relationOneToOne.slaveModelClass().getSimpleName()); + } + relationService.maskFieldDataList(relationList, igoreMaskFieldSet); + MyModelUtil.makeOneToOneRelation( + modelClass, resultList, relationList, relationStruct.relationField.getName()); + // 仅仅当需要加载从表字典关联时,才去加载。 + if (withDict && relationStruct.relationOneToOne.loadSlaveDict() && CollUtil.isNotEmpty(relationList)) { + @SuppressWarnings("unchecked") + BaseService proxyTarget = + (BaseService) AopTargetUtil.getTarget(relationService); + // 关联本地字典。 + proxyTarget.buildDictForDataList(relationList, false, ignoreFields); + // 关联全局字典 + proxyTarget.buildGlobalDictForDataList(relationList, ignoreFields); + // 关联常量字典 + proxyTarget.buildConstDictForDataList(relationList, ignoreFields); + } + } + } + } + + /** + * 为实体对象数据集成本地一对一关联数据。 + * + * @param dataObject 实体对象。 + * @param relationParam 从表数据关联参数对象。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildOneToOneForData(M dataObject, MyRelationParam relationParam, Set ignoreFields) { + if (dataObject == null || CollUtil.isEmpty(this.localRelationOneToOneStructList)) { + return; + } + boolean withDict = relationParam.isBuildOneToOneWithDict(); + for (RelationStruct relationStruct : this.localRelationOneToOneStructList) { + if (ignoreFields != null && ignoreFields.contains(relationStruct.relationField.getName())) { + continue; + } + Object id = ReflectUtil.getFieldValue(dataObject, relationStruct.masterIdField); + if (id != null) { + BaseService relationService = relationStruct.service; + Object relationObject = relationService.getOne(relationStruct.relationOneToOne.slaveIdField(), id); + Set ignoreMaskFieldSet = null; + if (relationParam.getIgnoreMaskFieldMap() != null) { + ignoreMaskFieldSet = relationParam.getIgnoreMaskFieldMap() + .get(relationStruct.relationOneToOne.slaveModelClass().getSimpleName()); + } + relationService.maskFieldData(relationObject, ignoreMaskFieldSet); + ReflectUtil.setFieldValue(dataObject, relationStruct.relationField, relationObject); + // 仅仅当需要加载从表字典关联时,才去加载。 + if (withDict && relationStruct.relationOneToOne.loadSlaveDict() && relationObject != null) { + @SuppressWarnings("unchecked") + BaseService proxyTarget = + (BaseService) AopTargetUtil.getTarget(relationService); + // 关联本地字典 + proxyTarget.buildDictForData(relationObject, false, ignoreFields); + // 关联全局字典 + proxyTarget.buildGlobalDictForData(relationObject, ignoreFields); + // 关联常量字典 + proxyTarget.buildConstDictForData(relationObject, ignoreFields); + } + } + } + } + + private void buildOneToManyForDataList(List resultList, MyRelationParam relationParam, Set ignoreFields) { + if (CollUtil.isEmpty(this.localRelationOneToManyStructList) || CollUtil.isEmpty(resultList)) { + return; + } + for (RelationStruct relationStruct : this.localRelationOneToManyStructList) { + if (ignoreFields != null && ignoreFields.contains(relationStruct.relationField.getName())) { + continue; + } + Set masterIdSet = resultList.stream() + .map(obj -> ReflectUtil.getFieldValue(obj, relationStruct.masterIdField)) + .filter(Objects::nonNull) + .collect(toSet()); + // 从主表集合中,抽取主表关联字段的集合,再以in list形式去从表中查询。 + if (CollUtil.isNotEmpty(masterIdSet)) { + BaseService relationService = relationStruct.service; + List relationList = relationService.getInListWithRelation( + relationStruct.relationOneToMany.slaveIdField(), masterIdSet, MyRelationParam.dictOnly()); + MyModelUtil.makeOneToManyRelation( + modelClass, resultList, relationList, relationStruct.relationField.getName()); + Set ignoreMaskFieldSet = null; + if (relationParam.getIgnoreMaskFieldMap() != null) { + ignoreMaskFieldSet = relationParam.getIgnoreMaskFieldMap() + .get(relationStruct.relationOneToMany.slaveModelClass().getSimpleName()); + } + for (M data : resultList) { + @SuppressWarnings("unchecked") + List relationDataList = + (List) ReflectUtil.getFieldValue(data, relationStruct.relationField.getName()); + relationService.maskFieldDataList(relationDataList, ignoreMaskFieldSet); + } + } + } + } + + private void buildOneToManyForData(M dataObject, MyRelationParam relationParam, Set ignoreFields) { + if (dataObject == null || CollUtil.isEmpty(this.localRelationOneToManyStructList)) { + return; + } + for (RelationStruct relationStruct : this.localRelationOneToManyStructList) { + if (ignoreFields != null && ignoreFields.contains(relationStruct.relationField.getName())) { + continue; + } + Object id = ReflectUtil.getFieldValue(dataObject, relationStruct.masterIdField); + if (id != null) { + BaseService relationService = relationStruct.service; + Set masterIdSet = new HashSet<>(1); + masterIdSet.add(id); + List relationObject = relationService.getInListWithRelation( + relationStruct.relationOneToMany.slaveIdField(), masterIdSet, MyRelationParam.dictOnly()); + Set ignoreMaskFieldSet = null; + if (relationParam.getIgnoreMaskFieldMap() != null) { + ignoreMaskFieldSet = relationParam.getIgnoreMaskFieldMap() + .get(relationStruct.relationOneToMany.slaveModelClass().getSimpleName()); + } + relationService.maskFieldDataList(relationObject, ignoreMaskFieldSet); + ReflectUtil.setFieldValue(dataObject, relationStruct.relationField, relationObject); + } + } + } + + private void buildManyToManyForDataList(List resultList, Set ignoreFields) { + if (CollUtil.isEmpty(this.localRelationManyToManyStructList) || CollUtil.isEmpty(resultList)) { + return; + } + for (RelationStruct relationStruct : this.localRelationManyToManyStructList) { + if (ignoreFields != null && ignoreFields.contains(relationStruct.relationField.getName())) { + continue; + } + Set masterIdSet = resultList.stream() + .map(obj -> ReflectUtil.getFieldValue(obj, idFieldName)) + .filter(Objects::nonNull) + .collect(toSet()); + // 从主表集合中,抽取主表关联字段的集合,再以in list形式去从表中查询。 + if (CollUtil.isNotEmpty(masterIdSet)) { + RelationManyToMany r = relationStruct.relationManyToMany; + String masterIdColumn = MyModelUtil.safeMapToColumnName(r.relationMasterIdField(), r.relationModelClass()); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.in(masterIdColumn, masterIdSet); + List relationList = relationStruct.manyToManyMapper.selectList(queryWrapper); + MyModelUtil.makeManyToManyRelation( + modelClass, idFieldName, resultList, relationList, relationStruct.relationField.getName()); + } + } + } + + /** + * 根据实体对象参数列表和过滤条件,集成本地多对多关联聚合计算数据。 + * + * @param resultList 实体对象数据列表。 + * @param criteriaListMap 过滤参数。key为主表字段名称,value是过滤条件列表。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildManyToManyAggregationForDataList( + List resultList, Map> criteriaListMap, Set ignoreFields) { + if (CollUtil.isEmpty(this.localRelationManyToManyAggrStructList) || CollUtil.isEmpty(resultList)) { + return; + } + if (criteriaListMap == null) { + criteriaListMap = new HashMap<>(this.localRelationManyToManyAggrStructList.size()); + } + for (RelationStruct relationStruct : this.localRelationManyToManyAggrStructList) { + if (!CollUtil.contains(ignoreFields, relationStruct.relationField.getName())) { + this.doBuildManyToManyAggregationForDataList(resultList, criteriaListMap, relationStruct); + } + } + } + + private void doBuildManyToManyAggregationForDataList( + List resultList, Map> criteriaListMap, RelationStruct relationStruct) { + Set masterIdSet = resultList.stream() + .map(obj -> ReflectUtil.getFieldValue(obj, relationStruct.masterIdField)) + .filter(Objects::nonNull) + .collect(toSet()); + if (CollUtil.isEmpty(masterIdSet)) { + return; + } + RelationManyToManyAggregation relation = relationStruct.relationManyToManyAggregation; + // 提取关联中用到的各种字段和表数据。 + BasicAggregationRelationInfo basicRelationInfo = + this.parseBasicAggregationRelationInfo(relationStruct, criteriaListMap); + // 构建多表关联的where语句 + StringBuilder whereClause = new StringBuilder(256); + // 如果需要从表聚合计算或参与过滤,则需要把中间表和从表之间的关联条件加上。 + if (!basicRelationInfo.onlySelectRelationTable) { + whereClause.append(basicRelationInfo.relationTable) + .append(".") + .append(basicRelationInfo.relationSlaveColumn) + .append(" = ") + .append(basicRelationInfo.slaveTable) + .append(".") + .append(basicRelationInfo.slaveColumn); + } else { + whereClause.append("1 = 1"); + } + List criteriaList = criteriaListMap.get(relationStruct.relationField.getName()); + if (criteriaList == null) { + criteriaList = new LinkedList<>(); + } + MyWhereCriteria inlistFilter = new MyWhereCriteria(); + inlistFilter.setCriteria(relation.relationModelClass(), + relation.relationMasterIdField(), MyWhereCriteria.OPERATOR_IN, masterIdSet); + criteriaList.add(inlistFilter); + if (StrUtil.isNotBlank(relationStruct.service.deletedFlagFieldName)) { + MyWhereCriteria deleteFilter = new MyWhereCriteria(); + deleteFilter.setCriteria( + relation.slaveModelClass(), + relationStruct.service.deletedFlagFieldName, + MyWhereCriteria.OPERATOR_EQUAL, + GlobalDeletedFlag.NORMAL); + criteriaList.add(deleteFilter); + } + String criteriaString = MyWhereCriteria.makeCriteriaString(criteriaList); + whereClause.append(AND_OP).append(criteriaString); + StringBuilder tableNames = new StringBuilder(64); + tableNames.append(basicRelationInfo.relationTable); + if (!basicRelationInfo.onlySelectRelationTable) { + tableNames.append(", ").append(basicRelationInfo.slaveTable); + } + List> aggregationMapList = + mapper().getGroupedListByCondition(tableNames.toString(), + basicRelationInfo.selectList, whereClause.toString(), basicRelationInfo.groupBy); + doMakeLocalAggregationData(aggregationMapList, resultList, relationStruct); + } + + /** + * 根据实体对象和过滤条件,集成本地多对多关联聚合计算数据。 + * + * @param dataObject 实体对象。 + * @param criteriaListMap 过滤参数。key为主表字段名称,value是过滤条件列表。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildManyToManyAggregationForData( + T dataObject, Map> criteriaListMap, Set ignoreFields) { + if (dataObject == null || CollUtil.isEmpty(this.localRelationManyToManyAggrStructList)) { + return; + } + if (criteriaListMap == null) { + criteriaListMap = new HashMap<>(localRelationManyToManyAggrStructList.size()); + } + for (RelationStruct relationStruct : this.localRelationManyToManyAggrStructList) { + Object masterIdValue = ReflectUtil.getFieldValue(dataObject, relationStruct.masterIdField); + if (masterIdValue == null || CollUtil.contains(ignoreFields, relationStruct.relationField.getName())) { + continue; + } + BasicAggregationRelationInfo basicRelationInfo = + this.parseBasicAggregationRelationInfo(relationStruct, criteriaListMap); + // 组装过滤条件 + String whereClause = this.makeManyToManyWhereClause( + relationStruct, masterIdValue, basicRelationInfo, criteriaListMap); + StringBuilder tableNames = new StringBuilder(64); + tableNames.append(basicRelationInfo.relationTable); + if (!basicRelationInfo.onlySelectRelationTable) { + tableNames.append(", ").append(basicRelationInfo.slaveTable); + } + List> aggregationMapList = + mapper().getGroupedListByCondition(tableNames.toString(), + basicRelationInfo.selectList, whereClause, basicRelationInfo.groupBy); + // 将查询后的结果回填到主表数据中。 + if (CollUtil.isNotEmpty(aggregationMapList)) { + Object value = aggregationMapList.get(0).get(AGGREGATED_VALUE); + if (value != null) { + ReflectUtil.setFieldValue(dataObject, relationStruct.relationField, value); + } + } + } + } + + /** + * 根据实体对象参数列表和过滤条件,集成本地一对多关联聚合计算数据。 + * + * @param resultList 实体对象数据列表。 + * @param criteriaListMap 过滤参数。key为主表字段名称,value是过滤条件列表。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildOneToManyAggregationForDataList( + List resultList, Map> criteriaListMap, Set ignoreFields) { + // 处理多一多场景下,根据主表的结果,进行从表聚合数据的计算。 + if (CollUtil.isEmpty(this.localRelationOneToManyAggrStructList) || CollUtil.isEmpty(resultList)) { + return; + } + if (criteriaListMap == null) { + criteriaListMap = new HashMap<>(localRelationOneToManyAggrStructList.size()); + } + for (RelationStruct relationStruct : this.localRelationOneToManyAggrStructList) { + if (CollUtil.contains(ignoreFields, relationStruct.relationField.getName())) { + continue; + } + Set masterIdSet = resultList.stream() + .map(obj -> ReflectUtil.getFieldValue(obj, relationStruct.masterIdField)) + .filter(Objects::nonNull) + .collect(toSet()); + if (CollUtil.isNotEmpty(masterIdSet)) { + RelationOneToManyAggregation relation = relationStruct.relationOneToManyAggregation; + // 开始获取后面所需的各种关联数据。此部分今后可以移植到缓存中,无需每次计算。 + String slaveTable = MyModelUtil.mapToTableName(relation.slaveModelClass()); + String slaveColumnName = MyModelUtil.mapToColumnName(relation.slaveIdField(), relation.slaveModelClass()); + Tuple2 selectAndGroupByTuple = makeSelectListAndGroupByClause( + slaveTable, slaveColumnName, relation.slaveModelClass(), + slaveTable, relation.aggregationField(), relation.aggregationType()); + String selectList = selectAndGroupByTuple.getFirst(); + String groupBy = selectAndGroupByTuple.getSecond(); + List criteriaList = criteriaListMap.get(relationStruct.relationField.getName()); + if (criteriaList == null) { + criteriaList = new LinkedList<>(); + } + MyWhereCriteria inlistFilter = new MyWhereCriteria(); + inlistFilter.setCriteria(relation.slaveModelClass(), + relation.slaveIdField(), MyWhereCriteria.OPERATOR_IN, masterIdSet); + criteriaList.add(inlistFilter); + if (StrUtil.isNotBlank(relationStruct.service.deletedFlagFieldName)) { + MyWhereCriteria deleteFilter = new MyWhereCriteria(); + deleteFilter.setCriteria( + relation.slaveModelClass(), + relationStruct.service.deletedFlagFieldName, + MyWhereCriteria.OPERATOR_EQUAL, + GlobalDeletedFlag.NORMAL); + criteriaList.add(deleteFilter); + } + String criteriaString = MyWhereCriteria.makeCriteriaString(criteriaList); + List> aggregationMapList = + mapper().getGroupedListByCondition(slaveTable, selectList, criteriaString, groupBy); + doMakeLocalAggregationData(aggregationMapList, resultList, relationStruct); + } + } + } + + /** + * 根据实体对象和过滤条件,集成本地一对多关联聚合计算数据。 + * + * @param dataObject 实体对象。 + * @param criteriaListMap 过滤参数。key为主表字段名称,value是过滤条件列表。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + private void buildOneToManyAggregationForData( + T dataObject, Map> criteriaListMap, Set ignoreFields) { + if (dataObject == null || CollUtil.isEmpty(this.localRelationOneToManyAggrStructList)) { + return; + } + if (criteriaListMap == null) { + criteriaListMap = new HashMap<>(localRelationOneToManyAggrStructList.size()); + } + for (RelationStruct relationStruct : this.localRelationOneToManyAggrStructList) { + if (CollUtil.contains(ignoreFields, relationStruct.relationField.getName())) { + continue; + } + Object masterIdValue = ReflectUtil.getFieldValue(dataObject, relationStruct.masterIdField); + if (masterIdValue != null) { + RelationOneToManyAggregation relation = relationStruct.relationOneToManyAggregation; + String slaveTable = MyModelUtil.mapToTableName(relation.slaveModelClass()); + String slaveColumnName = + MyModelUtil.mapToColumnName(relation.slaveIdField(), relation.slaveModelClass()); + Tuple2 selectAndGroupByTuple = makeSelectListAndGroupByClause( + slaveTable, slaveColumnName, relation.slaveModelClass(), + slaveTable, relation.aggregationField(), relation.aggregationType()); + String selectList = selectAndGroupByTuple.getFirst(); + String groupBy = selectAndGroupByTuple.getSecond(); + String whereClause = this.makeOneToManyWhereClause( + relationStruct, masterIdValue, slaveColumnName, criteriaListMap); + // 获取分组聚合计算结果 + List> aggregationMapList = + mapper().getGroupedListByCondition(slaveTable, selectList, whereClause, groupBy); + // 将计算结果回填到主表关联字段 + if (CollUtil.isNotEmpty(aggregationMapList)) { + Object value = aggregationMapList.get(0).get(AGGREGATED_VALUE); + if (value != null) { + ReflectUtil.setFieldValue(dataObject, relationStruct.relationField, value); + } + } + } + } + } + + /** + * 仅仅在spring boot 启动后的监听器事件中调用,缓存所有service的关联关系,加速后续的数据绑定效率。 + */ + @Override + public void loadRelationStruct() { + Field[] fields = ReflectUtil.getFields(modelClass); + for (Field f : fields) { + initializeRelationDictStruct(f); + initializeRelationStruct(f); + initializeRelationAggregationStruct(f); + } + } + + /** + * 缺省实现返回null,在进行一对多和多对多聚合计算时,没有额外的自定义过滤条件。如有需要,需子类自行实现。 + * + * @return 自定义过滤条件列表。 + */ + protected Map> buildAggregationAdditionalWhereCriteria() { + return null; + } + + /** + * 判断当前对象的关联字段数据是否需要被验证,如果原有对象为null,表示新对象第一次插入,则必须验证。 + * + * @param object 新对象。 + * @param originalObject 原有对象。 + * @param fieldGetter 获取需要验证字段的函数对象。 + * @param 需要验证字段的类型。 + * @return 需要关联验证返回true,否则false。 + */ + protected boolean needToVerify(M object, M originalObject, Function fieldGetter) { + if (object == null) { + return false; + } + T data = fieldGetter.apply(object); + if (data == null) { + return false; + } + if (data instanceof String stringData) { + if (stringData.isEmpty()) { + return false; + } + } + if (originalObject == null) { + return true; + } + T originalData = fieldGetter.apply(originalObject); + return !data.equals(originalData); + } + + /** + * 因为Mybatis Plus中QueryWrapper的条件方法都要求传入数据表字段名,因此提供该函数将 + * Java实体对象的字段名转换为数据表字段名,如果不存在会抛出异常。 + * 另外在MyModelUtil.mapToColumnName有一级缓存,对于查询过的对象字段都会放到缓存中, + * 下次映射转换的时候,会直接从缓存获取。 + * + * @param fieldName Java实体对象的字段名。 + * @return 对应的数据表字段名。 + */ + protected String safeMapToColumnName(String fieldName) { + String columnName = MyModelUtil.mapToColumnName(fieldName, modelClass); + if (columnName == null) { + throw new InvalidDataFieldException(modelClass.getSimpleName(), fieldName); + } + return columnName; + } + + /** + * 因为Mybatis Plus在update的时候,不能将实体对象中值为null的字段,更新为null, + * 而且忽略更新,在全部更新场景下,这个是非常重要的,所以我们写了这个函数绕开这一问题。 + * 该函数会遍历实体对象中,所有不包含@Transient注解,没有transient修饰符的字段,如果 + * 当前对象的该字段值为null,则会调用UpdateWrapper的set方法,将该字段赋值为null。 + * 相比于其他重载方法,该方法会将参数中的主键id,设置到UpdateWrapper的过滤条件中。 + * + * @param o 实体对象。 + * @param id 实体对象的主键值。 + * @return 创建后的UpdateWrapper。 + */ + protected UpdateWrapper createUpdateQueryForNullValue(M o, K id) { + UpdateWrapper uw = createUpdateQueryForNullValue(o, modelClass); + try { + M filter = modelClass.newInstance(); + this.setIdFieldMethod.invoke(filter, id); + uw.setEntity(filter); + } catch (Exception e) { + log.error("Failed to call reflection code of BaseService.createUpdateQueryForNullValue.", e); + throw new MyRuntimeException(e); + } + return uw; + } + + /** + * 因为Mybatis Plus在update的时候,不能将实体对象中值为null的字段,更新为null, + * 而且忽略更新,在全部更新场景下,这个是非常重要的,所以我们写了这个函数绕开这一问题。 + * 该函数会遍历实体对象中,所有不包含@Transient注解,没有transient修饰符的字段,如果 + * 当前对象的该字段值为null,则会调用UpdateWrapper的set方法,将该字段赋值为null。 + * + * @param o 实体对象。 + * @return 创建后的UpdateWrapper。 + */ + protected UpdateWrapper createUpdateQueryForNullValue(M o) { + return createUpdateQueryForNullValue(o, modelClass); + } + + /** + * 因为Mybatis Plus在update的时候,不能将实体对象中值为null的字段,更新为null, + * 而且忽略更新,在全部更新场景下,这个是非常重要的,所以我们写了这个函数绕开这一问题。 + * 该函数会遍历实体对象中,所有不包含@Transient注解,没有transient修饰符的字段,如果 + * 当前对象的该字段值为null,则会调用UpdateWrapper的set方法,将该字段赋值为null。 + * + * @param o 实体对象。 + * @param clazz 实体对象的class。 + * @return 创建后的UpdateWrapper。 + */ + public static UpdateWrapper createUpdateQueryForNullValue(T o, Class clazz) { + UpdateWrapper uw = new UpdateWrapper<>(); + Field[] fields = ReflectUtil.getFields(clazz); + List nullColumnList = new LinkedList<>(); + for (Field field : fields) { + TableField tableField = field.getAnnotation(TableField.class); + if (tableField == null || tableField.exist()) { + int modifiers = field.getModifiers(); + // transient类型的字段不能作为查询条件,静态字段和逻辑删除都不考虑。 + int transientMask = 128; + if ((modifiers & transientMask) == 1 + || Modifier.isStatic(modifiers) + || field.getAnnotation(TableLogic.class) != null) { + continue; + } + // 仅当实体对象参数中,当前字段值为null的时候,才会赋值给UpdateWrapper。 + // 以便在后续的更新中,可以将这些null字段的值设置到数据库表对应的字段中。 + if (ReflectUtil.getFieldValue(o, field) == null) { + nullColumnList.add(MyModelUtil.safeMapToColumnName(field.getName(), clazz)); + } + } + } + if (CollUtil.isNotEmpty(nullColumnList)) { + for (String nullColumn : nullColumnList) { + uw.set(nullColumn, null); + } + } + return uw; + } + + @SuppressWarnings("unchecked") + private void initializeRelationStruct(Field f) { + RelationOneToOne relationOneToOne = f.getAnnotation(RelationOneToOne.class); + if (relationOneToOne != null) { + RelationStruct relationStruct = new RelationStruct(); + relationStruct.relationField = f; + relationStruct.masterIdField = ReflectUtil.getField(modelClass, relationOneToOne.masterIdField()); + relationStruct.relationOneToOne = relationOneToOne; + if (!relationOneToOne.slaveServiceClass().equals(DummyClass.class)) { + relationStruct.service = (BaseService) + ApplicationContextHolder.getBean(relationOneToOne.slaveServiceClass()); + } else { + relationStruct.service = ApplicationContextHolder.getBean( + this.getNormalizedSlaveServiceName(relationOneToOne.slaveServiceName(), relationOneToOne.slaveModelClass())); + } + localRelationOneToOneStructList.add(relationStruct); + return; + } + RelationOneToMany relationOneToMany = f.getAnnotation(RelationOneToMany.class); + if (relationOneToMany != null) { + RelationStruct relationStruct = new RelationStruct(); + relationStruct.relationField = f; + relationStruct.masterIdField = ReflectUtil.getField(modelClass, relationOneToMany.masterIdField()); + relationStruct.relationOneToMany = relationOneToMany; + if (!relationOneToMany.slaveServiceClass().equals(DummyClass.class)) { + relationStruct.service = (BaseService) + ApplicationContextHolder.getBean(relationOneToMany.slaveServiceClass()); + } else { + relationStruct.service = ApplicationContextHolder.getBean( + this.getNormalizedSlaveServiceName(relationOneToMany.slaveServiceName(), relationOneToMany.slaveModelClass())); + } + localRelationOneToManyStructList.add(relationStruct); + return; + } + RelationManyToMany relationManyToMany = f.getAnnotation(RelationManyToMany.class); + if (relationManyToMany != null) { + RelationStruct relationStruct = new RelationStruct(); + relationStruct.relationField = f; + relationStruct.masterIdField = ReflectUtil.getField(modelClass, relationManyToMany.relationMasterIdField()); + relationStruct.relationManyToMany = relationManyToMany; + String relationMapperName = relationManyToMany.relationMapperName(); + if (StrUtil.isBlank(relationMapperName)) { + relationMapperName = relationManyToMany.relationModelClass().getSimpleName() + "Mapper"; + } + relationStruct.manyToManyMapper = ApplicationContextHolder.getBean(StrUtil.lowerFirst(relationMapperName)); + localRelationManyToManyStructList.add(relationStruct); + } + } + + @SuppressWarnings("unchecked") + private void initializeRelationAggregationStruct(Field f) { + RelationOneToManyAggregation relationOneToManyAggregation = f.getAnnotation(RelationOneToManyAggregation.class); + if (relationOneToManyAggregation != null) { + RelationStruct relationStruct = new RelationStruct(); + relationStruct.relationField = f; + relationStruct.masterIdField = ReflectUtil.getField(modelClass, relationOneToManyAggregation.masterIdField()); + relationStruct.relationOneToManyAggregation = relationOneToManyAggregation; + if (!relationOneToManyAggregation.slaveServiceClass().equals(DummyClass.class)) { + relationStruct.service = (BaseService) + ApplicationContextHolder.getBean(relationOneToManyAggregation.slaveServiceClass()); + } else { + relationStruct.service = ApplicationContextHolder.getBean(this.getNormalizedSlaveServiceName( + relationOneToManyAggregation.slaveServiceName(), relationOneToManyAggregation.slaveModelClass())); + } + localRelationOneToManyAggrStructList.add(relationStruct); + return; + } + RelationManyToManyAggregation relationManyToManyAggregation = f.getAnnotation(RelationManyToManyAggregation.class); + if (relationManyToManyAggregation != null) { + RelationStruct relationStruct = new RelationStruct(); + relationStruct.relationField = f; + relationStruct.masterIdField = ReflectUtil.getField(modelClass, relationManyToManyAggregation.masterIdField()); + relationStruct.relationManyToManyAggregation = relationManyToManyAggregation; + if (!relationManyToManyAggregation.slaveServiceClass().equals(DummyClass.class)) { + relationStruct.service = (BaseService) + ApplicationContextHolder.getBean(relationManyToManyAggregation.slaveServiceClass()); + } else { + relationStruct.service = ApplicationContextHolder.getBean(this.getNormalizedSlaveServiceName( + relationManyToManyAggregation.slaveServiceName(), relationManyToManyAggregation.slaveModelClass())); + } + localRelationManyToManyAggrStructList.add(relationStruct); + } + } + + @SuppressWarnings("unchecked") + private void initializeRelationDictStruct(Field f) { + RelationConstDict relationConstDict = f.getAnnotation(RelationConstDict.class); + if (relationConstDict != null) { + RelationStruct relationStruct = new RelationStruct(); + relationStruct.relationConstDict = relationConstDict; + relationStruct.relationField = f; + relationStruct.masterIdField = ReflectUtil.getField(modelClass, relationConstDict.masterIdField()); + Field dictMapField = ReflectUtil.getField(relationConstDict.constantDictClass(), "DICT_MAP"); + relationStruct.dictMap = (Map) ReflectUtil.getStaticFieldValue(dictMapField); + relationConstDictStructList.add(relationStruct); + return; + } + RelationGlobalDict relationGlobalDict = f.getAnnotation(RelationGlobalDict.class); + if (relationGlobalDict != null) { + RelationStruct relationStruct = new RelationStruct(); + relationStruct.relationGlobalDict = relationGlobalDict; + relationStruct.relationField = f; + relationStruct.masterIdField = ReflectUtil.getField(modelClass, relationGlobalDict.masterIdField()); + relationStruct.service = ApplicationContextHolder.getBean("globalDictService"); + relationStruct.globalDictMethd = ReflectUtil.getMethodByName( + relationStruct.service.getClass(), "getGlobalDictItemDictMapFromCache"); + relationGlobalDictStructList.add(relationStruct); + return; + } + RelationDict relationDict = f.getAnnotation(RelationDict.class); + if (relationDict != null) { + RelationStruct relationStruct = new RelationStruct(); + relationStruct.relationField = f; + relationStruct.masterIdField = ReflectUtil.getField(modelClass, relationDict.masterIdField()); + relationStruct.relationDict = relationDict; + if (StrUtil.isNotBlank(relationDict.equalOneToOneRelationField())) { + relationStruct.equalOneToOneRelationField = + ReflectUtil.getField(modelClass, relationDict.equalOneToOneRelationField()); + } + if (!relationDict.slaveServiceClass().equals(DummyClass.class)) { + relationStruct.service = (BaseService) + ApplicationContextHolder.getBean(relationDict.slaveServiceClass()); + } else { + relationStruct.service = ApplicationContextHolder.getBean( + this.getNormalizedSlaveServiceName(relationDict.slaveServiceName(), relationDict.slaveModelClass())); + } + localRelationDictStructList.add(relationStruct); + } + } + + private BasicAggregationRelationInfo parseBasicAggregationRelationInfo( + RelationStruct relationStruct, Map> criteriaListMap) { + RelationManyToManyAggregation relation = relationStruct.relationManyToManyAggregation; + BasicAggregationRelationInfo relationInfo = new BasicAggregationRelationInfo(); + // 提取关联中用到的各种字段和表数据。 + relationInfo.slaveTable = MyModelUtil.mapToTableName(relation.slaveModelClass()); + relationInfo.relationTable = MyModelUtil.mapToTableName(relation.relationModelClass()); + relationInfo.relationMasterColumn = + MyModelUtil.mapToColumnName(relation.relationMasterIdField(), relation.relationModelClass()); + relationInfo.relationSlaveColumn = + MyModelUtil.mapToColumnName(relation.relationSlaveIdField(), relation.relationModelClass()); + relationInfo.slaveColumn = MyModelUtil.mapToColumnName(relation.slaveIdField(), relation.slaveModelClass()); + // 判断是否只需要关联中间表即可,从而提升查询统计的效率。 + // 1. 统计字段为中间表字段。2. 自定义过滤条件中没有基于从表字段的过滤条件。 + relationInfo.onlySelectRelationTable = + relation.aggregationModelClass().equals(relation.relationModelClass()); + if (relationInfo.onlySelectRelationTable && MapUtil.isNotEmpty(criteriaListMap)) { + List criteriaList = + criteriaListMap.get(relationStruct.relationField.getName()); + if (CollUtil.isNotEmpty(criteriaList)) { + for (MyWhereCriteria whereCriteria : criteriaList) { + if (whereCriteria.getModelClazz().equals(relation.slaveModelClass())) { + relationInfo.onlySelectRelationTable = false; + break; + } + } + } + } + String aggregationTable = relation.aggregationModelClass().equals(relation.relationModelClass()) + ? relationInfo.relationTable : relationInfo.slaveTable; + Tuple2 selectAndGroupByTuple = makeSelectListAndGroupByClause( + relationInfo.relationTable, relationInfo.relationMasterColumn, relation.aggregationModelClass(), + aggregationTable, relation.aggregationField(), relation.aggregationType()); + relationInfo.selectList = selectAndGroupByTuple.getFirst(); + relationInfo.groupBy = selectAndGroupByTuple.getSecond(); + return relationInfo; + } + + private String makeManyToManyWhereClause( + RelationStruct relationStruct, + Object masterIdValue, + BasicAggregationRelationInfo basicRelationInfo, + Map> criteriaListMap) { + StringBuilder whereClause = new StringBuilder(256); + whereClause.append(basicRelationInfo.relationTable) + .append(".").append(basicRelationInfo.relationMasterColumn); + if (masterIdValue instanceof Number) { + whereClause.append(" = ").append(masterIdValue); + } else { + whereClause.append(" = '").append(masterIdValue).append("'"); + } + // 如果需要从表聚合计算或参与过滤,则需要把中间表和从表之间的关联条件加上。 + if (!basicRelationInfo.onlySelectRelationTable) { + whereClause.append(AND_OP) + .append(basicRelationInfo.relationTable) + .append(".") + .append(basicRelationInfo.relationSlaveColumn) + .append(" = ") + .append(basicRelationInfo.slaveTable) + .append(".") + .append(basicRelationInfo.slaveColumn); + } + List criteriaList = criteriaListMap.get(relationStruct.relationField.getName()); + if (criteriaList == null) { + criteriaList = new LinkedList<>(); + } + if (StrUtil.isNotBlank(relationStruct.service.deletedFlagFieldName)) { + MyWhereCriteria deleteFilter = new MyWhereCriteria(); + deleteFilter.setCriteria( + relationStruct.relationManyToManyAggregation.slaveModelClass(), + relationStruct.service.deletedFlagFieldName, + MyWhereCriteria.OPERATOR_EQUAL, + GlobalDeletedFlag.NORMAL); + criteriaList.add(deleteFilter); + } + if (CollUtil.isNotEmpty(criteriaList)) { + String criteriaString = MyWhereCriteria.makeCriteriaString(criteriaList); + whereClause.append(AND_OP).append(criteriaString); + } + return whereClause.toString(); + } + + private String makeOneToManyWhereClause( + RelationStruct relationStruct, + Object masterIdValue, + String slaveColumnName, + Map> criteriaListMap) { + StringBuilder whereClause = new StringBuilder(64); + if (masterIdValue instanceof Number) { + whereClause.append(slaveColumnName).append(" = ").append(masterIdValue); + } else { + whereClause.append(slaveColumnName).append(" = '").append(masterIdValue).append("'"); + } + List criteriaList = criteriaListMap.get(relationStruct.relationField.getName()); + if (criteriaList == null) { + criteriaList = new LinkedList<>(); + } + if (StrUtil.isNotBlank(relationStruct.service.deletedFlagFieldName)) { + MyWhereCriteria deleteFilter = new MyWhereCriteria(); + deleteFilter.setCriteria( + relationStruct.relationOneToManyAggregation.slaveModelClass(), + relationStruct.service.deletedFlagFieldName, + MyWhereCriteria.OPERATOR_EQUAL, + GlobalDeletedFlag.NORMAL); + criteriaList.add(deleteFilter); + } + if (CollUtil.isNotEmpty(criteriaList)) { + String criteriaString = MyWhereCriteria.makeCriteriaString(criteriaList); + whereClause.append(AND_OP).append(criteriaString); + } + return whereClause.toString(); + } + + private static class BasicAggregationRelationInfo { + private String slaveTable; + private String slaveColumn; + private String relationTable; + private String relationMasterColumn; + private String relationSlaveColumn; + private String selectList; + private String groupBy; + private boolean onlySelectRelationTable; + } + + private void doMakeLocalAggregationData( + List> aggregationMapList, List resultList, RelationStruct relationStruct) { + if (CollUtil.isEmpty(resultList)) { + return; + } + // 根据获取的分组聚合结果集,绑定到主表总的关联字段。 + if (CollUtil.isNotEmpty(aggregationMapList)) { + Map relatedMap = new HashMap<>(aggregationMapList.size()); + String groupedKey = GROUPED_KEY; + String aggregatedValue = AGGREGATED_VALUE; + if (!aggregationMapList.get(0).containsKey(groupedKey)) { + groupedKey = groupedKey.toLowerCase(); + aggregatedValue = aggregatedValue.toLowerCase(); + } + for (Map map : aggregationMapList) { + relatedMap.put(map.get(groupedKey).toString(), map.get(aggregatedValue)); + } + for (M dataObject : resultList) { + Object masterIdValue = ReflectUtil.getFieldValue(dataObject, relationStruct.masterIdField); + if (masterIdValue != null) { + Object value = relatedMap.get(masterIdValue.toString()); + if (value != null) { + ReflectUtil.setFieldValue(dataObject, relationStruct.relationField, value); + } + } + } + } + } + + private Tuple2 makeSelectListAndGroupByClause( + String groupTableName, + String groupColumnName, + Class aggregationModel, + String aggregationTableName, + String aggregationField, + Integer aggregationType) { + if (!AggregationType.isValid(aggregationType)) { + throw new IllegalArgumentException("Invalid AggregationType Value [" + + aggregationType + "] in Model [" + aggregationModel.getName() + "]."); + } + String aggregationFunc = AggregationType.getAggregationFunction(aggregationType); + String aggregationColumn = MyModelUtil.mapToColumnName(aggregationField, aggregationModel); + if (StrUtil.isBlank(aggregationColumn)) { + throw new IllegalArgumentException("Invalid AggregationField [" + + aggregationField + "] in Model [" + aggregationModel.getName() + "]."); + } + // 构建Select List + // 如:r_table.master_id groupedKey, SUM(r_table.aggr_column) aggregated_value + StringBuilder groupedSelectList = new StringBuilder(128); + groupedSelectList.append(groupTableName) + .append(".") + .append(groupColumnName) + .append(" ") + .append(GROUPED_KEY) + .append(", ") + .append(aggregationFunc) + .append("(") + .append(aggregationTableName) + .append(".") + .append(aggregationColumn) + .append(") ") + .append(AGGREGATED_VALUE) + .append(" "); + StringBuilder groupBy = new StringBuilder(64); + groupBy.append(groupTableName).append(".").append(groupColumnName); + return new Tuple2<>(groupedSelectList.toString(), groupBy.toString()); + } + + private Object doMaskFieldData(M data, Field maskField, MaskField anno) { + Object value = ReflectUtil.getFieldValue(data, maskField); + if (value == null) { + return value; + } + if (anno.maskType().equals(MaskFieldTypeEnum.NAME)) { + value = MaskFieldUtil.chineseName(value.toString(), anno.maskChar()); + } else if (anno.maskType().equals(MaskFieldTypeEnum.MOBILE_PHONE)) { + value = MaskFieldUtil.mobilePhone(value.toString(), anno.maskChar()); + } else if (anno.maskType().equals(MaskFieldTypeEnum.FIXED_PHONE)) { + value = MaskFieldUtil.fixedPhone(value.toString(), anno.maskChar()); + } else if (anno.maskType().equals(MaskFieldTypeEnum.EMAIL)) { + value = MaskFieldUtil.email(value.toString(), anno.maskChar()); + } else if (anno.maskType().equals(MaskFieldTypeEnum.ID_CARD)) { + value = MaskFieldUtil.idCardNum(value.toString(), anno.noMaskPrefix(), anno.noMaskSuffix(), anno.maskChar()); + } else if (anno.maskType().equals(MaskFieldTypeEnum.BANK_CARD)) { + value = MaskFieldUtil.bankCard(value.toString(), anno.maskChar()); + } else if (anno.maskType().equals(MaskFieldTypeEnum.CAR_LICENSE)) { + value = MaskFieldUtil.carLicense(value.toString(), anno.maskChar()); + } else if (anno.maskType().equals(MaskFieldTypeEnum.CUSTOM)) { + MaskFieldHandler handler = + maskFieldHandlerMap.computeIfAbsent(anno.handler(), ApplicationContextHolder::getBean); + value = handler.handleMask(modelClass.getSimpleName(), maskField.getName(), value.toString(), anno.maskChar()); + } + return value; + } + + private void compareAndSetMaskFieldData(M data, K id) { + if (CollUtil.isNotEmpty(maskFieldList)) { + M originalData = this.getById(id); + this.compareAndSetMaskFieldData(data, originalData); + } + } + + private String getNormalizedSlaveServiceName(String slaveServiceName, Class slaveModelClass) { + if (StrUtil.isBlank(slaveServiceName)) { + slaveServiceName = slaveModelClass.getSimpleName() + "Service"; + } + return StrUtil.lowerFirst(slaveServiceName); + } + + @Data + public static class RelationStruct { + private Field relationField; + private Field masterIdField; + private Field equalOneToOneRelationField; + private Method globalDictMethd; + private BaseService service; + private BaseDaoMapper manyToManyMapper; + private Map dictMap; + private RelationConstDict relationConstDict; + private RelationGlobalDict relationGlobalDict; + private RelationDict relationDict; + private RelationOneToOne relationOneToOne; + private RelationOneToMany relationOneToMany; + private RelationManyToMany relationManyToMany; + private RelationOneToManyAggregation relationOneToManyAggregation; + private RelationManyToManyAggregation relationManyToManyAggregation; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/service/IBaseDictService.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/service/IBaseDictService.java new file mode 100644 index 00000000..556b70b5 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/service/IBaseDictService.java @@ -0,0 +1,69 @@ +package com.orangeforms.common.core.base.service; + +import java.io.Serializable; +import java.util.List; + +/** + * 带有缓存功能的字典Service接口。 + * + * @param Model实体对象的类型。 + * @param Model对象主键的类型。 + * @author Jerry + * @date 2024-07-02 + */ +public interface IBaseDictService extends IBaseService { + + /** + * 重新加载数据库中所有当前表数据到系统内存。 + * + * @param force true则强制刷新,如果false,当缓存中存在数据时不刷新。 + */ + void reloadCachedData(boolean force); + + /** + * 保存新增对象。 + * + * @param data 新增对象。 + * @return 返回新增对象。 + */ + M saveNew(M data); + + /** + * 更新数据对象。 + * + * @param data 更新的对象。 + * @param originalData 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(M data, M originalData); + + /** + * 删除指定数据。 + * + * @param id 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(K id); + + /** + * 直接从缓存池中获取所有数据。 + * + * @return 返回所有数据。 + */ + List getAllListFromCache(); + + /** + * 根据父主键Id,获取子对象列表。 + * + * @param parentId 上级行政区划Id。 + * @return 下级行政区划列表。 + */ + List getListByParentId(K parentId); + + /** + * 获取缓存中的数据数量。 + * + * @return 缓存中的数据总量。 + */ + int getCachedCount(); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/service/IBaseService.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/service/IBaseService.java new file mode 100644 index 00000000..953980bc --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/service/IBaseService.java @@ -0,0 +1,559 @@ +package com.orangeforms.common.core.base.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TableModelInfo; + +import java.io.Serializable; +import java.util.*; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import java.util.function.Function; + +/** + * 所有Service的接口。 + * + * @param Model对象的类型。 + * @param Model对象主键的类型。 + * @author Jerry + * @date 2024-07-02 + */ +public interface IBaseService extends IService { + + /** + * 如果主键存在则更新,否则新增保存实体对象。 + * + * @param data 实体对象数据。 + * @param saveNew 新增实体对象方法。 + * @param update 更新实体对象方法。 + */ + void saveNewOrUpdate(M data, Consumer saveNew, BiConsumer update); + + /** + * 如果主键存在的则更新,否则批量新增保存实体对象。 + * + * @param dataList 实体对象数据列表。 + * @param saveNewBatch 批量新增实体对象方法。 + * @param update 更新实体对象方法。 + */ + void saveNewOrUpdateBatch(List dataList, Consumer> saveNewBatch, BiConsumer update); + + /** + * 根据过滤条件删除数据。 + * + * @param filter 过滤对象。 + * @return 删除数量。 + */ + Integer removeBy(M filter); + + /** + * 基于主从表之间的关联字段,批量改更新一对多从表数据。 + * 该操作会覆盖增、删、改三个操作,具体如下: + * 1. 先删除。从表中relationFieldName字段的值为relationFieldValue, 同时主键Id不在dataList中的。 + * 2. 再批量插入。遍历dataList中没有主键Id的对象,视为新对象批量插入。 + * 3. 最后逐条更新,遍历dataList中有主键Id的对象,视为已存在对象并逐条更新。 + * 4. 如果更新时间和更新用户Id为空,我们将视当前记录为变化数据,因此使用当前时间和用户分别填充这两个字段。 + * + * @param relationFieldName 主从表关联中,从表的Java字段名。 + * @param relationFieldValue 主从表关联中,与从表关联的主表字段值。该值会被赋值给从表关联字段。 + * @param updateUserIdFieldName 一对多从表的更新用户Id字段名。 + * @param updateTimeFieldName 一对多从表的更新时间字段名 + * @param dataList 批量更新的从表数据列表。 + * @param batchInserter 从表批量插入方法。 + */ + void updateBatchOneToManyRelation( + String relationFieldName, + Object relationFieldValue, + String updateUserIdFieldName, + String updateTimeFieldName, + List dataList, + Consumer> batchInserter); + + /** + * 判断指定字段的数据是否存在,且仅仅存在一条记录。 + * 如果是基于主键的过滤,会直接调用existId过滤函数,提升性能。在有缓存的场景下,也可以利用缓存。 + * + * @param fieldName 待过滤的字段名(Java 字段)。 + * @param fieldValue 字段值。 + * @return 存在且仅存在一条返回true,否则false。 + */ + boolean existOne(String fieldName, Object fieldValue); + + /** + * 判断主键Id关联的数据是否存在。 + * + * @param id 主键Id。 + * @return 存在返回true,否则false。 + */ + boolean existId(K id); + + /** + * 返回符合过滤条件的一条数据。 + * + * @param filter 过滤的Java对象。 + * @return 查询后的数据对象。 + */ + M getOne(M filter); + + /** + * 返回符合 filterField = filterValue 条件的一条数据。 + * + * @param filterField 过滤的Java字段。 + * @param filterValue 过滤的Java字段值。 + * @return 查询后的数据对象。 + */ + M getOne(String filterField, Object filterValue); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * + * @param id 主表主键Id。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @return 查询结果对象。 + */ + M getByIdWithRelation(K id, MyRelationParam relationParam); + + /** + * 获取所有数据。 + * + * @return 返回所有数据。 + */ + List getAllList(); + + /** + * 获取排序后所有数据。 + * + * @param orderByProperties 需要排序的字段属性,这里使用Java对象中的属性名,而不是数据库字段名。 + * @return 返回排序后所有数据。 + */ + List getAllListByOrder(String... orderByProperties); + + /** + * 判断参数值主键集合中的所有数据,是否全部存在 + * + * @param idSet 待校验的主键集合。 + * @return 全部存在返回true,否则false。 + */ + boolean existAllPrimaryKeys(Set idSet); + + /** + * 判断参数值列表中的所有数据,是否全部存在。另外,keyName字段在数据表中必须是唯一键值,否则返回结果会出现误判。 + * + * @param inFilterField 待校验的数据字段,这里使用Java对象中的属性,如courseId,而不是数据字段名course_id + * @param inFilterValues 数据值列表。 + * @return 全部存在返回true,否则false。 + */ + boolean existUniqueKeyList(String inFilterField, Set inFilterValues); + + /** + * 根据过滤字段和过滤集合,返回不存在的数据。 + * + * @param filterField 过滤的Java字段。 + * @param filterSet 过滤字段数据集合。 + * @param findFirst 是否找到第一个就返回。 + * @param 过滤字段类型。 + * @return filterSet中,在从表中不存在的数据集合。 + */ + List notExist(String filterField, Set filterSet, boolean findFirst); + + /** + * 返回符合主键 IN (idValues) 条件的所有数据。 + * + * @param idValues 主键值集合。 + * @return 检索后的数据列表。 + */ + List getInList(Set idValues); + + /** + * 返回符合 inFilterField IN (inFilterValues) 条件的所有数据。 + * + * @param inFilterField 参与(IN-list)过滤的Java字段。 + * @param inFilterValues 参与(IN-list)过滤的Java字段值集合。 + * @return 检索后的数据列表。 + */ + List getInList(String inFilterField, Set inFilterValues); + + /** + * 返回符合 inFilterField IN (inFilterValues) 条件的所有数据,并根据orderBy字段排序。 + * + * @param inFilterField 参与(IN-list)过滤的Java字段。 + * @param inFilterValues 参与(IN-list)过滤的Java字段值集合。 + * @param orderBy 排序字段。 + * @return 检索后的数据列表。 + */ + List getInList(String inFilterField, Set inFilterValues, String orderBy); + + /** + * 返回符合主键 IN (idValues) 条件的所有数据。同时返回关联数据。 + * + * @param idValues 主键值集合。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @return 检索后的数据列表。 + */ + List getInListWithRelation(Set idValues, MyRelationParam relationParam); + + /** + * 返回符合 inFilterField IN (inFilterValues) 条件的所有数据。同时返回关联数据。 + * + * @param inFilterField 参与(IN-list)过滤的Java字段。 + * @param inFilterValues 参与(IN-list)过滤的Java字段值集合。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @return 检索后的数据列表。 + */ + List getInListWithRelation(String inFilterField, Set inFilterValues, MyRelationParam relationParam); + + /** + * 返回符合 inFilterField IN (inFilterValues) 条件的所有数据,并根据orderBy字段排序。同时返回关联数据。 + * + * @param inFilterField 参与(IN-list)过滤的Java字段。 + * @param inFilterValues 参与(IN-list)过滤的Java字段值集合。 + * @param orderBy 排序字段。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @return 检索后的数据列表。 + */ + List getInListWithRelation( + String inFilterField, Set inFilterValues, String orderBy, MyRelationParam relationParam); + + /** + * 返回符合主键 NOT IN (idValues) 条件的所有数据。 + * + * @param idValues 主键值集合。 + * @return 检索后的数据列表。 + */ + List getNotInList(Set idValues); + + /** + * 返回符合 inFilterField NOT IN (inFilterValues) 条件的所有数据。 + * + * @param inFilterField 参与(NOT IN-list)过滤的Java字段。 + * @param inFilterValues 参与(NOT IN-list)过滤的Java字段值集合。 + * @return 检索后的数据列表。 + */ + List getNotInList(String inFilterField, Set inFilterValues); + + /** + * 返回符合 inFilterField NOT IN (inFilterValues) 条件的所有数据,并根据orderBy字段排序。 + * + * @param inFilterField 参与(NOT IN-list)过滤的Java字段。 + * @param inFilterValues 参与(NOT IN-list)过滤的Java字段值集合。 + * @param orderBy 排序字段。 + * @return 检索后的数据列表。 + */ + List getNotInList(String inFilterField, Set inFilterValues, String orderBy); + + /** + * 返回符合主键 NOT IN (idValues) 条件的所有数据。同时返回关联数据。 + * + * @param idValues 主键值集合。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @return 检索后的数据列表。 + */ + List getNotInListWithRelation(Set idValues, MyRelationParam relationParam); + + /** + * 返回符合 inFilterField NOT IN (inFilterValues) 条件的所有数据。同时返回关联数据。 + * + * @param inFilterField 参与(NOT IN-list)过滤的Java字段。 + * @param inFilterValues 参与(NOT IN-list)过滤的Java字段值集合。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @return 检索后的数据列表。 + */ + List getNotInListWithRelation(String inFilterField, Set inFilterValues, MyRelationParam relationParam); + + /** + * 返回符合 inFilterField NOT IN (inFilterValues) 条件的所有数据,并根据orderBy字段排序。同时返回关联数据。 + * + * @param inFilterField 参与(NOT IN-list)过滤的Java字段。 + * @param inFilterValues 参与(NOT IN-list)过滤的Java字段值集合。 + * @param orderBy 排序字段。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @return 检索后的数据列表。 + */ + List getNotInListWithRelation( + String inFilterField, Set inFilterValues, String orderBy, MyRelationParam relationParam); + + /** + * 用参数对象作为过滤条件,获取数据数量。 + * + * @param filter 过滤对象中,只有被赋值的字段,才会成为where中的条件。 + * @return 返回过滤后的数据数量。 + */ + long getCountByFilter(M filter); + + /** + * 用参数对象作为过滤条件,判断是否存在过滤数据。 + * + * @param filter 过滤对象中,只有被赋值的字段,才会成为where中的条件。 + * @return 存在返回true,否则false。 + */ + boolean existByFilter(M filter); + + /** + * 用参数对象作为过滤条件,获取查询结果。 + * + * @param filter 过滤对象中,只有被赋值的字段,才会成为where中的条件。如果参数为null,则返回全部数据。 + * @return 返回过滤后的数据。 + */ + List getListByFilter(M filter); + + /** + * 用参数对象作为过滤条件,获取查询结果。同时查询并绑定关联数据。 + * + * @param filter 该方法基于mybatis的通用mapper。如果参数为null,则返回全部数据。 + * @param orderBy 排序字段。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @return 返回过滤后的数据。 + */ + List getListWithRelationByFilter(M filter, String orderBy, MyRelationParam relationParam); + + /** + * 获取父主键Id下的所有子数据列表。 + * + * @param parentIdFieldName 父主键字段名字,如"courseId"。 + * @param parentId 父主键的值。 + * @return 父主键Id下的所有子数据列表。 + */ + List getListByParentId(String parentIdFieldName, K parentId); + + /** + * 根据指定的显示字段列表、过滤条件字符串和分组字符串,返回聚合计算后的查询结果。(基本是内部框架使用,不建议外部接口直接使用)。 + * + * @param selectFields 选择的字段列表,多个字段逗号分隔。 + * NOTE: 如果数据表字段和Java对象字段名字不同,Java对象字段应该以别名的形式出现。 + * 如: table_column_name modelFieldName。否则无法被反射回Bean对象。 + * @param whereClause SQL常量形式的条件从句。 + * @param groupBy SQL常量形式分组字段列表,逗号分隔。 + * @return 聚合计算后的数据结果集。 + */ + List> getGroupedListByCondition(String selectFields, String whereClause, String groupBy); + + /** + * 根据指定的显示字段列表、过滤条件字符串和排序字符串,返回查询结果。(基本是内部框架使用,不建议外部接口直接使用)。 + * + * @param selectList 选择的Java字段列表。如果为空表示返回全部字段。 + * @param filter 过滤对象。 + * @param whereClause SQL常量形式的条件从句。 + * @param orderBy SQL常量形式排序字段列表,逗号分隔。 + * @return 查询结果。 + */ + List getListByCondition(List selectList, M filter, String whereClause, String orderBy); + + /** + * 用指定过滤条件,计算记录数量。(基本是内部框架使用,不建议外部接口直接使用)。 + * + * @param whereClause SQL常量形式的条件从句。 + * @return 返回过滤后的数据数量。 + */ + Integer getCountByCondition(String whereClause); + + /** + * 仅对标记MaskField注解的字段数据进行脱敏。 + * + * @param data 实体对象。 + * @param ignoreFieldSet 忽略字段集合。如果为null,则对所有标记MaskField注解的字段数据进行脱敏处理。 + */ + void maskFieldData(M data, Set ignoreFieldSet); + + /** + * 仅对标记MaskField注解的字段数据进行脱敏。 + * + * @param dataList 实体对象列表。 + * @param ignoreFieldSet 忽略字段集合。如果为null,则对所有标记MaskField注解的字段数据进行脱敏处理。 + */ + void maskFieldDataList(List dataList, Set ignoreFieldSet); + + /** + * 比较并处理脱敏字段的数据变化。 + * 如果data对象中的脱敏字段值和originalData字段的脱敏后值相同,表示当前data对象的脱敏字段数据没有变化, + * 因此需要使用数据库中的原有字段值,覆盖当前实体对象中的该字段值,以保证数据库表字段中始终存储的是未脱敏数据。 + * + * @param data 当前数据对象。 + * @param originalData 原数据对象。 + */ + void compareAndSetMaskFieldData(M data, M originalData); + + /** + * 对标记MaskField注解的脱敏字段进行判断。字段数据中不能包含脱敏掩码字符。 + * + * @param data 实体对象。 + */ + void verifyMaskFieldData(M data); + + /** + * 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。 + * NOTE: BaseService中会给出返回CallResult.ok()的缺省实现。每个业务服务实现类在需要的时候可以重载该方法。 + * + * @param data 数据对象。 + * @param originalData 原有数据对象,null表示data为新增对象。 + * @return 应答结果对象。 + */ + CallResult verifyRelatedData(M data, M originalData); + + /** + * 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。 + * 如果data对象中包含主键值,方法内部会获取原有对象值,并进行更新方式的关联数据比对,否则视为新增数据关联对象比对。 + * + * @param data 数据对象。 + * @return 应答结果对象。 + */ + CallResult verifyRelatedData(M data); + + /** + * 根据最新对象列表和原有对象列表的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。 + * 如果dataList列表中的对象包含主键值,方法内部会获取原有对象值,并进行更新方式的关联数据比对,否则视为新增数据关联对象比对。 + * + * @param dataList 数据对象列表。 + * @return 应答结果对象。 + */ + CallResult verifyRelatedData(List dataList); + + /** + * 批量导入数据列表,对依赖全局字典的数据进行验证。 + * + * @param dataList 批量导入数据列表。 + * @param fieldName 业务主表中依赖全局字典的字段名,包含RelationGlobalDict注解的字段。 + * @param idGetter 获取业务主表中依赖全局字典字段值的Function对象。 + * @param 业务主表中依全局字典的字段类型。 + * @return 验证结果,如果失败,在data中包含具体的错误对象。 + */ + CallResult verifyImportForGlobalDict(List dataList, String fieldName, Function idGetter); + + /** + * 批量导入数据列表,对依赖常量字典的数据进行验证。 + * + * @param dataList 批量导入数据列表。 + * @param fieldName 业务主表中依赖常量字典的字段名,包含RelationConstDict注解的字段。 + * @param idGetter 获取业务主表中依赖常量字典字段值的Function对象。 + * @param 业务主表中依赖常量字典的字段类型。 + * @return 验证结果,如果失败,在data中包含具体的错误对象。 + */ + CallResult verifyImportForConstDict(List dataList, String fieldName, Function idGetter); + + /** + * 批量导入数据列表,对依赖字典表字典的数据进行验证。 + * + * @param dataList 批量导入数据列表。 + * @param fieldName 业务主表中依赖字典表字典的字段名,包含RelationDict注解的字段。 + * @param idGetter 获取业务主表中依赖字典表字典字段值的Function对象。 + * @param 业务主表中依赖字典表字典的字段类型。 + * @return 验证结果,如果失败,在data中包含具体的错误对象。 + */ + CallResult verifyImportForDict(List dataList, String fieldName, Function idGetter); + + /** + * 批量导入数据列表,对依赖数据源字典的数据进行验证。 + * + * @param dataList 批量导入数据列表。 + * @param fieldName 业务主表中依赖数据源字典的字段名,包含RelationDict注解的字段的数据源字典。 + * @param idGetter 获取业务主表中依赖数据源字典字段值的Function对象。 + * @param 业务主表中依赖数据源字典的字段类型。 + * @return 验证结果,如果失败,在data中包含具体的错误对象。 + */ + CallResult verifyImportForDatasourceDict(List dataList, String fieldName, Function idGetter); + + /** + * 批量导入数据列表,对存在一对一关联的数据进行验证。 + * + * @param dataList 批量导入数据列表。 + * @param fieldName 业务主表中存在一对一关联的字段名,包含RelationOneToOne注解的字段。 + * @param idGetter 获取业务主表中一对一关联字段值的Function对象。 + * @param 业务主表中存在一对一关联的字段类型。 + * @return 验证结果,如果失败,在data中包含具体的错误对象。 + */ + CallResult verifyImportForOneToOneRelation(List dataList, String fieldName, Function idGetter); + + /** + * 集成所有与主表实体对象相关的关联数据列表。包括一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param resultList 主表实体对象列表。数据集成将直接作用于该对象列表。 + * @param relationParam 实体对象数据组装的参数构建器。 + */ + void buildRelationForDataList(List resultList, MyRelationParam relationParam); + + /** + * 集成所有与主表实体对象相关的关联数据列表。包括本地和远程服务的一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param resultList 主表实体对象列表。数据集成将直接作用于该对象列表。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + void buildRelationForDataList(List resultList, MyRelationParam relationParam, Set ignoreFields); + + /** + * 该函数主要用于对查询结果的批量导出。不同于支持分页的列表查询,批量导出没有分页机制, + * 因此在导出数据量较大的情况下,很容易给数据库的内存、CPU和IO带来较大的压力。而通过 + * 我们的分批处理,可以极大的规避该问题的出现几率。调整batchSize的大小,也可以有效的 + * 改善运行效率。 + * 我们目前的处理机制是,先从主表取出所有符合条件的主表数据,这样可以避免分批处理时, + * 后面几批数据,因为skip过多而带来的效率问题。因为是单表过滤,不会给数据库带来过大的压力。 + * 之后再在主表结果集数据上进行分批级联处理。 + * 集成所有与主表实体对象相关的关联数据列表。包括一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param resultList 主表实体对象列表。数据集成将直接作用于该对象列表。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @param batchSize 每批集成的记录数量。小于等于0时将不做分批处理。 + */ + void buildRelationForDataList(List resultList, MyRelationParam relationParam, int batchSize); + + /** + * 该函数主要用于对查询结果的批量导出。不同于支持分页的列表查询,批量导出没有分页机制, + * 因此在导出数据量较大的情况下,很容易给数据库的内存、CPU和IO带来较大的压力。而通过 + * 我们的分批处理,可以极大的规避该问题的出现几率。调整batchSize的大小,也可以有效的 + * 改善运行效率。 + * 我们目前的处理机制是,先从主表取出所有符合条件的主表数据,这样可以避免分批处理时, + * 后面几批数据,因为skip过多而带来的效率问题。因为是单表过滤,不会给数据库带来过大的压力。 + * 之后再在主表结果集数据上进行分批级联处理。 + * 集成所有与主表实体对象相关的关联数据列表。包括一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param resultList 主表实体对象列表。数据集成将直接作用于该对象列表。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @param batchSize 每批集成的记录数量。小于等于0时将不做分批处理。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + */ + void buildRelationForDataList( + List resultList, MyRelationParam relationParam, int batchSize, Set ignoreFields); + + /** + * 集成所有与主表实体对象相关的关联数据对象。包括一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param dataObject 主表实体对象。数据集成将直接作用于该对象。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @param 实体对象类型。 + */ + void buildRelationForData(T dataObject, MyRelationParam relationParam); + + /** + * 集成所有与主表实体对象相关的关联数据对象。包括本地和远程服务的一对一、字典、一对多和多对多聚合运算等。 + * 也可以根据实际需求,单独调用该函数所包含的各个数据集成函数。 + * NOTE: 该方法内执行的SQL将禁用数据权限过滤。 + * + * @param dataObject 主表实体对象。数据集成将直接作用于该对象。 + * @param relationParam 实体对象数据组装的参数构建器。 + * @param ignoreFields 该集合中的字段,即便包含注解也不会在当前调用中进行数据组装。 + * @param 实体对象类型。 + */ + void buildRelationForData(T dataObject, MyRelationParam relationParam, Set ignoreFields); + + /** + * 仅仅在spring boot 启动后的监听器事件中调用,缓存所有service的关联关系,加速后续的数据绑定效率。 + */ + void loadRelationStruct(); + + /** + * 获取当前服务引用的实体对象及表信息。 + * + * @return 实体对象及表信息。 + */ + TableModelInfo getTableModelInfo(); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/vo/BaseVo.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/vo/BaseVo.java new file mode 100644 index 00000000..a4313a53 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/base/vo/BaseVo.java @@ -0,0 +1,35 @@ +package com.orangeforms.common.core.base.vo; + +import lombok.Data; + +import java.util.Date; + +/** + * VO对象的公共基类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class BaseVo { + + /** + * 创建者Id。 + */ + private Long createUserId; + + /** + * 创建时间。 + */ + private Date createTime; + + /** + * 更新者Id。 + */ + private Long updateUserId; + + /** + * 更新时间。 + */ + private Date updateTime; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/cache/CacheConfig.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/cache/CacheConfig.java new file mode 100644 index 00000000..203eafd1 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/cache/CacheConfig.java @@ -0,0 +1,110 @@ +package com.orangeforms.common.core.cache; + +import com.github.benmanes.caffeine.cache.Caffeine; +import org.springframework.cache.CacheManager; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.cache.caffeine.CaffeineCache; +import org.springframework.cache.support.SimpleCacheManager; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.ArrayList; +import java.util.concurrent.TimeUnit; + +/** + * 使用Caffeine作为本地缓存库 + * + * @author Jerry + * @date 2024-07-02 + */ +@Configuration +@EnableCaching +public class CacheConfig { + + private static final int DEFAULT_MAXSIZE = 10000; + private static final int DEFAULT_TTL = 3600; + + /** + * 定义cache名称、超时时长秒、最大个数 + * 每个cache缺省3600秒过期,最大个数1000 + */ + public enum CacheEnum { + /** + * 专门存储用户权限的缓存(600秒)。 + */ + USER_PERMISSION_CACHE(600, 10000), + /** + * 专门存储用户权限字的缓存(600秒)。仅当使用satoken权限框架时可用。 + */ + USER_PERM_CODE_CACHE(600, 10000), + /** + * 专门存储用户数据权限的缓存(600秒)。 + */ + DATA_PERMISSION_CACHE(600, 10000), + /** + * 专门存储用户菜单关联权限的缓存(600秒)。 + */ + MENU_PERM_CACHE(600, 10000), + /** + * 存储指定部门Id集合的所有子部门Id集合。 + */ + CHILDREN_DEPT_ID_CACHE(1800, 10000), + /** + * 在线表单组件渲染数据缓存。 + */ + ONLINE_FORM_RENDER_CACCHE(300, 100), + /** + * 报表表单组件渲染数据缓存。 + */ + REPORT_FORM_RENDER_CACCHE(300, 100), + /** + * 缺省全局缓存(时间是24小时)。 + */ + GLOBAL_CACHE(86400, 20000); + + CacheEnum() { + } + + CacheEnum(int ttl, int maxSize) { + this.ttl = ttl; + this.maxSize = maxSize; + } + + /** + * 缓存的最大数量。 + */ + private int maxSize = DEFAULT_MAXSIZE; + /** + * 缓存的时长(单位:秒) + */ + private int ttl = DEFAULT_TTL; + + public int getMaxSize() { + return maxSize; + } + + public int getTtl() { + return ttl; + } + } + + /** + * 初始化缓存配置。这里为了有别于Redisson的缓存。 + */ + @Bean("caffeineCacheManager") + public CacheManager cacheManager() { + SimpleCacheManager manager = new SimpleCacheManager(); + // 把各个cache注册到cacheManager中,CaffeineCache实现了org.springframework.cache.Cache接口 + ArrayList caches = new ArrayList<>(); + for (CacheEnum c : CacheEnum.values()) { + caches.add(new CaffeineCache(c.name(), + Caffeine.newBuilder().recordStats() + .expireAfterWrite(c.getTtl(), TimeUnit.SECONDS) + .maximumSize(c.getMaxSize()) + .build()) + ); + } + manager.setCaches(caches); + return manager; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/cache/DictionaryCache.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/cache/DictionaryCache.java new file mode 100644 index 00000000..14fe0391 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/cache/DictionaryCache.java @@ -0,0 +1,89 @@ +package com.orangeforms.common.core.cache; + +import java.util.List; +import java.util.Set; + +/** + * 主要用于完整缓存字典表数据的接口对象。 + * + * @param 字典表主键类型。 + * @param 字典表对象类型。 + * @author Jerry + * @date 2024-07-02 + */ +public interface DictionaryCache { + + /** + * 按照数据插入的顺序返回全部字典对象的列表。 + * + * @return 全部字段数据列表。 + */ + List getAll(); + + /** + * 获取缓存中与键列表对应的对象列表。 + * + * @param keys 主键集合。 + * @return 对象列表。 + */ + List getInList(Set keys); + + /** + * 重新加载。如果数据列表为空,则会清空原有缓存数据。 + * + * @param dataList 待缓存的数据列表。 + * @param force true则强制刷新,如果false,当缓存中存在数据时不刷新。 + */ + void reload(List dataList, boolean force); + + /** + * 从缓存中获取指定的数据。 + * + * @param key 数据的key。 + * @return 获取到的数据,如果没有返回null。 + */ + V get(K key); + + /** + * 将数据存入缓存。 + * + * @param key 通常为字典数据的主键。 + * @param object 字典数据对象。 + */ + void put(K key, V object); + + /** + * 获取缓存中数据条目的数量。 + * + * @return 返回缓存的数据数量。 + */ + int getCount(); + + /** + * 删除缓存中指定的键。 + * + * @param key 待删除数据的主键。 + * @return 返回被删除的对象,如果主键不存在,返回null。 + */ + V invalidate(K key); + + /** + * 删除缓存中,参数列表中包含的键。 + * + * @param keys 待删除数据的主键集合。 + */ + void invalidateSet(Set keys); + + /** + * 清空缓存。 + */ + void invalidateAll(); + + /** + * 根据父主键Id获取所有子对象的列表。 + * + * @param parentId 父主键Id。如果parentId为null,则返回所有一级节点数据。 + * @return 所有子对象的列表。 + */ + default List getListByParentId(K parentId) { throw new UnsupportedOperationException(); } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/cache/MapDictionaryCache.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/cache/MapDictionaryCache.java new file mode 100644 index 00000000..7f238801 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/cache/MapDictionaryCache.java @@ -0,0 +1,200 @@ +package com.orangeforms.common.core.cache; + +import cn.hutool.core.map.MapUtil; +import com.orangeforms.common.core.exception.MapCacheAccessException; +import lombok.extern.slf4j.Slf4j; + +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import java.util.function.Function; +import java.util.function.Supplier; + +/** + * 字典数据内存缓存对象。 + * + * @param 字典表主键类型。 + * @param 字典表对象类型。 + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class MapDictionaryCache implements DictionaryCache { + + /** + * 存储字典数据的Map。 + */ + protected final LinkedHashMap dataMap = new LinkedHashMap<>(); + /** + * 获取字典主键数据的函数对象。 + */ + protected final Function idGetter; + /** + * 由于大部分场景是读取操作,所以使用读写锁提高并发的伸缩性。 + */ + protected final ReadWriteLock lock = new ReentrantReadWriteLock(); + /** + * 超时时长。单位毫秒。 + */ + protected static final long TIMEOUT = 2000L; + + /** + * 当前对象的构造器函数。 + * + * @param idGetter 获取当前类主键字段值的函数对象。 + * @param 字典主键类型。 + * @param 字典对象类型 + * @return 实例化后的字典内存缓存对象。 + */ + public static MapDictionaryCache create(Function idGetter) { + if (idGetter == null) { + throw new IllegalArgumentException("IdGetter can't be NULL."); + } + return new MapDictionaryCache<>(idGetter); + } + + /** + * 构造函数。 + * + * @param idGetter 主键Id的获取函数对象。 + */ + public MapDictionaryCache(Function idGetter) { + this.idGetter = idGetter; + } + + @Override + public List getAll() { + return this.safeRead("getAll", () -> { + List resultList = new LinkedList<>(); + if (MapUtil.isNotEmpty(dataMap)) { + resultList.addAll(dataMap.values()); + } + return resultList; + }); + } + + @Override + public List getInList(Set keys) { + return this.safeRead("getInList", () -> { + List resultList = new LinkedList<>(); + keys.forEach(key -> { + V object = dataMap.get(key); + if (object != null) { + resultList.add(object); + } + }); + return resultList; + }); + } + + @Override + public V get(K id) { + if (id == null) { + return null; + } + return this.safeRead("get", () -> dataMap.get(id)); + } + + @Override + public void reload(List dataList, boolean force) { + if (!force && this.getCount() > 0) { + return; + } + this.safeWrite("reload", () -> { + dataMap.clear(); + dataList.forEach(dataObj -> { + K id = idGetter.apply(dataObj); + dataMap.put(id, dataObj); + }); + return null; + }); + } + + @Override + public void put(K id, V object) { + this.safeWrite("put", () -> dataMap.put(id, object)); + } + + @Override + public int getCount() { + return dataMap.size(); + } + + @Override + public V invalidate(K id) { + if (id == null) { + return null; + } + return this.safeWrite("invalidate", () -> dataMap.remove(id)); + } + + @Override + public void invalidateSet(Set keys) { + this.safeWrite("invalidateSet", () -> { + keys.forEach(id -> { + if (id != null) { + dataMap.remove(id); + } + }); + return null; + }); + } + + @Override + public void invalidateAll() { + this.safeWrite("invalidateAll", () -> { + dataMap.clear(); + return null; + }); + } + + protected T safeRead(String functionName, Supplier supplier) { + String exceptionMessage; + try { + if (lock.readLock().tryLock(TIMEOUT, TimeUnit.MILLISECONDS)) { + try { + return supplier.get(); + } finally { + lock.readLock().unlock(); + } + } else { + throw new TimeoutException(); + } + } catch (Exception e) { + if (e instanceof InterruptedException) { + Thread.currentThread().interrupt(); + } + exceptionMessage = String.format( + "LOCK Operation of [MapDictionaryCache::%s] encountered EXCEPTION [%s] for DICT.", + functionName, e.getClass().getSimpleName()); + log.warn(exceptionMessage); + throw new MapCacheAccessException(exceptionMessage, e); + } + } + + protected T safeWrite(String functionName, Supplier supplier) { + String exceptionMessage; + try { + if (lock.writeLock().tryLock(TIMEOUT, TimeUnit.MILLISECONDS)) { + try { + return supplier.get(); + } finally { + lock.writeLock().unlock(); + } + } else { + throw new TimeoutException(); + } + } catch (Exception e) { + if (e instanceof InterruptedException) { + Thread.currentThread().interrupt(); + } + exceptionMessage = String.format( + "LOCK Operation of [MapDictionaryCache::%s] encountered EXCEPTION [%s] for DICT.", + functionName, e.getClass().getSimpleName()); + log.warn(exceptionMessage); + throw new MapCacheAccessException(exceptionMessage, e); + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/cache/MapTreeDictionaryCache.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/cache/MapTreeDictionaryCache.java new file mode 100644 index 00000000..b492ebe2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/cache/MapTreeDictionaryCache.java @@ -0,0 +1,138 @@ +package com.orangeforms.common.core.cache; + +import cn.hutool.core.collection.CollUtil; +import com.google.common.collect.LinkedHashMultimap; +import com.google.common.collect.Multimap; +import lombok.extern.slf4j.Slf4j; + +import java.util.*; +import java.util.function.Function; + +/** + * 树形字典数据内存缓存对象。 + * + * @param 字典表主键类型。 + * @param 字典表对象类型。 + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class MapTreeDictionaryCache extends MapDictionaryCache { + + /** + * 树形数据存储对象。 + */ + private final Multimap allTreeMap = LinkedHashMultimap.create(); + /** + * 获取字典父主键数据的函数对象。 + */ + protected final Function parentIdGetter; + + /** + * 当前对象的构造器函数。 + * + * @param idGetter 获取当前类主键字段值的函数对象。 + * @param parentIdGetter 获取当前类父主键字段值的函数对象。 + * @param 字典主键类型。 + * @param 字典对象类型 + * @return 实例化后的树形字典内存缓存对象。 + */ + public static MapTreeDictionaryCache create(Function idGetter, Function parentIdGetter) { + if (idGetter == null) { + throw new IllegalArgumentException("IdGetter can't be NULL."); + } + if (parentIdGetter == null) { + throw new IllegalArgumentException("ParentIdGetter can't be NULL."); + } + return new MapTreeDictionaryCache<>(idGetter, parentIdGetter); + } + + /** + * 构造函数。 + * + * @param idGetter 获取当前类主键字段值的函数对象。 + * @param parentIdGetter 获取当前类父主键字段值的函数对象。 + */ + public MapTreeDictionaryCache(Function idGetter, Function parentIdGetter) { + super(idGetter); + this.parentIdGetter = parentIdGetter; + } + + @Override + public void reload(List dataList, boolean force) { + if (!force && this.getCount() > 0) { + return; + } + this.safeWrite("reload", () -> { + dataMap.clear(); + allTreeMap.clear(); + dataList.forEach(data -> { + K id = idGetter.apply(data); + dataMap.put(id, data); + K parentId = parentIdGetter.apply(data); + allTreeMap.put(parentId, data); + }); + return null; + }); + } + + @Override + public List getListByParentId(K parentId) { + return this.safeRead("getListByParentId", () -> { + List resultList = new LinkedList<>(); + Collection children = allTreeMap.get(parentId); + if (CollUtil.isNotEmpty(children)) { + resultList.addAll(children); + } + return resultList; + }); + } + + @Override + public void put(K id, V data) { + this.safeWrite("put", () -> { + dataMap.put(id, data); + K parentId = parentIdGetter.apply(data); + allTreeMap.remove(parentId, data); + allTreeMap.put(parentId, data); + return null; + }); + } + + @Override + public V invalidate(K id) { + return this.safeWrite("invalidate", () -> { + V v = dataMap.remove(id); + if (v != null) { + K parentId = parentIdGetter.apply(v); + allTreeMap.remove(parentId, v); + } + return v; + }); + } + + @Override + public void invalidateSet(Set keys) { + this.safeWrite("invalidateSet", () -> { + keys.forEach(id -> { + if (id != null) { + V data = dataMap.remove(id); + if (data != null) { + K parentId = parentIdGetter.apply(data); + allTreeMap.remove(parentId, data); + } + } + }); + return null; + }); + } + + @Override + public void invalidateAll() { + this.safeWrite("invalidateAll", () -> { + dataMap.clear(); + allTreeMap.clear(); + return null; + }); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/BaseMultiDataSourceConfig.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/BaseMultiDataSourceConfig.java new file mode 100644 index 00000000..369fcf33 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/BaseMultiDataSourceConfig.java @@ -0,0 +1,60 @@ +package com.orangeforms.common.core.config; + +import com.alibaba.druid.pool.DruidDataSource; +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +/** + * 基于Druid的数据源配置的基类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Configuration +@ConfigurationProperties(prefix = "spring.datasource.druid") +public class BaseMultiDataSourceConfig { + + private String driverClassName; + private String name; + private Integer initialSize; + private Integer minIdle; + private Integer maxActive; + private Integer maxWait; + private Integer timeBetweenEvictionRunsMillis; + private Integer minEvictableIdleTimeMillis; + private Boolean poolPreparedStatements; + private Integer maxPoolPreparedStatementPerConnectionSize; + private Integer maxOpenPreparedStatements; + private String validationQuery; + private Boolean testWhileIdle; + private Boolean testOnBorrow; + private Boolean testOnReturn; + + /** + * 将连接池的通用配置应用到数据源对象上。 + * + * @param druidDataSource Druid的数据源。 + * @return 应用后的Druid数据源。 + */ + protected DruidDataSource applyCommonProps(DruidDataSource druidDataSource) { + druidDataSource.setConnectionErrorRetryAttempts(5); + druidDataSource.setDriverClassName(driverClassName); + druidDataSource.setName(name); + druidDataSource.setInitialSize(initialSize); + druidDataSource.setMinIdle(minIdle); + druidDataSource.setMaxActive(maxActive); + druidDataSource.setMaxWait(maxWait); + druidDataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); + druidDataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); + druidDataSource.setPoolPreparedStatements(poolPreparedStatements); + druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize); + druidDataSource.setMaxOpenPreparedStatements(maxOpenPreparedStatements); + druidDataSource.setValidationQuery(validationQuery); + druidDataSource.setTestWhileIdle(testWhileIdle); + druidDataSource.setTestOnBorrow(testOnBorrow); + druidDataSource.setTestOnReturn(testOnReturn); + return druidDataSource; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/CommonWebMvcConfig.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/CommonWebMvcConfig.java new file mode 100644 index 00000000..e621b784 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/CommonWebMvcConfig.java @@ -0,0 +1,87 @@ +package com.orangeforms.common.core.config; + +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.alibaba.fastjson.support.config.FastJsonConfig; +import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; +import com.orangeforms.common.core.interceptor.MyRequestArgumentResolver; +import com.orangeforms.common.core.util.ContextUtil; +import com.orangeforms.common.core.util.MyDateUtil; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.http.converter.ByteArrayHttpMessageConverter; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.StringHttpMessageConverter; +import org.springframework.validation.beanvalidation.MethodValidationPostProcessor; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import jakarta.servlet.http.HttpServletRequest; +import java.lang.reflect.Type; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; + +/** + * 所有的项目拦截器、参数解析器、消息对象转换器都在这里集中配置。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Configuration +public class CommonWebMvcConfig implements WebMvcConfigurer { + + @Bean + public MethodValidationPostProcessor methodValidationPostProcessor() { + return new MethodValidationPostProcessor(); + } + + @Override + public void addArgumentResolvers(List argumentResolvers) { + // 添加MyRequestBody参数解析器 + argumentResolvers.add(new MyRequestArgumentResolver()); + } + + private HttpMessageConverter responseBodyConverter() { + return new StringHttpMessageConverter(StandardCharsets.UTF_8); + } + + @Bean + public FastJsonHttpMessageConverter fastJsonHttpMessageConverter() { + FastJsonHttpMessageConverter fastConverter = new MyFastJsonHttpMessageConverter(); + List supportedMediaTypes = new ArrayList<>(); + supportedMediaTypes.add(MediaType.APPLICATION_JSON); + supportedMediaTypes.add(MediaType.APPLICATION_FORM_URLENCODED); + fastConverter.setSupportedMediaTypes(supportedMediaTypes); + FastJsonConfig fastJsonConfig = new FastJsonConfig(); + fastJsonConfig.setSerializerFeatures( + SerializerFeature.PrettyFormat, + SerializerFeature.DisableCircularReferenceDetect, + SerializerFeature.IgnoreNonFieldGetter); + fastJsonConfig.setDateFormat(MyDateUtil.COMMON_SHORT_DATETIME_FORMAT); + fastConverter.setFastJsonConfig(fastJsonConfig); + return fastConverter; + } + + @Override + public void configureMessageConverters(List> converters) { + converters.add(responseBodyConverter()); + converters.add(new ByteArrayHttpMessageConverter()); + converters.add(fastJsonHttpMessageConverter()); + } + + public static class MyFastJsonHttpMessageConverter extends FastJsonHttpMessageConverter { + + @Override + public boolean canWrite(Type type, Class clazz, MediaType mediaType) { + HttpServletRequest request = ContextUtil.getHttpRequest(); + if (request == null) { + return super.canWrite(type, clazz, mediaType); + } + if (request.getRequestURI().contains("/v3/api-docs")) { + return false; + } + return super.canWrite(type, clazz, mediaType); + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/CoreProperties.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/CoreProperties.java new file mode 100644 index 00000000..b2bcabe2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/CoreProperties.java @@ -0,0 +1,83 @@ +package com.orangeforms.common.core.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +/** + * common-core的配置属性类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Configuration +@ConfigurationProperties(prefix = "common-core") +public class CoreProperties { + + public static final String MYSQL_TYPE = "mysql"; + public static final String POSTGRESQL_TYPE = "postgresql"; + public static final String ORACLE_TYPE = "oracle"; + public static final String DM_TYPE = "dm8"; + public static final String KINGBASE_TYPE = "kingbase"; + public static final String OPENGAUSS_TYPE = "opengauss"; + + /** + * 数据库类型。 + */ + private String databaseType = MYSQL_TYPE; + + /** + * 是否为MySQL。 + * + * @return 是返回true,否则false。 + */ + public boolean isMySql() { + return this.databaseType.equals(MYSQL_TYPE); + } + + /** + * 是否为PostgreSQl。 + * + * @return 是返回true,否则false。 + */ + public boolean isPostgresql() { + return this.databaseType.equals(POSTGRESQL_TYPE); + } + + /** + * 是否为Oracle。 + * + * @return 是返回true,否则false。 + */ + public boolean isOracle() { + return this.databaseType.equals(ORACLE_TYPE); + } + + /** + * 是否为达梦8。 + * + * @return 是返回true,否则false。 + */ + public boolean isDm() { + return this.databaseType.equals(DM_TYPE); + } + + /** + * 是否为人大金仓。 + * + * @return 是返回true,否则false。 + */ + public boolean isKingbase() { + return this.databaseType.equals(KINGBASE_TYPE); + } + + /** + * 是否为华为高斯。 + * + * @return 是返回true,否则false。 + */ + public boolean isOpenGauss() { + return this.databaseType.equals(OPENGAUSS_TYPE); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/DataSourceContextHolder.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/DataSourceContextHolder.java new file mode 100644 index 00000000..534443d7 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/DataSourceContextHolder.java @@ -0,0 +1,52 @@ +package com.orangeforms.common.core.config; + +/** + * 通过线程本地存储的方式,保存当前数据库操作所需的数据源类型,动态数据源会根据该值,进行动态切换。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class DataSourceContextHolder { + + private static final ThreadLocal CONTEXT_HOLDER = new ThreadLocal<>(); + + /** + * 设置数据源类型。 + * + * @param type 数据源类型 + * @return 原有数据源类型,如果第一次设置则返回null。 + */ + public static Integer setDataSourceType(Integer type) { + Integer datasourceType = CONTEXT_HOLDER.get(); + CONTEXT_HOLDER.set(type); + return datasourceType; + } + + /** + * 获取当前数据库操作执行线程的数据源类型,同时由动态数据源的路由函数调用。 + * + * @return 数据源类型。 + */ + public static Integer getDataSourceType() { + return CONTEXT_HOLDER.get(); + } + + /** + * 清除线程本地变量,以免内存泄漏。 + + * @param originalType 原有的数据源类型,如果该值为null,则情况本地化变量。 + */ + public static void unset(Integer originalType) { + if (originalType == null) { + CONTEXT_HOLDER.remove(); + } else { + CONTEXT_HOLDER.set(originalType); + } + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private DataSourceContextHolder() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/DataSourceInfo.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/DataSourceInfo.java new file mode 100644 index 00000000..8e03fcc2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/DataSourceInfo.java @@ -0,0 +1,41 @@ +package com.orangeforms.common.core.config; + +import lombok.Data; + +/** + * 主要用户动态多数据源使用的配置数据。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class DataSourceInfo { + /** + * 用于多数据源切换的数据源类型。 + */ + private Integer datasourceType; + /** + * 用户名。 + */ + private String username; + /** + * 密码。 + */ + private String password; + /** + * 数据库主机。 + */ + private String databaseHost; + /** + * 端口号。 + */ + private Integer port; + /** + * 模式名。 + */ + private String schemaName; + /** + * 数据库名称。 + */ + private String databaseName; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/DynamicDataSource.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/DynamicDataSource.java new file mode 100644 index 00000000..1508412d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/DynamicDataSource.java @@ -0,0 +1,170 @@ +package com.orangeforms.common.core.config; + +import cn.hutool.core.util.StrUtil; +import com.alibaba.druid.pool.DruidDataSource; +import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; +import org.springframework.util.Assert; + +import java.util.*; + +/** + * 动态数据源对象。当存在多个数据连接时使用。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class DynamicDataSource extends AbstractRoutingDataSource { + + @Autowired + private BaseMultiDataSourceConfig baseMultiDataSourceConfig; + @Autowired + private CoreProperties properties; + + private Set dynamicDatasourceTypeSet = new HashSet<>(); + private static final String ASSERT_MSG = "defaultTargetDatasource can't be null."; + + @Override + protected Object determineCurrentLookupKey() { + return DataSourceContextHolder.getDataSourceType(); + } + + /** + * 重新加载动态添加的数据源。既清空之前动态添加的数据源,同时添加参数中的新数据源列表。 + * + * @param dataSourceInfoList 新动态数据源列表。 + */ + public synchronized void reloadAll(List dataSourceInfoList) { + Map dataSourceMap = new HashMap<>(this.getResolvedDataSources()); + dynamicDatasourceTypeSet.forEach(dataSourceMap::remove); + dynamicDatasourceTypeSet.clear(); + for (DataSourceInfo dataSourceInfo : dataSourceInfoList) { + dynamicDatasourceTypeSet.add(dataSourceInfo.getDatasourceType()); + DruidDataSource dataSource = this.doConvert(dataSourceInfo); + baseMultiDataSourceConfig.applyCommonProps(dataSource); + dataSourceMap.put(dataSourceInfo.getDatasourceType(), dataSource); + } + Object defaultTargetDatasource = this.getResolvedDefaultDataSource(); + Assert.notNull(defaultTargetDatasource, ASSERT_MSG); + this.setTargetDataSources(dataSourceMap); + this.setDefaultTargetDataSource(defaultTargetDatasource); + super.afterPropertiesSet(); + } + + /** + * 添加动态添加数据源。 + * + * 动态添加数据源。 + */ + public synchronized void addDataSource(DataSourceInfo dataSourceInfo) { + if (dynamicDatasourceTypeSet.contains(dataSourceInfo.getDatasourceType())) { + return; + } + dynamicDatasourceTypeSet.add(dataSourceInfo.getDatasourceType()); + Map dataSourceMap = new HashMap<>(this.getResolvedDataSources()); + DruidDataSource dataSource = this.doConvert(dataSourceInfo); + baseMultiDataSourceConfig.applyCommonProps(dataSource); + dataSourceMap.put(dataSourceInfo.getDatasourceType(), dataSource); + Object defaultTargetDatasource = this.getResolvedDefaultDataSource(); + Assert.notNull(defaultTargetDatasource, ASSERT_MSG); + this.setTargetDataSources(dataSourceMap); + this.setDefaultTargetDataSource(defaultTargetDatasource); + super.afterPropertiesSet(); + } + + /** + * 添加动态添加数据源列表。 + * + * @param dataSourceInfoList 数据源信息列表。 + */ + public synchronized void addDataSources(List dataSourceInfoList) { + Map dataSourceMap = new HashMap<>(this.getResolvedDataSources()); + for (DataSourceInfo dataSourceInfo : dataSourceInfoList) { + if (!dynamicDatasourceTypeSet.contains(dataSourceInfo.getDatasourceType())) { + dynamicDatasourceTypeSet.add(dataSourceInfo.getDatasourceType()); + DruidDataSource dataSource = this.doConvert(dataSourceInfo); + baseMultiDataSourceConfig.applyCommonProps(dataSource); + dataSourceMap.put(dataSourceInfo.getDatasourceType(), dataSource); + } + } + Object defaultTargetDatasource = this.getResolvedDefaultDataSource(); + Assert.notNull(defaultTargetDatasource, ASSERT_MSG); + this.setTargetDataSources(dataSourceMap); + this.setDefaultTargetDataSource(defaultTargetDatasource); + super.afterPropertiesSet(); + } + + /** + * 动态移除数据源。 + * + * @param datasourceType 数据源类型。 + */ + public synchronized void removeDataSource(int datasourceType) { + if (!dynamicDatasourceTypeSet.remove(datasourceType)) { + return; + } + Map dataSourceMap = new HashMap<>(this.getResolvedDataSources()); + dataSourceMap.remove(datasourceType); + Object defaultTargetDatasource = this.getResolvedDefaultDataSource(); + Assert.notNull(defaultTargetDatasource, ASSERT_MSG); + this.setTargetDataSources(dataSourceMap); + this.setDefaultTargetDataSource(defaultTargetDatasource); + super.afterPropertiesSet(); + } + + private DruidDataSource doConvert(DataSourceInfo dataSourceInfo) { + DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); + dataSource.setUsername(dataSourceInfo.getUsername()); + dataSource.setPassword(dataSourceInfo.getPassword()); + StringBuilder urlBuilder = new StringBuilder(256); + String hostAndPort = dataSourceInfo.getDatabaseHost() + ":" + dataSourceInfo.getPort(); + if (properties.isMySql()) { + urlBuilder.append("jdbc:mysql://") + .append(hostAndPort) + .append("/") + .append(dataSourceInfo.getDatabaseName()) + .append("?characterEncoding=utf8&useSSL=true&serverTimezone=Asia/Shanghai"); + } else if (properties.isOracle()) { + urlBuilder.append("jdbc:oracle:thin:@") + .append(hostAndPort) + .append(":") + .append(dataSourceInfo.getDatabaseName()); + } else if (properties.isPostgresql()) { + urlBuilder.append("jdbc:postgresql://") + .append(hostAndPort) + .append("/") + .append(dataSourceInfo.getDatabaseName()); + if (StrUtil.isBlank(dataSourceInfo.getSchemaName())) { + urlBuilder.append("?currentSchema=public"); + } else { + urlBuilder.append("?currentSchema=").append(dataSourceInfo.getSchemaName()); + } + urlBuilder.append("&TimeZone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8"); + } else if (properties.isDm()) { + urlBuilder.append("jdbc:dm://") + .append(hostAndPort) + .append("?schema=") + .append(dataSourceInfo.getDatabaseName()) + .append("&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=true&characterEncoding=UTF-8"); + } else if (properties.isKingbase()) { + urlBuilder.append("jdbc:kingbase8://") + .append(hostAndPort) + .append("/") + .append(dataSourceInfo.getDatabaseName()) + .append("?useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=true&characterEncoding=UTF-8"); + } else if (properties.isOpenGauss()) { + urlBuilder.append("jdbc:opengauss://") + .append(hostAndPort) + .append("/") + .append(dataSourceInfo.getDatabaseName()); + if (StrUtil.isBlank(dataSourceInfo.getSchemaName())) { + urlBuilder.append("?currentSchema=public"); + } else { + urlBuilder.append("?currentSchema=").append(dataSourceInfo.getSchemaName()); + } + } + dataSource.setUrl(urlBuilder.toString()); + return dataSource; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/EncryptConfig.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/EncryptConfig.java new file mode 100644 index 00000000..830199b7 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/EncryptConfig.java @@ -0,0 +1,20 @@ +package com.orangeforms.common.core.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; + +/** + * 目前用于用户密码加密,UAA接入应用客户端的client_secret加密。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Configuration +public class EncryptConfig { + + @Bean + public BCryptPasswordEncoder passwordEncoder() { + return new BCryptPasswordEncoder(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/MybatisPlusKeyGeneratorConfig.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/MybatisPlusKeyGeneratorConfig.java new file mode 100644 index 00000000..5aee904d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/MybatisPlusKeyGeneratorConfig.java @@ -0,0 +1,21 @@ +package com.orangeforms.common.core.config; + +import com.baomidou.mybatisplus.core.incrementer.IKeyGenerator; +import com.baomidou.mybatisplus.extension.incrementer.OracleKeyGenerator; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * 仅仅用于Oracle,基于Sequence计算自增字段值的生成器。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Configuration +public class MybatisPlusKeyGeneratorConfig { + + @Bean + public IKeyGenerator keyGenerator() { + return new OracleKeyGenerator(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/RestTemplateConfig.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/RestTemplateConfig.java new file mode 100644 index 00000000..d8deb0ad --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/RestTemplateConfig.java @@ -0,0 +1,71 @@ +package com.orangeforms.common.core.config; + +import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; +import org.apache.hc.client5.http.classic.HttpClient; +import org.apache.hc.client5.http.config.RequestConfig; +import org.apache.hc.client5.http.impl.classic.HttpClientBuilder; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.client.ClientHttpRequestFactory; +import org.springframework.http.client.ClientHttpResponse; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.StringHttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.client.DefaultResponseErrorHandler; +import org.springframework.web.client.RestOperations; +import org.springframework.web.client.RestTemplate; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * RestTemplate连接池配置对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Configuration +public class RestTemplateConfig { + private static final int MAX_TOTAL_CONNECTION = 50; + private static final int MAX_CONNECTION_PER_ROUTE = 20; + private static final int CONNECTION_TIMEOUT = 20000; + private static final int READ_TIMEOUT = 30000; + + @Bean + @ConditionalOnMissingBean({RestOperations.class, RestTemplate.class}) + public RestTemplate restTemplate() { + RestTemplate restTemplate = new RestTemplate(createFactory()); + List> messageConverters = restTemplate.getMessageConverters(); + messageConverters.removeIf( + c -> c instanceof StringHttpMessageConverter || c instanceof MappingJackson2HttpMessageConverter); + messageConverters.add(1, new StringHttpMessageConverter(StandardCharsets.UTF_8)); + messageConverters.add(new FastJsonHttpMessageConverter()); + restTemplate.setErrorHandler(new DefaultResponseErrorHandler() { + @Override + public void handleError(ClientHttpResponse response) throws IOException { + // 防止400+和500等错误被直接抛出异常,这里避开了缺省处理方式,所有的错误均交给业务代码处理。 + } + }); + return restTemplate; + } + + private ClientHttpRequestFactory createFactory() { + PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(); + connectionManager.setMaxTotal(MAX_TOTAL_CONNECTION); + connectionManager.setDefaultMaxPerRoute(MAX_CONNECTION_PER_ROUTE); + RequestConfig requestConfig = RequestConfig.custom() + .setConnectionRequestTimeout(CONNECTION_TIMEOUT, TimeUnit.MICROSECONDS) + .setResponseTimeout(READ_TIMEOUT, TimeUnit.MICROSECONDS) + .build(); + HttpClient httpClient = HttpClientBuilder.create() + .setDefaultRequestConfig(requestConfig) + .setConnectionManager(connectionManager) + .build(); + return new HttpComponentsClientHttpRequestFactory(httpClient); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/TomcatConfig.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/TomcatConfig.java new file mode 100644 index 00000000..90ed08fd --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/config/TomcatConfig.java @@ -0,0 +1,39 @@ +package com.orangeforms.common.core.config; + +import org.apache.tomcat.util.descriptor.web.SecurityCollection; +import org.apache.tomcat.util.descriptor.web.SecurityConstraint; +import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * tomcat配置对象。当前配置禁用了PUT和DELETE方法,防止渗透攻击。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Configuration +public class TomcatConfig { + + @Bean + public TomcatServletWebServerFactory servletContainer() { + TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); + factory.addContextCustomizers(context -> { + SecurityConstraint securityConstraint = new SecurityConstraint(); + securityConstraint.setUserConstraint("CONFIDENTIAL"); + SecurityCollection collection = new SecurityCollection(); + collection.addPattern("/*"); + collection.addMethod("HEAD"); + collection.addMethod("PUT"); + collection.addMethod("PATCH"); + collection.addMethod("DELETE"); + collection.addMethod("TRACE"); + collection.addMethod("COPY"); + collection.addMethod("SEARCH"); + collection.addMethod("PROPFIND"); + securityConstraint.addCollection(collection); + context.addConstraint(securityConstraint); + }); + return factory; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/AggregationType.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/AggregationType.java new file mode 100644 index 00000000..d0368de0 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/AggregationType.java @@ -0,0 +1,81 @@ +package com.orangeforms.common.core.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 聚合计算的常量类型对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class AggregationType { + + /** + * sum 计数 + */ + public static final int SUM = 0; + /** + * count 汇总 + */ + public static final int COUNT = 1; + /** + * average 平均值 + */ + public static final int AVG = 2; + /** + * min 最小值 + */ + public static final int MIN = 3; + /** + * max 最大值 + */ + public static final int MAX = 4; + + private static final Map DICT_MAP = new HashMap<>(5); + static { + DICT_MAP.put(SUM, "累计总和"); + DICT_MAP.put(COUNT, "数量总和"); + DICT_MAP.put(AVG, "平均值"); + DICT_MAP.put(MIN, "最小值"); + DICT_MAP.put(MAX, "最大值"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 获取与SQL对应的聚合函数字符串名称。 + * + * @return 聚合函数名称。 + */ + public static String getAggregationFunction(Integer aggregationType) { + switch (aggregationType) { + case COUNT: + return "COUNT"; + case AVG: + return "AVG"; + case SUM: + return "SUM"; + case MAX: + return "MAX"; + case MIN: + return "MIN"; + default: + throw new IllegalArgumentException("无效的聚合类型!"); + } + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private AggregationType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/AppDeviceType.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/AppDeviceType.java new file mode 100644 index 00000000..edad8271 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/AppDeviceType.java @@ -0,0 +1,69 @@ +package com.orangeforms.common.core.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * App 登录的设备类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class AppDeviceType { + + /** + * 移动端 (如果不考虑区分android或ios的,可以使用该值) + */ + public static final int MOBILE = 0; + /** + * android + */ + public static final int ANDROID = 1; + /** + * iOS + */ + public static final int IOS = 2; + /** + * 微信公众号和小程序 + */ + public static final int WEIXIN = 3; + /** + * PC WEB + */ + public static final int WEB = 4; + + private static final Map DICT_MAP = new HashMap<>(5); + static { + DICT_MAP.put(MOBILE, "Mobile"); + DICT_MAP.put(ANDROID, "Android"); + DICT_MAP.put(IOS, "iOS"); + DICT_MAP.put(WEIXIN, "Wechat"); + DICT_MAP.put(WEB, "WEB"); + } + + /** + * 根据设备类型返回设备名称。 + * + * @param deviceType 设备类型。 + * @return 设备名称。 + */ + public static String getDeviceTypeName(int deviceType) { + return DICT_MAP.get(deviceType); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private AppDeviceType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/ApplicationConstant.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/ApplicationConstant.java new file mode 100644 index 00000000..25fce820 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/ApplicationConstant.java @@ -0,0 +1,161 @@ +package com.orangeforms.common.core.constant; + +import java.util.regex.Pattern; + +/** + * 应用程序的常量声明对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class ApplicationConstant { + + /** + * 适用于所有类型的字典格式数据。该常量为字典的键字段。 + */ + public static final String DICT_ID = "id"; + /** + * 适用于所有类型的字典格式数据。该常量为字典的名称字段。 + */ + public static final String DICT_NAME = "name"; + /** + * 适用于所有类型的字典格式数据。该常量为字典的键父字段。 + */ + public static final String PARENT_ID = "parentId"; + /** + * 数据同步使用的缺省消息队列主题名称。 + */ + public static final String DEFAULT_DATA_SYNC_TOPIC = "OrangeFormsOpen"; + /** + * 全量数据同步中,新增数据对象的键名称。 + */ + public static final String DEFAULT_FULL_SYNC_DATA_KEY = "data"; + /** + * 全量数据同步中,原有数据对象的键名称。 + */ + public static final String DEFAULT_FULL_SYNC_OLD_DATA_KEY = "oldData"; + /** + * 全量数据同步中,数据对象主键的键名称。 + */ + public static final String DEFAULT_FULL_SYNC_ID_KEY = "id"; + /** + * 为字典表数据缓存时,缓存名称的固定后缀。 + */ + public static final String DICT_CACHE_NAME_SUFFIX = "-DICT"; + /** + * 为树形字典表数据缓存时,缓存名称的固定后缀。 + */ + public static final String TREE_DICT_CACHE_NAME_SUFFIX = "-TREE-DICT"; + /** + * 图片文件上传的父目录。 + */ + public static final String UPLOAD_IMAGE_PARENT_PATH = "image"; + /** + * 附件文件上传的父目录。 + */ + public static final String UPLOAD_ATTACHMENT_PARENT_PATH = "attachment"; + /** + * CSV文件扩展名。 + */ + public static final String CSV_EXT = "csv"; + /** + * XLSX文件扩展名。 + */ + public static final String XLSX_EXT = "xlsx"; + /** + * 统计分类计算时,按天聚合计算的常量值。(前端在MyOrderParam和MyGroupParam中传给后台) + */ + public static final String DAY_AGGREGATION = "day"; + /** + * 统计分类计算时,按月聚合计算的常量值。(前端在MyOrderParam和MyGroupParam中传给后台) + */ + public static final String MONTH_AGGREGATION = "month"; + /** + * 统计分类计算时,按年聚合计算的常量值。(前端在MyOrderParam和MyGroupParam中传给后台) + */ + public static final String YEAR_AGGREGATION = "year"; + /** + * 请求头跟踪id名。 + */ + public static final String HTTP_HEADER_TRACE_ID = "traceId"; + /** + * 请求头菜单Id。 + */ + public static final String HTTP_HEADER_MENU_ID = "MenuId"; + /** + * 数据权限中,标记所有菜单的Id值。 + */ + public static final String DATA_PERM_ALL_MENU_ID = "AllMenuId"; + /** + * 请求头中记录的原始请求URL。 + */ + public static final String HTTP_HEADER_ORIGINAL_REQUEST_URL = "MY_ORIGINAL_REQUEST_URL"; + /** + * 免登录验证接口的请求头key。 + */ + public static final String HTTP_HEADER_DONT_AUTH = "DONT_AUTH"; + /** + * 系统服务内部调用时,可使用该HEAD,以便和外部调用加以区分,便于监控和流量分析。 + */ + public static final String HTTP_HEADER_INTERNAL_TOKEN = "INTERNAL_AUTH_TOKEN"; + /** + * 操作日志的数据源类型。 + */ + public static final int OPERATION_LOG_DATASOURCE_TYPE = 1000; + /** + * 在线表单的数据源类型。 + */ + public static final int COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE = 1010; + /** + * 报表模块的数据源类型。 + */ + public static final int COMMON_REPORT_DATASOURCE_TYPE = 1020; + /** + * 全局编码字典的数据源类型。 + */ + public static final int COMMON_GLOBAL_DICT_TYPE = 1050; + /** + * 租户管理所对应的数据源常量值。 + */ + public static final int TENANT_ADMIN_DATASOURCE_TYPE = 1100; + /** + * 租户业务默认数据库(系统搭建时的第一个租户数据库)所对应的数据源常量值。 + */ + public static final int TENANT_BUSINESS_DATASOURCE_TYPE = 1120; + /** + * 租户通用数据所对应的数据源常量值,如全局编码字典、在线表单、流程和报表等内置表数据。 + */ + public static final int TENANT_COMMON_DATASOURCE_TYPE = 1130; + /** + * 租户动态数据源主题(Redis)。 + */ + public static final String TENANT_DYNAMIC_DATASOURCE_TOPIC = "TenantDynamicDatasoruce"; + /** + * 租户基础数据同步(RocketMQ),如upms、全局编码字典、在线表单、流程、报表等。 + */ + public static final String TENANT_DATASYNC_TOPIC = "TenantSync"; + /** + * 租户管理的应用名。 + */ + public static final String TENANT_ADMIN_APP_NAME = "tenant-admin"; + /** + * 重要说明:该值为项目生成后的缺省密钥,仅为使用户可以快速上手并跑通流程。 + * 在实际的应用中,一定要为不同的项目或服务,自行生成公钥和私钥,并将 PRIVATE_KEY 的引用改为服务的配置项。 + * 密钥的生成方式,可通过执行common.core.util.RsaUtil类的main函数动态生成。 + */ + public static final String PRIVATE_KEY = + "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKkLhAydtOtA4WuIkkIIUVaGWu4ElOEAQF9GTulHHWOwCHI1UvcKolvS1G+mdsKcmGtEAQ92AUde/kDRGu8Wn7kLDtCgUfo72soHz7Qfv5pVB4ohMxQd/9cxeKjKbDoirhB9Z3xGF20zUozp4ZPLxpTtI7azr0xzUtd5+D/HfLDrAgMBAAECgYEApESZhDz4YyeAJiPnpJ06lS8oS2VOWzsIUs0av5uoloeoHXtt7Lx7u2kroHeNrl3Hy2yg7ypH4dgQkGHin3VHrVAgjG3TxhgBXIqqntzzk2AGJKBeIIkRX86uTvtKZyp3flUgcwcGmpepAHS1V1DPY3aVYvbcqAmoL6DX6VYN0NECQQDQUitMdC76lEtAr5/ywS0nrZJDo6U7eQ7ywx/eiJ+YmrSye8oorlAj1VBWG+Cl6jdHOHtTQyYv/tu71fjzQiJTAkEAz7wb47/vcSUpNWQxItFpXz0o6rbJh71xmShn1AKP7XptOVZGlW9QRYEzHabV9m/DHqI00cMGhHrWZAhCiTkUCQJAFsJjaJ7o4weAkTieyO7B+CvGZw1h5/V55Jvcx3s1tH5yb22G0Jr6tm9/r2isSnQkReutzZLwgR3e886UvD7lcQJAAUcD2OOuQkDbPwPNtYwaHMbQgJj9JkOI9kskUE5vuiMdltOr/XFAyhygRtdmy2wmhAK1VnDfkmL6/IR8fEGImQJABOB0KCalb0M8CPnqqHzozrD8gPObnIIr4aVvLIPATN2g7MM2N6F7JbI4RZFiKa92LV6bhQCY8OvHi5K2cgFpbw=="; + /** + * SQL注入检测的正则对象。 + */ + @SuppressWarnings("all") + public static final Pattern SQL_INJECT_PATTERN = + Pattern.compile("(.*\\=.*\\-\\-.*)|(.*(\\+).*)|(.*\\w+(%|\\$|#|&)\\w+.*)|(.*\\|\\|.*)|(.*\\s+(and|or)\\s+.*)" + + "|(.*\\b(select|update|union|and|or|delete|insert|trancate|char|substr|ascii|declare|exec|count|master|into|drop|execute|sleep|extractvalue|updatexml|substring|database|concat|rand)\\b.*)"); + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private ApplicationConstant() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/DataPermRuleType.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/DataPermRuleType.java new file mode 100644 index 00000000..772d0597 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/DataPermRuleType.java @@ -0,0 +1,81 @@ +package com.orangeforms.common.core.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 数据权限规则类型常量类。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class DataPermRuleType { + + /** + * 查看全部。 + */ + public static final int TYPE_ALL = 0; + + /** + * 仅查看当前用户。 + */ + public static final int TYPE_USER_ONLY = 1; + + /** + * 仅查看当前部门。 + */ + public static final int TYPE_DEPT_ONLY = 2; + + /** + * 所在部门及子部门。 + */ + public static final int TYPE_DEPT_AND_CHILD_DEPT = 3; + + /** + * 多部门及子部门。 + */ + public static final int TYPE_MULTI_DEPT_AND_CHILD_DEPT = 4; + + /** + * 自定义部门列表。 + */ + public static final int TYPE_CUSTOM_DEPT_LIST = 5; + + /** + * 本部门所有用户。 + */ + public static final int TYPE_DEPT_USERS = 6; + + /** + * 本部门及子部门所有用户。 + */ + public static final int TYPE_DEPT_AND_CHILD_DEPT_USERS = 7; + + private static final Map DICT_MAP = new HashMap<>(6); + static { + DICT_MAP.put(TYPE_ALL, "查看全部"); + DICT_MAP.put(TYPE_USER_ONLY, "仅查看当前用户"); + DICT_MAP.put(TYPE_DEPT_ONLY, "仅查看所在部门"); + DICT_MAP.put(TYPE_DEPT_AND_CHILD_DEPT, "所在部门及子部门"); + DICT_MAP.put(TYPE_MULTI_DEPT_AND_CHILD_DEPT, "多部门及子部门"); + DICT_MAP.put(TYPE_CUSTOM_DEPT_LIST, "自定义部门列表"); + DICT_MAP.put(TYPE_DEPT_USERS, "本部门所有用户"); + DICT_MAP.put(TYPE_DEPT_AND_CHILD_DEPT_USERS, "本部门及子部门所有用户"); + } + + /** + * 判断参数是否为当前常量字典的合法取值范围。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private DataPermRuleType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/DictType.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/DictType.java new file mode 100644 index 00000000..5d294431 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/DictType.java @@ -0,0 +1,59 @@ +package com.orangeforms.common.core.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 字典类型常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class DictType { + + /** + * 数据表字典。 + */ + public static final int TABLE = 1; + /** + * URL字典。 + */ + public static final int URL = 5; + /** + * 常量字典。 + */ + public static final int CONST = 10; + /** + * 自定义字典。 + */ + public static final int CUSTOM = 15; + /** + * 全局编码字典。 + */ + public static final int GLOBAL_DICT = 20; + + private static final Map DICT_MAP = new HashMap<>(2); + static { + DICT_MAP.put(TABLE, "数据表字典"); + DICT_MAP.put(URL, "URL字典"); + DICT_MAP.put(CONST, "静态字典"); + DICT_MAP.put(CUSTOM, "自定义字典"); + DICT_MAP.put(GLOBAL_DICT, "全局编码字典"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private DictType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/ErrorCodeEnum.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/ErrorCodeEnum.java new file mode 100644 index 00000000..423ba928 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/ErrorCodeEnum.java @@ -0,0 +1,88 @@ +package com.orangeforms.common.core.constant; + +/** + * 返回应答中的错误代码和错误信息。 + * + * @author Jerry + * @date 2024-07-02 + */ +public enum ErrorCodeEnum { + + /** + * 没有错误 + */ + NO_ERROR("没有错误"), + /** + * 未处理的异常! + */ + UNHANDLED_EXCEPTION("未处理的异常!"), + + ARGUMENT_NULL_EXIST("数据验证失败,接口调用参数存在空值,请核对!"), + ARGUMENT_PK_ID_NULL("数据验证失败,接口调用主键Id参数为空,请核对!"), + INVALID_ARGUMENT_FORMAT("数据验证失败,不合法的参数格式,请核对!"), + INVALID_STATUS_ARGUMENT("数据验证失败,无效的状态参数值,请核对!"), + UPLOAD_FAILED("数据验证失败,数据上传失败!"), + INVALID_UPLOAD_FIELD("数据验证失败,该字段不支持数据上传!"), + INVALID_UPLOAD_STORE_TYPE("数据验证失败,并不支持上传存储类型!"), + INVALID_UPLOAD_FILE_ARGUMENT("数据验证失败,上传文件参数错误,请核对!"), + INVALID_UPLOAD_FILE_FORMAT("无效的上传文件格式!"), + INVALID_UPLOAD_FILE_IOERROR("上传文件写入失败,请联系管理员!"), + UNAUTHORIZED_LOGIN("当前用户尚未登录或登录已超时,请重新登录!"), + UNAUTHORIZED_USER_PERMISSION("权限验证失败,当前用户不能访问该接口,请核对!"), + NO_ACCESS_PERMISSION("当前用户没有访问权限,请核对!"), + NO_OPERATION_PERMISSION("当前用户没有操作权限,请核对!"), + + PASSWORD_ERR("密码错误,请重试!"), + INVALID_USERNAME_PASSWORD("用户名或密码错误,请重试!"), + INVALID_ACCESS_TOKEN("无效的用户访问令牌!"), + INVALID_USER_STATUS("用户状态错误,请刷新后重试!"), + INVALID_TENANT_CODE("指定的租户编码并不存在,请刷新后重试!"), + INVALID_TENANT_STATUS("当前租户为不可用状态,请刷新后重试!"), + INVALID_USER_TENANT("当前用户并不属于当前租户,请刷新后重试!"), + + HAS_CHILDREN_DATA("数据验证失败,子数据存在,请刷新后重试!"), + DATA_VALIDATED_FAILED("数据验证失败,请核对!"), + UPLOAD_FILE_FAILED("文件上传失败,请联系管理员!"), + DATA_SAVE_FAILED("数据保存失败,请联系管理员!"), + DATA_ACCESS_FAILED("数据访问失败,请联系管理员!"), + DATA_PERM_ACCESS_FAILED("数据访问失败,您没有该页面的数据访问权限!"), + DUPLICATED_UNIQUE_KEY("数据保存失败,存在重复数据,请核对!"), + DATA_NOT_EXIST("数据不存在,请刷新后重试!"), + DATA_PARENT_LEVEL_ID_NOT_EXIST("数据验证失败,父级别关联Id不存在,请刷新后重试!"), + DATA_PARENT_ID_NOT_EXIST("数据验证失败,ParentId不存在,请核对!"), + INVALID_RELATED_RECORD_ID("数据验证失败,关联数据并不存在,请刷新后重试!"), + INVALID_DATA_MODEL("数据验证失败,无效的数据实体对象!"), + INVALID_DATA_FIELD("数据验证失败,无效的数据实体对象字段!"), + INVALID_CLASS_FIELD("数据验证失败,无效的类对象字段!"), + SERVER_INTERNAL_ERROR("服务器内部错误,请联系管理员!"), + REDIS_CACHE_ACCESS_TIMEOUT("Redis缓存数据访问超时,请刷新后重试!"), + REDIS_CACHE_ACCESS_STATE_ERROR("Redis缓存数据访问状态错误,请刷新后重试!"), + FAILED_TO_INVOKE_THIRDPARTY_URL("调用第三方接口失败!"), + + FLOW_WORK_ORDER_EXIST("该业务数据Id存在尚未完成审批的流程实例,同一业务数据主键不能同时重复提交审批!"); + + // 下面的枚举值为特定枚举值,即开发者可以根据自己的项目需求定义更多的非通用枚举值 + + /** + * 构造函数。 + * + * @param errorMessage 错误消息。 + */ + ErrorCodeEnum(String errorMessage) { + this.errorMessage = errorMessage; + } + + /** + * 错误信息。 + */ + private final String errorMessage; + + /** + * 获取错误信息。 + * + * @return 错误信息。 + */ + public String getErrorMessage() { + return errorMessage; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/FieldFilterType.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/FieldFilterType.java new file mode 100644 index 00000000..db0e1752 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/FieldFilterType.java @@ -0,0 +1,127 @@ +package com.orangeforms.common.core.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 字段过滤类型常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FieldFilterType { + /** + * 等于过滤。 + */ + public static final int EQUAL = 0; + /** + * 不等于过滤。 + */ + public static final int NOT_EQUAL = 1; + /** + * 大于等于。 + */ + public static final int GE = 2; + /** + * 大于。 + */ + public static final int GT = 3; + /** + * 小于等于。 + */ + public static final int LE = 4; + /** + * 小于。 + */ + public static final int LT = 5; + /** + * 模糊查询。 + */ + public static final int LIKE = 6; + /** + * IN列表过滤。 + */ + public static final int IN = 7; + /** + * NOT IN列表过滤。 + */ + public static final int NOT_IN = 8; + /** + * 范围过滤。 + */ + public static final int BETWEEN = 9; + /** + * 不为空。 + */ + public static final int IS_NOT_NULL = 100; + /** + * 为空。 + */ + public static final int IS_NULL = 101; + + private static final Map DICT_MAP = new HashMap<>(9); + static { + DICT_MAP.put(EQUAL, " = "); + DICT_MAP.put(NOT_EQUAL, " <> "); + DICT_MAP.put(GE, " >= "); + DICT_MAP.put(GT, " > "); + DICT_MAP.put(LE, " <= "); + DICT_MAP.put(LT, " < "); + DICT_MAP.put(LIKE, " LIKE "); + DICT_MAP.put(IN, " IN "); + DICT_MAP.put(NOT_IN, " NOT IN "); + DICT_MAP.put(BETWEEN, " BETWEEN "); + DICT_MAP.put(IS_NOT_NULL, " IS NOT NULL "); + DICT_MAP.put(IS_NULL, " IS NULL "); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 获取显示名。 + * @param value 常量值。 + * @return 常量值对应的显示名。 + */ + public static String getName(Integer value) { + return DICT_MAP.get(value); + } + + /** + * 不支持日期型字段的过滤类型。 + * + * @param filterType 过滤类型。 + * @return 不支持返回true,否则false。 + */ + public static boolean unsupportDateFilterType(int filterType) { + return filterType == FieldFilterType.IN + || filterType == FieldFilterType.NOT_IN + || filterType == FieldFilterType.NOT_EQUAL + || filterType == FieldFilterType.LIKE; + } + + /** + * 支持多过滤值的过滤类型。 + * + * @param filterType 过滤类型。 + * @return 支持返回true,否则false。 + */ + public static boolean supportMultiValueFilterType(int filterType) { + return filterType == FieldFilterType.IN + || filterType == FieldFilterType.NOT_IN + || filterType == FieldFilterType.BETWEEN; + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FieldFilterType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/FilterParamType.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/FilterParamType.java new file mode 100644 index 00000000..dda91b2e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/FilterParamType.java @@ -0,0 +1,54 @@ +package com.orangeforms.common.core.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 字段过滤参数类型常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FilterParamType { + + /** + * 整数数值型。 + */ + public static final int LONG = 0; + /** + * 浮点型。 + */ + public static final int FLOAT = 1; + /** + * 字符型。 + */ + public static final int STRING = 2; + /** + * 日期型。 + */ + public static final int DATE = 3; + + private static final Map DICT_MAP = new HashMap<>(9); + static { + DICT_MAP.put(LONG, "整数数值型"); + DICT_MAP.put(FLOAT, "浮点型"); + DICT_MAP.put(STRING, "字符型"); + DICT_MAP.put(DATE, "日期型"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FilterParamType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/GlobalDeletedFlag.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/GlobalDeletedFlag.java new file mode 100644 index 00000000..a7ed6ba3 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/GlobalDeletedFlag.java @@ -0,0 +1,25 @@ +package com.orangeforms.common.core.constant; + +/** + * 数据记录逻辑删除标记常量。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class GlobalDeletedFlag { + + /** + * 表示数据表记录已经删除 + */ + public static final int DELETED = -1; + /** + * 数据记录正常 + */ + public static final int NORMAL = 1; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private GlobalDeletedFlag() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/MaskFieldTypeEnum.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/MaskFieldTypeEnum.java new file mode 100644 index 00000000..d242e26c --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/MaskFieldTypeEnum.java @@ -0,0 +1,47 @@ +package com.orangeforms.common.core.constant; + +/** + * 字段脱敏类型枚举。。 + * + * @author Jerry + * @date 2024-07-02 + */ +public enum MaskFieldTypeEnum { + + /** + * 自定义实现。 + */ + CUSTOM, + /** + * 姓名。 + */ + NAME, + /** + * 移动电话。 + */ + MOBILE_PHONE, + /** + * 座机电话。 + */ + FIXED_PHONE, + /** + * 身份证。 + */ + ID_CARD, + /** + * 银行卡号。 + */ + BANK_CARD, + /** + * 汽车牌照号。 + */ + CAR_LICENSE, + /** + * 邮件。 + */ + EMAIL, + /** + * 固定长度的前缀和后缀不被掩码。 + */ + NO_MASK_PREFIX_SUFFIX, +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/ObjectFieldType.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/ObjectFieldType.java new file mode 100644 index 00000000..660b606c --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/ObjectFieldType.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.core.constant; + +/** + * 对应于数据表字段中的类型,我们需要统一映射到Java实体对象字段的类型。 + * 该类是描述Java实体对象字段类型的常量类。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class ObjectFieldType { + + public static final String LONG = "Long"; + public static final String INTEGER = "Integer"; + public static final String DOUBLE = "Double"; + public static final String BIG_DECIMAL = "BigDecimal"; + public static final String BOOLEAN = "Boolean"; + public static final String STRING = "String"; + public static final String DATE = "Date"; + public static final String BYTE_ARRAY = "byte[]"; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private ObjectFieldType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/UserFilterGroup.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/UserFilterGroup.java new file mode 100644 index 00000000..d966cf6d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/constant/UserFilterGroup.java @@ -0,0 +1,22 @@ +package com.orangeforms.common.core.constant; + +/** + * 用户分组过滤常量。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class UserFilterGroup { + + public static final String USER = "USER_GROUP"; + public static final String ROLE = "ROLE_GROUP"; + public static final String DEPT = "DEPT_GROUP"; + public static final String POST = "POST_GROUP"; + public static final String DEPT_POST = "DEPT_POST_GROUP"; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private UserFilterGroup() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/DataValidationException.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/DataValidationException.java new file mode 100644 index 00000000..66053ad5 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/DataValidationException.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.core.exception; + +/** + * 数据验证失败的自定义异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class DataValidationException extends RuntimeException { + + /** + * 构造函数。 + */ + public DataValidationException() { + + } + + /** + * 构造函数。 + * + * @param msg 错误信息。 + */ + public DataValidationException(String msg) { + super(msg); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidClassFieldException.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidClassFieldException.java new file mode 100644 index 00000000..762eac91 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidClassFieldException.java @@ -0,0 +1,30 @@ +package com.orangeforms.common.core.exception; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 无效的类对象字段的自定义异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class InvalidClassFieldException extends RuntimeException { + + private final String className; + private final String fieldName; + + /** + * 构造函数。 + * + * @param className 对象名。 + * @param fieldName 字段名。 + */ + public InvalidClassFieldException(String className, String fieldName) { + super("Invalid FieldName [" + fieldName + "] in Class [" + className + "]."); + this.className = className; + this.fieldName = fieldName; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidDataFieldException.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidDataFieldException.java new file mode 100644 index 00000000..2c5d249e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidDataFieldException.java @@ -0,0 +1,30 @@ +package com.orangeforms.common.core.exception; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 无效的实体对象字段的自定义异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class InvalidDataFieldException extends RuntimeException { + + private final String modelName; + private final String fieldName; + + /** + * 构造函数。 + * + * @param modelName 实体对象名。 + * @param fieldName 字段名。 + */ + public InvalidDataFieldException(String modelName, String fieldName) { + super("Invalid FieldName [" + fieldName + "] in Model Class [" + modelName + "]."); + this.modelName = modelName; + this.fieldName = fieldName; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidDataModelException.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidDataModelException.java new file mode 100644 index 00000000..b17abb8e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidDataModelException.java @@ -0,0 +1,27 @@ +package com.orangeforms.common.core.exception; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 无效的实体对象的自定义异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class InvalidDataModelException extends RuntimeException { + + private final String modelName; + + /** + * 构造函数。 + * + * @param modelName 实体对象名。 + */ + public InvalidDataModelException(String modelName) { + super("Invalid Model Class [" + modelName + "]."); + this.modelName = modelName; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidDblinkTypeException.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidDblinkTypeException.java new file mode 100644 index 00000000..b7589219 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidDblinkTypeException.java @@ -0,0 +1,24 @@ +package com.orangeforms.common.core.exception; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 无效的数据库链接类型自定义异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class InvalidDblinkTypeException extends RuntimeException { + + /** + * 构造函数。 + * + * @param dblinkType 数据库链接类型。 + */ + public InvalidDblinkTypeException(int dblinkType) { + super("Invalid Dblink Type [" + dblinkType + "]."); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidRedisModeException.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidRedisModeException.java new file mode 100644 index 00000000..9b197625 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/InvalidRedisModeException.java @@ -0,0 +1,27 @@ +package com.orangeforms.common.core.exception; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 无效的Redis模式的自定义异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class InvalidRedisModeException extends RuntimeException { + + private final String mode; + + /** + * 构造函数。 + * + * @param mode 错误的模式。 + */ + public InvalidRedisModeException(String mode) { + super("Invalid Redis Mode [" + mode + "], only supports [single/cluster/sentinel/master_slave]"); + this.mode = mode; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/MapCacheAccessException.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/MapCacheAccessException.java new file mode 100644 index 00000000..b47dd010 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/MapCacheAccessException.java @@ -0,0 +1,20 @@ +package com.orangeforms.common.core.exception; + +/** + * 内存缓存访问失败。比如:获取分布式数据锁超时、等待线程中断等。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class MapCacheAccessException extends RuntimeException { + + /** + * 构造函数。 + * + * @param msg 错误信息。 + * @param cause 原始异常。 + */ + public MapCacheAccessException(String msg, Throwable cause) { + super(msg, cause); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/MyRuntimeException.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/MyRuntimeException.java new file mode 100644 index 00000000..82d8f4ae --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/MyRuntimeException.java @@ -0,0 +1,46 @@ +package com.orangeforms.common.core.exception; + +/** + * 自定义的运行时异常,在需要抛出运行时异常时,可使用该异常。 + * NOTE:主要是为了避免SonarQube进行代码质量扫描时,给出警告。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class MyRuntimeException extends RuntimeException { + + /** + * 构造函数。 + */ + public MyRuntimeException() { + + } + + /** + * 构造函数。 + * + * @param throwable 引发异常对象。 + */ + public MyRuntimeException(Throwable throwable) { + super(throwable); + } + + /** + * 构造函数。 + * + * @param msg 错误信息。 + */ + public MyRuntimeException(String msg) { + super(msg); + } + + /** + * 构造函数。 + * + * @param msg 错误信息。 + * @param throwable 引发异常对象。 + */ + public MyRuntimeException(String msg, Throwable throwable) { + super(msg, throwable); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/NoDataAffectException.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/NoDataAffectException.java new file mode 100644 index 00000000..0d9dd3d9 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/NoDataAffectException.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.core.exception; + +/** + * 没有数据被修改的自定义异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class NoDataAffectException extends RuntimeException { + + /** + * 构造函数。 + */ + public NoDataAffectException() { + + } + + /** + * 构造函数。 + * + * @param msg 错误信息。 + */ + public NoDataAffectException(String msg) { + super(msg); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/NoDataPermException.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/NoDataPermException.java new file mode 100644 index 00000000..2e18d311 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/NoDataPermException.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.core.exception; + +/** + * 没有数据访问权限的自定义异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class NoDataPermException extends RuntimeException { + + /** + * 构造函数。 + */ + public NoDataPermException() { + + } + + /** + * 构造函数。 + * + * @param msg 错误信息。 + */ + public NoDataPermException(String msg) { + super(msg); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/RedisCacheAccessException.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/RedisCacheAccessException.java new file mode 100644 index 00000000..b0dfe017 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/exception/RedisCacheAccessException.java @@ -0,0 +1,20 @@ +package com.orangeforms.common.core.exception; + +/** + * Redis缓存访问失败。比如:获取分布式数据锁超时、等待线程中断等。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class RedisCacheAccessException extends RuntimeException { + + /** + * 构造函数。 + * + * @param msg 错误信息。 + * @param cause 原始异常。 + */ + public RedisCacheAccessException(String msg, Throwable cause) { + super(msg, cause); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/interceptor/MyRequestArgumentResolver.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/interceptor/MyRequestArgumentResolver.java new file mode 100644 index 00000000..08c198ad --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/interceptor/MyRequestArgumentResolver.java @@ -0,0 +1,227 @@ +package com.orangeforms.common.core.interceptor; + +import cn.hutool.core.convert.Convert; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.annotation.MyRequestBody; +import org.apache.commons.io.IOUtils; +import org.springframework.core.MethodParameter; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.lang.NonNull; +import org.springframework.util.Assert; +import org.springframework.web.bind.support.WebDataBinderFactory; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.method.support.ModelAndViewContainer; + +import jakarta.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.lang.reflect.ParameterizedType; +import java.math.BigDecimal; +import java.util.*; + +/** + * MyRequestBody解析器 + * 解决的问题: + * 1、单个字符串等包装类型都要写一个对象才可以用@RequestBody接收; + * 2、多个对象需要封装到一个对象里才可以用@RequestBody接收。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class MyRequestArgumentResolver implements HandlerMethodArgumentResolver { + + private static final String JSONBODY_ATTRIBUTE = "MY_REQUEST_BODY_ATTRIBUTE_XX"; + + private static final Set> CLASS_SET = new HashSet<>(); + + static { + CLASS_SET.add(Integer.class); + CLASS_SET.add(Long.class); + CLASS_SET.add(Short.class); + CLASS_SET.add(Float.class); + CLASS_SET.add(Double.class); + CLASS_SET.add(Boolean.class); + CLASS_SET.add(Byte.class); + CLASS_SET.add(BigDecimal.class); + CLASS_SET.add(Character.class); + CLASS_SET.add(Date.class); + } + + /** + * 设置支持的方法参数类型。 + * + * @param parameter 方法参数。 + * @return 支持的类型。 + */ + @Override + public boolean supportsParameter(@NonNull MethodParameter parameter) { + return parameter.hasParameterAnnotation(MyRequestBody.class); + } + + /** + * 参数解析,利用fastjson。 + * 注意:非基本类型返回null会报空指针异常,要通过反射或者JSON工具类创建一个空对象。 + */ + @Override + public Object resolveArgument( + @NonNull MethodParameter parameter, + ModelAndViewContainer mavContainer, + @NonNull NativeWebRequest webRequest, + WebDataBinderFactory binderFactory) throws Exception { + HttpServletRequest servletRequest = webRequest.getNativeRequest(HttpServletRequest.class); + Assert.notNull(servletRequest, "HttpServletRequest can't be NULL."); + String contentType = servletRequest.getContentType(); + if (!HttpMethod.POST.name().equals(servletRequest.getMethod())) { + throw new IllegalArgumentException("Only POST method can be applied @MyRequestBody annotation!"); + } + if (!StrUtil.containsIgnoreCase(contentType, MediaType.APPLICATION_JSON_VALUE)) { + throw new IllegalArgumentException( + "Only application/json Content-Type can be applied @MyRequestBody annotation!"); + } + // 根据@MyRequestBody注解value作为json解析的key + MyRequestBody parameterAnnotation = parameter.getParameterAnnotation(MyRequestBody.class); + Assert.notNull(parameterAnnotation, "parameterAnnotation can't be NULL"); + JSONObject jsonObject = getRequestBody(webRequest); + if (jsonObject == null) { + if (parameterAnnotation.required()) { + throw new IllegalArgumentException("Request Body is EMPTY!"); + } + return null; + } + String key = parameterAnnotation.value(); + if (StrUtil.isBlank(key)) { + key = parameter.getParameterName(); + } + Object value = jsonObject.get(key); + if (value == null) { + if (parameterAnnotation.required()) { + throw new IllegalArgumentException(String.format("Required parameter %s is not present!", key)); + } + return null; + } + // 获取参数类型。 + Class parameterType = parameter.getParameterType(); + // 基本类型 + if (parameterType.isPrimitive()) { + return parsePrimitive(parameterType.getName(), value); + } + // 基本类型包装类 + if (isBasicDataTypes(parameterType)) { + return parseBasicTypeWrapper(parameterType, value); + } else if (parameterType == String.class) { + // 字符串类型 + return value.toString(); + } + // 对象类型 + if (!(value instanceof JSONArray)) { + // 其他复杂对象 + return JSON.toJavaObject((JSONObject) value, parameterType); + } + if (parameter.getGenericParameterType() instanceof ParameterizedType) { + return ((JSONArray) value).toJavaObject(parameter.getGenericParameterType()); + } + // 非参数化的集合类型 + return JSON.parseObject(value.toString(), parameterType); + } + + private Object parsePrimitive(String parameterTypeName, Object value) { + final String booleanTypeName = "boolean"; + if (booleanTypeName.equals(parameterTypeName)) { + return Boolean.valueOf(value.toString()); + } + final String intTypeName = "int"; + if (intTypeName.equals(parameterTypeName)) { + return Integer.valueOf(value.toString()); + } + final String charTypeName = "char"; + if (charTypeName.equals(parameterTypeName)) { + return value.toString().charAt(0); + } + final String shortTypeName = "short"; + if (shortTypeName.equals(parameterTypeName)) { + return Short.valueOf(value.toString()); + } + final String longTypeName = "long"; + if (longTypeName.equals(parameterTypeName)) { + return Long.valueOf(value.toString()); + } + final String floatTypeName = "float"; + if (floatTypeName.equals(parameterTypeName)) { + return Float.valueOf(value.toString()); + } + final String doubleTypeName = "double"; + if (doubleTypeName.equals(parameterTypeName)) { + return Double.valueOf(value.toString()); + } + final String byteTypeName = "byte"; + if (byteTypeName.equals(parameterTypeName)) { + return Byte.valueOf(value.toString()); + } + return null; + } + + private Object parseBasicTypeWrapper(Class parameterType, Object value) { + if (Number.class.isAssignableFrom(parameterType)) { + return this.parseNumberType(parameterType, value); + } else if (parameterType == Boolean.class) { + return value; + } else if (parameterType == Character.class) { + return value.toString().charAt(0); + } else if (parameterType == Date.class) { + return Convert.toDate(value); + } + return null; + } + + private Object parseNumberType(Class parameterType, Object value) { + if (value instanceof String) { + return Convert.convert(parameterType, value); + } + Number number = (Number) value; + if (parameterType == Integer.class) { + return number.intValue(); + } else if (parameterType == Short.class) { + return number.shortValue(); + } else if (parameterType == Long.class) { + return number.longValue(); + } else if (parameterType == Float.class) { + return number.floatValue(); + } else if (parameterType == Double.class) { + return number.doubleValue(); + } else if (parameterType == Byte.class) { + return number.byteValue(); + } else if (parameterType == BigDecimal.class) { + if (value instanceof Double || value instanceof Float) { + return BigDecimal.valueOf(number.doubleValue()); + } else { + return BigDecimal.valueOf(number.longValue()); + } + } + return null; + } + + private boolean isBasicDataTypes(Class clazz) { + return CLASS_SET.contains(clazz); + } + + private JSONObject getRequestBody(NativeWebRequest webRequest) throws IOException { + HttpServletRequest servletRequest = webRequest.getNativeRequest(HttpServletRequest.class); + Assert.notNull(servletRequest, "servletRequest can't be NULL"); + // 有就直接获取 + JSONObject jsonObject = (JSONObject) webRequest.getAttribute(JSONBODY_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST); + // 没有就从请求中读取 + if (jsonObject == null) { + String jsonBody = IOUtils.toString(servletRequest.getReader()); + jsonObject = JSON.parseObject(jsonBody); + if (jsonObject != null) { + webRequest.setAttribute(JSONBODY_ATTRIBUTE, jsonObject, RequestAttributes.SCOPE_REQUEST); + } + } + return jsonObject; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/listener/LoadServiceRelationListener.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/listener/LoadServiceRelationListener.java new file mode 100644 index 00000000..d2c37fb1 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/listener/LoadServiceRelationListener.java @@ -0,0 +1,28 @@ +package com.orangeforms.common.core.listener; + +import com.orangeforms.common.core.base.service.BaseService; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; + +import java.util.Map; + +/** + * 应用程序启动后的事件监听对象。主要负责加载Model之间的字典关联和一对一关联所对应的Service结构关系。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class LoadServiceRelationListener implements ApplicationListener { + + @SuppressWarnings("all") + @Override + public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { + Map serviceMap = + applicationReadyEvent.getApplicationContext().getBeansOfType(BaseService.class); + for (Map.Entry e : serviceMap.entrySet()) { + e.getValue().loadRelationStruct(); + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/CallResult.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/CallResult.java new file mode 100644 index 00000000..70e09f76 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/CallResult.java @@ -0,0 +1,103 @@ +package com.orangeforms.common.core.object; + +import com.alibaba.fastjson.JSONObject; +import lombok.Data; + +/** + * 业务方法调用结果对象。可以同时返回具体的错误和JSON类型的数据对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class CallResult { + + /** + * 为了优化性能,所有没有携带数据的正确结果,均可用该对象表示。 + */ + private static final CallResult OK = new CallResult(); + /** + * 是否成功标记。 + */ + private boolean success = true; + /** + * 错误信息描述。 + */ + private String errorMessage = null; + /** + * 在验证同时,仍然需要附加的关联数据对象。 + */ + private JSONObject data; + + /** + * 创建验证结果对象。 + * + * @param errorMessage 错误描述信息。 + * @return 如果参数为空,表示成功,否则返回代码错误信息的错误对象实例。 + */ + public static CallResult create(String errorMessage) { + return errorMessage == null ? ok() : error(errorMessage); + } + + /** + * 创建验证结果对象。 + * + * @param errorMessage 错误描述信息。 + * @param data 附带的数据对象。 + * @return 如果参数为空,表示成功,否则返回代码错误信息的错误对象实例。 + */ + public static CallResult create(String errorMessage, JSONObject data) { + return errorMessage == null ? ok(data) : error(errorMessage); + } + + /** + * 创建表示验证成功的对象实例。 + * + * @return 验证成功对象实例。 + */ + public static CallResult ok() { + return OK; + } + + /** + * 创建表示验证成功的对象实例。 + * + * @param data 附带的数据对象。 + * @return 验证成功对象实例。 + */ + public static CallResult ok(JSONObject data) { + CallResult result = new CallResult(); + result.data = data; + return result; + } + + /** + * 创建表示验证失败的对象实例。 + * + * @param errorMessage 错误描述。 + * @return 验证失败对象实例。 + */ + public static CallResult error(String errorMessage) { + CallResult result = new CallResult(); + result.success = false; + result.errorMessage = errorMessage; + return result; + } + + /** + * 创建表示验证失败的对象实例。 + * + * @param errorMessage 错误描述。 + * @param data 附带的数据对象。 + * @return 验证失败对象实例。 + */ + public static CallResult error(String errorMessage, T data) { + CallResult result = new CallResult(); + result.success = false; + result.errorMessage = errorMessage; + JSONObject jsonObject = new JSONObject(); + jsonObject.put("errorData", data); + result.data = jsonObject; + return result; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/ColumnEncodedRule.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/ColumnEncodedRule.java new file mode 100644 index 00000000..c3422da4 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/ColumnEncodedRule.java @@ -0,0 +1,38 @@ +package com.orangeforms.common.core.object; + +import lombok.Data; + +/** + * 编码字段的编码规则。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class ColumnEncodedRule { + + /** + * 是否显示是计算并回显。 + */ + private Boolean calculateWhenView; + + /** + * 前缀。 + */ + private String prefix; + + /** + * 精确到DAYS/HOURS/MINUTES/SECONDS + */ + private String precisionTo; + + /** + * 中缀。 + */ + private String middle; + + /** + * 流水序号的字符宽度,不足的前面补0。 + */ + private Integer idWidth; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/ConstDictInfo.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/ConstDictInfo.java new file mode 100644 index 00000000..e063b9ab --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/ConstDictInfo.java @@ -0,0 +1,24 @@ +package com.orangeforms.common.core.object; + +import lombok.Data; + +import java.util.List; + +/** + * 常量字典的数据结构。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class ConstDictInfo { + + private List dictData; + + @Data + public static class ConstDictData { + private String type; + private Object id; + private String name; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/DummyClass.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/DummyClass.java new file mode 100644 index 00000000..5806fd02 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/DummyClass.java @@ -0,0 +1,27 @@ +package com.orangeforms.common.core.object; + +/** + * 哑元对象,主要用于注解中的缺省对象占位符。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class DummyClass { + + private static final Object EMPTY_OBJECT = new Object(); + + /** + * 可以忽略的空对象。避免sonarqube的各种警告。 + * + * @return 空对象。 + */ + public static Object emptyObject() { + return EMPTY_OBJECT; + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private DummyClass() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/GlobalThreadLocal.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/GlobalThreadLocal.java new file mode 100644 index 00000000..01b0d437 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/GlobalThreadLocal.java @@ -0,0 +1,52 @@ +package com.orangeforms.common.core.object; + +import cn.hutool.core.util.BooleanUtil; + +/** + * 线程本地化数据管理的工具类。可根据需求自行添加更多的线程本地化变量及其操作方法。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class GlobalThreadLocal { + + /** + * 存储数据权限过滤是否启用的线程本地化对象。 + * 目前的过滤条件,包括数据权限和租户过滤。 + */ + private static final ThreadLocal DATA_FILTER_ENABLE = ThreadLocal.withInitial(() -> Boolean.TRUE); + + /** + * 设置数据过滤是否打开。如果打开,当前Servlet线程所执行的SQL操作,均会进行数据过滤。 + * + * @param enable 打开为true,否则false。 + * @return 返回之前的状态,便于恢复。 + */ + public static boolean setDataFilter(boolean enable) { + boolean oldValue = DATA_FILTER_ENABLE.get(); + DATA_FILTER_ENABLE.set(enable); + return oldValue; + } + + /** + * 判断当前Servlet线程所执行的SQL操作,是否进行数据过滤。 + * + * @return true 进行数据权限过滤,否则false。 + */ + public static boolean enabledDataFilter() { + return BooleanUtil.isTrue(DATA_FILTER_ENABLE.get()); + } + + /** + * 清空该存储数据,主动释放线程本地化存储资源。 + */ + public static void clearDataFilter() { + DATA_FILTER_ENABLE.remove(); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private GlobalThreadLocal() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/LoginUserInfo.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/LoginUserInfo.java new file mode 100644 index 00000000..d33a5908 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/LoginUserInfo.java @@ -0,0 +1,62 @@ +package com.orangeforms.common.core.object; + +import lombok.Data; +import lombok.ToString; +import lombok.extern.slf4j.Slf4j; + +import java.util.Date; + +/** + * 在线登录用户信息。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ToString +@Slf4j +public class LoginUserInfo { + + /** + * 用户Id。 + */ + private Long userId; + /** + * 用户所在部门Id。 + * 仅当系统支持uaa时可用,否则可以直接忽略该字段。保留该字段是为了保持单体和微服务通用代码部分的兼容性。 + */ + private Long deptId; + /** + * 租户Id。 + * 仅当系统支持uaa时可用,否则可以直接忽略该字段。保留该字段是为了保持单体和微服务通用代码部分的兼容性。 + */ + private Long tenantId; + /** + * 是否为超级管理员。 + */ + private Boolean isAdmin; + /** + * 用户登录名。 + */ + private String loginName; + /** + * 用户显示名称。 + */ + private String showName; + /** + * 标识不同登录的会话Id。 + */ + private String sessionId; + /** + * 登录IP。 + */ + private String loginIp; + /** + * 登录时间。 + */ + private Date loginTime; + /** + * 登录设备类型。 + */ + private String deviceType; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyGroupCriteria.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyGroupCriteria.java new file mode 100644 index 00000000..02131aa6 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyGroupCriteria.java @@ -0,0 +1,24 @@ +package com.orangeforms.common.core.object; + +import lombok.AllArgsConstructor; +import lombok.Data; + +/** + * Mybatis Mapper.xml中所需的分组条件对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@AllArgsConstructor +public class MyGroupCriteria { + + /** + * GROUP BY 从句后面的参数。 + */ + private String groupBy; + /** + * SELECT 从句后面的分组显示字段。 + */ + private String groupSelect; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyGroupParam.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyGroupParam.java new file mode 100644 index 00000000..81fc69b5 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyGroupParam.java @@ -0,0 +1,231 @@ +package com.orangeforms.common.core.object; + +import cn.hutool.core.util.ReflectUtil; +import cn.hutool.core.util.StrUtil; +import com.orangeforms.common.core.config.CoreProperties; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.exception.InvalidClassFieldException; +import com.orangeforms.common.core.exception.InvalidDataFieldException; +import com.orangeforms.common.core.exception.InvalidDataModelException; +import com.orangeforms.common.core.util.ApplicationContextHolder; +import com.orangeforms.common.core.util.MyModelUtil; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.extern.slf4j.Slf4j; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +/** + * 查询分组参数请求对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EqualsAndHashCode(callSuper = true) +@Slf4j +@Data +public class MyGroupParam extends ArrayList { + + private final transient CoreProperties coreProperties = + ApplicationContextHolder.getBean(CoreProperties.class); + + /** + * SQL语句的SELECT LIST中,分组字段的返回字段名称列表。 + */ + private List selectGroupFieldList; + /** + * 分组参数解析后构建的SQL语句中所需的分组数据,如GROUP BY的字段列表和SELECT LIST中的分组字段显示列表。 + */ + private transient MyGroupCriteria groupCriteria; + /** + * 基于分组参数对象中的数据,构建SQL中select list和group by从句可以直接使用的分组对象。 + * + * @param groupParam 分组参数对象。 + * @param modelClazz 查询表对应的主对象的Class。 + * @return SQL中所需的GROUP对象。详见MyGroupCriteria类定义。 + */ + public static MyGroupParam buildGroupBy(MyGroupParam groupParam, Class modelClazz) { + if (groupParam == null) { + return null; + } + if (modelClazz == null) { + throw new IllegalArgumentException("modelClazz Argument can't be NULL"); + } + groupParam.selectGroupFieldList = new LinkedList<>(); + StringBuilder groupByBuilder = new StringBuilder(128); + StringBuilder groupSelectBuilder = new StringBuilder(128); + int i = 0; + for (GroupInfo groupInfo : groupParam) { + GroupBaseData groupBaseData = groupParam.parseGroupBaseData(groupInfo, modelClazz); + if (StrUtil.isBlank(groupBaseData.tableName)) { + throw new InvalidDataModelException(groupBaseData.modelName); + } + if (StrUtil.isBlank(groupBaseData.columnName)) { + throw new InvalidDataFieldException(groupBaseData.modelName, groupBaseData.fieldName); + } + groupParam.processGroupInfo(groupInfo, groupBaseData, groupByBuilder, groupSelectBuilder); + String aliasName = StrUtil.isBlank(groupInfo.aliasName) ? groupInfo.fieldName : groupInfo.aliasName; + // selectGroupFieldList中的元素,目前只是被export操作使用。会根据集合中的元素名称匹配导出表头。 + groupParam.selectGroupFieldList.add(aliasName); + if (++i < groupParam.size()) { + groupByBuilder.append(", "); + groupSelectBuilder.append(", "); + } + } + groupParam.groupCriteria = new MyGroupCriteria(groupByBuilder.toString(), groupSelectBuilder.toString()); + return groupParam; + } + + private GroupBaseData parseGroupBaseData(GroupInfo groupInfo, Class modelClazz) { + GroupBaseData baseData = new GroupBaseData(); + if (StrUtil.isBlank(groupInfo.fieldName)) { + throw new IllegalArgumentException("GroupInfo.fieldName can't be EMPTY"); + } + String[] stringArray = StrUtil.splitToArray(groupInfo.fieldName, '.'); + if (stringArray.length == 1) { + baseData.modelName = modelClazz.getSimpleName(); + baseData.fieldName = groupInfo.fieldName; + baseData.tableName = MyModelUtil.mapToTableName(modelClazz); + baseData.columnName = MyModelUtil.mapToColumnName(groupInfo.fieldName, modelClazz); + } else { + Field field = ReflectUtil.getField(modelClazz, stringArray[0]); + if (field == null) { + throw new InvalidClassFieldException(modelClazz.getSimpleName(), stringArray[0]); + } + Class fieldClazz = field.getType(); + baseData.modelName = fieldClazz.getSimpleName(); + baseData.fieldName = stringArray[1]; + baseData.tableName = MyModelUtil.mapToTableName(fieldClazz); + baseData.columnName = MyModelUtil.mapToColumnName(baseData.fieldName, fieldClazz); + } + return baseData; + } + + private void processGroupInfo( + GroupInfo groupInfo, GroupBaseData baseData, StringBuilder groupBy, StringBuilder groupSelect) { + String tableName = baseData.tableName; + String columnName = baseData.columnName; + if (StrUtil.isBlank(groupInfo.dateAggregateBy)) { + groupBy.append(tableName).append(".").append(columnName); + groupSelect.append(tableName).append(".").append(columnName); + if (StrUtil.isNotBlank(groupInfo.aliasName)) { + groupSelect.append(" ").append(groupInfo.aliasName); + } + return; + } + if (coreProperties.isMySql() || coreProperties.isDm()) { + this.processMySqlGroupInfoWithDateAggregation(groupInfo, baseData, groupBy, groupSelect); + } else if (coreProperties.isPostgresql() || coreProperties.isOpenGauss()) { + this.processPostgreSqlGroupInfoWithDateAggregation(groupInfo, baseData, groupBy, groupSelect); + } else if (coreProperties.isOracle() || coreProperties.isKingbase()) { + this.processOracleGroupInfoWithDateAggregation(groupInfo, baseData, groupBy, groupSelect); + } else { + throw new UnsupportedOperationException("Unsupport Database Type."); + } + if (StrUtil.isNotBlank(groupInfo.aliasName)) { + groupSelect.append(" ").append(groupInfo.aliasName); + } else { + groupSelect.append(" ").append(columnName); + } + } + + private void processMySqlGroupInfoWithDateAggregation( + GroupInfo groupInfo, GroupBaseData baseData, StringBuilder groupBy, StringBuilder groupSelect) { + groupBy.append("DATE_FORMAT(") + .append(baseData.tableName).append(".").append(baseData.columnName); + groupSelect.append("DATE_FORMAT(") + .append(baseData.tableName).append(".").append(baseData.columnName); + if (ApplicationConstant.DAY_AGGREGATION.equals(groupInfo.dateAggregateBy)) { + groupBy.append(", '%Y-%m-%d')"); + groupSelect.append(", '%Y-%m-%d')"); + } else if (ApplicationConstant.MONTH_AGGREGATION.equals(groupInfo.dateAggregateBy)) { + groupBy.append(", '%Y-%m-01')"); + groupSelect.append(", '%Y-%m-01')"); + } else if (ApplicationConstant.YEAR_AGGREGATION.equals(groupInfo.dateAggregateBy)) { + groupBy.append(", '%Y-01-01')"); + groupSelect.append(", '%Y-01-01')"); + } else { + throw new IllegalArgumentException("Illegal DATE_FORMAT for GROUP ID list."); + } + } + + private void processPostgreSqlGroupInfoWithDateAggregation( + GroupInfo groupInfo, GroupBaseData baseData, StringBuilder groupBy, StringBuilder groupSelect) { + String toCharFunc = "TO_CHAR("; + String dateFormat = ", 'YYYY-MM-dd')"; + groupBy.append(toCharFunc) + .append(baseData.tableName).append(".").append(baseData.columnName); + groupSelect.append(toCharFunc) + .append(baseData.tableName).append(".").append(baseData.columnName); + if (ApplicationConstant.DAY_AGGREGATION.equals(groupInfo.dateAggregateBy)) { + groupBy.append(dateFormat); + groupSelect.append(dateFormat); + } else if (ApplicationConstant.YEAR_AGGREGATION.equals(groupInfo.dateAggregateBy)) { + groupBy.append(", 'YYYY-01-01')"); + groupSelect.append(", 'YYYY-01-01')"); + } else if (ApplicationConstant.MONTH_AGGREGATION.equals(groupInfo.dateAggregateBy)) { + groupBy.append(", 'YYYY-MM-01')"); + groupSelect.append(", 'YYYY-MM-01')"); + } else { + throw new IllegalArgumentException("Illegal TO_CHAR for GROUP ID list."); + } + } + + private void processOracleGroupInfoWithDateAggregation( + GroupInfo groupInfo, GroupBaseData baseData, StringBuilder groupBy, StringBuilder groupSelect) { + String toCharFunc = "TO_CHAR("; + String dateFormat = ", 'YYYY-MM-dd')"; + groupBy.append(toCharFunc) + .append(baseData.tableName).append(".").append(baseData.columnName); + groupSelect.append(toCharFunc) + .append(baseData.tableName).append(".").append(baseData.columnName); + if (ApplicationConstant.DAY_AGGREGATION.equals(groupInfo.dateAggregateBy)) { + groupBy.append(dateFormat); + groupSelect.append(dateFormat); + } else if (ApplicationConstant.MONTH_AGGREGATION.equals(groupInfo.dateAggregateBy)) { + groupBy.append(", 'YYYY-MM') || '-01'"); + groupSelect.append(", 'YYYY-MM') || '-01'"); + } else if (ApplicationConstant.YEAR_AGGREGATION.equals(groupInfo.dateAggregateBy)) { + groupBy.append(", 'YYYY') || '-01-01'"); + groupSelect.append(", 'YYYY') || '-01-01'"); + } else { + throw new IllegalArgumentException("Illegal TO_CHAR for GROUP ID list."); + } + } + + /** + * 分组信息对象。 + */ + @Data + public static class GroupInfo { + /** + * Java对象的字段名。目前主要包含三种格式: + * 1. 简单的属性名称,如userId,将会直接映射到与其关联的数据库字段。表名为当前ModelClazz所对应的表名。 + * 映射结果或为 my_main_table.user_id + * 2. 一对一关联表属性,如user.userId,这里将先获取user属性的对象类型并映射到对应的表名,后面的userId为 + * user所在实体的属性。映射结果或为:my_sys_user.user_id + */ + private String fieldName; + /** + * SQL语句的Select List中,分组字段的别名。如果别名为NULL,直接取fieldName。 + */ + private String aliasName; + /** + * 如果该值不为NULL,则会对分组字段进行DATE_FORMAT函数的计算,并根据具体的值,将日期数据截取到指定的位。 + * day: 表示按照天聚合,将会截取到天。DATE_FORMAT(columnName, '%Y-%m-%d') + * month: 表示按照月聚合,将会截取到月。DATE_FORMAT(columnName, '%Y-%m-01') + * year: 表示按照年聚合,将会截取到年。DATE_FORMAT(columnName, '%Y-01-01') + */ + private String dateAggregateBy; + } + + private static class GroupBaseData { + private String modelName; + private String fieldName; + private String tableName; + private String columnName; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyOrderParam.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyOrderParam.java new file mode 100644 index 00000000..9d2ca7b2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyOrderParam.java @@ -0,0 +1,303 @@ +package com.orangeforms.common.core.object; + +import cn.hutool.core.util.ReflectUtil; +import com.baomidou.mybatisplus.annotation.TableId; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.exception.InvalidClassFieldException; +import com.orangeforms.common.core.exception.InvalidDataFieldException; +import com.orangeforms.common.core.exception.InvalidDataModelException; +import com.orangeforms.common.core.util.MyModelUtil; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import java.lang.reflect.Field; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; + +/** + * Controller参数中的排序请求对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EqualsAndHashCode(callSuper = true) +@Slf4j +@Data +public class MyOrderParam extends ArrayList { + + private static final String DICT_MAP = "DictMap."; + private static final Map, MyOrderParam> DEFAULT_ORDER_PARAM_MAP = new ConcurrentHashMap<>(); + + /** + * 基于排序对象中的JSON数据,构建SQL中order by从句可以直接使用的排序字符串。 + * 注意:如果orderParam为NULL,则会通过modelClazz对象推演出主键字典名,并按照主键倒排的方式生成默认的排序对象。 + * + * @param orderParam 排序参数对象。 + * @param modelClazz 查询主表对应的主对象的Class。 + * @return SQL中order by从句可以直接使用的排序字符串。 + */ + public static String buildOrderBy(MyOrderParam orderParam, Class modelClazz) { + return buildOrderBy(orderParam, modelClazz, true); + } + + /** + * 基于排序对象中的JSON数据,构建SQL中order by从句可以直接使用的排序字符串。 + * 注意:如果orderParam为NULL,则会通过modelClazz对象推演出主键字典名,并按照主键倒排的方式生成默认的排序对象。 + * + * @param orderParam 排序参数对象。 + * @param modelClazz 查询主表对应的主对象的Class。 + * @param addDefaultIfNull 如果为true,当orderParam参数为NULL是,则自动添加基于主键倒排序的索引。 + * @return SQL中order by从句可以直接使用的排序字符串。 + */ + public static String buildOrderBy(MyOrderParam orderParam, Class modelClazz, boolean addDefaultIfNull) { + if (orderParam == null) { + if (!addDefaultIfNull) { + return null; + } + orderParam = getAndSetDefaultOrderParam(modelClazz); + } + if (modelClazz == null) { + throw new IllegalArgumentException( + "modelClazz Argument in MyOrderParam.buildOrderBy can't be NULL"); + } + int i = 0; + StringBuilder orderBy = new StringBuilder(128); + for (OrderInfo orderInfo : orderParam) { + if (StringUtils.isBlank(orderInfo.getFieldName())) { + continue; + } + OrderBaseData orderBaseData = parseOrderBaseData(orderInfo, modelClazz); + if (StringUtils.isBlank(orderBaseData.tableName)) { + throw new InvalidDataModelException(orderBaseData.modelName); + } + if (StringUtils.isBlank(orderBaseData.columnName)) { + throw new InvalidDataFieldException(orderBaseData.modelName, orderBaseData.fieldName); + } + processOrderInfo(orderInfo, orderBaseData, orderBy); + if (++i < orderParam.size()) { + orderBy.append(", "); + } + } + return orderBy.toString(); + } + + private static MyOrderParam getAndSetDefaultOrderParam(Class modelClazz) { + MyOrderParam orderParam = DEFAULT_ORDER_PARAM_MAP.get(modelClazz); + if (orderParam != null) { + return orderParam; + } + orderParam = new MyOrderParam(); + DEFAULT_ORDER_PARAM_MAP.put(modelClazz, orderParam); + Field[] fields = ReflectUtil.getFields(modelClazz); + for (Field field : fields) { + if (field.getAnnotation(TableId.class) != null) { + orderParam.add(new OrderInfo(field.getName(), false, null)); + break; + } + } + return orderParam; + } + + private static void processOrderInfo( + OrderInfo orderInfo, OrderBaseData orderBaseData, StringBuilder orderByBuilder) { + if (StringUtils.isNotBlank(orderInfo.dateAggregateBy)) { + orderByBuilder.append("DATE_FORMAT(") + .append(orderBaseData.tableName).append(".").append(orderBaseData.columnName); + if (ApplicationConstant.DAY_AGGREGATION.equals(orderInfo.dateAggregateBy)) { + orderByBuilder.append(", '%Y-%m-%d')"); + } else if (ApplicationConstant.MONTH_AGGREGATION.equals(orderInfo.dateAggregateBy)) { + orderByBuilder.append(", '%Y-%m-01')"); + } else if (ApplicationConstant.YEAR_AGGREGATION.equals(orderInfo.dateAggregateBy)) { + orderByBuilder.append(", '%Y-01-01')"); + } else { + throw new IllegalArgumentException("Illegal DATE_FORMAT for GROUP ID list."); + } + } else { + orderByBuilder.append(orderBaseData.tableName).append(".").append(orderBaseData.columnName); + } + if (orderInfo.asc != null && !orderInfo.asc) { + orderByBuilder.append(" DESC"); + } + } + + private static OrderBaseData parseOrderBaseData(OrderInfo orderInfo, Class modelClazz) { + OrderBaseData orderBaseData = new OrderBaseData(); + orderBaseData.fieldName = StringUtils.substringBefore(orderInfo.fieldName, DICT_MAP); + String[] stringArray = StringUtils.split(orderBaseData.fieldName, '.'); + if (stringArray.length == 1) { + orderBaseData.modelName = modelClazz.getSimpleName(); + orderBaseData.tableName = MyModelUtil.mapToTableName(modelClazz); + orderBaseData.columnName = MyModelUtil.mapToColumnName(orderBaseData.fieldName, modelClazz); + } else { + Field field = ReflectUtil.getField(modelClazz, stringArray[0]); + if (field == null) { + throw new InvalidClassFieldException(modelClazz.getSimpleName(), stringArray[0]); + } + Class fieldClazz = field.getType(); + orderBaseData.modelName = fieldClazz.getSimpleName(); + orderBaseData.fieldName = stringArray[1]; + orderBaseData.tableName = MyModelUtil.mapToTableName(fieldClazz); + orderBaseData.columnName = MyModelUtil.mapToColumnName(orderBaseData.fieldName, fieldClazz); + } + return orderBaseData; + } + + /** + * 在排序列表中,可能存在基于指定表字段的排序,该函数将获取指定表的所有排序字段。 + * 返回的字符串,可直接用于SQL中的ORDER BY从句。 + * + * @param orderParam 排序参数对象。 + * @param modelClazz 查询主表对应的主对象的Class。 + * @param relationModelName 与关联表对应的Model的名称,如my_course_paper表应对的Java对象CoursePaper。 + * 如果该值为null或空字符串,则获取所有主表的排序字段。 + * @return 返回的是表字段,而非Java对象的属性,多个字段之间逗号分隔。 + */ + public static String getOrderClauseByModelName( + MyOrderParam orderParam, Class modelClazz, String relationModelName) { + if (orderParam == null) { + return null; + } + if (modelClazz == null) { + throw new IllegalArgumentException( + "modelClazz Argument in MyOrderParam.getOrderClauseByModelName can't be NULL"); + } + List fieldNameList = new LinkedList<>(); + String prefix = null; + if (StringUtils.isNotBlank(relationModelName)) { + prefix = relationModelName + "."; + } + for (OrderInfo orderInfo : orderParam) { + OrderBaseData baseData = parseOrderBaseData(orderInfo, modelClazz, prefix, relationModelName); + if (baseData != null) { + fieldNameList.add(makeOrderBy(baseData, orderInfo.asc)); + } + } + return StringUtils.join(fieldNameList, ", "); + } + + private static OrderBaseData parseOrderBaseData( + OrderInfo orderInfo, Class modelClazz, String prefix, String relationModelName) { + OrderBaseData baseData = null; + String fieldName = StringUtils.substringBefore(orderInfo.fieldName, DICT_MAP); + if (prefix != null) { + if (fieldName.startsWith(prefix)) { + baseData = new OrderBaseData(); + Field field = ReflectUtil.getField(modelClazz, relationModelName); + if (field == null) { + throw new InvalidClassFieldException(modelClazz.getSimpleName(), relationModelName); + } + Class fieldClazz = field.getType(); + baseData.modelName = fieldClazz.getSimpleName(); + baseData.fieldName = StringUtils.removeStart(fieldName, prefix); + baseData.tableName = MyModelUtil.mapToTableName(fieldClazz); + baseData.columnName = MyModelUtil.mapToColumnName(fieldName, fieldClazz); + } + } else { + String dotLimitor = "."; + if (!fieldName.contains(dotLimitor)) { + baseData = new OrderBaseData(); + baseData.modelName = modelClazz.getSimpleName(); + baseData.tableName = MyModelUtil.mapToTableName(modelClazz); + baseData.columnName = MyModelUtil.mapToColumnName(fieldName, modelClazz); + } + } + return baseData; + } + + private static String makeOrderBy(OrderBaseData baseData, Boolean asc) { + if (StringUtils.isBlank(baseData.tableName)) { + throw new InvalidDataModelException(baseData.modelName); + } + if (StringUtils.isBlank(baseData.columnName)) { + throw new InvalidDataFieldException(baseData.modelName, baseData.fieldName); + } + StringBuilder orderBy = new StringBuilder(128); + orderBy.append(baseData.tableName).append(".").append(baseData.columnName); + if (asc != null && !asc) { + orderBy.append(" DESC"); + } + return orderBy.toString(); + } + + /** + * 在排序列表中,可能存在基于指定表字段的排序,该函数将删除指定表的所有排序字段。 + * + * @param orderParam 排序参数对象。 + * @param modelClazz 查询主表对应的主对象的Class。 + * @param relationModelName 与关联表对应的Model的名称,如my_course_paper表应对的Java对象CoursePaper。 + * 如果该值为null或空字符串,则获取所有主表的排序字段。 + */ + public static void removeOrderClauseByModelName( + MyOrderParam orderParam, Class modelClazz, String relationModelName) { + if (orderParam == null) { + return; + } + if (modelClazz == null) { + throw new IllegalArgumentException( + "modelClazz Argument in MyOrderParam.removeOrderClauseByModelName can't be NULL"); + } + List fieldIndexList = new LinkedList<>(); + String prefix = null; + if (StringUtils.isNotBlank(relationModelName)) { + prefix = relationModelName + "."; + } + int i = 0; + for (OrderInfo orderInfo : orderParam) { + String fieldName = StringUtils.substringBefore(orderInfo.fieldName, DICT_MAP); + if (prefix != null) { + if (fieldName.startsWith(prefix)) { + fieldIndexList.add(i); + } + } else { + if (!fieldName.contains(".")) { + fieldIndexList.add(i); + } + } + ++i; + } + for (int index : fieldIndexList) { + orderParam.remove(index); + } + } + + /** + * 排序信息对象。 + */ + @AllArgsConstructor + @NoArgsConstructor + @Data + public static class OrderInfo { + /** + * Java对象的字段名。如果fieldName为空,则忽略跳过。目前主要包含三种格式: + * 1. 简单的属性名称,如userId,将会直接映射到与其关联的数据库字段。表名为当前ModelClazz所对应的表名。 + * 映射结果或为 my_main_table.user_id + * 2. 字典属性名称,如userIdDictMap.id,由于仅仅支持字典中Id数据的排序,所以直接截取DictMap之前的字符串userId作为排序属性。 + * 表名为当前ModelClazz所对应的表名。映射结果或为 my_main_table.user_id + * 3. 一对一关联表属性,如user.userId,这里将先获取user属性的对象类型并映射到对应的表名,后面的userId为 + * user所在实体的属性。映射结果或为:my_sys_user.user_id + */ + private String fieldName; + /** + * 排序方向。true为升序,否则降序。 + */ + private Boolean asc = true; + /** + * 如果该值不为NULL,则会对日期型排序字段进行DATE_FORMAT函数的计算,并根据具体的值,将日期数据截取到指定的位。 + * day: 表示按照天聚合,将会截取到天。DATE_FORMAT(columnName, '%Y-%m-%d') + * month: 表示按照月聚合,将会截取到月。DATE_FORMAT(columnName, '%Y-%m-01') + * year: 表示按照年聚合,将会截取到年。DATE_FORMAT(columnName, '%Y-01-01') + */ + private String dateAggregateBy; + } + + private static class OrderBaseData { + private String modelName; + private String fieldName; + private String tableName; + private String columnName; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyPageData.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyPageData.java new file mode 100644 index 00000000..57bb1c8f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyPageData.java @@ -0,0 +1,36 @@ +package com.orangeforms.common.core.object; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.LinkedList; +import java.util.List; + +/** + * 分页数据的应答返回对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class MyPageData { + /** + * 数据列表。 + */ + private List dataList; + /** + * 数据总数量。 + */ + private Long totalCount; + + /** + * 为了保持前端的数据格式兼容性,在没有数据的时候,需要返回空分页对象。 + * @return 空分页对象。 + */ + public static MyPageData emptyPageData() { + return new MyPageData<>(new LinkedList<>(), 0L); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyPageParam.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyPageParam.java new file mode 100644 index 00000000..cd4ddc41 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyPageParam.java @@ -0,0 +1,69 @@ +package com.orangeforms.common.core.object; + +import lombok.Getter; + +/** + * Controller参数中的分页请求对象 + * + * @author Jerry + * @date 2024-07-02 + */ +@Getter +public class MyPageParam { + + public static final int DEFAULT_PAGE_NUM = 1; + public static final int DEFAULT_PAGE_SIZE = 10; + public static final int DEFAULT_MAX_SIZE = 2000; + + /** + * 分页号码,从1开始计数。 + */ + private Integer pageNum; + + /** + * 每页大小。 + */ + private Integer pageSize; + + /** + * 是否统计totalCount + */ + private Boolean count = true; + + /** + * 设置当前分页页号。 + * + * @param pageNum 页号,如果传入非法值,则使用缺省值。 + */ + public void setPageNum(Integer pageNum) { + if (pageNum == null) { + return; + } + if (pageNum <= 0) { + pageNum = DEFAULT_PAGE_NUM; + } + this.pageNum = pageNum; + } + + /** + * 设置分页的大小。 + * + * @param pageSize 分页大小,如果传入非法值,则使用缺省值。 + */ + public void setPageSize(Integer pageSize) { + if (pageSize == null) { + return; + } + if (pageSize <= 0) { + pageSize = DEFAULT_PAGE_SIZE; + } + if (pageSize > DEFAULT_MAX_SIZE) { + pageSize = DEFAULT_MAX_SIZE; + } + this.pageSize = pageSize; + } + + public void setCount(Boolean count) { + this.count = count; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyPrintInfo.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyPrintInfo.java new file mode 100644 index 00000000..6a5a60d9 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyPrintInfo.java @@ -0,0 +1,32 @@ +package com.orangeforms.common.core.object; + +import com.alibaba.fastjson.JSONArray; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 打印信息对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@NoArgsConstructor +public class MyPrintInfo { + + /** + * 打印模板Id。 + */ + private Long printId; + /** + * 打印参数列表。对应于common-report模块的ReportPrintParam对象。 + */ + private List printParams; + + public MyPrintInfo(Long printId, List printParams) { + this.printId = printId; + this.printParams = printParams; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyRelationParam.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyRelationParam.java new file mode 100644 index 00000000..26f23c15 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyRelationParam.java @@ -0,0 +1,122 @@ +package com.orangeforms.common.core.object; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.StrUtil; +import lombok.Builder; +import lombok.Data; +import lombok.Getter; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * 实体对象数据组装参数构建器。 + * BaseService中的实体对象数据组装函数,会根据该参数对象进行数据组装。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@Builder +public class MyRelationParam { + + /** + * 是否组装字典关联的标记。 + * 组装RelationDict和RelationConstDict注解标记的字段。 + */ + private boolean buildDict; + + /** + * 是否组装一对一关联的标记。 + * 组装RelationOneToOne注解标记的字段。 + */ + private boolean buildOneToOne; + + /** + * 是否组装一对多关联的标记。 + * 组装RelationOneToMany注解标记的字段。 + */ + private boolean buildOneToMany; + + /** + * 在组装一对一关联的同时,是否继续关联从表中的字典。 + * 从表中RelationDict和RelationConstDict注解标记的字段。 + * 该字段为true时,无需设置buildOneToOne了。 + */ + private boolean buildOneToOneWithDict; + + /** + * 是否组装主表对多对多中间表关联的标记。 + * 组装RelationManyToMany注解标记的字段。 + */ + private boolean buildRelationManyToMany; + + /** + * 是否组装聚合计算关联的标记。 + * 组装RelationOneToManyAggregation和RelationManyToManyAggregation注解标记的字段。 + */ + private boolean buildRelationAggregation; + + /** + * 关联表中,需要忽略的脱敏字段名。key是关联表实体对象名,如SysUser,value是对象字段名的集合,如userId。 + */ + @Getter + private Map> ignoreMaskFieldMap; + + /** + * 关联表中需要忽略的脱敏字段结合。 + * @param ignoreRelationMaskFieldSet 数据项格式为"实体对象名.对象属性名",如 sysUser.userId。 + */ + public void setIgnoreMaskFieldSet(Set ignoreRelationMaskFieldSet) { + if (CollUtil.isEmpty(ignoreRelationMaskFieldSet)) { + return; + } + ignoreMaskFieldMap = MapUtil.newHashMap(); + for (String ignoreField : ignoreRelationMaskFieldSet) { + String[] fullFieldName = StrUtil.splitToArray(ignoreField, "."); + Set ignoreMaskFieldSet = + ignoreMaskFieldMap.computeIfAbsent(fullFieldName[0], k -> new HashSet<>()); + ignoreMaskFieldSet.add(fullFieldName[1]); + } + } + + /** + * 便捷方法,返回仅做字典关联的参数对象。 + * + * @return 返回仅做字典关联的参数对象。 + */ + public static MyRelationParam dictOnly() { + return MyRelationParam.builder().buildDict(true).build(); + } + + /** + * 便捷方法,返回仅做字典关联、一对一从表及其字典和聚合计算的参数对象。 + * NOTE: 对于一对多和多对多,这种从表数据是列表结果的关联,均不返回。 + * + * @return 返回仅做字典关联、一对一从表及其字典和聚合计算的参数对象。 + */ + public static MyRelationParam normal() { + return MyRelationParam.builder() + .buildDict(true) + .buildOneToOneWithDict(true) + .buildRelationAggregation(true) + .build(); + } + + /** + * 便捷方法,返回全部关联的参数对象。 + * + * @return 返回全部关联的参数对象。 + */ + public static MyRelationParam full() { + return MyRelationParam.builder() + .buildDict(true) + .buildOneToOneWithDict(true) + .buildRelationAggregation(true) + .buildRelationManyToMany(true) + .buildOneToMany(true) + .build(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyWhereCriteria.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyWhereCriteria.java new file mode 100644 index 00000000..d225446c --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/MyWhereCriteria.java @@ -0,0 +1,376 @@ +package com.orangeforms.common.core.object; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ReflectUtil; +import com.alibaba.fastjson.annotation.JSONField; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.exception.InvalidDataFieldException; +import com.orangeforms.common.core.exception.InvalidDataModelException; +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.core.util.MyModelUtil; +import lombok.*; +import lombok.extern.slf4j.Slf4j; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.regex.Matcher; + +/** + * Where中的条件语句。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Data +@NoArgsConstructor +public class MyWhereCriteria { + + /** + * 等于 + */ + public static final int OPERATOR_EQUAL = 0; + + /** + * 不等于 + */ + public static final int OPERATOR_NOT_EQUAL = 1; + + /** + * 大于等于 + */ + public static final int OPERATOR_GE = 2; + + /** + * 大于 + */ + public static final int OPERATOR_GT = 3; + + /** + * 小于等于 + */ + public static final int OPERATOR_LE = 4; + + /** + * 小于 + */ + public static final int OPERATOR_LT = 5; + + /** + * LIKE + */ + public static final int OPERATOR_LIKE = 6; + + /** + * NOT NULL + */ + public static final int OPERATOR_NOT_NULL = 7; + + /** + * IS NULL + */ + public static final int OPERATOR_IS_NULL = 8; + + /** + * IN + */ + public static final int OPERATOR_IN = 9; + + /** + * 参与过滤的实体对象的Class。 + */ + @JSONField(serialize = false) + private Class modelClazz; + + /** + * 数据库表名。 + */ + private String tableName; + + /** + * Java属性名称。 + */ + private String fieldName; + + /** + * 数据表字段名。 + */ + private String columnName; + + /** + * 数据表字段类型。 + */ + private Integer columnType; + + /** + * 操作符类型,取值范围见上面的常量值。 + */ + private Integer operatorType; + + /** + * 条件数据值。 + */ + private Object value; + + public MyWhereCriteria(Class modelClazz, String fieldName, Integer operatorType, Object value) { + this.modelClazz = modelClazz; + this.fieldName = fieldName; + this.operatorType = operatorType; + this.value = value; + } + + /** + * 设置条件值。 + * + * @param fieldName 条件所属的实体对象的字段名。 + * @param operatorType 条件操作符。具体值可参考当前对象的静态变量。 + * @param value 条件过滤值。 + * @return 验证结果对象,如果有错误将会返回具体的错误信息。 + */ + public CallResult setCriteria(String fieldName, Integer operatorType, Object value) { + this.operatorType = operatorType; + this.fieldName = fieldName; + this.value = value; + return doVerify(); + } + + /** + * 设置条件值。 + * + * @param modelClazz 数据表对应实体对象的Class. + * @param fieldName 条件所属的实体对象的字段名。 + * @param operatorType 条件操作符。具体值可参考当前对象的静态变量。 + * @param value 条件过滤值。 + * @return 验证结果对象,如果有错误将会返回具体的错误信息。 + */ + public CallResult setCriteria(Class modelClazz, String fieldName, Integer operatorType, Object value) { + this.modelClazz = modelClazz; + this.operatorType = operatorType; + this.fieldName = fieldName; + this.value = value; + return doVerify(); + } + + /** + * 设置条件值,通过该构造方法设置时,通常是直接将表名、字段名、字段类型等赋值,无需在通过modelClazz进行推演。 + * + * @param tableName 数据表名。 + * @param columnName 数据字段名。 + * @param columnType 数据字段类型。 + * @param operatorType 操作类型。具体值可参考当前对象的静态变量。 + * @param value 条件过滤值。 + */ + public void setCriteria( + String tableName, String columnName, String columnType, Integer operatorType, Object value) { + this.tableName = tableName; + this.columnName = columnName; + this.columnType = MyModelUtil.NUMERIC_FIELD_TYPE; + if (String.class.getSimpleName().equals(columnType)) { + this.columnType = MyModelUtil.STRING_FIELD_TYPE; + } else if (Date.class.getSimpleName().equals(columnType)) { + this.columnType = MyModelUtil.DATE_FIELD_TYPE; + } + this.operatorType = operatorType; + this.value = value; + } + + /** + * 在执行该函数之前,该对象的所有数据均已经赋值完毕。 + * 该函数主要验证操作符字段和条件值字段对应关系的合法性。 + * + * @return 验证结果对象,如果有错误将会返回具体的错误信息。 + */ + public CallResult doVerify() { + if (fieldName == null) { + return CallResult.error("过滤字段名称 [fieldName] 不能为空!"); + } + if (modelClazz != null && ReflectUtil.getField(modelClazz, fieldName) == null) { + return CallResult.error( + "过滤字段 [" + fieldName + "] 在实体对象 [" + modelClazz.getSimpleName() + "] 中并不存在!"); + } + if (!checkOperatorType()) { + return CallResult.error("无效的操作符类型 [" + operatorType + "]!"); + } + // 其他操作符必须包含value值 + if (operatorType != OPERATOR_IS_NULL && operatorType != OPERATOR_NOT_NULL && value == null) { + String operatorString = this.getOperatorString(); + return CallResult.error("操作符 [" + operatorString + "] 的条件值不能为空!"); + } + if (this.operatorType == OPERATOR_IN) { + if (!(value instanceof Collection)) { + return CallResult.error("操作符 [IN] 的条件值必须为集合对象!"); + } + if (CollUtil.isEmpty((Collection) value)) { + return CallResult.error("操作符 [IN] 的条件值不能为空!"); + } + } + return CallResult.ok(); + } + + /** + * 判断操作符类型是否合法。 + * + * @return 合法返回true,否则false。 + */ + public boolean checkOperatorType() { + return operatorType != null + && (operatorType >= OPERATOR_EQUAL && operatorType <= OPERATOR_IN); + } + + /** + * 获取操作符的字符串形式。 + * + * @return 操作符的字符串。 + */ + public String getOperatorString() { + switch (operatorType) { + case OPERATOR_EQUAL: + return " = "; + case OPERATOR_NOT_EQUAL: + return " != "; + case OPERATOR_GE: + return " >= "; + case OPERATOR_GT: + return " > "; + case OPERATOR_LE: + return " <= "; + case OPERATOR_LT: + return " < "; + case OPERATOR_LIKE: + return " LIKE "; + case OPERATOR_NOT_NULL: + return " IS NOT NULL "; + case OPERATOR_IS_NULL: + return " IS NULL "; + case OPERATOR_IN: + return " IN "; + default: + return null; + } + } + + /** + * 获取组装后的SQL Where从句,如 table_name.column_name = 'value'。 + * 与查询数据表对应的实体对象Class为当前对象的modelClazz字段。 + * + * @exception InvalidDataFieldException selectFieldList中存在非法实体字段时,抛出该异常。 + * @return 组装后的SQL条件从句。 + */ + public String makeCriteriaString() { + return makeCriteriaString(this.modelClazz); + } + + /** + * 获取组装后的SQL Where从句,如 table_name.column_name = 'value'。 + * + * @param modelClazz 与查询数据表对应的实体对象的Class。 + * @exception InvalidDataFieldException selectFieldList中存在非法实体字段时,抛出该异常。 + * @exception InvalidDataModelException 参数modelClazz没有对应的table,抛出该异常。 + * @return 组装后的SQL条件从句。 + */ + public String makeCriteriaString(Class modelClazz) { + String localTableName; + String localColumnName; + Integer localColumnType; + if (modelClazz != null) { + Tuple2 fieldInfo = MyModelUtil.mapToColumnInfo(fieldName, modelClazz); + if (fieldInfo == null) { + throw new InvalidDataFieldException(modelClazz.getSimpleName(), fieldName); + } + localColumnName = fieldInfo.getFirst(); + localColumnType = fieldInfo.getSecond(); + localTableName = MyModelUtil.mapToTableName(modelClazz); + if (localTableName == null) { + throw new InvalidDataModelException(modelClazz.getSimpleName()); + } + } else { + localTableName = this.tableName; + localColumnName = this.columnName; + localColumnType = this.columnType; + } + return this.buildClauseString(localTableName, localColumnName, localColumnType); + } + + /** + * 获取组装后的SQL Where从句。如 table_name.column_name = 'value'。 + * + * @param criteriaList 条件列表,所有条件直接目前仅支持 AND 的关系。 + * @exception InvalidDataFieldException selectFieldList中存在非法实体字段时,抛出该异常。 + * @return 组装后的SQL条件从句。 + */ + public static String makeCriteriaString(List criteriaList) { + return makeCriteriaString(criteriaList, null); + } + + /** + * 获取组装后的SQL Where从句。如 table_name.column_name = 'value'。 + * + * @param criteriaList 条件列表,所有条件直接目前仅支持 AND 的关系。 + * @param modelClazz 与数据表对应的实体对象的Class。 + * 如果不为NULL实体对象Class使用该值,否则使用每个MyWhereCriteria自身的modelClazz。 + * @exception InvalidDataFieldException selectFieldList中存在非法实体字段时,抛出该异常。 + * @return 组装后的SQL条件从句。 + */ + public static String makeCriteriaString(List criteriaList, Class modelClazz) { + if (CollUtil.isEmpty(criteriaList)) { + return null; + } + StringBuilder sb = new StringBuilder(256); + int i = 0; + for (MyWhereCriteria whereCriteria : criteriaList) { + Class clazz = modelClazz; + if (clazz == null) { + clazz = whereCriteria.modelClazz; + } + if (i++ != 0) { + sb.append(" AND "); + } + String criteriaString = whereCriteria.makeCriteriaString(clazz); + sb.append(criteriaString); + } + return sb.length() == 0 ? null : sb.toString(); + } + + private String buildClauseString(String tableName, String columnName, Integer columnType) { + StringBuilder sb = new StringBuilder(64); + sb.append(tableName).append(".").append(columnName).append(getOperatorString()); + if (operatorType == OPERATOR_IN) { + Collection filterValues = (Collection) value; + sb.append("("); + int i = 0; + for (Object filterValue : filterValues) { + this.doSqlInjectVerify(filterValue.toString()); + if (columnType.equals(MyModelUtil.NUMERIC_FIELD_TYPE)) { + sb.append(filterValue); + } else { + sb.append("'").append(filterValue).append("'"); + } + if (i++ != filterValues.size() - 1) { + sb.append(", "); + } + } + sb.append(")"); + return sb.toString(); + } + if (value == null) { + return sb.toString(); + } + this.doSqlInjectVerify(value.toString()); + if (columnType.equals(MyModelUtil.NUMERIC_FIELD_TYPE)) { + sb.append(value); + } else { + sb.append("'").append(value).append("'"); + } + return sb.toString(); + } + + private void doSqlInjectVerify(String v) { + Matcher matcher = ApplicationConstant.SQL_INJECT_PATTERN.matcher(v); + if (matcher.find()) { + String msg = String.format( + "The filterValue [%s] has SQL Inject Words", v); + throw new MyRuntimeException(msg); + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/ResponseResult.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/ResponseResult.java new file mode 100644 index 00000000..26e2eee5 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/ResponseResult.java @@ -0,0 +1,295 @@ +package com.orangeforms.common.core.object; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.annotation.JSONField; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.util.ContextUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; + +import jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; + +/** + * 接口返回对象 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Data +public class ResponseResult { + + /** + * 为了优化性能,所有没有携带数据的正确结果,均可用该对象表示。 + */ + private static final ResponseResult OK = new ResponseResult<>(); + /** + * 是否成功标记。 + */ + private boolean success = true; + /** + * 错误码。 + */ + private String errorCode = "NO-ERROR"; + /** + * 错误信息描述。 + */ + private String errorMessage = "NO-MESSAGE"; + /** + * 实际数据。 + */ + private T data = null; + /** + * HTTP状态码,通常用于内部调用的方法传递,不推荐返回给前端。 + */ + @JSONField(serialize = false) + private int httpStatus = 200; + + /** + * 根据参数errorCodeEnum的枚举值,判断创建成功对象还是错误对象。 + * 如果返回错误对象,errorCode 和 errorMessage 分别取自于参数 errorCodeEnum 的 name() 和 getErrorMessage()。 + * + * @param errorCodeEnum 错误码枚举。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult create(ErrorCodeEnum errorCodeEnum) { + return create(errorCodeEnum, errorCodeEnum.getErrorMessage()); + } + + /** + * 根据参数errorCodeEnum的枚举值,判断创建成功对象还是错误对象。 + * 如果返回错误对象,errorCode 和 errorMessage 分别取自于参数 errorCodeEnum 的 name() 和参数 errorMessage。 + * + * @param errorCodeEnum 错误码枚举。 + * @param errorMessage 如果该参数为null,错误信息取自errorCodeEnum参数内置的errorMessage,否则使用当前参数。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult create(ErrorCodeEnum errorCodeEnum, String errorMessage) { + errorMessage = errorMessage != null ? errorMessage : errorCodeEnum.getErrorMessage(); + return errorCodeEnum == ErrorCodeEnum.NO_ERROR ? success() : error(errorCodeEnum.name(), errorMessage); + } + + /** + * 根据参数errorCode是否为空,判断创建成功对象还是错误对象。 + * 如果返回错误对象,errorCode 和 errorMessage 分别取自于参数 errorCode 和参数 errorMessage。 + * + * @param errorCode 自定义的错误码。 + * @param errorMessage 自定义的错误信息。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult create(String errorCode, String errorMessage) { + return errorCode == null ? success() : error(errorCode, errorMessage); + } + + /** + * 根据参数errorCodeEnum的枚举值,判断创建成功对象还是错误对象。 + * 如果返回错误对象,errorCode 和 errorMessage 分别取自于参数 errorCodeEnum 的 name() 和参数 errorMessage。 + * + * @param errorCodeEnum 错误码枚举。 + * @param errorMessage 如果该参数为null,错误信息取自errorCodeEnum参数内置的errorMessage,否则使用当前参数。 + * @param data 如果错误枚举值为NO_ERROR,则返回该数据。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult create(ErrorCodeEnum errorCodeEnum, String errorMessage, T data) { + errorMessage = errorMessage != null ? errorMessage : errorCodeEnum.getErrorMessage(); + return errorCodeEnum == ErrorCodeEnum.NO_ERROR ? success(data) : error(errorCodeEnum.name(), errorMessage); + } + + /** + * 创建成功对象。 + * 如果需要绑定返回数据,可以在实例化后调用setDataObject方法。 + * + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult success() { + return OK; + } + + /** + * 创建带有返回数据的成功对象。 + * + * @param data 返回的数据对象。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult success(T data) { + ResponseResult resp = new ResponseResult<>(); + resp.data = data; + return resp; + } + + /** + * 创建带有返回数据的成功对象。 + * + * @param data 返回的数据对象。 + * @param clazz 目标数据类型。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult success(R data, Class clazz) { + ResponseResult resp = new ResponseResult<>(); + resp.data = MyModelUtil.copyTo(data, clazz); + return resp; + } + + /** + * 创建错误对象。 + * 如果返回错误对象,errorCode 和 errorMessage 分别取自于参数 errorCodeEnum 的 name() 和 getErrorMessage()。 + * + * @param errorCodeEnum 错误码枚举。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult error(ErrorCodeEnum errorCodeEnum) { + return error(errorCodeEnum.name(), errorCodeEnum.getErrorMessage()); + } + + /** + * 创建错误对象。 + * 如果返回错误对象,errorCode 和 errorMessage 分别取自于参数 errorCodeEnum 的 name() 和 getErrorMessage()。 + * + * @param httpStatus http状态值。 + * @param errorCodeEnum 错误码枚举。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult error(int httpStatus, ErrorCodeEnum errorCodeEnum) { + ResponseResult r = error(errorCodeEnum.name(), errorCodeEnum.getErrorMessage()); + r.setHttpStatus(httpStatus); + return r; + } + + /** + * 创建错误对象。 + * 如果返回错误对象,errorCode 和 errorMessage 分别取自于参数 errorCodeEnum 的 name() 和参数 errorMessage。 + * + * @param errorCodeEnum 错误码枚举。 + * @param errorMessage 自定义的错误信息。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult error(ErrorCodeEnum errorCodeEnum, String errorMessage) { + return error(errorCodeEnum.name(), errorMessage); + } + + /** + * 创建错误对象。 + * 如果返回错误对象,errorCode 和 errorMessage 分别取自于参数 errorCodeEnum 的 name() 和参数 errorMessage。 + * + * @param httpStatus http状态值。 + * @param errorCodeEnum 错误码枚举。 + * @param errorMessage 自定义的错误信息。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult error(int httpStatus, ErrorCodeEnum errorCodeEnum, String errorMessage) { + ResponseResult r = error(errorCodeEnum.name(), errorMessage); + r.setHttpStatus(httpStatus); + return r; + } + + /** + * 创建错误对象。 + * 如果返回错误对象,errorCode 和 errorMessage 分别取自于参数 errorCode 和参数 errorMessage。 + * + * @param errorCode 自定义的错误码。 + * @param errorMessage 自定义的错误信息。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult error(String errorCode, String errorMessage) { + return new ResponseResult<>(errorCode, errorMessage); + } + + /** + * 根据参数中出错的ResponseResult,创建新的错误应答对象。 + * + * @param errorCause 导致错误原因的应答对象。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult errorFrom(ResponseResult errorCause) { + return error(errorCause.errorCode, errorCause.getErrorMessage()); + } + + /** + * 根据参数中出错的CallResult,创建新的错误应答对象。 + * + * @param errorCause 导致错误原因的应答对象。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult errorFrom(CallResult errorCause) { + return error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorCause.getErrorMessage()); + } + + /** + * 根据参数中CallResult,创建新的应答对象。 + * + * @param result CallResult对象。 + * @return 返回创建的ResponseResult实例对象。 + */ + public static ResponseResult from(CallResult result) { + if (result.isSuccess()) { + return success(); + } + return error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage()); + } + + /** + * 是否成功。 + * + * @return true成功,否则false。 + */ + public boolean isSuccess() { + return success; + } + + /** + * 通过HttpServletResponse直接输出应该信息的工具方法。 + * + * @param httpStatus http状态码。 + * @param responseResult 应答内容。 + * @param 数据对象类型。 + * @throws IOException 异常错误。 + */ + public static void output(int httpStatus, ResponseResult responseResult) throws IOException { + if (httpStatus != HttpServletResponse.SC_OK) { + log.error(JSON.toJSONString(responseResult)); + } else { + log.info(JSON.toJSONString(responseResult)); + } + HttpServletResponse response = ContextUtil.getHttpResponse(); + PrintWriter out = response.getWriter(); + response.setContentType("application/json; charset=utf-8"); + response.setStatus(httpStatus); + if (responseResult != null) { + out.print(JSON.toJSONString(responseResult)); + } + out.flush(); + } + + /** + * 通过HttpServletResponse直接输出应该信息的工具方法。 + * + * @param httpStatus http状态码。 + * @throws IOException 异常错误。 + */ + public static void output(int httpStatus) throws IOException { + output(httpStatus, null); + } + + /** + * 通过HttpServletResponse直接输出应该信息的工具方法。Http状态码为200。 + * + * @param responseResult 应答内容。 + * @param 数据对象类型。 + * @throws IOException 异常错误。 + */ + public static void output(ResponseResult responseResult) throws IOException { + output(HttpServletResponse.SC_OK, responseResult); + } + + private ResponseResult() { + } + + private ResponseResult(String errorCode, String errorMessage) { + this.success = false; + this.errorCode = errorCode; + this.errorMessage = errorMessage; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/TableModelInfo.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/TableModelInfo.java new file mode 100644 index 00000000..71c9d594 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/TableModelInfo.java @@ -0,0 +1,33 @@ +package com.orangeforms.common.core.object; + +import lombok.Data; + +/** + * 数据表模型基础信息。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class TableModelInfo { + + /** + * 数据表名。 + */ + private String tableName; + + /** + * 实体对象名。 + */ + private String modelName; + + /** + * 主键的表字段名。 + */ + private String keyColumnName; + + /** + * 主键在实体对象中的属性名。 + */ + private String keyFieldName; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/TokenData.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/TokenData.java new file mode 100644 index 00000000..79f3c1f9 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/TokenData.java @@ -0,0 +1,134 @@ +package com.orangeforms.common.core.object; + +import com.orangeforms.common.core.util.ContextUtil; +import lombok.Data; +import lombok.ToString; + +import jakarta.servlet.http.HttpServletRequest; +import java.util.Date; + +/** + * 基于Jwt,用于前后端传递的令牌对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ToString +public class TokenData { + + /** + * 在HTTP Request对象中的属性键。 + */ + public static final String REQUEST_ATTRIBUTE_NAME = "tokenData"; + /** + * 是否为百分号编码后的TokenData数据。 + */ + public static final String REQUEST_ENCODED_TOKEN = "encodedTokenData"; + /** + * 用户Id。 + */ + private Long userId; + /** + * 用户所属角色。多个角色之间逗号分隔。 + */ + private String roleIds; + /** + * 用户所在部门Id。 + * 仅当系统支持uaa时可用,否则可以直接忽略该字段。保留该字段是为了保持单体和微服务通用代码部分的兼容性。 + */ + private Long deptId; + /** + * 用户所属岗位Id。多个岗位之间逗号分隔。仅当系统支持岗位时有值。 + */ + private String postIds; + /** + * 用户的部门岗位Id。多个岗位之间逗号分隔。仅当系统支持岗位时有值。 + */ + private String deptPostIds; + /** + * 租户Id。 + * 仅当系统支持uaa时可用,否则可以直接忽略该字段。保留该字段是为了保持单体和微服务通用代码部分的兼容性。 + */ + private Long tenantId; + /** + * 是否为超级管理员。 + */ + private Boolean isAdmin; + /** + * 用户登录名。 + */ + private String loginName; + /** + * 用户显示名称。 + */ + private String showName; + /** + * 所在部门名。 + */ + private String deptName; + /** + * 设备类型。参考AppDeviceType。 + */ + private String deviceType; + /** + * 标识不同登录的会话Id。 + */ + private String sessionId; + /** + * 目前仅用于SaToken权限框架。 + * 主要用于辅助管理在线用户数据,SaToken默认的功能对于租户Id和登录用户的查询,没有提供方便的支持,或是效率较低。 + */ + private String mySessionId; + /** + * 访问uaa的授权token。 + * 仅当系统支持uaa时可用,否则可以直接忽略该字段。保留该字段是为了保持单体和微服务通用代码部分的兼容性。 + */ + private String uaaAccessToken; + /** + * 数据库路由键(仅当水平分库时使用)。 + */ + private Integer datasourceType; + /** + * 登录IP。 + */ + private String loginIp; + /** + * 登录时间。 + */ + private Date loginTime; + /** + * 登录头像地址。 + */ + private String headImageUrl; + /** + * 原始的请求Token。 + */ + private String token; + /** + * 应用编码。空值表示非第三方应用。 + */ + private String appCode; + + /** + * 将令牌对象添加到Http请求对象。 + * + * @param tokenData 令牌对象。 + */ + public static void addToRequest(TokenData tokenData) { + HttpServletRequest request = ContextUtil.getHttpRequest(); + if (request != null) { + request.setAttribute(TokenData.REQUEST_ATTRIBUTE_NAME, tokenData); + } + } + + /** + * 从Http Request对象中获取令牌对象。 + * + * @return 令牌对象。 + */ + public static TokenData takeFromRequest() { + HttpServletRequest request = ContextUtil.getHttpRequest(); + return request == null ? null : (TokenData) request.getAttribute(REQUEST_ATTRIBUTE_NAME); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/Tuple2.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/Tuple2.java new file mode 100644 index 00000000..19799a3e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/Tuple2.java @@ -0,0 +1,50 @@ +package com.orangeforms.common.core.object; + +/** + * 二元组对象。主要用于可以一次返回多个结果的场景,同时还能避免强制转换。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class Tuple2 { + + /** + * 第一个变量。 + */ + private final T1 first; + /** + * 第二个变量。 + */ + private final T2 second; + + /** + * 构造函数。 + * + * @param first 第一个变量。 + * @param second 第二个变量。 + */ + public Tuple2(T1 first, T2 second) { + this.first = first; + this.second = second; + } + + /** + * 获取第一个变量。 + * + * @return 返回第一个变量。 + */ + public T1 getFirst() { + return first; + } + + /** + * 获取第二个变量。 + * + * @return 返回第二个变量。 + */ + public T2 getSecond() { + return second; + } + +} + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/Tuple3.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/Tuple3.java new file mode 100644 index 00000000..bc6e4b7e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/Tuple3.java @@ -0,0 +1,65 @@ +package com.orangeforms.common.core.object; + +/** + * 三元组对象。主要用于可以一次返回多个结果的场景,同时还能避免强制转换。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class Tuple3 { + + /** + * 第一个变量。 + */ + private final T1 first; + /** + * 第二个变量。 + */ + private final T2 second; + + /** + * 第三个变量。 + */ + private final T3 third; + + /** + * 构造函数。 + * + * @param first 第一个变量。 + * @param second 第二个变量。 + * @param third 第三个变量。 + */ + public Tuple3(T1 first, T2 second, T3 third) { + this.first = first; + this.second = second; + this.third = third; + } + + /** + * 获取第一个变量。 + * + * @return 返回第一个变量。 + */ + public T1 getFirst() { + return first; + } + + /** + * 获取第二个变量。 + * + * @return 返回第二个变量。 + */ + public T2 getSecond() { + return second; + } + + /** + * 获取第三个变量。 + * + * @return 返回第三个变量。 + */ + public T3 getThird() { + return third; + } +} + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/TypedCallResult.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/TypedCallResult.java new file mode 100644 index 00000000..2dea0ca3 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/object/TypedCallResult.java @@ -0,0 +1,109 @@ +package com.orangeforms.common.core.object; + +import lombok.Data; + +/** + * 业务方法调用结果对象。可以同时返回具体的错误和自定义类型的数据对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class TypedCallResult { + + /** + * 为了优化性能,所有没有携带数据的正确结果,均可用该对象表示。 + */ + private static final TypedCallResult OK = new TypedCallResult<>(); + /** + * 是否成功标记。 + */ + private boolean success = true; + /** + * 错误信息描述。 + */ + private String errorMessage = null; + /** + * 在验证同时,仍然需要附加的关联数据对象。 + */ + private T data; + + /** + * 创建验证结果对象。 + * + * @param errorMessage 错误描述信息。 + * @return 如果参数为空,表示成功,否则返回代码错误信息的错误对象实例。 + */ + public static TypedCallResult create(String errorMessage) { + return errorMessage == null ? ok() : error(errorMessage); + } + + /** + * 创建验证结果对象。 + * + * @param errorMessage 错误描述信息。 + * @param data 附带的数据对象。 + * @return 如果参数为空,表示成功,否则返回代码错误信息的错误对象实例。 + */ + public static TypedCallResult create(String errorMessage, T data) { + return errorMessage == null ? ok(data) : error(errorMessage, data); + } + + /** + * 创建表示验证成功的对象实例。 + * + * @return 验证成功对象实例。 + */ + public static TypedCallResult ok() { + return OK; + } + + /** + * 创建表示验证成功的对象实例。 + * + * @param data 附带的数据对象。 + * @return 验证成功对象实例。 + */ + public static TypedCallResult ok(T data) { + TypedCallResult result = new TypedCallResult<>(); + result.data = data; + return result; + } + + /** + * 创建表示验证失败的对象实例。 + * + * @param errorMessage 错误描述。 + * @return 验证失败对象实例。 + */ + public static TypedCallResult error(String errorMessage) { + TypedCallResult result = new TypedCallResult<>(); + result.success = false; + result.errorMessage = errorMessage; + return result; + } + + /** + * 创建表示验证失败的对象实例。 + * + * @param errorMessage 错误描述。 + * @param data 附带的数据对象。 + * @return 验证失败对象实例。 + */ + public static TypedCallResult error(String errorMessage, T data) { + TypedCallResult result = new TypedCallResult<>(); + result.success = false; + result.errorMessage = errorMessage; + result.data = data; + return result; + } + + /** + * 根据参数中出错的TypedCallResult,创建新的错误调用结果对象。 + * @param result 错误调用结果对象。 + * @return 新的错误调用结果对象。 + */ + public static TypedCallResult errorFrom(TypedCallResult result) { + return error(result.getErrorMessage()); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/upload/BaseUpDownloader.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/upload/BaseUpDownloader.java new file mode 100644 index 00000000..840610bf --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/upload/BaseUpDownloader.java @@ -0,0 +1,216 @@ +package com.orangeforms.common.core.upload; + +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.util.ContextUtil; +import com.orangeforms.common.core.util.MyCommonUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.io.FilenameUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.web.multipart.MultipartFile; + +import javax.imageio.ImageIO; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Objects; + +/** + * 上传或下载文件抽象父类。 + * 包含存储本地文件的功能,以及上传和下载所需的通用方法。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public abstract class BaseUpDownloader { + + /** + * 构建上传文件的完整目录。 + * + * @param rootBaseDir 文件下载的根目录。 + * @param modelName 所在数据表的实体对象名。 + * @param fieldName 关联字段的实体对象属性名。 + * @param asImage 是否为图片对象。图片是无需权限验证的,因此和附件存放在不同的子目录。 + * @return 上传文件的完整路径名。 + */ + public String makeFullPath( + String rootBaseDir, String modelName, String fieldName, Boolean asImage) { + StringBuilder uploadPathBuilder = new StringBuilder(128); + if (StringUtils.isNotBlank(rootBaseDir)) { + uploadPathBuilder.append(rootBaseDir).append("/"); + } + if (Boolean.TRUE.equals(asImage)) { + uploadPathBuilder.append(ApplicationConstant.UPLOAD_IMAGE_PARENT_PATH); + } else { + uploadPathBuilder.append(ApplicationConstant.UPLOAD_ATTACHMENT_PARENT_PATH); + } + if (StringUtils.isNotBlank(modelName)) { + uploadPathBuilder.append("/").append(modelName); + } + if (StringUtils.isNotBlank(fieldName)) { + uploadPathBuilder.append("/").append(fieldName); + } + return uploadPathBuilder.toString(); + } + + /** + * 构建上传文件的完整目录。 + * + * @param rootBaseDir 文件下载的根目录。 + * @param path 文件目录。 + * @return 上传文件的完整路径名。 + */ + public String makeFullPath(String rootBaseDir, String path) { + StringBuilder uploadPathBuilder = new StringBuilder(128); + if (StringUtils.isNotBlank(rootBaseDir)) { + uploadPathBuilder.append(rootBaseDir).append("/"); + } + if (StringUtils.isNotBlank(path)) { + if (!StrUtil.startWith(path, "/")) { + uploadPathBuilder.append("/"); + } + uploadPathBuilder.append(path); + } + return uploadPathBuilder.toString(); + } + + /** + * 构建上传操作的返回对象。 + * + * @param serviceContextPath 微服务的上下文路径,如: /admin/upms。 + * @param originalFilename 上传文件的原始文件名(包含扩展名)。 + */ + protected void fillUploadResponseInfo( + UploadResponseInfo responseInfo, String serviceContextPath, String originalFilename) { + // 根据请求上传的uri构建下载uri,只是将末尾的/upload改为/download即可。 + HttpServletRequest request = ContextUtil.getHttpRequest(); + String uri = request.getRequestURI(); + uri = StringUtils.removeEnd(uri, "/"); + uri = StringUtils.removeEnd(uri, "/upload"); + String downloadUri; + if (StringUtils.isBlank(serviceContextPath)) { + downloadUri = uri + "/download"; + } else { + downloadUri = serviceContextPath + uri + "/download"; + } + StringBuilder filenameBuilder = new StringBuilder(64); + filenameBuilder.append(MyCommonUtil.generateUuid()) + .append(".").append(FilenameUtils.getExtension(originalFilename)); + responseInfo.setDownloadUri(downloadUri); + responseInfo.setFilename(filenameBuilder.toString()); + } + + /** + * 执行下载操作,从本地文件系统读取数据,并将读取的数据直接写入到HttpServletResponse应答对象。 + * + * @param rootBaseDir 文件下载的根目录。 + * @param modelName 所在数据表的实体对象名。 + * @param fieldName 关联字段的实体对象属性名。 + * @param fileName 文件名。 + * @param asImage 是否为图片对象。图片是无需权限验证的,因此和附件存放在不同的子目录。 + * @param response Http 应答对象。 + * @throws IOException 操作错误。 + */ + public abstract void doDownload( + String rootBaseDir, + String modelName, + String fieldName, + String fileName, + Boolean asImage, + HttpServletResponse response) throws IOException; + + /** + * 执行下载操作,从本地文件系统读取数据,并将读取的数据直接写入到HttpServletResponse应答对象。 + * + * @param rootBaseDir 文件下载的根目录。 + * @param uriPath uri中的路径名。 + * @param fileName 文件名。 + * @param response Http 应答对象。 + * @throws IOException 操作错误。 + */ + public abstract void doDownload( + String rootBaseDir, + String uriPath, + String fileName, + HttpServletResponse response) throws IOException; + + /** + * 执行文件上传操作,并存入本地文件系统,再将与该文件下载对应的Url直接写入到HttpServletResponse应答对象,返回给前端。 + * + * @param serviceContextPath 微服务的上下文路径,如: /admin/upms。 + * @param rootBaseDir 存放上传文件的根目录。 + * @param modelName 所在数据表的实体对象名。 + * @param fieldName 关联字段的实体对象属性名。 + * @param uploadFile Http请求中上传的文件对象。 + * @param asImage 是否为图片对象。图片是无需权限验证的,因此和附件存放在不同的子目录。 + * @return 存储在本地上传文件名。 + * @throws IOException 操作错误。 + */ + public abstract UploadResponseInfo doUpload( + String serviceContextPath, + String rootBaseDir, + String modelName, + String fieldName, + Boolean asImage, + MultipartFile uploadFile) throws IOException; + + /** + * 执行文件上传操作,并存入本地文件系统,再将与该文件下载对应的Url直接写入到HttpServletResponse应答对象,返回给前端。 + * + * @param serviceContextPath 微服务的上下文路径,如: /admin/upms。 + * @param rootBaseDir 存放上传文件的根目录。 + * @param uriPath uri中的路径名。 + * @param uploadFile Http请求中上传的文件对象。 + * @return 存储在本地上传文件名。 + * @throws IOException 操作错误。 + */ + public abstract UploadResponseInfo doUpload( + String serviceContextPath, + String rootBaseDir, + String uriPath, + MultipartFile uploadFile) throws IOException; + + /** + * 判断filename参数指定的文件名,是否被包含在fileInfoJson参数中。 + * + * @param fileInfoJson 内部类UploadFileInfo的JSONArray数组。 + * @param filename 被包含的文件名。 + * @return 存在返回true,否则false。 + */ + public static boolean containFile(String fileInfoJson, String filename) { + if (StringUtils.isAnyBlank(fileInfoJson, filename)) { + return false; + } + List fileInfoList = JSON.parseArray(fileInfoJson, UploadResponseInfo.class); + if (CollectionUtils.isNotEmpty(fileInfoList)) { + for (UploadResponseInfo fileInfo : fileInfoList) { + if (StringUtils.equals(filename, fileInfo.getFilename())) { + return true; + } + } + } + return false; + } + + protected UploadResponseInfo verifyUploadArgument( + Boolean asImage, MultipartFile uploadFile) throws IOException { + UploadResponseInfo responseInfo = new UploadResponseInfo(); + if (Objects.isNull(uploadFile) || uploadFile.isEmpty()) { + responseInfo.setUploadFailed(true); + responseInfo.setErrorMessage(ErrorCodeEnum.INVALID_UPLOAD_FILE_ARGUMENT.getErrorMessage()); + return responseInfo; + } + if (BooleanUtil.isTrue(asImage) && ImageIO.read(uploadFile.getInputStream()) == null) { + responseInfo.setUploadFailed(true); + responseInfo.setErrorMessage(ErrorCodeEnum.INVALID_UPLOAD_FILE_FORMAT.getErrorMessage()); + return responseInfo; + } + return responseInfo; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/upload/LocalUpDownloader.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/upload/LocalUpDownloader.java new file mode 100644 index 00000000..e883d06e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/upload/LocalUpDownloader.java @@ -0,0 +1,169 @@ +package com.orangeforms.common.core.upload; + +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; + +import jakarta.annotation.PostConstruct; +import jakarta.servlet.http.HttpServletResponse; +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +/** + * 存储本地文件的上传下载实现类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Component +public class LocalUpDownloader extends BaseUpDownloader { + + @Autowired + private UpDownloaderFactory factory; + + @PostConstruct + public void doRegister() { + factory.registerUpDownloader(UploadStoreTypeEnum.LOCAL_SYSTEM, this); + } + + @Override + public void doDownload( + String rootBaseDir, + String modelName, + String fieldName, + String fileName, + Boolean asImage, + HttpServletResponse response) { + String uploadPath = makeFullPath(rootBaseDir, modelName, fieldName, asImage); + String fullFileanme = uploadPath + "/" + fileName; + this.downloadInternal(fullFileanme, fileName, response); + } + + @Override + public void doDownload( + String rootBaseDir, + String uriPath, + String fileName, + HttpServletResponse response) throws IOException { + StringBuilder pathBuilder = new StringBuilder(128); + if (StrUtil.isNotBlank(rootBaseDir)) { + pathBuilder.append(rootBaseDir); + } + if (StrUtil.isNotBlank(uriPath)) { + pathBuilder.append(uriPath); + } + pathBuilder.append("/"); + String fullFileanme = pathBuilder.append(fileName).toString(); + this.downloadInternal(fullFileanme, fileName, response); + } + + @Override + public UploadResponseInfo doUpload( + String serviceContextPath, + String rootBaseDir, + String modelName, + String fieldName, + Boolean asImage, + MultipartFile uploadFile) throws IOException { + String uploadPath = makeFullPath(rootBaseDir, modelName, fieldName, asImage); + return this.doUploadInternally(serviceContextPath, uploadPath, asImage, uploadFile); + } + + @Override + public UploadResponseInfo doUpload( + String serviceContextPath, + String rootBaseDir, + String uriPath, + MultipartFile uploadFile) throws IOException { + String uploadPath = makeFullPath(rootBaseDir, uriPath); + return this.doUploadInternally(serviceContextPath, uploadPath, false, uploadFile); + } + + /** + * 判断filename参数指定的文件名,是否被包含在fileInfoJson参数中。 + * + * @param fileInfoJson 内部类UploadFileInfo的JSONArray数组。 + * @param filename 被包含的文件名。 + * @return 存在返回true,否则false。 + */ + public static boolean containFile(String fileInfoJson, String filename) { + if (StringUtils.isAnyBlank(fileInfoJson, filename)) { + return false; + } + List fileInfoList = JSON.parseArray(fileInfoJson, UploadResponseInfo.class); + if (CollectionUtils.isNotEmpty(fileInfoList)) { + for (UploadResponseInfo fileInfo : fileInfoList) { + if (StringUtils.equals(filename, fileInfo.getFilename())) { + return true; + } + } + } + return false; + } + + private UploadResponseInfo doUploadInternally( + String serviceContextPath, + String uploadPath, + Boolean asImage, + MultipartFile uploadFile) throws IOException { + UploadResponseInfo responseInfo = super.verifyUploadArgument(asImage, uploadFile); + if (BooleanUtil.isTrue(responseInfo.getUploadFailed())) { + return responseInfo; + } + responseInfo.setUploadPath(uploadPath); + fillUploadResponseInfo(responseInfo, serviceContextPath, uploadFile.getOriginalFilename()); + try { + byte[] bytes = uploadFile.getBytes(); + StringBuilder sb = new StringBuilder(256); + sb.append(uploadPath).append("/").append(responseInfo.getFilename()); + Path path = Paths.get(sb.toString()); + // 如果没有files文件夹,则创建 + if (!Files.isWritable(path)) { + Files.createDirectories(Paths.get(uploadPath)); + } + // 文件写入指定路径 + Files.write(path, bytes); + } catch (IOException e) { + log.error("Failed to write uploaded file [" + uploadFile.getOriginalFilename() + " ].", e); + responseInfo.setUploadFailed(true); + responseInfo.setErrorMessage(ErrorCodeEnum.INVALID_UPLOAD_FILE_IOERROR.getErrorMessage()); + return responseInfo; + } + return responseInfo; + } + + private void downloadInternal(String fullFileanme, String fileName, HttpServletResponse response) { + File file = new File(fullFileanme); + if (!file.exists()) { + log.warn("Download file [" + fullFileanme + "] failed, no file found!"); + response.setStatus(HttpServletResponse.SC_NOT_FOUND); + return; + } + response.setHeader("content-type", "application/octet-stream"); + response.setContentType("application/octet-stream"); + response.setHeader("Content-Disposition", "attachment;filename=" + fileName); + byte[] buff = new byte[2048]; + try (OutputStream os = response.getOutputStream(); + BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file))) { + int i = bis.read(buff); + while (i != -1) { + os.write(buff, 0, i); + os.flush(); + i = bis.read(buff); + } + } catch (IOException e) { + log.error("Failed to call LocalUpDownloader.doDownload", e); + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/upload/UpDownloaderFactory.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/upload/UpDownloaderFactory.java new file mode 100644 index 00000000..323880d4 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/upload/UpDownloaderFactory.java @@ -0,0 +1,49 @@ +package com.orangeforms.common.core.upload; + +import org.springframework.stereotype.Component; + +import java.util.EnumMap; +import java.util.Map; + +/** + * 业务对象根据上传下载存储类型,获取上传下载对象的工厂类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class UpDownloaderFactory { + + private final Map upDownloaderMap = new EnumMap<>(UploadStoreTypeEnum.class); + + /** + * 根据存储类型获取上传下载对象。 + * @param storeType 存储类型。 + * @return 匹配的上传下载对象。 + */ + public BaseUpDownloader get(UploadStoreTypeEnum storeType) { + BaseUpDownloader upDownloader = upDownloaderMap.get(storeType); + if (upDownloader == null) { + throw new UnsupportedOperationException( + "The storeType [" + storeType.name() + "] isn't supported, please add dependency jar first."); + } + return upDownloader; + } + + /** + * 注册上传下载对象到工厂。 + * + * @param storeType 存储类型。 + * @param upDownloader 上传下载对象。 + */ + public void registerUpDownloader(UploadStoreTypeEnum storeType, BaseUpDownloader upDownloader) { + if (storeType == null || upDownloader == null) { + throw new IllegalArgumentException("The Argument can't be NULL."); + } + if (upDownloaderMap.containsKey(storeType)) { + throw new UnsupportedOperationException( + "The storeType [" + storeType.name() + "] has been registered already."); + } + upDownloaderMap.put(storeType, upDownloader); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/upload/UploadResponseInfo.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/upload/UploadResponseInfo.java new file mode 100644 index 00000000..3610a541 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/upload/UploadResponseInfo.java @@ -0,0 +1,33 @@ +package com.orangeforms.common.core.upload; + +import lombok.Data; + +/** + * 数据上传操作的应答信息对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class UploadResponseInfo { + /** + * 上传是否出现错误。 + */ + private Boolean uploadFailed = false; + /** + * 具体错误信息。 + */ + private String errorMessage; + /** + * 返回前端的下载url。 + */ + private String downloadUri; + /** + * 上传文件所在路径。 + */ + private String uploadPath; + /** + * 返回给前端的文件名。 + */ + private String filename; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/upload/UploadStoreInfo.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/upload/UploadStoreInfo.java new file mode 100644 index 00000000..32d7fed6 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/upload/UploadStoreInfo.java @@ -0,0 +1,22 @@ +package com.orangeforms.common.core.upload; + +import lombok.Data; + +/** + * 上传数据存储信息对象。这里之所以使用对象,主要是便于今后扩展。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class UploadStoreInfo { + + /** + * 是否支持上传。 + */ + private boolean supportUpload; + /** + * 上传数据存储类型。 + */ + private UploadStoreTypeEnum storeType; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/upload/UploadStoreTypeEnum.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/upload/UploadStoreTypeEnum.java new file mode 100644 index 00000000..62c1d2d7 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/upload/UploadStoreTypeEnum.java @@ -0,0 +1,31 @@ +package com.orangeforms.common.core.upload; + +/** + * 上传数据存储介质类型枚举。 + * + * @author Jerry + * @date 2024-07-02 + */ +public enum UploadStoreTypeEnum { + + /** + * 本地系统。 + */ + LOCAL_SYSTEM, + /** + * minio分布式存储。 + */ + MINIO_SYSTEM, + /** + * 阿里云OSS存储。 + */ + ALIYUN_OSS_SYTEM, + /** + * 腾讯云COS存储。 + */ + QCLOUD_COS_SYTEM, + /** + * 华为云OBS存储。 + */ + HUAWEI_OBS_SYSTEM +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/AopTargetUtil.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/AopTargetUtil.java new file mode 100644 index 00000000..48844678 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/AopTargetUtil.java @@ -0,0 +1,81 @@ +package com.orangeforms.common.core.util; + +import cn.hutool.core.util.ReflectUtil; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.aop.framework.AdvisedSupport; +import org.springframework.aop.framework.AopProxy; +import org.springframework.aop.support.AopUtils; + +import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.stream.Collectors; + +/** + * 获取JDK动态代理/CGLIB代理对象代理的目标对象的工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class AopTargetUtil { + + /** + * 获取参数对象代理的目标对象。 + * + * @param proxy 代理对象 + * @return 代理的目标对象。 + */ + public static Object getTarget(Object proxy) { + if (!AopUtils.isAopProxy(proxy)) { + return proxy; + } + try { + if (AopUtils.isJdkDynamicProxy(proxy)) { + return getJdkDynamicProxyTargetObject(proxy); + } else { + return getCglibProxyTargetObject(proxy); + } + } catch (Exception e) { + log.error("Failed to call getJdkDynamicProxyTargetObject or getCglibProxyTargetObject", e); + return null; + } + } + + /** + * 获取被织入完整的方法名。 + * + * @param joinPoint 织入方法对象。 + * @return 被织入完整的方法名。 + */ + public static String getFullMethodName(ProceedingJoinPoint joinPoint) { + StringBuilder sb = new StringBuilder(512); + MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); + sb.append(methodSignature.getMethod().getName()).append("("); + String paramTypes = Arrays.stream(methodSignature.getParameterTypes()) + .map(Class::getSimpleName).collect(Collectors.joining(", ")); + sb.append(paramTypes).append(")"); + return sb.toString(); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private AopTargetUtil() { + } + + private static Object getCglibProxyTargetObject(Object proxy) throws Exception { + Field h = proxy.getClass().getDeclaredField("CGLIB$CALLBACK_0"); + Object dynamicAdvisedInterceptor = ReflectUtil.getFieldValue(proxy, h); + Field advised = dynamicAdvisedInterceptor.getClass().getDeclaredField("advised"); + return ((AdvisedSupport) ReflectUtil.getFieldValue(dynamicAdvisedInterceptor, advised)).getTargetSource().getTarget(); + } + + private static Object getJdkDynamicProxyTargetObject(Object proxy) throws Exception { + Field h = proxy.getClass().getSuperclass().getDeclaredField("h"); + AopProxy aopProxy = (AopProxy) ReflectUtil.getFieldValue(proxy, h); + Field advised = aopProxy.getClass().getDeclaredField("advised"); + return ((AdvisedSupport) ReflectUtil.getFieldValue(aopProxy, advised)).getTargetSource().getTarget(); + } +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/ApplicationContextHolder.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/ApplicationContextHolder.java new file mode 100644 index 00000000..2a53c923 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/ApplicationContextHolder.java @@ -0,0 +1,88 @@ +package com.orangeforms.common.core.util; + +import com.orangeforms.common.core.exception.MyRuntimeException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.lang.NonNull; +import org.springframework.stereotype.Component; + +import java.util.Collection; + +/** + * Spring 系统启动应用感知对象,主要用于获取Spring Bean的上下文对象,后续的代码中可以直接查找系统中加载的Bean对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class ApplicationContextHolder implements ApplicationContextAware { + + private static ApplicationContext applicationContext; + + /** + * Spring 启动的过程中会自动调用,并将应用上下文对象赋值进来。 + * + * @param applicationContext 应用上下文对象,可通过该对象查找Spring中已经加载的Bean。 + */ + @Override + public void setApplicationContext(@NonNull ApplicationContext applicationContext) { + doSetApplicationContext(applicationContext); + } + + /** + * 获取应用上下文对象。 + * + * @return 应用上下文。 + */ + public static ApplicationContext getApplicationContext() { + assertApplicationContext(); + return applicationContext; + } + + /** + * 根据BeanName,获取Bean对象。 + * + * @param beanName Bean名称。 + * @param 返回的Bean类型。 + * @return Bean对象。 + */ + @SuppressWarnings("unchecked") + public static T getBean(String beanName) { + assertApplicationContext(); + return (T) applicationContext.getBean(beanName); + } + + /** + * 根据Bean的ClassType,获取Bean对象。 + * + * @param beanType Bean的Class类型。 + * @param 返回的Bean类型。 + * @return Bean对象。 + */ + public static T getBean(Class beanType) { + assertApplicationContext(); + return applicationContext.getBean(beanType); + } + + /** + * 根据Bean的ClassType,获取Bean对象列表。 + * + * @param beanType Bean的Class类型。 + * @param 返回的Bean类型。 + * @return Bean对象列表。 + */ + public static Collection getBeanListOfType(Class beanType) { + assertApplicationContext(); + return applicationContext.getBeansOfType(beanType).values(); + } + + private static void assertApplicationContext() { + if (ApplicationContextHolder.applicationContext == null) { + throw new MyRuntimeException("applicaitonContext属性为null,请检查是否注入了ApplicationContextHolder!"); + } + } + + private static void doSetApplicationContext(ApplicationContext applicationContext) { + ApplicationContextHolder.applicationContext = applicationContext; + } +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/ContextUtil.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/ContextUtil.java new file mode 100644 index 00000000..95382bde --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/ContextUtil.java @@ -0,0 +1,51 @@ +package com.orangeforms.common.core.util; + +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +/** + * 获取Servlet HttpRequest和HttpResponse的工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class ContextUtil { + + /** + * 判断当前是否处于HttpServletRequest上下文环境。 + * + * @return 是返回true,否则false。 + */ + public static boolean hasRequestContext() { + return RequestContextHolder.getRequestAttributes() != null; + } + + /** + * 获取Servlet请求上下文的HttpRequest对象。 + * + * @return 请求上下文中的HttpRequest对象。 + */ + public static HttpServletRequest getHttpRequest() { + ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + return attributes == null ? null : attributes.getRequest(); + } + + /** + * 获取Servlet请求上下文的HttpResponse对象。 + * + * @return 请求上下文中的HttpResponse对象。 + */ + public static HttpServletResponse getHttpResponse() { + ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + return attributes == null ? null : attributes.getResponse(); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private ContextUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/DataSourceResolver.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/DataSourceResolver.java new file mode 100644 index 00000000..256ddf5a --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/DataSourceResolver.java @@ -0,0 +1,21 @@ +package com.orangeforms.common.core.util; + +/** + * 基于自定义解析规则的多数据源解析接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface DataSourceResolver { + + /** + * 动态解析方法。实现类可以根据当前的请求,或者上下文环境进行动态解析。 + * + * @param arg 可选的入参。MyDataSourceResolver注解中的arg参数。 + * @param intArg 可选的整型入参。MyDataSourceResolver注解中的intArg参数。 + * @param methodName 被织入方法名称。 + * @param methodArgs 被织入方法的所有参数。 + * @return 返回用于多数据源切换的类型值。DataSourceResolveAspect 切面方法会根据该返回值和配置信息,进行多数据源切换。 + */ + Integer resolve(String arg, Integer intArg, String methodName, Object[] methodArgs); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/DefaultDataSourceResolver.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/DefaultDataSourceResolver.java new file mode 100644 index 00000000..b11e16fc --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/DefaultDataSourceResolver.java @@ -0,0 +1,55 @@ +package com.orangeforms.common.core.util; + +import org.springframework.stereotype.Component; + +/** + * 常量值指向的数据源。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class DefaultDataSourceResolver implements DataSourceResolver { + + private static final ThreadLocal DEFAULT_CONTEXT_HOLDER = new ThreadLocal<>(); + + @Override + public Integer resolve(String arg, Integer intArg, String methodName, Object[] methodArgs) { + Integer datasourceType = DEFAULT_CONTEXT_HOLDER.get(); + return datasourceType != null ? datasourceType : intArg; + } + + /** + * 设置报表数据源类型值。 + * + * @param type 数据源类型 + * @return 原有数据源类型,如果第一次设置则返回null。 + */ + public static Integer setDataSourceType(Integer type) { + Integer datasourceType = DEFAULT_CONTEXT_HOLDER.get(); + DEFAULT_CONTEXT_HOLDER.set(type); + return datasourceType; + } + + /** + * 获取当前报表数据库操作执行线程的数据源类型,同时由动态数据源的路由函数调用。 + * + * @return 数据源类型。 + */ + public static Integer getDataSourceType() { + return DEFAULT_CONTEXT_HOLDER.get(); + } + + /** + * 清除线程本地变量,以免内存泄漏。 + + * @param originalType 原有的数据源类型,如果该值为null,则情况本地化变量。 + */ + public static void unset(Integer originalType) { + if (originalType == null) { + DEFAULT_CONTEXT_HOLDER.remove(); + } else { + DEFAULT_CONTEXT_HOLDER.set(originalType); + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/ExportUtil.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/ExportUtil.java new file mode 100644 index 00000000..b3d37aa8 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/ExportUtil.java @@ -0,0 +1,111 @@ +package com.orangeforms.common.core.util; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.io.IoUtil; +import cn.hutool.poi.excel.ExcelUtil; +import cn.hutool.poi.excel.ExcelWriter; +import cn.jimmyshi.beanquery.BeanQuery; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.exception.MyRuntimeException; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.csv.CSVFormat; +import org.apache.commons.csv.CSVPrinter; +import org.apache.commons.io.FilenameUtils; + +import jakarta.servlet.ServletOutputStream; +import jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.Writer; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 导出工具类,目前支持xlsx和csv两种类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class ExportUtil { + + /** + * 数据导出。目前仅支持xlsx和csv。 + * + * @param dataList 导出数据列表。 + * @param selectFieldMap 导出的数据字段,key为对象字段名称,value为中文标题名称。 + * @param filename 导出文件名。 + * @param 数据对象类型。 + * @throws IOException 文件操作失败。 + */ + public static void doExport( + Collection dataList, Map selectFieldMap, String filename) throws IOException { + if (CollUtil.isEmpty(dataList)) { + return; + } + StringBuilder sb = new StringBuilder(128); + for (Map.Entry e : selectFieldMap.entrySet()) { + sb.append(e.getKey()).append(" as ").append(e.getValue()).append(", "); + } + // 去掉末尾的逗号 + String selectFieldString = sb.substring(0, sb.length() - 2); + // 写出数据到xcel格式的输出流 + List> resultList = BeanQuery.select(selectFieldString).executeFrom(dataList); + normalizeMultiSelectList(resultList); + // 构建HTTP输出流参数 + HttpServletResponse response = ContextUtil.getHttpResponse(); + response.setHeader("content-type", "application/octet-stream"); + response.setContentType("application/octet-stream"); + response.setHeader("Content-Disposition", "attachment;filename=" + filename); + if (ApplicationConstant.XLSX_EXT.equals(FilenameUtils.getExtension(filename))) { + ServletOutputStream out = response.getOutputStream(); + ExcelWriter writer = ExcelUtil.getWriter(true); + writer.setRowHeight(-1, 30); + writer.setColumnWidth(-1, 30); + writer.setColumnWidth(1, 20); + writer.write(resultList); + writer.flush(out); + writer.close(); + IoUtil.close(out); + } else if (ApplicationConstant.CSV_EXT.equals(FilenameUtils.getExtension(filename))) { + Collection headerList = selectFieldMap.values(); + String[] headerArray = new String[headerList.size()]; + headerList.toArray(headerArray); + CSVFormat format = CSVFormat.DEFAULT.withHeader(headerArray); + response.setCharacterEncoding(StandardCharsets.UTF_8.name()); + try (Writer out = response.getWriter(); CSVPrinter printer = new CSVPrinter(out, format)) { + for (Map o : resultList) { + for (Map.Entry entry : o.entrySet()) { + printer.print(entry.getValue()); + } + printer.println(); + } + printer.flush(); + } catch (Exception e) { + log.error("Failed to call ExportUtil.doExport", e); + } + } else { + throw new MyRuntimeException("不支持的导出文件类型!"); + } + } + + @SuppressWarnings("unchecked") + private static void normalizeMultiSelectList(List> resultList) { + for (Map data : resultList) { + for (Map.Entry entry : data.entrySet()) { + if (entry.getValue() instanceof List) { + List> dictMapList = ((List>) entry.getValue()); + List nameList = dictMapList.stream() + .map(item -> item.get("name").toString()).collect(Collectors.toList()); + data.put(entry.getKey(), CollUtil.join(nameList, ",")); + } + } + } + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private ExportUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/ImportUtil.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/ImportUtil.java new file mode 100644 index 00000000..baa79c78 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/ImportUtil.java @@ -0,0 +1,352 @@ +package com.orangeforms.common.core.util; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.io.file.FileNameUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.ReflectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.poi.excel.ExcelUtil; +import cn.hutool.poi.excel.sax.handler.RowHandler; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.orangeforms.common.core.annotation.RelationConstDict; +import com.orangeforms.common.core.annotation.RelationDict; +import com.orangeforms.common.core.annotation.RelationGlobalDict; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.exception.MyRuntimeException; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.joda.time.DateTime; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.io.IOException; +import java.io.Serializable; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.math.BigDecimal; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 导入工具类,目前支持xlsx和xls两种类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class ImportUtil { + + /** + * 根据实体类的Class类型,生成导入的头信息。 + * + * @param modelClazz 实体对象的Class类型。 + * @param ignoreFields 忽略的字段名集合,如创建时间、创建人、更新时间、更新人等。 + * @param 实体对象类型。 + * @return 创建后的导入头信息列表。 + */ + public static List makeHeaderInfoList(Class modelClazz, Set ignoreFields) { + List resultList = new LinkedList<>(); + Field[] fields = ReflectUtil.getFields(modelClazz); + int index = 0; + for (Field field : fields) { + int modifiers = field.getModifiers(); + // transient类型的字段不能作为查询条件,静态字段和逻辑删除都不考虑。需要忽略的字段也要跳过。 + int transientMask = 128; + if ((modifiers & transientMask) == 1 + || Modifier.isStatic(modifiers) + || field.getAnnotation(TableId.class) != null + || field.getAnnotation(TableLogic.class) != null + || CollUtil.contains(ignoreFields, field.getName())) { + continue; + } + TableField tableField = field.getAnnotation(TableField.class); + if (tableField == null || tableField.exist()) { + ImportHeaderInfo headerInfo = new ImportHeaderInfo(); + headerInfo.fieldName = field.getName(); + headerInfo.index = index++; + makeHeaderInfoFieldTypeByField(field, headerInfo); + resultList.add(headerInfo); + } + } + return resultList; + } + + /** + * 保存导入文件。 + * + * @param baseDir 导入文件本地缓存的根目录。 + * @param subDir 导入文件本地缓存的子目录。 + * @param importFile 导入的文件。 + * @return 保存的本地文件名。 + */ + public static String saveImportFile( + String baseDir, String subDir, MultipartFile importFile) throws IOException { + StringBuilder sb = new StringBuilder(256); + sb.append(baseDir); + if (!StrUtil.endWith(baseDir, "/")) { + sb.append("/"); + } + sb.append("importedFile/"); + if (StrUtil.isNotBlank(subDir)) { + sb.append(subDir); + if (!StrUtil.endWith(subDir, "/")) { + sb.append("/"); + } + } + String pathname = sb.toString(); + sb.append(new DateTime().toString("yyyy-MM-dd-HH-mm-")); + sb.append(MyCommonUtil.generateUuid()) + .append(".").append(FileNameUtil.getSuffix(importFile.getOriginalFilename())); + String fullname = sb.toString(); + try { + byte[] bytes = importFile.getBytes(); + Path path = Paths.get(fullname); + // 如果没有files文件夹,则创建 + if (!Files.isWritable(path)) { + Files.createDirectories(Paths.get(pathname)); + } + // 文件写入指定路径 + Files.write(path, bytes); + } catch (IOException e) { + log.error("Failed to write imported file [" + importFile.getOriginalFilename() + " ].", e); + throw e; + } + return fullname; + } + + /** + * 导入指定的excel,基于SAX方式解析后返回数据列表。 + * + * @param headers 头信息数组。 + * @param skipHeader 是否跳过第一行,通常改行为头信息。 + * @param filename 文件名。 + * @return 解析后数据列表。 + */ + public static List> doImport( + ImportHeaderInfo[] headers, boolean skipHeader, String filename) { + Assert.notNull(headers); + Assert.isTrue(StrUtil.isNotBlank(filename)); + List> resultList = new LinkedList<>(); + ExcelUtil.readBySax(new File(filename), 0, createRowHandler(headers, skipHeader, resultList)); + return resultList; + } + + /** + * 导入指定的excel,基于SAX方式解析后返回Bean类型的数据列表。 + * + * @param headers 头信息数组。 + * @param skipHeader 是否跳过第一行,通常改行为头信息。 + * @param filename 文件名。 + * @param clazz Bean的Class类型。 + * @param translateDictFieldSet 需要进行反向翻译的字典字段集合。 + * @return 解析后数据列表。 + */ + public static List doImport( + ImportHeaderInfo[] headers, + boolean skipHeader, + String filename, + Class clazz, + Set translateDictFieldSet) { + // 这里将需要进行字典反向翻译的字段类型改为String,否则使用原有的字典Id类型时,无法正确执行下面的doImport方法。 + if (CollUtil.isNotEmpty(translateDictFieldSet)) { + for (ImportHeaderInfo header : headers) { + if (translateDictFieldSet.contains(header.fieldName)) { + header.fieldType = STRING_TYPE; + } + } + } + List> resultList = doImport(headers, skipHeader, filename); + if (CollUtil.isNotEmpty(translateDictFieldSet)) { + translateDictFieldSet.forEach(c -> doTranslateDict(resultList, clazz, c)); + } + return MyModelUtil.mapToBeanList(resultList, clazz); + } + + /** + * 转换数据列表中,需要进行反向字典翻译的字段。 + * + * @param dataList 数据列表。 + * @param modelClass 对象模型。 + * @param fieldName 需要进行字典反向翻译的字段名。注意,该字段为需要翻译替换的Java字段名,与此同时, + * 该字段 + DictMap后缀的字段名,必须被RelationConstDict和RelationDict注解标记。 + */ + @SuppressWarnings("unchecked") + public static void doTranslateDict(List> dataList, Class modelClass, String fieldName) { + if (CollUtil.isEmpty(dataList)) { + return; + } + Field field = ReflectUtil.getField(modelClass, fieldName + "DictMap"); + Assert.notNull(field); + Map inversedDictMap; + if (field.isAnnotationPresent(RelationConstDict.class)) { + RelationConstDict r = field.getAnnotation(RelationConstDict.class); + Field f = ReflectUtil.getField(r.constantDictClass(), "DICT_MAP"); + Map dictMap = (Map) ReflectUtil.getStaticFieldValue(f); + inversedDictMap = MapUtil.inverse(dictMap); + } else if (field.isAnnotationPresent(RelationDict.class)) { + RelationDict r = field.getAnnotation(RelationDict.class); + String slaveServiceName = r.slaveServiceName(); + if (StrUtil.isBlank(slaveServiceName)) { + slaveServiceName = r.slaveModelClass().getSimpleName() + "Service"; + } + BaseService service = + ApplicationContextHolder.getBean(StrUtil.lowerFirst(slaveServiceName)); + List dictDataList = service.getAllList(); + List> dataMapList = MyModelUtil.beanToMapList(dictDataList); + inversedDictMap = new HashMap<>(dataMapList.size()); + dataMapList.forEach(d -> + inversedDictMap.put(d.get(r.slaveNameField()).toString(), d.get(r.slaveIdField()))); + } else if (field.isAnnotationPresent(RelationGlobalDict.class)) { + RelationGlobalDict r = field.getAnnotation(RelationGlobalDict.class); + BaseService s = ApplicationContextHolder.getBean("globalDictService"); + Method m = ReflectUtil.getMethodByName(s.getClass(), "getGlobalDictItemDictMapFromCache"); + Map dictMap = ReflectUtil.invoke(s, m, r.dictCode(), null); + inversedDictMap = MapUtil.inverse(dictMap); + } else { + throw new UnsupportedOperationException("Only Support RelationConstDict and RelationDict Field"); + } + if (MapUtil.isEmpty(inversedDictMap)) { + log.warn("Dict Data List is EMPTY."); + return; + } + for (Map data : dataList) { + Object value = data.get(fieldName); + if (value != null) { + Object newValue = inversedDictMap.get(value.toString()); + if (newValue != null) { + data.put(fieldName, newValue); + } + } + } + } + + private static void makeHeaderInfoFieldTypeByField(Field field, ImportHeaderInfo headerInfo) { + if (field.getType().equals(Integer.class)) { + headerInfo.fieldType = INT_TYPE; + } else if (field.getType().equals(Long.class)) { + headerInfo.fieldType = LONG_TYPE; + } else if (field.getType().equals(String.class)) { + headerInfo.fieldType = STRING_TYPE; + } else if (field.getType().equals(Boolean.class)) { + headerInfo.fieldType = BOOLEAN_TYPE; + } else if (field.getType().equals(Date.class)) { + headerInfo.fieldType = DATE_TYPE; + } else if (field.getType().equals(Double.class)) { + headerInfo.fieldType = DOUBLE_TYPE; + } else if (field.getType().equals(Float.class)) { + headerInfo.fieldType = FLOAT_TYPE; + } else if (field.getType().equals(BigDecimal.class)) { + headerInfo.fieldType = BIG_DECIMAL_TYPE; + } else { + throw new MyRuntimeException("Unsupport Import FieldType"); + } + } + + private static RowHandler createRowHandler( + ImportHeaderInfo[] headers, boolean skipHeader, List> resultList) { + return new MyRowHandler(headers, skipHeader, resultList); + } + + public static final int INT_TYPE = 0; + public static final int LONG_TYPE = 1; + public static final int STRING_TYPE = 2; + public static final int BOOLEAN_TYPE = 3; + public static final int DATE_TYPE = 4; + public static final int DOUBLE_TYPE = 5; + public static final int FLOAT_TYPE = 6; + public static final int BIG_DECIMAL_TYPE = 7; + + @NoArgsConstructor + @AllArgsConstructor + @Data + public static class ImportHeaderInfo { + /** + * 对应的Java实体对象属性名。 + */ + private String fieldName; + /** + * 对应的Java实体对象类型。 + */ + private Integer fieldType; + /** + * 0 表示excel中的第一列。 + */ + private Integer index; + } + + private static class MyRowHandler implements RowHandler { + private ImportHeaderInfo[] headers; + private Map headerInfoMap; + private boolean skipHeader; + private List> resultList; + + public MyRowHandler(ImportHeaderInfo[] headers, boolean skipHeader, List> resultList) { + this.headers = headers; + this.skipHeader = skipHeader; + this.resultList = resultList; + this.headerInfoMap = Arrays.stream(headers) + .collect(Collectors.toMap(ImportHeaderInfo::getIndex, c -> c)); + } + + @Override + public void handle(int sheetIndex, long rowIndex, List rowList) { + if (this.skipHeader && rowIndex == 0) { + return; + } + int i = 0; + Map data = new HashMap<>(headers.length); + for (Object rowData : rowList) { + ImportHeaderInfo headerInfo = this.headerInfoMap.get(i++); + if (headerInfo == null) { + continue; + } + switch (headerInfo.fieldType) { + case INT_TYPE: + data.put(headerInfo.fieldName, Convert.toInt(rowData)); + break; + case LONG_TYPE: + data.put(headerInfo.fieldName, Convert.toLong(rowData)); + break; + case STRING_TYPE: + data.put(headerInfo.fieldName, Convert.toStr(rowData)); + break; + case BOOLEAN_TYPE: + data.put(headerInfo.fieldName, Convert.toBool(rowData)); + break; + case DATE_TYPE: + data.put(headerInfo.fieldName, Convert.toDate(rowData)); + break; + case DOUBLE_TYPE: + data.put(headerInfo.fieldName, Convert.toDouble(rowData)); + break; + case FLOAT_TYPE: + data.put(headerInfo.fieldName, Convert.toFloat(rowData)); + break; + case BIG_DECIMAL_TYPE: + data.put(headerInfo.fieldName, Convert.toBigDecimal(rowData)); + break; + default: + throw new MyRuntimeException( + "Invalid ImportHeaderInfo.fieldType [" + headerInfo.fieldType + "]."); + } + } + resultList.add(data); + } + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private ImportUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/IpUtil.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/IpUtil.java new file mode 100644 index 00000000..c9ac471f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/IpUtil.java @@ -0,0 +1,104 @@ +package com.orangeforms.common.core.util; + +import cn.hutool.core.util.StrUtil; +import lombok.extern.slf4j.Slf4j; + +import jakarta.servlet.http.HttpServletRequest; +import java.net.Inet6Address; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.SocketException; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; + +/** + * Ip工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class IpUtil { + + private static final String UNKNOWN = "unknown"; + + /** + * 通过Servlet的HttpRequest对象获取Ip地址。 + * + * @param request HttpRequest对象。 + * @return 本次请求的Ip地址。 + */ + public static String getRemoteIpAddress(HttpServletRequest request) { + String ip = null; + // X-Forwarded-For:Squid 服务代理 + String ipAddresses = request.getHeader("X-Forwarded-For"); + if (StrUtil.isBlank(ipAddresses) || UNKNOWN.equalsIgnoreCase(ipAddresses)) { + // Proxy-Client-IP:apache 服务代理 + ipAddresses = request.getHeader("Proxy-Client-IP"); + } + if (StrUtil.isBlank(ipAddresses) || UNKNOWN.equalsIgnoreCase(ipAddresses)) { + ipAddresses = request.getHeader("HTTP_X_FORWARDED_FOR"); + } + if (StrUtil.isBlank(ipAddresses) || UNKNOWN.equalsIgnoreCase(ipAddresses)) { + // WL-Proxy-Client-IP:weblogic 服务代理 + ipAddresses = request.getHeader("WL-Proxy-Client-IP"); + } + if (StrUtil.isBlank(ipAddresses) || UNKNOWN.equalsIgnoreCase(ipAddresses)) { + // HTTP_CLIENT_IP:有些代理服务器 + ipAddresses = request.getHeader("HTTP_CLIENT_IP"); + } + if (StrUtil.isBlank(ipAddresses) || UNKNOWN.equalsIgnoreCase(ipAddresses)) { + // X-Real-IP:nginx服务代理 + ipAddresses = request.getHeader("X-Real-IP"); + } + // 有些网络通过多层代理,那么获取到的ip就会有多个,一般都是通过逗号(,)分割开来,并且第一个ip为客户端的真实IP + if (StrUtil.isNotBlank(ipAddresses)) { + ip = ipAddresses.split(",")[0]; + } + // 还是不能获取到,最后再通过request.getRemoteAddr();获取 + if (StrUtil.isBlank(ipAddresses) || UNKNOWN.equalsIgnoreCase(ipAddresses)) { + ip = request.getRemoteAddr(); + } + return ip; + } + + public static String getFirstLocalIpAddress() { + String ip; + try { + List ipList = getHostAddress(); + // default the first + ip = (!ipList.isEmpty()) ? ipList.get(0) : ""; + } catch (Exception ex) { + ip = ""; + log.error("Failed to call ", ex); + } + return ip; + } + + private static List getHostAddress() throws SocketException { + List ipList = new ArrayList<>(5); + Enumeration interfaces = NetworkInterface.getNetworkInterfaces(); + while (interfaces.hasMoreElements()) { + NetworkInterface ni = interfaces.nextElement(); + Enumeration allAddress = ni.getInetAddresses(); + while (allAddress.hasMoreElements()) { + InetAddress address = allAddress.nextElement(); + // skip the IPv6 addr + // skip the IPv6 addr + if (address.isLoopbackAddress() || address instanceof Inet6Address) { + continue; + } + String hostAddress = address.getHostAddress(); + ipList.add(hostAddress); + } + } + return ipList; + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private IpUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/JwtUtil.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/JwtUtil.java new file mode 100644 index 00000000..84e23a06 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/JwtUtil.java @@ -0,0 +1,112 @@ +package com.orangeforms.common.core.util; + +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.security.Keys; +import lombok.extern.slf4j.Slf4j; + +import javax.crypto.SecretKey; +import java.util.Date; +import java.util.Map; + +/** + * 基于JWT的Token生成工具类 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class JwtUtil { + + private static final String TOKEN_PREFIX = "Bearer "; + private static final String CLAIM_KEY_CREATEDTIME = "CreatedTime"; + + /** + * Token缺省过期时间是30分钟 + */ + private static final Long TOKEN_EXPIRATION = 1800000L; + /** + * 缺省情况下,Token会每5分钟被刷新一次 + */ + private static final Long REFRESH_TOKEN_INTERVAL = 300000L; + + /** + * 生成加密后的JWT令牌,生成的结果中包含令牌前缀,如"Bearer " + * + * @param claims 令牌中携带的数据 + * @param expirationMillisecond 过期的毫秒数 + * @return 生成后的令牌信息 + */ + public static String generateToken(Map claims, long expirationMillisecond, String signingKey) { + // 自动添加token的创建时间 + long createTime = System.currentTimeMillis(); + claims.put(CLAIM_KEY_CREATEDTIME, createTime); + SecretKey sk = Keys.hmacShaKeyFor(signingKey.getBytes()); + String token = Jwts.builder().claims(claims) + .signWith(sk, Jwts.SIG.HS256) + .expiration(new Date(createTime + expirationMillisecond)) + .compact(); + return TOKEN_PREFIX + token; + } + + /** + * 生成加密后的JWT令牌,生成的结果中包含令牌前缀,如"Bearer " + * + * @param claims 令牌中携带的数据 + * @return 生成后的令牌信息 + */ + public static String generateToken(Map claims, String signingKey) { + return generateToken(claims, TOKEN_EXPIRATION, signingKey); + } + + /** + * 获取token中的数据对象 + * + * @param token 令牌信息(需要包含令牌前缀,如"Bearer ") + * @return 令牌中的数据对象,解析视频返回null。 + */ + public static Claims parseToken(String token, String signingKey) { + if (token == null || !token.startsWith(TOKEN_PREFIX)) { + return null; + } + String tokenKey = token.substring(TOKEN_PREFIX.length()); + Claims claims = null; + try { + SecretKey sk = Keys.hmacShaKeyFor(signingKey.getBytes()); + claims = Jwts.parser().verifyWith(sk).build().parseSignedClaims(tokenKey).getPayload(); + } catch (Exception e) { + log.error("Token Expired", e); + } + return claims; + } + + /** + * 判断令牌是否过期 + * + * @param claims 令牌解密后的Map对象。 + * @return true 过期,否则false。 + */ + public static boolean isNullOrExpired(Claims claims) { + return claims == null || claims.getExpiration().before(new Date()); + } + + /** + * 判断解密后的Token payload是否需要被强制刷新,如果需要,则调用generateToken方法重新生成Token。 + * + * @param claims Token解密后payload数据 + * @return true 需要刷新,否则false + */ + public static boolean needToRefresh(Claims claims) { + if (claims == null) { + return false; + } + Long createTime = (Long) claims.get(CLAIM_KEY_CREATEDTIME); + return createTime == null || System.currentTimeMillis() - createTime > REFRESH_TOKEN_INTERVAL; + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private JwtUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/LogMessageUtil.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/LogMessageUtil.java new file mode 100644 index 00000000..b89dd09b --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/LogMessageUtil.java @@ -0,0 +1,33 @@ +package com.orangeforms.common.core.util; + +/** + * 拼接日志消息的工具类。 + * 主要目标是,尽量保证日志输出的统一性,同时也可以有效减少与日志信息相关的常量字符串, + * 提高代码的规范度和可维护性。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class LogMessageUtil { + + /** + * RPC调用错误格式。 + */ + private static final String RPC_ERROR_MSG_FORMAT = "RPC Failed with Error message [%s]"; + + /** + * 组装RPC调用的错误信息。 + * + * @param errorMsg 具体的错误信息。 + * @return 格式化后的错误信息。 + */ + public static String makeRpcError(String errorMsg) { + return String.format(RPC_ERROR_MSG_FORMAT, errorMsg); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private LogMessageUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/MaskFieldHandler.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/MaskFieldHandler.java new file mode 100644 index 00000000..e1d3bc4b --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/MaskFieldHandler.java @@ -0,0 +1,21 @@ +package com.orangeforms.common.core.util; + +/** + * 自定义脱敏处理器接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface MaskFieldHandler { + + /** + * 处理自定义的脱敏数据。可以根据表名和字段名,使用不同的自定义脱敏规则。 + * + * @param modelName 脱敏字段所在实体对象名。 + * @param fieldName 脱敏实体对象名中的字段属性名。 + * @param data 待脱敏的数据。 + * @param maskChar 脱敏掩码字符。 + * @return 脱敏后的数据。 + */ + String handleMask(String modelName, String fieldName, String data, char maskChar); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/MaskFieldUtil.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/MaskFieldUtil.java new file mode 100644 index 00000000..830aa2ff --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/MaskFieldUtil.java @@ -0,0 +1,203 @@ +package com.orangeforms.common.core.util; + +import cn.hutool.core.util.CharUtil; +import cn.hutool.core.util.StrUtil; + +/** + * 脱敏的工具类。具体实现的源码基本来自hutool的DesensitizedUtil, + * 只是因为我们需要支持自定义脱敏字符,因此需要重写hutool中的工具类方法。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class MaskFieldUtil { + + /** + * 【中文姓名】只显示第一个汉字,其他隐藏为2个星号,比如:李**。 + * + * @param fullName 姓名。 + * @param maskChar 遮掩字符。 + * @return 脱敏后的姓名。 + */ + public static String chineseName(String fullName, char maskChar) { + if (StrUtil.isBlank(fullName)) { + return StrUtil.EMPTY; + } + return StrUtil.replace(fullName, 1, fullName.length(), maskChar); + } + + /** + * 【身份证号】前1位 和后2位。 + * + * @param idCardNum 身份证。 + * @param front 保留:前面的front位数;从1开始。 + * @param end 保留:后面的end位数;从1开始。 + * @param maskChar 遮掩字符。 + * @return 脱敏后的身份证。 + */ + public static String idCardNum(String idCardNum, int front, int end, char maskChar) { + return noMaskPrefixAndSuffix(idCardNum, front, end, maskChar); + } + + /** + * 字符串的前front位和后end位的字符,不会被脱敏。 + * + * @param str 原字符串。 + * @param front 保留:前面的front位数;从1开始。 + * @param end 保留:后面的end位数;从1开始。 + * @param maskChar 遮掩字符。 + * @return 脱敏后的结果字符串。 + */ + public static String noMaskPrefixAndSuffix(String str, int front, int end, char maskChar) { + //身份证不能为空 + if (StrUtil.isBlank(str)) { + return StrUtil.EMPTY; + } + //需要截取的长度不能大于身份证号长度 + if ((front + end) > str.length()) { + return StrUtil.EMPTY; + } + //需要截取的不能小于0 + if (front < 0 || end < 0) { + return StrUtil.EMPTY; + } + return StrUtil.replace(str, front, str.length() - end, maskChar); + } + + /** + * 【固定电话 前四位,后两位。 + * + * @param num 固定电话。 + * @param maskChar 遮掩字符。 + * @return 脱敏后的固定电话。 + */ + public static String fixedPhone(String num, char maskChar) { + if (StrUtil.isBlank(num)) { + return StrUtil.EMPTY; + } + return StrUtil.replace(num, 4, num.length() - 2, maskChar); + } + + /** + * 【手机号码】前三位,后4位,其他隐藏,比如135****2210。 + * + * @param num 移动电话。 + * @param maskChar 遮掩字符。 + * @return 脱敏后的移动电话。 + */ + public static String mobilePhone(String num, char maskChar) { + if (StrUtil.isBlank(num)) { + return StrUtil.EMPTY; + } + return StrUtil.replace(num, 3, num.length() - 4, maskChar); + } + + /** + * 【地址】只显示到地区,不显示详细地址,比如:北京市海淀区****。 + * + * @param address 家庭住址。 + * @param sensitiveSize 敏感信息长度。 + * @param maskChar 遮掩字符。 + * @return 脱敏后的家庭地址。 + */ + public static String address(String address, int sensitiveSize, char maskChar) { + if (StrUtil.isBlank(address)) { + return StrUtil.EMPTY; + } + int length = address.length(); + return StrUtil.replace(address, length - sensitiveSize, length, maskChar); + } + + /** + * 【电子邮箱】邮箱前缀仅显示第一个字母,前缀其他隐藏,用星号代替,@及后面的地址显示,比如:d**@126.com。 + * + * @param email 邮箱。 + * @param maskChar 遮掩字符。 + * @return 脱敏后的邮箱。 + */ + public static String email(String email, char maskChar) { + if (StrUtil.isBlank(email)) { + return StrUtil.EMPTY; + } + int index = StrUtil.indexOf(email, '@'); + if (index <= 1) { + return email; + } + return StrUtil.replace(email, 1, index, maskChar); + } + + /** + * 【密码】密码的全部字符都用*代替,比如:******。 + * + * @param password 密码。 + * @return 脱敏后的密码。 + */ + public static String password(String password) { + if (StrUtil.isBlank(password)) { + return StrUtil.EMPTY; + } + return StrUtil.repeat('*', password.length()); + } + + /** + * 【中国车牌】车牌中间用*代替。 + * eg1:null -》 "" + * eg1:"" -》 "" + * eg3:苏D40000 -》 苏D4***0 + * eg4:陕A12345D -》 陕A1****D + * eg5:京A123 -》 京A123 如果是错误的车牌,不处理。 + * + * @param carLicense 完整的车牌号。 + * @param maskChar 遮掩字符。 + * @return 脱敏后的车牌。 + */ + public static String carLicense(String carLicense, char maskChar) { + if (StrUtil.isBlank(carLicense)) { + return StrUtil.EMPTY; + } + // 普通车牌 + if (carLicense.length() == 7) { + carLicense = StrUtil.replace(carLicense, 3, 6, maskChar); + } else if (carLicense.length() == 8) { + // 新能源车牌 + carLicense = StrUtil.replace(carLicense, 3, 7, maskChar); + } + return carLicense; + } + + /** + * 银行卡号脱敏。 + * eg: 1101 **** **** **** 3256。 + * + * @param bankCardNo 银行卡号。 + * @param maskChar 遮掩字符。 + * @return 脱敏之后的银行卡号。 + */ + public static String bankCard(String bankCardNo, char maskChar) { + if (StrUtil.isBlank(bankCardNo)) { + return bankCardNo; + } + bankCardNo = StrUtil.trim(bankCardNo); + if (bankCardNo.length() < 9) { + return bankCardNo; + } + final int length = bankCardNo.length(); + final int midLength = length - 8; + final StringBuilder buf = new StringBuilder(); + buf.append(bankCardNo, 0, 4); + for (int i = 0; i < midLength; ++i) { + if (i % 4 == 0) { + buf.append(CharUtil.SPACE); + } + buf.append(maskChar); + } + buf.append(CharUtil.SPACE).append(bankCardNo, length - 4, length); + return buf.toString(); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private MaskFieldUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/MyCommonUtil.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/MyCommonUtil.java new file mode 100644 index 00000000..fa97c514 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/MyCommonUtil.java @@ -0,0 +1,442 @@ +package com.orangeforms.common.core.util; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ReflectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.crypto.digest.DigestUtil; +import com.orangeforms.common.core.constant.AppDeviceType; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.validator.AddGroup; +import com.orangeforms.common.core.validator.UpdateGroup; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.ConstraintViolation; +import jakarta.validation.Validation; +import jakarta.validation.Validator; +import jakarta.validation.groups.Default; +import java.lang.reflect.Field; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 脚手架中常用的基本工具方法集合,一般而言工程内部使用的方法。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class MyCommonUtil { + + private static final Validator VALIDATOR; + + static { + VALIDATOR = Validation.buildDefaultValidatorFactory().getValidator(); + } + + /** + * 创建uuid。 + * + * @return 返回uuid。 + */ + public static String generateUuid() { + return UUID.randomUUID().toString().replace("-", ""); + } + + /** + * 对用户密码进行加盐后加密。 + * + * @param password 明文密码。 + * @param passwordSalt 盐值。 + * @return 加密后的密码。 + */ + public static String encrptedPassword(String password, String passwordSalt) { + return DigestUtil.md5Hex(password + passwordSalt); + } + + /** + * 这个方法一般用于Controller对于入口参数的基本验证。 + * 对于字符串,如果为空字符串,也将视为Blank,同时返回true。 + * + * @param objs 一组参数。 + * @return 返回是否存在null或空字符串的参数。 + */ + public static boolean existBlankArgument(Object...objs) { + for (Object obj : objs) { + if (MyCommonUtil.isBlankOrNull(obj)) { + return true; + } + } + return false; + } + + /** + * 结果和 existBlankArgument 相反。 + * + * @param objs 一组参数。 + * @return 返回是否存在null或空字符串的参数。 + */ + public static boolean existNotBlankArgument(Object...objs) { + for (Object obj : objs) { + if (!MyCommonUtil.isBlankOrNull(obj)) { + return true; + } + } + return false; + } + + /** + * 验证参数是否为空。 + * + * @param obj 待判断的参数。 + * @return 空或者null返回true,否则false。 + */ + public static boolean isBlankOrNull(Object obj) { + if (obj instanceof Collection) { + return CollUtil.isEmpty((Collection) obj); + } + return obj == null || (obj instanceof CharSequence && StrUtil.isBlank((CharSequence) obj)); + } + + /** + * 验证参数是否为非空。 + * + * @param obj 待判断的参数。 + * @return 空或者null返回false,否则true。 + */ + public static boolean isNotBlankOrNull(Object obj) { + return !isBlankOrNull(obj); + } + + /** + * 判断source是否等于其中任何一个对象值。 + * + * @param source 源对象。 + * @param others 其他对象。 + * @return 等于其中任何一个返回true,否则false。 + */ + public static boolean equalsAny(Object source, Object...others) { + for (Object one : others) { + if (ObjectUtil.equal(source, one)) { + return true; + } + } + return false; + } + + /** + * 判断模型对象是否通过校验,没有通过返回具体的校验错误信息。 + * + * @param model 带校验的model。 + * @param groups Validate绑定的校验组。 + * @return 没有错误返回null,否则返回具体的错误信息。 + */ + public static String getModelValidationError(T model, Class...groups) { + if (model != null) { + Set> constraintViolations = VALIDATOR.validate(model, groups); + if (!constraintViolations.isEmpty()) { + Iterator> it = constraintViolations.iterator(); + ConstraintViolation constraint = it.next(); + return constraint.getMessage(); + } + } + return null; + } + + /** + * 判断模型对象是否通过校验,没有通过返回具体的校验错误信息。 + * + * @param model 带校验的model。 + * @param forUpdate 是否为更新。 + * @return 没有错误返回null,否则返回具体的错误信息。 + */ + public static String getModelValidationError(T model, boolean forUpdate) { + if (model != null) { + Set> constraintViolations; + if (forUpdate) { + constraintViolations = VALIDATOR.validate(model, Default.class, UpdateGroup.class); + } else { + constraintViolations = VALIDATOR.validate(model, Default.class, AddGroup.class); + } + if (!constraintViolations.isEmpty()) { + Iterator> it = constraintViolations.iterator(); + ConstraintViolation constraint = it.next(); + return constraint.getMessage(); + } + } + return null; + } + + /** + * 判断模型对象是否通过校验,没有通过返回具体的校验错误信息。 + * + * @param modelList 带校验的model列表。 + * @param groups Validate绑定的校验组。 + * @return 没有错误返回null,否则返回具体的错误信息。 + */ + public static String getModelValidationError(List modelList, Class... groups) { + if (CollUtil.isNotEmpty(modelList)) { + for (T model : modelList) { + String errorMessage = getModelValidationError(model, groups); + if (StrUtil.isNotBlank(errorMessage)) { + return errorMessage; + } + } + } + return null; + } + + /** + * 判断模型对象是否通过校验,没有通过返回具体的校验错误信息。 + * + * @param modelList 带校验的model列表。 + * @param forUpdate 是否为更新。 + * @return 没有错误返回null,否则返回具体的错误信息。 + */ + public static String getModelValidationError(List modelList, boolean forUpdate) { + if (CollUtil.isNotEmpty(modelList)) { + for (T model : modelList) { + String errorMessage = getModelValidationError(model, forUpdate); + if (StrUtil.isNotBlank(errorMessage)) { + return errorMessage; + } + } + } + return null; + } + + /** + * 拼接参数中的字符串列表,用指定分隔符进行分割,同时每个字符串对象用单引号括起来。 + * + * @param dataList 字符串集合。 + * @param separator 分隔符。 + * @return 拼接后的字符串。 + */ + public static String joinString(Collection dataList, final char separator) { + int index = 0; + StringBuilder sb = new StringBuilder(128); + for (String data : dataList) { + sb.append("'").append(data).append("'"); + if (index++ != dataList.size() - 1) { + sb.append(separator); + } + } + return sb.toString(); + } + + /** + * 将SQL Like中的通配符替换为字符本身的含义,以便于比较。 + * + * @param str 待替换的字符串。 + * @return 替换后的字符串。 + */ + public static String replaceSqlWildcard(String str) { + if (StrUtil.isBlank(str)) { + return str; + } + return StrUtil.replaceChars(StrUtil.replaceChars(str, "_", "\\_"), "%", "\\%"); + } + + /** + * 获取对象中,非空字段的名字列表。 + * + * @param object 数据对象。 + * @param clazz 数据对象的class类型。 + * @param 数据对象类型。 + * @return 数据对象中,值不为NULL的字段数组。 + */ + public static String[] getNotNullFieldNames(T object, Class clazz) { + Field[] fields = ReflectUtil.getFields(clazz); + List fieldNameList = Arrays.stream(fields) + .filter(f -> ReflectUtil.getFieldValue(object, f) != null) + .map(Field::getName).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(fieldNameList)) { + return fieldNameList.toArray(new String[]{}); + } + return new String[]{}; + } + + /** + * 获取请求头中的设备信息。 + * + * @return 设备类型,具体值可参考AppDeviceType常量类。 + */ + public static int getDeviceType() { + // 缺省都按照Web登录方式设置,如果前端header中的值为不合法值,这里也不会报错,而是使用Web缺省方式。 + int deviceType = AppDeviceType.WEB; + String deviceTypeString = ContextUtil.getHttpRequest().getHeader("deviceType"); + if (StrUtil.isNotBlank(deviceTypeString)) { + Integer type = Integer.valueOf(deviceTypeString); + if (AppDeviceType.isValid(type)) { + deviceType = type; + } + } + return deviceType; + } + + /** + * 获取请求头中的设备信息。 + * + * @return 设备类型,具体值可参考AppDeviceType常量类。 + */ + public static String getDeviceTypeWithString() { + // 缺省都按照Web登录方式设置,如果前端header中的值为不合法值,这里也不会报错,而是使用Web缺省方式。 + int deviceType = AppDeviceType.WEB; + String deviceTypeString = ContextUtil.getHttpRequest().getHeader("deviceType"); + if (StrUtil.isNotBlank(deviceTypeString)) { + Integer type = Integer.valueOf(deviceTypeString); + if (AppDeviceType.isValid(type)) { + deviceType = type; + } + } + return AppDeviceType.getDeviceTypeName(deviceType); + } + + /** + * 获取第三方应用的编码。 + * + * @return 第三方应用编码。 + */ + public static String getAppCodeFromRequest() { + HttpServletRequest request = ContextUtil.getHttpRequest(); + String appCode = request.getHeader("AppCode"); + if (StrUtil.isBlank(appCode)) { + appCode = request.getParameter("AppCode"); + } + return appCode; + } + + /** + * 获取用户身份令牌。 + * + * @param tokenKey 令牌的Key。 + * @return 用户身份令牌。 + */ + public static String getTokenFromRequest(String tokenKey) { + HttpServletRequest request = ContextUtil.getHttpRequest(); + String token = request.getHeader(tokenKey); + if (StrUtil.isBlank(token)) { + token = request.getParameter(tokenKey); + } + if (StrUtil.isBlank(token)) { + token = request.getHeader(ApplicationConstant.HTTP_HEADER_INTERNAL_TOKEN); + } + return token; + } + + /** + * 转换为字典格式的数据列表。 + * + * @param dataList 源数据列表。 + * @param idGetter 获取字典Id字段值的函数方法。 + * @param nameGetter 获取字典名字段值的函数方法。 + * @param 源数据对象类型。 + * @param 字典Id的类型。 + * @return 字典格式的数据列表。 + */ + public static List> toDictDataList( + Collection dataList, Function idGetter, Function nameGetter) { + if (CollUtil.isEmpty(dataList)) { + return new LinkedList<>(); + } + return dataList.stream().map(item -> { + Map dataMap = new HashMap<>(2); + dataMap.put(ApplicationConstant.DICT_ID, idGetter.apply(item)); + dataMap.put(ApplicationConstant.DICT_NAME, nameGetter.apply(item)); + return dataMap; + }).collect(Collectors.toList()); + } + + /** + * 转换为树形字典格式的数据列表。 + * + * @param dataList 源数据列表。 + * @param idGetter 获取字典Id字段值的函数方法。 + * @param nameGetter 获取字典名字段值的函数方法。 + * @param parentIdGetter 获取字典Id父字段值的函数方法。 + * @param 源数据对象类型。 + * @param 字典Id的类型。 + * @return 字典格式的数据列表。 + */ + public static List> toDictDataList( + Collection dataList, + Function idGetter, + Function nameGetter, + Function parentIdGetter) { + if (CollUtil.isEmpty(dataList)) { + return new LinkedList<>(); + } + return dataList.stream().map(item -> { + Map dataMap = new HashMap<>(2); + dataMap.put(ApplicationConstant.DICT_ID, idGetter.apply(item)); + dataMap.put(ApplicationConstant.DICT_NAME, nameGetter.apply(item)); + dataMap.put(ApplicationConstant.PARENT_ID, parentIdGetter.apply(item)); + return dataMap; + }).collect(Collectors.toList()); + } + + /** + * 转换为字典格式的数据列表,同时支持一个附加字段。 + * + * @param dataList 源数据列表。 + * @param idGetter 获取字典Id字段值的函数方法。 + * @param nameGetter 获取字典名字段值的函数方法。 + * @param extraName 附加字段名。。 + * @param extraGetter 获取附加字段值的函数方法。 + * @param 源数据对象类型。 + * @param 字典Id的类型。 + * @param 附加字段值的类型。 + * @return 字典格式的数据列表。 + */ + public static List> toDictDataList( + Collection dataList, + Function idGetter, + Function nameGetter, + String extraName, + Function extraGetter) { + if (CollUtil.isEmpty(dataList)) { + return new LinkedList<>(); + } + return dataList.stream().map(item -> { + Map dataMap = new HashMap<>(2); + dataMap.put(ApplicationConstant.DICT_ID, idGetter.apply(item)); + dataMap.put(ApplicationConstant.DICT_NAME, nameGetter.apply(item)); + dataMap.put(extraName, extraGetter.apply(item)); + return dataMap; + }).collect(Collectors.toList()); + } + + /** + * 将SQL查询条件中的变量值替换为SQL拼接的字符串值。 + * + * @param value 参数值。 + * @return 转换后的参数字符串。 + */ + public static String convertSqlParamValue(Object value) { + if (value == null) { + return "null"; + } + if (value instanceof Number) { + return String.valueOf(value); + } + if (value instanceof Boolean) { + return String.valueOf(value.equals(Boolean.TRUE) ? 1 : 0); + } + StringBuilder builder = new StringBuilder(); + builder.append("'"); + if (value instanceof Date) { + builder.append(DateUtil.format((Date) value, MyDateUtil.COMMON_SHORT_DATETIME_FORMAT)); + } else if (value instanceof String) { + builder.append(value); + } + builder.append("'"); + return builder.toString(); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private MyCommonUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/MyCustomMaskFieldHandler.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/MyCustomMaskFieldHandler.java new file mode 100644 index 00000000..3f4c2c1a --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/MyCustomMaskFieldHandler.java @@ -0,0 +1,23 @@ +package com.orangeforms.common.core.util; + +import org.springframework.stereotype.Component; + +/** + * 缺省的自定义脱敏处理器的实现类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class MyCustomMaskFieldHandler implements MaskFieldHandler { + + @Override + public String handleMask(String modelName, String fieldName, String data, char maskChar) { + // 这里是我们默认提供的躺平实现方式。 + // 在默认生成的代码中,如果脱敏字段的处理类型为CUSTOM的时候,就会暂时使用 + // 该类为默认实现,其实这里就是一个占位符实现类。用户可根据需求自行实现自己所需的脱敏处理器实现类。 + // 实现后,可在脱敏字段的MaskField注解的handler参数中,改为自己的实现类。 + // 最后一句很重要,实现类必须是bean对象,如当前类用@Component注解标记。 + throw new UnsupportedOperationException("请仔细阅读上面的代码注解,并实现自己的处理类,以替代默认生成的自定义实现类!!"); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/MyDateUtil.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/MyDateUtil.java new file mode 100644 index 00000000..033c5178 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/MyDateUtil.java @@ -0,0 +1,320 @@ +package com.orangeforms.common.core.util; + +import com.orangeforms.common.core.object.Tuple2; +import org.apache.commons.lang3.time.DateUtils; +import org.joda.time.DateTime; +import org.joda.time.Period; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; + +import java.util.Calendar; +import java.util.Date; + +import static org.joda.time.PeriodType.days; + +/** + * 日期工具类,主要封装了部分joda-time中的方法,让很多代码一行完成,同时统一了日期到字符串的pattern格式。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class MyDateUtil { + + /** + * 统一的日期pattern,今后可以根据自己的需求去修改。 + */ + public static final String COMMON_DATE_FORMAT = "yyyy-MM-dd"; + /** + * 统一的日期时间pattern,今后可以根据自己的需求去修改。 + */ + public static final String COMMON_DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS"; + /** + * 统一的短日期时间pattern,今后可以根据自己的需求去修改。 + */ + public static final String COMMON_SHORT_DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; + /** + * 缺省日期格式化器,提前获取提升运行时效率。 + */ + private static final DateTimeFormatter DATE_PARSE_FORMATTER = + DateTimeFormat.forPattern(MyDateUtil.COMMON_DATE_FORMAT); + /** + * 缺省日期时间格式化器,提前获取提升运行时效率。 + */ + private static final DateTimeFormatter DATETIME_PARSE_FORMATTER = + DateTimeFormat.forPattern(MyDateUtil.COMMON_DATETIME_FORMAT); + + /** + * 缺省短日期时间格式化器,提前获取提升运行时效率。 + */ + private static final DateTimeFormatter DATETIME_SHORT_PARSE_FORMATTER = + DateTimeFormat.forPattern(MyDateUtil.COMMON_SHORT_DATETIME_FORMAT); + + /** + * 获取一天的开始时间的字符串格式,如2019-08-03 00:00:00.000。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getBeginTimeOfDay(DateTime dateTime) { + return dateTime.withTimeAtStartOfDay().toString(COMMON_DATETIME_FORMAT); + } + + /** + * 获取一天的结束时间的字符串格式,如2019-08-03 23:59:59.999。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getEndTimeOfDay(DateTime dateTime) { + return dateTime.withTime(23, 59, 59, 999).toString(COMMON_DATETIME_FORMAT); + } + + /** + * 获取一天的开始时间的字符串短格式,如2019-08-03 00:00:00。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getBeginTimeOfDayWithShort(DateTime dateTime) { + return dateTime.withTimeAtStartOfDay().toString(COMMON_SHORT_DATETIME_FORMAT); + } + + /** + * 获取一天的结束时间的字符串短格式,如2019-08-03 23:59:59。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getEndTimeOfDayWithShort(DateTime dateTime) { + return dateTime.withTime(23, 59, 59, 999).toString(COMMON_SHORT_DATETIME_FORMAT); + } + + /** + * 获取参数时间对象所在周的第一天的日期时间短格式。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getBeginDateTimeOfWeek(DateTime dateTime) { + return getBeginTimeOfDayWithShort(dateTime.dayOfWeek().withMinimumValue()); + } + + /** + * 获取参数时间对象所在周的结束时间的字符串短格式。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getEndDateTimeOfWeek(DateTime dateTime) { + return getEndTimeOfDayWithShort(dateTime.dayOfWeek().withMaximumValue()); + } + + /** + * 获取参数时间对象所在月份第一天的日期时间短格式。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getBeginDateTimeOfMonth(DateTime dateTime) { + return getBeginTimeOfDayWithShort(dateTime.dayOfMonth().withMinimumValue()); + } + + /** + * 获取参数时间对象所在月份的结束时间的字符串短格式, + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getEndDateTimeOfMonth(DateTime dateTime) { + return getEndTimeOfDayWithShort(dateTime.dayOfMonth().withMaximumValue()); + } + + /** + * 获取参数时间对象所在年的第一天的日期时间短格式。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getBeginDateTimeOfYear(DateTime dateTime) { + return getBeginTimeOfDayWithShort(dateTime.dayOfYear().withMinimumValue()); + } + + /** + * 获取参数时间对象所在年的结束时间的字符串短格式。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getEndDateTimeOfYear(DateTime dateTime) { + return getEndTimeOfDayWithShort(dateTime.dayOfYear().withMaximumValue()); + } + + + /** + * 获取参数时间对象所在季度的第一天的日期时间短格式。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getBeginDateTimeOfQuarter(DateTime dateTime) { + int m = dateTime.getMonthOfYear(); + int m2 = 10; + if (m >= 1 && m <= 3) { + m2 = 1; + } else if (m >= 4 && m <= 6) { + m2 = 4; + } else if (m >= 7 && m <= 9) { + m2 = 7; + } + return getBeginTimeOfDayWithShort(dateTime.withMonthOfYear(m2).dayOfMonth().withMinimumValue()); + } + + /** + * 获取参数时间对象所在季度的结束时间的字符串短格式, + * + * @param dateTime 待格式化的日期时间对象。 + * @return 格式化后的字符串。 + */ + public static String getEndDateTimeOfQuarter(DateTime dateTime) { + int m = dateTime.getMonthOfYear(); + int m2 = 12; + if (m >= 1 && m <= 3) { + m2 = 3; + } else if (m >= 4 && m <= 6) { + m2 = 6; + } else if (m >= 7 && m <= 9) { + m2 = 9; + } + return getEndTimeOfDayWithShort(dateTime.withMonthOfYear(m2).dayOfMonth().withMaximumValue()); + } + + /** + * 获取一天中的开始时间和结束时间的字符串格式,如2019-08-03 00:00:00.000 和 2019-08-03 23:59:59.999。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 包含格式后字符串的二元组对象。 + */ + public static Tuple2 getDateTimeRangeOfDay(DateTime dateTime) { + return new Tuple2<>(getBeginTimeOfDay(dateTime), getEndTimeOfDay(dateTime)); + } + + /** + * 获取本月第一天的日期格式。如2019-08-01。 + * + * @param dateTime 待格式化的日期对象。 + * @return 格式化后的字符串。 + */ + public static String getBeginDateOfMonth(DateTime dateTime) { + return dateTime.withDayOfMonth(1).toString(COMMON_DATE_FORMAT); + } + + /** + * 获取本月第一天的日期格式。如2019-08-01。 + * + * @param dateString 待格式化的日期字符串对象。 + * @return 格式化后的字符串。 + */ + public static String getBeginDateOfMonth(String dateString) { + DateTime dateTime = toDate(dateString); + return dateTime.withDayOfMonth(1).toString(COMMON_DATE_FORMAT); + } + + /** + * 计算指定日期距离今天相差的天数。 + * + * @param dateTime 待格式化的日期时间对象。 + * @return 相差天数。 + */ + public static int getDayDiffToNow(DateTime dateTime) { + return new Period(dateTime, new DateTime(), days()).getDays(); + } + + /** + * 将日期对象格式化为缺省的字符串格式。 + * + * @param dateTime 待格式化的日期对象。 + * @return 格式化后的字符串。 + */ + public static String toDateString(DateTime dateTime) { + return dateTime.toString(COMMON_DATE_FORMAT); + } + + /** + * 将日期时间对象格式化为缺省的字符串格式。 + * + * @param dateTime 待格式化的日期对象。 + * @return 格式化后的字符串。 + */ + public static String toDateTimeString(DateTime dateTime) { + return dateTime.toString(COMMON_DATETIME_FORMAT); + } + + /** + * 将缺省格式的日期字符串解析为日期对象。 + * + * @param dateString 待解析的字符串。 + * @return 解析后的日期对象。 + */ + public static DateTime toDate(String dateString) { + return DATE_PARSE_FORMATTER.parseDateTime(dateString); + } + + /** + * 将缺省格式的日期字符串解析为日期对象。 + * + * @param dateTimeString 待解析的字符串。 + * @return 解析后的日期对象。 + */ + public static DateTime toDateTime(String dateTimeString) { + return DATETIME_PARSE_FORMATTER.parseDateTime(dateTimeString); + } + + /** + * 将缺省格式的(不包含毫秒的)日期时间字符串解析为日期对象。 + * + * @param dateTimeString 待解析的字符串。 + * @return 解析后的日期对象。 + */ + public static DateTime toDateTimeWithoutMs(String dateTimeString) { + return DATETIME_SHORT_PARSE_FORMATTER.parseDateTime(dateTimeString); + } + + /** + * 截取时间到天。如2019-10-03 01:20:30 转换为 2019-10-03 00:00:00。 + * 由于没有字符串的中间转换,因此效率更高。 + * + * @param date 待截取日期对象。 + * @return 转换后日期对象。 + */ + public static Date truncateToDay(Date date) { + return DateUtils.truncate(date, Calendar.DAY_OF_MONTH); + } + + /** + * 截取时间到月。如2019-10-03 01:20:30 转换为 2019-10-01 00:00:00。 + * 由于没有字符串的中间转换,因此效率更高。 + * + * @param date 待截取日期对象。 + * @return 转换后日期对象。 + */ + public static Date truncateToMonth(Date date) { + return DateUtils.truncate(date, Calendar.MONTH); + } + + /** + * 截取时间到年。如2019-10-03 01:20:30 转换为 2019-01-01 00:00:00。 + * 由于没有字符串的中间转换,因此效率更高。 + * + * @param date 待截取日期对象。 + * @return 转换后日期对象。 + */ + public static Date truncateToYear(Date date) { + return DateUtils.truncate(date, Calendar.YEAR); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private MyDateUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/MyModelUtil.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/MyModelUtil.java new file mode 100644 index 00000000..70fca458 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/MyModelUtil.java @@ -0,0 +1,873 @@ +package com.orangeforms.common.core.util; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.ReflectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.annotation.*; +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.core.exception.InvalidDataFieldException; +import com.orangeforms.common.core.annotation.*; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.object.Tuple2; +import com.orangeforms.common.core.upload.UploadResponseInfo; +import com.orangeforms.common.core.upload.UploadStoreInfo; +import com.google.common.base.CaseFormat; +import lombok.extern.slf4j.Slf4j; + +import java.io.Serializable; +import java.lang.reflect.Field; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 负责Model数据操作、类型转换和关系关联等行为的工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class MyModelUtil { + + /** + * 数值型字段。 + */ + public static final Integer NUMERIC_FIELD_TYPE = 0; + /** + * 字符型字段。 + */ + public static final Integer STRING_FIELD_TYPE = 1; + /** + * 日期型字段。 + */ + public static final Integer DATE_FIELD_TYPE = 2; + /** + * 整个工程的实体对象中,创建者Id字段的Java对象名。 + */ + public static final String CREATE_USER_ID_FIELD_NAME = "createUserId"; + /** + * 整个工程的实体对象中,创建时间字段的Java对象名。 + */ + public static final String CREATE_TIME_FIELD_NAME = "createTime"; + /** + * 整个工程的实体对象中,更新者Id字段的Java对象名。 + */ + public static final String UPDATE_USER_ID_FIELD_NAME = "updateUserId"; + /** + * 整个工程的实体对象中,更新时间字段的Java对象名。 + */ + public static final String UPDATE_TIME_FIELD_NAME = "updateTime"; + /** + * mapToColumnName和mapToColumnInfo使用的缓存。 + */ + private static final Map> CACHED_COLUMNINFO_MAP = new ConcurrentHashMap<>(); + + /** + * 将Bean转换为Map。 + * + * @param data Bean数据对象。 + * @param Bean对象类型。 + * @return 转换后的Map。 + */ + public static Map beanToMap(T data) { + return BeanUtil.beanToMap(data); + } + + /** + * 将Bean的数据列表转换为Map列表。 + * + * @param dataList Bean数据列表。 + * @param Bean对象类型。 + * @return 转换后的Map列表。 + */ + public static List> beanToMapList(List dataList) { + return CollUtil.isEmpty(dataList) ? new LinkedList<>() + : dataList.stream().map(BeanUtil::beanToMap).collect(Collectors.toList()); + } + + /** + * 将Map的数据列表转换为Bean列表。 + * + * @param dataList Map数据列表。 + * @param Bean对象类型。 + * @return 转换后的Bean对象列表。 + */ + public static List mapToBeanList(List> dataList, Class clazz) { + return CollUtil.isEmpty(dataList) ? new LinkedList<>() + : dataList.stream().map(data -> BeanUtil.toBeanIgnoreError(data, clazz)).collect(Collectors.toList()); + } + + /** + * 拷贝源类型的集合数据到目标类型的集合中,其中源类型和目标类型中的对象字段类型完全相同。 + * NOTE: 该函数主要应用于框架中,Dto和Model之间的copy,特别针对一对一关联的深度copy。 + * 在Dto中,一对一对象可以使用Map来表示,而不需要使用从表对象的Dto。 + * + * @param sourceCollection 源类型集合。 + * @param targetClazz 目标类型的Class对象。 + * @param 源类型。 + * @param 目标类型。 + * @return copy后的目标类型对象集合。 + */ + public static List copyCollectionTo(Collection sourceCollection, Class targetClazz) { + List targetList = null; + if (sourceCollection == null) { + return targetList; + } + targetList = new LinkedList<>(); + if (CollUtil.isNotEmpty(sourceCollection)) { + for (S source : sourceCollection) { + try { + T target = targetClazz.newInstance(); + BeanUtil.copyProperties(source, target); + targetList.add(target); + } catch (Exception e) { + log.error("Failed to call MyModelUtil.copyCollectionTo", e); + return Collections.emptyList(); + } + } + } + return targetList; + } + + /** + * 拷贝源类型的对象数据到目标类型的对象中,其中源类型和目标类型中的对象字段类型完全相同。 + * NOTE: 该函数主要应用于框架中,Dto和Model之间的copy,特别针对一对一关联的深度copy。 + * 在Dto中,一对一对象可以使用Map来表示,而不需要使用从表对象的Dto。 + * + * @param source 源类型对象。 + * @param targetClazz 目标类型的Class对象。 + * @param 源类型。 + * @param 目标类型。 + * @return copy后的目标类型对象。 + */ + public static T copyTo(S source, Class targetClazz) { + if (source == null) { + return null; + } + try { + T target = targetClazz.newInstance(); + BeanUtil.copyProperties(source, target); + return target; + } catch (Exception e) { + log.error("Failed to call MyModelUtil.copyTo", e); + return null; + } + } + + /** + * 映射Model对象的字段反射对象,获取与该字段对应的数据库列名称。 + * + * @param field 字段反射对象。 + * @param modelClazz Model对象的Class类。 + * @return 该字段所对应的数据表列名称。 + */ + public static String mapToColumnName(Field field, Class modelClazz) { + return mapToColumnName(field.getName(), modelClazz); + } + + /** + * 映射Model对象的字段名称,获取与该字段对应的数据库列名称。 + * + * @param fieldName 字段名称。 + * @param modelClazz Model对象的Class类。 + * @return 该字段所对应的数据表列名称。 + */ + public static String mapToColumnName(String fieldName, Class modelClazz) { + Tuple2 columnInfo = mapToColumnInfo(fieldName, modelClazz); + return columnInfo == null ? null : columnInfo.getFirst(); + } + + /** + * 映射Model对象的字段反射对象,获取与该字段对应的数据库列名称。 + * 如果没有匹配到ColumnName,则立刻抛出异常。 + * + * @param field 字段反射对象。 + * @param modelClazz Model对象的Class类。 + * @return 该字段所对应的数据表列名称。 + */ + public static String safeMapToColumnName(Field field, Class modelClazz) { + return safeMapToColumnName(field.getName(), modelClazz); + } + + /** + * 映射Model对象的字段名称,获取与该字段对应的数据库列名称。 + * 如果没有匹配到ColumnName,则立刻抛出异常。 + * + * @param fieldName 字段名称。 + * @param modelClazz Model对象的Class类。 + * @return 该字段所对应的数据表列名称。 + */ + public static String safeMapToColumnName(String fieldName, Class modelClazz) { + String columnName = mapToColumnName(fieldName, modelClazz); + if (columnName == null) { + throw new InvalidDataFieldException(modelClazz.getSimpleName(), fieldName); + } + return columnName; + } + + /** + * 映射Model对象的字段名称,获取与该字段对应的数据库列名称和字段类型。 + * + * @param fieldName 字段名称。 + * @param modelClazz Model对象的Class类。 + * @return 该字段所对应的数据表列名称和Java字段类型。 + */ + public static Tuple2 mapToColumnInfo(String fieldName, Class modelClazz) { + if (StrUtil.isBlank(fieldName)) { + return null; + } + StringBuilder sb = new StringBuilder(128); + sb.append(modelClazz.getName()).append("-#-").append(fieldName); + Tuple2 columnInfo = CACHED_COLUMNINFO_MAP.get(sb.toString()); + if (columnInfo != null) { + return columnInfo; + } + Field field = ReflectUtil.getField(modelClazz, fieldName); + if (field == null) { + return null; + } + TableField c = field.getAnnotation(TableField.class); + String columnName = null; + if (c == null) { + TableId id = field.getAnnotation(TableId.class); + if (id != null) { + columnName = id.value(); + } + } + if (StrUtil.isBlank(columnName)) { + columnName = c == null ? CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, fieldName) : c.value(); + if (StrUtil.isBlank(columnName)) { + columnName = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, fieldName); + } + } + // 这里缺省情况下都是按照整型去处理,因为他覆盖太多的类型了。 + // 如Integer/Long/Double/BigDecimal,可根据实际情况完善和扩充。 + String typeName = field.getType().getSimpleName(); + Integer type = NUMERIC_FIELD_TYPE; + if (String.class.getSimpleName().equals(typeName)) { + type = STRING_FIELD_TYPE; + } else if (Date.class.getSimpleName().equals(typeName)) { + type = DATE_FIELD_TYPE; + } + columnInfo = new Tuple2<>(columnName, type); + CACHED_COLUMNINFO_MAP.put(sb.toString(), columnInfo); + return columnInfo; + } + + /** + * 映射Model主对象的Class名称,到Model所对应的表名称。 + * + * @param modelClazz Model主对象的Class。 + * @return Model对象对应的数据表名称。 + */ + public static String mapToTableName(Class modelClazz) { + TableName t = modelClazz.getAnnotation(TableName.class); + return t == null ? null : t.value(); + } + + /** + * 主Model类型中,遍历所有包含RelationConstDict注解的字段,并将关联的静态字典中的数据, + * 填充到thisModel对象的被注解字段中。 + * + * @param thisClazz 主对象的Class对象。 + * @param thisModel 主对象。 + * @param 主表对象类型。 + */ + @SuppressWarnings("unchecked") + public static void makeConstDictRelation(Class thisClazz, T thisModel) { + if (thisModel == null) { + return; + } + Field[] fields = ReflectUtil.getFields(thisClazz); + for (Field field : fields) { + // 这里不做任何空值判断,从而让配置错误在调试期间即可抛出 + Field thisTargetField = ReflectUtil.getField(thisClazz, field.getName()); + RelationConstDict r = thisTargetField.getAnnotation(RelationConstDict.class); + if (r == null) { + continue; + } + Field dictMapField = ReflectUtil.getField(r.constantDictClass(), "DICT_MAP"); + Map dictMap = + (Map) ReflectUtil.getFieldValue(r.constantDictClass(), dictMapField); + Object id = ReflectUtil.getFieldValue(thisModel, r.masterIdField()); + if (id != null) { + String name = dictMap.get(id); + if (name != null) { + Map m = new HashMap<>(2); + m.put("id", id); + m.put("name", name); + ReflectUtil.setFieldValue(thisModel, thisTargetField, m); + } + } + } + } + + /** + * 主Model类型中,遍历所有包含RelationConstDict注解的字段,并将关联的静态字典中的数据, + * 填充到thisModelList集合元素对象的被注解字段中。 + * + * @param thisClazz 主对象的Class对象。 + * @param thisModelList 主对象列表。 + * @param 主表对象类型。 + */ + @SuppressWarnings("unchecked") + public static void makeConstDictRelation(Class thisClazz, List thisModelList) { + if (CollUtil.isEmpty(thisModelList)) { + return; + } + List thisModelList2 = thisModelList.stream().filter(Objects::nonNull).collect(Collectors.toList()); + Field[] fields = ReflectUtil.getFields(thisClazz); + for (Field field : fields) { + // 这里不做任何空值判断,从而让配置错误在调试期间即可抛出 + Field thisTargetField = ReflectUtil.getField(thisClazz, field.getName()); + RelationConstDict r = thisTargetField.getAnnotation(RelationConstDict.class); + if (r == null) { + continue; + } + Field dictMapField = ReflectUtil.getField(r.constantDictClass(), "DICT_MAP"); + Map dictMap = + (Map) ReflectUtil.getFieldValue(r.constantDictClass(), dictMapField); + for (T thisModel : thisModelList2) { + Object id = ReflectUtil.getFieldValue(thisModel, r.masterIdField()); + if (id != null) { + String name = dictMap.get(id); + if (name != null) { + Map m = new HashMap<>(2); + m.put("id", id); + m.put("name", name); + ReflectUtil.setFieldValue(thisModel, thisTargetField, m); + } + } + } + } + } + + /** + * 在主Model类型中,根据thisRelationField字段的RelationDict注解参数,将被关联对象thatModel中的数据, + * 关联到thisModel对象的thisRelationField字段中。 + * + * @param thisClazz 主对象的Class对象。 + * @param thisModel 主对象。 + * @param thatModel 字典关联对象。 + * @param thisRelationField 主表对象中保存被关联对象的字段名称。 + * @param 主表对象类型。 + * @param 从表对象类型。 + */ + public static void makeDictRelation( + Class thisClazz, T thisModel, R thatModel, String thisRelationField) { + if (thatModel == null || thisModel == null) { + return; + } + // 这里不做任何空值判断,从而让配置错误在调试期间即可抛出 + Field thisTargetField = ReflectUtil.getField(thisClazz, thisRelationField); + RelationDict r = thisTargetField.getAnnotation(RelationDict.class); + Object slaveId = ReflectUtil.getFieldValue(thatModel, r.slaveIdField()); + if (slaveId != null) { + Map m = new HashMap<>(2); + m.put("id", slaveId); + m.put("name", ReflectUtil.getFieldValue(thatModel, r.slaveNameField())); + ReflectUtil.setFieldValue(thisModel, thisTargetField, m); + } + } + + /** + * 在主Model类型中,根据thisRelationField字段的RelationDict注解参数,将被关联对象集合thatModelList中的数据, + * 逐个关联到thisModelList每一个元素的thisRelationField字段中。 + * + * @param thisClazz 主对象的Class对象。 + * @param thisModelList 主对象列表。 + * @param thatModelList 字典关联对象列表集合。 + * @param thisRelationField 主表对象中保存被关联对象的字段名称。 + * @param 主表对象类型。 + * @param 从表对象类型。 + */ + public static void makeDictRelation( + Class thisClazz, List thisModelList, List thatModelList, String thisRelationField) { + if (CollUtil.isEmpty(thatModelList) || CollUtil.isEmpty(thisModelList)) { + return; + } + // 这里不做任何空值判断,从而让配置错误在调试期间即可抛出 + Field thisTargetField = ReflectUtil.getField(thisClazz, thisRelationField); + RelationDict r = thisTargetField.getAnnotation(RelationDict.class); + Field masterIdField = ReflectUtil.getField(thisClazz, r.masterIdField()); + Class thatClass = r.slaveModelClass(); + Field slaveIdField = ReflectUtil.getField(thatClass, r.slaveIdField()); + Field slaveNameField = ReflectUtil.getField(thatClass, r.slaveNameField()); + Map thatMap = new HashMap<>(20); + thatModelList.forEach(thatModel -> { + Object id = ReflectUtil.getFieldValue(thatModel, slaveIdField); + if (id != null) { + thatMap.put(id, thatModel); + } + }); + thisModelList.forEach(thisModel -> { + if (thisModel != null) { + Object id = ReflectUtil.getFieldValue(thisModel, masterIdField); + if (id != null) { + R thatModel = thatMap.get(id); + if (thatModel != null) { + Map m = new HashMap<>(4); + m.put("id", id); + m.put("name", ReflectUtil.getFieldValue(thatModel, slaveNameField)); + ReflectUtil.setFieldValue(thisModel, thisTargetField, m); + } + } + } + }); + } + + /** + * 在主Model类型中,根据thisRelationField字段的RelationDict注解参数,将被关联对象集合thatModelMap中的数据, + * 逐个关联到thisModelList每一个元素的thisRelationField字段中。 + * 该函数之所以使用Map,主要出于性能优化考虑,在连续使用thatModelMap进行关联时,有效的避免了从多次从List转换到Map的过程。 + * + * @param thisClazz 主对象的Class对象。 + * @param thisModelList 主对象列表。 + * @param thatMadelMap 字典关联对象映射集合。 + * @param thisRelationField 主表对象中保存被关联对象的字段名称。 + * @param 主表对象类型。 + * @param 从表对象类型。 + */ + public static void makeDictRelation( + Class thisClazz, List thisModelList, Map thatMadelMap, String thisRelationField) { + if (MapUtil.isEmpty(thatMadelMap) || CollUtil.isEmpty(thisModelList)) { + return; + } + // 这里不做任何空值判断,从而让配置错误在调试期间即可抛出 + Field thisTargetField = ReflectUtil.getField(thisClazz, thisRelationField); + RelationDict r = thisTargetField.getAnnotation(RelationDict.class); + Field masterIdField = ReflectUtil.getField(thisClazz, r.masterIdField()); + Class thatClass = r.slaveModelClass(); + Field slaveNameField = ReflectUtil.getField(thatClass, r.slaveNameField()); + thisModelList.forEach(thisModel -> { + if (thisModel != null) { + Object id = ReflectUtil.getFieldValue(thisModel, masterIdField); + if (id != null) { + R thatModel = thatMadelMap.get(id); + if (thatModel != null) { + Map m = new HashMap<>(4); + m.put("id", id); + m.put("name", ReflectUtil.getFieldValue(thatModel, slaveNameField)); + ReflectUtil.setFieldValue(thisModel, thisTargetField, m); + } + } + } + }); + } + + /** + * 在主Model类型中,根据thisRelationField字段的RelationGlobalDict注解参数,全局字典dictMap中的字典数据, + * 逐个关联到thisModelList每一个元素的thisRelationField字段中。 + * + * @param thisClazz 主对象的Class对象。 + * @param thisModelList 主对象列表。 + * @param dictMap 全局字典数据。 + * @param thisRelationField 主表对象中保存被关联对象的字段名称。 + * @param 主表对象类型。 + */ + public static void makeGlobalDictRelation( + Class thisClazz, List thisModelList, Map dictMap, String thisRelationField) { + if (MapUtil.isEmpty(dictMap) || CollUtil.isEmpty(thisModelList)) { + return; + } + // 这里不做任何空值判断,从而让配置错误在调试期间即可抛出 + Field thisTargetField = ReflectUtil.getField(thisClazz, thisRelationField); + RelationGlobalDict r = thisTargetField.getAnnotation(RelationGlobalDict.class); + Field masterIdField = ReflectUtil.getField(thisClazz, r.masterIdField()); + thisModelList.forEach(thisModel -> { + if (thisModel != null) { + Object id = ReflectUtil.getFieldValue(thisModel, masterIdField); + if (id != null) { + String name = dictMap.get(id.toString()); + if (name != null) { + Map m = new HashMap<>(2); + m.put("id", id); + m.put("name", name); + ReflectUtil.setFieldValue(thisModel, thisTargetField, m); + } + } + } + }); + } + + /** + * 在主Model类型中,根据thisRelationField字段的RelationOneToOne注解参数,将被关联对象列表thatModelList中的数据, + * 逐个关联到thisModelList每一个元素的thisRelationField字段中。 + * + * @param thisClazz 主对象的Class对象。 + * @param thisModelList 主对象列表。 + * @param thatModelList 一对一关联对象列表。 + * @param thisRelationField 主表对象中保存被关联对象的字段名称。 + * @param 主表对象类型。 + * @param 从表对象类型。 + */ + public static void makeOneToOneRelation( + Class thisClazz, List thisModelList, List thatModelList, String thisRelationField) { + if (CollUtil.isEmpty(thatModelList) || CollUtil.isEmpty(thisModelList)) { + return; + } + // 这里不做任何空值判断,从而让配置错误在调试期间即可抛出 + Field thisTargetField = ReflectUtil.getField(thisClazz, thisRelationField); + RelationOneToOne r = thisTargetField.getAnnotation(RelationOneToOne.class); + Field masterIdField = ReflectUtil.getField(thisClazz, r.masterIdField()); + Class thatClass = r.slaveModelClass(); + Field slaveIdField = ReflectUtil.getField(thatClass, r.slaveIdField()); + Map thatMap = new HashMap<>(20); + thatModelList.forEach(thatModel -> { + Object id = ReflectUtil.getFieldValue(thatModel, slaveIdField); + if (id != null) { + thatMap.put(id, thatModel); + } + }); + thisModelList.forEach(thisModel -> { + Object id = ReflectUtil.getFieldValue(thisModel, masterIdField); + if (id != null) { + R thatModel = thatMap.get(id); + if (thatModel != null) { + if (thisTargetField.getType().equals(Map.class)) { + ReflectUtil.setFieldValue(thisModel, thisTargetField, BeanUtil.beanToMap(thatModel)); + } else { + ReflectUtil.setFieldValue(thisModel, thisTargetField, thatModel); + } + } + } + }); + } + + /** + * 根据主对象和关联对象各自的关联Id函数,将主对象列表和关联对象列表中的数据关联到一起,并将关联对象 + * 设置到主对象的指定关联字段中。 + * NOTE: 用于主对象关联字段中,没有包含RelationOneToOne注解的场景。 + * + * @param thisClazz 主对象的Class对象。 + * @param thisModelList 主对象列表。 + * @param thisIdGetterFunc 主对象Id的Getter函数。 + * @param thatModelList 关联对象列表。 + * @param thatIdGetterFunc 关联对象Id的Getter函数。 + * @param thisRelationField 主对象中保存被关联对象的字段名称。 + * @param 主表对象类型。 + * @param 从表对象类型。 + */ + public static void makeOneToOneRelation( + Class thisClazz, + List thisModelList, + Function thisIdGetterFunc, + List thatModelList, + Function thatIdGetterFunc, + String thisRelationField) { + makeOneToOneRelation(thisClazz, thisModelList, + thisIdGetterFunc, thatModelList, thatIdGetterFunc, thisRelationField, false); + } + + /** + * 根据主对象和关联对象各自的关联Id函数,将主对象列表和关联对象列表中的数据关联到一起,并将关联对象 + * 设置到主对象的指定关联字段中。 + * NOTE: 用于主对象关联字段中,没有包含RelationOneToOne注解的场景。 + * + * @param thisClazz 主对象的Class对象。 + * @param thisModelList 主对象列表。 + * @param thisIdGetterFunc 主对象Id的Getter函数。 + * @param thatModelList 关联对象列表。 + * @param thatIdGetterFunc 关联对象Id的Getter函数。 + * @param thisRelationField 主对象中保存被关联对象的字段名称。 + * @param orderByThatList 如果为true,则按照ThatModelList的顺序输出。同时thisModelList被排序后的新列表替换。 + * @param 主表对象类型。 + * @param 从表对象类型。 + */ + public static void makeOneToOneRelation( + Class thisClazz, + List thisModelList, + Function thisIdGetterFunc, + List thatModelList, + Function thatIdGetterFunc, + String thisRelationField, + boolean orderByThatList) { + if (CollUtil.isEmpty(thisModelList)) { + return; + } + Field thisTargetField = ReflectUtil.getField(thisClazz, thisRelationField); + boolean isMap = thisTargetField.getType().equals(Map.class); + if (orderByThatList) { + List newThisModelList = new LinkedList<>(); + Map thisModelMap = + thisModelList.stream().collect(Collectors.toMap(thisIdGetterFunc, c -> c)); + thatModelList.forEach(thatModel -> { + Object thatId = thatIdGetterFunc.apply(thatModel); + if (thatId != null) { + T thisModel = thisModelMap.get(thatId); + if (thisModel != null) { + ReflectUtil.setFieldValue(thisModel, thisTargetField, normalize(isMap, thatModel)); + newThisModelList.add(thisModel); + } + } + }); + thisModelList.clear(); + thisModelList.addAll(newThisModelList); + return; + } + Map thatMadelMap = + thatModelList.stream().collect(Collectors.toMap(thatIdGetterFunc, c -> c)); + thisModelList.forEach(thisModel -> { + Object thisId = thisIdGetterFunc.apply(thisModel); + if (thisId != null) { + R thatModel = thatMadelMap.get(thisId); + if (thatModel != null) { + ReflectUtil.setFieldValue(thisModel, thisTargetField, normalize(isMap, thatModel)); + } + } + }); + } + + /** + * 在主Model类型中,根据thisRelationField字段的RelationOneToMany注解参数,将被关联对象列表thatModelList中的数据, + * 逐个关联到thisModelList每一个元素的thisRelationField字段中。 + * + * @param thisClazz 主对象的Class对象。 + * @param thisModelList 主对象列表。 + * @param thatModelList 一对多关联对象列表。 + * @param thisRelationField 主表对象中保存被关联对象的字段名称。 + * @param 主表对象类型。 + * @param 从表对象类型。 + */ + public static void makeOneToManyRelation( + Class thisClazz, List thisModelList, List thatModelList, String thisRelationField) { + if (CollUtil.isEmpty(thatModelList) || CollUtil.isEmpty(thisModelList)) { + return; + } + // 这里不做任何空值判断,从而让配置错误在调试期间即可抛出 + Field thisTargetField = ReflectUtil.getField(thisClazz, thisRelationField); + RelationOneToMany r = thisTargetField.getAnnotation(RelationOneToMany.class); + Field masterIdField = ReflectUtil.getField(thisClazz, r.masterIdField()); + Class thatClass = r.slaveModelClass(); + Field slaveIdField = ReflectUtil.getField(thatClass, r.slaveIdField()); + Map> thatMap = new HashMap<>(20); + thatModelList.forEach(thatModel -> { + Object id = ReflectUtil.getFieldValue(thatModel, slaveIdField); + if (id != null) { + List thatModelSubList = thatMap.computeIfAbsent(id, k -> new LinkedList<>()); + thatModelSubList.add(thatModel); + } + }); + thisModelList.forEach(thisModel -> { + Object id = ReflectUtil.getFieldValue(thisModel, masterIdField); + if (id != null) { + List thatModel = thatMap.get(id); + if (thatModel != null) { + ReflectUtil.setFieldValue(thisModel, thisTargetField, thatModel); + } + } + }); + } + + /** + * 在主Model类型中,根据thisRelationField字段的RelationManyToMany注解参数,将被关联对象列表relationModelList中的数据, + * 逐个关联到thisModelList每一个元素的thisRelationField字段中。 + * + * @param thisClazz 主对象的Class对象。 + * @param idFieldName 主表主键Id字段名。 + * @param thisModelList 主对象列表。 + * @param relationModelList 多对多关联对象列表。 + * @param thisRelationField 主表对象中保存被关联对象的字段名称。 + * @param 主表对象类型。 + * @param 关联表对象类型。 + */ + public static void makeManyToManyRelation( + Class thisClazz, String idFieldName, List thisModelList, List relationModelList, String thisRelationField) { + if (CollUtil.isEmpty(relationModelList) || CollUtil.isEmpty(thisModelList)) { + return; + } + // 这里不做任何空值判断,从而让配置错误在调试期间即可抛出 + Field thisTargetField = ReflectUtil.getField(thisClazz, thisRelationField); + RelationManyToMany r = thisTargetField.getAnnotation(RelationManyToMany.class); + Field masterIdField = ReflectUtil.getField(thisClazz, idFieldName); + Class thatClass = r.relationModelClass(); + Field slaveIdField = ReflectUtil.getField(thatClass, r.relationMasterIdField()); + Map> thatMap = new HashMap<>(20); + relationModelList.forEach(thatModel -> { + Object id = ReflectUtil.getFieldValue(thatModel, slaveIdField); + if (id != null) { + thatMap.computeIfAbsent(id, k -> new LinkedList<>()).add(thatModel); + } + }); + thisModelList.forEach(thisModel -> { + Object id = ReflectUtil.getFieldValue(thisModel, masterIdField); + if (id != null) { + List thatModel = thatMap.get(id); + if (thatModel != null) { + ReflectUtil.setFieldValue(thisModel, thisTargetField, thatModel); + } + } + }); + } + + private static Object normalize(boolean isMap, M model) { + return isMap ? BeanUtil.beanToMap(model) : model; + } + + /** + * 获取上传字段的存储信息。 + * + * @param modelClass model的class对象。 + * @param uploadFieldName 上传字段名。 + * @param model的类型。 + * @return 字段的上传存储信息对象。该值始终不会返回null。 + */ + public static UploadStoreInfo getUploadStoreInfo(Class modelClass, String uploadFieldName) { + UploadStoreInfo uploadStoreInfo = new UploadStoreInfo(); + Field uploadField = ReflectUtil.getField(modelClass, uploadFieldName); + if (uploadField == null) { + throw new UnsupportedOperationException("The Field [" + + uploadFieldName + "] doesn't exist in Model [" + modelClass.getSimpleName() + "]."); + } + uploadStoreInfo.setSupportUpload(false); + UploadFlagColumn anno = uploadField.getAnnotation(UploadFlagColumn.class); + if (anno != null) { + uploadStoreInfo.setSupportUpload(true); + uploadStoreInfo.setStoreType(anno.storeType()); + } + return uploadStoreInfo; + } + + /** + * 在插入实体对象数据之前,可以调用该方法,初始化通用字段的数据。 + * + * @param data 实体对象。 + * @param 实体对象类型。 + */ + public static void fillCommonsForInsert(M data) { + Field createdByField = ReflectUtil.getField(data.getClass(), CREATE_USER_ID_FIELD_NAME); + if (createdByField != null) { + ReflectUtil.setFieldValue(data, createdByField, TokenData.takeFromRequest().getUserId()); + } + Field createTimeField = ReflectUtil.getField(data.getClass(), CREATE_TIME_FIELD_NAME); + if (createTimeField != null) { + ReflectUtil.setFieldValue(data, createTimeField, new Date()); + } + Field updatedByField = ReflectUtil.getField(data.getClass(), UPDATE_USER_ID_FIELD_NAME); + if (updatedByField != null) { + ReflectUtil.setFieldValue(data, updatedByField, TokenData.takeFromRequest().getUserId()); + } + Field updateTimeField = ReflectUtil.getField(data.getClass(), UPDATE_TIME_FIELD_NAME); + if (updateTimeField != null) { + ReflectUtil.setFieldValue(data, updateTimeField, new Date()); + } + } + + /** + * 在更新实体对象数据之前,可以调用该方法,更新通用字段的数据。 + * + * @param data 实体对象。 + * @param originalData 原有实体对象。 + * @param 实体对象类型。 + */ + public static void fillCommonsForUpdate(M data, M originalData) { + Object createdByValue = ReflectUtil.getFieldValue(originalData, CREATE_USER_ID_FIELD_NAME); + if (createdByValue != null) { + ReflectUtil.setFieldValue(data, CREATE_USER_ID_FIELD_NAME, createdByValue); + } + Object createTimeValue = ReflectUtil.getFieldValue(originalData, CREATE_TIME_FIELD_NAME); + if (createTimeValue != null) { + ReflectUtil.setFieldValue(data, CREATE_TIME_FIELD_NAME, createTimeValue); + } + Field updatedByField = ReflectUtil.getField(data.getClass(), UPDATE_USER_ID_FIELD_NAME); + if (updatedByField != null) { + ReflectUtil.setFieldValue(data, updatedByField, TokenData.takeFromRequest().getUserId()); + } + Field updateTimeField = ReflectUtil.getField(data.getClass(), UPDATE_TIME_FIELD_NAME); + if (updateTimeField != null) { + ReflectUtil.setFieldValue(data, updateTimeField, new Date()); + } + } + + /** + * 为实体对象字段设置缺省值。如果data对象中指定字段的值为NULL,则设置缺省值,否则跳过。 + * + * @param data 实体对象。 + * @param fieldName 实体对象字段名。 + * @param defaultValue 缺省值。 + * @param 实体对象类型。 + * @param 缺省值类型。 + */ + public static void setDefaultValue(M data, String fieldName, V defaultValue) { + Object v = ReflectUtil.getFieldValue(data, fieldName); + if (v == null) { + ReflectUtil.setFieldValue(data, fieldName, defaultValue); + } + } + + /** + * 获取当前数据对象中,所有上传文件字段的数据,并将上传后的文件名存到集合中并返回。 + * + * @param data 数据对象。 + * @param clazz 数据对象的Class类型。 + * @param 数据对象类型。 + * @return 当前数据对象中,所有上传文件字段中,文件名属性的集合。 + */ + public static Set extractDownloadFileName(M data, Class clazz) { + Set resultSet = new HashSet<>(); + if (data == null) { + return resultSet; + } + Field[] fields = ReflectUtil.getFields(clazz); + for (Field field : fields) { + if (field.isAnnotationPresent(UploadFlagColumn.class)) { + String v = (String) ReflectUtil.getFieldValue(data, field); + List fileInfoList = JSON.parseArray(v, UploadResponseInfo.class); + if (CollUtil.isNotEmpty(fileInfoList)) { + fileInfoList.forEach(fileInfo -> resultSet.add(fileInfo.getFilename())); + } + } + } + return resultSet; + } + + /** + * 获取当前数据对象列表中,所有上传文件字段的数据,并将上传后的文件名存到集合中并返回。 + * + * @param dataList 数据对象。 + * @param clazz 数据对象的Class类型。 + * @param 数据对象类型。 + * @return 当前数据对象中,所有上传文件字段中,文件名属性的集合。 + */ + public static Set extractDownloadFileName(List dataList, Class clazz) { + Set resultSet = new HashSet<>(); + if (CollUtil.isEmpty(dataList)) { + return resultSet; + } + dataList.forEach(data -> resultSet.addAll(extractDownloadFileName(data, clazz))); + return resultSet; + } + + /** + * 根据数据对象指定字段的类型,将参数中的字段值集合转换为匹配的值类型集合。 + * @param clazz 数据对象的Class。 + * @param fieldName 字段名。 + * @param fieldValues 字符型的字段值集合。 + * @param 对象类型。 + * @return 转换后的字段值集合。 + */ + public static Set convertToTypeValues( + Class clazz, String fieldName, List fieldValues) { + Field f = ReflectUtil.getField(clazz, fieldName); + if (f == null) { + String errorMsg = "数据对象 [" + clazz.getSimpleName() + " ] 中,不存在该数据字段 [" + fieldName + "]!"; + throw new MyRuntimeException(errorMsg); + } + if (f.getType().equals(Long.class)) { + return fieldValues.stream().map(Long::valueOf).collect(Collectors.toSet()); + } else if (f.getType().equals(Integer.class)) { + return fieldValues.stream().map(Integer::valueOf).collect(Collectors.toSet()); + } + return new HashSet<>(fieldValues); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private MyModelUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/MyPageUtil.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/MyPageUtil.java new file mode 100644 index 00000000..fc2c7d8f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/MyPageUtil.java @@ -0,0 +1,155 @@ +package com.orangeforms.common.core.util; + +import cn.hutool.core.collection.CollUtil; +import cn.jimmyshi.beanquery.BeanQuery; +import com.alibaba.fastjson.JSONObject; +import com.github.pagehelper.Page; +import org.apache.commons.collections4.CollectionUtils; +import com.orangeforms.common.core.base.mapper.BaseModelMapper; +import com.orangeforms.common.core.object.MyPageData; +import com.orangeforms.common.core.object.Tuple2; + +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 生成带有分页信息的数据列表 + * + * @author Jerry + * @date 2024-07-02 + */ +public class MyPageUtil { + + private static final String DATA_LIST_LITERAL = "dataList"; + private static final String TOTAL_COUNT_LITERAL = "totalCount"; + + /** + * 用户构建带有分页信息的数据列表。 + * + * @param dataList 数据列表,该参数必须是调用PageMethod.startPage之后,立即执行mybatis查询操作的结果集。 + * @param includeFields 结果集中需要返回到前端的字段,多个字段之间逗号分隔。 + * @return 返回只是包含includeFields字段的数据列表,以及结果集TotalCount。 + */ + public static JSONObject makeResponseData(List dataList, String includeFields) { + JSONObject pageData = new JSONObject(); + pageData.put(DATA_LIST_LITERAL, BeanQuery.select(includeFields).from(dataList).execute()); + if (dataList instanceof Page) { + pageData.put(TOTAL_COUNT_LITERAL, ((Page)dataList).getTotal()); + } + return pageData; + } + + /** + * 用户构建带有分页信息的数据列表。 + * + * @param dataList 数据列表,该参数必须是调用PageMethod.startPage之后,立即执行mybatis查询操作的结果集。 + * @return 返回分页数据对象。 + */ + public static MyPageData makeResponseData(List dataList) { + MyPageData pageData = new MyPageData<>(); + pageData.setDataList(dataList); + if (dataList instanceof Page) { + pageData.setTotalCount(((Page)dataList).getTotal()); + } + return pageData; + } + + /** + * 用户构建带有分页信息的数据列表。 + * + * @param dataList 数据列表,该参数必须是调用PageMethod.startPage之后,立即执行mybatis查询操作的结果集。 + * @param totalCount 总数量。 + * @return 返回分页数据对象。 + */ + public static MyPageData makeResponseData(List dataList, Long totalCount) { + MyPageData pageData = new MyPageData<>(); + pageData.setDataList(dataList); + if (totalCount != null) { + pageData.setTotalCount(totalCount); + } + return pageData; + } + + /** + * 用户构建带有分页信息的数据列表。 + * + * @param dataList 实体对象数据列表。 + * @param modelMapper 实体对象到DomainVO对象的数据映射器。 + * @param DomainVO对象类型。 + * @param 实体对象类型。 + * @return 返回分页数据对象。 + */ + public static MyPageData makeResponseData(List dataList, BaseModelMapper modelMapper) { + long totalCount = 0L; + if (CollectionUtils.isEmpty(dataList)) { + // 这里需要构建分页数据对象,统一前端数据格式 + return MyPageData.emptyPageData(); + } + if (dataList instanceof Page) { + totalCount = ((Page) dataList).getTotal(); + } + return MyPageUtil.makeResponseData(modelMapper.fromModelList(dataList), totalCount); + } + + /** + * 构建带有分页信息的数据列表。 + * + * @param dataList 实体对象数据列表。 + * @param converter 转换函数对象。 + * @param 结果类型。 + * @param 实体对象类型。 + * @return 返回分页数据对象。 + */ + public static MyPageData makeResponseData(List dataList, Function converter) { + long totalCount = 0L; + if (CollUtil.isEmpty(dataList)) { + // 这里需要构建分页数据对象,统一前端数据格式 + return MyPageData.emptyPageData(); + } + if (dataList instanceof Page) { + totalCount = ((Page) dataList).getTotal(); + } + List resultList = dataList.stream().map(converter).collect(Collectors.toList()); + return MyPageUtil.makeResponseData(resultList, totalCount); + } + + /** + * 构建带有分页信息的数据列表。 + * + * @param dataList 实体对象数据列表。 + * @param targetClazz 模板对象类型。 + * @param 结果类型。 + * @param 实体对象类型。 + * @return 返回分页数据对象。 + */ + public static MyPageData makeResponseData(List dataList, Class targetClazz) { + long totalCount = 0L; + if (CollUtil.isEmpty(dataList)) { + // 这里需要构建分页数据对象,统一前端数据格式 + return MyPageData.emptyPageData(); + } + if (dataList instanceof Page) { + totalCount = ((Page) dataList).getTotal(); + } + List resultList = MyModelUtil.copyCollectionTo(dataList, targetClazz); + return MyPageUtil.makeResponseData(resultList, totalCount); + } + + /** + * 用户构建带有分页信息的数据列表。 + * + * @param responseData 第一个数据时数据列表,第二个是列表数量。 + * @param 源数据类型。 + * @return 返回分页数据对象。 + */ + public static MyPageData makeResponseData(Tuple2, Long> responseData) { + return makeResponseData(responseData.getFirst(), responseData.getSecond()); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private MyPageUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/RedisKeyUtil.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/RedisKeyUtil.java new file mode 100644 index 00000000..23494356 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/RedisKeyUtil.java @@ -0,0 +1,187 @@ +package com.orangeforms.common.core.util; + +import com.orangeforms.common.core.object.TokenData; + +/** + * Redis 键生成工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class RedisKeyUtil { + + private static final String SESSIONID_PREFIX = "SESSIONID:"; + + /** + * 获取通用的session缓存的键前缀。 + * + * @return session缓存的键前缀。 + */ + public static String getSessionIdPrefix() { + TokenData tokenData = TokenData.takeFromRequest(); + if (tokenData.getTenantId() == null) { + return SESSIONID_PREFIX; + } + return SESSIONID_PREFIX + tokenData.getTenantId() + "_"; + } + + /** + * 获取指定用户Id的session缓存的键前缀。 + * + * @param loginName 指定的用户登录名。 + * @return session缓存的键前缀。 + */ + public static String getSessionIdPrefix(String loginName) { + TokenData tokenData = TokenData.takeFromRequest(); + if (tokenData.getTenantId() == null) { + return SESSIONID_PREFIX + loginName + "_"; + } + return SESSIONID_PREFIX + tokenData.getTenantId() + "_" + loginName + "_"; + } + + /** + * 获取指定用户Id的session缓存的键前缀。 + * + * @param loginName 指定的用户登录名。 + * @param tokenData 令牌对象。 + * @return session缓存的键前缀。 + */ + public static String getSessionIdPrefix(TokenData tokenData, String loginName) { + if (tokenData.getTenantId() == null) { + return SESSIONID_PREFIX + loginName + "_"; + } + return SESSIONID_PREFIX + tokenData.getTenantId() + "_" + loginName + "_"; + } + + /** + * 获取指定用户Id和登录设备类型的session缓存的键前缀。 + * + * @param loginName 指定的用户登录名。 + * @param deviceType 设备类型。 + * @return session缓存的键前缀。 + */ + public static String getSessionIdPrefix(String loginName, int deviceType) { + TokenData tokenData = TokenData.takeFromRequest(); + if (tokenData.getTenantId() == null) { + return SESSIONID_PREFIX + loginName + "_" + deviceType + "_"; + } + return SESSIONID_PREFIX + tokenData.getTenantId() + "_" + loginName + "_" + deviceType + "_"; + } + + /** + * 计算SessionId返回存储于Redis中的键。 + * + * @param sessionId 会话Id。 + * @return 会话存储于Redis中的键值。 + */ + public static String makeSessionIdKey(String sessionId) { + return SESSIONID_PREFIX + sessionId; + } + + /** + * 计算SessionId关联的权限数据存储于Redis中的键。 + * + * @param sessionId 会话Id。 + * @return 会话关联的权限数据存储于Redis中的键值。 + */ + public static String makeSessionPermIdKey(String sessionId) { + return "PERM:" + sessionId; + } + + /** + * 计算SessionId关联的权限字存储于Redis中的键。 + * + * @param sessionId 会话Id。 + * @return 会话关联的权限字存储于Redis中的键值。 + */ + public static String makeSessionPermCodeKey(String sessionId) { + return "PERM_CODE:" + sessionId; + } + + /** + * 计算SessionId关联的数据权限数据存储于Redis中的键。 + * + * @param sessionId 会话Id。 + * @return 会话关联的数据权限数据存储于Redis中的键值。 + */ + public static String makeSessionDataPermIdKey(String sessionId) { + return "DATA_PERM:" + sessionId; + } + + /** + * 计算包含全局字典及其数据项的缓存键。 + * + * @param dictCode 全局字典编码。 + * @return 全局字典指定编码的缓存键。 + */ + public static String makeGlobalDictKey(String dictCode) { + return "GLOBAL_DICT:" + dictCode; + } + + /** + * 计算仅仅包含全局字典对象数据的缓存键。 + * + * @param dictCode 全局字典编码。 + * @return 全局字典指定编码的缓存键。 + */ + public static String makeGlobalDictOnlyKey(String dictCode) { + return "GLOBAL_DICT_ONLY:" + dictCode; + } + + /** + * 计算会话的菜单Id关联权限资源URL的缓存键。 + * + * @param sessionId 会话Id。 + * @param menuId 菜单Id。 + * @return 计算后的缓存键。 + */ + public static String makeSessionMenuPermKey(String sessionId, Object menuId) { + return "SESSION_MENU_ID:" + sessionId + "-" + menuId.toString(); + } + + /** + * 计算会话的菜单Id关联权限资源URL的缓存键的前缀。 + * + * @param sessionId 会话Id。 + * @return 计算后的缓存键前缀。 + */ + public static String getSessionMenuPermPrefix(String sessionId) { + return "SESSION_MENU_ID:" + sessionId + "-"; + } + + /** + * 计算会话关联的白名单URL的缓存键。 + * + * @param sessionId 会话Id。 + * @return 计算后的缓存键。 + */ + public static String makeSessionWhiteListPermKey(String sessionId) { + return "SESSION_WHITE_LIST:" + sessionId; + } + + /** + * 计算会话关联指定部门Ids的子部门Ids的缓存键。 + * + * @param sessionId 会话Id。 + * @param deptIds 部门Id,多个部门Id之间逗号分割。 + * @return 计算后的缓存键。 + */ + public static String makeSessionChildrenDeptIdKey(String sessionId, String deptIds) { + return "SESSION_CHILDREN_DEPT_ID:" + sessionId + "-" + deptIds; + } + + /** + * 计算租户编码的缓存键。 + * + * @param tenantCode 租户编码。 + */ + public static String makeTenantCodeKey(String tenantCode) { + return "TENANT_CODE:" + tenantCode; + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private RedisKeyUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/RsaUtil.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/RsaUtil.java new file mode 100644 index 00000000..05d34fb9 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/RsaUtil.java @@ -0,0 +1,102 @@ +package com.orangeforms.common.core.util; + +import cn.hutool.core.map.MapUtil; +import cn.hutool.crypto.asymmetric.KeyType; +import cn.hutool.crypto.asymmetric.RSA; +import lombok.extern.slf4j.Slf4j; + +import java.security.*; +import java.security.interfaces.RSAPrivateKey; +import java.security.interfaces.RSAPublicKey; +import java.util.Base64; +import java.util.Map; + +/** + * Java RSA 加密工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class RsaUtil { + + /** + * 密钥长度 于原文长度对应 以及越长速度越慢 + */ + private static final int KEY_SIZE = 1024; + /** + * 用于封装随机产生的公钥与私钥 + */ + private static final Map KEY_MAP = MapUtil.newHashMap(); + + /** + * 随机生成密钥对。 + */ + public static void genKeyPair() throws NoSuchAlgorithmException { + // KeyPairGenerator类用于生成公钥和私钥对,基于RSA算法生成对象 + KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA"); + // 初始化密钥对生成器 + keyPairGen.initialize(KEY_SIZE, new SecureRandom()); + // 生成一个密钥对,保存在keyPair中 + KeyPair keyPair = keyPairGen.generateKeyPair(); + // 得到私钥 + RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate(); + // 得到公钥 + RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); + String publicKeyString = Base64.getEncoder().encodeToString(publicKey.getEncoded()); + // 得到私钥字符串 + String privateKeyString = Base64.getEncoder().encodeToString(privateKey.getEncoded()); + // 将公钥和私钥保存到Map + // 0表示公钥 + KEY_MAP.put(0, publicKeyString); + // 1表示私钥 + KEY_MAP.put(1, privateKeyString); + } + + /** + * RSA公钥加密。 + * + * @param str 加密字符串 + * @param publicKey 公钥 + * @return 密文 + */ + public static String encrypt(String str, String publicKey) { + RSA rsa = new RSA(null, publicKey); + return Base64.getEncoder().encodeToString(rsa.encrypt(str, KeyType.PublicKey)); + } + + /** + * RSA私钥解密。 + * + * @param str 加密字符串 + * @param privateKey 私钥 + * @return 明文 + */ + public static String decrypt(String str, String privateKey) { + RSA rsa = new RSA(privateKey, null); + // 64位解码加密后的字符串 + return new String(rsa.decrypt(Base64.getDecoder().decode(str), KeyType.PrivateKey)); + } + + public static void main(String[] args) throws Exception { + long temp = System.currentTimeMillis(); + // 生成公钥和私钥 + genKeyPair(); + // 加密字符串 + log.info("公钥:" + KEY_MAP.get(0)); + log.info("私钥:" + KEY_MAP.get(1)); + log.info("生成密钥消耗时间:" + (System.currentTimeMillis() - temp) / 1000.0 + "秒"); + log.info("生成后的公钥前端使用!"); + log.info("生成后的私钥后台使用!"); + String message = "RSA测试ABCD~!@#$"; + log.info("原文:" + message); + temp = System.currentTimeMillis(); + String messageEn = encrypt(message, KEY_MAP.get(0)); + log.info("密文:" + messageEn); + log.info("加密消耗时间:" + (System.currentTimeMillis() - temp) / 1000.0 + "秒"); + temp = System.currentTimeMillis(); + String messageDe = decrypt(messageEn, KEY_MAP.get(1)); + log.info("解密:" + messageDe); + log.info("解密消耗时间:" + (System.currentTimeMillis() - temp) / 1000.0 + "秒"); + } +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/TreeNode.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/TreeNode.java new file mode 100644 index 00000000..5931410e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/util/TreeNode.java @@ -0,0 +1,92 @@ +package com.orangeforms.common.core.util; + +import cn.hutool.core.util.ObjectUtil; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 将列表结构组建为树结构的工具类。 + * + * @param 对象类型。 + * @param 节点之间关联键的类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class TreeNode { + + private K id; + private K parentId; + private T data; + private List> childList = new ArrayList<>(); + + /** + * 将列表结构组建为树结构的工具方法。 + * + * @param dataList 数据列表结构。 + * @param idFunc 获取关联id的函数对象。 + * @param parentIdFunc 获取关联ParentId的函数对象。 + * @param root 根节点。 + * @param 数据对象类型。 + * @param 节点之间关联键的类型。 + * @return 源数据对象的树结构存储。 + */ + public static List> build( + List dataList, Function idFunc, Function parentIdFunc, K root) { + List> treeNodeList = new ArrayList<>(); + for (T data : dataList) { + if (ObjectUtil.equals(parentIdFunc.apply(data), idFunc.apply(data))) { + continue; + } + TreeNode dataNode = new TreeNode<>(); + dataNode.setId(idFunc.apply(data)); + dataNode.setParentId(parentIdFunc.apply(data)); + dataNode.setData(data); + treeNodeList.add(dataNode); + } + return root == null ? toBuildTreeWithoutRoot(treeNodeList) : toBuildTree(treeNodeList, root); + } + + private static List> toBuildTreeWithoutRoot(List> treeNodes) { + Map> treeNodeMap = + treeNodes.stream().collect(Collectors.toMap(TreeNode::getId, n -> n)); + List> treeNodeList = new ArrayList<>(); + for (TreeNode treeNode : treeNodes) { + TreeNode parentNode = treeNodeMap.get(treeNode.getParentId()); + if (parentNode == null) { + treeNodeList.add(treeNode); + } else { + parentNode.add(treeNode); + } + } + return treeNodeList; + } + + private static List> toBuildTree(List> treeNodes, K root) { + List> treeNodeList = new ArrayList<>(); + for (TreeNode treeNode : treeNodes) { + if (root.equals(treeNode.getParentId())) { + treeNodeList.add(treeNode); + } + for (TreeNode it : treeNodes) { + if (it.getParentId() == treeNode.getId()) { + if (treeNode.getChildList() == null) { + treeNode.setChildList(new ArrayList<>()); + } + treeNode.add(it); + } + } + } + return treeNodeList; + } + + private void add(TreeNode node) { + childList.add(node); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/validator/AddGroup.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/validator/AddGroup.java new file mode 100644 index 00000000..a287fd56 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/validator/AddGroup.java @@ -0,0 +1,10 @@ +package com.orangeforms.common.core.validator; + +/** + * 数据增加的验证分组。通常用于数据新增场景。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface AddGroup { +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/validator/ConstDictRef.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/validator/ConstDictRef.java new file mode 100644 index 00000000..00e43b6a --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/validator/ConstDictRef.java @@ -0,0 +1,48 @@ +package com.orangeforms.common.core.validator; + +import jakarta.validation.Constraint; +import jakarta.validation.Payload; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 定义在Model对象中,标注字段值引用自指定的常量字典,和ConstDictRefValidator对象配合完成数据验证。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Constraint(validatedBy = ConstDictValidator.class) +public @interface ConstDictRef { + + /** + * 引用的常量字典对象,该对象必须包含isValid的静态方法。 + * + * @return 最大长度。 + */ + Class constDictClass(); + + /** + * 超过边界后的错误消息提示。 + * + * @return 错误提示。 + */ + String message() default "无效的字典引用值!"; + + /** + * 验证分组。 + * + * @return 验证分组。 + */ + Class[] groups() default {}; + + /** + * 载荷对象类型。 + * + * @return 载荷对象。 + */ + Class[] payload() default {}; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/validator/ConstDictValidator.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/validator/ConstDictValidator.java new file mode 100644 index 00000000..ba58a2a7 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/validator/ConstDictValidator.java @@ -0,0 +1,34 @@ +package com.orangeforms.common.core.validator; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ReflectUtil; + +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; +import java.lang.reflect.Method; + +/** + * * 数据字段自定义验证,用于验证Model中关联的常量字典值的合法性。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class ConstDictValidator implements ConstraintValidator { + + private ConstDictRef constDictRef; + + @Override + public void initialize(ConstDictRef constDictRef) { + this.constDictRef = constDictRef; + } + + @Override + public boolean isValid(Object s, ConstraintValidatorContext constraintValidatorContext) { + if (ObjectUtil.isEmpty(s)) { + return true; + } + Method method = + ReflectUtil.getMethodByName(constDictRef.constDictClass(), "isValid"); + return ReflectUtil.invokeStatic(method, s); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/validator/TextLength.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/validator/TextLength.java new file mode 100644 index 00000000..c5a983fb --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/validator/TextLength.java @@ -0,0 +1,55 @@ +package com.orangeforms.common.core.validator; + +import jakarta.validation.Constraint; +import jakarta.validation.Payload; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 定义在Model或Dto对象中,UTF-8编码的字符串字段长度的上限和下限,和TextLengthValidator对象配合完成数据验证。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Constraint(validatedBy = TextLengthValidator.class) +public @interface TextLength { + + /** + * 字符串字段的最小长度。 + * + * @return 最小长度。 + */ + int min() default 0; + + /** + * 字符串字段的最大长度。 + * + * @return 最大长度。 + */ + int max() default Integer.MAX_VALUE; + + /** + * 超过边界后的错误消息提示。 + * + * @return 错误提示。 + */ + String message() default "字段长度超过最大字节数!"; + + /** + * 验证分组。 + * + * @return 验证分组。 + */ + Class[] groups() default { }; + + /** + * 载荷对象类型。 + * + * @return 载荷对象。 + */ + Class[] payload() default { }; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/validator/TextLengthValidator.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/validator/TextLengthValidator.java new file mode 100644 index 00000000..5433bc2b --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/validator/TextLengthValidator.java @@ -0,0 +1,39 @@ +package com.orangeforms.common.core.validator; + +import org.apache.commons.lang3.CharUtils; + +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; + +/** + * 数据字段自定义验证,用于验证Model中UTF-8编码的字符串字段的最大长度和最小长度。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class TextLengthValidator implements ConstraintValidator { + + private TextLength textLength; + + @Override + public void initialize(TextLength textLength) { + this.textLength = textLength; + } + + @Override + public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) { + if (s == null) { + return true; + } + int length = 0; + for (int i = 0; i < s.length(); i++) { + char c = s.charAt(i); + if (CharUtils.isAscii(c)) { + ++length; + } else { + length += 2; + } + } + return length >= textLength.min() && length <= textLength.max(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/validator/UpdateGroup.java b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/validator/UpdateGroup.java new file mode 100644 index 00000000..1c196a79 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-core/src/main/java/com/orangeforms/common/core/validator/UpdateGroup.java @@ -0,0 +1,11 @@ +package com.orangeforms.common.core.validator; + +/** + * 数据修改的验证分组。通常用于数据更新的场景。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface UpdateGroup { + +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-datafilter/pom.xml b/OrangeFormsOpen-MybatisPlus/common/common-datafilter/pom.xml new file mode 100644 index 00000000..e791d2f7 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-datafilter/pom.xml @@ -0,0 +1,29 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-datafilter + 1.0.0 + common-datafilter + jar + + + + com.orangeforms + common-core + 1.0.0 + + + com.orangeforms + common-redis + 1.0.0 + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/aop/DisableDataFilterAspect.java b/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/aop/DisableDataFilterAspect.java new file mode 100644 index 00000000..91ab688d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/aop/DisableDataFilterAspect.java @@ -0,0 +1,42 @@ +package com.orangeforms.common.datafilter.aop; + +import com.orangeforms.common.core.object.GlobalThreadLocal; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +/** + * 禁用Mybatis拦截器数据过滤的AOP处理类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Aspect +@Component +@Order(1) +@Slf4j +public class DisableDataFilterAspect { + + /** + * 所有标记了DisableDataFilter注解的类和方法。 + */ + @Pointcut("@within(com.orangeforms.common.core.annotation.DisableDataFilter) " + + "|| @annotation(com.orangeforms.common.core.annotation.DisableDataFilter)") + public void disableDataFilterPointCut() { + // 空注释,避免sonar警告 + } + + @Around("disableDataFilterPointCut()") + public Object around(ProceedingJoinPoint point) throws Throwable { + boolean dataFilterEnabled = GlobalThreadLocal.setDataFilter(false); + try { + return point.proceed(); + } finally { + GlobalThreadLocal.setDataFilter(dataFilterEnabled); + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/config/DataFilterAutoConfig.java b/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/config/DataFilterAutoConfig.java new file mode 100644 index 00000000..eefef7b5 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/config/DataFilterAutoConfig.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.datafilter.config; + +import org.springframework.boot.context.properties.EnableConfigurationProperties; + +/** + * common-datafilter模块的自动配置引导类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EnableConfigurationProperties({DataFilterProperties.class}) +public class DataFilterAutoConfig { +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/config/DataFilterProperties.java b/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/config/DataFilterProperties.java new file mode 100644 index 00000000..f4019a9d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/config/DataFilterProperties.java @@ -0,0 +1,50 @@ +package com.orangeforms.common.datafilter.config; + +import lombok.Data; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * common-datafilter模块的配置类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ConfigurationProperties(prefix = "common-datafilter") +public class DataFilterProperties { + + /** + * 是否启用租户过滤。 + */ + @Value("${common-datafilter.tenant.enabled:false}") + private Boolean enabledTenantFilter; + + /** + * 是否启动数据权限过滤。 + */ + @Value("${common-datafilter.dataperm.enabled:false}") + private Boolean enabledDataPermFilter; + + /** + * 部门关联表的表名前缀,如zz_。该值主要用在MybatisDataFilterInterceptor拦截器中, + * 用于拼接数据权限过滤的SQL语句。 + */ + @Value("${common-datafilter.dataperm.deptRelationTablePrefix:}") + private String deptRelationTablePrefix; + + /** + * 该值为true的时候,在进行数据权限过滤时,会加上表名,如:zz_sys_user.dept_id = xxx。 + * 为false时,过滤条件不加表名,只是使用字段名,如:dept_id = xxx。该值目前主要适用于 + * Oracle分页SQL使用了子查询的场景。此场景下,由于子查询使用了别名,再在数据权限过滤条件中 + * 加上原有表名时,SQL语法会报错。 + */ + @Value("${common-datafilter.dataperm.addTableNamePrefix:true}") + private Boolean addTableNamePrefix; + + /** + * 是否打开menuId和当前url的匹配关系的验证。 + */ + @Value("${common-datafilter.dataperm.enableMenuPermVerify:true}") + private Boolean enableMenuPermVerify; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/config/DataFilterWebMvcConfigurer.java b/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/config/DataFilterWebMvcConfigurer.java new file mode 100644 index 00000000..2ba79d45 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/config/DataFilterWebMvcConfigurer.java @@ -0,0 +1,21 @@ +package com.orangeforms.common.datafilter.config; + +import com.orangeforms.common.datafilter.interceptor.DataFilterInterceptor; +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 2024-07-02 + */ +@Configuration +public class DataFilterWebMvcConfigurer implements WebMvcConfigurer { + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(new DataFilterInterceptor()).addPathPatterns("/**"); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/interceptor/DataFilterInterceptor.java b/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/interceptor/DataFilterInterceptor.java new file mode 100644 index 00000000..a20b9083 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/interceptor/DataFilterInterceptor.java @@ -0,0 +1,42 @@ +package com.orangeforms.common.datafilter.interceptor; + +import com.orangeforms.common.core.object.GlobalThreadLocal; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +/** + * 主要用于初始化,通过Mybatis拦截器插件进行数据过滤的标记。 + * 在调用controller接口处理方法之前,必须强制将数据过滤标记设置为缺省值。 + * 这样可以避免使用当前线程在处理上一个请求时,未能正常清理的数据过滤标记值。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class DataFilterInterceptor implements HandlerInterceptor { + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) + throws Exception { + // 每次进入Controller接口之前,均主动打开数据权限验证。 + // 可以避免该Servlet线程在处理之前的请求时异常退出,从而导致该状态数据没有被正常清除。 + GlobalThreadLocal.setDataFilter(true); + 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 { + GlobalThreadLocal.clearDataFilter(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/interceptor/MybatisDataFilterInterceptor.java b/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/interceptor/MybatisDataFilterInterceptor.java new file mode 100644 index 00000000..4e2253a0 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/interceptor/MybatisDataFilterInterceptor.java @@ -0,0 +1,637 @@ +package com.orangeforms.common.datafilter.interceptor; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.text.StrFormatter; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.ReflectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.annotation.TableName; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.annotation.*; +import com.orangeforms.common.core.cache.CacheConfig; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.core.exception.NoDataPermException; +import com.orangeforms.common.core.object.GlobalThreadLocal; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.ApplicationContextHolder; +import com.orangeforms.common.core.util.ContextUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.RedisKeyUtil; +import com.orangeforms.common.core.constant.DataPermRuleType; +import com.orangeforms.common.datafilter.config.DataFilterProperties; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import net.sf.jsqlparser.JSQLParserException; +import net.sf.jsqlparser.expression.operators.conditional.AndExpression; +import net.sf.jsqlparser.parser.CCJSqlParserUtil; +import net.sf.jsqlparser.statement.Statement; +import net.sf.jsqlparser.statement.delete.Delete; +import net.sf.jsqlparser.statement.select.FromItem; +import net.sf.jsqlparser.statement.select.PlainSelect; +import net.sf.jsqlparser.statement.select.Select; +import net.sf.jsqlparser.statement.select.SubSelect; +import net.sf.jsqlparser.statement.update.Update; +import org.apache.ibatis.executor.statement.RoutingStatementHandler; +import org.apache.ibatis.executor.statement.StatementHandler; +import org.apache.ibatis.mapping.BoundSql; +import org.apache.ibatis.mapping.MappedStatement; +import org.apache.ibatis.mapping.SqlCommandType; +import org.apache.ibatis.plugin.*; +import org.redisson.api.RBucket; +import org.redisson.api.RedissonClient; +import org.springframework.aop.framework.Advised; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.stereotype.Component; + +import jakarta.annotation.Resource; +import java.lang.reflect.Field; +import java.lang.reflect.ParameterizedType; +import java.sql.Connection; +import java.util.*; + +/** + * Mybatis拦截器。目前用于数据权限的统一拦截和注入处理。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Intercepts({@Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})}) +@Slf4j +@Component +public class MybatisDataFilterInterceptor implements Interceptor { + + @Autowired + private RedissonClient redissonClient; + @Autowired + private DataFilterProperties properties; + @Resource(name = "caffeineCacheManager") + private CacheManager cacheManager; + + /** + * 对象缓存。由于Set是排序后的,因此在查找排除方法名称时效率更高。 + * 在应用服务启动的监听器中(LoadDataPermMapperListener),会调用当前对象的(loadMappersWithDataPerm)方法,加载缓存。 + */ + private final Map cachedDataPermMap = MapUtil.newHashMap(); + /** + * 租户租户对象缓存。 + */ + private final Map cachedTenantMap = MapUtil.newHashMap(); + + /** + * 预先加载与数据过滤相关的数据到缓存,该函数会在(LoadDataFilterInfoListener)监听器中调用。 + */ + @SuppressWarnings("all") + public void loadInfoWithDataFilter() { + Map mapperMap = + ApplicationContextHolder.getApplicationContext().getBeansOfType(BaseDaoMapper.class); + for (BaseDaoMapper mapperProxy : mapperMap.values()) { + // 优先处理jdk的代理 + Object proxy = ReflectUtil.getFieldValue(mapperProxy, "h"); + // 如果不是jdk的代理,再看看cjlib的代理。 + if (proxy == null) { + proxy = ReflectUtil.getFieldValue(mapperProxy, "CGLIB$CALLBACK_0"); + } + Class mapperClass = (Class) ReflectUtil.getFieldValue(proxy, "mapperInterface"); + if (mapperClass == null) { + try { + mapperProxy = (BaseDaoMapper) + ((Advised) ReflectUtil.getFieldValue(proxy, "advised")).getTargetSource().getTarget(); + proxy = ReflectUtil.getFieldValue(mapperProxy, "h"); + mapperClass = (Class) ReflectUtil.getFieldValue(proxy, "mapperInterface"); + } catch (Exception e) { + throw new MyRuntimeException(e); + } + } + if (BooleanUtil.isTrue(properties.getEnabledTenantFilter())) { + loadTenantFilterData(mapperClass); + } + if (BooleanUtil.isTrue(properties.getEnabledDataPermFilter())) { + EnableDataPerm rule = mapperClass.getAnnotation(EnableDataPerm.class); + if (rule != null) { + loadDataPermFilterRules(mapperClass, rule); + } + } + } + } + + private void loadTenantFilterData(Class mapperClass) { + Class modelClass = (Class) ((ParameterizedType) + mapperClass.getGenericInterfaces()[0]).getActualTypeArguments()[0]; + Field[] fields = ReflectUtil.getFields(modelClass); + for (Field field : fields) { + if (field.getAnnotation(TenantFilterColumn.class) != null) { + ModelTenantInfo tenantInfo = new ModelTenantInfo(); + tenantInfo.setModelName(modelClass.getSimpleName()); + tenantInfo.setTableName(modelClass.getAnnotation(TableName.class).value()); + tenantInfo.setFieldName(field.getName()); + tenantInfo.setColumnName(MyModelUtil.mapToColumnName(field, modelClass)); + // 判断当前dao中是否包括不需要自动注入租户Id过滤的方法。 + DisableTenantFilter disableTenantFilter = mapperClass.getAnnotation(DisableTenantFilter.class); + if (disableTenantFilter != null) { + // 这里开始获取当前Mapper已经声明的的SqlId中,有哪些是需要排除在外的。 + // 排除在外的将不进行数据过滤。 + Set excludeMethodNameSet = new HashSet<>(); + for (String excludeName : disableTenantFilter.includeMethodName()) { + excludeMethodNameSet.add(excludeName); + // 这里是给pagehelper中,分页查询先获取数据总量的查询。 + excludeMethodNameSet.add(excludeName + "_COUNT"); + } + tenantInfo.setExcludeMethodNameSet(excludeMethodNameSet); + } + cachedTenantMap.put(mapperClass.getName(), tenantInfo); + break; + } + } + } + + private void loadDataPermFilterRules(Class mapperClass, EnableDataPerm rule) { + String sysDataPermMapperName = "SysDataPermMapper"; + // 由于给数据权限Mapper添加@EnableDataPerm,将会导致无限递归,因此这里检测到之后, + // 会在系统启动加载监听器的时候,及时抛出异常。 + if (StrUtil.equals(sysDataPermMapperName, mapperClass.getSimpleName())) { + throw new IllegalStateException("Add @EnableDataPerm annotation to SysDataPermMapper is ILLEGAL!"); + } + // 这里开始获取当前Mapper已经声明的的SqlId中,有哪些是需要排除在外的。 + // 排除在外的将不进行数据过滤。 + Set excludeMethodNameSet = null; + String[] excludes = rule.excluseMethodName(); + if (excludes.length > 0) { + excludeMethodNameSet = new HashSet<>(); + for (String excludeName : excludes) { + excludeMethodNameSet.add(excludeName); + // 这里是给pagehelper中,分页查询先获取数据总量的查询。 + excludeMethodNameSet.add(excludeName + "_COUNT"); + } + } + // 获取Mapper关联的主表信息,包括表名,user过滤字段名和dept过滤字段名。 + Class modelClazz = (Class) + ((ParameterizedType) mapperClass.getGenericInterfaces()[0]).getActualTypeArguments()[0]; + Field[] fields = ReflectUtil.getFields(modelClazz); + Field userFilterField = null; + Field deptFilterField = null; + for (Field field : fields) { + if (null != field.getAnnotation(UserFilterColumn.class)) { + userFilterField = field; + } + if (null != field.getAnnotation(DeptFilterColumn.class)) { + deptFilterField = field; + } + if (userFilterField != null && deptFilterField != null) { + break; + } + } + // 通过注解解析与Mapper关联的Model,并获取与数据权限关联的信息,并将结果缓存。 + ModelDataPermInfo info = new ModelDataPermInfo(); + info.setMainTableName(MyModelUtil.mapToTableName(modelClazz)); + info.setMustIncludeUserRule(rule.mustIncludeUserRule()); + info.setExcludeMethodNameSet(excludeMethodNameSet); + if (userFilterField != null) { + info.setUserFilterColumn(MyModelUtil.mapToColumnName(userFilterField, modelClazz)); + } + if (deptFilterField != null) { + info.setDeptFilterColumn(MyModelUtil.mapToColumnName(deptFilterField, modelClazz)); + } + cachedDataPermMap.put(mapperClass.getName(), info); + } + + @Override + public Object intercept(Invocation invocation) throws Throwable { + // 判断当前线程本地存储中,业务操作是否禁用了数据权限过滤,如果禁用,则不进行后续的数据过滤处理了。 + if (!GlobalThreadLocal.enabledDataFilter() + && BooleanUtil.isFalse(properties.getEnabledTenantFilter())) { + return invocation.proceed(); + } + // 只有在HttpServletRequest场景下,该拦截器才起作用,对于系统级别的预加载数据不会应用数据权限。 + if (!ContextUtil.hasRequestContext()) { + return invocation.proceed(); + } + // 没有登录的用户,不会参与租户过滤,如果需要过滤的,自己在代码中手动实现 + // 通常对于无需登录的白名单url,也无需过滤了。 + // 另外就是登录接口中,获取菜单列表的接口,由于尚未登录,没有TokenData,所以这个接口我们手动加入了该条件。 + if (TokenData.takeFromRequest() == null) { + return invocation.proceed(); + } + RoutingStatementHandler handler; + try { + handler = (RoutingStatementHandler) invocation.getTarget(); + } catch (Exception e) { + handler = (RoutingStatementHandler) + ReflectUtil.getFieldValue(ReflectUtil.getFieldValue(invocation.getTarget(), "h"), "target"); + } + StatementHandler delegate = + (StatementHandler) ReflectUtil.getFieldValue(handler, "delegate"); + // 通过反射获取delegate父类BaseStatementHandler的mappedStatement属性 + MappedStatement mappedStatement = + (MappedStatement) ReflectUtil.getFieldValue(delegate, "mappedStatement"); + SqlCommandType commandType = mappedStatement.getSqlCommandType(); + // 对于INSERT语句,我们不进行任何数据过滤。 + if (commandType == SqlCommandType.INSERT) { + return invocation.proceed(); + } + String sqlId = mappedStatement.getId(); + int pos = StrUtil.lastIndexOfIgnoreCase(sqlId, "."); + String className = StrUtil.sub(sqlId, 0, pos); + String methodName = StrUtil.subSuf(sqlId, pos + 1); + // 先进行租户过滤条件的处理,再将解析并处理后的SQL Statement交给下一步的数据权限过滤去处理。 + // 这样做的目的主要是为了减少一次SQL解析的过程,因为这是高频操作,所以要尽量去优化。 + Statement statement = null; + if (BooleanUtil.isTrue(properties.getEnabledTenantFilter())) { + statement = this.processTenantFilter(className, methodName, delegate.getBoundSql(), commandType); + } + // 处理数据权限过滤。 + if (GlobalThreadLocal.enabledDataFilter() + && BooleanUtil.isTrue(properties.getEnabledDataPermFilter())) { + this.processDataPermFilter(className, methodName, delegate.getBoundSql(), commandType, statement, sqlId); + } + return invocation.proceed(); + } + + private Statement processTenantFilter( + String className, String methodName, BoundSql boundSql, SqlCommandType commandType) throws JSQLParserException { + ModelTenantInfo info = cachedTenantMap.get(className); + if (info == null || CollUtil.contains(info.getExcludeMethodNameSet(), methodName)) { + return null; + } + String sql = boundSql.getSql(); + Statement statement = CCJSqlParserUtil.parse(sql); + StringBuilder filterBuilder = new StringBuilder(64); + filterBuilder.append(info.tableName).append(".") + .append(info.columnName) + .append("=") + .append(TokenData.takeFromRequest().getTenantId()); + String dataFilter = filterBuilder.toString(); + if (commandType == SqlCommandType.UPDATE) { + Update update = (Update) statement; + this.buildWhereClause(update, dataFilter); + } else if (commandType == SqlCommandType.DELETE) { + Delete delete = (Delete) statement; + this.buildWhereClause(delete, dataFilter); + } else { + Select select = (Select) statement; + PlainSelect selectBody = (PlainSelect) select.getSelectBody(); + FromItem fromItem = selectBody.getFromItem(); + if (fromItem != null) { + PlainSelect subSelect = null; + if (fromItem instanceof SubSelect) { + subSelect = (PlainSelect) ((SubSelect) fromItem).getSelectBody(); + } + if (subSelect != null) { + dataFilter = replaceTableAlias(info.getTableName(), subSelect, dataFilter); + buildWhereClause(subSelect, dataFilter); + } else { + dataFilter = replaceTableAlias(info.getTableName(), selectBody, dataFilter); + buildWhereClause(selectBody, dataFilter); + } + } + } + log.info("Tenant Filter Where Clause [{}]", dataFilter); + ReflectUtil.setFieldValue(boundSql, "sql", statement.toString()); + return statement; + } + + private void processDataPermFilter( + String className, String methodName, BoundSql boundSql, SqlCommandType commandType, Statement statement, String sqlId) + throws JSQLParserException { + // 判断当前线程本地存储中,业务操作是否禁用了数据权限过滤,如果禁用,则不进行后续的数据过滤处理了。 + // 数据过滤权限中,INSERT不过滤。如果是管理员则不参与数据权限的数据过滤,显示全部数据。 + TokenData tokenData = TokenData.takeFromRequest(); + if (Boolean.TRUE.equals(tokenData.getIsAdmin())) { + return; + } + ModelDataPermInfo info = cachedDataPermMap.get(className); + // 再次查找当前方法是否为排除方法,如果不是,就参与数据权限注入过滤。 + if (info == null || CollUtil.contains(info.getExcludeMethodNameSet(), methodName)) { + return; + } + String dataPermSessionKey = RedisKeyUtil.makeSessionDataPermIdKey(tokenData.getSessionId()); + Object cachedData = this.getCachedData(dataPermSessionKey); + if (cachedData == null) { + throw new NoDataPermException(StrFormatter.format( + "No Related DataPerm found for SQL_ID [{}] from Cache.", sqlId)); + } + JSONObject allMenuDataPermMap = cachedData instanceof JSONObject + ? (JSONObject) cachedData : JSON.parseObject(cachedData.toString()); + JSONObject menuDataPermMap = this.getAndVerifyMenuDataPerm(allMenuDataPermMap, sqlId); + Map dataPermMap = new HashMap<>(8); + for (Map.Entry entry : menuDataPermMap.entrySet()) { + dataPermMap.put(Integer.valueOf(entry.getKey()), entry.getValue().toString()); + } + if (MapUtil.isEmpty(dataPermMap)) { + throw new NoDataPermException(StrFormatter.format( + "No Related DataPerm found for SQL_ID [{}].", sqlId)); + } + if (dataPermMap.containsKey(DataPermRuleType.TYPE_ALL)) { + return; + } + // 如果当前过滤注解中mustIncludeUserRule参数为true,同时当前用户的数据权限中,不包含TYPE_USER_ONLY, + // 这里就需要自动添加该数据权限。 + if (info.getMustIncludeUserRule() + && !dataPermMap.containsKey(DataPermRuleType.TYPE_USER_ONLY)) { + dataPermMap.put(DataPermRuleType.TYPE_USER_ONLY, null); + } + this.processDataPerm(info, dataPermMap, boundSql, commandType, statement); + } + + private JSONObject getAndVerifyMenuDataPerm(JSONObject allMenuDataPermMap, String sqlId) { + String menuId = ContextUtil.getHttpRequest().getHeader(ApplicationConstant.HTTP_HEADER_MENU_ID); + if (menuId == null) { + menuId = ContextUtil.getHttpRequest().getParameter(ApplicationConstant.HTTP_HEADER_MENU_ID); + } + if (BooleanUtil.isFalse(properties.getEnableMenuPermVerify()) && menuId == null) { + menuId = ApplicationConstant.DATA_PERM_ALL_MENU_ID; + } + Assert.notNull(menuId); + JSONObject menuDataPermMap = allMenuDataPermMap.getJSONObject(menuId); + if (menuDataPermMap == null) { + menuDataPermMap = allMenuDataPermMap.getJSONObject(ApplicationConstant.DATA_PERM_ALL_MENU_ID); + } + if (menuDataPermMap == null) { + throw new NoDataPermException(StrFormatter.format( + "No Related DataPerm found for menuId [{}] and SQL_ID [{}].", menuId, sqlId)); + } + if (BooleanUtil.isTrue(properties.getEnableMenuPermVerify())) { + String url = ContextUtil.getHttpRequest().getHeader(ApplicationConstant.HTTP_HEADER_ORIGINAL_REQUEST_URL); + if (StrUtil.isBlank(url)) { + url = ContextUtil.getHttpRequest().getRequestURI(); + } + Assert.notNull(url); + if (!this.verifyMenuPerm(null, url, sqlId) && !this.verifyMenuPerm(menuId, url, sqlId)) { + String msg = StrFormatter.format("Mismatched DataPerm " + + "for menuId [{}] and url [{}] and SQL_ID [{}].", menuId, url, sqlId); + throw new NoDataPermException(msg); + } + } + return menuDataPermMap; + } + + private Object getCachedData(String dataPermSessionKey) { + Object cachedData; + Cache cache = cacheManager.getCache(CacheConfig.CacheEnum.DATA_PERMISSION_CACHE.name()); + org.springframework.util.Assert.notNull(cache, "Cache [DATA_PERMISSION_CACHE] can't be null."); + Cache.ValueWrapper wrapper = cache.get(dataPermSessionKey); + if (wrapper == null) { + cachedData = redissonClient.getBucket(dataPermSessionKey).get(); + if (cachedData != null) { + cache.put(dataPermSessionKey, JSON.parseObject(cachedData.toString())); + } + } else { + cachedData = wrapper.get(); + } + return cachedData; + } + + @SuppressWarnings("unchecked") + private boolean verifyMenuPerm(String menuId, String url, String sqlId) { + String sessionId = TokenData.takeFromRequest().getSessionId(); + String menuPermSessionKey; + if (menuId != null) { + menuPermSessionKey = RedisKeyUtil.makeSessionMenuPermKey(sessionId, menuId); + } else { + menuPermSessionKey = RedisKeyUtil.makeSessionWhiteListPermKey(sessionId); + } + Cache cache = cacheManager.getCache(CacheConfig.CacheEnum.MENU_PERM_CACHE.name()); + org.springframework.util.Assert.notNull(cache, "Cache [MENU_PERM_CACHE] can't be null!"); + Cache.ValueWrapper wrapper = cache.get(menuPermSessionKey); + if (wrapper != null) { + Object cachedData = wrapper.get(); + if (cachedData != null) { + return ((Set) cachedData).contains(url); + } + } + RBucket bucket = redissonClient.getBucket(menuPermSessionKey); + if (!bucket.isExists()) { + String msg; + if (menuId == null) { + msg = StrFormatter.format("No Related MenuPerm found " + + "in Redis Cache for WHITE_LIST and SQL_ID [{}] with sessionId [{}].", sqlId, sessionId); + } else { + msg = StrFormatter.format("No Related MenuPerm found " + + "in Redis Cache for menuId [{}] and SQL_ID [{}] with sessionId [{}].", menuId, sqlId, sessionId); + } + throw new NoDataPermException(msg); + } + Set cachedMenuPermSet = new HashSet<>(JSONArray.parseArray(bucket.get(), String.class)); + cache.put(menuPermSessionKey, cachedMenuPermSet); + return cachedMenuPermSet.contains(url); + } + + private void processDataPerm( + ModelDataPermInfo info, + Map dataPermMap, + BoundSql boundSql, + SqlCommandType commandType, + Statement statement) throws JSQLParserException { + List criteriaList = new LinkedList<>(); + for (Map.Entry entry : dataPermMap.entrySet()) { + String filterClause = processDataPermRule(info, entry.getKey(), entry.getValue()); + if (StrUtil.isNotBlank(filterClause)) { + criteriaList.add(filterClause); + } + } + if (CollUtil.isEmpty(criteriaList)) { + return; + } + StringBuilder filterBuilder = new StringBuilder(128); + filterBuilder.append("("); + filterBuilder.append(StrUtil.join(" OR ", criteriaList)); + filterBuilder.append(")"); + String dataFilter = filterBuilder.toString(); + if (statement == null) { + String sql = boundSql.getSql(); + statement = CCJSqlParserUtil.parse(sql); + } + if (commandType == SqlCommandType.UPDATE) { + Update update = (Update) statement; + this.buildWhereClause(update, dataFilter); + } else if (commandType == SqlCommandType.DELETE) { + Delete delete = (Delete) statement; + this.buildWhereClause(delete, dataFilter); + } else { + this.processSelect(statement, info, dataFilter); + } + log.info("DataPerm Filter Where Clause [{}]", dataFilter); + ReflectUtil.setFieldValue(boundSql, "sql", statement.toString()); + } + + private void processSelect(Statement statement, ModelDataPermInfo info, String dataFilter) + throws JSQLParserException { + Select select = (Select) statement; + PlainSelect selectBody = (PlainSelect) select.getSelectBody(); + FromItem fromItem = selectBody.getFromItem(); + if (fromItem == null) { + return; + } + PlainSelect subSelect = null; + if (fromItem instanceof SubSelect) { + subSelect = (PlainSelect) ((SubSelect) fromItem).getSelectBody(); + } + if (subSelect != null) { + dataFilter = replaceTableAlias(info.getMainTableName(), subSelect, dataFilter); + buildWhereClause(subSelect, dataFilter); + } else { + dataFilter = replaceTableAlias(info.getMainTableName(), selectBody, dataFilter); + buildWhereClause(selectBody, dataFilter); + } + } + + private String processDataPermRule(ModelDataPermInfo info, Integer ruleType, String dataIds) { + TokenData tokenData = TokenData.takeFromRequest(); + StringBuilder filter = new StringBuilder(128); + String tableName = info.getMainTableName(); + if (ruleType != DataPermRuleType.TYPE_USER_ONLY + && ruleType != DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT_USERS + && ruleType != DataPermRuleType.TYPE_DEPT_USERS) { + return this.processDeptDataPermRule(info, ruleType, dataIds); + } + if (StrUtil.isBlank(info.getUserFilterColumn())) { + log.warn("No UserFilterColumn for table [{}] but USER_FILTER_DATA_PERM exists !!!", tableName); + return filter.toString(); + } + if (BooleanUtil.isTrue(properties.getAddTableNamePrefix())) { + filter.append(info.getMainTableName()).append("."); + } + if (ruleType == DataPermRuleType.TYPE_USER_ONLY) { + filter.append(info.getUserFilterColumn()) + .append(" = ") + .append(tokenData.getUserId()); + } else { + filter.append(info.getUserFilterColumn()) + .append(" IN (") + .append(dataIds) + .append(") "); + } + return filter.toString(); + } + + private String processDeptDataPermRule(ModelDataPermInfo info, Integer ruleType, String deptIds) { + StringBuilder filter = new StringBuilder(128); + String tableName = info.getMainTableName(); + if (StrUtil.isBlank(info.getDeptFilterColumn())) { + log.warn("No DeptFilterColumn for table [{}] but DEPT_FILTER_DATA_PERM exists !!!", tableName); + return filter.toString(); + } + TokenData tokenData = TokenData.takeFromRequest(); + if (ruleType == DataPermRuleType.TYPE_DEPT_ONLY) { + if (BooleanUtil.isTrue(properties.getAddTableNamePrefix())) { + filter.append(info.getMainTableName()).append("."); + } + filter.append(info.getDeptFilterColumn()) + .append(" = ") + .append(tokenData.getDeptId()); + } else if (ruleType == DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT) { + filter.append(" EXISTS ") + .append("(SELECT 1 FROM ") + .append(properties.getDeptRelationTablePrefix()) + .append("sys_dept_relation WHERE ") + .append(properties.getDeptRelationTablePrefix()) + .append("sys_dept_relation.parent_dept_id = ") + .append(tokenData.getDeptId()) + .append(" AND "); + if (BooleanUtil.isTrue(properties.getAddTableNamePrefix())) { + filter.append(info.getMainTableName()).append("."); + } + filter.append(info.getDeptFilterColumn()) + .append(" = ") + .append(properties.getDeptRelationTablePrefix()) + .append("sys_dept_relation.dept_id) "); + } else if (ruleType == DataPermRuleType.TYPE_MULTI_DEPT_AND_CHILD_DEPT) { + filter.append(" EXISTS ") + .append("(SELECT 1 FROM ") + .append(properties.getDeptRelationTablePrefix()) + .append("sys_dept_relation WHERE ") + .append(properties.getDeptRelationTablePrefix()) + .append("sys_dept_relation.parent_dept_id IN (") + .append(deptIds) + .append(") AND "); + if (BooleanUtil.isTrue(properties.getAddTableNamePrefix())) { + filter.append(info.getMainTableName()).append("."); + } + filter.append(info.getDeptFilterColumn()) + .append(" = ") + .append(properties.getDeptRelationTablePrefix()) + .append("sys_dept_relation.dept_id) "); + } else if (ruleType == DataPermRuleType.TYPE_CUSTOM_DEPT_LIST) { + if (BooleanUtil.isTrue(properties.getAddTableNamePrefix())) { + filter.append(info.getMainTableName()).append("."); + } + filter.append(info.getDeptFilterColumn()) + .append(" IN (") + .append(deptIds) + .append(") "); + } + return filter.toString(); + } + + private String replaceTableAlias(String tableName, PlainSelect select, String dataFilter) { + if (select.getFromItem().getAlias() == null) { + return dataFilter; + } + return dataFilter.replaceAll(tableName, select.getFromItem().getAlias().getName()); + } + + private void buildWhereClause(Update update, String dataFilter) throws JSQLParserException { + if (update.getWhere() == null) { + update.setWhere(CCJSqlParserUtil.parseCondExpression(dataFilter)); + } else { + AndExpression and = new AndExpression( + CCJSqlParserUtil.parseCondExpression(dataFilter), update.getWhere()); + update.setWhere(and); + } + } + + private void buildWhereClause(Delete delete, String dataFilter) throws JSQLParserException { + if (delete.getWhere() == null) { + delete.setWhere(CCJSqlParserUtil.parseCondExpression(dataFilter)); + } else { + AndExpression and = new AndExpression( + CCJSqlParserUtil.parseCondExpression(dataFilter), delete.getWhere()); + delete.setWhere(and); + } + } + + private void buildWhereClause(PlainSelect select, String dataFilter) throws JSQLParserException { + if (select.getWhere() == null) { + select.setWhere(CCJSqlParserUtil.parseCondExpression(dataFilter)); + } else { + AndExpression and = new AndExpression( + CCJSqlParserUtil.parseCondExpression(dataFilter), select.getWhere()); + select.setWhere(and); + } + } + + @Override + public Object plugin(Object target) { + return Plugin.wrap(target, this); + } + + @Override + public void setProperties(Properties properties) { + // 这里需要空注解,否则sonar会不happy。 + } + + @Data + private static final class ModelDataPermInfo { + private Set excludeMethodNameSet; + private String userFilterColumn; + private String deptFilterColumn; + private String mainTableName; + private Boolean mustIncludeUserRule; + } + + @Data + private static final class ModelTenantInfo { + private Set excludeMethodNameSet; + private String modelName; + private String tableName; + private String fieldName; + private String columnName; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/listener/LoadDataFilterInfoListener.java b/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/listener/LoadDataFilterInfoListener.java new file mode 100644 index 00000000..5d7cb78b --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/java/com/orangeforms/common/datafilter/listener/LoadDataFilterInfoListener.java @@ -0,0 +1,25 @@ +package com.orangeforms.common.datafilter.listener; + +import com.orangeforms.common.datafilter.interceptor.MybatisDataFilterInterceptor; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; + +/** + * 应用服务启动监听器。 + * 目前主要功能是调用MybatisDataFilterInterceptor中的loadInfoWithDataFilter方法, + * 将标记有过滤注解的数据加载到缓存,以提升系统运行时效率。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class LoadDataFilterInfoListener implements ApplicationListener { + + @Override + public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { + MybatisDataFilterInterceptor interceptor = + applicationReadyEvent.getApplicationContext().getBean(MybatisDataFilterInterceptor.class); + interceptor.loadInfoWithDataFilter(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..a08c930a --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-datafilter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.orangeforms.common.datafilter.config.DataFilterAutoConfig \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dbutil/pom.xml b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/pom.xml new file mode 100644 index 00000000..e7ba325b --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/pom.xml @@ -0,0 +1,54 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-dbutil + 1.0.0 + common-dbutil + jar + + + + com.orangeforms + common-core + 1.0.0 + + + mysql + mysql-connector-java + 8.0.22 + + + org.postgresql + postgresql + runtime + + + com.oracle.database.jdbc + ojdbc6 + 11.2.0.4 + + + com.dameng + DmJdbcDriver18 + 8.1.2.141 + + + org.opengauss + opengauss-jdbc + 5.0.0-og + + + ru.yandex.clickhouse + clickhouse-jdbc + 0.3.2 + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/constant/CustomDateValueType.java b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/constant/CustomDateValueType.java new file mode 100644 index 00000000..258b9a73 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/constant/CustomDateValueType.java @@ -0,0 +1,83 @@ +package com.orangeforms.common.dbutil.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 自定义日期过滤值类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class CustomDateValueType { + /** + * 本日。 + */ + public static final String CURRENT_DAY = "1"; + /** + * 本周。 + */ + public static final String CURRENT_WEEK = "2"; + /** + * 本月。 + */ + public static final String CURRENT_MONTH = "3"; + /** + * 本季度。 + */ + public static final String CURRENT_QUARTER = "4"; + /** + * 今年。 + */ + public static final String CURRENT_YEAR = "5"; + /** + * 昨天。 + */ + public static final String LAST_DAY = "11"; + /** + * 上周。 + */ + public static final String LAST_WEEK = "12"; + /** + * 上月。 + */ + public static final String LAST_MONTH = "13"; + /** + * 上季度。 + */ + public static final String LAST_QUARTER = "14"; + /** + * 去年。 + */ + public static final String LAST_YEAR = "15"; + + private static final Map DICT_MAP = new HashMap<>(2); + static { + DICT_MAP.put(CURRENT_DAY, "本日"); + DICT_MAP.put(CURRENT_WEEK, "本周"); + DICT_MAP.put(CURRENT_MONTH, "本月"); + DICT_MAP.put(CURRENT_QUARTER, "本季度"); + DICT_MAP.put(CURRENT_YEAR, "今年"); + DICT_MAP.put(LAST_DAY, "昨日"); + DICT_MAP.put(LAST_WEEK, "上周"); + DICT_MAP.put(LAST_MONTH, "上月"); + DICT_MAP.put(LAST_QUARTER, "上季度"); + DICT_MAP.put(LAST_YEAR, "去年"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(String value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private CustomDateValueType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/constant/DblinkType.java b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/constant/DblinkType.java new file mode 100644 index 00000000..83c2ecef --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/constant/DblinkType.java @@ -0,0 +1,74 @@ +package com.orangeforms.common.dbutil.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 数据库连接类型常量对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class DblinkType { + + /** + * MySQL。 + */ + public static final int MYSQL = 0; + /** + * PostgreSQL。 + */ + public static final int POSTGRESQL = 1; + /** + * Oracle。 + */ + public static final int ORACLE = 2; + /** + * Dameng。 + */ + public static final int DAMENG = 3; + /** + * 人大金仓。 + */ + public static final int KINGBASE = 4; + /** + * OpenGauss。 + */ + public static final int OPENGAUSS = 5; + /** + * ClickHouse。 + */ + public static final int CLICKHOUSE = 10; + /** + * Doris。 + */ + public static final int DORIS = 11; + + private static final Map DICT_MAP = new HashMap<>(3); + static { + DICT_MAP.put(MYSQL, "MySQL"); + DICT_MAP.put(POSTGRESQL, "PostgreSQL"); + DICT_MAP.put(ORACLE, "Oracle"); + DICT_MAP.put(DAMENG, "Dameng"); + DICT_MAP.put(KINGBASE, "人大金仓"); + DICT_MAP.put(OPENGAUSS, "OpenGauss"); + DICT_MAP.put(CLICKHOUSE, "ClickHouse"); + DICT_MAP.put(DORIS, "Doris"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private DblinkType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/DatasetFilter.java b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/DatasetFilter.java new file mode 100644 index 00000000..8ec9d20a --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/DatasetFilter.java @@ -0,0 +1,52 @@ +package com.orangeforms.common.dbutil.object; + +import com.orangeforms.common.core.constant.FieldFilterType; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; + +/** + * 数据集过滤对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class DatasetFilter extends ArrayList { + + @Data + public static class FilterInfo { + /** + * 过滤的数据集Id。 + */ + private Long datasetId; + /** + * 过滤参数名称。 + */ + private String paramName; + /** + * 过滤参数值是单值时。使用该字段值。 + */ + private Object paramValue; + /** + * 过滤参数值是集合时,使用该字段值。 + */ + private Collection paramValueList; + /** + * 过滤类型。参考常量类 FieldFilterType。 + */ + private Integer filterType = FieldFilterType.EQUAL; + /** + * 是否为日期值的过滤。 + */ + private Boolean dateValueFilter = false; + /** + * 日期精确到。year/month/week/day + */ + private String dateRange; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/DatasetParam.java b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/DatasetParam.java new file mode 100644 index 00000000..03886f41 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/DatasetParam.java @@ -0,0 +1,49 @@ +package com.orangeforms.common.dbutil.object; + +import com.orangeforms.common.core.object.MyOrderParam; +import com.orangeforms.common.core.object.MyPageParam; +import lombok.Data; + +import java.util.List; + +/** + * 数据集查询的各种参数。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class DatasetParam { + + /** + * SELECT选择的字段名列表。 + */ + private List selectColumnNameList; + /** + * 数据集过滤参数。 + */ + private DatasetFilter filter; + /** + * SQL结果集的参数。 + */ + private DatasetFilter sqlFilter; + /** + * 分页参数。 + */ + private MyPageParam pageParam; + /** + * 分组参数。 + */ + private MyOrderParam orderParam; + /** + * 排序字符串。 + */ + private String orderBy; + /** + * 该值目前仅用于SQL类型的结果集。 + * 如果该值为true,SQL结果集中定义的参数都会被替换为 (1 = 1) 的恒成立过滤。 + * 比如 select * from zz_sys_user where user_status = ${status}, + * 该值为true的时会被替换为 select * from zz_sys_user where 1 = 1。 + */ + private Boolean disableSqlDatasetFilter = false; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/GenericResultSet.java b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/GenericResultSet.java new file mode 100644 index 00000000..f3151866 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/GenericResultSet.java @@ -0,0 +1,39 @@ +package com.orangeforms.common.dbutil.object; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 报表通用的查询结果集对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@AllArgsConstructor +@NoArgsConstructor +@Data +public class GenericResultSet { + + /** + * 查询结果集的字段meta数据列表。 + */ + private List columnMetaList; + + /** + * 查询数据集。如果当前结果集为分页查询,将只包含分页数据。 + */ + private List dataList; + + /** + * 查询数据总数。如果当前结果集为分页查询,该值为分页前的数据总数,否则为0。 + */ + private Long totalCount = 0L; + + public GenericResultSet(List columnMetaList, List dataList) { + this.columnMetaList = columnMetaList; + this.dataList = dataList; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/SqlResultSet.java b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/SqlResultSet.java new file mode 100644 index 00000000..7c927194 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/SqlResultSet.java @@ -0,0 +1,28 @@ +package com.orangeforms.common.dbutil.object; + +import cn.hutool.core.collection.CollUtil; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * 直接从数据库获取的查询结果集对象。通常内部使用。 + * + * @author Jerry + * @date 2024-07-02 + */ +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +@Data +public class SqlResultSet extends GenericResultSet { + + public SqlResultSet(List columnMetaList, List dataList) { + super(columnMetaList, dataList); + } + + public static boolean isEmpty(SqlResultSet rs) { + return rs == null || CollUtil.isEmpty(rs.getDataList()); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/SqlTable.java b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/SqlTable.java new file mode 100644 index 00000000..fdda9cf8 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/SqlTable.java @@ -0,0 +1,41 @@ +package com.orangeforms.common.dbutil.object; + +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * 数据库中的表对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class SqlTable { + + /** + * 表名称。 + */ + private String tableName; + + /** + * 表注释。 + */ + private String tableComment; + + /** + * 创建时间。 + */ + private Date createTime; + + /** + * 关联的字段列表。 + */ + private List columnList; + + /** + * 数据库链接Id。 + */ + private Long dblinkId; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/SqlTableColumn.java b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/SqlTableColumn.java new file mode 100644 index 00000000..afd5763f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/object/SqlTableColumn.java @@ -0,0 +1,83 @@ +package com.orangeforms.common.dbutil.object; + +import lombok.Data; + +/** + * 数据库中的表字段对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class SqlTableColumn { + + /** + * 表字段名。 + */ + private String columnName; + + /** + * 字段注释。 + */ + private String columnComment; + + /** + * 表字段类型。 + */ + private String columnType; + + /** + * 表字段全类型。 + */ + private String fullColumnType; + + /** + * 是否自动增长。 + */ + private Boolean autoIncrement; + + /** + * 是否为主键。 + */ + private Boolean primaryKey; + + /** + * 是否可以为空值。 + */ + private Boolean nullable; + + /** + * 字段顺序。 + */ + private Integer columnShowOrder; + + /** + * 附加信息。 + */ + private String extra; + + /** + * 数值型字段精度。 + */ + private Integer numericPrecision; + + /** + * 数值型字段刻度。 + */ + private Integer numericScale; + + /** + * 字符型字段精度。 + */ + private Long stringPrecision; + + /** + * 缺省值。 + */ + private Object columnDefault; + + /** + * 数据库链接类型。该值为冗余字段,只是为了提升运行时效率。 + */ + private int dblinkType; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/DataSourceProvider.java b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/DataSourceProvider.java new file mode 100644 index 00000000..c0a2423f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/DataSourceProvider.java @@ -0,0 +1,108 @@ +package com.orangeforms.common.dbutil.provider; + +/** + * 数据源操作的提供者接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface DataSourceProvider { + + /** + * 返回数据库链接类型,具体值可参考DblinkType常量类。 + * @return 返回数据库链接类型 + */ + int getDblinkType(); + + /** + * 返回Jdbc的配置对象。 + * + * @param configuration Jdbc 的配置数据,JSON格式。 + * @return Jdbc的配置对象。 + */ + JdbcConfig getJdbcConfig(String configuration); + + /** + * 获取当前数据库表meta列表数据的SQL语句。 + * + * @param searchString 表名的模糊匹配字符串。如果为空,则没有前缀规律。 + * @return 查询数据库表meta列表数据的SQL语句。 + */ + String getTableMetaListSql(String searchString); + + /** + * 获取当前数据库表meta数据的SQL语句。 + * + * @return 查询数据库表meta数据的SQL语句。 + */ + String getTableMetaSql(); + + /** + * 获取当前数据库指定表字段meta列表数据的SQL语句。 + * + * @return 查询指定表字段meta列表数据的SQL语句。 + */ + String getTableColumnMetaListSql(); + + /** + * 获取测试数据库连接的查询SQL。 + * + * @return 测试数据库连接的查询SQL + */ + default String getTestQuery() { + return "SELECT 'x'"; + } + + /** + * 为当前的SQL参数,加上分页部分。 + * + * @param sql SQL查询语句。 + * @param pageNum 页号,从1开始。 + * @param pageSize 每页数据量,如果为null,则取出后面所有数据。 + * @return 加上分页功能的SQL语句。 + */ + String makePageSql(String sql, Integer pageNum, Integer pageSize); + + /** + * 将数据表字段类型转换为Java字段类型。 + * + * @param columnType 数据表字段类型。 + * @param numericPrecision 数值精度。 + * @param numericScale 数值刻度。 + * @return 转换后的类型。 + */ + String convertColumnTypeToJavaType(String columnType, Integer numericPrecision, Integer numericScale); + + /** + * Having从句中,统计字段参与过滤时,是否可以直接使用别名。 + * + * @return 返回true,支持"HAVING sumOfColumn > 0",返回false,则为"HAVING sum(count) > 0"。 + */ + default boolean havingClauseUsingAlias() { + return true; + } + + /** + * SELECT的字段别名,是否需要加双引号,对于有些数据库,如果不加双引号,就会被数据库进行强制性的规则转义。 + * + * @return 返回true,SELECT grade_id "gradeId",否则 SELECT grade_id gradeId + */ + default boolean aliasWithQuotes() { + return false; + } + + /** + * 获取日期类型过滤条件语句。 + * + * @param columnName 字段名。 + * @param operator 操作符。 + * @return 过滤从句。 + */ + default String makeDateTimeFilterSql(String columnName, String operator) { + StringBuilder s = new StringBuilder(128); + if (columnName == null) { + columnName = ""; + } + return s.append(columnName).append(" ").append(operator).append(" ?").toString(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/JdbcConfig.java b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/JdbcConfig.java new file mode 100644 index 00000000..031b9541 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/JdbcConfig.java @@ -0,0 +1,62 @@ +package com.orangeforms.common.dbutil.provider; + +import lombok.Data; + +/** + * JDBC配置。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class JdbcConfig { + + /** + * 驱动名。由子类提供。 + */ + private String driver; + /** + * 连接池验证查询的语句。 + */ + private String validationQuery = "SELECT 'x'"; + /** + * Jdbc连接串,需要子类提供实现。 + */ + private String jdbcConnectionString; + /** + * 主机名。 + */ + private String host; + /** + * 端口号。 + */ + private Integer port; + /** + * 用户名。 + */ + private String username; + /** + * 密码。 + */ + private String password; + /** + * 数据库名。 + */ + private String database; + /** + * 模式名。 + */ + private String schema; + /** + * 连接池初始大小。 + */ + private int initialPoolSize = 5; + /** + * 连接池最小连接数。 + */ + private int minPoolSize = 5; + /** + * 连接池最大连接数。 + */ + private int maxPoolSize = 50; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/MySqlConfig.java b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/MySqlConfig.java new file mode 100644 index 00000000..cc7558b2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/MySqlConfig.java @@ -0,0 +1,42 @@ +package com.orangeforms.common.dbutil.provider; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * MySQL JDBC配置。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class MySqlConfig extends JdbcConfig { + + /** + * JDBC 驱动名。 + */ + private String driver = "com.mysql.cj.jdbc.Driver"; + /** + * 数据库JDBC连接串的扩展部分。 + */ + private String extraParams = "?characterEncoding=utf8&useSSL=true&serverTimezone=Asia/Shanghai"; + + /** + * 获取拼好后的JDBC连接串。 + * + * @return 拼好后的JDBC连接串。 + */ + @Override + public String getJdbcConnectionString() { + StringBuilder sb = new StringBuilder(256); + sb.append("jdbc:mysql://") + .append(getHost()) + .append(":") + .append(getPort()) + .append("/") + .append(getDatabase()) + .append(extraParams); + return sb.toString(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/MySqlProvider.java b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/MySqlProvider.java new file mode 100644 index 00000000..e4e52bac --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/provider/MySqlProvider.java @@ -0,0 +1,112 @@ +package com.orangeforms.common.dbutil.provider; + +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.orangeforms.common.core.constant.ObjectFieldType; +import com.orangeforms.common.dbutil.constant.DblinkType; + +/** + * MySQL数据源的提供者实现类。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class MySqlProvider implements DataSourceProvider { + + @Override + public int getDblinkType() { + return DblinkType.MYSQL; + } + + @Override + public JdbcConfig getJdbcConfig(String configuration) { + return JSON.parseObject(configuration, MySqlConfig.class); + } + + @Override + public String getTableMetaListSql(String searchString) { + StringBuilder sql = new StringBuilder(); + sql.append(this.getTableMetaListSql()); + if (StrUtil.isNotBlank(searchString)) { + sql.append(" AND table_name LIKE ?"); + } + return sql.append(" ORDER BY table_name").toString(); + } + + @Override + public String getTableMetaSql() { + return this.getTableMetaListSql() + " AND table_name = ?"; + } + + @Override + public String getTableColumnMetaListSql() { + return "SELECT " + + " column_name columnName, " + + " data_type columnType, " + + " column_type fullColumnType, " + + " column_comment columnComment, " + + " CASE WHEN column_key = 'PRI' THEN 1 ELSE 0 END AS primaryKey, " + + " is_nullable nullable, " + + " ordinal_position columnShowOrder, " + + " extra extra, " + + " CHARACTER_MAXIMUM_LENGTH stringPrecision, " + + " numeric_precision numericPrecision, " + + " COLUMN_DEFAULT columnDefault " + + "FROM " + + " information_schema.columns " + + "WHERE " + + " table_name = ?" + + " AND table_schema = (SELECT database()) " + + "ORDER BY ordinal_position"; + } + + @Override + public String makePageSql(String sql, Integer pageNum, Integer pageSize) { + if (pageSize == null) { + pageSize = 10; + } + int offset = pageNum > 0 ? (pageNum - 1) * pageSize : 0; + return sql + " LIMIT " + offset + "," + pageSize; + } + + @Override + public String convertColumnTypeToJavaType(String columnType, Integer numericPrecision, Integer numericScale) { + if (StrUtil.equalsAnyIgnoreCase(columnType, + "varchar", "char", "text", "longtext", "mediumtext", "tinytext", "enum", "json")) { + return ObjectFieldType.STRING; + } + if (StrUtil.equalsAnyIgnoreCase(columnType, "int", "mediumint", "smallint", "tinyint")) { + return ObjectFieldType.INTEGER; + } + if (StrUtil.equalsIgnoreCase(columnType, "bit")) { + return ObjectFieldType.BOOLEAN; + } + if (StrUtil.equalsIgnoreCase(columnType, "bigint")) { + return ObjectFieldType.LONG; + } + if (StrUtil.equalsIgnoreCase(columnType, "decimal")) { + return ObjectFieldType.BIG_DECIMAL; + } + if (StrUtil.equalsAnyIgnoreCase(columnType, "float", "double")) { + return ObjectFieldType.DOUBLE; + } + if (StrUtil.equalsAnyIgnoreCase(columnType, "date", "datetime", "timestamp", "time")) { + return ObjectFieldType.DATE; + } + if (StrUtil.equalsAnyIgnoreCase(columnType, "longblob", "blob")) { + return ObjectFieldType.BYTE_ARRAY; + } + return null; + } + + private String getTableMetaListSql() { + return "SELECT " + + " table_name tableName, " + + " table_comment tableComment, " + + " create_time createTime " + + "FROM " + + " information_schema.tables " + + "WHERE " + + " table_schema = DATABASE() "; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/util/DataSourceUtil.java b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/util/DataSourceUtil.java new file mode 100644 index 00000000..a3ca1445 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dbutil/src/main/java/com/orangeforms/common/dbutil/util/DataSourceUtil.java @@ -0,0 +1,840 @@ +package com.orangeforms.common.dbutil.util; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.druid.pool.DruidDataSource; +import com.alibaba.druid.pool.DruidDataSourceFactory; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.constant.FieldFilterType; +import com.orangeforms.common.core.exception.InvalidDblinkTypeException; +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.core.object.MyPageParam; +import com.orangeforms.common.core.object.Tuple2; +import com.orangeforms.common.core.util.MyDateUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.dbutil.constant.CustomDateValueType; +import com.orangeforms.common.dbutil.constant.DblinkType; +import com.orangeforms.common.dbutil.object.*; +import com.orangeforms.common.dbutil.provider.DataSourceProvider; +import com.orangeforms.common.dbutil.provider.JdbcConfig; +import com.orangeforms.common.dbutil.provider.MySqlProvider; +import lombok.extern.slf4j.Slf4j; +import net.sf.jsqlparser.parser.CCJSqlParserUtil; +import net.sf.jsqlparser.schema.Column; +import net.sf.jsqlparser.statement.select.PlainSelect; +import net.sf.jsqlparser.statement.select.Select; +import net.sf.jsqlparser.statement.select.SelectExpressionItem; +import net.sf.jsqlparser.statement.select.SelectItem; +import org.joda.time.DateTime; + +import javax.sql.DataSource; +import java.sql.*; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + +/** + * 动态加载的数据源工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public abstract class DataSourceUtil { + + private final Lock lock = new ReentrantLock(); + private final Map datasourceMap = MapUtil.newHashMap(); + private static final Map PROVIDER_MAP = new HashMap<>(5); + protected final Map dblinkProviderMap = new ConcurrentHashMap<>(4); + + private static final String SQL_SELECT = " SELECT "; + private static final String SQL_SELECT_FROM = " SELECT * FROM ("; + private static final String SQL_AS_TMP = " ) tmp "; + private static final String SQL_ORDER_BY = " ORDER BY "; + private static final String SQL_AND = " AND "; + private static final String SQL_WHERE = " WHERE "; + private static final String LOG_PREPARING_FORMAT = "==> Preparing: {}"; + private static final String LOG_PARMS_FORMAT = "==> Parameters: {}"; + private static final String LOG_TOTAL_FORMAT = "<== Total: {}"; + + static { + PROVIDER_MAP.put(DblinkType.MYSQL, new MySqlProvider()); + } + + /** + * 由子类实现,根据dblinkId获取数据库链接类型的方法。 + * + * @param dblinkId 数据库链接Id。 + * @return 数据库链接类型。 + */ + protected abstract int getDblinkTypeByDblinkId(Long dblinkId); + + /** + * 由子类实现,根据dblinkId获取数据库链接配置信息的方法。 + * + * @param dblinkId 数据库链接Id。 + * @return 数据库链接配置信息。 + */ + protected abstract String getDblinkConfigurationByDblinkId(Long dblinkId); + + /** + * 获取指定数据库类型的Provider实现类。 + * + * @param dblinkType 数据库类型。 + * @return 指定数据库类型的Provider实现类。 + */ + public DataSourceProvider getProvider(Integer dblinkType) { + return PROVIDER_MAP.get(dblinkType); + } + + /** + * 获取指定数据库链接的Provider实现类。 + * + * @param dblinkId 数据库链接Id。 + * @return 指定数据库类型的Provider实现类。 + */ + public DataSourceProvider getProvider(Long dblinkId) { + int dblinkType = this.getDblinkTypeByDblinkId(dblinkId); + DataSourceProvider provider = PROVIDER_MAP.get(dblinkType); + if (provider == null) { + throw new InvalidDblinkTypeException(dblinkType); + } + return provider; + } + + /** + * 测试数据库链接。 + * + * @param dblinkId 数据库链接Id。 + */ + public void testConnection(Long dblinkId) throws Exception { + DataSourceProvider provider = this.getProvider(dblinkId); + this.query(dblinkId, provider.getTestQuery()); + } + + /** + * 通过JDBC方式测试链接。 + * + * @param databaseType 数据库类型。参考DblinkType常量值。 + * @param host 主机名。 + * @param port 端口号。 + * @param schemaName 模式名。 + * @param databaseName 数据库名。 + * @param username 用户名。 + * @param password 密码。 + */ + public static void testConnection( + int databaseType, + String host, + Integer port, + String schemaName, + String databaseName, + String username, + String password) { + StringBuilder urlBuilder = new StringBuilder(256); + String hostAndPort = host + ":" + port; + urlBuilder.append("jdbc:mysql://") + .append(hostAndPort) + .append("/") + .append(databaseName) + .append("?characterEncoding=utf8&useSSL=true&serverTimezone=Asia/Shanghai"); + try { + Connection conn = DriverManager.getConnection(urlBuilder.toString(), username, password); + conn.close(); + } catch (SQLException e) { + log.error(e.getMessage(), e); + throw new MyRuntimeException(e.getMessage()); + } + } + + /** + * 根据Dblink对象获取关联的数据源。如果不存在会创建该数据库连接池的数据源, + * 并保存到Map中缓存,下次调用时可直接返回。 + * + * @param dblinkId 数据库链接Id。 + * @return 关联的数据库连接池的数据源。 + */ + public DataSource getDataSource(Long dblinkId) throws Exception { + DataSource dataSource = datasourceMap.get(dblinkId); + if (dataSource != null) { + return dataSource; + } + int dblinkType = this.getDblinkTypeByDblinkId(dblinkId); + DataSourceProvider provider = PROVIDER_MAP.get(dblinkType); + if (provider == null) { + throw new InvalidDblinkTypeException(dblinkType); + } + DruidDataSource druidDataSource = null; + lock.lock(); + try { + dataSource = datasourceMap.get(dblinkId); + if (dataSource != null) { + return dataSource; + } + JdbcConfig jdbcConfig = provider.getJdbcConfig(this.getDblinkConfigurationByDblinkId(dblinkId)); + Properties properties = new Properties(); + druidDataSource = (DruidDataSource) DruidDataSourceFactory.createDataSource(properties); + druidDataSource.setUrl(jdbcConfig.getJdbcConnectionString()); + druidDataSource.setDriverClassName(jdbcConfig.getDriver()); + druidDataSource.setValidationQuery(jdbcConfig.getValidationQuery()); + druidDataSource.setUsername(jdbcConfig.getUsername()); + druidDataSource.setPassword(jdbcConfig.getPassword()); + druidDataSource.setInitialSize(jdbcConfig.getInitialPoolSize()); + druidDataSource.setMinIdle(jdbcConfig.getMinPoolSize()); + druidDataSource.setMaxActive(jdbcConfig.getMaxPoolSize()); + druidDataSource.setConnectionErrorRetryAttempts(2); + druidDataSource.setTimeBetweenConnectErrorMillis(500); + druidDataSource.setBreakAfterAcquireFailure(true); + druidDataSource.init(); + datasourceMap.put(dblinkId, druidDataSource); + return druidDataSource; + } catch (Exception e) { + if (druidDataSource != null) { + druidDataSource.close(); + } + log.error("Failed to create DruidDatasource", e); + throw e; + } finally { + lock.unlock(); + } + } + + /** + * 关闭指定数据库链接Id关联的数据源,同时从缓存中移除该数据源对象。 + * + * @param dblinkId 数据库链接Id。 + */ + public void removeDataSource(Long dblinkId) { + lock.lock(); + try { + DataSource dataSource = datasourceMap.get(dblinkId); + if (dataSource == null) { + return; + } + ((DruidDataSource) dataSource).close(); + datasourceMap.remove(dblinkId); + } finally { + lock.unlock(); + } + } + + /** + * 获取指定数据源的数据库连接对象。 + * + * @param dblinkId 数据库链接Id。 + * @return 数据库连接对象。 + */ + public Connection getConnection(Long dblinkId) throws Exception { + DataSource dataSource = this.getDataSource(dblinkId); + return dataSource == null ? null : dataSource.getConnection(); + } + + /** + * 获取指定数据库链接的数据表列表。 + * + * @param dblinkId 数据库链接Id。 + * @param searchString 表名的模糊匹配字符串。如果为空,则没有前缀规律。 + * @return 数据表对象列表。 + */ + public List getTableList(Long dblinkId, String searchString) { + DataSourceProvider provider = this.getProvider(dblinkId); + List paramList = null; + if (StrUtil.isNotBlank(searchString)) { + paramList = new LinkedList<>(); + paramList.add("%" + searchString + "%"); + } + String querySql = provider.getTableMetaListSql(searchString); + try { + return this.query(dblinkId, querySql, paramList, SqlTable.class); + } catch (Exception e) { + log.error("Failed to call getTableList", e); + throw new MyRuntimeException(e); + } + } + + /** + * 获取指定数据库链接的数据表对象。 + * + * @param dblinkId 数据库链接Id。 + * @param tableName 表名称。 + * @return 数据表对象。 + */ + public SqlTable getTable(Long dblinkId, String tableName) { + DataSourceProvider provider = this.getProvider(dblinkId); + String querySql = provider.getTableMetaSql(); + List paramList = new LinkedList<>(); + paramList.add(tableName); + try { + return this.queryOne(dblinkId, querySql, paramList, SqlTable.class); + } catch (Exception e) { + log.error("Failed to call getTable", e); + throw new MyRuntimeException(e); + } + } + + /** + * 获取指定数据库链接下数据表的字段列表。 + * + * @param dblinkId 数据库链接Id。 + * @param tableName 表名称。 + * @return 数据表的字段列表。 + */ + public List getTableColumnList(Long dblinkId, String tableName) { + try { + DataSource dataSource = this.getDataSource(dblinkId); + try (Connection conn = dataSource.getConnection()) { + return this.getTableColumnList(dblinkId, conn, tableName); + } + } catch (Exception e) { + log.error("Failed to call getTableColumnList", e); + throw new MyRuntimeException(e); + } + } + + /** + * 获取指定数据库链接下数据表的字段列表。 + * + * @param dblinkId 数据库链接Id。 + * @param conn 数据库连接对象。 + * @param tableName 表名称。 + * @return 数据表的字段列表。 + */ + public List getTableColumnList(Long dblinkId, Connection conn, String tableName) { + DataSourceProvider provider = this.getProvider(dblinkId); + String querySql = provider.getTableColumnMetaListSql(); + List paramList = new LinkedList<>(); + paramList.add(tableName); + try { + List> dataList = this.query(conn, querySql, paramList); + return this.toTypedDataList(dataList, SqlTableColumn.class); + } catch (Exception e) { + log.error("Failed to call getTableColumnList", e); + throw new MyRuntimeException(e); + } + } + + /** + * 获取指定表的数据。 + * + * @param dblinkId 数据库链接Id。 + * @param tableName 表名。 + * @param datasetParam 数据集查询参数对象。 + * @return 表的数据结果。 + */ + public SqlResultSet> getTableDataList( + Long dblinkId, String tableName, DatasetParam datasetParam) throws Exception { + SqlTable table = this.getTable(dblinkId, tableName); + if (table == null) { + return null; + } + DataSourceProvider provider = this.getProvider(dblinkId); + if (datasetParam == null) { + datasetParam = new DatasetParam(); + } + String sql = "SELECT * FROM " + tableName; + if (CollUtil.isNotEmpty(datasetParam.getSelectColumnNameList())) { + sql = SQL_SELECT + StrUtil.join(",", datasetParam.getSelectColumnNameList()) + " FROM " + tableName; + } + Tuple2> filterTuple = this.buildWhereClauseByFilters(dblinkId, datasetParam.getFilter()); + sql += filterTuple.getFirst(); + List paramList = filterTuple.getSecond(); + String sqlCount = null; + MyPageParam pageParam = datasetParam.getPageParam(); + if (pageParam != null) { + net.sf.jsqlparser.statement.Statement statement = CCJSqlParserUtil.parse(sql); + Select select = (Select) statement; + PlainSelect selectBody = (PlainSelect) select.getSelectBody(); + List countSelectItems = new LinkedList<>(); + countSelectItems.add(new SelectExpressionItem(new Column("COUNT(1) AS CNT"))); + selectBody.setSelectItems(countSelectItems); + sqlCount = select.toString(); + sql = provider.makePageSql(sql, pageParam.getPageNum(), pageParam.getPageSize()); + } + return this.getDataListInternnally(dblinkId, provider, sqlCount, sql, datasetParam, paramList); + } + + /** + * 在指定数据库链接上执行查询语句,并返回指定映射对象类型的单条数据对象。 + * + * @param dblinkId 数据库链接Id。 + * @param query 待执行的SQL语句。 + * @param paramList 参数列表。 + * @param clazz 返回的映射对象Class类型。 + * @return 查询的结果对象。 + */ + public T queryOne(Long dblinkId, String query, List paramList, Class clazz) throws Exception { + List dataList = this.query(dblinkId, query, paramList, clazz); + return CollUtil.isEmpty(dataList) ? null : dataList.get(0); + } + + /** + * 在指定数据库链接上执行查询语句,并返回指定映射对象类型的数据列表。 + * + * @param dblinkId 数据库链接Id。 + * @param query 待执行的SQL语句。 + * @param paramList 参数列表。 + * @param clazz 返回的映射对象Class类型。 + * @return 查询的结果集。 + */ + public List query(Long dblinkId, String query, List paramList, Class clazz) throws Exception { + List> dataList = this.query(dblinkId, query, paramList); + return this.toTypedDataList(dataList, clazz); + } + + /** + * 在指定数据库链接上执行查询语句。 + * + * @param dblinkId 数据库链接Id。 + * @param query 待执行的SQL语句。 + * @return 查询的结果集。 + */ + public List> query(Long dblinkId, String query) throws Exception { + DataSource dataSource = this.getDataSource(dblinkId); + try (Connection conn = dataSource.getConnection()) { + return this.query(conn, query); + } catch (Exception e) { + log.error(e.getMessage(), e); + throw e; + } + } + + /** + * 在指定数据库链接上执行查询语句。 + * + * @param dblinkId 数据库链接Id。 + * @param query 待执行的SQL语句。 + * @param paramList 参数列表。 + * @return 查询的结果集。 + */ + public List> query(Long dblinkId, String query, List paramList) throws Exception { + DataSource dataSource = this.getDataSource(dblinkId); + try (Connection conn = dataSource.getConnection()) { + return this.query(conn, query, paramList); + } + } + + /** + * 计算过滤从句和过滤参数。 + * + * @param dblinkId 数据库链接Id。 + * @param filter 过滤参数列表。 + * @return 返回的Tuple对象的第一个参数是WHERE从句,第二个参数是过滤从句用到的参数列表。 + */ + public Tuple2> buildWhereClauseByFilters(Long dblinkId, DatasetFilter filter) { + filter = this.normalizeFilter(filter); + if (CollUtil.isEmpty(filter)) { + return new Tuple2<>("", null); + } + DataSourceProvider provider = this.getProvider(dblinkId); + StringBuilder where = new StringBuilder(); + int i = 0; + List paramList = new LinkedList<>(); + for (DatasetFilter.FilterInfo filterInfo : filter) { + if (i++ == 0) { + where.append(SQL_WHERE); + } else { + where.append(SQL_AND); + } + this.doBuildWhereClauseByFilter(filterInfo, provider, where, paramList); + } + return new Tuple2<>(where.toString(), paramList); + } + + private void doBuildWhereClauseByFilter( + DatasetFilter.FilterInfo filterInfo, + DataSourceProvider provider, + StringBuilder where, + List paramList) { + where.append(filterInfo.getParamName()); + if (filterInfo.getFilterType().equals(FieldFilterType.EQUAL)) { + this.doBuildWhereClauseByEqualFilter(filterInfo, provider, where, paramList); + } else if (filterInfo.getFilterType().equals(FieldFilterType.NOT_EQUAL)) { + where.append(" <> ?"); + paramList.add(filterInfo.getParamValue()); + } else if (filterInfo.getFilterType().equals(FieldFilterType.GE)) { + this.doBuildWhereClauseByGeFilter(filterInfo, provider, where, paramList); + } else if (filterInfo.getFilterType().equals(FieldFilterType.GT)) { + this.doBuildWhereClauseByGtFilter(filterInfo, provider, where, paramList); + } else if (filterInfo.getFilterType().equals(FieldFilterType.LE)) { + this.doBuildWhereClauseByLeFilter(filterInfo, provider, where, paramList); + } else if (filterInfo.getFilterType().equals(FieldFilterType.LT)) { + this.doBuildWhereClauseByLtFilter(filterInfo, provider, where, paramList); + } else if (filterInfo.getFilterType().equals(FieldFilterType.BETWEEN)) { + this.doBuildWhereClauseByBetweenFilter(filterInfo, provider, where, paramList); + } else if (filterInfo.getFilterType().equals(FieldFilterType.LIKE)) { + where.append(" LIKE ?"); + paramList.add("%" + filterInfo.getParamValue() + "%"); + } else if (filterInfo.getFilterType().equals(FieldFilterType.IN)) { + where.append(" IN ("); + where.append(StrUtil.repeatAndJoin("?", filterInfo.getParamValueList().size(), ",")); + where.append(")"); + paramList.addAll(filterInfo.getParamValueList()); + } else if (filterInfo.getFilterType().equals(FieldFilterType.NOT_IN)) { + where.append(" NOT IN ("); + where.append(StrUtil.repeatAndJoin("?", filterInfo.getParamValueList().size(), ",")); + where.append(")"); + paramList.addAll(filterInfo.getParamValueList()); + } else if (filterInfo.getFilterType().equals(FieldFilterType.IS_NOT_NULL)) { + where.append(" IS NOT NULL"); + } else if (filterInfo.getFilterType().equals(FieldFilterType.IS_NULL)) { + where.append(" IS NULL"); + } + } + + private void doBuildWhereClauseByEqualFilter( + DatasetFilter.FilterInfo filter, + DataSourceProvider provider, + StringBuilder where, + List paramList) { + if (BooleanUtil.isTrue(filter.getDateValueFilter())) { + String beginDateTime = this.getBeginDateTime(filter.getParamValue().toString(), filter.getDateRange()); + String endDateTime = this.getEndDateTime(filter.getParamValue().toString(), filter.getDateRange()); + where.append(provider.makeDateTimeFilterSql(null, ">=")); + where.append(SQL_AND); + where.append(provider.makeDateTimeFilterSql(filter.getParamName(), "<=")); + paramList.add(beginDateTime); + paramList.add(endDateTime); + } else { + where.append(" = ?"); + paramList.add(filter.getParamValue()); + } + } + + private void doBuildWhereClauseByGeFilter( + DatasetFilter.FilterInfo filter, + DataSourceProvider provider, + StringBuilder where, + List paramList) { + if (BooleanUtil.isTrue(filter.getDateValueFilter())) { + where.append(provider.makeDateTimeFilterSql(null, ">=")); + paramList.add(this.getBeginDateTime(filter.getParamValue().toString(), filter.getDateRange())); + } else { + paramList.add(filter.getParamValue()); + where.append(" >= ?"); + } + } + + private void doBuildWhereClauseByGtFilter( + DatasetFilter.FilterInfo filter, + DataSourceProvider provider, + StringBuilder where, + List paramList) { + if (BooleanUtil.isTrue(filter.getDateValueFilter())) { + where.append(provider.makeDateTimeFilterSql(null, ">")); + paramList.add(this.getEndDateTime(filter.getParamValue().toString(), filter.getDateRange())); + } else { + where.append(" > ?"); + paramList.add(filter.getParamValue()); + } + } + + private void doBuildWhereClauseByLeFilter( + DatasetFilter.FilterInfo filter, + DataSourceProvider provider, + StringBuilder where, + List paramList) { + if (BooleanUtil.isTrue(filter.getDateValueFilter())) { + where.append(provider.makeDateTimeFilterSql(null, "<=")); + paramList.add(this.getEndDateTime(filter.getParamValue().toString(), filter.getDateRange())); + } else { + where.append(" <= ?"); + paramList.add(filter.getParamValue()); + } + } + + private void doBuildWhereClauseByLtFilter( + DatasetFilter.FilterInfo filter, + DataSourceProvider provider, + StringBuilder where, + List paramList) { + if (BooleanUtil.isTrue(filter.getDateValueFilter())) { + where.append(provider.makeDateTimeFilterSql(null, "<")); + paramList.add(this.getBeginDateTime(filter.getParamValue().toString(), filter.getDateRange())); + } else { + where.append(" < ?"); + paramList.add(filter.getParamValue()); + } + } + + private void doBuildWhereClauseByBetweenFilter( + DatasetFilter.FilterInfo filter, + DataSourceProvider provider, + StringBuilder where, + List paramList) { + if (CollUtil.isEmpty(filter.getParamValueList())) { + return; + } + if (BooleanUtil.isTrue(filter.getDateValueFilter())) { + Object[] filterArray = filter.getParamValueList().toArray(); + where.append(provider.makeDateTimeFilterSql(null, ">=")); + paramList.add(this.getBeginDateTime(filterArray[0].toString(), filter.getDateRange())); + where.append(SQL_AND); + where.append(filter.getParamName()); + where.append(provider.makeDateTimeFilterSql(null, "<=")); + paramList.add(this.getEndDateTime(filterArray[1].toString(), filter.getDateRange())); + } else { + where.append(" BETWEEN ? AND ?"); + paramList.add(filter.getParamValueList()); + } + } + + private SqlResultSet> getDataListInternnally( + Long dblinkId, + DataSourceProvider provider, + String sqlCount, + String sql, + DatasetParam datasetParam, + List paramList) throws Exception { + Long totalCount = 0L; + SqlResultSet> resultSet = null; + try (Connection connection = this.getConnection(dblinkId)) { + boolean ignoreQueryData = false; + if (sqlCount != null) { + Map data = this.query(connection, sqlCount, paramList).get(0); + String key = data.entrySet().iterator().next().getKey(); + totalCount = (Long) data.get(key); + if (totalCount == 0L) { + ignoreQueryData = true; + } + } + if (!ignoreQueryData) { + if (datasetParam.getOrderBy() != null) { + sql += SQL_ORDER_BY + datasetParam.getOrderBy(); + } + resultSet = this.queryWithMeta(connection, sql, paramList); + resultSet.setTotalCount(totalCount); + } + } + return resultSet == null ? new SqlResultSet<>() : resultSet; + } + + private List> query(Connection conn, String query) throws SQLException { + try (Statement stat = conn.createStatement(); + ResultSet rs = stat.executeQuery(query)) { + log.info(LOG_PREPARING_FORMAT, query); + List> resultList = this.fetchResult(rs); + log.info(LOG_TOTAL_FORMAT, resultList.size()); + return resultList; + } catch (SQLException e) { + log.error(e.getMessage(), e); + throw e; + } + } + + private List> query(Connection conn, String query, List paramList) throws SQLException { + if (CollUtil.isEmpty(paramList)) { + return this.query(conn, query); + } + ResultSet rs = null; + try (PreparedStatement stat = conn.prepareStatement(query)) { + for (int i = 0; i < paramList.size(); i++) { + stat.setObject(i + 1, paramList.get(i)); + } + rs = stat.executeQuery(); + log.info(LOG_PREPARING_FORMAT, query); + List> resultList = this.fetchResult(rs); + log.info(LOG_TOTAL_FORMAT, resultList.size()); + return resultList; + } catch (SQLException e) { + log.error(e.getMessage(), e); + throw e; + } finally { + if (rs != null) { + try { + rs.close(); + } catch (Exception e) { + log.error("Failed to call rs.close", e); + } + } + } + } + + private SqlResultSet> queryWithMeta( + Connection connection, String query, List paramList) throws SQLException { + if (CollUtil.isEmpty(paramList)) { + try (Statement stat = connection.createStatement(); + ResultSet rs = stat.executeQuery(query)) { + log.info(LOG_PREPARING_FORMAT, query); + SqlResultSet> resultSet = this.fetchResultWithMeta(rs); + log.info(LOG_TOTAL_FORMAT, resultSet.getDataList() == null ? 0 : resultSet.getDataList().size()); + return resultSet; + } catch (SQLException e) { + log.error(e.getMessage(), e); + throw e; + } + } + ResultSet rs = null; + try (PreparedStatement stat = connection.prepareStatement(query)) { + for (int i = 0; i < paramList.size(); i++) { + stat.setObject(i + 1, paramList.get(i)); + } + rs = stat.executeQuery(); + log.info(LOG_PREPARING_FORMAT, query); + SqlResultSet> resultSet = this.fetchResultWithMeta(rs); + log.info(LOG_TOTAL_FORMAT, resultSet.getDataList() == null ? 0 : resultSet.getDataList().size()); + return resultSet; + } catch (SQLException e) { + log.error(e.getMessage(), e); + throw e; + } finally { + if (rs != null) { + try { + rs.close(); + } catch (Exception e) { + log.error("Failed to call rs.close", e); + } + } + } + } + + private List> fetchResult(ResultSet rs) throws SQLException { + ResultSetMetaData metaData = rs.getMetaData(); + int columnCount = metaData.getColumnCount(); + List> resultList = new LinkedList<>(); + while (rs.next()) { + JSONObject rowData = new JSONObject(); + for (int i = 0; i < columnCount; i++) { + rowData.put(metaData.getColumnLabel(i + 1), rs.getObject(i + 1)); + } + resultList.add(rowData); + } + return resultList; + } + + private SqlResultSet> fetchResultWithMeta(ResultSet rs) throws SQLException { + ResultSetMetaData metaData = rs.getMetaData(); + List columnMetaList = new LinkedList<>(); + int columnCount = metaData.getColumnCount(); + for (int i = 0; i < columnCount; i++) { + SqlTableColumn tableColumn = new SqlTableColumn(); + String columnLabel = metaData.getColumnLabel(i + 1); + tableColumn.setColumnName(columnLabel); + tableColumn.setColumnType(metaData.getColumnTypeName(i + 1)); + columnMetaList.add(tableColumn); + } + List> resultList = new LinkedList<>(); + while (rs.next()) { + JSONObject rowData = new JSONObject(); + for (int i = 0; i < columnCount; i++) { + rowData.put(metaData.getColumnLabel(i + 1), rs.getObject(i + 1)); + } + resultList.add(rowData); + } + return new SqlResultSet<>(columnMetaList, resultList); + } + + private List toTypedDataList(List> dataList, Class clazz) { + return MyModelUtil.mapToBeanList(dataList, clazz); + } + + private String getBeginDateTime(String dateValueType, String dateRange) { + DateTime now = DateTime.now(); + switch (dateValueType) { + case CustomDateValueType.CURRENT_DAY: + return MyDateUtil.getBeginTimeOfDayWithShort(now); + case CustomDateValueType.CURRENT_WEEK: + return MyDateUtil.getBeginDateTimeOfWeek(now); + case CustomDateValueType.CURRENT_MONTH: + return MyDateUtil.getBeginDateTimeOfMonth(now); + case CustomDateValueType.CURRENT_YEAR: + return MyDateUtil.getBeginDateTimeOfYear(now); + case CustomDateValueType.CURRENT_QUARTER: + return MyDateUtil.getBeginDateTimeOfQuarter(now); + case CustomDateValueType.LAST_DAY: + return MyDateUtil.getBeginTimeOfDay(now.minusDays(1)); + case CustomDateValueType.LAST_WEEK: + return MyDateUtil.getBeginDateTimeOfWeek(now.minusWeeks(1)); + case CustomDateValueType.LAST_MONTH: + return MyDateUtil.getBeginDateTimeOfMonth(now.minusMonths(1)); + case CustomDateValueType.LAST_YEAR: + return MyDateUtil.getBeginDateTimeOfYear(now.minusYears(1)); + case CustomDateValueType.LAST_QUARTER: + return MyDateUtil.getBeginDateTimeOfQuarter(now.minusMonths(3)); + default: + break; + } + // 执行到这里,基本就是自定义日期数据了 + if (StrUtil.isBlank(dateRange)) { + return dateValueType; + } + DateTime dateValue = MyDateUtil.toDateTimeWithoutMs(dateValueType); + switch (dateRange) { + case "year": + return MyDateUtil.getBeginDateTimeOfYear(dateValue); + case "month": + return MyDateUtil.getBeginDateTimeOfMonth(dateValue); + case "week": + return MyDateUtil.getBeginDateTimeOfWeek(dateValue); + case "date": + return MyDateUtil.getBeginTimeOfDayWithShort(dateValue); + default: + break; + } + return dateValueType; + } + + private String getEndDateTime(String dateValueType, String dateRange) { + DateTime now = DateTime.now(); + switch (dateValueType) { + case CustomDateValueType.CURRENT_DAY: + return MyDateUtil.getEndTimeOfDayWithShort(now); + case CustomDateValueType.CURRENT_WEEK: + return MyDateUtil.getEndDateTimeOfWeek(now); + case CustomDateValueType.CURRENT_MONTH: + return MyDateUtil.getEndDateTimeOfMonth(now); + case CustomDateValueType.CURRENT_YEAR: + return MyDateUtil.getEndDateTimeOfYear(now); + case CustomDateValueType.CURRENT_QUARTER: + return MyDateUtil.getEndDateTimeOfQuarter(now); + case CustomDateValueType.LAST_DAY: + return MyDateUtil.getEndTimeOfDay(now.minusDays(1)); + case CustomDateValueType.LAST_WEEK: + return MyDateUtil.getEndDateTimeOfWeek(now.minusWeeks(1)); + case CustomDateValueType.LAST_MONTH: + return MyDateUtil.getEndDateTimeOfMonth(now.minusMonths(1)); + case CustomDateValueType.LAST_YEAR: + return MyDateUtil.getEndDateTimeOfYear(now.minusYears(1)); + case CustomDateValueType.LAST_QUARTER: + return MyDateUtil.getEndDateTimeOfQuarter(now.minusMonths(3)); + default: + break; + } + // 执行到这里,基本就是自定义日期数据了 + if (StrUtil.isBlank(dateRange)) { + return dateValueType; + } + DateTime dateValue = MyDateUtil.toDateTimeWithoutMs(dateValueType); + switch (dateRange) { + case "year": + return MyDateUtil.getEndDateTimeOfYear(dateValue); + case "month": + return MyDateUtil.getEndDateTimeOfMonth(dateValue); + case "week": + return MyDateUtil.getEndDateTimeOfWeek(dateValue); + case "date": + return MyDateUtil.getEndTimeOfDayWithShort(dateValue); + default: + break; + } + return dateValueType; + } + + private DatasetFilter normalizeFilter(DatasetFilter filter) { + if (CollUtil.isEmpty(filter)) { + return filter; + } + DatasetFilter normalizedFilter = new DatasetFilter(); + for (DatasetFilter.FilterInfo filterInfo : filter) { + if (filterInfo.getFilterType().equals(FieldFilterType.IS_NULL) + || filterInfo.getFilterType().equals(FieldFilterType.IS_NOT_NULL) + || filterInfo.getParamValue() != null + || filterInfo.getParamValueList() != null) { + normalizedFilter.add(filterInfo); + } + } + return normalizedFilter; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/pom.xml b/OrangeFormsOpen-MybatisPlus/common/common-dict/pom.xml new file mode 100644 index 00000000..c2fc5d2d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/pom.xml @@ -0,0 +1,31 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-dict + + + + com.orangeforms + common-redis + 1.0.0 + + + com.orangeforms + common-sequence + 1.0.0 + + + com.orangeforms + common-swagger + 1.0.0 + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/constant/GlobalDictItemStatus.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/constant/GlobalDictItemStatus.java new file mode 100644 index 00000000..3076abfa --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/constant/GlobalDictItemStatus.java @@ -0,0 +1,44 @@ +package com.orangeforms.common.dict.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 全局字典项目数据状态。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class GlobalDictItemStatus { + + /** + * 正常。 + */ + public static final int NORMAL = 0; + /** + * 禁用。 + */ + public static final int DISABLED = 1; + + private static final Map DICT_MAP = new HashMap<>(4); + static { + DICT_MAP.put(NORMAL, "正常"); + DICT_MAP.put(DISABLED, "禁用"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private GlobalDictItemStatus() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/GlobalDictItemMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/GlobalDictItemMapper.java new file mode 100644 index 00000000..640491b6 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/GlobalDictItemMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.dict.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.dict.model.GlobalDictItem; + +/** + * 全局字典项目数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface GlobalDictItemMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/GlobalDictMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/GlobalDictMapper.java new file mode 100644 index 00000000..f924430a --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/GlobalDictMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.dict.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.dict.model.GlobalDict; + +/** + * 全局字典数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface GlobalDictMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/TenantGlobalDictItemMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/TenantGlobalDictItemMapper.java new file mode 100644 index 00000000..8a744d02 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/TenantGlobalDictItemMapper.java @@ -0,0 +1,54 @@ +package com.orangeforms.common.dict.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.dict.model.TenantGlobalDictItem; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 租户全局字典项目数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface TenantGlobalDictItemMapper extends BaseDaoMapper { + + /** + * 批量插入。 + * + * @param dictItemList 字典条目列表。 + */ + @Insert("") + void insertList(@Param("dictItemList") List dictItemList); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/TenantGlobalDictMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/TenantGlobalDictMapper.java new file mode 100644 index 00000000..6735d704 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dao/TenantGlobalDictMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.dict.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.dict.model.TenantGlobalDict; + +/** + * 租户全局字典数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface TenantGlobalDictMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/GlobalDictDto.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/GlobalDictDto.java new file mode 100644 index 00000000..564655d7 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/GlobalDictDto.java @@ -0,0 +1,40 @@ +package com.orangeforms.common.dict.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import com.orangeforms.common.core.validator.UpdateGroup; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 全局系统字典Dto。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "全局系统字典Dto") +@Data +public class GlobalDictDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long dictId; + + /** + * 字典编码。 + */ + @Schema(description = "字典编码") + @NotBlank(message = "数据验证失败,字典编码不能为空!") + private String dictCode; + + /** + * 字典中文名称。 + */ + @Schema(description = "字典中文名称") + @NotBlank(message = "数据验证失败,字典中文名称不能为空!") + private String dictName; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/GlobalDictItemDto.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/GlobalDictItemDto.java new file mode 100644 index 00000000..e80a934f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/GlobalDictItemDto.java @@ -0,0 +1,54 @@ +package com.orangeforms.common.dict.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import com.orangeforms.common.core.validator.UpdateGroup; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 全局系统字典项目Dto。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "全局系统字典项目Dto") +@Data +public class GlobalDictItemDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long id; + + /** + * 字典编码。 + */ + @Schema(description = "字典编码") + @NotBlank(message = "数据验证失败,字典编码不能为空!") + private String dictCode; + + /** + * 字典数据项Id。 + */ + @Schema(description = "字典数据项Id") + @NotNull(message = "数据验证失败,字典数据项Id不能为空!") + private String itemId; + + /** + * 字典数据项名称。 + */ + @Schema(description = "字典数据项名称") + @NotBlank(message = "数据验证失败,字典数据项名称不能为空!") + private String itemName; + + /** + * 显示顺序(数值越小越靠前)。 + */ + @Schema(description = "显示顺序") + @NotNull(message = "数据验证失败,显示顺序不能为空!") + private Integer showOrder; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/TenantGlobalDictDto.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/TenantGlobalDictDto.java new file mode 100644 index 00000000..63f55953 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/TenantGlobalDictDto.java @@ -0,0 +1,29 @@ +package com.orangeforms.common.dict.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 租户全局系统字典Dto。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "租户全局系统字典Dto") +@EqualsAndHashCode(callSuper = true) +@Data +public class TenantGlobalDictDto extends GlobalDictDto { + + /** + * 是否为所有租户的通用字典。 + */ + @Schema(description = "是否为所有租户的通用字典") + private Boolean tenantCommon; + + /** + * 租户的非公用字典的初始化字典数据。 + */ + @Schema(description = "租户的非公用字典的初始化字典数据") + private String initialData; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/TenantGlobalDictItemDto.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/TenantGlobalDictItemDto.java new file mode 100644 index 00000000..f6ac99a6 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/dto/TenantGlobalDictItemDto.java @@ -0,0 +1,18 @@ +package com.orangeforms.common.dict.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 租户全局系统字典项目Dto。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "租户全局系统字典项目Dto") +@EqualsAndHashCode(callSuper = true) +@Data +public class TenantGlobalDictItemDto extends GlobalDictItemDto { + +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/model/GlobalDict.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/model/GlobalDict.java new file mode 100644 index 00000000..ffd91552 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/model/GlobalDict.java @@ -0,0 +1,66 @@ +package com.orangeforms.common.dict.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +import java.util.Date; + +/** + * 全局系统字典实体类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_global_dict") +public class GlobalDict { + + /** + * 主键Id。 + */ + @TableId(value = "dict_id") + private Long dictId; + + /** + * 字典编码。 + */ + @TableField(value = "dict_code") + private String dictCode; + + /** + * 字典中文名称。 + */ + @TableField(value = "dict_name") + private String dictName; + + /** + * 更新用户名。 + */ + @TableField(value = "update_user_id") + private Long updateUserId; + + /** + * 更新时间。 + */ + @TableField(value = "update_time") + private Date updateTime; + + /** + * 创建用户Id。 + */ + @TableField(value = "create_user_id") + private Long createUserId; + + /** + * 创建时间。 + */ + @TableField(value = "create_time") + private Date createTime; + + /** + * 逻辑删除字段。 + */ + @TableLogic + @TableField(value = "deleted_flag") + private Integer deletedFlag; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/model/GlobalDictItem.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/model/GlobalDictItem.java new file mode 100644 index 00000000..fa73d48f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/model/GlobalDictItem.java @@ -0,0 +1,83 @@ +package com.orangeforms.common.dict.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +import java.util.Date; + +/** + * 全局系统字典项目实体类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_global_dict_item") +public class GlobalDictItem { + + /** + * 主键Id。 + */ + @TableId(value = "id") + private Long id; + + /** + * 字典编码。 + */ + @TableField(value = "dict_code") + private String dictCode; + + /** + * 字典数据项Id。 + */ + @TableField(value = "item_id") + private String itemId; + + /** + * 字典数据项名称。 + */ + @TableField(value = "item_name") + private String itemName; + + /** + * 显示顺序(数值越小越靠前)。 + */ + @TableField(value = "show_order") + private Integer showOrder; + + /** + * 字典状态。具体值引用DictItemStatus常量类。 + */ + private Integer status; + + /** + * 创建时间。 + */ + @TableField(value = "create_time") + private Date createTime; + + /** + * 创建用户Id。 + */ + @TableField(value = "create_user_id") + private Long createUserId; + + /** + * 更新用户名。 + */ + @TableField(value = "update_user_id") + private Long updateUserId; + + /** + * 更新时间。 + */ + @TableField(value = "update_time") + private Date updateTime; + + /** + * 逻辑删除字段。 + */ + @TableLogic + @TableField(value = "deleted_flag") + private Integer deletedFlag; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/model/TenantGlobalDict.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/model/TenantGlobalDict.java new file mode 100644 index 00000000..3aa846d0 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/model/TenantGlobalDict.java @@ -0,0 +1,29 @@ +package com.orangeforms.common.dict.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 租户全局系统字典实体类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@TableName(value = "zz_tenant_global_dict") +public class TenantGlobalDict extends GlobalDict { + + /** + * 是否为所有租户的通用字典。 + */ + @TableField(value = "tenant_common") + private Boolean tenantCommon; + + /** + * 租户的非公用字典的初始化字典数据。 + */ + @TableField(value = "initial_data") + private String initialData; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/model/TenantGlobalDictItem.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/model/TenantGlobalDictItem.java new file mode 100644 index 00000000..bf5b73b0 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/model/TenantGlobalDictItem.java @@ -0,0 +1,23 @@ +package com.orangeforms.common.dict.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 租户全局系统字典项目实体类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@TableName(value = "zz_tenant_global_dict_item") +public class TenantGlobalDictItem extends GlobalDictItem { + + /** + * 租户Id。 + */ + @TableField(value = "tenant_id") + private Long tenantId; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/GlobalDictItemService.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/GlobalDictItemService.java new file mode 100644 index 00000000..66750ff7 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/GlobalDictItemService.java @@ -0,0 +1,92 @@ +package com.orangeforms.common.dict.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.dict.model.GlobalDictItem; + +import java.io.Serializable; +import java.util.List; + +/** + * 全局字典项目数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface GlobalDictItemService extends IBaseService { + + /** + * 保存新增的全局字典项目。 + * + * @param globalDictItem 新字典项目对象。 + * @return 保存后的对象。 + */ + GlobalDictItem saveNew(GlobalDictItem globalDictItem); + + /** + * 更新全局字典项目对象。 + * + * @param globalDictItem 更新的全局字典项目对象。 + * @param originalGlobalDictItem 原有的全局字典项目对象。 + * @return 更新成功返回true,否则false。 + */ + boolean update(GlobalDictItem globalDictItem, GlobalDictItem originalGlobalDictItem); + + /** + * 更新字典条目的编码。 + * + * @param oldCode 原有编码。 + * @param newCode 新编码。 + */ + void updateNewCode(String oldCode, String newCode); + + /** + * 更新字典条目的状态。 + * + * @param globalDictItem 字典项目对象。 + * @param status 状态值。 + */ + void updateStatus(GlobalDictItem globalDictItem, Integer status); + + /** + * 删除指定字典项目。 + * + * @param globalDictItem 待删除字典项目。 + * @return 成功返回true,否则false。 + */ + boolean remove(GlobalDictItem globalDictItem); + + /** + * 判断指定的编码和项目Id是否存在。 + * + * @param dictCode 字典编码。 + * @param itemId 项目Id。 + * @return true存在,否则false。 + */ + boolean existDictCodeAndItemId(String dictCode, Serializable itemId); + + /** + * 根据字典编码和项目Id获取指定字段项目对象。 + * + * @param dictCode 字典编码。 + * @param itemId 项目Id。 + * @return 字典项目对象。 + */ + GlobalDictItem getGlobalDictItemByDictCodeAndItemId(String dictCode, Serializable itemId); + + /** + * 查询数据字典项目列表。 + * + * @param filter 过滤对象。 + * @param orderBy 排序字符串,如果为空,则按照showOrder升序排序。 + * @return 查询结果列表。 + */ + List getGlobalDictItemList(GlobalDictItem filter, String orderBy); + + /** + * 查询指定字典编码的数据字典项目列表。查询结果按照showOrder升序排序。 + * + * @param dictCode 过滤对象。 + * @return 查询结果列表。 + */ + List getGlobalDictItemListByDictCode(String dictCode); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/GlobalDictService.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/GlobalDictService.java new file mode 100644 index 00000000..2eaadcf2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/GlobalDictService.java @@ -0,0 +1,108 @@ +package com.orangeforms.common.dict.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.dict.model.GlobalDict; +import com.orangeforms.common.dict.model.GlobalDictItem; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 全局字典数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface GlobalDictService extends IBaseService { + + /** + * 保存全局字典对象。 + * + * @param globalDict 全局字典对象。 + * @return 保存后的字典对象。 + */ + GlobalDict saveNew(GlobalDict globalDict); + + /** + * 更新全局字典对象。 + * + * @param globalDict 更新的全局字典对象。 + * @param originalGlobalDict 原有的全局字典对象。 + * @return 更新成功返回true,否则false。 + */ + boolean update(GlobalDict globalDict, GlobalDict originalGlobalDict); + + /** + * 删除全局字典对象,以及其关联的字典项目数据。 + * + * @param dictId 全局字典Id。 + * @return 是否删除成功。 + */ + boolean remove(Long dictId); + + /** + * 获取全局字典列表。 + * + * @param filter 过滤对象。 + * @param orderBy 排序条件。 + * @return 查询结果集列表。 + */ + List getGlobalDictList(GlobalDict filter, String orderBy); + + /** + * 判断字典编码是否存在。 + * + * @param dictCode 字典编码。 + * @return true表示存在,否则false。 + */ + boolean existDictCode(String dictCode); + + /** + * 判断指定字典编码的字典项目是否存在。 + * 该方法通常会在业务主表中调用,为了提升整体运行时效率,该方法会从缓存中获取,如果缓存为空, + * 会从数据库读取指定编码的字典数据,并同步到缓存。 + * + * @param dictCode 字典编码。 + * @param itemId 字典项目Id。 + * @return true表示存在,否则false。 + */ + boolean existDictItemFromCache(String dictCode, Serializable itemId); + + /** + * 从缓存中获取指定编码的字典项目列表。 + * 该方法通常会在业务主表中调用,为了提升整体运行时效率,该方法会从缓存中获取,如果缓存为空, + * 会从数据库读取指定编码的字典数据,并同步到缓存。 + * + * @param dictCode 字典编码。 + * @param itemIds 字典项目Id集合。 + * @return 查询结果列表。 + */ + List getGlobalDictItemListFromCache(String dictCode, Set itemIds); + + /** + * 从缓存中获取指定编码的字典项目列表。返回的结果Map中,键是itemId,值是itemName。 + * 该方法通常会在业务主表中调用,为了提升整体运行时效率,该方法会从缓存中获取,如果缓存为空, + * 会从数据库读取指定编码的字典数据,并同步到缓存。 + * + * @param dictCode 字典编码。 + * @param itemIds 字典项目Id集合。 + * @return 查询结果列表。 + */ + Map getGlobalDictItemDictMapFromCache(String dictCode, Set itemIds); + + /** + * 强制同步指定字典编码的全部字典项目到缓存。 + * + * @param dictCode 字典编码。 + */ + void reloadCachedData(String dictCode); + + /** + * 从缓存中移除指定字典编码的数据。 + * + * @param dictCode 字典编码。 + */ + void removeCache(String dictCode); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/TenantGlobalDictItemService.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/TenantGlobalDictItemService.java new file mode 100644 index 00000000..74d3f5fa --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/TenantGlobalDictItemService.java @@ -0,0 +1,115 @@ +package com.orangeforms.common.dict.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.dict.model.TenantGlobalDict; +import com.orangeforms.common.dict.model.TenantGlobalDictItem; + +import java.io.Serializable; +import java.util.List; + +/** + * 租户全局字典项目数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface TenantGlobalDictItemService extends IBaseService { + + /** + * 保存新增的租户字典项目。 + * + * @param tenantGlobalDict 字典对象。 + * @param tenantGlobalDictItem 新字典项目对象。 + * @return 保存后的对象。 + */ + TenantGlobalDictItem saveNew(TenantGlobalDict tenantGlobalDict, TenantGlobalDictItem tenantGlobalDictItem); + + /** + * 批量新增的租户字典项目。 + * + * @param dictItemList 字典项对象列表。 + */ + void saveNewBatch(List dictItemList); + + /** + * 更新租户字典项目对象。 + * + * @param tenantGlobalDict 字典对象。 + * @param tenantGlobalDictItem 更新的全局字典项目对象。 + * @param originalTenantGlobalDictItem 原有的全局字典项目对象。 + * @return 更新成功返回true,否则false。 + */ + boolean update( + TenantGlobalDict tenantGlobalDict, + TenantGlobalDictItem tenantGlobalDictItem, + TenantGlobalDictItem originalTenantGlobalDictItem); + + /** + * 更新字典条目的编码。 + * + * @param oldCode 原有编码。 + * @param newCode 新编码。 + */ + void updateNewCode(String oldCode, String newCode); + + /** + * 更新字典条目的状态。 + * + * @param tenantGlobalDict 字典对象。 + * @param tenantGlobalDictItem 字典项目对象。 + * @param status 状态值。 + */ + void updateStatus(TenantGlobalDict tenantGlobalDict, TenantGlobalDictItem tenantGlobalDictItem, Integer status); + + /** + * 删除指定租户字典项目。 + * + * @param tenantGlobalDict 字典对象。 + * @param tenantGlobalDictItem 待删除字典项目。 + * @return 成功返回true,否则false。 + */ + boolean remove(TenantGlobalDict tenantGlobalDict, TenantGlobalDictItem tenantGlobalDictItem); + + /** + * 判断指定字典的项目Id是否存在。如果是租户非公用字典,会基于租户Id进行过滤。 + * + * @param tenantGlobalDict 字典对象。 + * @param itemId 项目Id。 + * @return true存在,否则false。 + */ + boolean existDictCodeAndItemId(TenantGlobalDict tenantGlobalDict, Serializable itemId); + + /** + * 判断指定租户的编码是否已经存在字典数据。 + * + * @param dictCode 字典编码。 + * @return true存在,否则false。 + */ + boolean existDictCode(String dictCode); + + /** + * 根据租户字典编码和项目Id获取指定字段项目对象。 + * + * @param dictCode 字典编码。 + * @param itemId 项目Id。 + * @return 字典项目对象。 + */ + TenantGlobalDictItem getGlobalDictItemByDictCodeAndItemId(String dictCode, Serializable itemId); + + /** + * 查询租户数据字典项目列表。 + * + * @param filter 过滤对象。 + * @param orderBy 排序字符串,如果为空,则按照showOrder升序排序。 + * @return 查询结果列表。 + */ + List getGlobalDictItemList(TenantGlobalDictItem filter, String orderBy); + + /** + * 查询指定字典的租户数据字典项目列表。如果是租户非公用字典,会仅仅返回该租户的字典数据列表。按照showOrder升序排序。 + * + * @param tenantGlobalDict 编码字典对象。 + * @return 查询结果列表。 + */ + List getGlobalDictItemList(TenantGlobalDict tenantGlobalDict); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/TenantGlobalDictService.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/TenantGlobalDictService.java new file mode 100644 index 00000000..3c02c46c --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/TenantGlobalDictService.java @@ -0,0 +1,137 @@ +package com.orangeforms.common.dict.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.dict.model.TenantGlobalDict; +import com.orangeforms.common.dict.model.TenantGlobalDictItem; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 租户全局字典数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface TenantGlobalDictService extends IBaseService { + + /** + * 保存租户全局字典对象。 + * + * @param tenantGlobalDict 全局租户字典对象。 + * @param tenantIdSet 租户Id集合。 + * @return 保存后的字典对象。 + */ + TenantGlobalDict saveNew(TenantGlobalDict tenantGlobalDict, Set tenantIdSet); + + /** + * 更新租户全局字典对象。 + * + * @param tenantGlobalDict 更新的租户全局字典对象。 + * @param originalTenantGlobalDict 原有的租户全局字典对象。 + * @return 更新成功返回true,否则false。 + */ + boolean update(TenantGlobalDict tenantGlobalDict, TenantGlobalDict originalTenantGlobalDict); + + /** + * 删除租户全局字典对象,以及其关联的字典项目数据。 + * + * @param dictId 全局字典Id。 + * @return 是否删除成功。 + */ + boolean remove(Long dictId); + + /** + * 获取全局字典列表。 + * + * @param filter 过滤对象。 + * @param orderBy 排序条件。 + * @return 查询结果集列表。 + */ + List getGlobalDictList(TenantGlobalDict filter, String orderBy); + + /** + * 判断租户字典编码是否存在。 + * + * @param dictCode 字典编码。 + * @return true表示存在,否则false。 + */ + boolean existDictCode(String dictCode); + + /** + * 根据字典编码获取全局字典编码对象。 + * + * @param dictCode 字典编码。 + * @return 查询后的字典对象。 + */ + TenantGlobalDict getTenantGlobalDictByDictCode(String dictCode); + + /** + * 从缓存中中获取指定字典数据。如果缓存中不存在,会从数据库读取并同步到缓存。 + * + * @param dictCode 字典编码。 + * @return 查询到的字段对象。 + */ + TenantGlobalDict getTenantGlobalDictFromCache(String dictCode); + + /** + * 从缓存中获取指定编码的字典项目列表。 + * 如果是租户非公用字典,会仅仅返回该租户的字典数据列表。 + * 该方法通常会在业务主表中调用,为了提升整体运行时效率,该方法会从缓存中获取,如果缓存为空, + * 会从数据库读取指定编码的字典数据,并同步到缓存。 + * + * @param tenantGlobalDict 编码字典对象。 + * @param itemIds 字典项目Id集合。 + * @return 查询结果列表。 + */ + List getGlobalDictItemListFromCache(TenantGlobalDict tenantGlobalDict, Set itemIds); + + /** + * 从缓存中获取指定编码的字典项目列表。返回的结果Map中,键是itemId,值是itemName。 + * 如果是租户非公用字典,会仅仅返回该租户的字典数据列表。 + * 该方法通常会在业务主表中调用,为了提升整体运行时效率,该方法会从缓存中获取,如果缓存为空, + * 会从数据库读取指定编码的字典数据,并同步到缓存。 + * + * @param tenantGlobalDict 编码字典对象。 + * @param itemIds 字典项目Id集合。 + * @return 查询结果列表。 + */ + Map getGlobalDictItemDictMapFromCache(TenantGlobalDict tenantGlobalDict, Set itemIds); + + /** + * 强制同步指定所有租户通用字典编码的全部字典项目到缓存。 + * 如果是租户非公用字典,会仅仅返回该租户的字典数据列表。 + * + * @param tenantGlobalDict 编码字典对象。 + */ + void reloadCachedData(TenantGlobalDict tenantGlobalDict); + + /** + * 重置所有非公用租户编码字典的数据到缓存。 + * 该方法会将指定编码字典中,所有租户的缓存全部重新加载。一般用于系统故障,或大促活动的数据预热。 + * + * @param tenantGlobalDict 非公用编码字典对象。 + */ + void reloadAllTenantCachedData(TenantGlobalDict tenantGlobalDict); + + /** + * 从缓存中移除指定字典编码的数据。 + * 该方法的实现内部会判断是否为公用字典,还是租户可修改的非公用字典。 + * + * @param tenantGlobalDict 字典编码。 + */ + void removeCache(TenantGlobalDict tenantGlobalDict); + + /** + * 判断指定字典编码的字典项目是否存在。 + * 该方法通常会在业务主表中调用,为了提升整体运行时效率,该方法会从缓存中获取,如果缓存为空, + * 会从数据库读取指定编码的字典数据,并同步到缓存。 + * + * @param dictCode 字典编码。 + * @param itemId 字典项目Id。 + * @return true表示存在,否则false。 + */ + boolean existDictItemFromCache(String dictCode, Serializable itemId); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/GlobalDictItemServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/GlobalDictItemServiceImpl.java new file mode 100644 index 00000000..662511a3 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/GlobalDictItemServiceImpl.java @@ -0,0 +1,143 @@ +package com.orangeforms.common.dict.service.impl; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.constant.GlobalDeletedFlag; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.dict.constant.GlobalDictItemStatus; +import com.orangeforms.common.dict.dao.GlobalDictItemMapper; +import com.orangeforms.common.dict.model.GlobalDictItem; +import com.orangeforms.common.dict.service.GlobalDictItemService; +import com.orangeforms.common.dict.service.GlobalDictService; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * 全局字典项目数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_GLOBAL_DICT_TYPE) +@Service("globalDictItemService") +public class GlobalDictItemServiceImpl + extends BaseService implements GlobalDictItemService { + + @Autowired + private GlobalDictItemMapper globalDictItemMapper; + @Autowired + private GlobalDictService globalDictService; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return globalDictItemMapper; + } + + @Override + public GlobalDictItem saveNew(GlobalDictItem globalDictItem) { + globalDictService.removeCache(globalDictItem.getDictCode()); + globalDictItem.setId(idGenerator.nextLongId()); + globalDictItem.setDeletedFlag(GlobalDeletedFlag.NORMAL); + globalDictItem.setStatus(GlobalDictItemStatus.NORMAL); + globalDictItem.setCreateUserId(TokenData.takeFromRequest().getUserId()); + globalDictItem.setUpdateUserId(globalDictItem.getCreateUserId()); + globalDictItem.setCreateTime(new Date()); + globalDictItem.setUpdateTime(globalDictItem.getCreateTime()); + globalDictItemMapper.insert(globalDictItem); + return globalDictItem; + } + + @Override + public boolean update(GlobalDictItem globalDictItem, GlobalDictItem originalGlobalDictItem) { + globalDictService.removeCache(globalDictItem.getDictCode()); + // 该方法不能直接修改字典状态。 + globalDictItem.setStatus(originalGlobalDictItem.getStatus()); + globalDictItem.setCreateUserId(originalGlobalDictItem.getCreateUserId()); + globalDictItem.setCreateTime(originalGlobalDictItem.getCreateTime()); + globalDictItem.setUpdateUserId(TokenData.takeFromRequest().getUserId()); + globalDictItem.setUpdateTime(new Date()); + return globalDictItemMapper.updateById(globalDictItem) == 1; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void updateNewCode(String oldCode, String newCode) { + GlobalDictItem globalDictItem = new GlobalDictItem(); + globalDictItem.setDictCode(newCode); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(GlobalDictItem::getDictCode, oldCode); + globalDictItemMapper.update(globalDictItem, queryWrapper); + } + + @Override + public void updateStatus(GlobalDictItem globalDictItem, Integer status) { + globalDictService.removeCache(globalDictItem.getDictCode()); + globalDictItem.setStatus(status); + globalDictItem.setUpdateUserId(TokenData.takeFromRequest().getUserId()); + globalDictItem.setUpdateTime(new Date()); + globalDictItemMapper.updateById(globalDictItem); + } + + @Override + public boolean remove(GlobalDictItem globalDictItem) { + globalDictService.removeCache(globalDictItem.getDictCode()); + return this.removeById(globalDictItem.getId()); + } + + @Override + public boolean existDictCodeAndItemId(String dictCode, Serializable itemId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(GlobalDictItem::getDictCode, dictCode); + queryWrapper.eq(GlobalDictItem::getItemId, itemId.toString()); + return globalDictItemMapper.selectCount(queryWrapper) > 0; + } + + @Override + public GlobalDictItem getGlobalDictItemByDictCodeAndItemId(String dictCode, Serializable itemId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(GlobalDictItem::getDictCode, dictCode); + queryWrapper.eq(GlobalDictItem::getItemId, itemId.toString()); + return globalDictItemMapper.selectOne(queryWrapper); + } + + @Override + public List getGlobalDictItemList(GlobalDictItem filter, String orderBy) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(filter); + if (StrUtil.isNotBlank(orderBy)) { + queryWrapper.last(" ORDER BY " + orderBy); + } else { + queryWrapper.orderByAsc(GlobalDictItem::getShowOrder); + } + return globalDictItemMapper.selectList(queryWrapper); + } + + @Override + public List getGlobalDictItemListByDictCode(String dictCode) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(GlobalDictItem::getDictCode, dictCode); + queryWrapper.orderByAsc(GlobalDictItem::getShowOrder); + return globalDictItemMapper.selectList(queryWrapper); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/GlobalDictServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/GlobalDictServiceImpl.java new file mode 100644 index 00000000..1315cd53 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/GlobalDictServiceImpl.java @@ -0,0 +1,190 @@ +package com.orangeforms.common.dict.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.constant.GlobalDeletedFlag; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.RedisKeyUtil; +import com.orangeforms.common.dict.constant.GlobalDictItemStatus; +import com.orangeforms.common.dict.dao.GlobalDictMapper; +import com.orangeforms.common.dict.model.GlobalDict; +import com.orangeforms.common.dict.model.GlobalDictItem; +import com.orangeforms.common.dict.service.GlobalDictItemService; +import com.orangeforms.common.dict.service.GlobalDictService; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import lombok.extern.slf4j.Slf4j; +import org.redisson.api.RMap; +import org.redisson.api.RedissonClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.Serializable; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 全局字典数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_GLOBAL_DICT_TYPE) +@Service("globalDictService") +public class GlobalDictServiceImpl extends BaseService implements GlobalDictService { + + @Autowired + private GlobalDictMapper globalDictMapper; + @Autowired + private GlobalDictItemService globalDictItemService; + @Autowired + private RedissonClient redissonClient; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return globalDictMapper; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public GlobalDict saveNew(GlobalDict globalDict) { + globalDict.setDictId(idGenerator.nextLongId()); + globalDict.setDeletedFlag(GlobalDeletedFlag.NORMAL); + globalDict.setCreateUserId(TokenData.takeFromRequest().getUserId()); + globalDict.setUpdateUserId(globalDict.getCreateUserId()); + globalDict.setCreateTime(new Date()); + globalDict.setUpdateTime(globalDict.getCreateTime()); + globalDictMapper.insert(globalDict); + return globalDict; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(GlobalDict globalDict, GlobalDict originalGlobalDict) { + this.removeCache(originalGlobalDict.getDictCode()); + globalDict.setCreateUserId(originalGlobalDict.getCreateUserId()); + globalDict.setCreateTime(originalGlobalDict.getCreateTime()); + globalDict.setUpdateUserId(TokenData.takeFromRequest().getUserId()); + globalDict.setUpdateTime(new Date()); + if (globalDictMapper.updateById(globalDict) != 1) { + return false; + } + if (!StrUtil.equals(globalDict.getDictCode(), originalGlobalDict.getDictCode())) { + globalDictItemService.updateNewCode(originalGlobalDict.getDictCode(), globalDict.getDictCode()); + } + return true; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long dictId) { + GlobalDict globalDict = this.getById(dictId); + if (globalDict == null) { + return false; + } + this.removeCache(globalDict.getDictCode()); + if (globalDictMapper.deleteById(dictId) == 0) { + return false; + } + GlobalDictItem filter = new GlobalDictItem(); + filter.setDictCode(globalDict.getDictCode()); + globalDictItemService.removeBy(filter); + return true; + } + + @Override + public List getGlobalDictList(GlobalDict filter, String orderBy) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(filter); + if (StrUtil.isNotBlank(orderBy)) { + queryWrapper.last(" ORDER BY " + orderBy); + } + return globalDictMapper.selectList(queryWrapper); + } + + @Override + public boolean existDictCode(String dictCode) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(GlobalDict::getDictCode, dictCode); + return globalDictMapper.selectCount(queryWrapper) > 0; + } + + @Override + public boolean existDictItemFromCache(String dictCode, Serializable itemId) { + return CollUtil.isNotEmpty(this.getGlobalDictItemListFromCache(dictCode, CollUtil.newHashSet(itemId))); + } + + @Override + public List getGlobalDictItemListFromCache(String dictCode, Set itemIds) { + if (CollUtil.isNotEmpty(itemIds) && !(itemIds.iterator().next() instanceof String)) { + itemIds = itemIds.stream().map(Object::toString).collect(Collectors.toSet()); + } + List dataList; + RMap cachedMap = + redissonClient.getMap(RedisKeyUtil.makeGlobalDictKey(dictCode)); + if (cachedMap.isExists()) { + Map dataMap = + CollUtil.isEmpty(itemIds) ? cachedMap.readAllMap() : cachedMap.getAll(itemIds); + dataList = dataMap.values().stream() + .map(c -> JSON.parseObject(c, GlobalDictItem.class)).collect(Collectors.toList()); + dataList.sort(Comparator.comparingInt(GlobalDictItem::getShowOrder)); + } else { + dataList = globalDictItemService.getGlobalDictItemListByDictCode(dictCode); + this.putCache(dictCode, dataList); + if (CollUtil.isNotEmpty(itemIds)) { + Set tmpItemIds = itemIds; + dataList = dataList.stream() + .filter(c -> tmpItemIds.contains(c.getItemId())).collect(Collectors.toList()); + } + } + return dataList; + } + + @Override + public Map getGlobalDictItemDictMapFromCache(String dictCode, Set itemIds) { + List dataList = this.getGlobalDictItemListFromCache(dictCode, itemIds); + return dataList.stream().collect(Collectors.toMap(GlobalDictItem::getItemId, GlobalDictItem::getItemName)); + } + + @Override + public void reloadCachedData(String dictCode) { + this.removeCache(dictCode); + List dataList = globalDictItemService.getGlobalDictItemListByDictCode(dictCode); + this.putCache(dictCode, dataList); + } + + @Override + public void removeCache(String dictCode) { + if (StrUtil.isNotBlank(dictCode)) { + redissonClient.getMap(RedisKeyUtil.makeGlobalDictKey(dictCode)).delete(); + } + } + + private void putCache(String dictCode, List globalDictItemList) { + if (CollUtil.isNotEmpty(globalDictItemList)) { + Map dataMap = globalDictItemList.stream() + .filter(item -> item.getStatus() == GlobalDictItemStatus.NORMAL) + .collect(Collectors.toMap(GlobalDictItem::getItemId, JSON::toJSONString)); + if (MapUtil.isNotEmpty(dataMap)) { + redissonClient.getMap(RedisKeyUtil.makeGlobalDictKey(dictCode)).putAll(dataMap); + } + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/TenantGlobalDictItemServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/TenantGlobalDictItemServiceImpl.java new file mode 100644 index 00000000..623b14b9 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/TenantGlobalDictItemServiceImpl.java @@ -0,0 +1,190 @@ +package com.orangeforms.common.dict.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.core.util.BooleanUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.constant.GlobalDeletedFlag; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.dict.constant.GlobalDictItemStatus; +import com.orangeforms.common.dict.dao.TenantGlobalDictItemMapper; +import com.orangeforms.common.dict.model.TenantGlobalDict; +import com.orangeforms.common.dict.model.TenantGlobalDictItem; +import com.orangeforms.common.dict.service.TenantGlobalDictItemService; +import com.orangeforms.common.dict.service.TenantGlobalDictService; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * 租户全局字典项目数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.TENANT_COMMON_DATASOURCE_TYPE) +@Slf4j +@Service("tenantGlobalDictItemService") +public class TenantGlobalDictItemServiceImpl + extends BaseService implements TenantGlobalDictItemService { + + @Autowired + private TenantGlobalDictItemMapper tenantGlobalDictItemMapper; + @Autowired + private TenantGlobalDictService tenantGlobalDictService; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return tenantGlobalDictItemMapper; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public TenantGlobalDictItem saveNew(TenantGlobalDict dict, TenantGlobalDictItem dictItem) { + tenantGlobalDictService.removeCache(dict); + if (BooleanUtil.isFalse(dict.getTenantCommon())) { + dictItem.setTenantId(TokenData.takeFromRequest().getTenantId()); + } + dictItem.setId(idGenerator.nextLongId()); + dictItem.setDeletedFlag(GlobalDeletedFlag.NORMAL); + dictItem.setStatus(GlobalDictItemStatus.NORMAL); + dictItem.setCreateUserId(TokenData.takeFromRequest().getUserId()); + dictItem.setUpdateUserId(dictItem.getCreateUserId()); + dictItem.setCreateTime(new Date()); + dictItem.setUpdateTime(dictItem.getCreateTime()); + tenantGlobalDictItemMapper.insert(dictItem); + return dictItem; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNewBatch(List dictItemList) { + if (CollUtil.isEmpty(dictItemList)) { + return; + } + Date now = new Date(); + for (TenantGlobalDictItem dictItem : dictItemList) { + if (dictItem.getId() == null) { + dictItem.setId(idGenerator.nextLongId()); + } + if (dictItem.getCreateUserId() == null) { + dictItem.setCreateUserId(TokenData.takeFromRequest().getUserId()); + } + dictItem.setUpdateUserId(dictItem.getCreateUserId()); + dictItem.setUpdateTime(now); + dictItem.setCreateTime(now); + dictItem.setStatus(GlobalDictItemStatus.NORMAL); + dictItem.setDeletedFlag(GlobalDeletedFlag.NORMAL); + } + tenantGlobalDictItemMapper.insertList(dictItemList); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(TenantGlobalDict dict, TenantGlobalDictItem dictItem, TenantGlobalDictItem originalDictItem) { + tenantGlobalDictService.removeCache(dict); + // 该方法不能直接修改字典状态,更不会修改tenantId。 + dictItem.setStatus(originalDictItem.getStatus()); + dictItem.setTenantId(originalDictItem.getTenantId()); + dictItem.setCreateUserId(originalDictItem.getCreateUserId()); + dictItem.setCreateTime(originalDictItem.getCreateTime()); + dictItem.setUpdateUserId(TokenData.takeFromRequest().getUserId()); + dictItem.setUpdateTime(new Date()); + return tenantGlobalDictItemMapper.updateById(dictItem) == 1; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void updateNewCode(String oldCode, String newCode) { + TenantGlobalDictItem dictItem = new TenantGlobalDictItem(); + dictItem.setDictCode(newCode); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(TenantGlobalDictItem::getDictCode, oldCode); + tenantGlobalDictItemMapper.update(dictItem, queryWrapper); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void updateStatus(TenantGlobalDict dict, TenantGlobalDictItem dictItem, Integer status) { + tenantGlobalDictService.removeCache(dict); + dictItem.setStatus(status); + dictItem.setUpdateUserId(TokenData.takeFromRequest().getUserId()); + dictItem.setUpdateTime(new Date()); + tenantGlobalDictItemMapper.updateById(dictItem); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(TenantGlobalDict dict, TenantGlobalDictItem dictItem) { + tenantGlobalDictService.removeCache(dict); + return this.removeById(dictItem.getId()); + } + + @Override + public boolean existDictCodeAndItemId(TenantGlobalDict dict, Serializable itemId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(TenantGlobalDictItem::getDictCode, dict.getDictCode()); + queryWrapper.eq(TenantGlobalDictItem::getItemId, itemId.toString()); + if (BooleanUtil.isFalse(dict.getTenantCommon())) { + queryWrapper.eq(TenantGlobalDictItem::getTenantId, TokenData.takeFromRequest().getTenantId()); + } + return tenantGlobalDictItemMapper.selectCount(queryWrapper) > 0; + } + + @Override + public boolean existDictCode(String dictCode) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(TenantGlobalDictItem::getDictCode, dictCode); + return tenantGlobalDictItemMapper.selectCount(queryWrapper) > 0; + } + + @Override + public TenantGlobalDictItem getGlobalDictItemByDictCodeAndItemId(String dictCode, Serializable itemId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(TenantGlobalDictItem::getDictCode, dictCode); + queryWrapper.eq(TenantGlobalDictItem::getItemId, itemId.toString()); + return tenantGlobalDictItemMapper.selectOne(queryWrapper); + } + + @Override + public List getGlobalDictItemList(TenantGlobalDictItem filter, String orderBy) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(filter); + if (StrUtil.isNotBlank(orderBy)) { + queryWrapper.last(" ORDER BY " + orderBy); + } else { + queryWrapper.orderByAsc(TenantGlobalDictItem::getShowOrder); + } + return tenantGlobalDictItemMapper.selectList(queryWrapper); + } + + @Override + public List getGlobalDictItemList(TenantGlobalDict dict) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(TenantGlobalDictItem::getDictCode, dict.getDictCode()); + if (BooleanUtil.isFalse(dict.getTenantCommon())) { + queryWrapper.eq(TenantGlobalDictItem::getTenantId, TokenData.takeFromRequest().getTenantId()); + } + queryWrapper.orderByAsc(TenantGlobalDictItem::getShowOrder); + return tenantGlobalDictItemMapper.selectList(queryWrapper); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/TenantGlobalDictServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/TenantGlobalDictServiceImpl.java new file mode 100644 index 00000000..d9caab86 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/service/impl/TenantGlobalDictServiceImpl.java @@ -0,0 +1,305 @@ +package com.orangeforms.common.dict.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.constant.GlobalDeletedFlag; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.core.util.RedisKeyUtil; +import com.orangeforms.common.dict.constant.GlobalDictItemStatus; +import com.orangeforms.common.dict.dao.TenantGlobalDictMapper; +import com.orangeforms.common.dict.model.TenantGlobalDict; +import com.orangeforms.common.dict.model.TenantGlobalDictItem; +import com.orangeforms.common.dict.service.TenantGlobalDictItemService; +import com.orangeforms.common.dict.service.TenantGlobalDictService; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import lombok.extern.slf4j.Slf4j; +import org.redisson.api.RBucket; +import org.redisson.api.RMap; +import org.redisson.api.RedissonClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.Serializable; +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +/** + * 租户全局字典数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.TENANT_COMMON_DATASOURCE_TYPE) +@Slf4j +@Service("tenantGlobalDictService") +public class TenantGlobalDictServiceImpl + extends BaseService implements TenantGlobalDictService { + + @Autowired + private TenantGlobalDictMapper tenantGlobalDictMapper; + @Autowired + private TenantGlobalDictItemService tenantGlobalDictItemService; + @Autowired + private RedissonClient redissonClient; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return tenantGlobalDictMapper; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public TenantGlobalDict saveNew(TenantGlobalDict dict, Set tenantIdSet) { + String initialData = dict.getInitialData(); + dict.setDictId(idGenerator.nextLongId()); + dict.setDeletedFlag(GlobalDeletedFlag.NORMAL); + dict.setCreateUserId(TokenData.takeFromRequest().getUserId()); + dict.setUpdateUserId(dict.getCreateUserId()); + dict.setCreateTime(new Date()); + dict.setUpdateTime(dict.getCreateTime()); + if (BooleanUtil.isTrue(dict.getTenantCommon())) { + dict.setInitialData(null); + } + tenantGlobalDictMapper.insert(dict); + List dictItemList = null; + if (StrUtil.isNotBlank(initialData)) { + dictItemList = JSONArray.parseArray(initialData, TenantGlobalDictItem.class); + dictItemList.forEach(dictItem -> { + dictItem.setDictCode(dict.getDictCode()); + dictItem.setCreateUserId(dict.getCreateUserId()); + }); + } + if (BooleanUtil.isTrue(dict.getTenantCommon())) { + tenantGlobalDictItemService.saveNewBatch(dictItemList); + } else { + if (CollUtil.isEmpty(tenantIdSet) || dictItemList == null) { + return dict; + } + for (Long tenantId : tenantIdSet) { + dictItemList.forEach(dictItem -> { + dictItem.setId(idGenerator.nextLongId()); + dictItem.setTenantId(tenantId); + }); + tenantGlobalDictItemService.saveNewBatch(dictItemList); + } + } + return dict; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(TenantGlobalDict dict, TenantGlobalDict originalDict) { + this.removeGlobalDictAllCache(originalDict); + dict.setCreateUserId(originalDict.getCreateUserId()); + dict.setCreateTime(originalDict.getCreateTime()); + dict.setUpdateUserId(TokenData.takeFromRequest().getUserId()); + dict.setUpdateTime(new Date()); + if (tenantGlobalDictMapper.updateById(dict) != 1) { + return false; + } + if (!StrUtil.equals(dict.getDictCode(), originalDict.getDictCode())) { + tenantGlobalDictItemService.updateNewCode(originalDict.getDictCode(), dict.getDictCode()); + } + return true; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long dictId) { + TenantGlobalDict dict = this.getById(dictId); + if (dict == null) { + return false; + } + this.removeGlobalDictAllCache(dict); + if (tenantGlobalDictMapper.deleteById(dictId) == 0) { + return false; + } + TenantGlobalDictItem filter = new TenantGlobalDictItem(); + filter.setDictCode(dict.getDictCode()); + tenantGlobalDictItemService.removeBy(filter); + return true; + } + + @Override + public List getGlobalDictList(TenantGlobalDict filter, String orderBy) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(filter); + if (StrUtil.isNotBlank(orderBy)) { + queryWrapper.last(" ORDER BY " + orderBy); + } + return tenantGlobalDictMapper.selectList(queryWrapper); + } + + @Override + public boolean existDictCode(String dictCode) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(TenantGlobalDict::getDictCode, dictCode); + return tenantGlobalDictMapper.selectCount(queryWrapper) > 0; + } + + @Override + public TenantGlobalDict getTenantGlobalDictByDictCode(String dictCode) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(TenantGlobalDict::getDictCode, dictCode); + return tenantGlobalDictMapper.selectOne(queryWrapper); + } + + @Override + public TenantGlobalDict getTenantGlobalDictFromCache(String dictCode) { + String key = RedisKeyUtil.makeGlobalDictOnlyKey(dictCode); + RBucket bucket = redissonClient.getBucket(key); + if (bucket.isExists()) { + return JSON.parseObject(bucket.get(), TenantGlobalDict.class); + } + TenantGlobalDict dict = this.getTenantGlobalDictByDictCode(dictCode); + if (dict != null) { + bucket.set(JSON.toJSONString(dict)); + } + return dict; + } + + @Override + public List getGlobalDictItemListFromCache(TenantGlobalDict dict, Set itemIds) { + if (CollUtil.isNotEmpty(itemIds) && !(itemIds.iterator().next() instanceof String)) { + itemIds = itemIds.stream().map(Object::toString).collect(Collectors.toSet()); + } + String key = RedisKeyUtil.makeGlobalDictKey(dict.getDictCode()); + if (BooleanUtil.isFalse(dict.getTenantCommon())) { + key = this.appendTenantSuffix(key); + } + List dataList; + RMap cachedMap = redissonClient.getMap(key); + if (cachedMap.isExists()) { + Map dataMap = + CollUtil.isEmpty(itemIds) ? cachedMap.readAllMap() : cachedMap.getAll(itemIds); + dataList = dataMap.values().stream() + .map(c -> JSON.parseObject(c, TenantGlobalDictItem.class)).collect(Collectors.toList()); + dataList.sort(Comparator.comparingInt(TenantGlobalDictItem::getShowOrder)); + } else { + dataList = tenantGlobalDictItemService.getGlobalDictItemList(dict); + this.putCache(dict, dataList); + if (CollUtil.isNotEmpty(itemIds)) { + Set tmpItemIds = itemIds; + dataList = dataList.stream() + .filter(c -> tmpItemIds.contains(c.getItemId())).collect(Collectors.toList()); + } + } + return dataList; + } + + @Override + public Map getGlobalDictItemDictMapFromCache( + TenantGlobalDict dict, Set itemIds) { + List dataList = this.getGlobalDictItemListFromCache(dict, itemIds); + return dataList.stream() + .collect(Collectors.toMap(TenantGlobalDictItem::getItemId, TenantGlobalDictItem::getItemName)); + } + + @Override + public void reloadCachedData(TenantGlobalDict dict) { + this.removeCache(dict); + List dataList = tenantGlobalDictItemService.getGlobalDictItemList(dict); + this.putCache(dict, dataList); + } + + @Override + public void reloadAllTenantCachedData(TenantGlobalDict dict) { + if (StrUtil.isBlank(dict.getDictCode())) { + return; + } + String dictCodeKey = RedisKeyUtil.makeGlobalDictKey(dict.getDictCode()); + redissonClient.getKeys().deleteByPattern(dictCodeKey + "*"); + TenantGlobalDictItem filter = new TenantGlobalDictItem(); + filter.setDictCode(dict.getDictCode()); + List dictItemList = + tenantGlobalDictItemService.getGlobalDictItemList(filter, null); + if (CollUtil.isEmpty(dictItemList)) { + return; + } + Map> dictItemMap = + dictItemList.stream().collect(Collectors.groupingBy(TenantGlobalDictItem::getTenantId)); + for (Map.Entry> entry : dictItemMap.entrySet()) { + String key = dictCodeKey + "-" + entry.getKey(); + Map dataMap = entry.getValue().stream() + .collect(Collectors.toMap(TenantGlobalDictItem::getItemId, JSON::toJSONString)); + RMap cachedMap = redissonClient.getMap(key); + cachedMap.putAll(dataMap); + cachedMap.expire(1, TimeUnit.DAYS); + } + } + + @Override + public void removeCache(TenantGlobalDict dict) { + if (StrUtil.isBlank(dict.getDictCode())) { + return; + } + String key = RedisKeyUtil.makeGlobalDictKey(dict.getDictCode()); + if (BooleanUtil.isFalse(dict.getTenantCommon())) { + key = this.appendTenantSuffix(key); + } + redissonClient.getMap(key).delete(); + } + + @Override + public boolean existDictItemFromCache(String dictCode, Serializable itemId) { + TenantGlobalDict tenantGlobalDict = this.getTenantGlobalDictFromCache(dictCode); + return CollUtil.isNotEmpty(this.getGlobalDictItemListFromCache(tenantGlobalDict, CollUtil.newHashSet(itemId))); + } + + private void putCache(TenantGlobalDict dict, List dictItemList) { + if (CollUtil.isEmpty(dictItemList)) { + return; + } + String key = RedisKeyUtil.makeGlobalDictKey(dict.getDictCode()); + if (BooleanUtil.isFalse(dict.getTenantCommon())) { + key = this.appendTenantSuffix(key); + } + Map dataMap = dictItemList.stream() + .filter(item -> item.getStatus() == GlobalDictItemStatus.NORMAL) + .collect(Collectors.toMap(TenantGlobalDictItem::getItemId, JSON::toJSONString)); + if (MapUtil.isNotEmpty(dataMap)) { + RMap cachedMap = redissonClient.getMap(key); + cachedMap.putAll(dataMap); + cachedMap.expire(1, TimeUnit.DAYS); + } + } + + private String appendTenantSuffix(String key) { + return key + "-" + TokenData.takeFromRequest().getTenantId(); + } + + private void removeGlobalDictAllCache(TenantGlobalDict dict) { + String dictCode = dict.getDictCode(); + if (StrUtil.isBlank(dictCode)) { + return; + } + String key = RedisKeyUtil.makeGlobalDictOnlyKey(dictCode); + redissonClient.getBucket(key).delete(); + key = RedisKeyUtil.makeGlobalDictKey(dictCode); + if (BooleanUtil.isTrue(dict.getTenantCommon())) { + redissonClient.getMap(key).delete(); + } else { + redissonClient.getKeys().deleteByPatternAsync(key + "*"); + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/util/GlobalDictOperationHelper.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/util/GlobalDictOperationHelper.java new file mode 100644 index 00000000..05e308ef --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/util/GlobalDictOperationHelper.java @@ -0,0 +1,89 @@ +package com.orangeforms.common.dict.util; + +import cn.hutool.core.util.StrUtil; +import com.github.pagehelper.Page; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.ResponseResult; +import com.orangeforms.common.core.object.MyPageData; +import com.orangeforms.common.core.object.MyPageParam; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.dict.dto.GlobalDictDto; +import com.orangeforms.common.dict.model.GlobalDict; +import com.orangeforms.common.dict.model.GlobalDictItem; +import com.orangeforms.common.dict.service.GlobalDictService; +import com.orangeforms.common.dict.vo.GlobalDictVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 全局编码字典操作的通用帮助对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Component +public class GlobalDictOperationHelper { + + @Autowired + private GlobalDictService globalDictService; + + /** + * 获取全部编码字典列表。 + * + * @param globalDictDtoFilter 过滤对象。 + * @param pageParam 分页参数。 + * @return 字典的数据列表。 + */ + public ResponseResult> listAllGlobalDict( + GlobalDictDto globalDictDtoFilter, MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + GlobalDict filter = MyModelUtil.copyTo(globalDictDtoFilter, GlobalDict.class); + List dictList = globalDictService.getGlobalDictList(filter, null); + List dictVoList = MyModelUtil.copyCollectionTo(dictList, GlobalDictVo.class); + long totalCount = 0L; + if (dictList instanceof Page) { + totalCount = ((Page) dictList).getTotal(); + } + return ResponseResult.success(MyPageUtil.makeResponseData(dictVoList, totalCount)); + } + + public List> toDictDataList(List resultList, String itemIdType) { + return resultList.stream().map(item -> { + Map dataMap = new HashMap<>(4); + Object itemId = item.getItemId(); + if (StrUtil.equals(itemIdType, "Long")) { + itemId = Long.valueOf(item.getItemId()); + } else if (StrUtil.equals(itemIdType, "Integer")) { + itemId = Integer.valueOf(item.getItemId()); + } + dataMap.put(ApplicationConstant.DICT_ID, itemId); + dataMap.put(ApplicationConstant.DICT_NAME, item.getItemName()); + dataMap.put("showOrder", item.getShowOrder()); + dataMap.put("status", item.getStatus()); + return dataMap; + }).collect(Collectors.toList()); + } + + public List> toDictDataList2(List resultList) { + return resultList.stream().map(item -> { + Map dataMap = new HashMap<>(5); + dataMap.put(ApplicationConstant.DICT_ID, item.getId()); + dataMap.put("itemId", item.getItemId()); + dataMap.put(ApplicationConstant.DICT_NAME, item.getItemName()); + dataMap.put("showOrder", item.getShowOrder()); + dataMap.put("status", item.getStatus()); + return dataMap; + }).collect(Collectors.toList()); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/GlobalDictItemVo.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/GlobalDictItemVo.java new file mode 100644 index 00000000..cbf07bd4 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/GlobalDictItemVo.java @@ -0,0 +1,77 @@ +package com.orangeforms.common.dict.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 全局系统字典项目Vo。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "全局系统字典项目Vo") +@Data +public class GlobalDictItemVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long id; + + /** + * 字典编码。 + */ + @Schema(description = "字典编码") + private String dictCode; + + /** + * 字典数据项Id。 + */ + @Schema(description = "字典数据项Id") + private String itemId; + + /** + * 字典数据项名称。 + */ + @Schema(description = "字典数据项名称") + private String itemName; + + /** + * 显示顺序(数值越小越靠前)。 + */ + @Schema(description = "显示顺序") + private Integer showOrder; + + /** + * 字典状态。具体值引用DictItemStatus常量类。 + */ + @Schema(description = "字典状态") + private Integer status; + + /** + * 创建用户Id。 + */ + @Schema(description = "创建用户Id") + private Long createUserId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建用户名。 + */ + @Schema(description = "创建用户名") + private Long updateUserId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/GlobalDictVo.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/GlobalDictVo.java new file mode 100644 index 00000000..f77a2581 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/GlobalDictVo.java @@ -0,0 +1,59 @@ +package com.orangeforms.common.dict.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 全局系统字典Vo。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "全局系统字典Vo") +@Data +public class GlobalDictVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long dictId; + + /** + * 字典编码。 + */ + @Schema(description = "字典编码") + private String dictCode; + + /** + * 字典中文名称。 + */ + @Schema(description = "字典中文名称") + private String dictName; + + /** + * 创建用户Id。 + */ + @Schema(description = "创建用户Id") + private Long createUserId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建用户名。 + */ + @Schema(description = "创建用户名") + private Long updateUserId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/TenantGlobalDictItemVo.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/TenantGlobalDictItemVo.java new file mode 100644 index 00000000..967b561d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/TenantGlobalDictItemVo.java @@ -0,0 +1,18 @@ +package com.orangeforms.common.dict.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 租户全局系统字典项目Vo。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "租户全局系统字典项目Vo") +@Data +@EqualsAndHashCode(callSuper = true) +public class TenantGlobalDictItemVo extends GlobalDictItemVo { + +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/TenantGlobalDictVo.java b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/TenantGlobalDictVo.java new file mode 100644 index 00000000..94ac38fc --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-dict/src/main/java/com/orangeforms/common/dict/vo/TenantGlobalDictVo.java @@ -0,0 +1,29 @@ +package com.orangeforms.common.dict.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 租户全局系统字典Vo。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "租户全局系统字典Vo") +@Data +@EqualsAndHashCode(callSuper = true) +public class TenantGlobalDictVo extends GlobalDictVo { + + /** + * 是否为所有租户的通用字典。 + */ + @Schema(description = "是否为所有租户的通用字典") + private Boolean tenantCommon; + + /** + * 租户的非公用字典的初始化字典数据。 + */ + @Schema(description = "租户的非公用字典的初始化字典数据") + private String initialData; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-ext/pom.xml b/OrangeFormsOpen-MybatisPlus/common/common-ext/pom.xml new file mode 100644 index 00000000..f34963db --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-ext/pom.xml @@ -0,0 +1,21 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-ext + + + + com.orangeforms + common-redis + 1.0.0 + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/java/com/orangeforms/common/ext/base/BizWidgetDatasource.java b/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/java/com/orangeforms/common/ext/base/BizWidgetDatasource.java new file mode 100644 index 00000000..81673674 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/java/com/orangeforms/common/ext/base/BizWidgetDatasource.java @@ -0,0 +1,41 @@ +package com.orangeforms.common.ext.base; + +import com.orangeforms.common.core.object.MyOrderParam; +import com.orangeforms.common.core.object.MyPageData; +import com.orangeforms.common.core.object.MyPageParam; + +import java.util.List; +import java.util.Map; + +/** + * 业务组件获取数据的数据源接口。 + * 如果业务服务集成了common-ext组件,可以通过实现该接口的方式,为BizWidgetController访问提供数据。 + * 对于没有集成common-ext组件的服务,可以通过http方式,为BizWidgetController访问提供数据。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface BizWidgetDatasource { + + /** + * 获取指定通用业务组件的数据。 + * + * @param widgetType 业务组件类型。 + * @param filter 过滤参数。不同的数据源参数不同。这里我们以键值对的方式传递。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 查询后的分页数据列表。 + */ + MyPageData> getDataList( + String widgetType, Map filter, MyOrderParam orderParam, MyPageParam pageParam); + + /** + * 获取指定主键Id的数据对象。 + * + * @param widgetType 业务组件类型。 + * @param fieldName 字段名,如果为空,则使用主键字段名。 + * @param fieldValues 字段值集合。 + * @return 指定主键Id的数据对象。 + */ + List> getDataListWithInList(String widgetType, String fieldName, List fieldValues); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/java/com/orangeforms/common/ext/config/CommonExtAutoConfig.java b/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/java/com/orangeforms/common/ext/config/CommonExtAutoConfig.java new file mode 100644 index 00000000..41180d8c --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/java/com/orangeforms/common/ext/config/CommonExtAutoConfig.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.ext.config; + +import org.springframework.boot.context.properties.EnableConfigurationProperties; + +/** + * common-ext通用扩展模块的自动配置引导类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EnableConfigurationProperties({CommonExtProperties.class}) +public class CommonExtAutoConfig { +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/java/com/orangeforms/common/ext/config/CommonExtProperties.java b/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/java/com/orangeforms/common/ext/config/CommonExtProperties.java new file mode 100644 index 00000000..7aeb2c23 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/java/com/orangeforms/common/ext/config/CommonExtProperties.java @@ -0,0 +1,76 @@ +package com.orangeforms.common.ext.config; + +import cn.hutool.core.collection.CollUtil; +import lombok.Data; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * common-ext配置属性类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ConfigurationProperties(prefix = "common-ext") +public class CommonExtProperties implements InitializingBean { + + /** + * 上传存储类型。具体值可参考枚举 UploadStoreTypeEnum。默认0为本地存储。 + */ + @Value("${common-ext.uploadStoreType:0}") + private Integer uploadStoreType; + + /** + * 仅当uploadStoreType等于0的时候,该配置值生效。 + */ + @Value("${common-ext.uploadFileBaseDir:./zz-resource/upload-files/commonext}") + private String uploadFileBaseDir; + + private List apps; + + private Map applicationMap; + + @Override + public void afterPropertiesSet() throws Exception { + if (CollUtil.isEmpty(apps)) { + applicationMap = new HashMap<>(1); + } else { + applicationMap = apps.stream().collect(Collectors.toMap(AppProperties::getAppCode, c -> c)); + } + } + + @Data + public static class AppProperties { + /** + * 应用编码。 + */ + private String appCode; + /** + * 通用业务组件数据源属性列表。 + */ + private List bizWidgetDatasources; + } + + @Data + public static class BizWidgetDatasourceProperties { + /** + * 通用业务组件的数据源类型。多个类型之间逗号分隔,如:upms_user,upms_dept。 + */ + private String types; + /** + * 列表数据接口地址。格式为完整的url,如:http://xxxxx + */ + private String listUrl; + /** + * 详情数据接口地址。格式为完整的url,如:http://xxxxx + */ + private String viewUrl; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/java/com/orangeforms/common/ext/constant/BizWidgetDatasourceType.java b/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/java/com/orangeforms/common/ext/constant/BizWidgetDatasourceType.java new file mode 100644 index 00000000..5d3b4ae6 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/java/com/orangeforms/common/ext/constant/BizWidgetDatasourceType.java @@ -0,0 +1,41 @@ +package com.orangeforms.common.ext.constant; + +/** + * 业务组件数据源类型常量类。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class BizWidgetDatasourceType { + + /** + * 通用用户组件数据源类型。 + */ + public static final String UPMS_USER_TYPE = "upms_user"; + + /** + * 通用部门组件数据源类型。 + */ + public static final String UPMS_DEPT_TYPE = "upms_dept"; + + /** + * 通用角色组件数据源类型。 + */ + public static final String UPMS_ROLE_TYPE = "upms_role"; + + /** + * 通用岗位组件数据源类型。 + */ + public static final String UPMS_POST_TYPE = "upms_post"; + + /** + * 通用部门岗位组件数据源类型。 + */ + public static final String UPMS_DEPT_POST_TYPE = "upms_dept_post"; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private BizWidgetDatasourceType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/java/com/orangeforms/common/ext/controller/BizWidgetController.java b/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/java/com/orangeforms/common/ext/controller/BizWidgetController.java new file mode 100644 index 00000000..021ac5e1 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/java/com/orangeforms/common/ext/controller/BizWidgetController.java @@ -0,0 +1,58 @@ +package com.orangeforms.common.ext.controller; + +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.ext.util.BizWidgetDatasourceExtHelper; +import com.orangeforms.common.core.annotation.MyRequestBody; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +/** + * 业务组件获取数据的访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@RestController +@RequestMapping("${common-ext.urlPrefix}/bizwidget") +public class BizWidgetController { + + @Autowired + private BizWidgetDatasourceExtHelper bizWidgetDatasourceExtHelper; + + @PostMapping("/list") + public ResponseResult>> list( + @MyRequestBody(required = true) String widgetType, + @MyRequestBody JSONObject filter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + String appCode = TokenData.takeFromRequest().getAppCode(); + MyPageData> pageData = + bizWidgetDatasourceExtHelper.getDataList(appCode, widgetType, filter, orderParam, pageParam); + return ResponseResult.success(pageData); + } + + /** + * 查看指定多条数据的详情。 + * + * @param widgetType 组件类型。 + * @param fieldName 字段名,如果为空则默认为主键过滤。 + * @param fieldValues 字段值。多个值之间逗号分割。 + * @return 详情数据。 + */ + @PostMapping("/view") + public ResponseResult>> view( + @MyRequestBody(required = true) String widgetType, + @MyRequestBody String fieldName, + @MyRequestBody(required = true) String fieldValues) { + String appCode = TokenData.takeFromRequest().getAppCode(); + List> dataMapList = + bizWidgetDatasourceExtHelper.getDataListWithInList(appCode, widgetType, fieldName, fieldValues); + return ResponseResult.success(dataMapList); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/java/com/orangeforms/common/ext/controller/UtilController.java b/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/java/com/orangeforms/common/ext/controller/UtilController.java new file mode 100644 index 00000000..0d94cc1c --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/java/com/orangeforms/common/ext/controller/UtilController.java @@ -0,0 +1,112 @@ +package com.orangeforms.common.ext.controller; + +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.EnumUtil; +import cn.hutool.core.util.StrUtil; +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.upload.BaseUpDownloader; +import com.orangeforms.common.core.upload.UpDownloaderFactory; +import com.orangeforms.common.core.upload.UploadResponseInfo; +import com.orangeforms.common.core.upload.UploadStoreTypeEnum; +import com.orangeforms.common.core.util.ContextUtil; +import com.orangeforms.common.ext.config.CommonExtProperties; +import lombok.extern.slf4j.Slf4j; +import org.redisson.api.RBinaryStream; +import org.redisson.api.RedissonClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.OutputStream; + +/** + * 扩展工具接口类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@RestController +@RequestMapping("${common-ext.urlPrefix}/util") +public class UtilController { + + @Autowired + private UpDownloaderFactory upDownloaderFactory; + @Autowired + private CommonExtProperties properties; + @Autowired + private RedissonClient redissonClient; + + private static final String IMAGE_DATA_FIELD = "imageData"; + + /** + * 上传图片数据。 + * + * @param uploadFile 上传图片文件。 + */ + @PostMapping("/uploadImage") + public void uploadImage(@RequestParam("uploadFile") MultipartFile uploadFile) throws IOException { + BaseUpDownloader upDownloader = + upDownloaderFactory.get(EnumUtil.getEnumAt(UploadStoreTypeEnum.class, properties.getUploadStoreType())); + UploadResponseInfo responseInfo = upDownloader.doUpload(null, + properties.getUploadFileBaseDir(), "CommonExt", IMAGE_DATA_FIELD, true, uploadFile); + if (BooleanUtil.isTrue(responseInfo.getUploadFailed())) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, + ResponseResult.error(ErrorCodeEnum.UPLOAD_FAILED, responseInfo.getErrorMessage())); + return; + } + String uploadUri = ContextUtil.getHttpRequest().getRequestURI(); + uploadUri = StrUtil.removeSuffix(uploadUri, "/"); + uploadUri = StrUtil.removeSuffix(uploadUri, "/uploadImage"); + responseInfo.setDownloadUri(uploadUri + "/downloadImage"); + ResponseResult.output(ResponseResult.success(responseInfo)); + } + + /** + * 下载图片数据。 + * + * @param filename 文件名。 + * @param response Http 应答对象。 + */ + @GetMapping("/downloadImage") + public void downloadImage(@RequestParam String filename, HttpServletResponse response) { + try { + BaseUpDownloader upDownloader = + upDownloaderFactory.get(EnumUtil.getEnumAt(UploadStoreTypeEnum.class, properties.getUploadStoreType())); + upDownloader.doDownload(properties.getUploadFileBaseDir(), + "CommonExt", IMAGE_DATA_FIELD, filename, true, response); + } catch (Exception e) { + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + log.error(e.getMessage(), e); + } + } + + /** + * 下载缓存的会话图片数据。 + * + * @param filename 文件名。 + * @param response Http 应答对象。 + */ + @GetMapping("/downloadSessionImage") + public void downloadSessionImage(@RequestParam String filename, HttpServletResponse response) throws IOException { + TokenData tokenData = TokenData.takeFromRequest(); + String key = tokenData.getSessionId() + filename; + RBinaryStream stream = redissonClient.getBinaryStream(key); + if (!stream.isExists()) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, + ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, "无效的会话缓存图片!")); + } + response.setHeader("content-type", "application/octet-stream"); + response.setContentType("application/octet-stream"); + response.setHeader("Content-Disposition", "attachment;filename=" + filename); + try (OutputStream os = response.getOutputStream()) { + os.write(stream.getAndDelete()); + } catch (IOException e) { + log.error("Failed to call LocalUpDownloader.doDownload", e); + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/java/com/orangeforms/common/ext/util/BizWidgetDatasourceExtHelper.java b/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/java/com/orangeforms/common/ext/util/BizWidgetDatasourceExtHelper.java new file mode 100644 index 00000000..ba9cef17 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/java/com/orangeforms/common/ext/util/BizWidgetDatasourceExtHelper.java @@ -0,0 +1,209 @@ +package com.orangeforms.common.ext.util; + +import cn.hutool.core.lang.Assert; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.text.StrFormatter; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpResponse; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.ext.base.BizWidgetDatasource; +import com.orangeforms.common.ext.config.CommonExtProperties; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import jakarta.annotation.PostConstruct; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 高级通用业务组件的扩展帮助实现类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Component +public class BizWidgetDatasourceExtHelper { + + @Autowired + private CommonExtProperties properties; + /** + * 全部框架使用橙单框架,同时组件所在模块,如在线表单,报表等和业务服务位于同一服务内是使用。 + */ + private static final String DEFAULT_ORANGE_APP = "__DEFAULT_ORANGE_APP__"; + /** + * Map的数据结构为:Map> + */ + private Map> dataExtractorMap = MapUtil.newHashMap(); + + @PostConstruct + private void laodThirdPartyAppConfig() { + Map appPropertiesMap = properties.getApplicationMap(); + if (MapUtil.isEmpty(appPropertiesMap)) { + return; + } + for (Map.Entry entry : appPropertiesMap.entrySet()) { + String appCode = entry.getKey(); + List datasources = entry.getValue().getBizWidgetDatasources(); + Map m = new HashMap<>(datasources.size()); + for (CommonExtProperties.BizWidgetDatasourceProperties datasource : datasources) { + List types = StrUtil.split(datasource.getTypes(), ","); + DatasourceWrapper w = new DatasourceWrapper(); + w.setListUrl(datasource.getListUrl()); + w.setViewUrl(datasource.getViewUrl()); + for (String type : types) { + m.put(type, w); + } + } + dataExtractorMap.put(appCode, m); + } + } + + /** + * 为默认APP注册基础组件数据源对象。 + * + * @param type 数据源类型。 + * @param datasource 业务通用组件的数据源接口。 + */ + public void registerDatasource(String type, BizWidgetDatasource datasource) { + Assert.notBlank(type); + Assert.notNull(datasource); + Map datasourceWrapperMap = + dataExtractorMap.computeIfAbsent(DEFAULT_ORANGE_APP, k -> new HashMap<>(2)); + datasourceWrapperMap.put(type, new DatasourceWrapper(datasource)); + } + + /** + * 根据过滤条件获取指定通用业务组件的数据列表。 + * + * @param appCode 接入应用编码。如果为空,则使用默认的 DEFAULT_ORANGE_APP。 + * @param type 组件数据源类型。 + * @param filter 过滤参数。不同的数据源参数不同。这里我们以键值对的方式传递。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 查询后的分页数据列表。 + */ + public MyPageData> getDataList( + String appCode, String type, Map filter, MyOrderParam orderParam, MyPageParam pageParam) { + if (StrUtil.isBlank(type)) { + throw new MyRuntimeException("Argument [types] can't be BLANK"); + } + if (StrUtil.isBlank(appCode)) { + return this.getDataList(type, filter, orderParam, pageParam); + } + DatasourceWrapper wrapper = this.getDatasourceWrapper(appCode, type); + JSONObject body = new JSONObject(); + body.put("type", type); + if (MapUtil.isNotEmpty(filter)) { + body.put("filter", filter); + } + if (orderParam != null) { + body.put("orderParam", orderParam); + } + if (pageParam != null) { + body.put("pageParam", pageParam); + } + String response = this.invokeThirdPartyUrlWithPost(wrapper.getListUrl(), body.toJSONString()); + ResponseResult>> responseResult = + JSON.parseObject(response, new TypeReference>>>() { + }); + if (!responseResult.isSuccess()) { + throw new MyRuntimeException(responseResult.getErrorMessage()); + } + return responseResult.getData(); + } + + /** + * 根据指定字段的集合获取指定通用业务组件的数据对象列表。 + * + * @param appCode 接入应用Id。如果为空,则使用默认的 DEFAULT_ORANGE_APP。 + * @param type 组件数据源类型。 + * @param fieldName 字段名称。 + * @param fieldValues 字段值结合。 + * @return 指定字段数据集合的数据对象列表。 + */ + public List> getDataListWithInList( + String appCode, String type, String fieldName, String fieldValues) { + if (StrUtil.isBlank(fieldValues)) { + throw new MyRuntimeException("Argument [fieldValues] can't be BLANK"); + } + if (StrUtil.isBlank(type)) { + throw new MyRuntimeException("Argument [types] can't be BLANK"); + } + if (StrUtil.isBlank(appCode)) { + return this.getDataListWithInList(type, fieldName, fieldValues); + } + DatasourceWrapper wrapper = this.getDatasourceWrapper(appCode, type); + JSONObject body = new JSONObject(); + body.put("type", type); + if (StrUtil.isNotBlank(fieldName)) { + body.put("fieldName", fieldName); + } + body.put("fieldValues", fieldValues); + String response = this.invokeThirdPartyUrlWithPost(wrapper.getViewUrl(), body.toJSONString()); + ResponseResult>> responseResult = + JSON.parseObject(response, new TypeReference>>>() { + }); + if (!responseResult.isSuccess()) { + throw new MyRuntimeException(responseResult.getErrorMessage()); + } + return responseResult.getData(); + } + + private MyPageData> getDataList( + String type, Map filter, MyOrderParam orderParam, MyPageParam pageParam) { + DatasourceWrapper wrapper = this.getDatasourceWrapper(DEFAULT_ORANGE_APP, type); + return wrapper.getBizWidgetDataSource().getDataList(type, filter, orderParam, pageParam); + } + + private List> getDataListWithInList(String type, String fieldName, String fieldValues) { + DatasourceWrapper wrapper = this.getDatasourceWrapper(DEFAULT_ORANGE_APP, type); + return wrapper.getBizWidgetDataSource().getDataListWithInList(type, fieldName, StrUtil.split(fieldValues, ",")); + } + + private String invokeThirdPartyUrlWithPost(String url, String body) { + String token = TokenData.takeFromRequest().getToken(); + Map headerMap = new HashMap<>(1); + headerMap.put("Authorization", token); + StringBuilder fullUrl = new StringBuilder(128); + fullUrl.append(url).append("?token=").append(token); + HttpResponse httpResponse = HttpUtil.createPost(fullUrl.toString()).body(body).addHeaders(headerMap).execute(); + if (!httpResponse.isOk()) { + String msg = StrFormatter.format( + "Failed to call [{}] with ERROR HTTP Status [{}] and [{}].", + url, httpResponse.getStatus(), httpResponse.body()); + log.error(msg); + throw new MyRuntimeException(msg); + } + return httpResponse.body(); + } + + private DatasourceWrapper getDatasourceWrapper(String appCode, String type) { + Map datasourceWrapperMap = dataExtractorMap.get(appCode); + Assert.notNull(datasourceWrapperMap); + DatasourceWrapper wrapper = datasourceWrapperMap.get(type); + Assert.notNull(wrapper); + return wrapper; + } + + @NoArgsConstructor + @Data + public static class DatasourceWrapper { + private BizWidgetDatasource bizWidgetDataSource; + private String listUrl; + private String viewUrl; + + public DatasourceWrapper(BizWidgetDatasource bizWidgetDataSource) { + this.bizWidgetDataSource = bizWidgetDataSource; + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..fc140409 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-ext/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.orangeforms.common.ext.config.CommonExtAutoConfig \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow-online/pom.xml b/OrangeFormsOpen-MybatisPlus/common/common-flow-online/pom.xml new file mode 100644 index 00000000..9e40544e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow-online/pom.xml @@ -0,0 +1,29 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-flow-online + 1.0.0 + common-flow-online + jar + + + + com.orangeforms + common-flow + 1.0.0 + + + com.orangeforms + common-online + 1.0.0 + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/config/FlowOnlineAutoConfig.java b/OrangeFormsOpen-MybatisPlus/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/config/FlowOnlineAutoConfig.java new file mode 100644 index 00000000..07538229 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/config/FlowOnlineAutoConfig.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.flow.online.config; + +import org.springframework.boot.context.properties.EnableConfigurationProperties; + +/** + * common-flow-online模块的自动配置引导类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EnableConfigurationProperties({FlowOnlineProperties.class}) +public class FlowOnlineAutoConfig { +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/config/FlowOnlineProperties.java b/OrangeFormsOpen-MybatisPlus/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/config/FlowOnlineProperties.java new file mode 100644 index 00000000..143afba4 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/config/FlowOnlineProperties.java @@ -0,0 +1,20 @@ +package com.orangeforms.common.flow.online.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * 在线表单工作流模块的配置对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ConfigurationProperties(prefix = "common-flow-online") +public class FlowOnlineProperties { + + /** + * 在线表单的URL前缀。 + */ + private String urlPrefix; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/controller/FlowOnlineOperationController.java b/OrangeFormsOpen-MybatisPlus/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/controller/FlowOnlineOperationController.java new file mode 100644 index 00000000..94dbf0c1 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/controller/FlowOnlineOperationController.java @@ -0,0 +1,1089 @@ +package com.orangeforms.common.flow.online.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.common.core.annotation.DisableDataFilter; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.flow.constant.FlowApprovalType; +import com.orangeforms.common.flow.constant.FlowConstant; +import com.orangeforms.common.flow.constant.FlowTaskStatus; +import com.orangeforms.common.flow.dto.FlowTaskCommentDto; +import com.orangeforms.common.flow.dto.FlowWorkOrderDto; +import com.orangeforms.common.flow.exception.FlowOperationException; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.flow.model.constant.FlowMessageType; +import com.orangeforms.common.flow.online.service.FlowOnlineOperationService; +import com.orangeforms.common.flow.service.FlowApiService; +import com.orangeforms.common.flow.service.FlowEntryService; +import com.orangeforms.common.flow.service.FlowMessageService; +import com.orangeforms.common.flow.service.FlowWorkOrderService; +import com.orangeforms.common.flow.util.FlowOperationHelper; +import com.orangeforms.common.flow.vo.FlowEntryVo; +import com.orangeforms.common.flow.vo.FlowTaskVo; +import com.orangeforms.common.flow.vo.FlowWorkOrderVo; +import com.orangeforms.common.flow.vo.TaskInfoVo; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.online.config.OnlineProperties; +import com.orangeforms.common.online.dto.OnlineFilterDto; +import com.orangeforms.common.online.model.*; +import com.orangeforms.common.online.model.constant.FieldFilterType; +import com.orangeforms.common.online.model.constant.FieldKind; +import com.orangeforms.common.online.model.constant.RelationType; +import com.orangeforms.common.online.service.*; +import com.orangeforms.common.online.util.OnlineOperationHelper; +import com.orangeforms.common.redis.cache.SessionCacheHelper; +import com.orangeforms.common.satoken.annotation.SaTokenDenyAuth; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.history.HistoricProcessInstance; +import org.flowable.engine.runtime.ProcessInstance; +import org.flowable.task.api.Task; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.io.Serializable; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 工作流在线表单流程操作接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "工作流在线表单流程操作接口") +@Slf4j +@RestController +@RequestMapping("${common-flow.urlPrefix}/flowOnlineOperation") +@ConditionalOnProperty(name = "common-flow.operationEnabled", havingValue = "true") +public class FlowOnlineOperationController { + + @Autowired + private FlowEntryService flowEntryService; + @Autowired + private FlowApiService flowApiService; + @Autowired + private FlowOperationHelper flowOperationHelper; + @Autowired + private FlowOnlineOperationService flowOnlineOperationService; + @Autowired + private FlowWorkOrderService flowWorkOrderService; + @Autowired + private FlowMessageService flowMessageService; + @Autowired + private OnlineFormService onlineFormService; + @Autowired + private OnlinePageService onlinePageService; + @Autowired + private OnlineOperationService onlineOperationService; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private OnlineOperationHelper onlineOperationHelper; + @Autowired + private OnlineProperties onlineProperties; + @Autowired + private SessionCacheHelper sessionCacheHelper; + + private static final String ONE_TO_MANY_VAR_SUFFIX = "List"; + + /** + * 根据指定流程的主版本,发起一个流程实例,同时作为第一个任务节点的执行人,执行第一个用户任务。 + * 该接口无需数据权限过滤,因此用DisableDataFilter注解标注。如果当前系统没有支持数据权限过滤,该注解不会有任何影响。 + * 注:流程设计页面的"启动"按钮,调用该接口可以启动任何流程用于流程配置后的测试验证。 + * + * @param processDefinitionKey 流程定义标识。 + * @param flowTaskCommentDto 审批意见。 + * @param taskVariableData 流程任务变量数据。 + * @param masterData 流程审批相关的主表数据。 + * @param slaveData 流程审批相关的多个从表数据。 + * @param copyData 传阅数据,格式为type和id,type的值参考FlowConstant中的常量值。 + * @return 应答结果对象。 + */ + @DisableDataFilter + @SaCheckPermission("flowEntry.all") + @OperationLog(type = SysOperationLogType.START_FLOW) + @PostMapping("/startPreview") + public ResponseResult startPreview( + @MyRequestBody(required = true) String processDefinitionKey, + @MyRequestBody(required = true) FlowTaskCommentDto flowTaskCommentDto, + @MyRequestBody JSONObject taskVariableData, + @MyRequestBody(required = true) JSONObject masterData, + @MyRequestBody JSONObject slaveData, + @MyRequestBody JSONObject copyData) { + return this.startAndTake( + processDefinitionKey, flowTaskCommentDto, taskVariableData, masterData, slaveData, copyData); + } + + /** + * 根据指定流程的主版本,发起一个流程实例,同时作为第一个任务节点的执行人,执行第一个用户任务。 + * 该接口无需数据权限过滤,因此用DisableDataFilter注解标注。如果当前系统没有支持数据权限过滤,该注解不会有任何影响。 + * + * @param processDefinitionKey 流程定义标识。 + * @param flowTaskCommentDto 审批意见。 + * @param taskVariableData 流程任务变量数据。 + * @param masterData 流程审批相关的主表数据。 + * @param slaveData 流程审批相关的多个从表数据。 + * @param copyData 传阅数据,格式为type和id,type的值参考FlowConstant中的常量值。 + * @return 应答结果对象。 + */ + @DisableDataFilter + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.START_FLOW) + @PostMapping("/startAndTakeUserTask/{processDefinitionKey}") + public ResponseResult startAndTakeUserTask( + @PathVariable("processDefinitionKey") String processDefinitionKey, + @MyRequestBody(required = true) FlowTaskCommentDto flowTaskCommentDto, + @MyRequestBody JSONObject taskVariableData, + @MyRequestBody(required = true) JSONObject masterData, + @MyRequestBody JSONObject slaveData, + @MyRequestBody JSONObject copyData) { + return this.startAndTake( + processDefinitionKey, flowTaskCommentDto, taskVariableData, masterData, slaveData, copyData); + } + + /** + * 启动流程并创建工单,同时将当前录入的数据存入草稿。 + * + * @param processDefinitionKey 流程定义标识。 + * @param processInstanceId 流程实例Id。第一次保存时,该值为null。 + * @param masterData 流程审批相关的主表数据。 + * @param slaveData 流程审批相关的多个从表数据。 + * @return 应答结果对象,草稿的待办任务对象。 + */ + @DisableDataFilter + @SaTokenDenyAuth + @PostMapping("/startAndSaveDraft/{processDefinitionKey}") + public ResponseResult startAndSaveDraft( + @PathVariable("processDefinitionKey") String processDefinitionKey, + @MyRequestBody String processInstanceId, + @MyRequestBody JSONObject masterData, + @MyRequestBody JSONObject slaveData) { + String errorMessage; + if (MapUtil.isEmpty(masterData) && MapUtil.isEmpty(slaveData)) { + errorMessage = "数据验证失败,业务数据不能全部为空!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + ResponseResult> verifyResult = + this.verifyAndGetFlowEntryPublishAndDatasource(processDefinitionKey, true); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + FlowEntryPublish flowEntryPublish = verifyResult.getData().getFirst(); + OnlineTable masterTable = verifyResult.getData().getSecond().getMasterTable(); + // 自动填充创建人数据。 + for (OnlineColumn column : masterTable.getColumnMap().values()) { + if (ObjectUtil.equals(column.getFieldKind(), FieldKind.CREATE_USER_ID)) { + masterData.put(column.getColumnName(), TokenData.takeFromRequest().getUserId()); + } else if (ObjectUtil.equals(column.getFieldKind(), FieldKind.CREATE_DEPT_ID)) { + masterData.put(column.getColumnName(), TokenData.takeFromRequest().getDeptId()); + } + } + FlowWorkOrder flowWorkOrder; + if (processInstanceId == null) { + flowWorkOrder = flowOnlineOperationService.saveNewDraftAndStartProcess( + flowEntryPublish.getProcessDefinitionId(), masterTable.getTableId(), masterData, slaveData); + } else { + ResponseResult flowWorkOrderResult = + flowOperationHelper.verifyAndGetFlowWorkOrderWithDraft(processDefinitionKey, processInstanceId); + if (!flowWorkOrderResult.isSuccess()) { + return ResponseResult.errorFrom(flowWorkOrderResult); + } + flowWorkOrder = flowWorkOrderResult.getData(); + flowWorkOrderService.updateDraft(flowWorkOrderResult.getData().getWorkOrderId(), + JSON.toJSONString(masterData), JSON.toJSONString(slaveData)); + } + List taskList = flowApiService.getProcessInstanceActiveTaskList(flowWorkOrder.getProcessInstanceId()); + List flowTaskVoList = flowApiService.convertToFlowTaskList(taskList); + return ResponseResult.success(flowTaskVoList.get(0)); + } + + /** + * 提交流程的用户任务。 + * 该接口无需数据权限过滤,因此用DisableDataFilter注解标注。如果当前系统没有支持数据权限过滤,该注解不会有任何影响。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 流程任务Id。 + * @param flowTaskCommentDto 流程审批数据。 + * @param taskVariableData 流程任务变量数据。 + * @param masterData 流程审批相关的主表数据。 + * @param slaveData 流程审批相关的多个从表数据。 + * @param copyData 传阅数据,格式为type和id,type的值参考FlowConstant中的常量值。 + * @return 应答结果对象。 + */ + @DisableDataFilter + @OperationLog(type = SysOperationLogType.SUBMIT_TASK) + @PostMapping("/submitUserTask") + public ResponseResult submitUserTask( + @MyRequestBody(required = true) String processInstanceId, + @MyRequestBody(required = true) String taskId, + @MyRequestBody(required = true) FlowTaskCommentDto flowTaskCommentDto, + @MyRequestBody JSONObject taskVariableData, + @MyRequestBody JSONObject masterData, + @MyRequestBody JSONObject slaveData, + @MyRequestBody JSONObject copyData) { + String errorMessage; + // 验证流程任务的合法性。 + Task task = flowApiService.getProcessInstanceActiveTask(processInstanceId, taskId); + ResponseResult taskInfoResult = flowOperationHelper.verifyAndGetRuntimeTaskInfo(task); + if (!taskInfoResult.isSuccess()) { + return ResponseResult.errorFrom(taskInfoResult); + } + TaskInfoVo taskInfo = taskInfoResult.getData(); + // 验证在线表单及其关联数据源的合法性。 + ResponseResult datasourceResult = this.verifyAndGetOnlineDatasource(taskInfo.getFormId()); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + CallResult assigneeVerifyResult = flowApiService.verifyAssigneeOrCandidateAndClaim(task); + if (!assigneeVerifyResult.isSuccess()) { + return ResponseResult.errorFrom(assigneeVerifyResult); + } + OnlineDatasource datasource = datasourceResult.getData(); + ProcessInstance instance = flowApiService.getProcessInstance(processInstanceId); + String dataId = instance.getBusinessKey(); + // 这里把传阅数据放到任务变量中,是为了避免给流程数据操作方法增加额外的方法调用参数。 + if (MapUtil.isNotEmpty(copyData)) { + if (taskVariableData == null) { + taskVariableData = new JSONObject(); + } + taskVariableData.put(FlowConstant.COPY_DATA_KEY, copyData); + } + FlowTaskComment flowTaskComment = BeanUtil.copyProperties(flowTaskCommentDto, FlowTaskComment.class); + if (StrUtil.isBlank(dataId)) { + return this.submitNewTask(processInstanceId, taskId, + flowTaskComment, taskVariableData, datasource, masterData, slaveData); + } + try { + if (StrUtil.equals(flowTaskComment.getApprovalType(), FlowApprovalType.TRANSFER) + && StrUtil.isBlank(flowTaskComment.getDelegateAssignee())) { + errorMessage = "数据验证失败,加签或转办任务指派人不能为空!!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + // 如果本次请求中包含从表数据,则一同插入。 + ResponseResult>> slaveDataListResult = + onlineOperationHelper.buildSlaveDataList(datasource.getDatasourceId(), slaveData); + if (!slaveDataListResult.isSuccess()) { + return ResponseResult.errorFrom(slaveDataListResult); + } + flowOnlineOperationService.updateAndTakeTask( + task, flowTaskComment, taskVariableData, datasource, masterData, dataId, slaveDataListResult.getData()); + } catch (FlowOperationException e) { + log.error("Failed to call [FlowOnlineOperationService.updateAndTakeTask]", e); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, e.getMessage()); + } + return ResponseResult.success(); + } + + /** + * 查看指定流程实例的草稿数据。 + * NOTE: 白名单接口。 + * + * @param processDefinitionKey 流程定义标识。 + * @param processInstanceId 流程实例Id。 + * @return 流程实例的草稿数据。 + */ + @DisableDataFilter + @GetMapping("/viewDraftData") + public ResponseResult viewDraftData( + @RequestParam String processDefinitionKey, @RequestParam String processInstanceId) { + String errorMessage; + ResponseResult flowWorkOrderResult = + flowOperationHelper.verifyAndGetFlowWorkOrderWithDraft(processDefinitionKey, processInstanceId); + if (!flowWorkOrderResult.isSuccess()) { + return ResponseResult.errorFrom(flowWorkOrderResult); + } + FlowWorkOrder flowWorkOrder = flowWorkOrderResult.getData(); + if (flowWorkOrder.getOnlineTableId() == null) { + errorMessage = "数据验证失败,当前工单不是在线表单工单!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + FlowWorkOrderExt flowWorkOrderExt = + flowWorkOrderService.getFlowWorkOrderExtByWorkOrderId(flowWorkOrder.getWorkOrderId()); + if (StrUtil.isBlank(flowWorkOrderExt.getDraftData())) { + return ResponseResult.success(null); + } + Long tableId = flowWorkOrder.getOnlineTableId(); + OnlineTable masterTable = onlineTableService.getOnlineTableFromCache(tableId); + JSONObject draftData = JSON.parseObject(flowWorkOrderExt.getDraftData()); + JSONObject masterData = draftData.getJSONObject(FlowConstant.MASTER_DATA_KEY); + JSONObject slaveData = draftData.getJSONObject(FlowConstant.SLAVE_DATA_KEY); + OnlineDatasource datasource = + onlineDatasourceService.getOnlineDatasourceByMasterTableId(tableId); + List slaveRelationList = null; + if (slaveData != null) { + ResponseResult> relationListResult = + onlineOperationHelper.verifyAndGetRelationList(datasource.getDatasourceId(), null); + if (!relationListResult.isSuccess()) { + return ResponseResult.errorFrom(relationListResult); + } + slaveRelationList = relationListResult.getData(); + } + datasource.setMasterTable(masterTable); + JSONObject jsonData = this.buildDraftData(datasource, masterData, slaveRelationList, slaveData); + return ResponseResult.success(jsonData); + } + + /** + * 获取当前流程实例的详情数据。包括主表数据、一对一从表数据、一对多从表数据列表等。 + * 该接口无需数据权限过滤,因此用DisableDataFilter注解标注。如果当前系统没有支持数据权限过滤,该注解不会有任何影响。 + * + * @param processInstanceId 当前运行时的流程实例Id。 + * @param taskId 流程任务Id。 + * @return 当前流程实例的详情数据。 + */ + @DisableDataFilter + @GetMapping("/viewUserTask") + public ResponseResult viewUserTask( + @RequestParam String processInstanceId, @RequestParam String taskId) { + // 验证流程任务的合法性。 + Task task = flowApiService.getProcessInstanceActiveTask(processInstanceId, taskId); + ProcessInstance instance = flowApiService.getProcessInstance(processInstanceId); + // 如果业务主数据为空,则直接返回。 + if (StrUtil.isBlank(instance.getBusinessKey())) { + return ResponseResult.success(null); + } + ResponseResult taskInfoResult = flowOperationHelper.verifyAndGetRuntimeTaskInfo(task); + if (!taskInfoResult.isSuccess()) { + return ResponseResult.errorFrom(taskInfoResult); + } + TaskInfoVo taskInfo = taskInfoResult.getData(); + // 验证在线表单及其关联数据源的合法性。 + ResponseResult datasourceResult = this.verifyAndGetOnlineDatasource(taskInfo.getFormId()); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + ResponseResult> relationListResult = + onlineOperationHelper.verifyAndGetRelationList(datasourceResult.getData().getDatasourceId(), null); + if (!relationListResult.isSuccess()) { + return ResponseResult.errorFrom(relationListResult); + } + JSONObject jsonData = this.buildUserTaskData( + instance.getBusinessKey(), datasourceResult.getData(), relationListResult.getData()); + return ResponseResult.success(jsonData); + } + + /** + * 获取已经结束的流程实例的详情数据。包括主表数据、一对一从表数据、一对多从表数据列表等。 + * 该接口无需数据权限过滤,因此用DisableDataFilter注解标注。如果当前系统没有支持数据权限过滤,该注解不会有任何影响。 + * + * @param processInstanceId 历史流程实例Id。 + * @param taskId 历史任务Id。如果该值为null,仅有发起人可以查看当前流程数据,否则只有任务的指派人才能查看。 + * @return 历史流程实例的详情数据。 + */ + @DisableDataFilter + @GetMapping("/viewHistoricProcessInstance") + public ResponseResult viewHistoricProcessInstance( + @RequestParam String processInstanceId, @RequestParam(required = false) String taskId) { + // 验证流程实例的合法性。 + ResponseResult verifyResult = + flowOperationHelper.verifyAndGetHistoricProcessInstance(processInstanceId, taskId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + HistoricProcessInstance instance = verifyResult.getData(); + if (StrUtil.isBlank(instance.getBusinessKey())) { + // 对于没有提交过任何用户任务的场景,可直接返回空数据。 + return ResponseResult.success(new JSONObject()); + } + FlowEntryPublish flowEntryPublish = + flowEntryService.getFlowEntryPublishList(CollUtil.newHashSet(instance.getProcessDefinitionId())).get(0); + TaskInfoVo taskInfoVo = JSON.parseObject(flowEntryPublish.getInitTaskInfo(), TaskInfoVo.class); + // 验证在线表单及其关联数据源的合法性。 + ResponseResult datasourceResult = this.verifyAndGetOnlineDatasource(taskInfoVo.getFormId()); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + ResponseResult> relationListResult = + onlineOperationHelper.verifyAndGetRelationList(datasourceResult.getData().getDatasourceId(), null); + if (!relationListResult.isSuccess()) { + return ResponseResult.errorFrom(relationListResult); + } + JSONObject jsonData = this.buildUserTaskData( + instance.getBusinessKey(), datasourceResult.getData(), relationListResult.getData()); + return ResponseResult.success(jsonData); + } + + /** + * 根据消息Id,获取流程Id关联的业务数据。 + * NOTE:白名单接口。 + * + * @param messageId 抄送消息Id。 + * @return 抄送消息关联的流程实例业务数据。 + */ + @DisableDataFilter + @GetMapping("/viewCopyBusinessData") + public ResponseResult viewCopyBusinessData(@RequestParam Long messageId) { + String errorMessage; + // 验证流程任务的合法性。 + FlowMessage flowMessage = flowMessageService.getById(messageId); + if (flowMessage == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + if (flowMessage.getMessageType() != FlowMessageType.COPY_TYPE) { + errorMessage = "数据验证失败,当前消息不是抄送类型消息!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (flowMessage.getOnlineFormData() == null || !flowMessage.getOnlineFormData()) { + errorMessage = "数据验证失败,当前消息为静态路由表单数据,不能通过该接口获取!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!flowMessageService.isCandidateIdentityOnMessage(messageId)) { + errorMessage = "数据验证失败,当前用户没有权限访问该消息!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + HistoricProcessInstance instance = + flowApiService.getHistoricProcessInstance(flowMessage.getProcessInstanceId()); + // 如果业务主数据为空,则直接返回。 + if (StrUtil.isBlank(instance.getBusinessKey())) { + errorMessage = "数据验证失败,当前消息为所属流程实例没有包含业务主键Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + Long formId = Long.valueOf(flowMessage.getBusinessDataShot()); + // 验证在线表单及其关联数据源的合法性。 + ResponseResult datasourceResult = this.verifyAndGetOnlineDatasource(formId); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + OnlineDatasource datasource = datasourceResult.getData(); + ResponseResult> relationListResult = + onlineOperationHelper.verifyAndGetRelationList(datasource.getDatasourceId(), null); + if (!relationListResult.isSuccess()) { + return ResponseResult.errorFrom(relationListResult); + } + JSONObject jsonData = this.buildUserTaskData( + instance.getBusinessKey(), datasource, relationListResult.getData()); + // 将当前消息更新为已读 + flowMessageService.readCopyTask(messageId); + return ResponseResult.success(jsonData); + } + + /** + * 工作流工单列表。 + * + * @param processDefinitionKey 流程标识名。 + * @param flowWorkOrderDtoFilter 过滤对象。 + * @param pageParam 分页参数。 + * @return 查询结果。 + */ + @SaTokenDenyAuth + @PostMapping("/listWorkOrder/{processDefinitionKey}") + public ResponseResult> listWorkOrder( + @PathVariable("processDefinitionKey") String processDefinitionKey, + @MyRequestBody FlowWorkOrderDto flowWorkOrderDtoFilter, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount()); + } + FlowWorkOrder flowWorkOrderFilter = + flowOperationHelper.makeWorkOrderFilter(flowWorkOrderDtoFilter, processDefinitionKey); + MyOrderParam orderParam = new MyOrderParam(); + orderParam.add(new MyOrderParam.OrderInfo("workOrderId", false, null)); + String orderBy = MyOrderParam.buildOrderBy(orderParam, FlowWorkOrder.class); + List flowWorkOrderList = + flowWorkOrderService.getFlowWorkOrderList(flowWorkOrderFilter, orderBy); + MyPageData resultData = + MyPageUtil.makeResponseData(flowWorkOrderList, FlowWorkOrderVo.class); + flowOperationHelper.buildWorkOrderApprovalStatus(processDefinitionKey, resultData.getDataList()); + // 根据工单的提交用户名获取用户的显示名称,便于前端显示。 + // 同时这也是一个如何通过插件方法,将loginName映射到showName的示例, + flowWorkOrderService.fillUserShowNameByLoginName(resultData.getDataList()); + // 工单自身的查询中可以受到数据权限的过滤,但是工单集成业务数据时,则无需再对业务数据进行数据权限过滤了。 + GlobalThreadLocal.setDataFilter(false); + ResponseResult responseResult = this.makeWorkOrderTaskInfo(resultData.getDataList()); + if (!responseResult.isSuccess()) { + return ResponseResult.errorFrom(responseResult); + } + return ResponseResult.success(resultData); + } + + /** + * 为数据源主表字段上传文件。 + * + * @param processDefinitionKey 流程引擎流程定义标识。 + * @param processInstanceId 流程实例Id。 + * @param taskId 流程任务Id。 + * @param datasourceId 数据源Id。 + * @param relationId 数据源关联Id。 + * @param fieldName 数据表字段名。 + * @param asImage 是否为图片文件。 + * @param uploadFile 上传文件对象。 + */ + @DisableDataFilter + @OperationLog(type = SysOperationLogType.UPLOAD, saveResponse = false) + @PostMapping("/upload") + public void upload( + @RequestParam String processDefinitionKey, + @RequestParam(required = false) String processInstanceId, + @RequestParam(required = false) String taskId, + @RequestParam Long datasourceId, + @RequestParam(required = false) Long relationId, + @RequestParam String fieldName, + @RequestParam Boolean asImage, + @RequestParam("uploadFile") MultipartFile uploadFile) throws IOException { + ResponseResult verifyResult = + this.verifyUploadOrDownload(processDefinitionKey, processInstanceId, taskId, datasourceId); + if (!verifyResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, ResponseResult.errorFrom(verifyResult)); + return; + } + ResponseResult verifyTableResult = + this.verifyAndGetOnlineTable(datasourceId, relationId, null, null); + if (!verifyTableResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, ResponseResult.errorFrom(verifyTableResult)); + return; + } + onlineOperationHelper.doUpload(verifyTableResult.getData(), fieldName, asImage, uploadFile); + } + + /** + * 下载文件接口。 + * 越权访问限制说明: + * taskId为空,当前用户必须为当前流程的发起人,否则必须为当前任务的指派人或候选人。 + * relationId为空,下载数据为主表字段,否则为关联的从表字段。 + * 该接口无需数据权限过滤,因此用DisableDataFilter注解标注。如果当前系统没有支持数据权限过滤,该注解不会有任何影响。 + * + * @param processDefinitionKey 流程引擎流程定义标识。 + * @param processInstanceId 流程实例Id。 + * @param taskId 流程任务Id。 + * @param datasourceId 数据源Id。 + * @param relationId 数据源关联Id。 + * @param dataId 附件所在记录的主键Id。 + * @param fieldName 数据表字段名。 + * @param asImage 是否为图片文件。 + * @param response Http 应答对象。 + */ + @DisableDataFilter + @OperationLog(type = SysOperationLogType.DOWNLOAD, saveResponse = false) + @GetMapping("/download") + public void download( + @RequestParam String processDefinitionKey, + @RequestParam(required = false) String processInstanceId, + @RequestParam(required = false) String taskId, + @RequestParam Long datasourceId, + @RequestParam(required = false) Long relationId, + @RequestParam(required = false) String dataId, + @RequestParam String fieldName, + @RequestParam String filename, + @RequestParam Boolean asImage, + HttpServletResponse response) throws IOException { + ResponseResult verifyResult = + this.verifyUploadOrDownload(processDefinitionKey, processInstanceId, taskId, datasourceId); + if (!verifyResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, ResponseResult.errorFrom(verifyResult)); + return; + } + ResponseResult verifyTableResult = + this.verifyAndGetOnlineTable(datasourceId, relationId, verifyResult.getData(), dataId); + if (!verifyTableResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, ResponseResult.errorFrom(verifyTableResult)); + return; + } + onlineOperationHelper.doDownload(verifyTableResult.getData(), dataId, fieldName, filename, asImage, response); + } + + /** + * 获取所有流程对象,同时获取关联的在线表单对象列表。 + * + * @return 查询结果。 + */ + @GetMapping("/listFlowEntryForm") + public ResponseResult> listFlowEntryForm() { + List flowEntryList = flowEntryService.getFlowEntryList(null, null); + List flowEntryVoList = MyModelUtil.copyCollectionTo(flowEntryList, FlowEntryVo.class); + if (CollUtil.isNotEmpty(flowEntryVoList)) { + Set pageIdSet = flowEntryVoList.stream().map(FlowEntryVo::getPageId).collect(Collectors.toSet()); + List formList = onlineFormService.getOnlineFormListByPageIds(pageIdSet); + formList.forEach(f -> f.setWidgetJson(null)); + Map> formMap = + formList.stream().collect(Collectors.groupingBy(OnlineForm::getPageId)); + for (FlowEntryVo flowEntryVo : flowEntryVoList) { + List flowEntryFormList = formMap.get(flowEntryVo.getPageId()); + flowEntryVo.setFormList(MyModelUtil.beanToMapList(flowEntryFormList)); + } + } + return ResponseResult.success(flowEntryVoList); + } + + /** + * 获取在线表单工作流Id所关联的权限数据,包括权限字列表和权限资源列表。 + * 注:该接口仅用于微服务间调用使用,无需对前端开放。 + * + * @param onlineFlowEntryIds 在线表单工作流Id集合。 + * @return 参数中在线表单工作流Id集合所关联的权限数据。 + */ + @GetMapping("/calculatePermData") + public ResponseResult>> calculatePermData(@RequestParam Set onlineFlowEntryIds) { + return ResponseResult.success(flowOnlineOperationService.calculatePermData(onlineFlowEntryIds)); + } + + private ResponseResult startAndTake( + String processDefinitionKey, + FlowTaskCommentDto flowTaskCommentDto, + JSONObject taskVariableData, + JSONObject masterData, + JSONObject slaveData, + JSONObject copyData) { + ResponseResult> verifyResult = + this.verifyAndGetFlowEntryPublishAndDatasource(processDefinitionKey, true); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + FlowEntryPublish flowEntryPublish = verifyResult.getData().getFirst(); + OnlineDatasource datasource = verifyResult.getData().getSecond(); + OnlineTable masterTable = datasource.getMasterTable(); + // 这里把传阅数据放到任务变量中,是为了避免给流程数据操作方法增加额外的方法调用参数。 + if (MapUtil.isNotEmpty(copyData)) { + if (taskVariableData == null) { + taskVariableData = new JSONObject(); + } + taskVariableData.put(FlowConstant.COPY_DATA_KEY, copyData); + } + FlowTaskComment flowTaskComment = BeanUtil.copyProperties(flowTaskCommentDto, FlowTaskComment.class); + // 保存在线表单提交的数据,同时启动流程和自动完成第一个用户任务。 + if (slaveData == null) { + flowOnlineOperationService.saveNewAndStartProcess( + flowEntryPublish.getProcessDefinitionId(), + flowTaskComment, + taskVariableData, + masterTable, + masterData); + } else { + // 如果本次请求中包含从表数据,则一同插入。 + ResponseResult>> slaveDataListResult = + onlineOperationHelper.buildSlaveDataList(datasource.getDatasourceId(), slaveData); + if (!slaveDataListResult.isSuccess()) { + return ResponseResult.errorFrom(slaveDataListResult); + } + flowOnlineOperationService.saveNewAndStartProcess( + flowEntryPublish.getProcessDefinitionId(), + flowTaskComment, + taskVariableData, + masterTable, + masterData, + slaveDataListResult.getData()); + } + return ResponseResult.success(); + } + + private ResponseResult verifyAndGetOnlineDatasource(Long formId) { + List formDatasourceList = onlineFormService.getFormDatasourceListFromCache(formId); + if (CollUtil.isEmpty(formDatasourceList)) { + String errorMessage = "数据验证失败,流程任务绑定的在线表单Id [" + formId + "] 不存在,请修改流程图!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return onlineOperationHelper.verifyAndGetDatasource(formDatasourceList.get(0).getDatasourceId()); + } + + private ResponseResult> verifyAndGetFlowEntryPublishAndDatasource( + String processDefinitionKey, boolean checkStarter) { + String errorMessage; + // 1. 验证流程数据的合法性。 + ResponseResult flowEntryResult = flowOperationHelper.verifyAndGetFlowEntry(processDefinitionKey); + if (!flowEntryResult.isSuccess()) { + return ResponseResult.errorFrom(flowEntryResult); + } + // 2. 验证流程一个用户任务的合法性。 + FlowEntryPublish flowEntryPublish = flowEntryResult.getData().getMainFlowEntryPublish(); + if (BooleanUtil.isFalse(flowEntryPublish.getActiveStatus())) { + errorMessage = "数据验证失败,当前流程发布对象已被挂起,不能启动新流程!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + ResponseResult taskInfoResult = + flowOperationHelper.verifyAndGetInitialTaskInfo(flowEntryPublish, checkStarter); + if (!taskInfoResult.isSuccess()) { + return ResponseResult.errorFrom(taskInfoResult); + } + TaskInfoVo taskInfo = taskInfoResult.getData(); + // 3. 验证在线表单及其关联数据源的合法性。 + ResponseResult datasourceResult = this.verifyAndGetOnlineDatasource(taskInfo.getFormId()); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + return ResponseResult.success(new Tuple2<>(flowEntryPublish, datasourceResult.getData())); + } + + private ResponseResult verifyAndGetOnlineTable( + Long datasourceId, Long relationId, String businessKey, String dataId) { + ResponseResult datasourceResult = + onlineOperationHelper.verifyAndGetDatasource(datasourceId); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + OnlineTable masterTable = datasourceResult.getData().getMasterTable(); + OnlineTable table = masterTable; + ResponseResult relationResult = null; + if (relationId != null) { + relationResult = onlineOperationHelper.verifyAndGetRelation(datasourceId, relationId); + if (!relationResult.isSuccess()) { + return ResponseResult.errorFrom(relationResult); + } + table = relationResult.getData().getSlaveTable(); + } + if (StrUtil.hasBlank(businessKey, dataId)) { + return ResponseResult.success(table); + } + String errorMessage; + // 如果relationId为null,这里就是主表数据。 + if (relationId == null) { + if (!StrUtil.equals(businessKey, dataId)) { + errorMessage = "数据验证失败,参数主键Id与流程主表主键Id不匹配!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(table); + } + OnlineDatasourceRelation relation = relationResult.getData(); + OnlineTable slaveTable = relation.getSlaveTable(); + Map dataMap = + onlineOperationService.getMasterData(slaveTable, null, null, dataId); + if (dataMap == null) { + errorMessage = "数据验证失败,从表主键Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineColumn slaveColumn = relation.getSlaveColumn(); + Object relationSlaveDataId = dataMap.get(slaveColumn.getColumnName()); + if (relationSlaveDataId == null) { + errorMessage = "数据验证失败,当前关联的从表字段值为NULL!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineColumn masterColumn = masterTable.getColumnMap().get(relation.getMasterColumnId()); + if (BooleanUtil.isTrue(masterColumn.getPrimaryKey()) + && !StrUtil.equals(relationSlaveDataId.toString(), businessKey)) { + errorMessage = "数据验证失败,当前从表主键Id关联的主表Id当前流程的BusinessKey不一致!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + Map masterDataMap = + onlineOperationService.getMasterData(masterTable, null, null, businessKey); + if (masterDataMap == null) { + errorMessage = "数据验证失败,主表主键Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + Object relationMasterDataId = masterDataMap.get(masterColumn.getColumnName()); + if (relationMasterDataId == null) { + errorMessage = "数据验证失败,当前关联的主表字段值为NULL!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!StrUtil.equals(relationMasterDataId.toString(), relationSlaveDataId.toString())) { + errorMessage = "数据验证失败,当前关联的主表字段值和从表字段值不一致!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(table); + } + + private ResponseResult verifyUploadOrDownload( + String processDefinitionKey, String processInstanceId, String taskId, Long datasourceId) { + if (!StrUtil.isAllBlank(processInstanceId, taskId)) { + ResponseResult verifyResult = + flowOperationHelper.verifyUploadOrDownloadPermission(processInstanceId, taskId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(ResponseResult.errorFrom(verifyResult)); + } + } + String errorMessage; + FlowEntry flowEntry = flowEntryService.getFlowEntryFromCache(processDefinitionKey); + if (flowEntry == null) { + errorMessage = "数据验证失败,指定流程Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + String businessKey = null; + if (processInstanceId != null) { + HistoricProcessInstance instance = flowApiService.getHistoricProcessInstance(processInstanceId); + if (!StrUtil.equals(flowEntry.getProcessDefinitionKey(), instance.getProcessDefinitionKey())) { + errorMessage = "数据验证失败,指定流程实例并不属于当前流程!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + businessKey = instance.getBusinessKey(); + } + List datasourceList = + onlinePageService.getOnlinePageDatasourceListByPageId(flowEntry.getPageId()); + Optional r = datasourceList.stream() + .map(OnlinePageDatasource::getDatasourceId).filter(c -> c.equals(datasourceId)).findFirst(); + if (r.isEmpty()) { + errorMessage = "数据验证失败,当前数据源Id并不属于当前流程!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(businessKey); + } + + private ResponseResult submitNewTask( + String instanceId, + String taskId, + FlowTaskComment comment, + JSONObject variableData, + OnlineDatasource datasource, + JSONObject masterData, + JSONObject slaveData) { + OnlineTable masterTable = datasource.getMasterTable(); + // 保存在线表单提交的数据,同时启动流程和自动完成第一个用户任务。 + if (slaveData == null) { + flowOnlineOperationService.saveNewAndTakeTask( + instanceId, taskId, comment, variableData, masterTable, masterData); + } else { + // 如果本次请求中包含从表数据,则一同插入。 + ResponseResult>> slaveDataListResult = + onlineOperationHelper.buildSlaveDataList(datasource.getDatasourceId(), slaveData); + if (!slaveDataListResult.isSuccess()) { + return ResponseResult.errorFrom(slaveDataListResult); + } + flowOnlineOperationService.saveNewAndTakeTask( + instanceId, taskId, comment, variableData, masterTable, masterData, slaveDataListResult.getData()); + } + return ResponseResult.success(); + } + + private JSONObject buildUserTaskData( + String businessKey, OnlineDatasource datasource, List relationList) { + OnlineTable masterTable = datasource.getMasterTable(); + JSONObject jsonData = new JSONObject(); + List oneToOneRelationList = relationList.stream() + .filter(r -> r.getRelationType().equals(RelationType.ONE_TO_ONE)).collect(Collectors.toList()); + Map result = + onlineOperationService.getMasterData(masterTable, oneToOneRelationList, relationList, businessKey); + if (MapUtil.isEmpty(result)) { + return jsonData; + } + jsonData.put(datasource.getVariableName(), result); + List oneToManyRelationList = relationList.stream() + .filter(r -> r.getRelationType().equals(RelationType.ONE_TO_MANY)).collect(Collectors.toList()); + if (CollUtil.isEmpty(oneToManyRelationList)) { + return jsonData; + } + for (OnlineDatasourceRelation relation : oneToManyRelationList) { + OnlineFilterDto filterDto = new OnlineFilterDto(); + filterDto.setTableName(relation.getSlaveTable().getTableName()); + OnlineColumn slaveColumn = relation.getSlaveTable().getColumnMap().get(relation.getSlaveColumnId()); + filterDto.setColumnName(slaveColumn.getColumnName()); + filterDto.setFilterType(FieldFilterType.EQUAL_FILTER); + OnlineColumn masterColumn = masterTable.getColumnMap().get(relation.getMasterColumnId()); + Object columnValue = result.get(masterColumn.getColumnName()); + filterDto.setColumnValue(columnValue); + MyPageData> pageData = onlineOperationService.getSlaveDataList( + relation, CollUtil.newLinkedList(filterDto), null, null); + if (CollUtil.isNotEmpty(pageData.getDataList())) { + result.put(relation.getVariableName() + ONE_TO_MANY_VAR_SUFFIX, pageData.getDataList()); + } + } + return jsonData; + } + + private JSONObject buildDraftData( + OnlineDatasource datasource, + JSONObject masterData, + List relationList, + JSONObject slaveData) { + OnlineTable masterTable = datasource.getMasterTable(); + JSONObject jsonData = new JSONObject(); + JSONObject normalizedMasterData = new JSONObject(); + Map columnNameAndColumnMap = masterTable.getColumnMap() + .values().stream().collect(Collectors.toMap(OnlineColumn::getColumnName, c -> c)); + if (masterData != null) { + for (Map.Entry entry : masterData.entrySet()) { + OnlineColumn column = columnNameAndColumnMap.get(entry.getKey()); + Object v = onlineOperationHelper.convertToTypeValue(column, entry.getValue().toString()); + normalizedMasterData.put(entry.getKey(), v); + } + } + if (slaveData != null && relationList != null) { + Map relationMap = + relationList.stream().collect(Collectors.toMap(OnlineDatasourceRelation::getRelationId, c -> c)); + for (Map.Entry entry : slaveData.entrySet()) { + OnlineDatasourceRelation relation = relationMap.get(Long.valueOf(entry.getKey())); + if (relation != null) { + this.buildRelationDraftData(relation, entry.getValue(), normalizedMasterData); + } + } + } + jsonData.put(datasource.getVariableName(), normalizedMasterData); + return jsonData; + } + + private void buildRelationDraftData(OnlineDatasourceRelation relation, Object value, JSONObject masterData) { + if (relation.getRelationType().equals(RelationType.ONE_TO_ONE)) { + Map slaveColumnNameAndColumnMap = + relation.getSlaveTable().getColumnMap().values() + .stream().collect(Collectors.toMap(OnlineColumn::getColumnName, c -> c)); + JSONObject slaveObject = (JSONObject) value; + JSONObject normalizedSlaveObject = new JSONObject(); + for (Map.Entry entry2 : slaveObject.entrySet()) { + OnlineColumn column = slaveColumnNameAndColumnMap.get(entry2.getKey()); + Object v = onlineOperationHelper.convertToTypeValue(column, entry2.getValue().toString()); + normalizedSlaveObject.put(entry2.getKey(), v); + } + masterData.put(relation.getVariableName(), normalizedSlaveObject); + } else if (relation.getRelationType().equals(RelationType.ONE_TO_MANY)) { + JSONArray slaveArray = (JSONArray) value; + JSONArray normalizedSlaveArray = new JSONArray(); + for (int i = 0; i <= slaveArray.size() - 1; i++) { + JSONObject slaveObject = slaveArray.getJSONObject(i); + JSONObject normalizedSlaveObject = new JSONObject(); + normalizedSlaveObject.putAll(slaveObject); + normalizedSlaveArray.add(normalizedSlaveObject); + } + masterData.put(relation.getVariableName(), normalizedSlaveArray); + } + } + + private ResponseResult makeWorkOrderTaskInfo(List flowWorkOrderVoList) { + if (CollUtil.isEmpty(flowWorkOrderVoList)) { + return ResponseResult.success(); + } + Set definitionIdSet = + flowWorkOrderVoList.stream().map(FlowWorkOrderVo::getProcessDefinitionId).collect(Collectors.toSet()); + List flowEntryPublishList = flowEntryService.getFlowEntryPublishList(definitionIdSet); + Map flowEntryPublishMap = + flowEntryPublishList.stream().collect(Collectors.toMap(FlowEntryPublish::getProcessDefinitionId, c -> c)); + for (FlowWorkOrderVo flowWorkOrderVo : flowWorkOrderVoList) { + FlowEntryPublish flowEntryPublish = flowEntryPublishMap.get(flowWorkOrderVo.getProcessDefinitionId()); + flowWorkOrderVo.setInitTaskInfo(flowEntryPublish.getInitTaskInfo()); + } + Long tableId = flowWorkOrderVoList.get(0).getOnlineTableId(); + OnlineTable masterTable = onlineTableService.getOnlineTableFromCache(tableId); + ResponseResult responseResult = + this.buildWorkOrderMasterData(flowWorkOrderVoList, masterTable); + if (!responseResult.isSuccess()) { + return ResponseResult.errorFrom(responseResult); + } + responseResult = this.buildWorkOrderDraftData(flowWorkOrderVoList, masterTable); + if (!responseResult.isSuccess()) { + return ResponseResult.errorFrom(responseResult); + } + List unfinishedProcessInstanceIds = flowWorkOrderVoList.stream() + .filter(c -> !c.getFlowStatus().equals(FlowTaskStatus.FINISHED)) + .map(FlowWorkOrderVo::getProcessInstanceId) + .collect(Collectors.toList()); + if (CollUtil.isEmpty(unfinishedProcessInstanceIds)) { + return ResponseResult.success(); + } + Map> taskMap = + flowApiService.getTaskListByProcessInstanceIds(unfinishedProcessInstanceIds) + .stream().collect(Collectors.groupingBy(Task::getProcessInstanceId)); + for (FlowWorkOrderVo flowWorkOrderVo : flowWorkOrderVoList) { + List instanceTaskList = taskMap.get(flowWorkOrderVo.getProcessInstanceId()); + if (instanceTaskList != null) { + JSONArray taskArray = new JSONArray(); + for (Task task : instanceTaskList) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("taskId", task.getId()); + jsonObject.put("taskName", task.getName()); + jsonObject.put("taskKey", task.getTaskDefinitionKey()); + jsonObject.put("assignee", task.getAssignee()); + taskArray.add(jsonObject); + } + flowWorkOrderVo.setRuntimeTaskInfoList(taskArray); + } + } + return ResponseResult.success(); + } + + private ResponseResult buildWorkOrderDraftData( + List flowWorkOrderVoList, OnlineTable masterTable) { + List draftWorkOrderList = flowWorkOrderVoList.stream() + .filter(c -> c.getFlowStatus().equals(FlowTaskStatus.DRAFT)).collect(Collectors.toList()); + if (CollUtil.isEmpty(draftWorkOrderList)) { + return ResponseResult.success(); + } + Set workOrderIdSet = draftWorkOrderList.stream() + .map(FlowWorkOrderVo::getWorkOrderId).collect(Collectors.toSet()); + List workOrderExtList = + flowWorkOrderService.getFlowWorkOrderExtByWorkOrderIds(workOrderIdSet); + Map workOrderExtMap = workOrderExtList.stream() + .collect(Collectors.toMap(FlowWorkOrderExt::getWorkOrderId, c -> c)); + for (FlowWorkOrderVo workOrder : draftWorkOrderList) { + FlowWorkOrderExt workOrderExt = workOrderExtMap.get(workOrder.getWorkOrderId()); + if (workOrderExt == null) { + continue; + } + JSONObject draftData = JSON.parseObject(workOrderExt.getDraftData()); + JSONObject masterData = draftData.getJSONObject(FlowConstant.MASTER_DATA_KEY); + JSONObject slaveData = draftData.getJSONObject(FlowConstant.SLAVE_DATA_KEY); + OnlineDatasource datasource = + onlineDatasourceService.getOnlineDatasourceByMasterTableId(masterTable.getTableId()); + List slaveRelationList = null; + if (slaveData != null) { + ResponseResult> relationListResult = + onlineOperationHelper.verifyAndGetRelationList(datasource.getDatasourceId(), RelationType.ONE_TO_ONE); + if (!relationListResult.isSuccess()) { + return ResponseResult.errorFrom(relationListResult); + } + slaveRelationList = relationListResult.getData(); + } + datasource.setMasterTable(masterTable); + JSONObject jsonData = this.buildDraftData(datasource, masterData, slaveRelationList, slaveData); + JSONObject masterAndOneToOneData = jsonData.getJSONObject(datasource.getVariableName()); + if (MapUtil.isNotEmpty(masterAndOneToOneData)) { + List> dataList = new LinkedList<>(); + dataList.add(masterAndOneToOneData); + onlineOperationService.buildDataListWithDict(masterTable, slaveRelationList, dataList); + } + workOrder.setMasterData(masterAndOneToOneData); + } + return ResponseResult.success(); + } + + private ResponseResult buildWorkOrderMasterData( + List flowWorkOrderVoList, OnlineTable masterTable) { + Set businessKeySet = flowWorkOrderVoList.stream() + .map(FlowWorkOrderVo::getBusinessKey) + .filter(Objects::nonNull).collect(Collectors.toSet()); + if (CollUtil.isEmpty(businessKeySet)) { + return ResponseResult.success(); + } + Set convertedBusinessKeySet = + onlineOperationHelper.convertToTypeValue(masterTable.getPrimaryKeyColumn(), businessKeySet); + List filterList = new LinkedList<>(); + OnlineFilterDto filterDto = new OnlineFilterDto(); + filterDto.setTableName(masterTable.getTableName()); + filterDto.setColumnName(masterTable.getPrimaryKeyColumn().getColumnName()); + filterDto.setFilterType(FieldFilterType.IN_LIST_FILTER); + filterDto.setColumnValueList(new HashSet<>(convertedBusinessKeySet)); + filterList.add(filterDto); + TaskInfoVo taskInfoVo = JSON.parseObject(flowWorkOrderVoList.get(0).getInitTaskInfo(), TaskInfoVo.class); + // 验证在线表单及其关联数据源的合法性。 + ResponseResult datasourceResult = this.verifyAndGetOnlineDatasource(taskInfoVo.getFormId()); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + OnlineDatasource datasource = datasourceResult.getData(); + ResponseResult> relationListResult = + onlineOperationHelper.verifyAndGetRelationList(datasource.getDatasourceId(), RelationType.ONE_TO_ONE); + if (!relationListResult.isSuccess()) { + return ResponseResult.errorFrom(relationListResult); + } + MyPageData> pageData = onlineOperationService.getMasterDataList( + masterTable, relationListResult.getData(), null, filterList, null, null); + List> dataList = pageData.getDataList(); + Map> dataMap = dataList.stream() + .collect(Collectors.toMap(c -> c.get(masterTable.getPrimaryKeyColumn().getColumnName()).toString(), c -> c)); + for (FlowWorkOrderVo flowWorkOrderVo : flowWorkOrderVoList) { + if (StrUtil.isNotBlank(flowWorkOrderVo.getBusinessKey())) { + Object dataId = onlineOperationHelper.convertToTypeValue( + masterTable.getPrimaryKeyColumn(), flowWorkOrderVo.getBusinessKey()); + Map data = dataMap.get(dataId.toString()); + if (data != null) { + flowWorkOrderVo.setMasterData(data); + } + } + } + return ResponseResult.success(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/service/FlowOnlineOperationService.java b/OrangeFormsOpen-MybatisPlus/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/service/FlowOnlineOperationService.java new file mode 100644 index 00000000..14aee423 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/service/FlowOnlineOperationService.java @@ -0,0 +1,136 @@ +package com.orangeforms.common.flow.online.service; + +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.flow.model.FlowTaskComment; +import com.orangeforms.common.flow.model.FlowWorkOrder; +import com.orangeforms.common.online.model.OnlineDatasource; +import com.orangeforms.common.online.model.OnlineDatasourceRelation; +import com.orangeforms.common.online.model.OnlineTable; +import org.flowable.task.api.Task; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 流程操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowOnlineOperationService { + + /** + * 保存在线表单的数据,同时启动流程。如果当前用户是第一个用户任务的Assignee, + * 或者第一个用户任务的Assignee是流程发起人变量,该方法还会自动Take第一个任务。 + * + * @param processDefinitionId 流程定义Id。 + * @param flowTaskComment 流程审批批注对象。 + * @param taskVariableData 流程任务的变量数据。 + * @param table 表对象。 + * @param data 表数据。 + */ + void saveNewAndStartProcess( + String processDefinitionId, + FlowTaskComment flowTaskComment, + JSONObject taskVariableData, + OnlineTable table, + JSONObject data); + + /** + * 保存在线表单的数据,同时启动流程。如果当前用户是第一个用户任务的Assignee, + * 或者第一个用户任务的Assignee是流程发起人变量,该方法还会自动Take第一个任务。 + * + * @param processDefinitionId 流程定义Id。 + * @param flowTaskComment 流程审批批注对象。 + * @param taskVariableData 流程任务的变量数据。 + * @param masterTable 主表对象。 + * @param masterData 主表数据。 + * @param slaveDataListMap 关联从表数据Map。 + */ + void saveNewAndStartProcess( + String processDefinitionId, + FlowTaskComment flowTaskComment, + JSONObject taskVariableData, + OnlineTable masterTable, + JSONObject masterData, + Map> slaveDataListMap); + + /** + * 保存在线表单的草稿数据,同时启动一个流程实例。 + * + * @param processDefinitionId 流程定义Id。 + * @param tableId 在线表单主表Id。 + * @param masterData 主表数据。 + * @param slaveData 所有关联从表数据。 + * @return 流程工单对象。 + */ + FlowWorkOrder saveNewDraftAndStartProcess( + String processDefinitionId, Long tableId, JSONObject masterData, JSONObject slaveData); + + /** + * 保存在线表单的数据,同时Take用户任务。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 流程任务Id。 + * @param flowTaskComment 流程审批批注对象。 + * @param taskVariableData 流程任务的变量数据。 + * @param table 表对象。 + * @param data 表数据。 + */ + void saveNewAndTakeTask( + String processInstanceId, + String taskId, + FlowTaskComment flowTaskComment, + JSONObject taskVariableData, + OnlineTable table, + JSONObject data); + + /** + * 保存在线表单的数据,同时Take用户任务。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 流程任务Id。 + * @param flowTaskComment 流程审批批注对象。 + * @param taskVariableData 流程任务的变量数据。 + * @param masterTable 主表对象。 + * @param masterData 主表数据。 + * @param slaveDataListMap 关联从表数据Map。 + */ + void saveNewAndTakeTask( + String processInstanceId, + String taskId, + FlowTaskComment flowTaskComment, + JSONObject taskVariableData, + OnlineTable masterTable, + JSONObject masterData, + Map> slaveDataListMap); + + /** + * 保存业务表数据,同时接收流程任务。 + * + * @param task 流程任务。 + * @param flowTaskComment 流程审批批注对象。 + * @param taskVariableData 流程任务的变量数据。 + * @param datasource 主表所在数据源。 + * @param masterData 主表数据。 + * @param masterDataId 主表数据主键。 + * @param slaveDataListMap 从表数据。 + */ + void updateAndTakeTask( + Task task, + FlowTaskComment flowTaskComment, + JSONObject taskVariableData, + OnlineDatasource datasource, + JSONObject masterData, + String masterDataId, + Map> slaveDataListMap); + + /** + * 获取在线表单工作流Id所关联的权限数据,包括权限字列表和权限资源列表。 + * + * @param onlineFormEntryIds 在线表单工作流Id集合。 + * @return 参数中在线表单工作流Id集合所关联的权限数据。 + */ + List> calculatePermData(Set onlineFormEntryIds); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/service/impl/FlowOnlineBusinessServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/service/impl/FlowOnlineBusinessServiceImpl.java new file mode 100644 index 00000000..4dba8ac7 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/service/impl/FlowOnlineBusinessServiceImpl.java @@ -0,0 +1,97 @@ +package com.orangeforms.common.flow.online.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; +import com.orangeforms.common.core.annotation.MyDataSource; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.flow.base.service.BaseFlowOnlineService; +import com.orangeforms.common.flow.model.FlowWorkOrder; +import com.orangeforms.common.flow.util.FlowCustomExtFactory; +import com.orangeforms.common.online.exception.OnlineRuntimeException; +import com.orangeforms.common.online.model.OnlineColumn; +import com.orangeforms.common.online.model.OnlineDatasource; +import com.orangeforms.common.online.model.OnlineDatasourceRelation; +import com.orangeforms.common.online.model.OnlineTable; +import com.orangeforms.common.online.model.constant.FieldKind; +import com.orangeforms.common.online.service.OnlineDatasourceRelationService; +import com.orangeforms.common.online.service.OnlineDatasourceService; +import com.orangeforms.common.online.service.OnlineOperationService; +import com.orangeforms.common.online.service.OnlineTableService; +import jakarta.annotation.PostConstruct; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * 在线表单和流程监听器进行数据对接时的服务实现类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSource(ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("flowOnlineBusinessService") +public class FlowOnlineBusinessServiceImpl implements BaseFlowOnlineService { + + @Autowired + private FlowCustomExtFactory flowCustomExtFactory; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private OnlineDatasourceRelationService onlineDatasourceRelationService; + @Autowired + private OnlineOperationService onlineOperationService; + + @PostConstruct + public void doRegister() { + flowCustomExtFactory.getOnlineBusinessDataExtHelper().setOnlineBusinessService(this); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void updateFlowStatus(FlowWorkOrder workOrder) { + OnlineTable onlineTable = onlineTableService.getOnlineTableFromCache(workOrder.getOnlineTableId()); + if (onlineTable == null) { + log.error("OnlineTableId [{}] doesn't exist while calling FlowOnlineBusinessServiceImpl.updateFlowStatus", + workOrder.getOnlineTableId()); + return; + } + String dataId = workOrder.getBusinessKey(); + for (OnlineColumn column : onlineTable.getColumnMap().values()) { + if (ObjectUtil.equals(column.getFieldKind(), FieldKind.FLOW_FINISHED_STATUS)) { + onlineOperationService.updateColumn(onlineTable, dataId, column, workOrder.getFlowStatus()); + } + if (ObjectUtil.equals(column.getFieldKind(), FieldKind.FLOW_APPROVAL_STATUS)) { + onlineOperationService.updateColumn(onlineTable, dataId, column, workOrder.getLatestApprovalStatus()); + } + } + } + + @Override + public void deleteBusinessData(FlowWorkOrder workOrder) { + OnlineTable onlineTable = onlineTableService.getOnlineTableFromCache(workOrder.getOnlineTableId()); + if (onlineTable == null) { + log.error("OnlineTableId [{}] doesn't exist while calling FlowOnlineBusinessServiceImpl.deleteBusinessData", + workOrder.getOnlineTableId()); + return; + } + OnlineDatasource datasource = + onlineDatasourceService.getOnlineDatasourceByMasterTableId(onlineTable.getTableId()); + List relationList = + onlineDatasourceRelationService.getOnlineDatasourceRelationListFromCache(CollUtil.newHashSet(datasource.getDatasourceId())); + String dataId = workOrder.getBusinessKey(); + for (OnlineDatasourceRelation relation : relationList) { + OnlineTable slaveTable = onlineTableService.getOnlineTableFromCache(relation.getSlaveTableId()); + if (slaveTable == null) { + throw new OnlineRuntimeException("数据验证失败,数据源关联 [" + relation.getRelationName() + "] 的从表Id不存在!"); + } + relation.setSlaveTable(slaveTable); + } + onlineOperationService.delete(onlineTable, relationList, dataId); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/service/impl/FlowOnlineOperationServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/service/impl/FlowOnlineOperationServiceImpl.java new file mode 100644 index 00000000..514343ca --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow-online/src/main/java/com/orangeforms/common/flow/online/service/impl/FlowOnlineOperationServiceImpl.java @@ -0,0 +1,287 @@ +package com.orangeforms.common.flow.online.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.annotation.MultiDatabaseWriteMethod; +import com.orangeforms.common.core.annotation.MyDataSource; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.flow.config.FlowProperties; +import com.orangeforms.common.flow.constant.FlowApprovalType; +import com.orangeforms.common.flow.constant.FlowConstant; +import com.orangeforms.common.flow.constant.FlowTaskStatus; +import com.orangeforms.common.flow.exception.FlowOperationException; +import com.orangeforms.common.flow.model.FlowEntry; +import com.orangeforms.common.flow.model.FlowTaskComment; +import com.orangeforms.common.flow.model.FlowWorkOrder; +import com.orangeforms.common.flow.online.service.FlowOnlineOperationService; +import com.orangeforms.common.flow.service.FlowApiService; +import com.orangeforms.common.flow.service.FlowEntryService; +import com.orangeforms.common.flow.service.FlowWorkOrderService; +import com.orangeforms.common.online.config.OnlineProperties; +import com.orangeforms.common.online.model.OnlineDatasource; +import com.orangeforms.common.online.model.OnlineDatasourceRelation; +import com.orangeforms.common.online.model.OnlineTable; +import com.orangeforms.common.online.service.OnlineDatasourceService; +import com.orangeforms.common.online.service.OnlineOperationService; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.runtime.ProcessInstance; +import org.flowable.task.api.Task; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import java.util.stream.Collectors; + +@Slf4j +@MyDataSource(ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("flowOnlineOperationService") +public class FlowOnlineOperationServiceImpl implements FlowOnlineOperationService { + + @Autowired + private FlowApiService flowApiService; + @Autowired + private FlowWorkOrderService flowWorkOrderService; + @Autowired + private FlowEntryService flowEntryService; + @Autowired + private OnlineOperationService onlineOperationService; + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private OnlineProperties onlineProperties; + @Autowired + private FlowProperties flowProperties; + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNewAndStartProcess( + String processDefinitionId, + FlowTaskComment flowTaskComment, + JSONObject taskVariableData, + OnlineTable table, + JSONObject data) { + this.saveNewAndStartProcess(processDefinitionId, flowTaskComment, taskVariableData, table, data, null); + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNewAndStartProcess( + String processDefinitionId, + FlowTaskComment flowTaskComment, + JSONObject taskVariableData, + OnlineTable masterTable, + JSONObject masterData, + Map> slaveDataListMap) { + Object dataId = onlineOperationService.saveNewWithRelation(masterTable, masterData, slaveDataListMap); + Assert.notNull(dataId); + if (taskVariableData == null) { + taskVariableData = new JSONObject(); + } + taskVariableData.put(FlowConstant.MASTER_DATA_KEY, masterData); + taskVariableData.put(FlowConstant.SLAVE_DATA_KEY, this.normailizeSlaveDataListMap(slaveDataListMap)); + taskVariableData.put(FlowConstant.MASTER_TABLE_KEY, masterTable); + ProcessInstance instance = flowApiService.start(processDefinitionId, dataId); + flowWorkOrderService.saveNew(instance, dataId, masterTable.getTableId(), null); + flowApiService.takeFirstTask(instance.getProcessInstanceId(), flowTaskComment, taskVariableData); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public FlowWorkOrder saveNewDraftAndStartProcess( + String processDefinitionId, Long tableId, JSONObject masterData, JSONObject slaveData) { + ProcessInstance instance = flowApiService.start(processDefinitionId, null); + return flowWorkOrderService.saveNewWithDraft( + instance, tableId, null, JSON.toJSONString(masterData), JSON.toJSONString(slaveData)); + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNewAndTakeTask( + String processInstanceId, + String taskId, + FlowTaskComment flowTaskComment, + JSONObject taskVariableData, + OnlineTable table, + JSONObject data) { + this.saveNewAndTakeTask( + processInstanceId, taskId, flowTaskComment, taskVariableData, table, data, null); + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNewAndTakeTask( + String processInstanceId, + String taskId, + FlowTaskComment flowTaskComment, + JSONObject taskVariableData, + OnlineTable masterTable, + JSONObject masterData, + Map> slaveDataListMap) { + Object dataId = onlineOperationService.saveNewWithRelation(masterTable, masterData, slaveDataListMap); + Assert.notNull(dataId); + Task task = flowApiService.getProcessInstanceActiveTask(processInstanceId, taskId); + flowApiService.setBusinessKeyForProcessInstance(processInstanceId, dataId); + Map variables = + flowApiService.initAndGetProcessInstanceVariables(task.getProcessDefinitionId()); + if (taskVariableData == null) { + taskVariableData = new JSONObject(); + } + taskVariableData.putAll(variables); + taskVariableData.put(FlowConstant.MASTER_DATA_KEY, masterData); + taskVariableData.put(FlowConstant.SLAVE_DATA_KEY, this.normailizeSlaveDataListMap(slaveDataListMap)); + taskVariableData.put(FlowConstant.MASTER_TABLE_KEY, masterTable); + flowApiService.completeTask(task, flowTaskComment, taskVariableData); + ProcessInstance instance = flowApiService.getProcessInstance(processInstanceId); + FlowWorkOrder flowWorkOrder = + flowWorkOrderService.getFlowWorkOrderByProcessInstanceId(instance.getProcessInstanceId()); + if (flowWorkOrder == null) { + flowWorkOrderService.saveNew(instance, dataId, masterTable.getTableId(), null); + } else { + flowWorkOrder.setBusinessKey(dataId.toString()); + flowWorkOrder.setUpdateTime(new Date()); + flowWorkOrder.setFlowStatus(FlowTaskStatus.SUBMITTED); + flowWorkOrderService.updateById(flowWorkOrder); + } + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public void updateAndTakeTask( + Task task, + FlowTaskComment flowTaskComment, + JSONObject taskVariableData, + OnlineDatasource datasource, + JSONObject masterData, + String masterDataId, + Map> slaveDataListMap) { + int flowStatus = FlowTaskStatus.APPROVING; + if (flowTaskComment.getApprovalType().equals(FlowApprovalType.REFUSE)) { + flowStatus = FlowTaskStatus.REFUSED; + } else if (flowTaskComment.getApprovalType().equals(FlowApprovalType.STOP)) { + flowStatus = FlowTaskStatus.FINISHED; + } + OnlineTable masterTable = datasource.getMasterTable(); + Long datasourceId = datasource.getDatasourceId(); + flowWorkOrderService.updateFlowStatusByProcessInstanceId(task.getProcessInstanceId(), flowStatus); + this.updateMasterData(masterTable, masterData, masterDataId); + if (slaveDataListMap != null) { + for (Map.Entry> relationEntry : slaveDataListMap.entrySet()) { + Long relationId = relationEntry.getKey().getRelationId(); + onlineOperationService.updateRelationData( + masterTable, masterData, masterDataId, datasourceId, relationId, relationEntry.getValue()); + } + } + if (flowTaskComment.getApprovalType().equals(FlowApprovalType.STOP)) { + Integer s = MapUtil.getInt(taskVariableData, FlowConstant.LATEST_APPROVAL_STATUS_KEY); + flowWorkOrderService.updateLatestApprovalStatusByProcessInstanceId(task.getProcessInstanceId(), s); + CallResult stopResult = flowApiService.stopProcessInstance( + task.getProcessInstanceId(), flowTaskComment.getTaskComment(), flowStatus); + if (!stopResult.isSuccess()) { + throw new FlowOperationException(stopResult.getErrorMessage()); + } + } else { + if (taskVariableData == null) { + taskVariableData = new JSONObject(); + } + taskVariableData.put(FlowConstant.MASTER_DATA_KEY, masterData); + taskVariableData.put(FlowConstant.SLAVE_DATA_KEY, this.normailizeSlaveDataListMap(slaveDataListMap)); + taskVariableData.put(FlowConstant.MASTER_TABLE_KEY, masterTable); + flowApiService.completeTask(task, flowTaskComment, taskVariableData); + } + } + + @Override + public List> calculatePermData(Set onlineFormEntryIds) { + if (CollUtil.isEmpty(onlineFormEntryIds)) { + return new LinkedList<>(); + } + List> permDataList = new LinkedList<>(); + List flowEntries = flowEntryService.getInList(onlineFormEntryIds); + Set pageIds = flowEntries.stream().map(FlowEntry::getPageId).collect(Collectors.toSet()); + Map pageAndVariableNameMap = + onlineDatasourceService.getPageIdAndVariableNameMapByPageIds(pageIds); + for (FlowEntry flowEntry : flowEntries) { + JSONObject permData = new JSONObject(); + permData.put("entryId", flowEntry.getEntryId()); + String key = StrUtil.upperFirst(flowEntry.getProcessDefinitionKey()); + List permCodeList = new LinkedList<>(); + String formPermCode = "form" + key; + permCodeList.add(formPermCode); + permCodeList.add(formPermCode + ":fragment" + key); + permData.put("permCodeList", permCodeList); + String flowUrlPrefix = flowProperties.getUrlPrefix(); + String onlineUrlPrefix = onlineProperties.getUrlPrefix(); + List permList = CollUtil.newLinkedList( + onlineUrlPrefix + "/onlineForm/view", + onlineUrlPrefix + "/onlineForm/render", + onlineUrlPrefix + "/onlineOperation/listByOneToManyRelationId/" + pageAndVariableNameMap.get(flowEntry.getPageId()), + onlineUrlPrefix + "/onlineOperation/uploadByOneToManyRelationId/" + pageAndVariableNameMap.get(flowEntry.getPageId()), + onlineUrlPrefix + "/onlineOperation/dowloadByOneToManyRelationId/" + pageAndVariableNameMap.get(flowEntry.getPageId()), + flowUrlPrefix + "/flowOperation/viewInitialHistoricTaskInfo", + flowUrlPrefix + "/flowOperation/startOnly", + flowUrlPrefix + "/flowOperation/viewInitialTaskInfo", + flowUrlPrefix + "/flowOperation/viewRuntimeTaskInfo", + flowUrlPrefix + "/flowOperation/viewProcessBpmn", + flowUrlPrefix + "/flowOperation/viewHighlightFlowData", + flowUrlPrefix + "/flowOperation/listFlowTaskComment", + flowUrlPrefix + "/flowOperation/cancelWorkOrder", + flowUrlPrefix + "/flowOperation/listRuntimeTask", + flowUrlPrefix + "/flowOperation/listHistoricProcessInstance", + flowUrlPrefix + "/flowOperation/listHistoricTask", + flowUrlPrefix + "/flowOperation/freeJumpTo", + flowUrlPrefix + "/flowOnlineOperation/startPreview", + flowUrlPrefix + "/flowOnlineOperation/viewUserTask", + flowUrlPrefix + "/flowOnlineOperation/viewHistoricProcessInstance", + flowUrlPrefix + "/flowOnlineOperation/submitUserTask", + flowUrlPrefix + "/flowOnlineOperation/upload", + flowUrlPrefix + "/flowOnlineOperation/download", + flowUrlPrefix + "/flowOperation/submitConsign", + flowUrlPrefix + "/flowOnlineOperation/startAndTakeUserTask/" + flowEntry.getProcessDefinitionKey(), + flowUrlPrefix + "/flowOnlineOperation/startAndSaveDraft/" + flowEntry.getProcessDefinitionKey(), + flowUrlPrefix + "/flowOnlineOperation/listWorkOrder/" + flowEntry.getProcessDefinitionKey(), + flowUrlPrefix + "/flowOnlineOperation/printWorkOrder/" + flowEntry.getProcessDefinitionKey() + ); + permData.put("permList", permList); + permDataList.add(permData); + } + return permDataList; + } + + private void updateMasterData(OnlineTable masterTable, JSONObject masterData, String dataId) { + if (masterData == null) { + return; + } + // 如果存在主表数据,就执行主表数据的更新。 + Map originalMasterData = + onlineOperationService.getMasterData(masterTable, null, null, dataId); + for (Map.Entry entry : originalMasterData.entrySet()) { + masterData.putIfAbsent(entry.getKey(), entry.getValue()); + } + if (!onlineOperationService.update(masterTable, masterData)) { + throw new FlowOperationException("主表数据不存在!"); + } + } + + private Map> normailizeSlaveDataListMap( + Map> slaveDataListMap) { + if (slaveDataListMap == null || slaveDataListMap.isEmpty()) { + return null; + } + Map> resultMap = new HashMap<>(slaveDataListMap.size()); + for (Map.Entry> entry : slaveDataListMap.entrySet()) { + resultMap.put(entry.getKey().getSlaveTable().getTableName(), entry.getValue()); + } + return resultMap; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow-online/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/OrangeFormsOpen-MybatisPlus/common/common-flow-online/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..8ec96e36 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow-online/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.orangeforms.common.flow.online.config.FlowOnlineAutoConfig \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/pom.xml b/OrangeFormsOpen-MybatisPlus/common/common-flow/pom.xml new file mode 100644 index 00000000..daad1d91 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/pom.xml @@ -0,0 +1,49 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-flow + 1.0.0 + common-flow + jar + + + + com.orangeforms + common-satoken + 1.0.0 + + + com.orangeforms + common-datafilter + 1.0.0 + + + com.orangeforms + common-sequence + 1.0.0 + + + com.orangeforms + common-log + 1.0.0 + + + com.orangeforms + common-swagger + 1.0.0 + + + org.flowable + flowable-spring-boot-starter-process + ${flowable.version} + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/advice/FlowExceptionHandler.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/advice/FlowExceptionHandler.java new file mode 100644 index 00000000..b7ee7293 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/advice/FlowExceptionHandler.java @@ -0,0 +1,58 @@ +package com.orangeforms.common.flow.advice; + +import com.alibaba.fastjson.JSON; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.ResponseResult; +import com.orangeforms.common.core.util.ContextUtil; +import com.orangeforms.common.flow.exception.FlowEmptyUserException; +import com.orangeforms.common.flow.model.FlowTaskComment; +import com.orangeforms.common.flow.service.FlowTaskCommentService; +import lombok.extern.slf4j.Slf4j; +import org.flowable.common.engine.api.FlowableException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.annotation.Order; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +/** + * 流程业务层的异常处理类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Order(1) +@RestControllerAdvice("com.orangeforms") +public class FlowExceptionHandler { + + @Autowired + private FlowTaskCommentService flowTaskCommentService; + + @ExceptionHandler(value = FlowableException.class) + public ResponseResult exceptionHandle(FlowableException ex, HttpServletRequest request) { + if (ex instanceof FlowEmptyUserException) { + FlowEmptyUserException flowEmptyUserException = (FlowEmptyUserException) ex; + FlowTaskComment comment = JSON.parseObject(flowEmptyUserException.getMessage(), FlowTaskComment.class); + flowTaskCommentService.saveNew(comment); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, "下一个任务节点的审批人为空,提交被自动驳回!"); + } + log.error("Unhandled FlowException from URL [" + request.getRequestURI() + "]", ex); + ContextUtil.getHttpResponse().setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + return ResponseResult.error(ErrorCodeEnum.UNHANDLED_EXCEPTION, ex.getMessage()); + } + + @SuppressWarnings("unchecked") + private T findCause(Throwable ex, Class clazz) { + if (ex.getCause() == null) { + return null; + } + if (ex.getCause().getClass().equals(clazz)) { + return (T) ex.getCause(); + } else { + return this.findCause(ex.getCause(), clazz); + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/base/service/BaseFlowOnlineService.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/base/service/BaseFlowOnlineService.java new file mode 100644 index 00000000..c22362f9 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/base/service/BaseFlowOnlineService.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.flow.base.service; + +import com.orangeforms.common.flow.model.FlowWorkOrder; + +/** + * 工作流在线表单的服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface BaseFlowOnlineService { + + /** + * 更新在线表单主表数据的流程状态字段值。 + * + * @param workOrder 工单对象。 + */ + void updateFlowStatus(FlowWorkOrder workOrder); + + /** + * 根据工单对象级联删除业务数据。 + * + * @param workOrder 工单对象。 + */ + void deleteBusinessData(FlowWorkOrder workOrder); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/config/CustomEngineConfigurator.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/config/CustomEngineConfigurator.java new file mode 100644 index 00000000..bf9709a6 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/config/CustomEngineConfigurator.java @@ -0,0 +1,48 @@ +package com.orangeforms.common.flow.config; + +import com.orangeforms.common.core.config.DynamicDataSource; +import com.orangeforms.common.core.constant.ApplicationConstant; +import lombok.extern.slf4j.Slf4j; +import org.flowable.common.engine.impl.AbstractEngineConfiguration; +import org.flowable.common.engine.impl.EngineConfigurator; +import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; + +import javax.sql.DataSource; +import java.util.Map; + +/** + * 服务启动过程中动态切换flowable引擎内置表所在的数据源。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class CustomEngineConfigurator implements EngineConfigurator { + + @Override + public void beforeInit(AbstractEngineConfiguration engineConfiguration) { + DataSource dataSource = engineConfiguration.getDataSource(); + if (dataSource instanceof TransactionAwareDataSourceProxy) { + TransactionAwareDataSourceProxy proxy = (TransactionAwareDataSourceProxy) dataSource; + DataSource targetDataSource = proxy.getTargetDataSource(); + if (targetDataSource instanceof DynamicDataSource) { + DynamicDataSource dynamicDataSource = (DynamicDataSource) targetDataSource; + Map dynamicDataSourceMap = dynamicDataSource.getResolvedDataSources(); + DataSource flowDataSource = dynamicDataSourceMap.get(ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE); + if (flowDataSource != null) { + engineConfiguration.setDataSource(flowDataSource); + } + } + } + } + + @Override + public void configure(AbstractEngineConfiguration engineConfiguration) { + // 默认实现。 + } + + @Override + public int getPriority() { + return 0; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/config/FlowAutoConfig.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/config/FlowAutoConfig.java new file mode 100644 index 00000000..a6c7345a --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/config/FlowAutoConfig.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.flow.config; + +import org.springframework.boot.context.properties.EnableConfigurationProperties; + +/** + * common-flow模块的自动配置引导类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EnableConfigurationProperties({FlowProperties.class}) +public class FlowAutoConfig { +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/config/FlowProperties.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/config/FlowProperties.java new file mode 100644 index 00000000..3acf5347 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/config/FlowProperties.java @@ -0,0 +1,20 @@ +package com.orangeforms.common.flow.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * 工作流的配置对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ConfigurationProperties(prefix = "common-flow") +public class FlowProperties { + + /** + * 工作落工单操作接口的URL前缀。 + */ + private String urlPrefix; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowApprovalType.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowApprovalType.java new file mode 100644 index 00000000..aa4de82c --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowApprovalType.java @@ -0,0 +1,97 @@ +package com.orangeforms.common.flow.constant; + +/** + * 工作流任务触发BUTTON。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FlowApprovalType { + + /** + * 保存。 + */ + public static final String SAVE = "save"; + /** + * 同意。 + */ + public static final String AGREE = "agree"; + /** + * 拒绝。 + */ + public static final String REFUSE = "refuse"; + /** + * 驳回。 + */ + public static final String REJECT = "reject"; + /** + * 撤销。 + */ + public static final String REVOKE = "revoke"; + /** + * 指派。 + */ + public static final String TRANSFER = "transfer"; + /** + * 多实例会签。 + */ + public static final String MULTI_SIGN = "multi_sign"; + /** + * 会签同意。 + */ + public static final String MULTI_AGREE = "multi_agree"; + /** + * 会签拒绝。 + */ + public static final String MULTI_REFUSE = "multi_refuse"; + /** + * 会签弃权。 + */ + public static final String MULTI_ABSTAIN = "multi_abstain"; + /** + * 多实例加签。 + */ + public static final String MULTI_CONSIGN = "multi_consign"; + /** + * 多实例减签。 + */ + public static final String MULTI_MINUS_SIGN = "multi_minus_sign"; + /** + * 中止。 + */ + public static final String STOP = "stop"; + /** + * 干预。 + */ + public static final String INTERVENE = "intervene"; + /** + * 自由跳转。 + */ + public static final String FREE_JUMP = "free_jump"; + /** + * 流程复活。 + */ + public static final String REUSED = "reused"; + /** + * 流程复活。 + */ + public static final String REVIVE = "revive"; + /** + * 超时自动审批。 + */ + public static final String TIMEOUT_AUTO_COMPLETE = "timeout_auto_complete"; + /** + * 空审批人自动审批。 + */ + public static final String EMPTY_USER_AUTO_COMPLETE = "empty_user_auto_complete"; + /** + * 空审批人自动退回。 + */ + public static final String EMPTY_USER_AUTO_REJECT = "empty_user_auto_reject"; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowApprovalType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowBackType.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowBackType.java new file mode 100644 index 00000000..495831b8 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowBackType.java @@ -0,0 +1,25 @@ +package com.orangeforms.common.flow.constant; + +/** + * 待办任务回退类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FlowBackType { + + /** + * 驳回。 + */ + public static final int REJECT = 0; + /** + * 撤回。 + */ + public static final int REVOKE = 1; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowBackType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowBuiltinApprovalStatus.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowBuiltinApprovalStatus.java new file mode 100644 index 00000000..cdb89485 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowBuiltinApprovalStatus.java @@ -0,0 +1,33 @@ +package com.orangeforms.common.flow.constant; + +/** + * 内置的流程审批状态。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class FlowBuiltinApprovalStatus { + + /** + * 同意。 + */ + public static final int AGREED = 1; + /** + * 拒绝。 + */ + public static final int REFUSED = 2; + /** + * 会签同意。 + */ + public static final int MULTI_AGREED = 3; + /** + * 会签拒绝。 + */ + public static final int MULTI_REFUSED = 4; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowBuiltinApprovalStatus() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowConstant.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowConstant.java new file mode 100644 index 00000000..12ccf122 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowConstant.java @@ -0,0 +1,266 @@ +package com.orangeforms.common.flow.constant; + +/** + * 工作流中的常量数据。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class FlowConstant { + + /** + * 标识流程实例启动用户的变量名。 + */ + public static final String START_USER_NAME_VAR = "${startUserName}"; + + /** + * 流程实例发起人变量名。 + */ + public static final String PROC_INSTANCE_INITIATOR_VAR = "initiator"; + + /** + * 流程实例中发起人用户的变量名。 + */ + public static final String PROC_INSTANCE_START_USER_NAME_VAR = "startUserName"; + + /** + * 流程任务的指定人变量。 + */ + public static final String TASK_APPOINTED_ASSIGNEE_VAR = "appointedAssignee"; + + /** + * 操作类型变量。 + */ + public static final String OPERATION_TYPE_VAR = "operationType"; + + /** + * 提交用户。 + */ + public static final String SUBMIT_USER_VAR = "submitUser"; + + /** + * 多任务拒绝数量变量。 + */ + public static final String MULTI_REFUSE_COUNT_VAR = "multiRefuseCount"; + + /** + * 多任务同意数量变量。 + */ + public static final String MULTI_AGREE_COUNT_VAR = "multiAgreeCount"; + + /** + * 多任务弃权数量变量。 + */ + public static final String MULTI_ABSTAIN_COUNT_VAR = "multiAbstainCount"; + + /** + * 会签发起任务。 + */ + public static final String MULTI_SIGN_START_TASK_VAR = "multiSignStartTask"; + + /** + * 会签任务总数量。 + */ + public static final String MULTI_SIGN_NUM_OF_INSTANCES_VAR = "multiNumOfInstances"; + + /** + * 会签任务执行的批次Id。 + */ + public static final String MULTI_SIGN_TASK_EXECUTION_ID_VAR = "taskExecutionId"; + + /** + * 多实例实例数量变量。 + */ + public static final String NUMBER_OF_INSTANCES_VAR = "nrOfInstances"; + + /** + * 多实例已完成实例数量变量。 + */ + public static final String NUMBER_OF_COMPLETED_INSTANCES_VAR = "nrOfCompletedInstances"; + + /** + * 多任务指派人列表变量。 + */ + public static final String MULTI_ASSIGNEE_LIST_VAR = "assigneeList"; + + /** + * 上级部门领导审批变量。 + */ + public static final String GROUP_TYPE_UP_DEPT_POST_LEADER_VAR = "upDeptPostLeader"; + + /** + * 本部门领导审批变量。 + */ + public static final String GROUP_TYPE_DEPT_POST_LEADER_VAR = "deptPostLeader"; + + /** + * 所有部门岗位审批变量。 + */ + public static final String GROUP_TYPE_ALL_DEPT_POST_VAR = "allDeptPost"; + + /** + * 本部门岗位审批变量。 + */ + public static final String GROUP_TYPE_SELF_DEPT_POST_VAR = "selfDeptPost"; + + /** + * 同级部门岗位审批变量。 + */ + public static final String GROUP_TYPE_SIBLING_DEPT_POST_VAR = "siblingDeptPost"; + + /** + * 上级部门岗位审批变量。 + */ + public static final String GROUP_TYPE_UP_DEPT_POST_VAR = "upDeptPost"; + + /** + * 任意部门关联的岗位审批变量。 + */ + public static final String GROUP_TYPE_DEPT_POST_VAR = "deptPost"; + + /** + * 指定角色分组变量。 + */ + public static final String GROUP_TYPE_ROLE_VAR = "role"; + + /** + * 指定部门分组变量。 + */ + public static final String GROUP_TYPE_DEPT_VAR = "dept"; + + /** + * 指定用户分组变量。 + */ + public static final String GROUP_TYPE_USER_VAR = "user"; + + /** + * 指定审批人。 + */ + public static final String GROUP_TYPE_ASSIGNEE = "ASSIGNEE"; + + /** + * 岗位。 + */ + public static final String GROUP_TYPE_POST = "POST"; + + /** + * 上级部门领导审批。 + */ + public static final String GROUP_TYPE_UP_DEPT_POST_LEADER = "UP_DEPT_POST_LEADER"; + + /** + * 本部门岗位领导审批。 + */ + public static final String GROUP_TYPE_DEPT_POST_LEADER = "DEPT_POST_LEADER"; + + /** + * 本部门岗位前缀。 + */ + public static final String SELF_DEPT_POST_PREFIX = "SELF_DEPT_"; + + /** + * 上级部门岗位前缀。 + */ + public static final String UP_DEPT_POST_PREFIX = "UP_DEPT_"; + + /** + * 同级部门岗位前缀。 + */ + public static final String SIBLING_DEPT_POST_PREFIX = "SIBLING_DEPT_"; + + /** + * 当前流程实例所有任务的抄送数据前缀。 + */ + public static final String COPY_DATA_MAP_PREFIX = "copyDataMap_"; + + /** + * 作为临时变量存入任务变量JSONObject对象时的key。 + */ + public static final String COPY_DATA_KEY = "copyDataKey"; + + /** + * 流程中业务快照数据中,主表数据的Key。 + */ + public static final String MASTER_DATA_KEY = "masterData"; + + /** + * 流程中业务快照数据中,关联从表数据的Key。 + */ + public static final String SLAVE_DATA_KEY = "slaveData"; + + /** + * 流程任务的最近更新状态的Key。 + */ + public static final String LATEST_APPROVAL_STATUS_KEY = "latestApprovalStatus"; + + /** + * 流程用户任务待办之前的通知类型的Key。 + */ + public static final String USER_TASK_NOTIFY_TYPES_KEY = "flowNotifyTypeList"; + + /** + * 流程用户任务自动跳过类型的Key。 + */ + public static final String USER_TASK_AUTO_SKIP_KEY = "autoSkipType"; + + /** + * 流程用户任务驳回类型的Key。 + */ + public static final String USER_TASK_REJECT_TYPE_KEY = "rejectType"; + + /** + * 驳回时携带的变量数据。 + */ + public static final String REJECT_TO_SOURCE_DATA_VAR = "rejectData"; + + /** + * 驳回时携带的变量数据。 + */ + public static final String REJECT_BACK_TO_SOURCE_DATA_VAR = "rejectBackData"; + + /** + * 指定审批人。 + */ + public static final String DELEGATE_ASSIGNEE_VAR = "defaultAssignee"; + + /** + * 业务主表对象的键。目前仅仅用户在线表单工作流。 + */ + public static final String MASTER_TABLE_KEY = "masterTable"; + + /** + * 不删除任务超时作业。 + */ + public static final String NOT_DELETE_TIMEOUT_TASK_JOB_KEY = "notDeleteTimeoutTaskJob"; + + /** + * 用户任务超时小时数。 + */ + public static final String TASK_TIMEOUT_HOURS = "timeoutHours"; + + /** + * 用户任务超时处理方式。 + */ + public static final String TASK_TIMEOUT_HANDLE_WAY = "timeoutHandleWay"; + + /** + * 用户任务超时指定审批人。 + */ + public static final String TASK_TIMEOUT_DEFAULT_ASSIGNEE = "defaultAssignee"; + + /** + * 空处理人处理方式。 + */ + public static final String EMPTY_USER_HANDLE_WAY = "emptyUserHandleWay"; + + /** + * 空处理人时指定的审批人。 + */ + public static final String EMPTY_USER_TO_ASSIGNEE = "emptyUserToAssignee"; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowConstant() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowTaskStatus.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowTaskStatus.java new file mode 100644 index 00000000..d25ec6e4 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowTaskStatus.java @@ -0,0 +1,49 @@ +package com.orangeforms.common.flow.constant; + +/** + * 工作流任务类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FlowTaskStatus { + + /** + * 已提交。 + */ + public static final int SUBMITTED = 0; + /** + * 审批中。 + */ + public static final int APPROVING = 1; + /** + * 被拒绝。 + */ + public static final int REFUSED = 2; + /** + * 已结束。 + */ + public static final int FINISHED = 3; + /** + * 提前停止。 + */ + public static final Integer STOPPED = 4; + /** + * 已取消。 + */ + public static final Integer CANCELLED = 5; + /** + * 保存草稿。 + */ + public static final Integer DRAFT = 6; + /** + * 流程复活。 + */ + public static final Integer REVIVE = 7; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowTaskStatus() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowTaskType.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowTaskType.java new file mode 100644 index 00000000..8d97ba9b --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/constant/FlowTaskType.java @@ -0,0 +1,25 @@ +package com.orangeforms.common.flow.constant; + +/** + * 工作流任务类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FlowTaskType { + + /** + * 其他类型任务。 + */ + public static final int OTHER_TYPE = 0; + /** + * 用户任务。 + */ + public static final int USER_TYPE = 1; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowTaskType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowCategoryController.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowCategoryController.java new file mode 100644 index 00000000..95558d08 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowCategoryController.java @@ -0,0 +1,232 @@ +package com.orangeforms.common.flow.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.flow.dto.*; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.flow.model.constant.FlowEntryStatus; +import com.orangeforms.common.flow.service.*; +import com.orangeforms.common.flow.vo.*; +import lombok.extern.slf4j.Slf4j; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +/** + * 工作流流程分类接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "工作流流程分类接口") +@Slf4j +@RestController +@RequestMapping("${common-flow.urlPrefix}/flowCategory") +@ConditionalOnProperty(name = "common-flow.operationEnabled", havingValue = "true") +public class FlowCategoryController { + + @Autowired + private FlowCategoryService flowCategoryService; + @Autowired + private FlowEntryService flowEntryService; + + /** + * 新增FlowCategory数据。 + * + * @param flowCategoryDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"flowCategoryDto.categoryId"}) + @SaCheckPermission("flowCategory.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody FlowCategoryDto flowCategoryDto) { + String errorMessage = MyCommonUtil.getModelValidationError(flowCategoryDto); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + FlowCategory flowCategory = MyModelUtil.copyTo(flowCategoryDto, FlowCategory.class); + if (flowCategoryService.existByCode(flowCategory.getCode())) { + return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, "数据验证失败,当前流程分类已经存在!"); + } + flowCategory = flowCategoryService.saveNew(flowCategory); + return ResponseResult.success(flowCategory.getCategoryId()); + } + + /** + * 更新FlowCategory数据。 + * + * @param flowCategoryDto 更新对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("flowCategory.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody FlowCategoryDto flowCategoryDto) { + String errorMessage = MyCommonUtil.getModelValidationError(flowCategoryDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + FlowCategory flowCategory = MyModelUtil.copyTo(flowCategoryDto, FlowCategory.class); + ResponseResult verifyResult = this.doVerifyAndGet(flowCategory.getCategoryId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + FlowCategory originalFlowCategory = verifyResult.getData(); + if (!StrUtil.equals(flowCategory.getCode(), originalFlowCategory.getCode())) { + FlowEntry filter = new FlowEntry(); + filter.setCategoryId(flowCategory.getCategoryId()); + filter.setStatus(FlowEntryStatus.PUBLISHED); + List flowEntryList = flowEntryService.getListByFilter(filter); + if (CollUtil.isNotEmpty(flowEntryList)) { + errorMessage = "数据验证失败,当前流程分类存在已经发布的流程数据,因此分类标识不能修改!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (flowCategoryService.existByCode(flowCategory.getCode())) { + errorMessage = "数据验证失败,当前流程分类已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage); + } + } + if (!flowCategoryService.update(flowCategory, originalFlowCategory)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 删除FlowCategory数据。 + * + * @param categoryId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("flowCategory.all") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long categoryId) { + String errorMessage; + ResponseResult verifyResult = this.doVerifyAndGet(categoryId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + FlowEntry filter = new FlowEntry(); + filter.setCategoryId(categoryId); + List flowEntryList = flowEntryService.getListByFilter(filter); + if (CollUtil.isNotEmpty(flowEntryList)) { + errorMessage = "数据验证失败,请先删除当前流程分类关联的流程数据!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!flowCategoryService.remove(categoryId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的FlowCategory列表。 + * + * @param flowCategoryDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("flowCategory.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody FlowCategoryDto flowCategoryDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + FlowCategory flowCategoryFilter = MyModelUtil.copyTo(flowCategoryDtoFilter, FlowCategory.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, FlowCategory.class); + List flowCategoryList = flowCategoryService.getFlowCategoryListWithRelation(flowCategoryFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(flowCategoryList, FlowCategoryVo.class)); + } + + /** + * 查看指定FlowCategory对象详情。 + * + * @param categoryId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("flowCategory.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long categoryId) { + ResponseResult verifyResult = this.doVerifyAndGet(categoryId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + return ResponseResult.success(verifyResult.getData(), FlowCategoryVo.class); + } + + /** + * 以字典形式返回全部FlowCategory数据集合。字典的键值为[categoryId, name]。 + * 白名单接口,登录用户均可访问。 + * + * @param filter 过滤对象。 + * @return 应答结果对象,包含的数据为 List>,map中包含两条记录,key的值分别是id和name,value对应具体数据。 + */ + @GetMapping("/listDict") + public ResponseResult>> listDict(@ParameterObject FlowCategoryDto filter) { + List resultList = + flowCategoryService.getFlowCategoryList(MyModelUtil.copyTo(filter, FlowCategory.class), null); + return ResponseResult.success( + MyCommonUtil.toDictDataList(resultList, FlowCategory::getCategoryId, FlowCategory::getName)); + } + + /** + * 根据字典Id集合,获取查询后的字典数据。 + * + * @param dictIds 字典Id集合。 + * @return 应答结果对象,包含字典形式的数据集合。 + */ + @GetMapping("/listDictByIds") + public ResponseResult>> listDictByIds(@RequestParam List dictIds) { + List resultList = flowCategoryService.getInList(new HashSet<>(dictIds)); + return ResponseResult.success( + MyCommonUtil.toDictDataList(resultList, FlowCategory::getCategoryId, FlowCategory::getName)); + } + + private ResponseResult doVerifyAndGet(Long categoryId) { + String errorMessage; + if (MyCommonUtil.existBlankArgument(categoryId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + FlowCategory flowCategory = flowCategoryService.getById(categoryId); + if (flowCategory == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + TokenData tokenData = TokenData.takeFromRequest(); + if (!StrUtil.equals(flowCategory.getAppCode(), tokenData.getAppCode())) { + errorMessage = "数据验证失败,当前应用并不存在该流程分类的定义!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (ObjectUtil.notEqual(flowCategory.getTenantId(), tokenData.getTenantId())) { + errorMessage = "数据验证失败,当前租户并不存在该流程分类的定义!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(flowCategory); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowEntryController.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowEntryController.java new file mode 100644 index 00000000..855e59de --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowEntryController.java @@ -0,0 +1,475 @@ +package com.orangeforms.common.flow.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.flow.constant.FlowTaskType; +import com.orangeforms.common.flow.dto.*; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.flow.model.constant.FlowEntryStatus; +import com.orangeforms.common.flow.service.*; +import com.orangeforms.common.flow.vo.*; +import lombok.extern.slf4j.Slf4j; +import org.flowable.bpmn.model.*; +import org.flowable.bpmn.model.Process; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import javax.xml.stream.XMLStreamException; +import java.util.*; + +/** + * 工作流流程定义接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "工作流流程定义接口") +@Slf4j +@RestController +@RequestMapping("${common-flow.urlPrefix}/flowEntry") +@ConditionalOnProperty(name = "common-flow.operationEnabled", havingValue = "true") +public class FlowEntryController { + + @Autowired + private FlowEntryService flowEntryService; + @Autowired + private FlowCategoryService flowCategoryService; + @Autowired + private FlowEntryVariableService flowEntryVariableService; + @Autowired + private FlowApiService flowApiService; + @Autowired + private FlowTaskExtService flowTaskExtService; + + /** + * 新增工作流对象数据。 + * + * @param flowEntryDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"flowEntryDto.entryId"}) + @SaCheckPermission("flowEntry.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody FlowEntryDto flowEntryDto) { + String errorMessage = MyCommonUtil.getModelValidationError(flowEntryDto); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + FlowEntry flowEntry = MyModelUtil.copyTo(flowEntryDto, FlowEntry.class); + if (flowEntryService.existByProcessDefinitionKey(flowEntry.getProcessDefinitionKey())) { + errorMessage = "数据验证失败,该流程定义标识已存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + // 验证关联Id的数据合法性 + CallResult callResult = flowEntryService.verifyRelatedData(flowEntry, null); + if (!callResult.isSuccess()) { + errorMessage = callResult.getErrorMessage(); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + flowEntry = flowEntryService.saveNew(flowEntry); + return ResponseResult.success(flowEntry.getEntryId()); + } + + /** + * 更新工作流对象数据。 + * + * @param flowEntryDto 更新对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("flowEntry.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody FlowEntryDto flowEntryDto) { + String errorMessage = MyCommonUtil.getModelValidationError(flowEntryDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + FlowEntry flowEntry = MyModelUtil.copyTo(flowEntryDto, FlowEntry.class); + ResponseResult verifyResult = this.doVerifyAndGet(flowEntry.getEntryId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + FlowEntry originalFlowEntry = verifyResult.getData(); + if (ObjectUtil.notEqual(flowEntry.getProcessDefinitionKey(), originalFlowEntry.getProcessDefinitionKey())) { + if (originalFlowEntry.getStatus().equals(FlowEntryStatus.PUBLISHED)) { + errorMessage = "数据验证失败,当前流程为发布状态,流程标识不能修改!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (flowEntryService.existByProcessDefinitionKey(flowEntry.getProcessDefinitionKey())) { + errorMessage = "数据验证失败,该流程定义标识已存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + // 验证关联Id的数据合法性 + CallResult callResult = flowEntryService.verifyRelatedData(flowEntry, originalFlowEntry); + if (!callResult.isSuccess()) { + errorMessage = callResult.getErrorMessage(); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!flowEntryService.update(flowEntry, originalFlowEntry)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 删除工作流对象数据。 + * + * @param entryId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("flowEntry.all") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long entryId) { + String errorMessage; + if (MyCommonUtil.existBlankArgument(entryId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + ResponseResult verifyResult = this.doVerifyAndGet(entryId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + FlowEntry originalFlowEntry = verifyResult.getData(); + if (originalFlowEntry.getStatus().equals(FlowEntryStatus.PUBLISHED)) { + errorMessage = "数据验证失败,当前流程为发布状态,不能删除!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!flowEntryService.remove(entryId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 发布工作流。 + * + * @param entryId 流程主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("flowEntry.all") + @OperationLog(type = SysOperationLogType.PUBLISH) + @PostMapping("/publish") + public ResponseResult publish(@MyRequestBody(required = true) Long entryId) throws XMLStreamException { + String errorMessage; + ResponseResult verifyResult = this.doVerifyAndGet(entryId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + FlowEntry flowEntry = verifyResult.getData(); + if (StrUtil.isBlank(flowEntry.getBpmnXml())) { + errorMessage = "数据验证失败,该流程没有流程图不能被发布!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + ResponseResult taskInfoResult = this.verifyAndGetInitialTaskInfo(flowEntry); + if (!taskInfoResult.isSuccess()) { + return ResponseResult.errorFrom(taskInfoResult); + } + String taskInfo = taskInfoResult.getData() == null ? null : JSON.toJSONString(taskInfoResult.getData()); + flowEntryService.publish(flowEntry, taskInfo); + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的工作流列表。 + * + * @param flowEntryDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("flowEntry.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody FlowEntryDto flowEntryDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + FlowEntry flowEntryFilter = MyModelUtil.copyTo(flowEntryDtoFilter, FlowEntry.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, FlowEntry.class); + List flowEntryList = flowEntryService.getFlowEntryListWithRelation(flowEntryFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(flowEntryList, FlowEntryVo.class)); + } + + /** + * 查看指定工作流对象详情。 + * + * @param entryId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("flowEntry.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long entryId) { + ResponseResult verifyResult = this.doVerifyAndGet(entryId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + FlowEntry flowEntry = flowEntryService.getByIdWithRelation(entryId, MyRelationParam.full()); + if (flowEntry == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(flowEntry, FlowEntryVo.class); + } + + /** + * 列出指定流程的发布版本列表。 + * + * @param entryId 流程主键Id。 + * @return 应答结果对象,包含流程发布列表数据。 + */ + @SaCheckPermission("flowEntry.all") + @GetMapping("/listFlowEntryPublish") + public ResponseResult> listFlowEntryPublish(@RequestParam Long entryId) { + ResponseResult verifyResult = this.doVerifyAndGet(entryId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + List flowEntryPublishList = flowEntryService.getFlowEntryPublishList(entryId); + return ResponseResult.success(MyModelUtil.copyCollectionTo(flowEntryPublishList, FlowEntryPublishVo.class)); + } + + /** + * 以字典形式返回全部FlowEntry数据集合。字典的键值为[entryId, procDefinitionName]。 + * 白名单接口,登录用户均可访问。 + * + * @param filter 过滤对象。 + * @return 应答结果对象,包含的数据为 List>,map中包含两条记录,key的值分别是id和name,value对应具体数据。 + */ + @GetMapping("/listDict") + public ResponseResult>> listDict(@ParameterObject FlowEntryDto filter) { + List resultList = + flowEntryService.getFlowEntryList(MyModelUtil.copyTo(filter, FlowEntry.class), null); + return ResponseResult.success( + MyCommonUtil.toDictDataList(resultList, FlowEntry::getEntryId, FlowEntry::getProcessDefinitionName)); + } + + /** + * 获取所有流程分类和流程定义的列表。白名单接口。 + * + * @return 所有流程分类和流程定义的列表 + */ + @GetMapping("/listAll") + public ResponseResult listAll() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("flowEntryList", flowEntryService.getFlowEntryList(null, null)); + jsonObject.put("flowCategoryList", flowCategoryService.getFlowCategoryList(null, null)); + return ResponseResult.success(jsonObject); + } + + /** + * 白名单接口,根据流程Id,获取流程引擎需要的流程标识和流程名称。 + * + * @param entryId 流程Id。 + * @return 流程的部分数据。 + */ + @GetMapping("/viewDict") + public ResponseResult> viewDict(@RequestParam Long entryId) { + ResponseResult verifyResult = this.doVerifyAndGet(entryId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + FlowEntry flowEntry = verifyResult.getData(); + Map resultMap = new HashMap<>(2); + resultMap.put("processDefinitionKey", flowEntry.getProcessDefinitionKey()); + resultMap.put("processDefinitionName", flowEntry.getProcessDefinitionName()); + return ResponseResult.success(resultMap); + } + + /** + * 切换指定工作的发布主版本。 + * + * @param entryId 工作流主键Id。 + * @param newEntryPublishId 新的工作流发布主版本对象的主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("flowEntry.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/updateMainVersion") + public ResponseResult updateMainVersion( + @MyRequestBody(required = true) Long entryId, + @MyRequestBody(required = true) Long newEntryPublishId) { + String errorMessage; + ResponseResult verifyResult = this.doVerifyAndGet(entryId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + FlowEntryPublish flowEntryPublish = flowEntryService.getFlowEntryPublishFromCache(newEntryPublishId); + if (flowEntryPublish == null) { + errorMessage = "数据验证失败,当前流程发布版本并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (ObjectUtil.notEqual(entryId, flowEntryPublish.getEntryId())) { + errorMessage = "数据验证失败,当前工作流并不包含该工作流发布版本数据,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (BooleanUtil.isTrue(flowEntryPublish.getMainVersion())) { + errorMessage = "数据验证失败,该版本已经为当前工作流的发布主版本,不能重复设置!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + flowEntryService.updateFlowEntryMainVersion(flowEntryService.getById(entryId), flowEntryPublish); + return ResponseResult.success(); + } + + /** + * 挂起工作流的指定发布版本。 + * + * @param entryPublishId 工作发布Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("flowEntry.all") + @OperationLog(type = SysOperationLogType.SUSPEND) + @PostMapping("/suspendFlowEntryPublish") + public ResponseResult suspendFlowEntryPublish(@MyRequestBody(required = true) Long entryPublishId) { + String errorMessage; + FlowEntryPublish flowEntryPublish = flowEntryService.getFlowEntryPublishFromCache(entryPublishId); + if (flowEntryPublish == null) { + errorMessage = "数据验证失败,当前流程发布版本并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + ResponseResult verifyResult = this.doVerifyAndGet(flowEntryPublish.getEntryId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (BooleanUtil.isFalse(flowEntryPublish.getActiveStatus())) { + errorMessage = "数据验证失败,当前流程发布版本已处于挂起状态!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + flowEntryService.suspendFlowEntryPublish(flowEntryPublish); + return ResponseResult.success(); + } + + /** + * 激活工作流的指定发布版本。 + * + * @param entryPublishId 工作发布Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("flowEntry.all") + @OperationLog(type = SysOperationLogType.RESUME) + @PostMapping("/activateFlowEntryPublish") + public ResponseResult activateFlowEntryPublish(@MyRequestBody(required = true) Long entryPublishId) { + String errorMessage; + FlowEntryPublish flowEntryPublish = flowEntryService.getFlowEntryPublishFromCache(entryPublishId); + if (flowEntryPublish == null) { + errorMessage = "数据验证失败,当前流程发布版本并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + ResponseResult verifyResult = this.doVerifyAndGet(flowEntryPublish.getEntryId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (BooleanUtil.isTrue(flowEntryPublish.getActiveStatus())) { + errorMessage = "数据验证失败,当前流程发布版本已处于激活状态!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + flowEntryService.activateFlowEntryPublish(flowEntryPublish); + return ResponseResult.success(); + } + + private ResponseResult doVerifyAndGet(Long entryId) { + String errorMessage; + if (MyCommonUtil.existBlankArgument(entryId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + FlowEntry flowEntry = flowEntryService.getById(entryId); + if (flowEntry == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + TokenData tokenData = TokenData.takeFromRequest(); + if (!StrUtil.equals(flowEntry.getAppCode(), tokenData.getAppCode())) { + errorMessage = "数据验证失败,当前应用并不存在该流程定义!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (ObjectUtil.notEqual(flowEntry.getTenantId(), tokenData.getTenantId())) { + errorMessage = "数据验证失败,当前租户并不存在该流程定义!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(flowEntry); + } + + private ResponseResult verifyAndGetInitialTaskInfo(FlowEntry flowEntry) throws XMLStreamException { + String errorMessage; + BpmnModel bpmnModel = flowApiService.convertToBpmnModel(flowEntry.getBpmnXml()); + Process process = bpmnModel.getMainProcess(); + if (process == null) { + errorMessage = "数据验证失败,当前流程标识 [" + flowEntry.getProcessDefinitionKey() + "] 关联的流程模型并不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + Collection elementList = process.getFlowElements(); + FlowElement startEvent = null; + // 这里我们只定位流程模型中的第二个节点。 + for (FlowElement flowElement : elementList) { + if (flowElement instanceof StartEvent) { + startEvent = flowElement; + break; + } + } + if (startEvent == null) { + errorMessage = "数据验证失败,当前流程图没有包含 [开始事件] 节点,请修改流程图!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + FlowElement firstTask = this.findFirstTask(elementList, startEvent); + if (firstTask == null) { + errorMessage = "数据验证失败,当前流程图没有包含 [开始事件] 节点没有任何连线,请修改流程图!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + TaskInfoVo taskInfoVo; + if (firstTask instanceof UserTask) { + UserTask userTask = (UserTask) firstTask; + String formKey = userTask.getFormKey(); + if (StrUtil.isNotBlank(formKey)) { + taskInfoVo = JSON.parseObject(formKey, TaskInfoVo.class); + } else { + taskInfoVo = new TaskInfoVo(); + } + taskInfoVo.setAssignee(userTask.getAssignee()); + taskInfoVo.setTaskKey(userTask.getId()); + taskInfoVo.setTaskType(FlowTaskType.USER_TYPE); + Map> extensionMap = userTask.getExtensionElements(); + if (MapUtil.isNotEmpty(extensionMap)) { + taskInfoVo.setOperationList(flowTaskExtService.buildOperationListExtensionElement(extensionMap)); + taskInfoVo.setVariableList(flowTaskExtService.buildVariableListExtensionElement(extensionMap)); + } + } else { + taskInfoVo = new TaskInfoVo(); + taskInfoVo.setTaskType(FlowTaskType.OTHER_TYPE); + } + return ResponseResult.success(taskInfoVo); + } + + private FlowElement findFirstTask(Collection elementList, FlowElement startEvent) { + for (FlowElement flowElement : elementList) { + if (flowElement instanceof SequenceFlow) { + SequenceFlow sequenceFlow = (SequenceFlow) flowElement; + if (sequenceFlow.getSourceFlowElement().equals(startEvent)) { + return sequenceFlow.getTargetFlowElement(); + } + } + } + return null; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowEntryVariableController.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowEntryVariableController.java new file mode 100644 index 00000000..371d37cc --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowEntryVariableController.java @@ -0,0 +1,159 @@ +package com.orangeforms.common.flow.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.common.flow.vo.*; +import com.orangeforms.common.flow.dto.*; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.flow.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.core.validator.UpdateGroup; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; + +import java.util.*; +import jakarta.validation.groups.Default; + +/** + * 工作流流程变量接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "工作流流程变量接口") +@Slf4j +@RestController +@RequestMapping("${common-flow.urlPrefix}/flowEntryVariable") +@ConditionalOnProperty(name = "common-flow.operationEnabled", havingValue = "true") +public class FlowEntryVariableController { + + @Autowired + private FlowEntryVariableService flowEntryVariableService; + + /** + * 新增流程变量数据。 + * + * @param flowEntryVariableDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"flowEntryVariableDto.variableId"}) + @SaCheckPermission("flowEntry.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody FlowEntryVariableDto flowEntryVariableDto) { + String errorMessage = MyCommonUtil.getModelValidationError(flowEntryVariableDto); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + FlowEntryVariable flowEntryVariable = MyModelUtil.copyTo(flowEntryVariableDto, FlowEntryVariable.class); + flowEntryVariable = flowEntryVariableService.saveNew(flowEntryVariable); + return ResponseResult.success(flowEntryVariable.getVariableId()); + } + + /** + * 更新流程变量数据。 + * + * @param flowEntryVariableDto 更新对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("flowEntry.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody FlowEntryVariableDto flowEntryVariableDto) { + String errorMessage = MyCommonUtil.getModelValidationError(flowEntryVariableDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + FlowEntryVariable flowEntryVariable = MyModelUtil.copyTo(flowEntryVariableDto, FlowEntryVariable.class); + FlowEntryVariable originalFlowEntryVariable = flowEntryVariableService.getById(flowEntryVariable.getVariableId()); + if (originalFlowEntryVariable == null) { + // NOTE: 修改下面方括号中的话述 + errorMessage = "数据验证失败,当前 [数据] 并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!flowEntryVariableService.update(flowEntryVariable, originalFlowEntryVariable)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 删除流程变量数据。 + * + * @param variableId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("flowEntry.all") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long variableId) { + String errorMessage; + if (MyCommonUtil.existBlankArgument(variableId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + // 验证关联Id的数据合法性 + FlowEntryVariable originalFlowEntryVariable = flowEntryVariableService.getById(variableId); + if (originalFlowEntryVariable == null) { + // NOTE: 修改下面方括号中的话述 + errorMessage = "数据验证失败,当前 [对象] 并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!flowEntryVariableService.remove(variableId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的流程变量列表。 + * + * @param flowEntryVariableDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("flowEntry.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody FlowEntryVariableDto flowEntryVariableDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + FlowEntryVariable flowEntryVariableFilter = MyModelUtil.copyTo(flowEntryVariableDtoFilter, FlowEntryVariable.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, FlowEntryVariable.class); + List flowEntryVariableList = + flowEntryVariableService.getFlowEntryVariableListWithRelation(flowEntryVariableFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(flowEntryVariableList, FlowEntryVariableVo.class)); + } + + /** + * 查看指定流程变量对象详情。 + * + * @param variableId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("flowEntry.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long variableId) { + if (MyCommonUtil.existBlankArgument(variableId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + FlowEntryVariable flowEntryVariable = flowEntryVariableService.getByIdWithRelation(variableId, MyRelationParam.full()); + if (flowEntryVariable == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(flowEntryVariable, FlowEntryVariableVo.class); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowMessageController.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowMessageController.java new file mode 100644 index 00000000..ffcc00b6 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowMessageController.java @@ -0,0 +1,110 @@ +package com.orangeforms.common.flow.controller; + +import io.swagger.v3.oas.annotations.tags.Tag; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.flow.model.constant.FlowMessageType; +import com.orangeforms.common.flow.model.FlowMessage; +import com.orangeforms.common.flow.service.FlowMessageService; +import com.orangeforms.common.flow.vo.FlowMessageVo; +import com.github.pagehelper.page.PageMethod; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 工作流消息接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "工作流消息接口") +@Slf4j +@RestController +@RequestMapping("${common-flow.urlPrefix}/flowMessage") +@ConditionalOnProperty(name = "common-flow.operationEnabled", havingValue = "true") +public class FlowMessageController { + + @Autowired + private FlowMessageService flowMessageService; + + /** + * 获取当前用户的未读消息总数。 + * NOTE:白名单接口。 + * + * @return 应答结果对象,包含当前用户的未读消息总数。 + */ + @GetMapping("/getMessageCount") + public ResponseResult getMessageCount() { + JSONObject resultData = new JSONObject(); + resultData.put("remindingMessageCount", flowMessageService.countRemindingMessageListByUser()); + resultData.put("copyMessageCount", flowMessageService.countCopyMessageByUser()); + return ResponseResult.success(resultData); + } + + /** + * 获取当前用户的催办消息列表。 + * 不仅仅包含,其中包括当前用户所属角色、部门和岗位的候选组催办消息。 + * NOTE:白名单接口。 + * + * @return 应答结果对象,包含查询结果集。 + */ + @PostMapping("/listRemindingTask") + public ResponseResult> listRemindingTask(@MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount()); + } + List flowMessageList = flowMessageService.getRemindingMessageListByUser(); + return ResponseResult.success(MyPageUtil.makeResponseData(flowMessageList, FlowMessageVo.class)); + } + + /** + * 获取当前用户的抄送消息列表。 + * 不仅仅包含,其中包括当前用户所属角色、部门和岗位的候选组抄送消息。 + * NOTE:白名单接口。 + * + * @param read true表示已读,false表示未读。 + * @return 应答结果对象,包含查询结果集。 + */ + @PostMapping("/listCopyMessage") + public ResponseResult> listCopyMessage( + @MyRequestBody MyPageParam pageParam, @MyRequestBody Boolean read) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount()); + } + List flowMessageList = flowMessageService.getCopyMessageListByUser(read); + return ResponseResult.success(MyPageUtil.makeResponseData(flowMessageList, FlowMessageVo.class)); + } + + /** + * 读取抄送消息,同时更新当前用户对指定抄送消息的读取状态。 + * + * @param messageId 消息Id。 + * @return 应答结果对象。 + */ + @PostMapping("/readCopyTask") + public ResponseResult readCopyTask(@MyRequestBody Long messageId) { + String errorMessage; + // 验证流程任务的合法性。 + FlowMessage flowMessage = flowMessageService.getById(messageId); + if (flowMessage == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + if (flowMessage.getMessageType() != FlowMessageType.COPY_TYPE) { + errorMessage = "数据验证失败,当前消息不是抄送类型消息!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!flowMessageService.isCandidateIdentityOnMessage(messageId)) { + errorMessage = "数据验证失败,当前用户没有权限访问该消息!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + flowMessageService.readCopyTask(messageId); + return ResponseResult.success(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowOperationController.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowOperationController.java new file mode 100644 index 00000000..981fe6ac --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/controller/FlowOperationController.java @@ -0,0 +1,941 @@ +package com.orangeforms.common.flow.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.annotation.DisableDataFilter; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.flow.constant.FlowApprovalType; +import com.orangeforms.common.flow.constant.FlowConstant; +import com.orangeforms.common.flow.constant.FlowTaskStatus; +import com.orangeforms.common.flow.exception.FlowOperationException; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.flow.service.*; +import com.orangeforms.common.flow.util.FlowCustomExtFactory; +import com.orangeforms.common.flow.util.FlowOperationHelper; +import com.orangeforms.common.flow.vo.FlowTaskCommentVo; +import com.orangeforms.common.flow.vo.FlowTaskVo; +import com.orangeforms.common.flow.vo.FlowUserInfoVo; +import com.orangeforms.common.flow.vo.TaskInfoVo; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.slf4j.Slf4j; +import org.flowable.bpmn.converter.BpmnXMLConverter; +import org.flowable.bpmn.model.BpmnModel; +import org.flowable.bpmn.model.UserTask; +import org.flowable.engine.history.HistoricActivityInstance; +import org.flowable.engine.history.HistoricProcessInstance; +import org.flowable.task.api.Task; +import org.flowable.task.api.TaskInfo; +import org.flowable.task.api.history.HistoricTaskInstance; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.util.StreamUtils; +import org.springframework.web.bind.annotation.*; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.text.ParseException; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 工作流流程操作接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "工作流流程操作接口") +@Slf4j +@RestController +@RequestMapping("${common-flow.urlPrefix}/flowOperation") +@ConditionalOnProperty(name = "common-flow.operationEnabled", havingValue = "true") +public class FlowOperationController { + + @Autowired + private FlowEntryService flowEntryService; + @Autowired + private FlowTaskCommentService flowTaskCommentService; + @Autowired + private FlowTaskExtService flowTaskExtService; + @Autowired + private FlowApiService flowApiService; + @Autowired + private FlowWorkOrderService flowWorkOrderService; + @Autowired + private FlowMessageService flowMessageService; + @Autowired + private FlowOperationHelper flowOperationHelper; + @Autowired + private FlowCustomExtFactory flowCustomExtFactory; + @Autowired + private FlowMultiInstanceTransService flowMultiInstanceTransService; + + private static final String ACTIVE_MULTI_INST_TASK = "activeMultiInstanceTask"; + private static final String SHOW_NAME = "showName"; + private static final String INSTANCE_ID = "processInstanceId"; + + /** + * 获取开始节点之后的第一个任务节点的数据。 + * + * @param processDefinitionKey 流程标识。 + * @return 任务节点的自定义对象数据。 + */ + @GetMapping("/viewInitialTaskInfo") + public ResponseResult viewInitialTaskInfo(@RequestParam String processDefinitionKey) { + ResponseResult flowEntryResult = flowOperationHelper.verifyAndGetFlowEntry(processDefinitionKey); + if (!flowEntryResult.isSuccess()) { + return ResponseResult.errorFrom(flowEntryResult); + } + FlowEntryPublish flowEntryPublish = flowEntryResult.getData().getMainFlowEntryPublish(); + String initTaskInfo = flowEntryPublish.getInitTaskInfo(); + TaskInfoVo taskInfo = StrUtil.isBlank(initTaskInfo) + ? null : JSON.parseObject(initTaskInfo, TaskInfoVo.class); + if (taskInfo != null) { + String loginName = TokenData.takeFromRequest().getLoginName(); + taskInfo.setAssignedMe(StrUtil.equalsAny( + taskInfo.getAssignee(), loginName, FlowConstant.START_USER_NAME_VAR)); + } + return ResponseResult.success(taskInfo); + } + + /** + * 获取流程运行时指定任务的信息。 + * + * @param processDefinitionId 流程引擎的定义Id。 + * @param processInstanceId 流程引擎的实例Id。 + * @param taskId 流程引擎的任务Id。 + * @return 任务节点的自定义对象数据。 + */ + @GetMapping("/viewRuntimeTaskInfo") + public ResponseResult viewRuntimeTaskInfo( + @RequestParam String processDefinitionId, + @RequestParam String processInstanceId, + @RequestParam String taskId) { + Task task = flowApiService.getProcessInstanceActiveTask(processInstanceId, taskId); + ResponseResult taskInfoResult = flowOperationHelper.verifyAndGetRuntimeTaskInfo(task); + if (!taskInfoResult.isSuccess()) { + return ResponseResult.errorFrom(taskInfoResult); + } + TaskInfoVo taskInfoVo = taskInfoResult.getData(); + FlowTaskExt flowTaskExt = + flowTaskExtService.getByProcessDefinitionIdAndTaskId(processDefinitionId, taskInfoVo.getTaskKey()); + if (flowTaskExt != null) { + if (StrUtil.isNotBlank(flowTaskExt.getOperationListJson())) { + taskInfoVo.setOperationList(JSON.parseArray(flowTaskExt.getOperationListJson(), JSONObject.class)); + } + if (StrUtil.isNotBlank(flowTaskExt.getVariableListJson())) { + taskInfoVo.setVariableList(JSON.parseArray(flowTaskExt.getVariableListJson(), JSONObject.class)); + } + } + return ResponseResult.success(taskInfoVo); + } + + /** + * 获取流程运行时指定任务的信息。 + * + * @param processDefinitionId 流程引擎的定义Id。 + * @param processInstanceId 流程引擎的实例Id。 + * @param taskId 流程引擎的任务Id。 + * @return 任务节点的自定义对象数据。 + */ + @GetMapping("/viewHistoricTaskInfo") + public ResponseResult viewHistoricTaskInfo( + @RequestParam String processDefinitionId, + @RequestParam String processInstanceId, + @RequestParam String taskId) { + String errorMessage; + HistoricTaskInstance taskInstance = flowApiService.getHistoricTaskInstance(processInstanceId, taskId); + String loginName = TokenData.takeFromRequest().getLoginName(); + if (!StrUtil.equals(taskInstance.getAssignee(), loginName)) { + errorMessage = "数据验证失败,当前用户不是指派人!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + TaskInfoVo taskInfoVo = JSON.parseObject(taskInstance.getFormKey(), TaskInfoVo.class); + FlowTaskExt flowTaskExt = + flowTaskExtService.getByProcessDefinitionIdAndTaskId(processDefinitionId, taskInstance.getTaskDefinitionKey()); + if (flowTaskExt != null) { + if (StrUtil.isNotBlank(flowTaskExt.getOperationListJson())) { + taskInfoVo.setOperationList(JSON.parseArray(flowTaskExt.getOperationListJson(), JSONObject.class)); + } + if (StrUtil.isNotBlank(flowTaskExt.getVariableListJson())) { + taskInfoVo.setVariableList(JSON.parseArray(flowTaskExt.getVariableListJson(), JSONObject.class)); + } + } + return ResponseResult.success(taskInfoVo); + } + + /** + * 获取第一个提交表单数据的任务信息。 + * + * @param processInstanceId 流程实例Id。 + * @return 任务节点的自定义对象数据。 + */ + @GetMapping("/viewInitialHistoricTaskInfo") + public ResponseResult viewInitialHistoricTaskInfo(@RequestParam String processInstanceId) { + String errorMessage; + List taskCommentList = + flowTaskCommentService.getFlowTaskCommentList(processInstanceId); + if (CollUtil.isEmpty(taskCommentList)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + FlowTaskComment taskComment = taskCommentList.get(0); + HistoricTaskInstance task = flowApiService.getHistoricTaskInstance(processInstanceId, taskComment.getTaskId()); + if (StrUtil.isBlank(task.getFormKey())) { + errorMessage = "数据验证失败,指定任务的formKey属性不存在,请重新修改流程图!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + TaskInfoVo taskInfo = JSON.parseObject(task.getFormKey(), TaskInfoVo.class); + taskInfo.setTaskKey(task.getTaskDefinitionKey()); + return ResponseResult.success(taskInfo); + } + + /** + * 获取任务的用户信息列表。 + * + * @param processDefinitionId 流程定义Id。 + * @param processInstanceId 流程实例Id。 + * @param taskId 流程任务Id。 + * @param historic 是否为历史任务。 + * @return 任务相关的用户信息列表。 + */ + @DisableDataFilter + @GetMapping("/viewTaskUserInfo") + public ResponseResult> viewTaskUserInfo( + @RequestParam String processDefinitionId, + @RequestParam String processInstanceId, + @RequestParam String taskId, + @RequestParam Boolean historic) { + TaskInfo taskInfo; + HistoricTaskInstance hisotricTask; + if (BooleanUtil.isFalse(historic)) { + taskInfo = flowApiService.getTaskById(taskId); + if (taskInfo == null) { + hisotricTask = flowApiService.getHistoricTaskInstance(processInstanceId, taskId); + taskInfo = hisotricTask; + historic = true; + } + } else { + hisotricTask = flowApiService.getHistoricTaskInstance(processInstanceId, taskId); + taskInfo = hisotricTask; + } + if (taskInfo == null) { + String errorMessage = "数据验证失败,任务Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + String taskKey = taskInfo.getTaskDefinitionKey(); + FlowTaskExt taskExt = flowTaskExtService.getByProcessDefinitionIdAndTaskId(processDefinitionId, taskKey); + boolean isMultiInstanceTask = flowApiService.isMultiInstanceTask(taskInfo.getProcessDefinitionId(), taskKey); + List resultUserInfoList = + flowTaskExtService.getCandidateUserInfoList(processInstanceId, taskExt, taskInfo, isMultiInstanceTask, historic); + if (BooleanUtil.isTrue(historic) || isMultiInstanceTask) { + List taskCommentList = buildApprovedFlowTaskCommentList(taskInfo, isMultiInstanceTask); + Map resultUserInfoMap = + resultUserInfoList.stream().collect(Collectors.toMap(FlowUserInfoVo::getLoginName, c -> c)); + for (FlowTaskComment taskComment : taskCommentList) { + FlowUserInfoVo flowUserInfoVo = resultUserInfoMap.get(taskComment.getCreateLoginName()); + if (flowUserInfoVo != null) { + flowUserInfoVo.setLastApprovalTime(taskComment.getCreateTime()); + } + } + } + return ResponseResult.success(resultUserInfoList); + } + + /** + * 获取多实例会签任务的指派人列表。 + * NOTE: 白名单接口。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 多实例任务的上一级任务Id。 + * @return 应答结果,指定会签任务的指派人列表。 + */ + @GetMapping("/listMultiSignAssignees") + public ResponseResult> listMultiSignAssignees( + @RequestParam String processInstanceId, @RequestParam String taskId) { + ResponseResult verifyResult = this.doVerifyMultiSign(processInstanceId, taskId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + Task activeMultiInstanceTask = + verifyResult.getData().getObject(ACTIVE_MULTI_INST_TASK, Task.class); + String multiInstanceExecId = flowApiService.getExecutionVariableStringWithSafe( + activeMultiInstanceTask.getExecutionId(), FlowConstant.MULTI_SIGN_TASK_EXECUTION_ID_VAR); + FlowMultiInstanceTrans trans = + flowMultiInstanceTransService.getWithAssigneeListByMultiInstanceExecId(multiInstanceExecId); + List commentList = + flowTaskCommentService.getFlowTaskCommentListByMultiInstanceExecId(multiInstanceExecId); + List assigneeList = StrUtil.split(trans.getAssigneeList(), ","); + Set approvedAssigneeSet = commentList.stream() + .map(FlowTaskComment::getCreateLoginName).collect(Collectors.toSet()); + List resultList = new LinkedList<>(); + Map usernameMap = + flowCustomExtFactory.getFlowIdentityExtHelper().mapUserShowNameByLoginName(new HashSet<>(assigneeList)); + for (String assignee : assigneeList) { + JSONObject resultData = new JSONObject(); + resultData.put("assignee", assignee); + resultData.put(SHOW_NAME, usernameMap.get(assignee)); + resultData.put("approved", approvedAssigneeSet.contains(assignee)); + resultList.add(resultData); + } + return ResponseResult.success(resultList); + } + + /** + * 提交多实例加签或减签。 + * NOTE: 白名单接口。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 多实例任务的上一级任务Id。 + * @param newAssignees 加签减签人列表,多个指派人之间逗号分隔。 + * @param isAdd 是否为加签,如果没有该参数,为了保持兼容性,缺省值为true。 + * @return 应答结果。 + */ + @PostMapping("/submitConsign") + public ResponseResult submitConsign( + @MyRequestBody(required = true) String processInstanceId, + @MyRequestBody(required = true) String taskId, + @MyRequestBody(required = true) String newAssignees, + @MyRequestBody Boolean isAdd) { + String errorMessage; + ResponseResult verifyResult = this.doVerifyMultiSign(processInstanceId, taskId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + HistoricTaskInstance taskInstance = + verifyResult.getData().getObject("taskInstance", HistoricTaskInstance.class); + Task activeMultiInstanceTask = + verifyResult.getData().getObject(ACTIVE_MULTI_INST_TASK, Task.class); + String multiInstanceExecId = flowApiService.getExecutionVariableStringWithSafe( + activeMultiInstanceTask.getExecutionId(), FlowConstant.MULTI_SIGN_TASK_EXECUTION_ID_VAR); + JSONArray assigneeArray = JSON.parseArray(newAssignees); + if (isAdd == null) { + isAdd = true; + } + if (!isAdd) { + List commentList = + flowTaskCommentService.getFlowTaskCommentListByMultiInstanceExecId(multiInstanceExecId); + if (CollUtil.isNotEmpty(commentList)) { + Set approvedAssigneeSet = commentList.stream() + .map(FlowTaskComment::getCreateLoginName).collect(Collectors.toSet()); + String loginName = this.findExistAssignee(approvedAssigneeSet, assigneeArray); + if (loginName != null) { + errorMessage = "数据验证失败,用户 [" + loginName + "] 已经审批,不能减签该用户!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + } else { + // 避免同一人被重复加签。 + FlowMultiInstanceTrans trans = + flowMultiInstanceTransService.getWithAssigneeListByMultiInstanceExecId(multiInstanceExecId); + Set assigneeSet = new HashSet<>(StrUtil.split(trans.getAssigneeList(), ",")); + String loginName = this.findExistAssignee(assigneeSet, assigneeArray); + if (loginName != null) { + errorMessage = "数据验证失败,用户 [" + loginName + "] 已经是会签人,不能重复指定!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + try { + flowApiService.submitConsign(taskInstance, activeMultiInstanceTask, newAssignees, isAdd); + } catch (FlowOperationException e) { + errorMessage = e.getMessage(); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 返回当前用户待办的任务列表。 + * + * @param processDefinitionKey 流程标识。 + * @param processDefinitionName 流程定义名 (模糊查询)。 + * @param taskName 任务名称 (模糊查询)。 + * @param pageParam 分页对象。 + * @return 返回当前用户待办的任务列表。如果指定流程标识,则仅返回该流程的待办任务列表。 + */ + @DisableDataFilter + @PostMapping("/listRuntimeTask") + public ResponseResult> listRuntimeTask( + @MyRequestBody String processDefinitionKey, + @MyRequestBody String processDefinitionName, + @MyRequestBody String taskName, + @MyRequestBody(required = true) MyPageParam pageParam) { + String username = TokenData.takeFromRequest().getLoginName(); + MyPageData pageData = flowApiService.getTaskListByUserName( + username, processDefinitionKey, processDefinitionName, taskName, pageParam); + List flowTaskVoList = flowApiService.convertToFlowTaskList(pageData.getDataList()); + return ResponseResult.success(MyPageUtil.makeResponseData(flowTaskVoList, pageData.getTotalCount())); + } + + /** + * 返回当前用户待办的任务数量。 + * + * @return 返回当前用户待办的任务数量。 + */ + @PostMapping("/countRuntimeTask") + public ResponseResult countRuntimeTask() { + String username = TokenData.takeFromRequest().getLoginName(); + long totalCount = flowApiService.getTaskCountByUserName(username); + return ResponseResult.success(totalCount); + } + + /** + * 主动驳回当前的待办任务到开始节点,只用当前待办任务的指派人或者候选者才能完成该操作。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 待办任务Id。 + * @param taskComment 驳回备注。 + * @return 操作应答结果。 + */ + @PostMapping("/rejectToStartUserTask") + public ResponseResult rejectToStartUserTask( + @MyRequestBody(required = true) String processInstanceId, + @MyRequestBody(required = true) String taskId, + @MyRequestBody(required = true) String taskComment) { + ResponseResult taskResult = + flowOperationHelper.verifySubmitAndGetTask(processInstanceId, taskId, null); + if (!taskResult.isSuccess()) { + return ResponseResult.errorFrom(taskResult); + } + FlowTaskComment firstTaskComment = flowTaskCommentService.getFirstFlowTaskComment(processInstanceId); + CallResult result = flowApiService.backToRuntimeTask( + taskResult.getData(), firstTaskComment.getTaskKey(), true, taskComment); + if (!result.isSuccess()) { + return ResponseResult.errorFrom(result); + } + return ResponseResult.success(); + } + + /** + * 主动驳回当前的待办任务,只用当前待办任务的指派人或者候选者才能完成该操作。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 待办任务Id。 + * @param taskComment 驳回备注。 + * @return 操作应答结果。 + */ + @PostMapping("/rejectRuntimeTask") + public ResponseResult rejectRuntimeTask( + @MyRequestBody(required = true) String processInstanceId, + @MyRequestBody(required = true) String taskId, + @MyRequestBody(required = true) String taskComment) { + String errorMessage; + ResponseResult taskResult = + flowOperationHelper.verifySubmitAndGetTask(processInstanceId, taskId, null); + if (!taskResult.isSuccess()) { + return ResponseResult.errorFrom(taskResult); + } + CallResult result = flowApiService.backToRuntimeTask(taskResult.getData(), null, true, taskComment); + if (!result.isSuccess()) { + return ResponseResult.errorFrom(result); + } + return ResponseResult.success(); + } + + /** + * 撤回当前用户提交的,但是尚未被审批的待办任务。只有已办任务的指派人才能完成该操作。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 待撤回的已办任务Id。 + * @param taskComment 撤回备注。 + * @return 操作应答结果。 + */ + @PostMapping("/revokeHistoricTask") + public ResponseResult revokeHistoricTask( + @MyRequestBody(required = true) String processInstanceId, + @MyRequestBody(required = true) String taskId, + @MyRequestBody(required = true) String taskComment) { + String errorMessage; + if (!flowApiService.existActiveProcessInstance(processInstanceId)) { + errorMessage = "数据验证失败,当前流程实例已经结束,不能执行撤回!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + HistoricTaskInstance taskInstance = flowApiService.getHistoricTaskInstance(processInstanceId, taskId); + if (taskInstance == null) { + errorMessage = "数据验证失败,当前任务不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!StrUtil.equals(taskInstance.getAssignee(), TokenData.takeFromRequest().getLoginName())) { + errorMessage = "数据验证失败,任务指派人与当前用户不匹配!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + FlowTaskComment latestComment = flowTaskCommentService.getLatestFlowTaskComment(processInstanceId); + if (latestComment == null) { + errorMessage = "数据验证失败,当前实例没有任何审批提交记录!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!latestComment.getTaskId().equals(taskId)) { + errorMessage = "数据验证失败,当前审批任务已被办理,不能撤回!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + List activeTaskList = flowApiService.getProcessInstanceActiveTaskList(processInstanceId); + if (CollUtil.isEmpty(activeTaskList)) { + errorMessage = "数据验证失败,当前流程没有任何待办任务!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (latestComment.getApprovalType().equals(FlowApprovalType.TRANSFER)) { + if (activeTaskList.size() > 1) { + errorMessage = "数据验证失败,转办任务数量不能多于1个!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + // 如果是转办任务,无需节点跳转,将指派人改为当前用户即可。 + Task task = activeTaskList.get(0); + task.setAssignee(TokenData.takeFromRequest().getLoginName()); + } else { + CallResult result = + flowApiService.backToRuntimeTask(activeTaskList.get(0), null, false, taskComment); + if (!result.isSuccess()) { + return ResponseResult.errorFrom(result); + } + } + return ResponseResult.success(); + } + + /** + * 获取当前流程任务的审批列表。 + * + * @param processInstanceId 当前运行时的流程实例Id。 + * @return 当前流程实例的详情数据。 + */ + @GetMapping("/listFlowTaskComment") + public ResponseResult> listFlowTaskComment(@RequestParam String processInstanceId) { + List flowTaskCommentList = + flowTaskCommentService.getFlowTaskCommentList(processInstanceId); + List resultList = MyModelUtil.copyCollectionTo(flowTaskCommentList, FlowTaskCommentVo.class); + return ResponseResult.success(resultList); + } + + /** + * 获取指定流程定义的流程图。 + * + * @param processDefinitionId 流程定义Id。 + * @return 流程图。 + */ + @GetMapping("/viewProcessBpmn") + public ResponseResult viewProcessBpmn(@RequestParam String processDefinitionId) throws IOException { + BpmnXMLConverter converter = new BpmnXMLConverter(); + BpmnModel bpmnModel = flowApiService.getBpmnModelByDefinitionId(processDefinitionId); + byte[] xmlBytes = converter.convertToXML(bpmnModel); + InputStream in = new ByteArrayInputStream(xmlBytes); + return ResponseResult.success(StreamUtils.copyToString(in, StandardCharsets.UTF_8)); + } + + /** + * 获取流程图高亮数据。 + * + * @param processInstanceId 流程实例Id。 + * @return 流程图高亮数据。 + */ + @GetMapping("/viewHighlightFlowData") + public ResponseResult viewHighlightFlowData(@RequestParam String processInstanceId) { + List activityInstanceList = + flowApiService.getHistoricActivityInstanceList(processInstanceId); + Set finishedTaskSet = activityInstanceList.stream() + .filter(s -> !StrUtil.equals(s.getActivityType(), "sequenceFlow")) + .map(HistoricActivityInstance::getActivityId).collect(Collectors.toSet()); + Set finishedSequenceFlowSet = activityInstanceList.stream() + .filter(s -> StrUtil.equals(s.getActivityType(), "sequenceFlow")) + .map(HistoricActivityInstance::getActivityId).collect(Collectors.toSet()); + //获取流程实例当前正在待办的节点 + List unfinishedInstanceList = + flowApiService.getHistoricUnfinishedInstanceList(processInstanceId); + Set unfinishedTaskSet = new LinkedHashSet<>(); + for (HistoricActivityInstance unfinishedActivity : unfinishedInstanceList) { + unfinishedTaskSet.add(unfinishedActivity.getActivityId()); + } + JSONObject jsonData = new JSONObject(); + jsonData.put("finishedTaskSet", finishedTaskSet); + jsonData.put("finishedSequenceFlowSet", finishedSequenceFlowSet); + jsonData.put("unfinishedTaskSet", unfinishedTaskSet); + return ResponseResult.success(jsonData); + } + + /** + * 获取当前用户的已办理的审批任务列表。 + * + * @param processDefinitionName 流程名。 + * @param beginDate 流程发起开始时间。 + * @param endDate 流程发起结束时间。 + * @param pageParam 分页对象。 + * @return 查询结果应答。 + */ + @DisableDataFilter + @PostMapping("/listHistoricTask") + public ResponseResult>> listHistoricTask( + @MyRequestBody String processDefinitionName, + @MyRequestBody String beginDate, + @MyRequestBody String endDate, + @MyRequestBody(required = true) MyPageParam pageParam) throws ParseException { + MyPageData pageData = + flowApiService.getHistoricTaskInstanceFinishedList(processDefinitionName, beginDate, endDate, pageParam); + List> resultList = new LinkedList<>(); + pageData.getDataList().forEach(instance -> resultList.add(BeanUtil.beanToMap(instance))); + List taskInstanceList = pageData.getDataList(); + if (CollUtil.isNotEmpty(taskInstanceList)) { + Set instanceIdSet = taskInstanceList.stream() + .map(HistoricTaskInstance::getProcessInstanceId).collect(Collectors.toSet()); + List instanceList = flowApiService.getHistoricProcessInstanceList(instanceIdSet); + Set loginNameSet = instanceList.stream() + .map(HistoricProcessInstance::getStartUserId).collect(Collectors.toSet()); + List userInfoList = flowCustomExtFactory + .getFlowIdentityExtHelper().getUserInfoListByUsernameSet(loginNameSet); + Map userInfoMap = + userInfoList.stream().collect(Collectors.toMap(FlowUserInfoVo::getLoginName, c -> c)); + Map instanceMap = + instanceList.stream().collect(Collectors.toMap(HistoricProcessInstance::getId, c -> c)); + List workOrderList = + flowWorkOrderService.getInList(INSTANCE_ID, instanceIdSet); + Map workOrderMap = + workOrderList.stream().collect(Collectors.toMap(FlowWorkOrder::getProcessInstanceId, c -> c)); + resultList.forEach(result -> { + String instanceId = result.get(INSTANCE_ID).toString(); + HistoricProcessInstance instance = instanceMap.get(instanceId); + result.put("processDefinitionKey", instance.getProcessDefinitionKey()); + result.put("processDefinitionName", instance.getProcessDefinitionName()); + result.put("startUser", instance.getStartUserId()); + FlowUserInfoVo userInfo = userInfoMap.get(instance.getStartUserId()); + result.put(SHOW_NAME, userInfo.getShowName()); + result.put("headImageUrl", userInfo.getHeadImageUrl()); + result.put("businessKey", instance.getBusinessKey()); + FlowWorkOrder flowWorkOrder = workOrderMap.get(instanceId); + if (flowWorkOrder != null) { + result.put("workOrderCode", flowWorkOrder.getWorkOrderCode()); + } + }); + Set taskIdSet = + taskInstanceList.stream().map(HistoricTaskInstance::getId).collect(Collectors.toSet()); + List commentList = flowTaskCommentService.getFlowTaskCommentListByTaskIds(taskIdSet); + Map> commentMap = + commentList.stream().collect(Collectors.groupingBy(FlowTaskComment::getTaskId)); + resultList.forEach(result -> { + List comments = commentMap.get(result.get("id").toString()); + if (CollUtil.isNotEmpty(comments)) { + result.put("approvalType", comments.get(0).getApprovalType()); + comments.remove(0); + } + }); + } + return ResponseResult.success(MyPageUtil.makeResponseData(resultList, pageData.getTotalCount())); + } + + /** + * 根据输入参数查询,当前用户的历史流程数据。 + * + * @param processDefinitionName 流程名。 + * @param beginDate 流程发起开始时间。 + * @param endDate 流程发起结束时间。 + * @param pageParam 分页对象。 + * @return 查询结果应答。 + */ + @DisableDataFilter + @PostMapping("/listHistoricProcessInstance") + public ResponseResult>> listHistoricProcessInstance( + @MyRequestBody String processDefinitionName, + @MyRequestBody String beginDate, + @MyRequestBody String endDate, + @MyRequestBody(required = true) MyPageParam pageParam) throws ParseException { + String loginName = TokenData.takeFromRequest().getLoginName(); + MyPageData pageData = flowApiService.getHistoricProcessInstanceList( + null, processDefinitionName, loginName, beginDate, endDate, pageParam, true); + Set loginNameSet = pageData.getDataList().stream() + .map(HistoricProcessInstance::getStartUserId).collect(Collectors.toSet()); + List userInfoList = flowCustomExtFactory + .getFlowIdentityExtHelper().getUserInfoListByUsernameSet(loginNameSet); + if (CollUtil.isEmpty(userInfoList)) { + userInfoList = new LinkedList<>(); + } + Map userInfoMap = + userInfoList.stream().collect(Collectors.toMap(FlowUserInfoVo::getLoginName, c -> c)); + Set instanceIdSet = pageData.getDataList().stream() + .map(HistoricProcessInstance::getId).collect(Collectors.toSet()); + List workOrderList = + flowWorkOrderService.getInList(INSTANCE_ID, instanceIdSet); + Map workOrderMap = + workOrderList.stream().collect(Collectors.toMap(FlowWorkOrder::getProcessInstanceId, c -> c)); + List> resultList = new LinkedList<>(); + pageData.getDataList().forEach(instance -> { + Map data = BeanUtil.beanToMap(instance); + FlowUserInfoVo userInfo = userInfoMap.get(instance.getStartUserId()); + if (userInfo != null) { + data.put(SHOW_NAME, userInfo.getShowName()); + data.put("headImageUrl", userInfo.getHeadImageUrl()); + } + FlowWorkOrder workOrder = workOrderMap.get(instance.getId()); + if (workOrder != null) { + data.put("workOrderCode", workOrder.getWorkOrderCode()); + data.put("flowStatus", workOrder.getFlowStatus()); + } + resultList.add(data); + }); + return ResponseResult.success(MyPageUtil.makeResponseData(resultList, pageData.getTotalCount())); + } + + /** + * 根据输入参数查询,所有历史流程数据。 + * + * @param processDefinitionName 流程名。 + * @param startUser 流程发起用户。 + * @param beginDate 流程发起开始时间。 + * @param endDate 流程发起结束时间。 + * @param pageParam 分页对象。 + * @return 查询结果。 + */ + @PostMapping("/listAllHistoricProcessInstance") + public ResponseResult>> listAllHistoricProcessInstance( + @MyRequestBody String processDefinitionName, + @MyRequestBody String startUser, + @MyRequestBody String beginDate, + @MyRequestBody String endDate, + @MyRequestBody(required = true) MyPageParam pageParam) throws ParseException { + MyPageData pageData = flowApiService.getHistoricProcessInstanceList( + null, processDefinitionName, startUser, beginDate, endDate, pageParam, false); + List> resultList = new LinkedList<>(); + pageData.getDataList().forEach(instance -> resultList.add(BeanUtil.beanToMap(instance))); + List unfinishedProcessInstanceIds = pageData.getDataList().stream() + .filter(c -> c.getEndTime() == null) + .map(HistoricProcessInstance::getId) + .collect(Collectors.toList()); + MyPageData> pageResultData = + MyPageUtil.makeResponseData(resultList, pageData.getTotalCount()); + if (CollUtil.isEmpty(unfinishedProcessInstanceIds)) { + return ResponseResult.success(pageResultData); + } + Set processInstanceIds = pageData.getDataList().stream() + .map(HistoricProcessInstance::getId).collect(Collectors.toSet()); + List taskList = flowApiService.getTaskListByProcessInstanceIds(unfinishedProcessInstanceIds); + Map> taskMap = + taskList.stream().collect(Collectors.groupingBy(Task::getProcessInstanceId)); + for (Map result : resultList) { + String processInstanceId = result.get(INSTANCE_ID).toString(); + List instanceTaskList = taskMap.get(processInstanceId); + if (instanceTaskList != null) { + JSONArray taskArray = new JSONArray(); + for (Task task : instanceTaskList) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("taskId", task.getId()); + jsonObject.put("taskName", task.getName()); + jsonObject.put("taskKey", task.getTaskDefinitionKey()); + jsonObject.put("assignee", task.getAssignee()); + taskArray.add(jsonObject); + } + result.put("runtimeTaskInfoList", taskArray); + } + } + return ResponseResult.success(pageResultData); + } + + /** + * 催办工单,只有流程发起人才可以催办工单。 + * 催办场景必须要取消数据权限过滤,因为流程的指派很可能是跨越部门的。 + * 既然被指派和催办了,这里就应该禁用工单表的数据权限过滤约束。 + * 如果您的系统没有支持数据权限过滤,DisableDataFilter不会有任何影响,建议保留。 + * + * @param workOrderId 工单Id。 + * @return 应答结果。 + */ + @DisableDataFilter + @OperationLog(type = SysOperationLogType.REMIND_TASK) + @PostMapping("/remindRuntimeTask") + public ResponseResult remindRuntimeTask(@MyRequestBody(required = true) Long workOrderId) { + FlowWorkOrder flowWorkOrder = flowWorkOrderService.getById(workOrderId); + if (flowWorkOrder == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + String errorMessage; + if (!flowWorkOrder.getCreateUserId().equals(TokenData.takeFromRequest().getUserId())) { + errorMessage = "数据验证失败,只有流程发起人才能催办工单!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (flowWorkOrder.getFlowStatus().equals(FlowTaskStatus.FINISHED) + || flowWorkOrder.getFlowStatus().equals(FlowTaskStatus.CANCELLED) + || flowWorkOrder.getFlowStatus().equals(FlowTaskStatus.STOPPED)) { + errorMessage = "数据验证失败,已经结束的流程,不能催办工单!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (flowWorkOrder.getFlowStatus().equals(FlowTaskStatus.DRAFT)) { + errorMessage = "数据验证失败,流程草稿不能催办工单!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + flowMessageService.saveNewRemindMessage(flowWorkOrder); + return ResponseResult.success(); + } + + /** + * 取消工作流工单,仅当没有进入任何审批流程之前,才可以取消工单。 + * + * @param workOrderId 工单Id。 + * @param cancelReason 取消原因。 + * @return 应答结果。 + */ + @OperationLog(type = SysOperationLogType.CANCEL_FLOW) + @DisableDataFilter + @PostMapping("/cancelWorkOrder") + public ResponseResult cancelWorkOrder( + @MyRequestBody(required = true) Long workOrderId, + @MyRequestBody(required = true) String cancelReason) { + FlowWorkOrder flowWorkOrder = flowWorkOrderService.getById(workOrderId); + if (flowWorkOrder == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + String errorMessage; + if (!flowWorkOrder.getFlowStatus().equals(FlowTaskStatus.SUBMITTED) + && !flowWorkOrder.getFlowStatus().equals(FlowTaskStatus.DRAFT)) { + errorMessage = "数据验证失败,当前流程已经进入审批状态,不能撤销工单!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!flowWorkOrder.getCreateUserId().equals(TokenData.takeFromRequest().getUserId())) { + errorMessage = "数据验证失败,当前用户不是工单所有者,不能撤销工单!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + CallResult result; + // 草稿工单直接删除当前工单。 + if (flowWorkOrder.getFlowStatus().equals(FlowTaskStatus.DRAFT)) { + result = flowWorkOrderService.removeDraft(flowWorkOrder); + } else { + result = flowApiService.stopProcessInstance( + flowWorkOrder.getProcessInstanceId(), cancelReason, true); + } + if (!result.isSuccess()) { + return ResponseResult.errorFrom(result); + } + return ResponseResult.success(); + } + + /** + * 获取指定流程定义Id的所有用户任务数据列表。 + * + * @param processDefinitionId 流程定义Id。 + * @return 查询结果。 + */ + @GetMapping("/listAllUserTask") + public ResponseResult> listAllUserTask(@RequestParam String processDefinitionId) { + Map taskMap = flowApiService.getAllUserTaskMap(processDefinitionId); + List resultList = new LinkedList<>(); + for (UserTask t : taskMap.values()) { + JSONObject data = new JSONObject(); + data.put("id", t.getId()); + data.put("name", t.getName()); + resultList.add(data); + } + return ResponseResult.success(resultList); + } + + /** + * 终止流程实例,将任务从当前节点直接流转到主流程的结束事件。 + * + * @param processInstanceId 流程实例Id。 + * @param stopReason 停止原因。 + * @return 执行结果应答。 + */ + @SaCheckPermission("flowOperation.all") + @OperationLog(type = SysOperationLogType.STOP_FLOW) + @DisableDataFilter + @PostMapping("/stopProcessInstance") + public ResponseResult stopProcessInstance( + @MyRequestBody(required = true) String processInstanceId, + @MyRequestBody(required = true) String stopReason) { + CallResult result = flowApiService.stopProcessInstance(processInstanceId, stopReason, false); + if (!result.isSuccess()) { + return ResponseResult.errorFrom(result); + } + return ResponseResult.success(); + } + + /** + * 删除流程实例。 + * + * @param processInstanceId 流程实例Id。 + * @return 执行结果应答。 + */ + @SaCheckPermission("flowOperation.all") + @OperationLog(type = SysOperationLogType.DELETE_FLOW) + @PostMapping("/deleteProcessInstance") + public ResponseResult deleteProcessInstance(@MyRequestBody(required = true) String processInstanceId) { + flowApiService.deleteProcessInstance(processInstanceId); + return ResponseResult.success(); + } + + private List buildApprovedFlowTaskCommentList(TaskInfo taskInfo, boolean isMultiInstanceTask) { + List taskCommentList; + if (isMultiInstanceTask) { + String multiInstanceExecId; + FlowMultiInstanceTrans trans = + flowMultiInstanceTransService.getByExecutionId(taskInfo.getExecutionId(), taskInfo.getId()); + if (trans != null) { + multiInstanceExecId = trans.getMultiInstanceExecId(); + } else { + multiInstanceExecId = flowApiService.getExecutionVariableStringWithSafe( + taskInfo.getExecutionId(), FlowConstant.MULTI_SIGN_TASK_EXECUTION_ID_VAR); + } + taskCommentList = flowTaskCommentService.getFlowTaskCommentListByMultiInstanceExecId(multiInstanceExecId); + } else { + taskCommentList = flowTaskCommentService.getFlowTaskCommentListByExecutionId( + taskInfo.getProcessInstanceId(), taskInfo.getId(), taskInfo.getExecutionId()); + } + return taskCommentList; + } + + private ResponseResult doVerifyMultiSign(String processInstanceId, String taskId) { + String errorMessage; + if (!flowApiService.existActiveProcessInstance(processInstanceId)) { + errorMessage = "数据验证失败,当前流程实例已经结束,不能执行加签!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + HistoricTaskInstance taskInstance = flowApiService.getHistoricTaskInstance(processInstanceId, taskId); + if (taskInstance == null) { + errorMessage = "数据验证失败,当前任务不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + String loginName = TokenData.takeFromRequest().getLoginName(); + if (!StrUtil.equals(taskInstance.getAssignee(), loginName)) { + errorMessage = "数据验证失败,任务指派人与当前用户不匹配!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + List activeTaskList = flowApiService.getProcessInstanceActiveTaskList(processInstanceId); + Task activeMultiInstanceTask = null; + Map userTaskMap = flowApiService.getAllUserTaskMap(taskInstance.getProcessDefinitionId()); + for (Task activeTask : activeTaskList) { + UserTask userTask = userTaskMap.get(activeTask.getTaskDefinitionKey()); + if (!userTask.hasMultiInstanceLoopCharacteristics()) { + errorMessage = "数据验证失败,指定加签任务不存在或已审批完毕!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + String startTaskId = flowApiService.getTaskVariableStringWithSafe( + activeTask.getId(), FlowConstant.MULTI_SIGN_START_TASK_VAR); + if (StrUtil.equals(startTaskId, taskId)) { + activeMultiInstanceTask = activeTask; + break; + } + } + if (activeMultiInstanceTask == null) { + errorMessage = "数据验证失败,指定加签任务不存在或已审批完毕!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + JSONObject resultData = new JSONObject(); + resultData.put("taskInstance", taskInstance); + resultData.put(ACTIVE_MULTI_INST_TASK, activeMultiInstanceTask); + return ResponseResult.success(resultData); + } + + private String findExistAssignee(Set assigneeSet, JSONArray assigneeArray) { + for (int i = 0; i < assigneeArray.size(); i++) { + String loginName = assigneeArray.getString(i); + if (assigneeSet.contains(loginName)) { + return loginName; + } + } + return null; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowCategoryMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowCategoryMapper.java new file mode 100644 index 00000000..7cd964f6 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowCategoryMapper.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowCategory; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * FlowCategory数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowCategoryMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param flowCategoryFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getFlowCategoryList( + @Param("flowCategoryFilter") FlowCategory flowCategoryFilter, @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryMapper.java new file mode 100644 index 00000000..3e4154a8 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryMapper.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowEntry; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * FlowEntry数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowEntryMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param flowEntryFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getFlowEntryList( + @Param("flowEntryFilter") FlowEntry flowEntryFilter, @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryPublishMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryPublishMapper.java new file mode 100644 index 00000000..233c5531 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryPublishMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowEntryPublish; + +/** + * 数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowEntryPublishMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryPublishVariableMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryPublishVariableMapper.java new file mode 100644 index 00000000..76de0460 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryPublishVariableMapper.java @@ -0,0 +1,22 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowEntryPublishVariable; + +import java.util.List; + +/** + * 数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowEntryPublishVariableMapper extends BaseDaoMapper { + + /** + * 批量插入流程发布的变量列表。 + * + * @param entryPublishVariableList 流程发布的变量列表。 + */ + void insertList(List entryPublishVariableList); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryVariableMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryVariableMapper.java new file mode 100644 index 00000000..c7c133bb --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowEntryVariableMapper.java @@ -0,0 +1,27 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowEntryVariable; +import org.apache.ibatis.annotations.Param; + +import java.util.*; + +/** + * 流程变量数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowEntryVariableMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param flowEntryVariableFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getFlowEntryVariableList( + @Param("flowEntryVariableFilter") FlowEntryVariable flowEntryVariableFilter, + @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMessageCandidateIdentityMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMessageCandidateIdentityMapper.java new file mode 100644 index 00000000..c37279f2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMessageCandidateIdentityMapper.java @@ -0,0 +1,21 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowMessageCandidateIdentity; +import org.apache.ibatis.annotations.Param; + +/** + * 流程任务消息的候选身份数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowMessageCandidateIdentityMapper extends BaseDaoMapper { + + /** + * 删除指定流程实例的消息关联数据。 + * + * @param processInstanceId 流程实例Id。 + */ + void deleteByProcessInstanceId(@Param("processInstanceId") String processInstanceId); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMessageIdentityOperationMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMessageIdentityOperationMapper.java new file mode 100644 index 00000000..bc635b07 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMessageIdentityOperationMapper.java @@ -0,0 +1,21 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowMessageIdentityOperation; +import org.apache.ibatis.annotations.Param; + +/** + * 流程任务消息所属用户的操作数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowMessageIdentityOperationMapper extends BaseDaoMapper { + + /** + * 删除指定流程实例的消息关联数据。 + * + * @param processInstanceId 流程实例Id。 + */ + void deleteByProcessInstanceId(@Param("processInstanceId") String processInstanceId); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMessageMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMessageMapper.java new file mode 100644 index 00000000..b34474ae --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMessageMapper.java @@ -0,0 +1,79 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowMessage; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Set; + +/** + * 工作流消息数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowMessageMapper extends BaseDaoMapper { + + /** + * 获取指定用户和身份分组Id集合的催办消息列表。 + * + * @param tenantId 租户Id。 + * @param appCode 应用编码。 + * @param loginName 用户的登录名。与流程任务的assignee精确匹配。 + * @param groupIdSet 用户身份分组Id集合。 + * @return 查询后的催办消息列表。 + */ + List getRemindingMessageListByUser( + @Param("tenantId") Long tenantId, + @Param("appCode") String appCode, + @Param("loginName") String loginName, + @Param("groupIdSet") Set groupIdSet); + + /** + * 获取指定用户和身份分组Id集合的抄送消息列表。 + * + * @param tenantId 租户Id。 + * @param appCode 应用编码。 + * @param loginName 用户登录名。 + * @param groupIdSet 用户身份分组Id集合。 + * @param read true表示已读,false表示未读。 + * @return 查询后的抄送消息列表。 + */ + List getCopyMessageListByUser( + @Param("tenantId") Long tenantId, + @Param("appCode") String appCode, + @Param("loginName") String loginName, + @Param("groupIdSet") Set groupIdSet, + @Param("read") Boolean read); + + /** + * 计算当前用户催办消息的数量。 + * + * @param tenantId 租户Id。 + * @param appCode 应用编码。 + * @param loginName 用户登录名。 + * @param groupIdSet 用户身份分组Id集合。 + * @return 数据数量。 + */ + int countRemindingMessageListByUser( + @Param("tenantId") Long tenantId, + @Param("appCode") String appCode, + @Param("loginName") String loginName, + @Param("groupIdSet") Set groupIdSet); + + /** + * 计算当前用户未读抄送消息的数量。 + * + * @param tenantId 租户Id。 + * @param appCode 应用编码。 + * @param loginName 用户登录名。 + * @param groupIdSet 用户身份分组Id集合。 + * @return 数据数量 + */ + int countCopyMessageListByUser( + @Param("tenantId") Long tenantId, + @Param("appCode") String appCode, + @Param("loginName") String loginName, + @Param("groupIdSet") Set groupIdSet); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMultiInstanceTransMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMultiInstanceTransMapper.java new file mode 100644 index 00000000..131e9368 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowMultiInstanceTransMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowMultiInstanceTrans; + +/** + * 流程多实例任务执行流水访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowMultiInstanceTransMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowTaskCommentMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowTaskCommentMapper.java new file mode 100644 index 00000000..5da2bf06 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowTaskCommentMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowTaskComment; + +/** + * 流程任务批注数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowTaskCommentMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowTaskExtMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowTaskExtMapper.java new file mode 100644 index 00000000..9145a5e2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowTaskExtMapper.java @@ -0,0 +1,22 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowTaskExt; + +import java.util.List; + +/** + * 流程任务扩展数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowTaskExtMapper extends BaseDaoMapper { + + /** + * 批量插入流程任务扩展信息列表。 + * + * @param flowTaskExtList 流程任务扩展信息列表。 + */ + void insertList(List flowTaskExtList); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowWorkOrderExtMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowWorkOrderExtMapper.java new file mode 100644 index 00000000..b69fd718 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowWorkOrderExtMapper.java @@ -0,0 +1,14 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowWorkOrderExt; + +/** + * 工作流工单扩展数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowWorkOrderExtMapper extends BaseDaoMapper { + +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowWorkOrderMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowWorkOrderMapper.java new file mode 100644 index 00000000..fe270142 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/FlowWorkOrderMapper.java @@ -0,0 +1,49 @@ +package com.orangeforms.common.flow.dao; + +import com.orangeforms.common.core.annotation.EnableDataPerm; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.flow.model.FlowWorkOrder; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.*; + +/** + * 工作流工单表数据操作访问接口。 + * 如果当前系统支持数据权限过滤,当前用户必须要能看自己的工单数据,所以需要把EnableDataPerm + * 的mustIncludeUserRule参数设置为true,即便当前用户的数据权限中并不包含DataPermRuleType.TYPE_USER_ONLY, + * 数据过滤拦截组件也会自动补偿该类型的数据权限,以便当前用户可以看到自己发起的工单。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EnableDataPerm(mustIncludeUserRule = true) +public interface FlowWorkOrderMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param flowWorkOrderFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getFlowWorkOrderList( + @Param("flowWorkOrderFilter") FlowWorkOrder flowWorkOrderFilter, @Param("orderBy") String orderBy); + + /** + * 计算指定前缀工单编码的最大值。 + * + * @param prefix 工单编码前缀。 + * @return 该工单编码前缀的最大值。 + */ + @Select("SELECT MAX(work_order_code) FROM zz_flow_work_order WHERE work_order_code LIKE '${prefix}'") + String getMaxWorkOrderCodeByPrefix(@Param("prefix") String prefix); + + /** + * 根据工单编码查询指定工单,查询过程也会考虑逻辑删除的数据。 + * @param workOrderCode 工单编码。 + * @return 工单编码的流程工单数量。 + */ + @Select("SELECT COUNT(*) FROM zz_flow_work_order WHERE work_order_code = #{workOrderCode}") + int getCountByWorkOrderCode(@Param("workOrderCode") String workOrderCode); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowCategoryMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowCategoryMapper.xml new file mode 100644 index 00000000..65460911 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowCategoryMapper.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_flow_category.tenant_id IS NULL + + + AND zz_flow_category.tenant_id = #{flowCategoryFilter.tenantId} + + + AND zz_flow_category.app_code IS NULL + + + AND zz_flow_category.app_code = #{flowCategoryFilter.appCode} + + + AND zz_flow_category.name = #{flowCategoryFilter.name} + + + AND zz_flow_category.code = #{flowCategoryFilter.code} + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryMapper.xml new file mode 100644 index 00000000..78351d5d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryMapper.xml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_flow_entry.tenant_id IS NULL + + + AND zz_flow_entry.tenant_id = #{flowEntryFilter.tenantId} + + + AND zz_flow_entry.app_code IS NULL + + + AND zz_flow_entry.app_code = #{flowEntryFilter.appCode} + + + AND zz_flow_entry.process_definition_name = #{flowEntryFilter.processDefinitionName} + + + AND zz_flow_entry.process_definition_key = #{flowEntryFilter.processDefinitionKey} + + + AND zz_flow_entry.category_id = #{flowEntryFilter.categoryId} + + + AND zz_flow_entry.status = #{flowEntryFilter.status} + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryPublishMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryPublishMapper.xml new file mode 100644 index 00000000..a8c679aa --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryPublishMapper.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryPublishVariableMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryPublishVariableMapper.xml new file mode 100644 index 00000000..68bd83ff --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryPublishVariableMapper.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + INSERT INTO zz_flow_entry_publish_variable VALUES + + (#{item.variableId}, + #{item.entryPublishId}, + #{item.variableName}, + #{item.showName}, + #{item.variableType}, + #{item.bindDatasourceId}, + #{item.bindRelationId}, + #{item.bindColumnId}, + #{item.builtin}) + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryVariableMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryVariableMapper.xml new file mode 100644 index 00000000..09a4ea8e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowEntryVariableMapper.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_flow_entry_variable.entry_id = #{flowEntryVariableFilter.entryId} + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMessageCandidateIdentityMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMessageCandidateIdentityMapper.xml new file mode 100644 index 00000000..5dc31fc7 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMessageCandidateIdentityMapper.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + DELETE FROM zz_flow_msg_candidate_identity a + WHERE EXISTS (SELECT * FROM zz_flow_message b + WHERE a.message_id = b.message_id AND b.process_instance_id = #{processInstanceId}) + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMessageIdentityOperationMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMessageIdentityOperationMapper.xml new file mode 100644 index 00000000..60a8e4a0 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMessageIdentityOperationMapper.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + DELETE FROM zz_flow_msg_identity_operation a + WHERE EXISTS (SELECT * FROM zz_flow_message b + WHERE a.message_id = b.message_id AND b.process_instance_id = #{processInstanceId}) + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMessageMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMessageMapper.xml new file mode 100644 index 00000000..2fcd87f5 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMessageMapper.xml @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND a.tenant_id IS NULL + + + AND a.tenant_id = #{tenantId} + + + AND a.app_code IS NULL + + + AND a.app_code = #{appCode} + + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMultiInstanceTransMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMultiInstanceTransMapper.xml new file mode 100644 index 00000000..732758a2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowMultiInstanceTransMapper.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowTaskCommentMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowTaskCommentMapper.xml new file mode 100644 index 00000000..69323d82 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowTaskCommentMapper.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowTaskExtMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowTaskExtMapper.xml new file mode 100644 index 00000000..2fca8da4 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowTaskExtMapper.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + INSERT INTO zz_flow_task_ext VALUES + + (#{item.processDefinitionId}, + #{item.taskId}, + #{item.operationListJson}, + #{item.variableListJson}, + #{item.assigneeListJson}, + #{item.groupType}, + #{item.deptPostListJson}, + #{item.roleIds}, + #{item.deptIds}, + #{item.candidateUsernames}, + #{item.copyListJson}, + #{item.extraDataJson}) + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowWorkOrderExtMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowWorkOrderExtMapper.xml new file mode 100644 index 00000000..2d3867d3 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowWorkOrderExtMapper.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowWorkOrderMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowWorkOrderMapper.xml new file mode 100644 index 00000000..24da5a15 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dao/mapper/FlowWorkOrderMapper.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_flow_work_order.deleted_flag = ${@com.orangeforms.common.core.constant.GlobalDeletedFlag@NORMAL} + + + + + + + AND zz_flow_work_order.tenant_id IS NULL + + + AND zz_flow_work_order.tenant_id = #{flowWorkOrderFilter.tenantId} + + + AND zz_flow_work_order.app_code IS NULL + + + AND zz_flow_work_order.app_code = #{flowWorkOrderFilter.appCode} + + + AND zz_flow_work_order.work_order_code = #{flowWorkOrderFilter.workOrderCode} + + + AND zz_flow_work_order.process_definition_key = #{flowWorkOrderFilter.processDefinitionKey} + + + AND zz_flow_work_order.latest_approval_status = #{flowWorkOrderFilter.latestApprovalStatus} + + + AND zz_flow_work_order.flow_status = #{flowWorkOrderFilter.flowStatus} + + + AND zz_flow_work_order.create_time >= #{flowWorkOrderFilter.createTimeStart} + + + AND zz_flow_work_order.create_time <= #{flowWorkOrderFilter.createTimeEnd} + + + AND zz_flow_work_order.create_user_id = #{flowWorkOrderFilter.createUserId} + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowCategoryDto.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowCategoryDto.java new file mode 100644 index 00000000..05b4b875 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowCategoryDto.java @@ -0,0 +1,47 @@ +package com.orangeforms.common.flow.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import com.orangeforms.common.core.validator.UpdateGroup; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 流程分类的Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "流程分类的Dto对象") +@Data +public class FlowCategoryDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long categoryId; + + /** + * 显示名称。 + */ + @Schema(description = "显示名称") + @NotBlank(message = "数据验证失败,显示名称不能为空!") + private String name; + + /** + * 分类编码。 + */ + @Schema(description = "分类编码") + @NotBlank(message = "数据验证失败,分类编码不能为空!") + private String code; + + /** + * 实现顺序。 + */ + @Schema(description = "实现顺序") + @NotNull(message = "数据验证失败,实现顺序不能为空!") + private Integer showOrder; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowEntryDto.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowEntryDto.java new file mode 100644 index 00000000..817ae003 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowEntryDto.java @@ -0,0 +1,107 @@ +package com.orangeforms.common.flow.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import com.orangeforms.common.core.validator.ConstDictRef; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.flow.model.constant.FlowBindFormType; +import com.orangeforms.common.flow.model.constant.FlowEntryStatus; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 流程的Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "流程的Dto对象") +@Data +public class FlowEntryDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键不能为空!", groups = {UpdateGroup.class}) + private Long entryId; + + /** + * 流程名称。 + */ + @Schema(description = "流程名称") + @NotBlank(message = "数据验证失败,流程名称不能为空!") + private String processDefinitionName; + + /** + * 流程标识Key。 + */ + @Schema(description = "流程标识Key") + @NotBlank(message = "数据验证失败,流程标识Key不能为空!") + private String processDefinitionKey; + + /** + * 流程分类。 + */ + @Schema(description = "流程分类") + @NotNull(message = "数据验证失败,流程分类不能为空!") + private Long categoryId; + + /** + * 流程状态。 + */ + @Schema(description = "流程状态") + @ConstDictRef(constDictClass = FlowEntryStatus.class, message = "数据验证失败,工作流状态为无效值!") + private Integer status; + + /** + * 流程定义的xml。 + */ + @Schema(description = "流程定义的xml") + private String bpmnXml; + + /** + * 流程图类型。0: 普通流程图,1: 钉钉风格的流程图。 + */ + @Schema(description = "流程图类型。0: 普通流程图,1: 钉钉风格的流程图") + private Integer diagramType; + + /** + * 绑定表单类型。 + */ + @Schema(description = "绑定表单类型") + @ConstDictRef(constDictClass = FlowBindFormType.class, message = "数据验证失败,工作流绑定表单类型为无效值!") + @NotNull(message = "数据验证失败,工作流绑定表单类型不能为空!") + private Integer bindFormType; + + /** + * 在线表单的页面Id。 + */ + @Schema(description = "在线表单的页面Id") + private Long pageId; + + /** + * 在线表单的缺省路由名称。 + */ + @Schema(description = "在线表单的缺省路由名称") + private String defaultRouterName; + + /** + * 在线表单Id。 + */ + @Schema(description = "在线表单Id") + private Long defaultFormId; + + /** + * 工单表编码字段的编码规则,如果为空则不计算工单编码。 + */ + @Schema(description = "工单表编码字段的编码规则") + private String encodedRule; + + /** + * 流程的自定义扩展数据(JSON格式)。 + */ + @Schema(description = "流程的自定义扩展数据") + private String extensionData; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowEntryVariableDto.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowEntryVariableDto.java new file mode 100644 index 00000000..75659d13 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowEntryVariableDto.java @@ -0,0 +1,81 @@ +package com.orangeforms.common.flow.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import com.orangeforms.common.core.validator.ConstDictRef; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.flow.model.constant.FlowVariableType; +import lombok.Data; + +import jakarta.validation.constraints.*; + +/** + * 流程变量Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "流程变量Dto对象") +@Data +public class FlowEntryVariableDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long variableId; + + /** + * 流程Id。 + */ + @Schema(description = "流程Id") + @NotNull(message = "数据验证失败,流程Id不能为空!") + private Long entryId; + + /** + * 变量名。 + */ + @Schema(description = "变量名") + @NotBlank(message = "数据验证失败,变量名不能为空!") + private String variableName; + + /** + * 显示名。 + */ + @Schema(description = "显示名") + @NotBlank(message = "数据验证失败,显示名不能为空!") + private String showName; + + /** + * 流程变量类型。 + */ + @Schema(description = "流程变量类型") + @ConstDictRef(constDictClass = FlowVariableType.class, message = "数据验证失败,流程变量类型为无效值!") + @NotNull(message = "数据验证失败,流程变量类型不能为空!") + private Integer variableType; + + /** + * 绑定数据源Id。 + */ + @Schema(description = "绑定数据源Id") + private Long bindDatasourceId; + + /** + * 绑定数据源关联Id。 + */ + @Schema(description = "绑定数据源关联Id") + private Long bindRelationId; + + /** + * 绑定字段Id。 + */ + @Schema(description = "绑定字段Id") + private Long bindColumnId; + + /** + * 是否内置。 + */ + @Schema(description = "是否内置") + @NotNull(message = "数据验证失败,是否内置不能为空!") + private Boolean builtin; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowMessageDto.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowMessageDto.java new file mode 100644 index 00000000..0d616e97 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowMessageDto.java @@ -0,0 +1,51 @@ +package com.orangeforms.common.flow.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 工作流通知消息Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "工作流通知消息Dto对象") +@Data +public class FlowMessageDto { + + /** + * 消息类型。 + */ + @Schema(description = "消息类型") + private Integer messageType; + + /** + * 工单Id。 + */ + @Schema(description = "工单Id") + private Long workOrderId; + + /** + * 流程名称。 + */ + @Schema(description = "流程名称") + private String processDefinitionName; + + /** + * 流程任务名称。 + */ + @Schema(description = "流程任务名称") + private String taskName; + + /** + * 更新时间范围过滤起始值(>=)。 + */ + @Schema(description = "updateTime 范围过滤起始值") + private String updateTimeStart; + + /** + * 更新时间范围过滤结束值(<=)。 + */ + @Schema(description = "updateTime 范围过滤结束值") + private String updateTimeEnd; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowTaskCommentDto.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowTaskCommentDto.java new file mode 100644 index 00000000..4af04f6e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowTaskCommentDto.java @@ -0,0 +1,38 @@ +package com.orangeforms.common.flow.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 流程任务的批注。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "流程任务的批注") +@Data +public class FlowTaskCommentDto { + + /** + * 流程任务触发按钮类型,内置值可参考FlowTaskButton。 + */ + @Schema(description = "流程任务触发按钮类型") + @NotNull(message = "数据验证失败,任务的审批类型不能为空!") + private String approvalType; + + /** + * 流程任务的批注内容。 + */ + @Schema(description = "流程任务的批注内容") + @NotBlank(message = "数据验证失败,任务审批内容不能为空!") + private String taskComment; + + /** + * 委托指定人,比如加签、转办等。 + */ + @Schema(description = "委托指定人,比如加签、转办等") + private String delegateAssignee; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowWorkOrderDto.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowWorkOrderDto.java new file mode 100644 index 00000000..f87c94c5 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/dto/FlowWorkOrderDto.java @@ -0,0 +1,39 @@ +package com.orangeforms.common.flow.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 工作流工单Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "工作流工单Dto对象") +@Data +public class FlowWorkOrderDto { + + /** + * 工单编码。 + */ + @Schema(description = "工单编码") + private String workOrderCode; + + /** + * 流程状态。参考FlowTaskStatus常量值对象。 + */ + @Schema(description = "流程状态") + private Integer flowStatus; + + /** + * createTime 范围过滤起始值(>=)。 + */ + @Schema(description = "createTime 范围过滤起始值") + private String createTimeStart; + + /** + * createTime 范围过滤结束值(<=)。 + */ + @Schema(description = "createTime 范围过滤结束值") + private String createTimeEnd; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/exception/FlowEmptyUserException.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/exception/FlowEmptyUserException.java new file mode 100644 index 00000000..02784712 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/exception/FlowEmptyUserException.java @@ -0,0 +1,21 @@ +package com.orangeforms.common.flow.exception; + +import org.flowable.common.engine.api.FlowableException; + +/** + * 流程空用户异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class FlowEmptyUserException extends FlowableException { + + /** + * 构造函数。 + * + * @param msg 错误信息。 + */ + public FlowEmptyUserException(String msg) { + super(msg); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/exception/FlowOperationException.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/exception/FlowOperationException.java new file mode 100644 index 00000000..313571e1 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/exception/FlowOperationException.java @@ -0,0 +1,35 @@ +package com.orangeforms.common.flow.exception; + +/** + * 流程操作异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class FlowOperationException extends RuntimeException { + + /** + * 构造函数。 + */ + public FlowOperationException() { + + } + + /** + * 构造函数。 + * + * @param throwable 引发异常对象。 + */ + public FlowOperationException(Throwable throwable) { + super(throwable); + } + + /** + * 构造函数。 + * + * @param msg 错误信息。 + */ + public FlowOperationException(String msg) { + super(msg); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/AutoSkipTaskListener.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/AutoSkipTaskListener.java new file mode 100644 index 00000000..4c1fce9f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/AutoSkipTaskListener.java @@ -0,0 +1,165 @@ +package com.orangeforms.common.flow.listener; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.text.StrFormatter; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.ApplicationContextHolder; +import com.orangeforms.common.flow.constant.FlowApprovalType; +import com.orangeforms.common.flow.constant.FlowConstant; +import com.orangeforms.common.flow.model.FlowTaskComment; +import com.orangeforms.common.flow.model.FlowTaskExt; +import com.orangeforms.common.flow.object.FlowTaskOperation; +import com.orangeforms.common.flow.service.FlowApiService; +import com.orangeforms.common.flow.service.FlowTaskCommentService; +import com.orangeforms.common.flow.service.FlowTaskExtService; +import lombok.extern.slf4j.Slf4j; +import org.flowable.bpmn.model.ExtensionAttribute; +import org.flowable.bpmn.model.UserTask; +import org.flowable.engine.delegate.TaskListener; +import org.flowable.task.api.Task; +import org.flowable.task.service.delegate.DelegateTask; + +import java.util.*; + +/** + * 流程任务自动审批跳过的监听器。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class AutoSkipTaskListener implements TaskListener { + + private final transient FlowTaskCommentService flowTaskCommentService = + ApplicationContextHolder.getBean(FlowTaskCommentService.class); + private final transient FlowApiService flowApiService = + ApplicationContextHolder.getBean(FlowApiService.class); + private final transient FlowTaskExtService flowTaskExtService = + ApplicationContextHolder.getBean(FlowTaskExtService.class); + + /** + * 流程的发起者等于当前任务的Assignee。 + */ + private static final String EQ_START_USER = "0"; + /** + * 上一步的提交者等于当前任务的Assignee。 + */ + private static final String EQ_PREV_SUBMIT_USER = "1"; + /** + * 当前任务的Assignee之前提交过审核。 + */ + private static final String EQ_HISTORIC_SUBMIT_USER = "2"; + + @Override + public void notify(DelegateTask t) { + UserTask userTask = flowApiService.getUserTask(t.getProcessDefinitionId(), t.getTaskDefinitionKey()); + List attributes = userTask.getAttributes().get(FlowConstant.USER_TASK_AUTO_SKIP_KEY); + Set skipTypes = new HashSet<>(StrUtil.split(attributes.get(0).getValue(), ",")); + String assignedUser = this.getAssignedUser(userTask, t.getProcessDefinitionId(), t.getExecutionId()); + if (StrUtil.isBlank(assignedUser)) { + return; + } + for (String skipType : skipTypes) { + if (this.verifyAndHandle(userTask, t, skipType, assignedUser)) { + return; + } + } + } + + private boolean verifyAndHandle(UserTask userTask, DelegateTask task, String skipType, String assignedUser) { + FlowTaskComment comment = null; + switch (skipType) { + case EQ_START_USER: + Object v = task.getVariable(FlowConstant.PROC_INSTANCE_START_USER_NAME_VAR); + if (ObjectUtil.equal(v, assignedUser)) { + comment = flowTaskCommentService.getFirstFlowTaskComment(task.getProcessInstanceId()); + } + break; + case EQ_PREV_SUBMIT_USER: + Object v2 = task.getVariable(FlowConstant.SUBMIT_USER_VAR); + if (ObjectUtil.equal(v2, assignedUser)) { + TokenData tokenData = TokenData.takeFromRequest(); + comment = new FlowTaskComment(); + comment.setCreateUserId(tokenData.getUserId()); + comment.setCreateLoginName(tokenData.getLoginName()); + comment.setCreateUsername(tokenData.getShowName()); + } + break; + case EQ_HISTORIC_SUBMIT_USER: + List comments = + flowTaskCommentService.getFlowTaskCommentList(task.getProcessInstanceId()); + List resultComments = new LinkedList<>(); + for (FlowTaskComment c : comments) { + if (StrUtil.equals(c.getCreateLoginName(), assignedUser)) { + resultComments.add(c); + } + } + if (CollUtil.isNotEmpty(resultComments)) { + comment = resultComments.get(0); + } + break; + default: + break; + } + if (comment != null) { + FlowTaskExt flowTaskExt = flowTaskExtService + .getByProcessDefinitionIdAndTaskId(task.getProcessDefinitionId(), userTask.getId()); + JSONObject taskVariableData = new JSONObject(); + if (StrUtil.isNotBlank(flowTaskExt.getOperationListJson())) { + List taskOperationList = + JSONArray.parseArray(flowTaskExt.getOperationListJson(), FlowTaskOperation.class); + taskOperationList.stream() + .filter(op -> op.getType().equals(FlowApprovalType.AGREE)) + .map(FlowTaskOperation::getLatestApprovalStatus).findFirst() + .ifPresent(status -> taskVariableData.put(FlowConstant.LATEST_APPROVAL_STATUS_KEY, status)); + } + Task t = flowApiService.getTaskById(task.getId()); + comment.fillWith(t); + comment.setApprovalType(FlowApprovalType.AGREE); + comment.setTaskComment(StrFormatter.format("自动跳过审批。审批人 [{}], 跳过原因 [{}]。", + userTask.getAssignee(), this.getMessageBySkipType(skipType))); + flowApiService.completeTask(t, comment, taskVariableData); + } + return comment != null; + } + + private String getAssignedUser(UserTask userTask, String processDefinitionId, String executionId) { + String assignedUser = userTask.getAssignee(); + if (StrUtil.isNotBlank(assignedUser)) { + if (assignedUser.startsWith("${") && assignedUser.endsWith("}")) { + String variableName = assignedUser.substring(2, assignedUser.length() - 1); + assignedUser = flowApiService.getExecutionVariableStringWithSafe(executionId, variableName); + } + } else { + FlowTaskExt flowTaskExt = flowTaskExtService + .getByProcessDefinitionIdAndTaskId(processDefinitionId, userTask.getId()); + List candidateUsernames; + if (StrUtil.isBlank(flowTaskExt.getCandidateUsernames())) { + candidateUsernames = Collections.emptyList(); + } else if (!StrUtil.equals(flowTaskExt.getCandidateUsernames(), "${" + FlowConstant.TASK_APPOINTED_ASSIGNEE_VAR + "}")) { + candidateUsernames = StrUtil.split(flowTaskExt.getCandidateUsernames(), ","); + } else { + String value = flowApiService + .getExecutionVariableStringWithSafe(executionId, FlowConstant.TASK_APPOINTED_ASSIGNEE_VAR); + candidateUsernames = value == null ? null : StrUtil.split(value, ","); + } + if (candidateUsernames != null && candidateUsernames.size() == 1) { + assignedUser = candidateUsernames.get(0); + } + } + return assignedUser; + } + + private String getMessageBySkipType(String skipType) { + return switch (skipType) { + case EQ_PREV_SUBMIT_USER -> "审批人与上一审批节点处理人相同"; + case EQ_START_USER -> "审批人为发起人"; + case EQ_HISTORIC_SUBMIT_USER -> "审批人审批过"; + default -> ""; + }; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/DeptPostLeaderListener.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/DeptPostLeaderListener.java new file mode 100644 index 00000000..7f47ecca --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/DeptPostLeaderListener.java @@ -0,0 +1,27 @@ +package com.orangeforms.common.flow.listener; + +import com.orangeforms.common.flow.constant.FlowConstant; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.delegate.TaskListener; +import org.flowable.task.service.delegate.DelegateTask; + +import java.util.Map; + +/** + * 当用户任务的候选组为本部门领导岗位时,该监听器会在任务创建时,获取当前流程实例发起人的部门领导。 + * 并将其指派为当前任务的候选组。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class DeptPostLeaderListener implements TaskListener { + + @Override + public void notify(DelegateTask delegateTask) { + Map variables = delegateTask.getVariables(); + if (variables.get(FlowConstant.GROUP_TYPE_DEPT_POST_LEADER_VAR) == null) { + delegateTask.setAssignee(variables.get(FlowConstant.PROC_INSTANCE_START_USER_NAME_VAR).toString()); + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/FlowFinishedListener.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/FlowFinishedListener.java new file mode 100644 index 00000000..417a4417 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/FlowFinishedListener.java @@ -0,0 +1,56 @@ +package com.orangeforms.common.flow.listener; + +import cn.hutool.core.util.StrUtil; +import com.orangeforms.common.core.object.GlobalThreadLocal; +import com.orangeforms.common.core.util.ApplicationContextHolder; +import com.orangeforms.common.flow.constant.FlowTaskStatus; +import com.orangeforms.common.flow.model.FlowWorkOrder; +import com.orangeforms.common.flow.service.FlowWorkOrderService; +import com.orangeforms.common.flow.util.FlowCustomExtFactory; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.delegate.DelegateExecution; +import org.flowable.engine.delegate.ExecutionListener; + +/** + * 流程实例监听器,在流程实例结束的时候,需要完成一些自定义的业务行为。如: + * 1. 更新流程工单表的审批状态字段。 + * 2. 业务数据同步。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class FlowFinishedListener implements ExecutionListener { + + private final transient FlowWorkOrderService flowWorkOrderService = + ApplicationContextHolder.getBean(FlowWorkOrderService.class); + private final transient FlowCustomExtFactory flowCustomExtFactory = + ApplicationContextHolder.getBean(FlowCustomExtFactory.class); + + @Override + public void notify(DelegateExecution execution) { + if (!StrUtil.equals("end", execution.getEventName())) { + return; + } + boolean enabled = GlobalThreadLocal.setDataFilter(false); + try { + String processInstanceId = execution.getProcessInstanceId(); + FlowWorkOrder workOrder = flowWorkOrderService.getFlowWorkOrderByProcessInstanceId(processInstanceId); + if (workOrder == null) { + return; + } + int flowStatus = FlowTaskStatus.FINISHED; + if (workOrder.getFlowStatus().equals(FlowTaskStatus.CANCELLED) + || workOrder.getFlowStatus().equals(FlowTaskStatus.STOPPED)) { + flowStatus = workOrder.getFlowStatus(); + } + workOrder.setFlowStatus(flowStatus); + // 更新流程工单中的流程状态。 + flowWorkOrderService.updateFlowStatusByProcessInstanceId(processInstanceId, flowStatus); + // 处理在线表单工作流的自定义状态更新。 + flowCustomExtFactory.getOnlineBusinessDataExtHelper().updateFlowStatus(workOrder); + } finally { + GlobalThreadLocal.setDataFilter(enabled); + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/FlowTaskNotifyListener.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/FlowTaskNotifyListener.java new file mode 100644 index 00000000..ba8e09ad --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/FlowTaskNotifyListener.java @@ -0,0 +1,80 @@ +package com.orangeforms.common.flow.listener; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.orangeforms.common.core.util.ApplicationContextHolder; +import com.orangeforms.common.flow.constant.FlowConstant; +import com.orangeforms.common.flow.model.FlowTaskExt; +import com.orangeforms.common.flow.object.FlowUserTaskExtData; +import com.orangeforms.common.flow.service.FlowApiService; +import com.orangeforms.common.flow.service.FlowTaskExtService; +import com.orangeforms.common.flow.util.BaseFlowNotifyExtHelper; +import com.orangeforms.common.flow.util.FlowCustomExtFactory; +import com.orangeforms.common.flow.vo.FlowTaskVo; +import com.orangeforms.common.flow.vo.FlowUserInfoVo; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.delegate.TaskListener; +import org.flowable.engine.runtime.ProcessInstance; +import org.flowable.task.api.Task; +import org.flowable.task.service.delegate.DelegateTask; + +import java.util.List; + +/** + * 任务进入待办状态时的通知监听器。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class FlowTaskNotifyListener implements TaskListener { + + private final transient FlowTaskExtService flowTaskExtService = + ApplicationContextHolder.getBean(FlowTaskExtService.class); + private final transient FlowApiService flowApiService = + ApplicationContextHolder.getBean(FlowApiService.class); + private final transient FlowCustomExtFactory flowCustomExtFactory = + ApplicationContextHolder.getBean(FlowCustomExtFactory.class); + + @Override + public void notify(DelegateTask delegateTask) { + String definitionId = delegateTask.getProcessDefinitionId(); + String instanceId = delegateTask.getProcessInstanceId(); + String taskId = delegateTask.getId(); + String taskKey = delegateTask.getTaskDefinitionKey(); + FlowTaskExt taskExt = flowTaskExtService.getByProcessDefinitionIdAndTaskId(definitionId, taskKey); + if (StrUtil.isBlank(taskExt.getExtraDataJson())) { + return; + } + FlowUserTaskExtData extData = JSON.parseObject(taskExt.getExtraDataJson(), FlowUserTaskExtData.class); + if (CollUtil.isEmpty(extData.getFlowNotifyTypeList())) { + return; + } + ProcessInstance instance = flowApiService.getProcessInstance(instanceId); + Object initiator = flowApiService.getProcessInstanceVariable(instanceId, FlowConstant.PROC_INSTANCE_INITIATOR_VAR); + boolean isMultiInstanceTask = flowApiService.isMultiInstanceTask(definitionId, taskKey); + Task task = flowApiService.getProcessInstanceActiveTask(instanceId, taskId); + List userInfoList = + flowTaskExtService.getCandidateUserInfoList(instanceId, taskExt, task, isMultiInstanceTask, false); + if (CollUtil.isEmpty(userInfoList)) { + log.warn("ProcessDefinition [{}] Task [{}] don't find the candidate users for notification.", + instance.getProcessDefinitionName(), task.getName()); + return; + } + BaseFlowNotifyExtHelper helper = flowCustomExtFactory.getFlowNotifyExtHelper(); + Assert.notNull(helper); + for (String notifyType : extData.getFlowNotifyTypeList()) { + FlowTaskVo flowTaskVo = new FlowTaskVo(); + flowTaskVo.setProcessDefinitionId(definitionId); + flowTaskVo.setProcessInstanceId(instanceId); + flowTaskVo.setTaskKey(taskKey); + flowTaskVo.setTaskName(delegateTask.getName()); + flowTaskVo.setTaskId(delegateTask.getId()); + flowTaskVo.setBusinessKey(instance.getBusinessKey()); + flowTaskVo.setProcessInstanceInitiator(initiator.toString()); + helper.doNotify(notifyType, userInfoList, flowTaskVo); + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/FlowUserTaskListener.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/FlowUserTaskListener.java new file mode 100644 index 00000000..6760fcc4 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/FlowUserTaskListener.java @@ -0,0 +1,32 @@ +package com.orangeforms.common.flow.listener; + +import com.orangeforms.common.core.util.ApplicationContextHolder; +import com.orangeforms.common.flow.constant.FlowConstant; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.RuntimeService; +import org.flowable.engine.delegate.TaskListener; +import org.flowable.task.service.delegate.DelegateTask; + +import java.util.Map; + +/** + * 流程任务通用监听器。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class FlowUserTaskListener implements TaskListener { + + private final transient RuntimeService runtimeService = + ApplicationContextHolder.getBean(RuntimeService.class); + + @Override + public void notify(DelegateTask delegateTask) { + Map variables = delegateTask.getVariables(); + if (variables.get(FlowConstant.DELEGATE_ASSIGNEE_VAR) != null) { + delegateTask.setAssignee(variables.get(FlowConstant.DELEGATE_ASSIGNEE_VAR).toString()); + runtimeService.removeVariableLocal(delegateTask.getExecutionId(), FlowConstant.DELEGATE_ASSIGNEE_VAR); + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/UpDeptPostLeaderListener.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/UpDeptPostLeaderListener.java new file mode 100644 index 00000000..f29d6cbb --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/UpDeptPostLeaderListener.java @@ -0,0 +1,27 @@ +package com.orangeforms.common.flow.listener; + +import com.orangeforms.common.flow.constant.FlowConstant; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.delegate.TaskListener; +import org.flowable.task.service.delegate.DelegateTask; + +import java.util.Map; + +/** + * 当用户任务的候选组为上级部门领导岗位时,该监听器会在任务创建时,获取当前流程实例发起人的部门领导。 + * 并将其指派为当前任务的候选组。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class UpDeptPostLeaderListener implements TaskListener { + + @Override + public void notify(DelegateTask delegateTask) { + Map variables = delegateTask.getVariables(); + if (variables.get(FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER_VAR) == null) { + delegateTask.setAssignee(variables.get(FlowConstant.PROC_INSTANCE_START_USER_NAME_VAR).toString()); + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/UpdateLatestApprovalStatusListener.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/UpdateLatestApprovalStatusListener.java new file mode 100644 index 00000000..4b7144da --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/listener/UpdateLatestApprovalStatusListener.java @@ -0,0 +1,44 @@ +package com.orangeforms.common.flow.listener; + +import cn.hutool.core.util.StrUtil; +import com.orangeforms.common.core.util.ApplicationContextHolder; +import com.orangeforms.common.flow.model.FlowWorkOrder; +import com.orangeforms.common.flow.service.FlowWorkOrderService; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.delegate.DelegateExecution; +import org.flowable.engine.delegate.ExecutionListener; +import org.flowable.engine.impl.el.FixedValue; + +/** + * 更新流程的最后审批状态的监听器,目前用于排他网关到任务结束节点的连线上, + * 以便于准确的判断流程实例的最后审批状态。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class UpdateLatestApprovalStatusListener implements ExecutionListener { + + private FixedValue latestApprovalStatus; + + private final transient FlowWorkOrderService flowWorkOrderService = + ApplicationContextHolder.getBean(FlowWorkOrderService.class); + + public void setAutoStoreVariablesExp(FixedValue approvalStatus) { + this.latestApprovalStatus = approvalStatus; + } + + @Override + public void notify(DelegateExecution execution) { + if (StrUtil.isNotBlank(latestApprovalStatus.getExpressionText())) { + FlowWorkOrder workOrder = + flowWorkOrderService.getFlowWorkOrderByProcessInstanceId(execution.getProcessInstanceId()); + if (workOrder == null) { + return; + } + Integer approvalStatus = Integer.valueOf(latestApprovalStatus.getExpressionText()); + String processInstanceId = execution.getProcessInstanceId(); + flowWorkOrderService.updateLatestApprovalStatusByProcessInstanceId(processInstanceId, approvalStatus); + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowCategory.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowCategory.java new file mode 100644 index 00000000..9529dab1 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowCategory.java @@ -0,0 +1,77 @@ +package com.orangeforms.common.flow.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +import java.util.Date; + +/** + * 流程分类的实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_flow_category") +public class FlowCategory { + + /** + * 主键Id。 + */ + @TableId(value = "category_id") + private Long categoryId; + + /** + * 租户Id。 + */ + @TableField(value = "tenant_id") + private Long tenantId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @TableField(value = "app_code") + private String appCode; + + /** + * 显示名称。 + */ + @TableField(value = "name") + private String name; + + /** + * 分类编码。 + */ + @TableField(value = "code") + private String code; + + /** + * 实现顺序。 + */ + @TableField(value = "show_order") + private Integer showOrder; + + /** + * 更新时间。 + */ + @TableField(value = "update_time") + private Date updateTime; + + /** + * 更新者Id。 + */ + @TableField(value = "update_user_id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @TableField(value = "create_time") + private Date createTime; + + /** + * 创建者Id。 + */ + @TableField(value = "create_user_id") + private Long createUserId; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntry.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntry.java new file mode 100644 index 00000000..6510c1c6 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntry.java @@ -0,0 +1,154 @@ +package com.orangeforms.common.flow.model; + +import com.baomidou.mybatisplus.annotation.*; +import com.orangeforms.common.core.annotation.RelationOneToOne; +import lombok.Data; + +import java.util.Date; + +/** + * 流程的实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_flow_entry") +public class FlowEntry { + + /** + * 主键。 + */ + @TableId(value = "entry_id") + private Long entryId; + + /** + * 租户Id。 + */ + @TableField(value = "tenant_id") + private Long tenantId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @TableField(value = "app_code") + private String appCode; + + /** + * 流程名称。 + */ + @TableField(value = "process_definition_name") + private String processDefinitionName; + + /** + * 流程标识Key。 + */ + @TableField(value = "process_definition_key") + private String processDefinitionKey; + + /** + * 流程分类。 + */ + @TableField(value = "category_id") + private Long categoryId; + + /** + * 工作流部署的发布主版本Id。 + */ + @TableField(value = "main_entry_publish_id") + private Long mainEntryPublishId; + + /** + * 最新发布时间。 + */ + @TableField(value = "latest_publish_time") + private Date latestPublishTime; + + /** + * 流程状态。 + */ + @TableField(value = "status") + private Integer status; + + /** + * 流程定义的xml。 + */ + @TableField(value = "bpmn_xml") + private String bpmnXml; + + /** + * 流程图类型。0: 普通流程图,1: 钉钉风格的流程图。 + */ + @TableField(value = "diagram_type") + private Integer diagramType; + + /** + * 绑定表单类型。 + */ + @TableField(value = "bind_form_type") + private Integer bindFormType; + + /** + * 在线表单的页面Id。 + */ + @TableField(value = "page_id") + private Long pageId; + + /** + * 在线表单Id。 + */ + @TableField(value = "default_form_id") + private Long defaultFormId; + + /** + * 静态表单的缺省路由名称。 + */ + @TableField(value = "default_router_name") + private String defaultRouterName; + + /** + * 工单表编码字段的编码规则,如果为空则不计算工单编码。 + */ + @TableField(value = "encoded_rule") + private String encodedRule; + + /** + * 流程的自定义扩展数据(JSON格式)。 + */ + @TableField(value = "extension_data") + private String extensionData; + + /** + * 更新时间。 + */ + @TableField(value = "update_time") + private Date updateTime; + + /** + * 更新者Id。 + */ + @TableField(value = "update_user_id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @TableField(value = "create_time") + private Date createTime; + + /** + * 创建者Id。 + */ + @TableField(value = "create_user_id") + private Long createUserId; + + @TableField(exist = false) + private FlowEntryPublish mainFlowEntryPublish; + + @RelationOneToOne( + masterIdField = "categoryId", + slaveModelClass = FlowCategory.class, + slaveIdField = "categoryId") + @TableField(exist = false) + private FlowCategory flowCategory; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntryPublish.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntryPublish.java new file mode 100644 index 00000000..def7bfdc --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntryPublish.java @@ -0,0 +1,89 @@ +package com.orangeforms.common.flow.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +import java.util.Date; + +/** + * 流程发布数据的实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_flow_entry_publish") +public class FlowEntryPublish { + + /** + * 主键Id。 + */ + @TableId(value = "entry_publish_id") + private Long entryPublishId; + + /** + * 流程Id。 + */ + @TableField(value = "entry_id") + private Long entryId; + + /** + * 流程引擎的部署Id。 + */ + @TableField(value = "deploy_id") + private String deployId; + + /** + * 流程引擎中的流程定义Id。 + */ + @TableField(value = "process_definition_id") + private String processDefinitionId; + + /** + * 发布版本。 + */ + @TableField(value = "publish_version") + private Integer publishVersion; + + /** + * 激活状态。 + */ + @TableField(value = "active_status") + private Boolean activeStatus; + + /** + * 是否为主版本。 + */ + @TableField(value = "main_version") + private Boolean mainVersion; + + /** + * 创建者Id。 + */ + @TableField(value = "create_user_id") + private Long createUserId; + + /** + * 发布时间。 + */ + @TableField(value = "publish_time") + private Date publishTime; + + /** + * 第一个非开始节点任务的附加信息。 + */ + @TableField(value = "init_task_info") + private String initTaskInfo; + + /** + * 分析后的节点JSON信息。 + */ + @TableField(value = "analyzed_node_json") + private String analyzedNodeJson; + + /** + * 流程的自定义扩展数据(JSON格式)。 + */ + @TableField(value = "extension_data") + private String extensionData; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntryPublishVariable.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntryPublishVariable.java new file mode 100644 index 00000000..be7965ec --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntryPublishVariable.java @@ -0,0 +1,69 @@ +package com.orangeforms.common.flow.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +/** + * FlowEntryPublishVariable实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_flow_entry_publish_variable") +public class FlowEntryPublishVariable { + + /** + * 主键Id。 + */ + @TableId(value = "variable_id") + private Long variableId; + + /** + * 流程Id。 + */ + @TableField(value = "entry_publish_id") + private Long entryPublishId; + + /** + * 变量名。 + */ + @TableField(value = "variable_name") + private String variableName; + + /** + * 显示名。 + */ + @TableField(value = "show_name") + private String showName; + + /** + * 变量类型。 + */ + @TableField(value = "variable_type") + private Integer variableType; + + /** + * 是否内置。 + */ + @TableField(value = "builtin") + private Boolean builtin; + + /** + * 绑定数据源Id。 + */ + @TableField(value = "bind_datasource_id") + private Long bindDatasourceId; + + /** + * 绑定数据源关联Id。 + */ + @TableField(value = "bind_relation_id") + private Long bindRelationId; + + /** + * 绑定字段Id。 + */ + @TableField(value = "bind_column_id") + private Long bindColumnId; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntryVariable.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntryVariable.java new file mode 100644 index 00000000..bbb8df66 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowEntryVariable.java @@ -0,0 +1,77 @@ +package com.orangeforms.common.flow.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +import java.util.Date; + +/** + * 流程变量实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_flow_entry_variable") +public class FlowEntryVariable { + + /** + * 主键Id。 + */ + @TableId(value = "variable_id") + private Long variableId; + + /** + * 流程Id。 + */ + @TableField(value = "entry_id") + private Long entryId; + + /** + * 变量名。 + */ + @TableField(value = "variable_name") + private String variableName; + + /** + * 显示名。 + */ + @TableField(value = "show_name") + private String showName; + + /** + * 流程变量类型。 + */ + @TableField(value = "variable_type") + private Integer variableType; + + /** + * 绑定数据源Id。 + */ + @TableField(value = "bind_datasource_id") + private Long bindDatasourceId; + + /** + * 绑定数据源关联Id。 + */ + @TableField(value = "bind_relation_id") + private Long bindRelationId; + + /** + * 绑定字段Id。 + */ + @TableField(value = "bind_column_id") + private Long bindColumnId; + + /** + * 是否内置。 + */ + @TableField(value = "builtin") + private Boolean builtin; + + /** + * 创建时间。 + */ + @TableField(value = "create_time") + private Date createTime; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMessage.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMessage.java new file mode 100644 index 00000000..e466ec36 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMessage.java @@ -0,0 +1,167 @@ +package com.orangeforms.common.flow.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +import java.util.Date; + +/** + * 工作流通知消息实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_flow_message") +public class FlowMessage { + + /** + * 主键Id。 + */ + @TableId(value = "message_id") + private Long messageId; + + /** + * 租户Id。 + */ + @TableField(value = "tenant_id") + private Long tenantId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @TableField(value = "app_code") + private String appCode; + + /** + * 消息类型。 + */ + @TableField(value = "message_type") + private Integer messageType; + + /** + * 消息内容。 + */ + @TableField(value = "message_content") + private String messageContent; + + /** + * 催办次数。 + */ + @TableField(value = "remind_count") + private Integer remindCount; + + /** + * 工单Id。 + */ + @TableField(value = "work_order_id") + private Long workOrderId; + + /** + * 流程定义Id。 + */ + @TableField(value = "process_definition_id") + private String processDefinitionId; + + /** + * 流程定义标识。 + */ + @TableField(value = "process_definition_key") + private String processDefinitionKey; + + /** + * 流程名称。 + */ + @TableField(value = "process_definition_name") + private String processDefinitionName; + + /** + * 流程实例Id。 + */ + @TableField(value = "process_instance_id") + private String processInstanceId; + + /** + * 流程实例发起者。 + */ + @TableField(value = "process_instance_initiator") + private String processInstanceInitiator; + + /** + * 流程任务Id。 + */ + @TableField(value = "task_id") + private String taskId; + + /** + * 流程任务定义标识。 + */ + @TableField(value = "task_definition_key") + private String taskDefinitionKey; + + /** + * 流程任务名称。 + */ + @TableField(value = "task_name") + private String taskName; + + /** + * 创建时间。 + */ + @TableField(value = "task_start_time") + private Date taskStartTime; + + /** + * 任务指派人登录名。 + */ + @TableField(value = "task_assignee") + private String taskAssignee; + + /** + * 任务是否已完成。 + */ + @TableField(value = "task_finished") + private Boolean taskFinished; + + /** + * 业务数据快照。 + */ + @TableField(value = "business_data_shot") + private String businessDataShot; + + /** + * 是否为在线表单消息数据。 + */ + @TableField(value = "online_form_data") + private Boolean onlineFormData; + + /** + * 更新时间。 + */ + @TableField(value = "update_time") + private Date updateTime; + + /** + * 更新者Id。 + */ + @TableField(value = "update_user_id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @TableField(value = "create_time") + private Date createTime; + + /** + * 创建者Id。 + */ + @TableField(value = "create_user_id") + private Long createUserId; + + /** + * 创建者显示名。 + */ + @TableField(value = "create_username") + private String createUsername; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMessageCandidateIdentity.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMessageCandidateIdentity.java new file mode 100644 index 00000000..75cdb858 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMessageCandidateIdentity.java @@ -0,0 +1,39 @@ +package com.orangeforms.common.flow.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +/** + * 流程任务消息的候选身份实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_flow_msg_candidate_identity") +public class FlowMessageCandidateIdentity { + + /** + * 主键Id。 + */ + @TableId(value = "id") + private Long id; + + /** + * 任务消息Id。 + */ + @TableField(value = "message_id") + private Long messageId; + + /** + * 候选身份类型。 + */ + @TableField(value = "candidate_type") + private String candidateType; + + /** + * 候选身份Id。 + */ + @TableField(value = "candidate_id") + private String candidateId; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMessageIdentityOperation.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMessageIdentityOperation.java new file mode 100644 index 00000000..9dc9a78c --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMessageIdentityOperation.java @@ -0,0 +1,48 @@ +package com.orangeforms.common.flow.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +import java.util.Date; + +/** + * 流程任务消息所属用户的操作表。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_flow_msg_identity_operation") +public class FlowMessageIdentityOperation { + + /** + * 主键Id。 + */ + @TableId(value = "id") + private Long id; + + /** + * 任务消息Id。 + */ + @TableField(value = "message_id") + private Long messageId; + + /** + * 用户登录名。 + */ + @TableField(value = "login_name") + private String loginName; + + /** + * 操作类型。 + * 常量值参考FlowMessageOperationType对象。 + */ + @TableField(value = "operation_type") + private Integer operationType; + + /** + * 操作时间。 + */ + @TableField(value = "operation_time") + private Date operationTime; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMultiInstanceTrans.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMultiInstanceTrans.java new file mode 100644 index 00000000..fe2f18a2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowMultiInstanceTrans.java @@ -0,0 +1,97 @@ +package com.orangeforms.common.flow.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.flowable.task.api.TaskInfo; + +import java.util.Date; + +/** + * 流程多实例任务执行流水对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@NoArgsConstructor +@TableName(value = "zz_flow_multi_instance_trans") +public class FlowMultiInstanceTrans { + + /** + * 主键Id。 + */ + @TableId(value = "id") + private Long id; + + /** + * 流程实例Id。 + */ + @TableField(value = "process_instance_id") + private String processInstanceId; + + /** + * 任务Id。 + */ + @TableField(value = "task_id") + private String taskId; + + /** + * 任务标识。 + */ + @TableField(value = "task_key") + private String taskKey; + + /** + * 会签任务的执行Id。 + */ + @TableField(value = "multi_instance_exec_id") + private String multiInstanceExecId; + + /** + * 任务的执行Id。 + */ + @TableField(value = "execution_id") + private String executionId; + + /** + * 会签指派人列表。 + */ + @TableField(value = "assignee_list") + private String assigneeList; + + /** + * 创建者Id。 + */ + @TableField(value = "create_user_id") + private Long createUserId; + + /** + * 创建者登录名。 + */ + @TableField(value = "create_login_name") + private String createLoginName; + + /** + * 创建者显示名。 + */ + @TableField(value = "create_username") + private String createUsername; + + /** + * 创建时间。 + */ + @TableField(value = "create_time") + private Date createTime; + + public FlowMultiInstanceTrans(TaskInfo task) { + this.fillWith(task); + } + + public void fillWith(TaskInfo task) { + this.taskId = task.getId(); + this.taskKey = task.getTaskDefinitionKey(); + this.processInstanceId = task.getProcessInstanceId(); + this.executionId = task.getExecutionId(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowTaskComment.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowTaskComment.java new file mode 100644 index 00000000..d6959dfc --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowTaskComment.java @@ -0,0 +1,150 @@ +package com.orangeforms.common.flow.model; + +import com.baomidou.mybatisplus.annotation.*; +import com.orangeforms.common.core.util.ContextUtil; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.flowable.task.api.TaskInfo; + +import java.util.Date; + +/** + * FlowTaskComment实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@NoArgsConstructor +@TableName(value = "zz_flow_task_comment") +public class FlowTaskComment { + + /** + * 主键Id。 + */ + @TableId(value = "id") + private Long id; + + /** + * 流程实例Id。 + */ + @TableField(value = "process_instance_id") + private String processInstanceId; + + /** + * 任务Id。 + */ + @TableField(value = "task_id") + private String taskId; + + /** + * 任务标识。 + */ + @TableField(value = "task_key") + private String taskKey; + + /** + * 任务名称。 + */ + @TableField(value = "task_name") + private String taskName; + + /** + * 用于驳回和自由跳的目标任务标识。 + */ + @TableField(value = "target_task_key") + private String targetTaskKey; + + /** + * 任务的执行Id。 + */ + @TableField(value = "execution_id") + private String executionId; + + /** + * 会签任务的执行Id。 + */ + @TableField(value = "multi_instance_exec_id") + private String multiInstanceExecId; + + /** + * 审批类型。 + */ + @TableField(value = "approval_type") + private String approvalType; + + /** + * 批注内容。 + */ + @TableField(value = "task_comment") + private String taskComment; + + /** + * 委托指定人,比如加签、转办等。 + */ + @TableField(value = "delegate_assignee") + private String delegateAssignee; + + /** + * 自定义数据。开发者可自行扩展,推荐使用JSON格式数据。 + */ + @TableField(value = "custom_business_data") + private String customBusinessData; + + /** + * 审批人头像。 + */ + @TableField(value = "head_image_url") + private String headImageUrl; + + /** + * 创建者Id。 + */ + @TableField(value = "create_user_id") + private Long createUserId; + + /** + * 创建者登录名。 + */ + @TableField(value = "create_login_name") + private String createLoginName; + + /** + * 创建者显示名。 + */ + @TableField(value = "create_username") + private String createUsername; + + /** + * 创建时间。 + */ + @TableField(value = "create_time") + private Date createTime; + + private static final String REQ_ATTRIBUTE_KEY = "flowTaskComment"; + + public FlowTaskComment(TaskInfo task) { + this.fillWith(task); + } + + public static void setToRequest(FlowTaskComment comment) { + if (ContextUtil.getHttpRequest() != null) { + ContextUtil.getHttpRequest().setAttribute(REQ_ATTRIBUTE_KEY, comment); + } + } + + public static FlowTaskComment getFromRequest() { + if (ContextUtil.getHttpRequest() == null) { + return null; + } + return (FlowTaskComment) ContextUtil.getHttpRequest().getAttribute(REQ_ATTRIBUTE_KEY); + } + + public void fillWith(TaskInfo task) { + this.taskId = task.getId(); + this.taskKey = task.getTaskDefinitionKey(); + this.taskName = task.getName(); + this.processInstanceId = task.getProcessInstanceId(); + this.executionId = task.getExecutionId(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowTaskExt.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowTaskExt.java new file mode 100644 index 00000000..725c9ac0 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowTaskExt.java @@ -0,0 +1,87 @@ +package com.orangeforms.common.flow.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +/** + * 流程任务扩展实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_flow_task_ext") +public class FlowTaskExt { + + /** + * 流程引擎的定义Id。 + */ + @TableField(value = "process_definition_id") + private String processDefinitionId; + + /** + * 流程引擎任务Id。 + */ + @TableField(value = "task_id") + private String taskId; + + /** + * 操作列表JSON。 + */ + @TableField(value = "operation_list_json") + private String operationListJson; + + /** + * 变量列表JSON。 + */ + @TableField(value = "variable_list_json") + private String variableListJson; + + /** + * 存储多实例的assigneeList的JSON。 + */ + @TableField(value = "assignee_list_json") + private String assigneeListJson; + + /** + * 分组类型。 + */ + @TableField(value = "group_type") + private String groupType; + + /** + * 保存岗位相关的数据。 + */ + @TableField(value = "dept_post_list_json") + private String deptPostListJson; + + /** + * 逗号分隔的角色Id。 + */ + @TableField(value = "role_ids") + private String roleIds; + + /** + * 逗号分隔的部门Id。 + */ + @TableField(value = "dept_ids") + private String deptIds; + + /** + * 逗号分隔候选用户名。 + */ + @TableField(value = "candidate_usernames") + private String candidateUsernames; + + /** + * 抄送相关的数据。 + */ + @TableField(value = "copy_list_json") + private String copyListJson; + + /** + * 用户任务的扩展属性,存储为JSON的字符串格式。 + */ + @TableField(value = "extra_data_json") + private String extraDataJson; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowWorkOrder.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowWorkOrder.java new file mode 100644 index 00000000..1ac6fcfe --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowWorkOrder.java @@ -0,0 +1,163 @@ +package com.orangeforms.common.flow.model; + +import com.baomidou.mybatisplus.annotation.*; +import com.orangeforms.common.core.annotation.DeptFilterColumn; +import com.orangeforms.common.core.annotation.UserFilterColumn; +import com.orangeforms.common.core.annotation.RelationConstDict; +import com.orangeforms.common.flow.constant.FlowTaskStatus; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 工作流工单实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_flow_work_order") +public class FlowWorkOrder { + + /** + * 主键Id。 + */ + @TableId(value = "work_order_id") + private Long workOrderId; + + /** + * 租户Id。 + */ + @TableField(value = "tenant_id") + private Long tenantId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @TableField(value = "app_code") + private String appCode; + + /** + * 工单编码字段。 + */ + @TableField(value = "work_order_code") + private String workOrderCode; + + /** + * 流程定义标识。 + */ + @TableField(value = "process_definition_key") + private String processDefinitionKey; + + /** + * 流程名称。 + */ + @TableField(value = "process_definition_name") + private String processDefinitionName; + + /** + * 流程引擎的定义Id。 + */ + @TableField(value = "process_definition_id") + private String processDefinitionId; + + /** + * 流程实例Id。 + */ + @TableField(value = "process_instance_id") + private String processInstanceId; + + /** + * 在线表单的主表Id。 + */ + @TableField(value = "online_table_id") + private Long onlineTableId; + + /** + * 静态表单所使用的数据表名。 + */ + @TableField(value = "table_name") + private String tableName; + + /** + * 业务主键值。 + */ + @TableField(value = "business_key") + private String businessKey; + + /** + * 最近的审批状态。 + */ + @TableField(value = "latest_approval_status") + private Integer latestApprovalStatus; + + /** + * 流程状态。参考FlowTaskStatus常量值对象。 + */ + @TableField(value = "flow_status") + private Integer flowStatus; + + /** + * 提交用户登录名称。 + */ + @TableField(value = "submit_username") + private String submitUsername; + + /** + * 提交用户所在部门Id。 + */ + @DeptFilterColumn + @TableField(value = "dept_id") + private Long deptId; + + /** + * 更新时间。 + */ + @TableField(value = "update_time") + private Date updateTime; + + /** + * 更新者Id。 + */ + @TableField(value = "update_user_id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @TableField(value = "create_time") + private Date createTime; + + /** + * 创建者Id。 + */ + @UserFilterColumn + @TableField(value = "create_user_id") + private Long createUserId; + + /** + * 逻辑删除标记字段(1: 正常 -1: 已删除)。 + */ + @TableLogic + @TableField(value = "deleted_flag") + private Integer deletedFlag; + + /** + * createTime 范围过滤起始值(>=)。 + */ + @TableField(exist = false) + private String createTimeStart; + + /** + * createTime 范围过滤结束值(<=)。 + */ + @TableField(exist = false) + private String createTimeEnd; + + @RelationConstDict( + masterIdField = "flowStatus", + constantDictClass = FlowTaskStatus.class) + @TableField(exist = false) + private Map flowStatusDictMap; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowWorkOrderExt.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowWorkOrderExt.java new file mode 100644 index 00000000..ef0f515a --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/FlowWorkOrderExt.java @@ -0,0 +1,72 @@ +package com.orangeforms.common.flow.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +import java.util.Date; + +/** + * 工作流工单扩展数据实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_flow_work_order_ext") +public class FlowWorkOrderExt { + + /** + * 主键Id。 + */ + @TableId(value = "id") + private Long id; + + /** + * 流程工单Id。 + */ + @TableField(value = "work_order_id") + private Long workOrderId; + + /** + * 草稿数据。 + */ + @TableField(value = "draft_data") + private String draftData; + + /** + * 业务数据。 + */ + @TableField(value = "business_data") + private String businessData; + + /** + * 更新时间。 + */ + @TableField(value = "update_time") + private Date updateTime; + + /** + * 更新者Id。 + */ + @TableField(value = "update_user_id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @TableField(value = "create_time") + private Date createTime; + + /** + * 创建者Id。 + */ + @TableField(value = "create_user_id") + private Long createUserId; + + /** + * 逻辑删除标记字段(1: 正常 -1: 已删除)。 + */ + @TableLogic + @TableField(value = "deleted_flag") + private Integer deletedFlag; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowBindFormType.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowBindFormType.java new file mode 100644 index 00000000..37de6e36 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowBindFormType.java @@ -0,0 +1,44 @@ +package com.orangeforms.common.flow.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 工作流绑定表单类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FlowBindFormType { + + /** + * 在线表单。 + */ + public static final int ONLINE_FORM = 0; + /** + * 路由表单。 + */ + public static final int ROUTER_FORM = 1; + + private static final Map DICT_MAP = new HashMap<>(2); + static { + DICT_MAP.put(ONLINE_FORM, "在线表单"); + DICT_MAP.put(ROUTER_FORM, "路由表单"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowBindFormType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowEntryStatus.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowEntryStatus.java new file mode 100644 index 00000000..826e9895 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowEntryStatus.java @@ -0,0 +1,44 @@ +package com.orangeforms.common.flow.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 工作流状态。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FlowEntryStatus { + + /** + * 未发布。 + */ + public static final int UNPUBLISHED = 0; + /** + * 已发布。 + */ + public static final int PUBLISHED = 1; + + private static final Map DICT_MAP = new HashMap<>(2); + static { + DICT_MAP.put(UNPUBLISHED, "未发布"); + DICT_MAP.put(PUBLISHED, "已发布"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowEntryStatus() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowMessageOperationType.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowMessageOperationType.java new file mode 100644 index 00000000..6bd62cfd --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowMessageOperationType.java @@ -0,0 +1,21 @@ +package com.orangeforms.common.flow.model.constant; + +/** + * 工作流消息操作类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FlowMessageOperationType { + + /** + * 已读操作。 + */ + public static final int READ_FINISHED = 0; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowMessageOperationType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowMessageType.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowMessageType.java new file mode 100644 index 00000000..18d41da2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowMessageType.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.flow.model.constant; + +/** + * 工作流消息类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FlowMessageType { + + /** + * 催办消息。 + */ + public static final int REMIND_TYPE = 0; + + /** + * 抄送消息。 + */ + public static final int COPY_TYPE = 1; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowMessageType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowVariableType.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowVariableType.java new file mode 100644 index 00000000..f68f49ad --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/model/constant/FlowVariableType.java @@ -0,0 +1,44 @@ +package com.orangeforms.common.flow.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 流程变量类型。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FlowVariableType { + + /** + * 流程实例变量。 + */ + public static final int INSTANCE = 0; + /** + * 任务变量。 + */ + public static final int TASK = 1; + + private static final Map DICT_MAP = new HashMap<>(2); + static { + DICT_MAP.put(INSTANCE, "流程实例变量"); + DICT_MAP.put(TASK, "任务变量"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowVariableType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowElementExtProperty.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowElementExtProperty.java new file mode 100644 index 00000000..a3277c29 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowElementExtProperty.java @@ -0,0 +1,18 @@ +package com.orangeforms.common.flow.object; + +import lombok.Data; + +/** + * 流程任务的扩展属性。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class FlowElementExtProperty { + + /** + * 最近的审批状态,该值目前仅仅用于流程线元素,即SequenceElement。 + */ + private Integer latestApprovalStatus; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowEntryExtensionData.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowEntryExtensionData.java new file mode 100644 index 00000000..fec564d5 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowEntryExtensionData.java @@ -0,0 +1,37 @@ +package com.orangeforms.common.flow.object; + +import lombok.Data; + +import java.util.List; +import java.util.Map; + +/** + * 流程扩展数据对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class FlowEntryExtensionData { + + /** + * 通知类型。 + */ + private List notifyTypes; + /** + * 流程审批状态字典数据列表。Map的key是id和name。 + */ + private List> approvalStatusDict; + /** + * 级联删除业务数据。 + */ + private Boolean cascadeDeleteBusinessData = false; + /** + * 是否支持流程复活。 + */ + private Boolean supportRevive = false; + /** + * 复活数据保留天数。0表示永久保留。 + */ + private Integer keptReviveDays = 0; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowRumtimeObject.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowRumtimeObject.java new file mode 100644 index 00000000..978284c7 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowRumtimeObject.java @@ -0,0 +1,24 @@ +package com.orangeforms.common.flow.object; + +import lombok.Data; +import org.flowable.engine.runtime.ProcessInstance; +import org.flowable.task.api.Task; + +/** + * 工作流运行时常用对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class FlowRumtimeObject { + + /** + * 运行时流程实例对象。 + */ + private ProcessInstance instance; + /** + * 运行时流程任务对象。 + */ + private Task task; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowTaskMultiSignAssign.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowTaskMultiSignAssign.java new file mode 100644 index 00000000..55c1388b --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowTaskMultiSignAssign.java @@ -0,0 +1,22 @@ +package com.orangeforms.common.flow.object; + +import lombok.Data; + +/** + * 表示多实例任务的指派人信息。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class FlowTaskMultiSignAssign { + + /** + * 指派人类型。参考常量类 UserFilterGroup。 + */ + private String assigneeType; + /** + * 逗号分隔的指派人列表。 + */ + private String assigneeList; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowTaskOperation.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowTaskOperation.java new file mode 100644 index 00000000..8ad86d88 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowTaskOperation.java @@ -0,0 +1,38 @@ +package com.orangeforms.common.flow.object; + +import lombok.Data; + +/** + * 流程图中的用户任务操作数据。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class FlowTaskOperation { + + /** + * 操作Id。 + */ + private String id; + /** + * 操作的标签名。 + */ + private String label; + /** + * 操作类型。 + */ + private String type; + /** + * 显示顺序。 + */ + private Integer showOrder; + /** + * 最后审批状态。 + */ + private Integer latestApprovalStatus; + /** + * 在流程图中定义的多实例会签的指定人员信息。 + */ + private FlowTaskMultiSignAssign multiSignAssignee; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowTaskPostCandidateGroup.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowTaskPostCandidateGroup.java new file mode 100644 index 00000000..5e954d8f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowTaskPostCandidateGroup.java @@ -0,0 +1,64 @@ +package com.orangeforms.common.flow.object; + +import com.orangeforms.common.flow.constant.FlowConstant; +import lombok.Data; + +import java.util.LinkedList; +import java.util.List; + +/** + * 流程任务岗位候选组数据。仅用于流程任务的候选组类型为岗位时。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class FlowTaskPostCandidateGroup { + + /** + * 唯一值,目前仅前端使用。 + */ + private String id; + /** + * 岗位类型。 + * 1. 所有部门岗位审批变量,值为 (allDeptPost)。 + * 2. 本部门岗位审批变量,值为 (selfDeptPost)。 + * 3. 上级部门岗位审批变量,值为 (upDeptPost)。 + * 4. 任意部门关联的岗位审批变量,值为 (deptPost)。 + */ + private String type; + /** + * 岗位Id。type为(1,2,3)时使用该值。 + */ + private String postId; + /** + * 部门岗位Id。type为(4)时使用该值。 + */ + private String deptPostId; + + public static List buildCandidateGroupList(List groupDataList) { + List candidateGroupList = new LinkedList<>(); + for (FlowTaskPostCandidateGroup groupData : groupDataList) { + switch (groupData.getType()) { + case FlowConstant.GROUP_TYPE_ALL_DEPT_POST_VAR: + candidateGroupList.add(groupData.getPostId()); + break; + case FlowConstant.GROUP_TYPE_DEPT_POST_VAR: + candidateGroupList.add(groupData.getDeptPostId()); + break; + case FlowConstant.GROUP_TYPE_SELF_DEPT_POST_VAR: + candidateGroupList.add("${" + FlowConstant.SELF_DEPT_POST_PREFIX + groupData.getPostId() + "}"); + break; + case FlowConstant.GROUP_TYPE_SIBLING_DEPT_POST_VAR: + candidateGroupList.add("${" + FlowConstant.SIBLING_DEPT_POST_PREFIX + groupData.getPostId() + "}"); + break; + case FlowConstant.GROUP_TYPE_UP_DEPT_POST_VAR: + candidateGroupList.add("${" + FlowConstant.UP_DEPT_POST_PREFIX + groupData.getPostId() + "}"); + break; + default: + break; + } + } + return candidateGroupList; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowUserTaskExtData.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowUserTaskExtData.java new file mode 100644 index 00000000..85d8a7a3 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/object/FlowUserTaskExtData.java @@ -0,0 +1,63 @@ +package com.orangeforms.common.flow.object; + +import lombok.Data; + +import java.util.List; + +/** + * 流程用户任务扩展数据对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class FlowUserTaskExtData { + + public static final String NOTIFY_TYPE_MSG = "message"; + public static final String NOTIFY_TYPE_EMAIL = "email"; + + public static final String TIMEOUT_AUTO_COMPLETE = "autoComplete"; + public static final String TIMEOUT_SEND_MSG = "sendMessage"; + + public static final String EMPTY_USER_TO_ASSIGNEE = "toAssignee"; + public static final String EMPTY_USER_AUTO_REJECT = "autoReject"; + public static final String EMPTY_USER_AUTO_COMPLETE = "autoComplete"; + + /** + * 拒绝后再提交,走重新审批。 + */ + public static final String REJECT_TYPE_REDO = "0"; + /** + * 拒绝后再提交,直接回到驳回前的节点。 + */ + public static final String REJECT_TYPE_BACK_TO_SOURCE = "1"; + + /** + * 任务通知类型列表。 + */ + private List flowNotifyTypeList; + /** + * 拒绝后再次提交的审批类型。 + */ + private String rejectType = REJECT_TYPE_REDO; + /** + * 到期提醒的小时数(从待办任务被创建的时候开始计算)。 + */ + private Integer timeoutHours; + /** + * 任务超时的处理方式。 + */ + private String timeoutHandleWay; + /** + * 默认审批人。 + */ + private String defaultAssignee; + /** + * 空用户审批处理方式。 + */ + private String emptyUserHandleWay; + /** + * 空用户审批时设定的审批人。 + */ + private String emptyUserToAssignee; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowApiService.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowApiService.java new file mode 100644 index 00000000..892ea587 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowApiService.java @@ -0,0 +1,568 @@ +package com.orangeforms.common.flow.service; + +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.object.MyPageData; +import com.orangeforms.common.core.object.MyPageParam; +import com.orangeforms.common.core.object.Tuple2; +import com.orangeforms.common.flow.model.FlowTaskComment; +import com.orangeforms.common.flow.model.FlowTaskExt; +import com.orangeforms.common.flow.vo.FlowTaskVo; +import org.flowable.bpmn.model.BpmnModel; +import org.flowable.bpmn.model.FieldExtension; +import org.flowable.bpmn.model.FlowElement; +import org.flowable.bpmn.model.UserTask; +import org.flowable.engine.delegate.ExecutionListener; +import org.flowable.engine.delegate.TaskListener; +import org.flowable.engine.history.HistoricActivityInstance; +import org.flowable.engine.history.HistoricProcessInstance; +import org.flowable.engine.repository.ProcessDefinition; +import org.flowable.engine.runtime.ProcessInstance; +import org.flowable.task.api.Task; +import org.flowable.task.api.TaskInfo; +import org.flowable.task.api.history.HistoricTaskInstance; + +import javax.xml.stream.XMLStreamException; +import java.text.ParseException; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 流程引擎API的接口封装服务。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowApiService { + + /** + * 启动流程实例。 + * + * @param processDefinitionId 流程定义Id。 + * @param dataId 业务主键Id。 + * @return 新启动的流程实例。 + */ + ProcessInstance start(String processDefinitionId, Object dataId); + + /** + * 完成第一个用户任务。 + * + * @param processInstanceId 流程实例Id。 + * @param flowTaskComment 审批对象。 + * @param taskVariableData 流程任务的变量数据。 + * @return 新完成的任务对象。 + */ + Task takeFirstTask(String processInstanceId, FlowTaskComment flowTaskComment, JSONObject taskVariableData); + + /** + * 启动流程实例,如果当前登录用户为第一个用户任务的指派者,或者Assginee为流程启动人变量时, + * 则自动完成第一个用户任务。 + * + * @param processDefinitionId 流程定义Id。 + * @param dataId 当前流程主表的主键数据。 + * @param flowTaskComment 审批对象。 + * @param taskVariableData 流程任务的变量数据。 + * @return 新启动的流程实例。 + */ + ProcessInstance startAndTakeFirst( + String processDefinitionId, Object dataId, FlowTaskComment flowTaskComment, JSONObject taskVariableData); + + /** + * 多实例加签减签。 + * + * @param startTaskInstance 会签对象的发起任务实例。 + * @param multiInstanceActiveTask 正在执行的多实例任务对象。 + * @param newAssignees 新指派人,多个指派人之间逗号分隔。 + * @param isAdd 是否为加签。 + */ + void submitConsign(HistoricTaskInstance startTaskInstance, Task multiInstanceActiveTask, String newAssignees, boolean isAdd); + + /** + * 完成任务,同时提交审批数据。 + * + * @param task 工作流任务对象。 + * @param flowTaskComment 审批对象。 + * @param taskVariableData 流程任务的变量数据。 + */ + void completeTask(Task task, FlowTaskComment flowTaskComment, JSONObject taskVariableData); + + /** + * 判断当前登录用户是否为流程实例中的用户任务的指派人。或是候选人之一,如果是候选人则拾取该任务并成为指派人。 + * 如果都不是,就会返回具体的错误信息。 + * + * @param task 流程实例中的用户任务。 + * @return 调用结果。 + */ + CallResult verifyAssigneeOrCandidateAndClaim(Task task); + + /** + * 初始化并返回流程实例的变量Map。 + * + * @param processDefinitionId 流程定义Id。 + * @return 初始化后的流程实例变量Map。 + */ + Map initAndGetProcessInstanceVariables(String processDefinitionId); + + /** + * 判断当前登录用户是否为流程实例中的用户任务的指派人。或是候选人之一。 + * + * @param task 流程实例中的用户任务。 + * @return 是返回true,否则false。 + */ + boolean isAssigneeOrCandidate(TaskInfo task); + + /** + * 获取指定流程定义的全部流程节点。 + * + * @param processDefinitionId 流程定义Id。 + * @return 当前流程定义的全部节点集合。 + */ + Collection getProcessAllElements(String processDefinitionId); + + /** + * 判断当前登录用户是否为流程实例的发起人。 + * + * @param processInstanceId 流程实例Id。 + * @return 是返回true,否则false。 + */ + boolean isProcessInstanceStarter(String processInstanceId); + + /** + * 为流程实例设置BusinessKey。 + * + * @param processInstanceId 流程实例Id。 + * @param dataId 通常为主表的主键Id。 + */ + void setBusinessKeyForProcessInstance(String processInstanceId, Object dataId); + + /** + * 判断指定的流程实例Id是否存在。 + * + * @param processInstanceId 流程实例Id。 + * @return 存在返回true,否则false。 + */ + boolean existActiveProcessInstance(String processInstanceId); + + /** + * 获取指定的流程实例对象。 + * + * @param processInstanceId 流程实例Id。 + * @return 流程实例对象。 + */ + ProcessInstance getProcessInstance(String processInstanceId); + + /** + * 获取指定的流程实例对象。 + * + * @param processDefinitionId 流程定义Id。 + * @param businessKey 业务主键Id。 + * @return 流程实例对象。 + */ + ProcessInstance getProcessInstanceByBusinessKey(String processDefinitionId, String businessKey); + + /** + * 获取流程实例的列表。 + * + * @param processInstanceIdSet 流程实例Id集合。 + * @return 流程实例列表。 + */ + List getProcessInstanceList(Set processInstanceIdSet); + + /** + * 根据流程定义Id查询流程定义对象。 + * + * @param processDefinitionId 流程定义Id。 + * @return 流程定义对象。 + */ + ProcessDefinition getProcessDefinitionById(String processDefinitionId); + + /** + * 根据流程部署Id查询流程定义对象。 + * + * @param deployId 流程部署Id。 + * @return 流程定义对象。 + */ + ProcessDefinition getProcessDefinitionByDeployId(String deployId); + + /** + * 获取流程定义的列表。 + * + * @param processDefinitionIdSet 流程定义Id集合。 + * @return 流程定义列表。 + */ + List getProcessDefinitionList(Set processDefinitionIdSet); + + /** + * 挂起流程定义对象。 + * + * @param processDefinitionId 流程定义Id。 + */ + void suspendProcessDefinition(String processDefinitionId); + + /** + * 激活流程定义对象。 + * + * @param processDefinitionId 流程定义Id。 + */ + void activateProcessDefinition(String processDefinitionId); + + /** + * 获取指定流程定义的BpmnModel。 + * + * @param processDefinitionId 流程定义Id。 + * @return 关联的BpmnModel。 + */ + BpmnModel getBpmnModelByDefinitionId(String processDefinitionId); + + /** + * 判断任务是否为多实例任务。 + * + * @param processDefinitionId 流程定义Id。 + * @param taskKey 流程任务标识。 + * @return true为多实例,否则false。 + */ + boolean isMultiInstanceTask(String processDefinitionId, String taskKey); + + /** + * 设置流程实例的变量集合。 + * + * @param processInstanceId 流程实例Id。 + * @param variableMap 变量名。 + */ + void setProcessInstanceVariables(String processInstanceId, Map variableMap); + + /** + * 获取流程实例的变量。 + * + * @param processInstanceId 流程实例Id。 + * @param variableName 变量名。 + * @return 变量值。 + */ + Object getProcessInstanceVariable(String processInstanceId, String variableName); + + /** + * 获取指定流程实例和任务Id的当前活动任务。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 流程任务Id。 + * @return 当前流程实例的活动任务。 + */ + Task getProcessInstanceActiveTask(String processInstanceId, String taskId); + + /** + * 获取指定流程实例的当前活动任务列表。 + * + * @param processInstanceId 流程实例Id。 + * @return 当前流程实例的活动任务。 + */ + List getProcessInstanceActiveTaskList(String processInstanceId); + + /** + * 获取指定流程实例的当前活动任务列表,同时转换为流出任务视图对象列表。 + * + * @param processInstanceId 流程实例Id。 + * @return 当前流程实例的活动任务。 + */ + List getProcessInstanceActiveTaskListAndConvert(String processInstanceId); + + /** + * 根据任务Id,获取当前运行时任务。 + * + * @param taskId 任务Id。 + * @return 运行时任务对象。 + */ + Task getTaskById(String taskId); + + /** + * 获取用户的任务列表。这其中包括当前用户作为指派人和候选人。 + * + * @param username 指派人。 + * @param definitionKey 流程定义的标识。 + * @param definitionName 流程定义名。 + * @param taskName 任务名称。 + * @param pageParam 分页对象。 + * @return 用户的任务列表。 + */ + MyPageData getTaskListByUserName( + String username, String definitionKey, String definitionName, String taskName, MyPageParam pageParam); + + /** + * 获取用户的任务数量。这其中包括当前用户作为指派人和候选人。 + * + * @param username 指派人。 + * @return 用户的任务数量。 + */ + long getTaskCountByUserName(String username); + + /** + * 获取流程实例Id集合的运行时任务列表。 + * + * @param processInstanceIdSet 流程实例Id集合。 + * @return 运行时任务列表。 + */ + List getTaskListByProcessInstanceIds(List processInstanceIdSet); + + /** + * 将流程任务列表数据,转换为前端可以显示的流程对象。 + * + * @param taskList 流程引擎中的任务列表。 + * @return 前端可以显示的流程任务列表。 + */ + List convertToFlowTaskList(List taskList); + + /** + * 添加流程实例结束的监听器。 + * + * @param bpmnModel 流程模型。 + * @param listenerClazz 流程监听器的Class对象。 + */ + void addProcessInstanceEndListener(BpmnModel bpmnModel, Class listenerClazz); + + /** + * 添加流程任务的执行监听器。 + * + * @param flowElement 指定任务节点。 + * @param listenerClazz 执行监听器。 + * @param event 事件。 + * @param fieldExtensions 执行监听器的扩展变量列表。 + */ + void addExecutionListener( + FlowElement flowElement, + Class listenerClazz, + String event, + List fieldExtensions); + + /** + * 添加流程任务创建的任务监听器。 + * + * @param userTask 用户任务。 + * @param listenerClazz 任务监听器。 + */ + void addTaskCreateListener(UserTask userTask, Class listenerClazz); + + /** + * 获取流程实例的历史流程实例。 + * + * @param processInstanceId 流程实例Id。 + * @return 历史流程实例。 + */ + HistoricProcessInstance getHistoricProcessInstance(String processInstanceId); + + /** + * 获取流程实例的历史流程实例列表。 + * + * @param processInstanceIdSet 流程实例Id集合。 + * @return 历史流程实例列表。 + */ + List getHistoricProcessInstanceList(Set processInstanceIdSet); + + /** + * 查询历史流程实例的列表。 + * + * @param processDefinitionKey 流程标识名。 + * @param processDefinitionName 流程名。 + * @param startUser 流程发起用户。 + * @param beginDate 流程发起开始时间。 + * @param endDate 流程发起结束时间。 + * @param pageParam 分页对象。 + * @param finishedOnly 仅仅返回已经结束的流程。 + * @return 分页后的查询列表对象。 + * @throws ParseException 日期参数解析失败。 + */ + MyPageData getHistoricProcessInstanceList( + String processDefinitionKey, + String processDefinitionName, + String startUser, + String beginDate, + String endDate, + MyPageParam pageParam, + boolean finishedOnly) throws ParseException; + + /** + * 获取流程实例的已完成历史任务列表。 + * + * @param processInstanceId 流程实例Id。 + * @return 流程实例已完成的历史任务列表。 + */ + List getHistoricActivityInstanceList(String processInstanceId); + + /** + * 获取流程实例的已完成历史任务列表,同时按照每个活动实例的开始时间升序排序。 + * + * @param processInstanceId 流程实例Id。 + * @return 流程实例已完成的历史任务列表。 + */ + List getHistoricActivityInstanceListOrderByStartTime(String processInstanceId); + + /** + * 获取当前用户的历史已办理任务列表。 + * + * @param processDefinitionName 流程名。 + * @param beginDate 流程发起开始时间。 + * @param endDate 流程发起结束时间。 + * @param pageParam 分页对象。 + * @return 分页后的查询列表对象。 + * @throws ParseException 日期参数解析失败。 + */ + MyPageData getHistoricTaskInstanceFinishedList( + String processDefinitionName, + String beginDate, + String endDate, + MyPageParam pageParam) throws ParseException; + + /** + * 获取指定的历史任务实例。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 任务Id。 + * @return 历史任务实例。 + */ + HistoricTaskInstance getHistoricTaskInstance(String processInstanceId, String taskId); + + /** + * 获取流程实例的待完成任务列表。 + * + * @param processInstanceId 流程实例Id。 + * @return 流程实例待完成的任务列表。 + */ + List getHistoricUnfinishedInstanceList(String processInstanceId); + + /** + * 终止流程实例,将任务从当前节点直接流转到主流程的结束事件。 + * + * @param processInstanceId 流程实例Id。 + * @param stopReason 停止原因。 + * @param forCancel 是否由取消工单触发。 + * @return 执行结果。 + */ + CallResult stopProcessInstance(String processInstanceId, String stopReason, boolean forCancel); + + /** + * 终止流程实例,将任务从当前节点直接流转到主流程的结束事件。 + * + * @param processInstanceId 流程实例Id。 + * @param stopReason 停止原因。 + * @param status 流程状态。 + * @return 执行结果。 + */ + CallResult stopProcessInstance(String processInstanceId, String stopReason, int status); + + /** + * 删除流程实例。 + * + * @param processInstanceId 流程实例Id。 + */ + void deleteProcessInstance(String processInstanceId); + + /** + * 获取任务的指定本地变量。 + * + * @param taskId 任务Id。 + * @param variableName 变量名。 + * @return 变量值。 + */ + Object getTaskVariable(String taskId, String variableName); + + /** + * 安全的获取任务变量,并返回字符型的变量值。 + * + * @param taskId 任务Id。 + * @param variableName 变量名。 + * @return 返回变量值的字符串形式,如果变量不存在不会抛异常,返回null。 + */ + String getTaskVariableStringWithSafe(String taskId, String variableName); + + /** + * 获取任务执行时的指定本地变量。 + * + * @param executionId 任务执行时Id。 + * @param variableName 变量名。 + * @return 变量值。 + */ + Object getExecutionVariable(String executionId, String variableName); + + /** + * 安全的获取任务执行时变量,并返回字符型的变量值。 + * + * @param executionId 任务执行时Id。 + * @param variableName 变量名。 + * @return 返回变量值的字符串形式,如果变量不存在不会抛异常,返回null。 + */ + String getExecutionVariableStringWithSafe(String executionId, String variableName); + + /** + * 获取历史流程变量。 + * + * @param processInstanceId 流程实例Id。 + * @param variableName 变量名。 + * @return 获取历史流程变量。 + */ + Object getHistoricProcessInstanceVariable(String processInstanceId, String variableName); + + /** + * 将xml格式的流程模型字符串,转换为标准的流程模型。 + * + * @param bpmnXml xml格式的流程模型字符串。 + * @return 转换后的标准的流程模型。 + * @throws XMLStreamException XML流处理异常 + */ + BpmnModel convertToBpmnModel(String bpmnXml) throws XMLStreamException; + + /** + * 回退到上一个用户任务节点。如果没有指定,则回退到上一个任务。 + * + * @param task 当前活动任务。 + * @param targetKey 指定回退到的任务标识。如果为null,则回退到上一个任务。 + * @param forReject true表示驳回,false为撤回。 + * @param reason 驳回或者撤销的原因。 + * @return 回退结果。 + */ + CallResult backToRuntimeTask(Task task, String targetKey, boolean forReject, String reason); + + /** + * 转办任务给他人。 + * + * @param task 流程任务。 + * @param flowTaskComment 审批对象。 + */ + void transferTo(Task task, FlowTaskComment flowTaskComment); + + /** + * 获取当前任务在流程图中配置候选用户组数据。 + * + * @param flowTaskExt 流程任务扩展对象。 + * @param taskId 运行时任务Id。 + * @return 候选用户组数据。 + */ + List getCandidateUsernames(FlowTaskExt flowTaskExt, String taskId); + + /** + * 获取当前任务在流程图中配置到的部门岗位Id集合和岗位Id集合。 + * + * @param flowTaskExt 流程任务扩展对象。 + * @param processInstanceId 流程实例Id。 + * @param historic 是否为历史任务。 + * @return first为部门岗位Id集合,second是岗位Id集合。 + */ + Tuple2, Set> getDeptPostIdAndPostIds( + FlowTaskExt flowTaskExt, String processInstanceId, boolean historic); + + /** + * 获取流程图中所有用户任务的映射。 + * + * @param processDefinitionId 流程定义Id。 + * @return 流程图中所有用户任务的映射。 + */ + Map getAllUserTaskMap(String processDefinitionId); + + /** + * 获取流程图中指定的用户任务。 + * + * @param processDefinitionId 流程定义Id。 + * @param taskKey 用户任务标识。 + * @return 用户任务。 + */ + UserTask getUserTask(String processDefinitionId, String taskKey); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowCategoryService.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowCategoryService.java new file mode 100644 index 00000000..506c6f15 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowCategoryService.java @@ -0,0 +1,69 @@ +package com.orangeforms.common.flow.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.flow.model.*; + +import java.util.List; + +/** + * FlowCategory数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowCategoryService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param flowCategory 新增对象。 + * @return 返回新增对象。 + */ + FlowCategory saveNew(FlowCategory flowCategory); + + /** + * 更新数据对象。 + * + * @param flowCategory 更新的对象。 + * @param originalFlowCategory 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(FlowCategory flowCategory, FlowCategory originalFlowCategory); + + /** + * 删除指定数据。 + * + * @param categoryId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long categoryId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getFlowCategoryListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getFlowCategoryList(FlowCategory filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getFlowCategoryList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getFlowCategoryListWithRelation(FlowCategory filter, String orderBy); + + /** + * 当前流程分类编码是否存在。 + * + * @param code 流程分类编码。 + * @return true存在,否则false。 + */ + boolean existByCode(String code); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowEntryService.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowEntryService.java new file mode 100644 index 00000000..9cd3a366 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowEntryService.java @@ -0,0 +1,133 @@ +package com.orangeforms.common.flow.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.flow.model.*; + +import javax.xml.stream.XMLStreamException; +import java.util.List; +import java.util.Set; + +/** + * FlowEntry数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowEntryService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param flowEntry 新增工作流对象。 + * @return 返回新增对象。 + */ + FlowEntry saveNew(FlowEntry flowEntry); + + /** + * 发布指定流程。 + * + * @param flowEntry 待发布的流程对象。 + * @param initTaskInfo 第一个非开始节点任务的附加信息。 + * @throws XMLStreamException 解析bpmn.xml的异常。 + */ + void publish(FlowEntry flowEntry, String initTaskInfo) throws XMLStreamException; + + /** + * 更新数据对象。 + * + * @param flowEntry 更新的对象。 + * @param originalFlowEntry 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(FlowEntry flowEntry, FlowEntry originalFlowEntry); + + /** + * 删除指定数据。 + * + * @param entryId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long entryId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getFlowEntryListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getFlowEntryList(FlowEntry filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getFlowEntryList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getFlowEntryListWithRelation(FlowEntry filter, String orderBy); + + /** + * 根据流程定义标识获取流程对象。从缓存中读取,如不存在则从数据库读取后,再同步到缓存。 + * + * @param processDefinitionKey 流程定义标识。 + * @return 流程对象。 + */ + FlowEntry getFlowEntryFromCache(String processDefinitionKey); + + /** + * 根据流程Id获取流程发布列表数据。 + * + * @param entryId 流程Id。 + * @return 流程关联的发布列表数据。 + */ + List getFlowEntryPublishList(Long entryId); + + /** + * 根据流程引擎中的流程定义Id集合,查询流程发布对象。 + * + * @param processDefinitionIdSet 流程引擎中的流程定义Id集合。 + * @return 查询结果。 + */ + List getFlowEntryPublishList(Set processDefinitionIdSet); + + /** + * 获取指定工作流发布版本对象。从缓存中读取,如缓存中不存在,从数据库读取并同步缓存。 + * + * @param entryPublishId 工作流发布对象Id。 + * @return 查询后的对象。 + */ + FlowEntryPublish getFlowEntryPublishFromCache(Long entryPublishId); + + /** + * 为指定工作流更新发布的主版本。 + * + * @param flowEntry 工作流对象。 + * @param newMainFlowEntryPublish 工作流新的发布主版本对象。 + */ + void updateFlowEntryMainVersion(FlowEntry flowEntry, FlowEntryPublish newMainFlowEntryPublish); + + /** + * 挂起指定的工作流发布对象。 + * + * @param flowEntryPublish 待挂起的工作流发布对象。 + */ + void suspendFlowEntryPublish(FlowEntryPublish flowEntryPublish); + + /** + * 激活指定的工作流发布对象。 + * + * @param flowEntryPublish 待恢复的工作流发布对象。 + */ + void activateFlowEntryPublish(FlowEntryPublish flowEntryPublish); + + /** + * 判断指定流程定义标识是否存在。 + * @param processDefinitionKey 流程定义标识。 + * @return true存在,否则false。 + */ + boolean existByProcessDefinitionKey(String processDefinitionKey); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowEntryVariableService.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowEntryVariableService.java new file mode 100644 index 00000000..963a33fb --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowEntryVariableService.java @@ -0,0 +1,68 @@ +package com.orangeforms.common.flow.service; + +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.core.base.service.IBaseService; + +import java.util.*; + +/** + * 流程变量数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowEntryVariableService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param flowEntryVariable 新增对象。 + * @return 返回新增对象。 + */ + FlowEntryVariable saveNew(FlowEntryVariable flowEntryVariable); + + /** + * 更新数据对象。 + * + * @param flowEntryVariable 更新的对象。 + * @param originalFlowEntryVariable 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(FlowEntryVariable flowEntryVariable, FlowEntryVariable originalFlowEntryVariable); + + /** + * 删除指定数据。 + * + * @param variableId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long variableId); + + /** + * 删除指定流程Id的所有变量。 + * + * @param entryId 流程Id。 + */ + void removeByEntryId(Long entryId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getFlowEntryVariableListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getFlowEntryVariableList(FlowEntryVariable filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getFlowEntryVariableList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getFlowEntryVariableListWithRelation(FlowEntryVariable filter, String orderBy); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowMessageService.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowMessageService.java new file mode 100644 index 00000000..1d0b53f8 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowMessageService.java @@ -0,0 +1,106 @@ +package com.orangeforms.common.flow.service; + +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.flow.model.FlowMessage; +import com.orangeforms.common.flow.model.FlowWorkOrder; +import org.flowable.task.api.Task; + +import java.util.List; + +/** + * 工作流消息数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowMessageService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param flowMessage 新增对象。 + * @return 保存后的消息对象。 + */ + FlowMessage saveNew(FlowMessage flowMessage); + + /** + * 根据工单参数,保存催单消息对象。如果当前工单存在多个待办任务,则插入多条催办消息数据。 + * + * @param flowWorkOrder 待催办的工单。 + */ + void saveNewRemindMessage(FlowWorkOrder flowWorkOrder); + + /** + * 保存抄送消息对象。 + * + * @param task 待抄送的任务。 + * @param copyDataJson 抄送人员或者组的Id数据。 + */ + void saveNewCopyMessage(Task task, JSONObject copyDataJson); + + /** + * 更新指定运行时任务Id的消费为已完成状态。 + * + * @param taskId 运行时任务Id。 + */ + void updateFinishedStatusByTaskId(String taskId); + + /** + * 更新指定流程实例Id的消费为已完成状态。 + * + * @param processInstanceId 流程实例IdId。 + */ + void updateFinishedStatusByProcessInstanceId(String processInstanceId); + + /** + * 获取当前用户的催办消息列表。 + * + * @return 查询后的催办消息列表。 + */ + List getRemindingMessageListByUser(); + + /** + * 获取当前用户的抄送消息列表。 + * + * @param read true表示已读,false表示未读。 + * @return 查询后的抄送消息列表。 + */ + List getCopyMessageListByUser(Boolean read); + + /** + * 判断当前用户是否有权限访问指定消息Id。 + * + * @param messageId 消息Id。 + * @return true为合法访问者,否则false。 + */ + boolean isCandidateIdentityOnMessage(Long messageId); + + /** + * 读取抄送消息,同时更新当前用户对指定抄送消息的读取状态。 + * + * @param messageId 消息Id。 + */ + void readCopyTask(Long messageId); + + /** + * 计算当前用户催办消息的数量。 + * + * @return 当前用户催办消息数量。 + */ + int countRemindingMessageListByUser(); + + /** + * 计算当前用户未读抄送消息的数量。 + * + * @return 当前用户未读抄送消息数量。 + */ + int countCopyMessageByUser(); + + /** + * 删除指定流程实例的消息。 + * + * @param processInstanceId 流程实例Id。 + */ + void removeByProcessInstanceId(String processInstanceId); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowMultiInstanceTransService.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowMultiInstanceTransService.java new file mode 100644 index 00000000..3b0ff74c --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowMultiInstanceTransService.java @@ -0,0 +1,38 @@ +package com.orangeforms.common.flow.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.flow.model.FlowMultiInstanceTrans; + +/** + * 会签任务操作流水数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowMultiInstanceTransService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param flowMultiInstanceTrans 新增对象。 + * @return 返回新增对象。 + */ + FlowMultiInstanceTrans saveNew(FlowMultiInstanceTrans flowMultiInstanceTrans); + + /** + * 根据流程执行Id获取对象。 + * + * @param executionId 流程执行Id。 + * @param taskId 执行任务Id。 + * @return 数据对象。 + */ + FlowMultiInstanceTrans getByExecutionId(String executionId, String taskId); + + /** + * 根据多实例的统一执行Id,获取assgineeList字段不为空的数据。 + * + * @param multiInstanceExecId 多实例统一执行Id。 + * @return 数据对象。 + */ + FlowMultiInstanceTrans getWithAssigneeListByMultiInstanceExecId(String multiInstanceExecId); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowTaskCommentService.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowTaskCommentService.java new file mode 100644 index 00000000..4dc05e05 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowTaskCommentService.java @@ -0,0 +1,84 @@ +package com.orangeforms.common.flow.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.flow.model.FlowTaskComment; + +import java.util.List; +import java.util.Set; + +/** + * 流程任务批注数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowTaskCommentService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param flowTaskComment 新增对象。 + * @return 返回新增对象。 + */ + FlowTaskComment saveNew(FlowTaskComment flowTaskComment); + + /** + * 查询指定流程实例Id下的所有审批任务的批注。 + * + * @param processInstanceId 流程实例Id。 + * @return 查询结果集。 + */ + List getFlowTaskCommentList(String processInstanceId); + + /** + * 查询与指定流程任务Id集合关联的所有审批任务的批注。 + * + * @param taskIdSet 流程任务Id集合。 + * @return 查询结果集。 + */ + List getFlowTaskCommentListByTaskIds(Set taskIdSet); + + /** + * 获取指定流程实例的最后一条审批任务。 + * + * @param processInstanceId 流程实例Id。 + * @return 查询结果。 + */ + FlowTaskComment getLatestFlowTaskComment(String processInstanceId); + + /** + * 获取指定流程实例和任务定义标识的最后一条审批任务。 + * + * @param processInstanceId 流程实例Id。 + * @param taskDefinitionKey 任务定义标识。 + * @return 查询结果。 + */ + FlowTaskComment getLatestFlowTaskComment(String processInstanceId, String taskDefinitionKey); + + /** + * 获取指定流程实例的第一条审批任务。 + * + * @param processInstanceId 流程实例Id。 + * @return 查询结果。 + */ + FlowTaskComment getFirstFlowTaskComment(String processInstanceId); + + /** + * 获取指定任务实例和执行批次的审批数据列表。 + * + * @param processInstanceId 流程实例。 + * @param taskId 任务Id + * @param executionId 任务执行Id + * @return 审批数据列表。 + */ + List getFlowTaskCommentListByExecutionId( + String processInstanceId, String taskId, String executionId); + + /** + * 根据多实例执行Id获取任务审批对象数据列表。 + * + * @param multiInstanceExecId 多实例执行Id。 + * @return 审批数据列表。 + */ + List getFlowTaskCommentListByMultiInstanceExecId(String multiInstanceExecId); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowTaskExtService.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowTaskExtService.java new file mode 100644 index 00000000..dca29c00 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowTaskExtService.java @@ -0,0 +1,124 @@ +package com.orangeforms.common.flow.service; + +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.flow.object.FlowElementExtProperty; +import com.orangeforms.common.flow.vo.FlowUserInfoVo; +import com.orangeforms.common.core.base.service.IBaseService; +import org.flowable.bpmn.model.BpmnModel; +import org.flowable.bpmn.model.ExtensionElement; +import org.flowable.bpmn.model.FlowElement; +import org.flowable.bpmn.model.UserTask; +import org.flowable.task.api.TaskInfo; + +import java.util.List; +import java.util.Map; + +/** + * 流程任务扩展数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowTaskExtService extends IBaseService { + + /** + * 批量插入流程任务扩展信息列表。 + * + * @param flowTaskExtList 流程任务扩展信息列表。 + */ + void saveBatch(List flowTaskExtList); + + /** + * 查询指定的流程任务扩展对象。 + * + * @param processDefinitionId 流程引擎的定义Id。 + * @param taskId 流程引擎的任务Id。 + * @return 查询结果。 + */ + FlowTaskExt getByProcessDefinitionIdAndTaskId(String processDefinitionId, String taskId); + + /** + * 查询指定的流程定义的任务扩展对象。 + * + * @param processDefinitionId 流程引擎的定义Id。 + * @return 查询结果。 + */ + List getByProcessDefinitionId(String processDefinitionId); + + /** + * 获取任务扩展信息中的候选人用户信息列表。 + * + * @param processInstanceId 流程引擎的实例Id。 + * @param flowTaskExt 任务扩展对象。 + * @param taskInfo 任务信息。 + * @param isMultiInstanceTask 是否为多实例任务。 + * @param historic 是否为历史任务。 + * @return 候选人用户信息列表。 + */ + List getCandidateUserInfoList( + String processInstanceId, + FlowTaskExt flowTaskExt, + TaskInfo taskInfo, + boolean isMultiInstanceTask, + boolean historic); + + /** + * 获取指定任务的用户列表信息。 + * + * @param processInstanceId 流程实例。 + * @param executionId 执行实例。 + * @param flowTaskExt 流程用户任务的扩展对象。 + * @return 候选人用户信息列表。 + */ + List getCandidateUserInfoList( + String processInstanceId, + String executionId, + FlowTaskExt flowTaskExt); + + /** + * 通过UserTask对象中的扩展节点信息,构建FLowTaskExt对象。 + * + * @param userTask 流程图中定义的用户任务对象。 + * @return 构建后的流程任务扩展信息对象。 + */ + FlowTaskExt buildTaskExtByUserTask(UserTask userTask); + + /** + * 获取指定流程图中所有UserTask对象的扩展节点信息,构建FLowTaskExt对象列表。 + * + * @param bpmnModel 流程图模型对象。 + * @return 当前流程图中所有用户流程任务的扩展信息对象列表。 + */ + List buildTaskExtList(BpmnModel bpmnModel); + + /** + * 根据流程定义中用户任务的扩展节点数据,构建出前端所需的操作列表数据对象。 + * @param extensionMap 用户任务的扩展节点。 + * @return 前端所需的操作列表数据对象。 + */ + List buildOperationListExtensionElement(Map> extensionMap); + + /** + * 根据流程定义中用户任务的扩展节点数据,构建出前端所需的变量列表数据对象。 + * @param extensionMap 用户任务的扩展节点。 + * @return 前端所需的变量列表数据对象。 + */ + List buildVariableListExtensionElement(Map> extensionMap); + + /** + * 读取流程定义中,流程元素的扩展属性数据。 + * + * @param element 流程图中定义的流程元素。 + * @return 流程元素的扩展属性数据。 + */ + FlowElementExtProperty buildFlowElementExt(FlowElement element); + + /** + * 读取流程定义中,流程元素的扩展属性数据。 + * + * @param element 流程图中定义的流程元素。 + * @return 流程元素的扩展属性数据,并转换为JSON对象。 + */ + JSONObject buildFlowElementExtToJson(FlowElement element); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowWorkOrderService.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowWorkOrderService.java new file mode 100644 index 00000000..4299abe7 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/FlowWorkOrderService.java @@ -0,0 +1,184 @@ +package com.orangeforms.common.flow.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.object.MyOrderParam; +import com.orangeforms.common.core.object.MyPageData; +import com.orangeforms.common.core.object.MyPageParam; +import com.orangeforms.common.flow.dto.FlowWorkOrderDto; +import com.orangeforms.common.flow.model.FlowWorkOrder; +import com.orangeforms.common.flow.model.FlowWorkOrderExt; +import com.orangeforms.common.flow.vo.FlowWorkOrderVo; +import org.flowable.engine.runtime.ProcessInstance; + +import java.util.*; + +/** + * 工作流工单表数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface FlowWorkOrderService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param instance 流程实例对象。 + * @param dataId 流程实例的BusinessKey。 + * @param onlineTableId 在线数据表的主键Id。 + * @param tableName 面向静态表单所使用的表名。 + * @return 新增的工作流工单对象。 + */ + FlowWorkOrder saveNew(ProcessInstance instance, Object dataId, Long onlineTableId, String tableName); + + /** + * 保存工单草稿。 + * + * @param instance 流程实例对象。 + * @param onlineTableId 在线表单的主表Id。 + * @param tableName 静态表单的主表表名。 + * @param masterData 主表数据。 + * @param slaveData 从表数据。 + * @return 工单对象。 + */ + FlowWorkOrder saveNewWithDraft( + ProcessInstance instance, Long onlineTableId, String tableName, String masterData, String slaveData); + + /** + * 更新流程工单的草稿数据。 + * + * @param workOrderId 工单Id。 + * @param masterData 主表数据。 + * @param slaveData 从表数据。 + */ + void updateDraft(Long workOrderId, String masterData, String slaveData); + + /** + * 删除指定数据。 + * + * @param workOrderId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long workOrderId); + + /** + * 删除指定流程实例Id的关联工单。 + * + * @param processInstanceId 流程实例Id。 + */ + void removeByProcessInstanceId(String processInstanceId); + + /** + * 获取工作流工单单表查询结果。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getFlowWorkOrderList(FlowWorkOrder filter, String orderBy); + + /** + * 获取工作流工单列表及其关联字典数据。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getFlowWorkOrderListWithRelation(FlowWorkOrder filter, String orderBy); + + /** + * 根据流程实例Id,查询关联的工单对象。 + * + * @param processInstanceId 流程实例Id。 + * @return 工作流工单对象。 + */ + FlowWorkOrder getFlowWorkOrderByProcessInstanceId(String processInstanceId); + + /** + * 根据业务主键,查询是否存在指定的工单。 + * + * @param tableName 静态表单工作流使用的数据表。 + * @param businessKey 业务数据主键Id。 + * @param unfinished 是否为没有结束工单。 + * @return 存在返回true,否则false。 + */ + boolean existByBusinessKey(String tableName, Object businessKey, boolean unfinished); + + /** + * 根据流程定义和业务主键,查询是否存在指定的未完成工单。 + * + * @param processDefinitionKey 静态表单工作流使用的数据表。 + * @param businessKey 业务数据主键Id。 + * @return 存在返回true,否则false。 + */ + boolean existUnfinished(String processDefinitionKey, Object businessKey); + + /** + * 根据流程实例Id,更新流程状态。 + * + * @param processInstanceId 流程实例Id。 + * @param flowStatus 新的流程状态值,如果该值为null,不执行任何更新。 + */ + void updateFlowStatusByProcessInstanceId(String processInstanceId, Integer flowStatus); + + /** + * 根据流程实例Id,更新流程最后审批状态。 + * + * @param processInstanceId 流程实例Id。 + * @param approvalStatus 新的流程最后审批状态,如果该值为null,不执行任何更新。 + */ + void updateLatestApprovalStatusByProcessInstanceId(String processInstanceId, Integer approvalStatus); + + /** + * 是否有查看该工单的数据权限。 + * + * @param processInstanceId 流程实例Id。 + * @return 存在返回true,否则false。 + */ + boolean hasDataPermOnFlowWorkOrder(String processInstanceId); + + /** + * 根据工单列表中的submitUserName,找到映射的userShowName,并会写到Vo中指定字段。 + * 同时这也是一个如何通过插件方法,将loginName映射到showName的示例, + * + * @param dataList 工单Vo对象列表。 + */ + void fillUserShowNameByLoginName(List dataList); + + /** + * 根据工单Id获取工单扩展对象数据。 + * + * @param workOrderId 工单Id。 + * @return 工单扩展对象。 + */ + FlowWorkOrderExt getFlowWorkOrderExtByWorkOrderId(Long workOrderId); + + /** + * 根据工单Id集合获取工单扩展对象数据列表。 + * + * @param workOrderIds 工单Id集合。 + * @return 工单扩展对象列表。 + */ + List getFlowWorkOrderExtByWorkOrderIds(Set workOrderIds); + + /** + * 移除草稿工单,同时停止已经启动的流程实例。 + * + * @param flowWorkOrder 工单对象。 + * @return 停止流程实例的结果。 + */ + CallResult removeDraft(FlowWorkOrder flowWorkOrder); + + /** + * 获取分页后的工单列表同时构建部分任务数据。该方法主要是为了尽量减少路由表单工作流listWorkOrder的重复代码。 + * + * @param filter 工单过滤对象。 + * @param pageParam 分页参数对象。 + * @param orderParam 排序参数对象。 + * @param processDefinitionKey 流程定义标识。 + * @return 分页的工单列表。 + */ + MyPageData getPagedWorkOrderListAndBuildData( + FlowWorkOrderDto filter, MyPageParam pageParam, MyOrderParam orderParam, String processDefinitionKey); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowApiServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowApiServiceImpl.java new file mode 100644 index 00000000..7699f795 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowApiServiceImpl.java @@ -0,0 +1,2039 @@ +package com.orangeforms.common.flow.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.annotation.MultiDatabaseWriteMethod; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.constant.UserFilterGroup; +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.MyDateUtil; +import com.orangeforms.common.flow.constant.FlowApprovalType; +import com.orangeforms.common.flow.constant.FlowConstant; +import com.orangeforms.common.flow.constant.FlowTaskStatus; +import com.orangeforms.common.flow.exception.FlowOperationException; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.flow.object.FlowEntryExtensionData; +import com.orangeforms.common.flow.object.FlowTaskMultiSignAssign; +import com.orangeforms.common.flow.object.FlowTaskOperation; +import com.orangeforms.common.flow.object.FlowTaskPostCandidateGroup; +import com.orangeforms.common.flow.service.*; +import com.orangeforms.common.flow.util.BaseFlowIdentityExtHelper; +import com.orangeforms.common.flow.util.CustomChangeActivityStateBuilderImpl; +import com.orangeforms.common.flow.util.FlowCustomExtFactory; +import com.orangeforms.common.flow.vo.FlowTaskVo; +import com.orangeforms.common.flow.vo.FlowUserInfoVo; +import lombok.Cleanup; +import lombok.extern.slf4j.Slf4j; +import org.flowable.bpmn.converter.BpmnXMLConverter; +import org.flowable.bpmn.model.Process; +import org.flowable.bpmn.model.*; +import org.flowable.common.engine.impl.de.odysseus.el.ExpressionFactoryImpl; +import org.flowable.common.engine.impl.de.odysseus.el.util.SimpleContext; +import org.flowable.common.engine.impl.identity.Authentication; +import org.flowable.common.engine.impl.javax.el.ExpressionFactory; +import org.flowable.common.engine.impl.javax.el.ValueExpression; +import org.flowable.engine.*; +import org.flowable.engine.delegate.ExecutionListener; +import org.flowable.engine.delegate.TaskListener; +import org.flowable.engine.history.HistoricActivityInstance; +import org.flowable.engine.history.HistoricProcessInstance; +import org.flowable.engine.history.HistoricProcessInstanceQuery; +import org.flowable.engine.impl.RuntimeServiceImpl; +import org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior; +import org.flowable.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior; +import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl; +import org.flowable.engine.repository.ProcessDefinition; +import org.flowable.engine.runtime.ChangeActivityStateBuilder; +import org.flowable.engine.runtime.Execution; +import org.flowable.engine.runtime.ProcessInstance; +import org.flowable.engine.runtime.ProcessInstanceBuilder; +import org.flowable.identitylink.api.IdentityLink; +import org.flowable.task.api.Task; +import org.flowable.task.api.TaskInfo; +import org.flowable.task.api.TaskQuery; +import org.flowable.task.api.history.HistoricTaskInstance; +import org.flowable.task.api.history.HistoricTaskInstanceQuery; +import org.flowable.variable.api.history.HistoricVariableInstance; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; + +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("flowApiService") +public class FlowApiServiceImpl implements FlowApiService { + + @Autowired + private RepositoryService repositoryService; + @Autowired + private RuntimeService runtimeService; + @Autowired + private TaskService taskService; + @Autowired + private HistoryService historyService; + @Autowired + private ManagementService managementService; + @Autowired + private FlowEntryService flowEntryService; + @Autowired + private FlowTaskCommentService flowTaskCommentService; + @Autowired + private FlowTaskExtService flowTaskExtService; + @Autowired + private FlowWorkOrderService flowWorkOrderService; + @Autowired + private FlowMessageService flowMessageService; + @Autowired + private FlowCustomExtFactory flowCustomExtFactory; + @Autowired + private FlowMultiInstanceTransService flowMultiInstanceTransService; + + @Transactional(rollbackFor = Exception.class) + @Override + public ProcessInstance start(String processDefinitionId, Object dataId) { + TokenData tokenData = TokenData.takeFromRequest(); + Map variableMap = this.initAndGetProcessInstanceVariables(processDefinitionId); + Authentication.setAuthenticatedUserId(tokenData.getLoginName()); + String businessKey = dataId == null ? null : dataId.toString(); + ProcessInstanceBuilder builder = runtimeService.createProcessInstanceBuilder() + .processDefinitionId(processDefinitionId).businessKey(businessKey).variables(variableMap); + if (tokenData.getTenantId() != null) { + builder.tenantId(tokenData.getTenantId().toString()); + } else { + if (tokenData.getAppCode() != null) { + builder.tenantId(tokenData.getAppCode()); + } + } + return builder.start(); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public Task takeFirstTask(String processInstanceId, FlowTaskComment flowTaskComment, JSONObject taskVariableData) { + String loginName = TokenData.takeFromRequest().getLoginName(); + // 获取流程启动后的第一个任务。 + Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).active().singleResult(); + if (StrUtil.equalsAny(task.getAssignee(), loginName, FlowConstant.START_USER_NAME_VAR)) { + // 按照规则,调用该方法的用户,就是第一个任务的assignee,因此默认会自动执行complete。 + flowTaskComment.fillWith(task); + this.completeTask(task, flowTaskComment, taskVariableData); + } + return task; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public ProcessInstance startAndTakeFirst( + String processDefinitionId, Object dataId, FlowTaskComment flowTaskComment, JSONObject taskVariableData) { + ProcessInstance instance = this.start(processDefinitionId, dataId); + this.takeFirstTask(instance.getProcessInstanceId(), flowTaskComment, taskVariableData); + return instance; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void submitConsign( + HistoricTaskInstance startTaskInstance, Task multiInstanceActiveTask, String newAssignees, boolean isAdd) { + JSONArray assigneeArray = JSON.parseArray(newAssignees); + String multiInstanceExecId = this.getExecutionVariableStringWithSafe( + multiInstanceActiveTask.getExecutionId(), FlowConstant.MULTI_SIGN_TASK_EXECUTION_ID_VAR); + FlowMultiInstanceTrans trans = + flowMultiInstanceTransService.getWithAssigneeListByMultiInstanceExecId(multiInstanceExecId); + Set assigneeSet = new HashSet<>(StrUtil.split(trans.getAssigneeList(), ",")); + Task runtimeTask = null; + for (int i = 0; i < assigneeArray.size(); i++) { + String assignee = assigneeArray.getString(i); + if (isAdd) { + assigneeSet.add(assignee); + } else { + assigneeSet.remove(assignee); + } + if (isAdd) { + Map variables = new HashMap<>(2); + variables.put("assignee", assigneeArray.getString(i)); + variables.put(FlowConstant.MULTI_SIGN_START_TASK_VAR, startTaskInstance.getId()); + runtimeService.addMultiInstanceExecution( + multiInstanceActiveTask.getTaskDefinitionKey(), multiInstanceActiveTask.getProcessInstanceId(), variables); + } else { + TaskQuery query = taskService.createTaskQuery().active(); + query.processInstanceId(multiInstanceActiveTask.getProcessInstanceId()); + query.taskDefinitionKey(multiInstanceActiveTask.getTaskDefinitionKey()); + query.taskAssignee(assignee); + runtimeTask = query.singleResult(); + if (runtimeTask == null) { + throw new FlowOperationException("审批人 [" + assignee + "] 已经提交审批,不能执行减签操作!"); + } + runtimeService.deleteMultiInstanceExecution(runtimeTask.getExecutionId(), false); + } + } + if (!isAdd && runtimeTask != null) { + this.doChangeTask(runtimeTask); + } + trans.setAssigneeList(StrUtil.join(",", assigneeSet)); + flowMultiInstanceTransService.updateById(trans); + FlowTaskComment flowTaskComment = new FlowTaskComment(); + flowTaskComment.fillWith(startTaskInstance); + flowTaskComment.setApprovalType(isAdd ? FlowApprovalType.MULTI_CONSIGN : FlowApprovalType.MULTI_MINUS_SIGN); + String showName = TokenData.takeFromRequest().getLoginName(); + String comment = String.format("用户 [%s] [%s] [%s]。", isAdd ? "加签" : "减签", showName, newAssignees); + flowTaskComment.setTaskComment(comment); + flowTaskCommentService.saveNew(flowTaskComment); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void completeTask(Task task, FlowTaskComment flowTaskComment, JSONObject taskVariableData) { + if (taskVariableData == null) { + taskVariableData = new JSONObject(); + } + JSONObject passCopyData = (JSONObject) taskVariableData.remove(FlowConstant.COPY_DATA_KEY); + // 判断当前完成执行的任务,是否存在抄送设置。 + Object copyData = runtimeService.getVariable( + task.getProcessInstanceId(), FlowConstant.COPY_DATA_MAP_PREFIX + task.getTaskDefinitionKey()); + if (copyData != null || passCopyData != null) { + JSONObject copyDataJson = this.mergeCopyData(copyData, passCopyData); + flowMessageService.saveNewCopyMessage(task, copyDataJson); + } + if (flowTaskComment != null) { + // 这里处理多实例会签逻辑。 + if (flowTaskComment.getApprovalType().equals(FlowApprovalType.MULTI_SIGN)) { + String loginName = TokenData.takeFromRequest().getLoginName(); + String assigneeList = this.getMultiInstanceAssigneeList(task, taskVariableData); + Assert.isTrue(StrUtil.isNotBlank(assigneeList)); + taskVariableData.put(FlowConstant.MULTI_AGREE_COUNT_VAR, 0); + taskVariableData.put(FlowConstant.MULTI_REFUSE_COUNT_VAR, 0); + taskVariableData.put(FlowConstant.MULTI_ABSTAIN_COUNT_VAR, 0); + taskVariableData.put(FlowConstant.MULTI_SIGN_NUM_OF_INSTANCES_VAR, 0); + taskVariableData.put(FlowConstant.MULTI_SIGN_START_TASK_VAR, task.getId()); + String multiInstanceExecId = MyCommonUtil.generateUuid(); + taskVariableData.put(FlowConstant.MULTI_SIGN_TASK_EXECUTION_ID_VAR, multiInstanceExecId); + String comment = String.format("用户 [%s] 会签 [%s]。", loginName, assigneeList); + FlowMultiInstanceTrans multiInstanceTrans = new FlowMultiInstanceTrans(task); + multiInstanceTrans.setMultiInstanceExecId(multiInstanceExecId); + multiInstanceTrans.setAssigneeList(assigneeList); + flowMultiInstanceTransService.saveNew(multiInstanceTrans); + flowTaskComment.setTaskComment(comment); + } + // 处理转办。 + if (FlowApprovalType.TRANSFER.equals(flowTaskComment.getApprovalType())) { + this.transferTo(task, flowTaskComment); + return; + } + this.handleMultiInstanceApprovalType( + task.getExecutionId(), flowTaskComment.getApprovalType(), taskVariableData); + taskVariableData.put(FlowConstant.OPERATION_TYPE_VAR, flowTaskComment.getApprovalType()); + this.setSubmitUserVar(taskVariableData, flowTaskComment); + flowTaskComment.fillWith(task); + if (this.isMultiInstanceTask(task.getProcessDefinitionId(), task.getTaskDefinitionKey())) { + String multiInstanceExecId = getExecutionVariableStringWithSafe( + task.getExecutionId(), FlowConstant.MULTI_SIGN_TASK_EXECUTION_ID_VAR); + FlowMultiInstanceTrans multiInstanceTrans = new FlowMultiInstanceTrans(task); + multiInstanceTrans.setMultiInstanceExecId(multiInstanceExecId); + flowMultiInstanceTransService.saveNew(multiInstanceTrans); + flowTaskComment.setMultiInstanceExecId(multiInstanceExecId); + } + flowTaskCommentService.saveNew(flowTaskComment); + } + taskVariableData.remove(FlowConstant.PROC_INSTANCE_START_USER_NAME_VAR); + Integer approvalStatus = MapUtil.getInt(taskVariableData, FlowConstant.LATEST_APPROVAL_STATUS_KEY); + flowWorkOrderService.updateLatestApprovalStatusByProcessInstanceId(task.getProcessInstanceId(), approvalStatus); + taskService.complete(task.getId(), taskVariableData, this.makeTransientVariableMap(taskVariableData)); + flowMessageService.updateFinishedStatusByTaskId(task.getId()); + } + + private void setSubmitUserVar(JSONObject taskVariableData, FlowTaskComment comment) { + TokenData tokenData = TokenData.takeFromRequest(); + if (tokenData != null) { + taskVariableData.put(FlowConstant.SUBMIT_USER_VAR, tokenData.getLoginName()); + } else { + if (StrUtil.isNotBlank(comment.getCreateLoginName())) { + taskVariableData.put(FlowConstant.SUBMIT_USER_VAR, comment.getCreateLoginName()); + } + } + } + + private JSONObject makeTransientVariableMap(JSONObject taskVariableData) { + JSONObject result = new JSONObject(); + if (taskVariableData == null) { + return result; + } + Object masterData = taskVariableData.get(FlowConstant.MASTER_DATA_KEY); + if (masterData != null) { + result.put(FlowConstant.MASTER_DATA_KEY, masterData); + } + Object slaveData = taskVariableData.get(FlowConstant.SLAVE_DATA_KEY); + if (slaveData != null) { + result.put(FlowConstant.SLAVE_DATA_KEY, slaveData); + } + Object masterTable = taskVariableData.get(FlowConstant.MASTER_TABLE_KEY); + if (masterTable != null) { + result.put(FlowConstant.MASTER_TABLE_KEY, masterTable); + } + taskVariableData.remove(FlowConstant.MASTER_DATA_KEY); + taskVariableData.remove(FlowConstant.SLAVE_DATA_KEY); + taskVariableData.remove(FlowConstant.MASTER_TABLE_KEY); + return result; + } + + private String getMultiInstanceAssigneeList(Task task, JSONObject taskVariableData) { + JSONArray assigneeArray = taskVariableData.getJSONArray(FlowConstant.MULTI_ASSIGNEE_LIST_VAR); + String assigneeList; + if (CollUtil.isEmpty(assigneeArray)) { + FlowTaskExt flowTaskExt = flowTaskExtService.getByProcessDefinitionIdAndTaskId( + task.getProcessDefinitionId(), task.getTaskDefinitionKey()); + assigneeList = this.buildMutiSignAssigneeList(flowTaskExt.getOperationListJson()); + if (assigneeList != null) { + taskVariableData.put(FlowConstant.MULTI_ASSIGNEE_LIST_VAR, StrUtil.split(assigneeList, ',')); + } + } else { + assigneeList = CollUtil.join(assigneeArray, ","); + } + return assigneeList; + } + + private JSONObject mergeCopyData(Object copyData, JSONObject passCopyData) { + // passCopyData是传阅数据,copyData是抄送数据。 + JSONObject resultCopyDataJson = passCopyData; + if (resultCopyDataJson == null) { + resultCopyDataJson = JSON.parseObject(copyData.toString()); + } else if (copyData != null) { + JSONObject copyDataJson = JSON.parseObject(copyData.toString()); + for (Map.Entry entry : copyDataJson.entrySet()) { + String value = resultCopyDataJson.getString(entry.getKey()); + if (value == null) { + resultCopyDataJson.put(entry.getKey(), entry.getValue()); + } else { + List list1 = StrUtil.split(value, ","); + List list2 = StrUtil.split(entry.getValue().toString(), ","); + Set valueSet = new HashSet<>(list1); + valueSet.addAll(list2); + resultCopyDataJson.put(entry.getKey(), StrUtil.join(",", valueSet)); + } + } + } + this.processMergeCopyData(resultCopyDataJson); + return resultCopyDataJson; + } + + private void processMergeCopyData(JSONObject resultCopyDataJson) { + TokenData tokenData = TokenData.takeFromRequest(); + BaseFlowIdentityExtHelper flowIdentityExtHelper = flowCustomExtFactory.getFlowIdentityExtHelper(); + for (Map.Entry entry : resultCopyDataJson.entrySet()) { + String type = entry.getKey(); + switch (type) { + case FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER_VAR: + Object upLeaderDeptPostId = + flowIdentityExtHelper.getUpLeaderDeptPostId(tokenData.getDeptId()); + entry.setValue(upLeaderDeptPostId); + break; + case FlowConstant.GROUP_TYPE_DEPT_POST_LEADER_VAR: + Object leaderDeptPostId = + flowIdentityExtHelper.getLeaderDeptPostId(tokenData.getDeptId()); + entry.setValue(leaderDeptPostId); + break; + case FlowConstant.GROUP_TYPE_SELF_DEPT_POST_VAR: + Set selfPostIdSet = new HashSet<>(StrUtil.split(entry.getValue().toString(), ",")); + Map deptPostIdMap = + flowIdentityExtHelper.getDeptPostIdMap(tokenData.getDeptId(), selfPostIdSet); + String deptPostIdValues = ""; + if (deptPostIdMap != null) { + deptPostIdValues = StrUtil.join(",", deptPostIdMap.values()); + } + entry.setValue(deptPostIdValues); + break; + case FlowConstant.GROUP_TYPE_SIBLING_DEPT_POST_VAR: + Set siblingPostIdSet = new HashSet<>(StrUtil.split(entry.getValue().toString(), ",")); + Map siblingDeptPostIdMap = + flowIdentityExtHelper.getSiblingDeptPostIdMap(tokenData.getDeptId(), siblingPostIdSet); + String siblingDeptPostIdValues = ""; + if (siblingDeptPostIdMap != null) { + siblingDeptPostIdValues = StrUtil.join(",", siblingDeptPostIdMap.values()); + } + entry.setValue(siblingDeptPostIdValues); + break; + case FlowConstant.GROUP_TYPE_UP_DEPT_POST_VAR: + Set upPostIdSet = new HashSet<>(StrUtil.split(entry.getValue().toString(), ",")); + Map upDeptPostIdMap = + flowIdentityExtHelper.getUpDeptPostIdMap(tokenData.getDeptId(), upPostIdSet); + String upDeptPostIdValues = ""; + if (upDeptPostIdMap != null) { + upDeptPostIdValues = StrUtil.join(",", upDeptPostIdMap.values()); + } + entry.setValue(upDeptPostIdValues); + break; + default: + break; + } + } + } + + @Transactional(rollbackFor = Exception.class) + @Override + public CallResult verifyAssigneeOrCandidateAndClaim(Task task) { + String errorMessage; + String loginName = TokenData.takeFromRequest().getLoginName(); + // 这里必须先执行拾取操作,如果当前用户是候选人,特别是对于分布式场景,更是要先完成候选人的拾取。 + if (task.getAssignee() == null) { + // 没有指派人 + if (!this.isAssigneeOrCandidate(task)) { + errorMessage = "数据验证失败,当前用户不是该待办任务的候选人,请刷新后重试!"; + return CallResult.error(errorMessage); + } + // 作为候选人主动拾取任务。 + taskService.claim(task.getId(), loginName); + } else { + if (!task.getAssignee().equals(loginName)) { + errorMessage = "数据验证失败,当前用户不是该待办任务的指派人,请刷新后重试!"; + return CallResult.error(errorMessage); + } + } + return CallResult.ok(); + } + + @Override + public Map initAndGetProcessInstanceVariables(String processDefinitionId) { + TokenData tokenData = TokenData.takeFromRequest(); + String loginName = tokenData.getLoginName(); + // 设置流程变量。 + Map variableMap = new HashMap<>(4); + variableMap.put(FlowConstant.PROC_INSTANCE_INITIATOR_VAR, loginName); + variableMap.put(FlowConstant.PROC_INSTANCE_START_USER_NAME_VAR, loginName); + List flowTaskExtList = flowTaskExtService.getByProcessDefinitionId(processDefinitionId); + boolean hasDeptPostLeader = false; + boolean hasUpDeptPostLeader = false; + boolean hasPostCandidateGroup = false; + for (FlowTaskExt flowTaskExt : flowTaskExtList) { + if (StrUtil.equals(flowTaskExt.getGroupType(), FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER)) { + hasUpDeptPostLeader = true; + } else if (StrUtil.equals(flowTaskExt.getGroupType(), FlowConstant.GROUP_TYPE_DEPT_POST_LEADER)) { + hasDeptPostLeader = true; + } else if (StrUtil.equals(flowTaskExt.getGroupType(), FlowConstant.GROUP_TYPE_POST)) { + hasPostCandidateGroup = true; + } + } + // 如果流程图的配置中包含用户身份相关的变量(如:部门领导和上级领导审批),flowIdentityExtHelper就不能为null。 + // 这个需要子类去实现 BaseFlowIdentityExtHelper 接口,并注册到FlowCustomExtFactory的工厂中。 + BaseFlowIdentityExtHelper flowIdentityExtHelper = flowCustomExtFactory.getFlowIdentityExtHelper(); + if (hasUpDeptPostLeader) { + Assert.notNull(flowIdentityExtHelper); + Object upLeaderDeptPostId = flowIdentityExtHelper.getUpLeaderDeptPostId(tokenData.getDeptId()); + if (upLeaderDeptPostId == null) { + variableMap.put(FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER_VAR, null); + } else { + variableMap.put(FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER_VAR, upLeaderDeptPostId.toString()); + } + } + if (hasDeptPostLeader) { + Assert.notNull(flowIdentityExtHelper); + Object leaderDeptPostId = flowIdentityExtHelper.getLeaderDeptPostId(tokenData.getDeptId()); + if (leaderDeptPostId == null) { + variableMap.put(FlowConstant.GROUP_TYPE_DEPT_POST_LEADER_VAR, null); + } else { + variableMap.put(FlowConstant.GROUP_TYPE_DEPT_POST_LEADER_VAR, leaderDeptPostId.toString()); + } + } + if (hasPostCandidateGroup) { + Assert.notNull(flowIdentityExtHelper); + Map postGroupDataMap = + this.buildPostCandidateGroupData(flowIdentityExtHelper, flowTaskExtList); + variableMap.putAll(postGroupDataMap); + } + this.buildCopyData(flowTaskExtList, variableMap); + return variableMap; + } + + private void buildCopyData(List flowTaskExtList, Map variableMap) { + for (FlowTaskExt flowTaskExt : flowTaskExtList) { + if (StrUtil.isBlank(flowTaskExt.getCopyListJson())) { + continue; + } + List copyDataList = JSON.parseArray(flowTaskExt.getCopyListJson(), JSONObject.class); + Map copyDataMap = new HashMap<>(copyDataList.size()); + for (JSONObject copyData : copyDataList) { + String type = copyData.getString("type"); + String id = copyData.getString("id"); + copyDataMap.put(type, id == null ? "" : id); + } + variableMap.put(FlowConstant.COPY_DATA_MAP_PREFIX + flowTaskExt.getTaskId(), JSON.toJSONString(copyDataMap)); + } + } + + private Map buildPostCandidateGroupData( + BaseFlowIdentityExtHelper flowIdentityExtHelper, List flowTaskExtList) { + Map postVariableMap = MapUtil.newHashMap(); + Set selfPostIdSet = new HashSet<>(); + Set siblingPostIdSet = new HashSet<>(); + Set upPostIdSet = new HashSet<>(); + for (FlowTaskExt flowTaskExt : flowTaskExtList) { + if (flowTaskExt.getGroupType().equals(FlowConstant.GROUP_TYPE_POST)) { + Assert.notNull(flowTaskExt.getDeptPostListJson()); + List groupDataList = + JSONArray.parseArray(flowTaskExt.getDeptPostListJson(), FlowTaskPostCandidateGroup.class); + for (FlowTaskPostCandidateGroup groupData : groupDataList) { + switch (groupData.getType()) { + case FlowConstant.GROUP_TYPE_SELF_DEPT_POST_VAR -> selfPostIdSet.add(groupData.getPostId()); + case FlowConstant.GROUP_TYPE_SIBLING_DEPT_POST_VAR -> siblingPostIdSet.add(groupData.getPostId()); + case FlowConstant.GROUP_TYPE_UP_DEPT_POST_VAR -> upPostIdSet.add(groupData.getPostId()); + default -> { + } + } + } + } + } + postVariableMap.putAll(this.buildSelfPostCandidateGroupData(flowIdentityExtHelper, selfPostIdSet)); + postVariableMap.putAll(this.buildSiblingPostCandidateGroupData(flowIdentityExtHelper, siblingPostIdSet)); + postVariableMap.putAll(this.buildUpPostCandidateGroupData(flowIdentityExtHelper, upPostIdSet)); + return postVariableMap; + } + + private Map buildSelfPostCandidateGroupData( + BaseFlowIdentityExtHelper flowIdentityExtHelper, Set selfPostIdSet) { + Map postVariableMap = MapUtil.newHashMap(); + if (CollUtil.isNotEmpty(selfPostIdSet)) { + Map deptPostIdMap = + flowIdentityExtHelper.getDeptPostIdMap(TokenData.takeFromRequest().getDeptId(), selfPostIdSet); + for (String postId : selfPostIdSet) { + if (MapUtil.isNotEmpty(deptPostIdMap) && deptPostIdMap.containsKey(postId)) { + String deptPostId = deptPostIdMap.get(postId); + postVariableMap.put(FlowConstant.SELF_DEPT_POST_PREFIX + postId, deptPostId); + } else { + postVariableMap.put(FlowConstant.SELF_DEPT_POST_PREFIX + postId, ""); + } + } + } + return postVariableMap; + } + + private Map buildSiblingPostCandidateGroupData( + BaseFlowIdentityExtHelper flowIdentityExtHelper, Set siblingPostIdSet) { + Map postVariableMap = MapUtil.newHashMap(); + if (CollUtil.isNotEmpty(siblingPostIdSet)) { + Map siblingDeptPostIdMap = + flowIdentityExtHelper.getSiblingDeptPostIdMap(TokenData.takeFromRequest().getDeptId(), siblingPostIdSet); + for (String postId : siblingPostIdSet) { + if (MapUtil.isNotEmpty(siblingDeptPostIdMap) && siblingDeptPostIdMap.containsKey(postId)) { + String siblingDeptPostId = siblingDeptPostIdMap.get(postId); + postVariableMap.put(FlowConstant.SIBLING_DEPT_POST_PREFIX + postId, siblingDeptPostId); + } else { + postVariableMap.put(FlowConstant.SIBLING_DEPT_POST_PREFIX + postId, ""); + } + } + } + return postVariableMap; + } + + private Map buildUpPostCandidateGroupData( + BaseFlowIdentityExtHelper flowIdentityExtHelper, Set upPostIdSet) { + Map postVariableMap = MapUtil.newHashMap(); + if (CollUtil.isNotEmpty(upPostIdSet)) { + Map upDeptPostIdMap = + flowIdentityExtHelper.getUpDeptPostIdMap(TokenData.takeFromRequest().getDeptId(), upPostIdSet); + for (String postId : upPostIdSet) { + if (MapUtil.isNotEmpty(upDeptPostIdMap) && upDeptPostIdMap.containsKey(postId)) { + String upDeptPostId = upDeptPostIdMap.get(postId); + postVariableMap.put(FlowConstant.UP_DEPT_POST_PREFIX + postId, upDeptPostId); + } else { + postVariableMap.put(FlowConstant.UP_DEPT_POST_PREFIX + postId, ""); + } + } + } + return postVariableMap; + } + + @Override + public boolean isAssigneeOrCandidate(TaskInfo task) { + String loginName = TokenData.takeFromRequest().getLoginName(); + if (StrUtil.isNotBlank(task.getAssignee())) { + return StrUtil.equals(loginName, task.getAssignee()); + } + TaskQuery query = taskService.createTaskQuery(); + this.buildCandidateCondition(query, loginName); + query.taskId(task.getId()); + return query.active().count() != 0; + } + + @Override + public Collection getProcessAllElements(String processDefinitionId) { + Process process = repositoryService.getBpmnModel(processDefinitionId).getProcesses().get(0); + return this.getAllElements(process.getFlowElements(), null); + } + + @Override + public boolean isProcessInstanceStarter(String processInstanceId) { + String loginName = TokenData.takeFromRequest().getLoginName(); + return historyService.createHistoricProcessInstanceQuery() + .processInstanceId(processInstanceId).startedBy(loginName).count() != 0; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void setBusinessKeyForProcessInstance(String processInstanceId, Object dataId) { + runtimeService.updateBusinessKey(processInstanceId, dataId.toString()); + } + + @Override + public boolean existActiveProcessInstance(String processInstanceId) { + return runtimeService.createProcessInstanceQuery() + .processInstanceId(processInstanceId).active().count() != 0; + } + + @Override + public ProcessInstance getProcessInstance(String processInstanceId) { + return runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); + } + + @Override + public ProcessInstance getProcessInstanceByBusinessKey(String processDefinitionId, String businessKey) { + return runtimeService.createProcessInstanceQuery() + .processDefinitionId(processDefinitionId).processInstanceBusinessKey(businessKey).singleResult(); + } + + @Override + public Task getProcessInstanceActiveTask(String processInstanceId, String taskId) { + TaskQuery query = taskService.createTaskQuery().processInstanceId(processInstanceId); + if (StrUtil.isNotBlank(taskId)) { + query.taskId(taskId); + } + return query.active().singleResult(); + } + + @Override + public List getProcessInstanceActiveTaskList(String processInstanceId) { + return taskService.createTaskQuery().processInstanceId(processInstanceId).list(); + } + + @Override + public List getProcessInstanceActiveTaskListAndConvert(String processInstanceId) { + List taskList = taskService.createTaskQuery().processInstanceId(processInstanceId).list(); + return this.convertToFlowTaskList(taskList); + } + + @Override + public Task getTaskById(String taskId) { + return taskService.createTaskQuery().taskId(taskId).singleResult(); + } + + @Override + public MyPageData getTaskListByUserName( + String username, String definitionKey, String definitionName, String taskName, MyPageParam pageParam) { + TaskQuery query = this.createQuery(); + if (StrUtil.isNotBlank(definitionKey)) { + query.processDefinitionKey(definitionKey); + } + if (StrUtil.isNotBlank(definitionName)) { + query.processDefinitionNameLike("%" + definitionName + "%"); + } + if (StrUtil.isNotBlank(taskName)) { + query.taskNameLike("%" + taskName + "%"); + } + this.buildCandidateCondition(query, username); + long totalCount = query.count(); + query.orderByTaskCreateTime().desc(); + int firstResult = (pageParam.getPageNum() - 1) * pageParam.getPageSize(); + List taskList = query.listPage(firstResult, pageParam.getPageSize()); + return new MyPageData<>(taskList, totalCount); + } + + @Override + public long getTaskCountByUserName(String username) { + TaskQuery query = this.createQuery(); + this.buildCandidateCondition(query, username); + return query.count(); + } + + @Override + public List getTaskListByProcessInstanceIds(List processInstanceIdSet) { + return taskService.createTaskQuery().processInstanceIdIn(processInstanceIdSet).active().list(); + } + + @Override + public List getProcessInstanceList(Set processInstanceIdSet) { + return runtimeService.createProcessInstanceQuery().processInstanceIds(processInstanceIdSet).list(); + } + + @Override + public ProcessDefinition getProcessDefinitionById(String processDefinitionId) { + return repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult(); + } + + @Override + public List getProcessDefinitionList(Set processDefinitionIdSet) { + return repositoryService.createProcessDefinitionQuery().processDefinitionIds(processDefinitionIdSet).list(); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void suspendProcessDefinition(String processDefinitionId) { + repositoryService.suspendProcessDefinitionById(processDefinitionId); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void activateProcessDefinition(String processDefinitionId) { + repositoryService.activateProcessDefinitionById(processDefinitionId); + } + + @Override + public BpmnModel getBpmnModelByDefinitionId(String processDefinitionId) { + return repositoryService.getBpmnModel(processDefinitionId); + } + + @Override + public boolean isMultiInstanceTask(String processDefinitionId, String taskKey) { + BpmnModel model = this.getBpmnModelByDefinitionId(processDefinitionId); + FlowElement flowElement = model.getFlowElement(taskKey); + if (!(flowElement instanceof UserTask userTask)) { + return false; + } + return userTask.hasMultiInstanceLoopCharacteristics(); + } + + @Override + public ProcessDefinition getProcessDefinitionByDeployId(String deployId) { + return repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult(); + } + + @Override + public void setProcessInstanceVariables(String processInstanceId, Map variableMap) { + runtimeService.setVariables(processInstanceId, variableMap); + } + + @Override + public Object getProcessInstanceVariable(String processInstanceId, String variableName) { + return runtimeService.getVariable(processInstanceId, variableName); + } + + @Override + public List convertToFlowTaskList(List taskList) { + List flowTaskVoList = new LinkedList<>(); + if (CollUtil.isEmpty(taskList)) { + return flowTaskVoList; + } + Set processDefinitionIdSet = taskList.stream() + .map(Task::getProcessDefinitionId).collect(Collectors.toSet()); + Set procInstanceIdSet = taskList.stream() + .map(Task::getProcessInstanceId).collect(Collectors.toSet()); + List flowEntryPublishList = + flowEntryService.getFlowEntryPublishList(processDefinitionIdSet); + Map flowEntryPublishMap = + flowEntryPublishList.stream().collect(Collectors.toMap(FlowEntryPublish::getProcessDefinitionId, c -> c)); + List instanceList = this.getProcessInstanceList(procInstanceIdSet); + Map instanceMap = + instanceList.stream().collect(Collectors.toMap(ProcessInstance::getId, c -> c)); + List definitionList = this.getProcessDefinitionList(processDefinitionIdSet); + Map definitionMap = + definitionList.stream().collect(Collectors.toMap(ProcessDefinition::getId, c -> c)); + List workOrderList = + flowWorkOrderService.getInList("processInstanceId", procInstanceIdSet); + Map workOrderMap = + workOrderList.stream().collect(Collectors.toMap(FlowWorkOrder::getProcessInstanceId, c -> c)); + for (Task task : taskList) { + FlowTaskVo flowTaskVo = new FlowTaskVo(); + flowTaskVo.setTaskId(task.getId()); + flowTaskVo.setTaskName(task.getName()); + flowTaskVo.setTaskKey(task.getTaskDefinitionKey()); + flowTaskVo.setTaskFormKey(task.getFormKey()); + flowTaskVo.setTaskStartTime(task.getCreateTime()); + flowTaskVo.setEntryId(flowEntryPublishMap.get(task.getProcessDefinitionId()).getEntryId()); + ProcessDefinition processDefinition = definitionMap.get(task.getProcessDefinitionId()); + flowTaskVo.setProcessDefinitionId(processDefinition.getId()); + flowTaskVo.setProcessDefinitionName(processDefinition.getName()); + flowTaskVo.setProcessDefinitionKey(processDefinition.getKey()); + flowTaskVo.setProcessDefinitionVersion(processDefinition.getVersion()); + ProcessInstance processInstance = instanceMap.get(task.getProcessInstanceId()); + flowTaskVo.setProcessInstanceId(processInstance.getId()); + Object initiator = this.getProcessInstanceVariable( + processInstance.getId(), FlowConstant.PROC_INSTANCE_INITIATOR_VAR); + flowTaskVo.setProcessInstanceInitiator(initiator.toString()); + flowTaskVo.setProcessInstanceStartTime(processInstance.getStartTime()); + flowTaskVo.setBusinessKey(processInstance.getBusinessKey()); + FlowWorkOrder flowWorkOrder = workOrderMap.get(task.getProcessInstanceId()); + if (flowWorkOrder != null) { + flowTaskVo.setIsDraft(flowWorkOrder.getFlowStatus().equals(FlowTaskStatus.DRAFT)); + flowTaskVo.setWorkOrderCode(flowWorkOrder.getWorkOrderCode()); + } + flowTaskVoList.add(flowTaskVo); + } + Set loginNameSet = flowTaskVoList.stream() + .map(FlowTaskVo::getProcessInstanceInitiator).collect(Collectors.toSet()); + List flowUserInfos = flowCustomExtFactory + .getFlowIdentityExtHelper().getUserInfoListByUsernameSet(loginNameSet); + Map userInfoMap = + flowUserInfos.stream().collect(Collectors.toMap(FlowUserInfoVo::getLoginName, c -> c)); + for (FlowTaskVo flowTaskVo : flowTaskVoList) { + FlowUserInfoVo userInfo = userInfoMap.get(flowTaskVo.getProcessInstanceInitiator()); + flowTaskVo.setShowName(userInfo.getShowName()); + flowTaskVo.setHeadImageUrl(userInfo.getHeadImageUrl()); + } + return flowTaskVoList; + } + + @Override + public void addProcessInstanceEndListener(BpmnModel bpmnModel, Class listenerClazz) { + Assert.notNull(listenerClazz); + Process process = bpmnModel.getMainProcess(); + FlowableListener listener = this.createListener("end", listenerClazz.getName()); + process.getExecutionListeners().add(listener); + } + + @Override + public void addExecutionListener( + FlowElement flowElement, + Class listenerClazz, + String event, + List fieldExtensions) { + Assert.notNull(listenerClazz); + FlowableListener listener = this.createListener(event, listenerClazz.getName()); + if (fieldExtensions != null) { + listener.setFieldExtensions(fieldExtensions); + } + flowElement.getExecutionListeners().add(listener); + } + + @Override + public void addTaskCreateListener(UserTask userTask, Class listenerClazz) { + Assert.notNull(listenerClazz); + FlowableListener listener = this.createListener("create", listenerClazz.getName()); + userTask.getTaskListeners().add(listener); + } + + @Override + public HistoricProcessInstance getHistoricProcessInstance(String processInstanceId) { + return historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); + } + + @Override + public List getHistoricProcessInstanceList(Set processInstanceIdSet) { + return historyService.createHistoricProcessInstanceQuery().processInstanceIds(processInstanceIdSet).list(); + } + + @Override + public MyPageData getHistoricProcessInstanceList( + String processDefinitionKey, + String processDefinitionName, + String startUser, + String beginDate, + String endDate, + MyPageParam pageParam, + boolean finishedOnly) throws ParseException { + HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery(); + if (StrUtil.isNotBlank(processDefinitionKey)) { + query.processDefinitionKey(processDefinitionKey); + } + if (StrUtil.isNotBlank(processDefinitionName)) { + query.processDefinitionName(processDefinitionName); + } + if (StrUtil.isNotBlank(startUser)) { + query.startedBy(startUser); + } + if (StrUtil.isNotBlank(beginDate)) { + SimpleDateFormat sdf = new SimpleDateFormat(MyDateUtil.COMMON_SHORT_DATETIME_FORMAT); + query.startedAfter(sdf.parse(beginDate)); + } + if (StrUtil.isNotBlank(endDate)) { + SimpleDateFormat sdf = new SimpleDateFormat(MyDateUtil.COMMON_SHORT_DATETIME_FORMAT); + query.startedBefore(sdf.parse(endDate)); + } + TokenData tokenData = TokenData.takeFromRequest(); + if (tokenData.getTenantId() != null) { + query.processInstanceTenantId(tokenData.getTenantId().toString()); + } else { + if (tokenData.getAppCode() == null) { + query.processInstanceWithoutTenantId(); + } else { + query.processInstanceTenantId(tokenData.getAppCode()); + } + } + if (finishedOnly) { + query.finished(); + } + query.orderByProcessInstanceStartTime().desc(); + long totalCount = query.count(); + int firstResult = (pageParam.getPageNum() - 1) * pageParam.getPageSize(); + List instanceList = query.listPage(firstResult, pageParam.getPageSize()); + return new MyPageData<>(instanceList, totalCount); + } + + @Override + public MyPageData getHistoricTaskInstanceFinishedList( + String processDefinitionName, + String beginDate, + String endDate, + MyPageParam pageParam) throws ParseException { + String loginName = TokenData.takeFromRequest().getLoginName(); + HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery() + .taskAssignee(loginName) + .finished(); + if (StrUtil.isNotBlank(processDefinitionName)) { + query.processDefinitionName(processDefinitionName); + } + if (StrUtil.isNotBlank(beginDate)) { + SimpleDateFormat sdf = new SimpleDateFormat(MyDateUtil.COMMON_SHORT_DATETIME_FORMAT); + query.taskCompletedAfter(sdf.parse(beginDate)); + } + if (StrUtil.isNotBlank(endDate)) { + SimpleDateFormat sdf = new SimpleDateFormat(MyDateUtil.COMMON_SHORT_DATETIME_FORMAT); + query.taskCompletedBefore(sdf.parse(endDate)); + } + TokenData tokenData = TokenData.takeFromRequest(); + if (tokenData.getTenantId() != null) { + query.taskTenantId(tokenData.getTenantId().toString()); + } else { + if (StrUtil.isBlank(tokenData.getAppCode())) { + query.taskWithoutTenantId(); + } else { + query.taskTenantId(tokenData.getAppCode()); + } + } + query.orderByHistoricTaskInstanceEndTime().desc(); + long totalCount = query.count(); + int firstResult = (pageParam.getPageNum() - 1) * pageParam.getPageSize(); + List instanceList = query.listPage(firstResult, pageParam.getPageSize()); + return new MyPageData<>(instanceList, totalCount); + } + + @Override + public List getHistoricActivityInstanceList(String processInstanceId) { + return historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list(); + } + + @Override + public List getHistoricActivityInstanceListOrderByStartTime(String processInstanceId) { + return historyService.createHistoricActivityInstanceQuery() + .processInstanceId(processInstanceId).orderByHistoricActivityInstanceStartTime().asc().list(); + } + + @Override + public HistoricTaskInstance getHistoricTaskInstance(String processInstanceId, String taskId) { + return historyService.createHistoricTaskInstanceQuery() + .processInstanceId(processInstanceId).taskId(taskId).singleResult(); + } + + @Override + public List getHistoricUnfinishedInstanceList(String processInstanceId) { + return historyService.createHistoricActivityInstanceQuery() + .processInstanceId(processInstanceId).unfinished().list(); + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public CallResult stopProcessInstance(String processInstanceId, String stopReason, boolean forCancel) { + //需要先更新状态,以便FlowFinishedListener监听器可以正常的判断流程结束的状态。 + int status = FlowTaskStatus.STOPPED; + if (forCancel) { + status = FlowTaskStatus.CANCELLED; + } + return this.stopProcessInstance(processInstanceId, stopReason, status); + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public CallResult stopProcessInstance(String processInstanceId, String stopReason, int status) { + List taskList = taskService.createTaskQuery().processInstanceId(processInstanceId).active().list(); + if (CollUtil.isEmpty(taskList)) { + return CallResult.error("数据验证失败,当前流程尚未开始或已经结束!"); + } + BpmnModel bpmnModel = repositoryService.getBpmnModel(taskList.get(0).getProcessDefinitionId()); + EndEvent endEvent = bpmnModel.getMainProcess() + .findFlowElementsOfType(EndEvent.class, false).get(0); + List currentActivitiIds = new LinkedList<>(); + flowWorkOrderService.updateFlowStatusByProcessInstanceId(processInstanceId, status); + for (Task task : taskList) { + String currActivityId = task.getTaskDefinitionKey(); + currentActivitiIds.add(currActivityId); + FlowNode currFlow = (FlowNode) bpmnModel.getMainProcess().getFlowElement(currActivityId); + if (currFlow == null) { + List subProcessList = + bpmnModel.getMainProcess().findFlowElementsOfType(SubProcess.class); + for (SubProcess subProcess : subProcessList) { + FlowElement flowElement = subProcess.getFlowElement(currActivityId); + if (flowElement != null) { + currFlow = (FlowNode) flowElement; + break; + } + } + } + org.springframework.util.Assert.notNull(currFlow, "currFlow can't be NULL"); + if (!(currFlow.getParentContainer().equals(endEvent.getParentContainer()))) { + throw new FlowOperationException("数据验证失败,不能从子流程直接中止!"); + } + FlowTaskComment taskComment = new FlowTaskComment(task); + taskComment.setApprovalType(FlowApprovalType.STOP); + taskComment.setTaskComment(stopReason); + flowTaskCommentService.saveNew(taskComment); + } + this.doChangeState(processInstanceId, currentActivitiIds, CollUtil.newArrayList(endEvent.getId())); + flowMessageService.updateFinishedStatusByProcessInstanceId(processInstanceId); + return CallResult.ok(); + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public void deleteProcessInstance(String processInstanceId) { + historyService.deleteHistoricProcessInstance(processInstanceId); + flowMessageService.removeByProcessInstanceId(processInstanceId); + FlowWorkOrder workOrder = flowWorkOrderService.getFlowWorkOrderByProcessInstanceId(processInstanceId); + if (workOrder == null) { + return; + } + FlowEntry flowEntry = flowEntryService.getFlowEntryFromCache(workOrder.getProcessDefinitionKey()); + if (StrUtil.isNotBlank(flowEntry.getExtensionData())) { + FlowEntryExtensionData extData = JSON.parseObject(flowEntry.getExtensionData(), FlowEntryExtensionData.class); + if (BooleanUtil.isTrue(extData.getCascadeDeleteBusinessData())) { + // 级联删除在线表单工作流的业务数据。 + flowCustomExtFactory.getOnlineBusinessDataExtHelper().deleteBusinessData(workOrder); + } + } + flowWorkOrderService.removeByProcessInstanceId(processInstanceId); + } + + @Override + public Object getTaskVariable(String taskId, String variableName) { + return taskService.getVariable(taskId, variableName); + } + + @Override + public String getTaskVariableStringWithSafe(String taskId, String variableName) { + try { + Object v = taskService.getVariable(taskId, variableName); + if (v == null) { + return null; + } + return v.toString(); + } catch (Exception e) { + String errorMessage = + String.format("Failed to getTaskVariable taskId [%s], variableName [%s]", taskId, variableName); + log.error(errorMessage, e); + return null; + } + } + + @Override + public Object getExecutionVariable(String executionId, String variableName) { + return runtimeService.getVariable(executionId, variableName); + } + + @Override + public String getExecutionVariableStringWithSafe(String executionId, String variableName) { + try { + Object v = runtimeService.getVariable(executionId, variableName); + if (v == null) { + return null; + } + return v.toString(); + } catch (Exception e) { + String errorMessage = String.format( + "Failed to getExecutionVariableStringWithSafe executionId [%s], variableName [%s]", executionId, variableName); + log.error(errorMessage, e); + return null; + } + } + + @Override + public Object getHistoricProcessInstanceVariable(String processInstanceId, String variableName) { + HistoricVariableInstance hv = historyService.createHistoricVariableInstanceQuery() + .processInstanceId(processInstanceId).variableName(variableName).singleResult(); + return hv == null ? null : hv.getValue(); + } + + @Override + public BpmnModel convertToBpmnModel(String bpmnXml) throws XMLStreamException { + BpmnXMLConverter converter = new BpmnXMLConverter(); + InputStream in = new ByteArrayInputStream(bpmnXml.getBytes(StandardCharsets.UTF_8)); + @Cleanup XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(in); + return converter.convertToBpmnModel(reader); + } + + @Transactional + @Override + public CallResult backToRuntimeTask(Task task, String targetKey, boolean forReject, String reason) { + String errorMessage; + ProcessDefinition processDefinition = this.getProcessDefinitionById(task.getProcessDefinitionId()); + Collection allElements = this.getProcessAllElements(processDefinition.getId()); + FlowElement source = null; + // 获取跳转的节点元素 + FlowElement target = null; + for (FlowElement flowElement : allElements) { + if (flowElement.getId().equals(task.getTaskDefinitionKey())) { + source = flowElement; + if (StrUtil.isBlank(targetKey)) { + break; + } + } + if (StrUtil.isNotBlank(targetKey)) { + if (flowElement.getId().equals(targetKey)) { + target = flowElement; + } + } + } + if (targetKey != null && target == null) { + errorMessage = "数据验证失败,被驳回的指定目标节点不存在!"; + return CallResult.error(errorMessage); + } + UserTask oneUserTask = null; + List targetIds = null; + if (target == null) { + List parentUserTaskList = this.getParentUserTaskList(source, null, null); + if (CollUtil.isEmpty(parentUserTaskList)) { + errorMessage = "数据验证失败,当前节点为初始任务节点,不能驳回!"; + return CallResult.error(errorMessage); + } + // 获取活动ID, 即节点Key + Set parentUserTaskKeySet = new HashSet<>(); + parentUserTaskList.forEach(item -> parentUserTaskKeySet.add(item.getId())); + List historicActivityIdList = + this.getHistoricActivityInstanceListOrderByStartTime(task.getProcessInstanceId()); + // 数据清洗,将回滚导致的脏数据清洗掉 + List lastHistoricTaskInstanceList = + this.cleanHistoricTaskInstance(allElements, historicActivityIdList); + // 此时历史任务实例为倒序,获取最后走的节点 + targetIds = new ArrayList<>(); + // 循环结束标识,遇到当前目标节点的次数 + int number = 0; + StringBuilder parentHistoricTaskKey = new StringBuilder(); + for (String historicTaskInstanceKey : lastHistoricTaskInstanceList) { + // 当会签时候会出现特殊的,连续都是同一个节点历史数据的情况,这种时候跳过 + if (parentHistoricTaskKey.toString().equals(historicTaskInstanceKey)) { + continue; + } + parentHistoricTaskKey = new StringBuilder(historicTaskInstanceKey); + if (historicTaskInstanceKey.equals(task.getTaskDefinitionKey())) { + number++; + } + if (number == 2) { + break; + } + // 如果当前历史节点,属于父级的节点,说明最后一次经过了这个点,需要退回这个点 + if (parentUserTaskKeySet.contains(historicTaskInstanceKey)) { + targetIds.add(historicTaskInstanceKey); + } + } + // 目的获取所有需要被跳转的节点 currentIds + // 取其中一个父级任务,因为后续要么存在公共网关,要么就是串行公共线路 + oneUserTask = parentUserTaskList.get(0); + } + // 获取所有正常进行的执行任务的活动节点ID,这些任务不能直接使用,需要找出其中需要撤回的任务 + List runExecutionList = + runtimeService.createExecutionQuery().processInstanceId(task.getProcessInstanceId()).list(); + List runActivityIdList = runExecutionList.stream() + .map(Execution::getActivityId) + .filter(StrUtil::isNotBlank).collect(Collectors.toList()); + // 需驳回任务列表 + List currentIds = new ArrayList<>(); + // 通过父级网关的出口连线,结合 runExecutionList 比对,获取需要撤回的任务 + List currentFlowElementList = this.getChildUserTaskList( + target != null ? target : oneUserTask, runActivityIdList, null, null); + currentFlowElementList.forEach(item -> currentIds.add(item.getId())); + if (target == null) { + // 规定:并行网关之前节点必须需存在唯一用户任务节点,如果出现多个任务节点,则并行网关节点默认为结束节点,原因为不考虑多对多情况 + if (targetIds.size() > 1 && currentIds.size() > 1) { + errorMessage = "数据验证失败,任务出现多对多情况,无法撤回!"; + return CallResult.error(errorMessage); + } + } + AtomicReference> tmp = new AtomicReference<>(); + // 用于下面新增网关删除信息时使用 + String targetTmp = targetKey != null ? targetKey : String.join(",", targetIds); + // currentIds 为活动ID列表 + // currentExecutionIds 为执行任务ID列表 + // 需要通过执行任务ID来设置驳回信息,活动ID不行 + currentIds.forEach(currentId -> runExecutionList.forEach(runExecution -> { + if (StrUtil.isNotBlank(runExecution.getActivityId()) && currentId.equals(runExecution.getActivityId())) { + // 查询当前节点的执行任务的历史数据 + tmp.set(historyService.createHistoricActivityInstanceQuery() + .processInstanceId(task.getProcessInstanceId()) + .executionId(runExecution.getId()) + .activityId(runExecution.getActivityId()).list()); + // 如果这个列表的数据只有 1 条数据 + // 网关肯定只有一条,且为包容网关或并行网关 + // 这里的操作目的是为了给网关在扭转前提前加上删除信息,结构与普通节点的删除信息一样,目的是为了知道这个网关也是有经过跳转的 + if (tmp.get() != null && tmp.get().size() == 1 && StrUtil.isNotBlank(tmp.get().get(0).getActivityType()) + && ("parallelGateway".equals(tmp.get().get(0).getActivityType()) || "inclusiveGateway".equals(tmp.get().get(0).getActivityType()))) { + // singleResult 能够执行更新操作 + // 利用 流程实例ID + 执行任务ID + 活动节点ID 来指定唯一数据,保证数据正确 + historyService.createNativeHistoricActivityInstanceQuery().sql( + "UPDATE ACT_HI_ACTINST SET DELETE_REASON_ = 'Change activity to " + targetTmp + "' WHERE PROC_INST_ID_='" + task.getProcessInstanceId() + "' AND EXECUTION_ID_='" + runExecution.getId() + "' AND ACT_ID_='" + runExecution.getActivityId() + "'").singleResult(); + } + } + })); + try { + if (StrUtil.isNotBlank(targetKey)) { + runtimeService.createChangeActivityStateBuilder() + .processInstanceId(task.getProcessInstanceId()) + .moveActivityIdsToSingleActivityId(currentIds, targetKey).changeState(); + } else { + // 如果父级任务多于 1 个,说明当前节点不是并行节点,原因为不考虑多对多情况 + if (targetIds.size() > 1) { + // 1 对 多任务跳转,currentIds 当前节点(1),targetIds 跳转到的节点(多) + ChangeActivityStateBuilder builder = runtimeService.createChangeActivityStateBuilder() + .processInstanceId(task.getProcessInstanceId()) + .moveSingleActivityIdToActivityIds(currentIds.get(0), targetIds); + for (String targetId : targetIds) { + FlowTaskComment taskComment = + flowTaskCommentService.getLatestFlowTaskComment(task.getProcessInstanceId(), targetId); + // 如果驳回后的目标任务包含指定人,则直接通过变量回抄,如果没有则自动忽略该变量,不会给流程带来任何影响。 + String submitLoginName = taskComment.getCreateLoginName(); + if (StrUtil.isNotBlank(submitLoginName)) { + builder.localVariable(targetId, FlowConstant.TASK_APPOINTED_ASSIGNEE_VAR, submitLoginName); + } + } + builder.changeState(); + } + // 如果父级任务只有一个,因此当前任务可能为网关中的任务 + if (targetIds.size() == 1) { + // 1 对 1 或 多 对 1 情况,currentIds 当前要跳转的节点列表(1或多),targetIds.get(0) 跳转到的节点(1) + // 如果驳回后的目标任务包含指定人,则直接通过变量回抄,如果没有则自动忽略该变量,不会给流程带来任何影响。 + ChangeActivityStateBuilder builder = runtimeService.createChangeActivityStateBuilder() + .processInstanceId(task.getProcessInstanceId()) + .moveActivityIdsToSingleActivityId(currentIds, targetIds.get(0)); + FlowTaskComment taskComment = + flowTaskCommentService.getLatestFlowTaskComment(task.getProcessInstanceId(), targetIds.get(0)); + String submitLoginName = taskComment.getCreateLoginName(); + if (StrUtil.isNotBlank(submitLoginName)) { + builder.localVariable(targetIds.get(0), FlowConstant.TASK_APPOINTED_ASSIGNEE_VAR, submitLoginName); + } + builder.changeState(); + } + } + FlowTaskComment comment = new FlowTaskComment(); + comment.setTaskId(task.getId()); + comment.setTaskKey(task.getTaskDefinitionKey()); + comment.setTaskName(task.getName()); + comment.setApprovalType(forReject ? FlowApprovalType.REJECT : FlowApprovalType.REVOKE); + comment.setProcessInstanceId(task.getProcessInstanceId()); + comment.setTaskComment(reason); + flowTaskCommentService.saveNew(comment); + } catch (Exception e) { + log.error("Failed to execute moveSingleActivityIdToActivityIds", e); + return CallResult.error(e.getMessage()); + } + return CallResult.ok(); + } + + private List getParentUserTaskList( + FlowElement source, Set hasSequenceFlow, List userTaskList) { + userTaskList = userTaskList == null ? new ArrayList<>() : userTaskList; + hasSequenceFlow = hasSequenceFlow == null ? new HashSet<>() : hasSequenceFlow; + // 如果该节点为开始节点,且存在上级子节点,则顺着上级子节点继续迭代 + if (source instanceof StartEvent && source.getSubProcess() != null) { + userTaskList = getParentUserTaskList(source.getSubProcess(), hasSequenceFlow, userTaskList); + } + List sequenceFlows = getElementIncomingFlows(source); + if (sequenceFlows != null) { + // 循环找到目标元素 + for (SequenceFlow sequenceFlow : sequenceFlows) { + // 如果发现连线重复,说明循环了,跳过这个循环 + if (hasSequenceFlow.contains(sequenceFlow.getId())) { + continue; + } + // 添加已经走过的连线 + hasSequenceFlow.add(sequenceFlow.getId()); + // 类型为用户节点,则新增父级节点 + if (sequenceFlow.getSourceFlowElement() instanceof UserTask) { + userTaskList.add((UserTask) sequenceFlow.getSourceFlowElement()); + continue; + } + // 类型为子流程,则添加子流程开始节点出口处相连的节点 + if (sequenceFlow.getSourceFlowElement() instanceof SubProcess) { + // 获取子流程用户任务节点 + List childUserTaskList = findChildProcessUserTasks( + (StartEvent) ((SubProcess) sequenceFlow.getSourceFlowElement()).getFlowElements().toArray()[0], null, null); + // 如果找到节点,则说明该线路找到节点,不继续向下找,反之继续 + if (childUserTaskList != null && !childUserTaskList.isEmpty()) { + userTaskList.addAll(childUserTaskList); + continue; + } + } + // 网关场景的继续迭代 + // 注意:已经经过的节点与连线都应该用浅拷贝出来的对象 + // 比如分支:a->b->c与a->d->c,走完a->b->c后走另一个路线是,已经经过的节点应该不包含a->b->c路线的数据 + userTaskList = getParentUserTaskList( + sequenceFlow.getSourceFlowElement(), new HashSet<>(hasSequenceFlow), userTaskList); + } + } + return userTaskList; + } + + private List getChildUserTaskList( + FlowElement source, List runActiveIdList, Set hasSequenceFlow, List flowElementList) { + hasSequenceFlow = hasSequenceFlow == null ? new HashSet<>() : hasSequenceFlow; + flowElementList = flowElementList == null ? new ArrayList<>() : flowElementList; + // 如果该节点为开始节点,且存在上级子节点,则顺着上级子节点继续迭代 + if (source instanceof EndEvent && source.getSubProcess() != null) { + flowElementList = getChildUserTaskList( + source.getSubProcess(), runActiveIdList, hasSequenceFlow, flowElementList); + } + // 根据类型,获取出口连线 + List sequenceFlows = getElementOutgoingFlows(source); + if (sequenceFlows != null) { + // 循环找到目标元素 + for (SequenceFlow sequenceFlow: sequenceFlows) { + // 如果发现连线重复,说明循环了,跳过这个循环 + if (hasSequenceFlow.contains(sequenceFlow.getId())) { + continue; + } + // 添加已经走过的连线 + hasSequenceFlow.add(sequenceFlow.getId()); + // 如果为用户任务类型,或者为网关 + // 活动节点ID 在运行的任务中存在,添加 + FlowElement targetElement = sequenceFlow.getTargetFlowElement(); + if ((targetElement instanceof UserTask || targetElement instanceof Gateway) + && runActiveIdList.contains(targetElement.getId())) { + flowElementList.add(sequenceFlow.getTargetFlowElement()); + continue; + } + // 如果节点为子流程节点情况,则从节点中的第一个节点开始获取 + if (sequenceFlow.getTargetFlowElement() instanceof SubProcess) { + List childUserTaskList = getChildUserTaskList( + (FlowElement) (((SubProcess) sequenceFlow.getTargetFlowElement()).getFlowElements().toArray()[0]), runActiveIdList, hasSequenceFlow, null); + // 如果找到节点,则说明该线路找到节点,不继续向下找,反之继续 + if (childUserTaskList != null && !childUserTaskList.isEmpty()) { + flowElementList.addAll(childUserTaskList); + continue; + } + } + // 继续迭代 + // 注意:已经经过的节点与连线都应该用浅拷贝出来的对象 + // 比如分支:a->b->c与a->d->c,走完a->b->c后走另一个路线是,已经经过的节点应该不包含a->b->c路线的数据 + flowElementList = getChildUserTaskList( + sequenceFlow.getTargetFlowElement(), runActiveIdList, new HashSet<>(hasSequenceFlow), flowElementList); + } + } + return flowElementList; + } + + private List cleanHistoricTaskInstance( + Collection allElements, List historicActivityList) { + // 会签节点收集 + List multiTask = new ArrayList<>(); + allElements.forEach(flowElement -> { + if (flowElement instanceof UserTask) { + // 如果该节点的行为为会签行为,说明该节点为会签节点 + if (((UserTask) flowElement).getBehavior() instanceof ParallelMultiInstanceBehavior + || ((UserTask) flowElement).getBehavior() instanceof SequentialMultiInstanceBehavior) { + multiTask.add(flowElement.getId()); + } + } + }); + // 循环放入栈,栈 LIFO:后进先出 + Stack stack = new Stack<>(); + historicActivityList.forEach(stack::push); + // 清洗后的历史任务实例 + List lastHistoricTaskInstanceList = new ArrayList<>(); + // 网关存在可能只走了部分分支情况,且还存在跳转废弃数据以及其他分支数据的干扰,因此需要对历史节点数据进行清洗 + // 临时用户任务 key + StringBuilder userTaskKey = null; + // 临时被删掉的任务 key,存在并行情况 + List deleteKeyList = new ArrayList<>(); + // 临时脏数据线路 + List> dirtyDataLineList = new ArrayList<>(); + // 由某个点跳到会签点,此时出现多个会签实例对应 1 个跳转情况,需要把这些连续脏数据都找到 + // 会签特殊处理下标 + int multiIndex = -1; + // 会签特殊处理 key + StringBuilder multiKey = null; + // 会签特殊处理操作标识 + boolean multiOpera = false; + while (!stack.empty()) { + // 从这里开始 userTaskKey 都还是上个栈的 key + // 是否是脏数据线路上的点 + final boolean[] isDirtyData = {false}; + for (Set oldDirtyDataLine : dirtyDataLineList) { + if (oldDirtyDataLine.contains(stack.peek().getActivityId())) { + isDirtyData[0] = true; + } + } + // 删除原因不为空,说明从这条数据开始回跳或者回退的 + // MI_END:会签完成后,其他未签到节点的删除原因,不在处理范围内 + if (stack.peek().getDeleteReason() != null && !"MI_END".equals(stack.peek().getDeleteReason())) { + // 可以理解为脏线路起点 + String dirtyPoint = ""; + if (stack.peek().getDeleteReason().contains("Change activity to ")) { + dirtyPoint = stack.peek().getDeleteReason().replace("Change activity to ", ""); + } + // 会签回退删除原因有点不同 + if (stack.peek().getDeleteReason().contains("Change parent activity to ")) { + dirtyPoint = stack.peek().getDeleteReason().replace("Change parent activity to ", ""); + } + FlowElement dirtyTask = null; + // 获取变更节点的对应的入口处连线 + // 如果是网关并行回退情况,会变成两条脏数据路线,效果一样 + for (FlowElement flowElement : allElements) { + if (flowElement.getId().equals(stack.peek().getActivityId())) { + dirtyTask = flowElement; + } + } + // 获取脏数据线路 + Set dirtyDataLine = + findDirtyRoads(dirtyTask, null, null, StrUtil.split(dirtyPoint, ','), null); + // 自己本身也是脏线路上的点,加进去 + dirtyDataLine.add(stack.peek().getActivityId()); + log.info(stack.peek().getActivityId() + "点脏路线集合:" + dirtyDataLine); + // 是全新的需要添加的脏线路 + boolean isNewDirtyData = true; + for (Set strings : dirtyDataLineList) { + // 如果发现他的上个节点在脏线路内,说明这个点可能是并行的节点,或者连续驳回 + // 这时,都以之前的脏线路节点为标准,只需合并脏线路即可,也就是路线补全 + if (strings.contains(userTaskKey.toString())) { + isNewDirtyData = false; + strings.addAll(dirtyDataLine); + } + } + // 已确定时全新的脏线路 + if (isNewDirtyData) { + // deleteKey 单一路线驳回到并行,这种同时生成多个新实例记录情况,这时 deleteKey 其实是由多个值组成 + // 按照逻辑,回退后立刻生成的实例记录就是回退的记录 + // 至于驳回所生成的 Key,直接从删除原因中获取,因为存在驳回到并行的情况 + deleteKeyList.add(dirtyPoint + ","); + dirtyDataLineList.add(dirtyDataLine); + } + // 添加后,现在这个点变成脏线路上的点了 + isDirtyData[0] = true; + } + // 如果不是脏线路上的点,说明是有效数据,添加历史实例 Key + if (!isDirtyData[0]) { + lastHistoricTaskInstanceList.add(stack.peek().getActivityId()); + } + // 校验脏线路是否结束 + for (int i = 0; i < deleteKeyList.size(); i ++) { + // 如果发现脏数据属于会签,记录下下标与对应 Key,以备后续比对,会签脏数据范畴开始 + if (multiKey == null && multiTask.contains(stack.peek().getActivityId()) + && deleteKeyList.get(i).contains(stack.peek().getActivityId())) { + multiIndex = i; + multiKey = new StringBuilder(stack.peek().getActivityId()); + } + // 会签脏数据处理,节点退回会签清空 + // 如果在会签脏数据范畴中发现 Key改变,说明会签脏数据在上个节点就结束了,可以把会签脏数据删掉 + if (multiKey != null && !multiKey.toString().equals(stack.peek().getActivityId())) { + deleteKeyList.set(multiIndex , deleteKeyList.get(multiIndex).replace(stack.peek().getActivityId() + ",", "")); + multiKey = null; + // 结束进行下校验删除 + multiOpera = true; + } + // 其他脏数据处理 + // 发现该路线最后一条脏数据,说明这条脏数据线路处理完了,删除脏数据信息 + // 脏数据产生的新实例中是否包含这条数据 + if (multiKey == null && deleteKeyList.get(i).contains(stack.peek().getActivityId())) { + // 删除匹配到的部分 + deleteKeyList.set(i , deleteKeyList.get(i).replace(stack.peek().getActivityId() + ",", "")); + } + // 如果每组中的元素都以匹配过,说明脏数据结束 + if ("".equals(deleteKeyList.get(i))) { + // 同时删除脏数据 + deleteKeyList.remove(i); + dirtyDataLineList.remove(i); + break; + } + } + // 会签数据处理需要在循环外处理,否则可能导致溢出 + // 会签的数据肯定是之前放进去的所以理论上不会溢出,但还是校验下 + if (multiOpera && deleteKeyList.size() > multiIndex && "".equals(deleteKeyList.get(multiIndex))) { + // 同时删除脏数据 + deleteKeyList.remove(multiIndex); + dirtyDataLineList.remove(multiIndex); + multiIndex = -1; + multiOpera = false; + } + // pop() 方法与 peek() 方法不同,在返回值的同时,会把值从栈中移除 + // 保存新的 userTaskKey 在下个循环中使用 + userTaskKey = new StringBuilder(stack.pop().getActivityId()); + } + log.info("清洗后的历史节点数据:" + lastHistoricTaskInstanceList); + return lastHistoricTaskInstanceList; + } + + private List findChildProcessUserTasks(FlowElement source, Set hasSequenceFlow, List userTaskList) { + hasSequenceFlow = hasSequenceFlow == null ? new HashSet<>() : hasSequenceFlow; + userTaskList = userTaskList == null ? new ArrayList<>() : userTaskList; + // 根据类型,获取出口连线 + List sequenceFlows = getElementOutgoingFlows(source); + if (sequenceFlows != null) { + // 循环找到目标元素 + for (SequenceFlow sequenceFlow : sequenceFlows) { + // 如果发现连线重复,说明循环了,跳过这个循环 + if (hasSequenceFlow.contains(sequenceFlow.getId())) { + continue; + } + // 添加已经走过的连线 + hasSequenceFlow.add(sequenceFlow.getId()); + // 如果为用户任务类型,且任务节点的 Key 正在运行的任务中存在,添加 + if (sequenceFlow.getTargetFlowElement() instanceof UserTask) { + userTaskList.add((UserTask) sequenceFlow.getTargetFlowElement()); + continue; + } + // 如果节点为子流程节点情况,则从节点中的第一个节点开始获取 + if (sequenceFlow.getTargetFlowElement() instanceof SubProcess) { + List childUserTaskList = findChildProcessUserTasks((FlowElement) (((SubProcess) sequenceFlow.getTargetFlowElement()).getFlowElements().toArray()[0]), hasSequenceFlow, null); + // 如果找到节点,则说明该线路找到节点,不继续向下找,反之继续 + if (childUserTaskList != null && !childUserTaskList.isEmpty()) { + userTaskList.addAll(childUserTaskList); + continue; + } + } + // 继续迭代 + // 注意:已经经过的节点与连线都应该用浅拷贝出来的对象 + // 比如分支:a->b->c与a->d->c,走完a->b->c后走另一个路线是,已经经过的节点应该不包含a->b->c路线的数据 + userTaskList = findChildProcessUserTasks(sequenceFlow.getTargetFlowElement(), new HashSet<>(hasSequenceFlow), userTaskList); + } + } + return userTaskList; + } + + private Set findDirtyRoads( + FlowElement source, List passRoads, Set hasSequenceFlow, List targets, Set dirtyRoads) { + passRoads = passRoads == null ? new ArrayList<>() : passRoads; + dirtyRoads = dirtyRoads == null ? new HashSet<>() : dirtyRoads; + hasSequenceFlow = hasSequenceFlow == null ? new HashSet<>() : hasSequenceFlow; + // 如果该节点为开始节点,且存在上级子节点,则顺着上级子节点继续迭代 + if (source instanceof StartEvent && source.getSubProcess() != null) { + dirtyRoads = findDirtyRoads(source.getSubProcess(), passRoads, hasSequenceFlow, targets, dirtyRoads); + } + // 根据类型,获取入口连线 + List sequenceFlows = getElementIncomingFlows(source); + if (sequenceFlows != null) { + // 循环找到目标元素 + for (SequenceFlow sequenceFlow: sequenceFlows) { + // 如果发现连线重复,说明循环了,跳过这个循环 + if (hasSequenceFlow.contains(sequenceFlow.getId())) { + continue; + } + // 添加已经走过的连线 + hasSequenceFlow.add(sequenceFlow.getId()); + // 新增经过的路线 + passRoads.add(sequenceFlow.getSourceFlowElement().getId()); + // 如果此点为目标点,确定经过的路线为脏线路,添加点到脏线路中,然后找下个连线 + if (targets.contains(sequenceFlow.getSourceFlowElement().getId())) { + dirtyRoads.addAll(passRoads); + continue; + } + // 如果该节点为开始节点,且存在上级子节点,则顺着上级子节点继续迭代 + if (sequenceFlow.getSourceFlowElement() instanceof SubProcess) { + dirtyRoads = findChildProcessAllDirtyRoad( + (StartEvent) ((SubProcess) sequenceFlow.getSourceFlowElement()).getFlowElements().toArray()[0], null, dirtyRoads); + // 是否存在子流程上,true 是,false 否 + Boolean isInChildProcess = dirtyTargetInChildProcess( + (StartEvent) ((SubProcess) sequenceFlow.getSourceFlowElement()).getFlowElements().toArray()[0], null, targets, null); + if (isInChildProcess) { + // 已在子流程上找到,该路线结束 + continue; + } + } + // 继续迭代 + // 注意:已经经过的节点与连线都应该用浅拷贝出来的对象 + // 比如分支:a->b->c与a->d->c,走完a->b->c后走另一个路线是,已经经过的节点应该不包含a->b->c路线的数据 + dirtyRoads = findDirtyRoads(sequenceFlow.getSourceFlowElement(), + new ArrayList<>(passRoads), new HashSet<>(hasSequenceFlow), targets, dirtyRoads); + } + } + return dirtyRoads; + } + + private Set findChildProcessAllDirtyRoad( + FlowElement source, Set hasSequenceFlow, Set dirtyRoads) { + hasSequenceFlow = hasSequenceFlow == null ? new HashSet<>() : hasSequenceFlow; + dirtyRoads = dirtyRoads == null ? new HashSet<>() : dirtyRoads; + // 根据类型,获取出口连线 + List sequenceFlows = getElementOutgoingFlows(source); + if (sequenceFlows != null) { + // 循环找到目标元素 + for (SequenceFlow sequenceFlow: sequenceFlows) { + // 如果发现连线重复,说明循环了,跳过这个循环 + if (hasSequenceFlow.contains(sequenceFlow.getId())) { + continue; + } + // 添加已经走过的连线 + hasSequenceFlow.add(sequenceFlow.getId()); + // 添加脏路线 + dirtyRoads.add(sequenceFlow.getTargetFlowElement().getId()); + // 如果节点为子流程节点情况,则从节点中的第一个节点开始获取 + if (sequenceFlow.getTargetFlowElement() instanceof SubProcess) { + dirtyRoads = findChildProcessAllDirtyRoad( + (FlowElement) (((SubProcess) sequenceFlow.getTargetFlowElement()).getFlowElements().toArray()[0]), hasSequenceFlow, dirtyRoads); + } + // 继续迭代 + // 注意:已经经过的节点与连线都应该用浅拷贝出来的对象 + // 比如分支:a->b->c与a->d->c,走完a->b->c后走另一个路线是,已经经过的节点应该不包含a->b->c路线的数据 + dirtyRoads = findChildProcessAllDirtyRoad( + sequenceFlow.getTargetFlowElement(), new HashSet<>(hasSequenceFlow), dirtyRoads); + } + } + return dirtyRoads; + } + + private Boolean dirtyTargetInChildProcess( + FlowElement source, Set hasSequenceFlow, List targets, Boolean inChildProcess) { + hasSequenceFlow = hasSequenceFlow == null ? new HashSet<>() : hasSequenceFlow; + inChildProcess = inChildProcess != null && inChildProcess; + // 根据类型,获取出口连线 + List sequenceFlows = getElementOutgoingFlows(source); + if (sequenceFlows != null && !inChildProcess) { + // 循环找到目标元素 + for (SequenceFlow sequenceFlow: sequenceFlows) { + // 如果发现连线重复,说明循环了,跳过这个循环 + if (hasSequenceFlow.contains(sequenceFlow.getId())) { + continue; + } + // 添加已经走过的连线 + hasSequenceFlow.add(sequenceFlow.getId()); + // 如果发现目标点在子流程上存在,说明只到子流程为止 + if (targets.contains(sequenceFlow.getTargetFlowElement().getId())) { + inChildProcess = true; + break; + } + // 如果节点为子流程节点情况,则从节点中的第一个节点开始获取 + if (sequenceFlow.getTargetFlowElement() instanceof SubProcess) { + inChildProcess = dirtyTargetInChildProcess((FlowElement) (((SubProcess) sequenceFlow.getTargetFlowElement()).getFlowElements().toArray()[0]), hasSequenceFlow, targets, inChildProcess); + } + // 继续迭代 + // 注意:已经经过的节点与连线都应该用浅拷贝出来的对象 + // 比如分支:a->b->c与a->d->c,走完a->b->c后走另一个路线是,已经经过的节点应该不包含a->b->c路线的数据 + inChildProcess = dirtyTargetInChildProcess(sequenceFlow.getTargetFlowElement(), new HashSet<>(hasSequenceFlow), targets, inChildProcess); + } + } + return inChildProcess; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void transferTo(Task task, FlowTaskComment flowTaskComment) { + List transferUserList = StrUtil.split(flowTaskComment.getDelegateAssignee(), ","); + for (String transferUser : transferUserList) { + if (transferUser.equals(FlowConstant.START_USER_NAME_VAR)) { + String startUser = this.getProcessInstanceVariable( + task.getProcessInstanceId(), FlowConstant.PROC_INSTANCE_START_USER_NAME_VAR).toString(); + String newDelegateAssignee = StrUtil.replace( + flowTaskComment.getDelegateAssignee(), FlowConstant.START_USER_NAME_VAR, startUser); + flowTaskComment.setDelegateAssignee(newDelegateAssignee); + transferUserList = StrUtil.split(flowTaskComment.getDelegateAssignee(), ","); + break; + } + } + taskService.unclaim(task.getId()); + FlowTaskExt taskExt = flowTaskExtService.getByProcessDefinitionIdAndTaskId( + task.getProcessDefinitionId(), task.getTaskDefinitionKey()); + if (StrUtil.isNotBlank(taskExt.getCandidateUsernames())) { + List candidateUsernames = this.getCandidateUsernames(taskExt, task.getId()); + if (CollUtil.isNotEmpty(candidateUsernames)) { + for (String username : candidateUsernames) { + taskService.deleteCandidateUser(task.getId(), username); + } + } + } else if (StrUtil.equals(taskExt.getGroupType(), FlowConstant.GROUP_TYPE_ASSIGNEE)) { + List links = taskService.getIdentityLinksForTask(task.getId()); + for (IdentityLink link : links) { + taskService.deleteUserIdentityLink(task.getId(), link.getUserId(), link.getType()); + } + } else { + this.removeCandidateGroup(taskExt, task); + } + transferUserList.forEach(u -> taskService.addCandidateUser(task.getId(), u)); + flowTaskComment.fillWith(task); + flowTaskCommentService.saveNew(flowTaskComment); + } + + @Override + public List getCandidateUsernames(FlowTaskExt flowTaskExt, String taskId) { + if (StrUtil.isBlank(flowTaskExt.getCandidateUsernames())) { + return Collections.emptyList(); + } + if (!StrUtil.equals(flowTaskExt.getCandidateUsernames(), "${" + FlowConstant.TASK_APPOINTED_ASSIGNEE_VAR + "}")) { + return StrUtil.split(flowTaskExt.getCandidateUsernames(), ","); + } + Object candidateUsernames = getTaskVariableStringWithSafe(taskId, FlowConstant.TASK_APPOINTED_ASSIGNEE_VAR); + return candidateUsernames == null ? null : StrUtil.split(candidateUsernames.toString(), ","); + } + + @Override + public Tuple2, Set> getDeptPostIdAndPostIds( + FlowTaskExt flowTaskExt, String processInstanceId, boolean historic) { + Set postIdSet = new LinkedHashSet<>(); + Set deptPostIdSet = new LinkedHashSet<>(); + if (StrUtil.equals(flowTaskExt.getGroupType(), FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER)) { + Object v = this.getProcessInstanceVariable( + processInstanceId, FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER_VAR, historic); + if (ObjectUtil.isNotEmpty(v)) { + deptPostIdSet.add(v.toString()); + } + } else if (StrUtil.equals(flowTaskExt.getGroupType(), FlowConstant.GROUP_TYPE_DEPT_POST_LEADER)) { + Object v = this.getProcessInstanceVariable( + processInstanceId, FlowConstant.GROUP_TYPE_DEPT_POST_LEADER_VAR, historic); + if (ObjectUtil.isNotEmpty(v)) { + deptPostIdSet.add(v.toString()); + } + } else if (StrUtil.equals(flowTaskExt.getGroupType(), FlowConstant.GROUP_TYPE_POST) + && StrUtil.isNotBlank(flowTaskExt.getDeptPostListJson())) { + this.buildDeptPostIdAndPostIdsForPost(flowTaskExt, processInstanceId, historic, postIdSet, deptPostIdSet); + } + return new Tuple2<>(deptPostIdSet, postIdSet); + } + + @Override + public Map getAllUserTaskMap(String processDefinitionId) { + BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId); + Process process = bpmnModel.getProcesses().get(0); + return process.findFlowElementsOfType(UserTask.class) + .stream().collect(Collectors.toMap(UserTask::getId, a -> a, (k1, k2) -> k1)); + } + + @Override + public UserTask getUserTask(String processDefinitionId, String taskKey) { + BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId); + for (Process process : bpmnModel.getProcesses()) { + UserTask userTask = process.findFlowElementsOfType(UserTask.class) + .stream().filter(t -> t.getId().equals(taskKey)).findFirst().orElse(null); + if (userTask != null) { + return userTask; + } + } + return null; + } + + private void doChangeState(String processInstanceId, List currentIds, List targetIds) { + if (ObjectUtil.hasEmpty(currentIds, targetIds)) { + throw new MyRuntimeException("跳转的源节点和任务节点数量均不能为空!"); + } + ChangeActivityStateBuilder builder = + this.createChangeActivityStateBuilder(currentIds, targetIds, processInstanceId); + targetIds.forEach(targetId -> { + FlowTaskComment comment = flowTaskCommentService.getLatestFlowTaskComment(processInstanceId, targetId); + if (comment != null && StrUtil.isNotBlank(comment.getCreateLoginName())) { + builder.localVariable(targetId, FlowConstant.TASK_APPOINTED_ASSIGNEE_VAR, comment.getCreateLoginName()); + } + }); + builder.changeState(); + } + + private ChangeActivityStateBuilder createChangeActivityStateBuilder( + List currentIds, List targetIds, String processInstanceId) { + ChangeActivityStateBuilder builder; + if (currentIds.size() > 1 && targetIds.size() > 1) { + builder = new CustomChangeActivityStateBuilderImpl((RuntimeServiceImpl) runtimeService); + ((CustomChangeActivityStateBuilderImpl) builder) + .moveActivityIdsToActivityIds(currentIds, targetIds) + .processInstanceId(processInstanceId); + } else { + builder = runtimeService.createChangeActivityStateBuilder().processInstanceId(processInstanceId); + if (targetIds.size() == 1) { + if (currentIds.size() == 1) { + builder.moveActivityIdTo(currentIds.get(0), targetIds.get(0)); + } else { + builder.moveActivityIdsToSingleActivityId(currentIds, targetIds.get(0)); + } + } else { + builder.moveSingleActivityIdToActivityIds(currentIds.get(0), targetIds); + } + } + return builder; + } + + private void removeCandidateGroup(FlowTaskExt taskExt, Task task) { + if (StrUtil.isNotBlank(taskExt.getDeptIds())) { + for (String deptId : StrUtil.split(taskExt.getDeptIds(), ",")) { + taskService.deleteCandidateGroup(task.getId(), deptId); + } + } + if (StrUtil.isNotBlank(taskExt.getRoleIds())) { + for (String roleId : StrUtil.split(taskExt.getRoleIds(), ",")) { + taskService.deleteCandidateGroup(task.getId(), roleId); + } + } + Tuple2, Set> tuple2 = + getDeptPostIdAndPostIds(taskExt, task.getProcessInstanceId(), false); + if (CollUtil.isNotEmpty(tuple2.getFirst())) { + for (String deptPostId : tuple2.getFirst()) { + taskService.deleteCandidateGroup(task.getId(), deptPostId); + } + } + if (CollUtil.isNotEmpty(tuple2.getSecond())) { + for (String postId : tuple2.getSecond()) { + taskService.deleteCandidateGroup(task.getId(), postId); + } + } + } + + private void buildDeptPostIdAndPostIdsForPost( + FlowTaskExt flowTaskExt, + String processInstanceId, + boolean historic, + Set postIdSet, + Set deptPostIdSet) { + List groupDataList = + JSON.parseArray(flowTaskExt.getDeptPostListJson(), FlowTaskPostCandidateGroup.class); + for (FlowTaskPostCandidateGroup groupData : groupDataList) { + switch (groupData.getType()) { + case FlowConstant.GROUP_TYPE_ALL_DEPT_POST_VAR: + postIdSet.add(groupData.getPostId()); + break; + case FlowConstant.GROUP_TYPE_DEPT_POST_VAR: + deptPostIdSet.add(groupData.getDeptPostId()); + break; + case FlowConstant.GROUP_TYPE_SELF_DEPT_POST_VAR: + Object v = this.getProcessInstanceVariable( + processInstanceId, FlowConstant.SELF_DEPT_POST_PREFIX + groupData.getPostId(), historic); + if (ObjectUtil.isNotEmpty(v)) { + deptPostIdSet.add(v.toString()); + } + break; + case FlowConstant.GROUP_TYPE_UP_DEPT_POST_VAR: + Object v2 = this.getProcessInstanceVariable( + processInstanceId, FlowConstant.UP_DEPT_POST_PREFIX + groupData.getPostId(), historic); + if (ObjectUtil.isNotEmpty(v2)) { + deptPostIdSet.add(v2.toString()); + } + break; + case FlowConstant.GROUP_TYPE_SIBLING_DEPT_POST_VAR: + Object v3 = this.getProcessInstanceVariable( + processInstanceId, FlowConstant.SIBLING_DEPT_POST_PREFIX + groupData.getPostId(), historic); + if (ObjectUtil.isNotEmpty(v3)) { + deptPostIdSet.addAll(StrUtil.split(v3.toString(), ",") + .stream().filter(StrUtil::isNotBlank).toList()); + } + break; + default: + break; + } + } + } + + private Object getProcessInstanceVariable(String processInstanceId, String variableName, boolean historic) { + if (historic) { + return getHistoricProcessInstanceVariable(processInstanceId, variableName); + } + return getProcessInstanceVariable(processInstanceId, variableName); + } + + private void handleMultiInstanceApprovalType(String executionId, String approvalType, JSONObject taskVariableData) { + if (StrUtil.isBlank(approvalType)) { + return; + } + if (StrUtil.equalsAny(approvalType, + FlowApprovalType.MULTI_AGREE, + FlowApprovalType.MULTI_REFUSE, + FlowApprovalType.MULTI_ABSTAIN)) { + Map variables = runtimeService.getVariables(executionId); + Integer agreeCount = (Integer) variables.get(FlowConstant.MULTI_AGREE_COUNT_VAR); + Integer refuseCount = (Integer) variables.get(FlowConstant.MULTI_REFUSE_COUNT_VAR); + Integer abstainCount = (Integer) variables.get(FlowConstant.MULTI_ABSTAIN_COUNT_VAR); + Integer nrOfInstances = (Integer) variables.get(FlowConstant.NUMBER_OF_INSTANCES_VAR); + taskVariableData.put(FlowConstant.MULTI_AGREE_COUNT_VAR, agreeCount); + taskVariableData.put(FlowConstant.MULTI_REFUSE_COUNT_VAR, refuseCount); + taskVariableData.put(FlowConstant.MULTI_ABSTAIN_COUNT_VAR, abstainCount); + taskVariableData.put(FlowConstant.MULTI_SIGN_NUM_OF_INSTANCES_VAR, nrOfInstances); + switch (approvalType) { + case FlowApprovalType.MULTI_AGREE: + if (agreeCount == null) { + agreeCount = 0; + } + taskVariableData.put(FlowConstant.MULTI_AGREE_COUNT_VAR, agreeCount + 1); + break; + case FlowApprovalType.MULTI_REFUSE: + if (refuseCount == null) { + refuseCount = 0; + } + taskVariableData.put(FlowConstant.MULTI_REFUSE_COUNT_VAR, refuseCount + 1); + break; + case FlowApprovalType.MULTI_ABSTAIN: + if (abstainCount == null) { + abstainCount = 0; + } + taskVariableData.put(FlowConstant.MULTI_ABSTAIN_COUNT_VAR, abstainCount + 1); + break; + default: + break; + } + } + } + + private TaskQuery createQuery() { + TaskQuery query = taskService.createTaskQuery().active(); + TokenData tokenData = TokenData.takeFromRequest(); + if (tokenData.getTenantId() != null) { + query.taskTenantId(tokenData.getTenantId().toString()); + } else { + if (StrUtil.isBlank(tokenData.getAppCode())) { + query.taskWithoutTenantId(); + } else { + query.taskTenantId(tokenData.getAppCode()); + } + } + return query; + } + + private void buildCandidateCondition(TaskQuery query, String loginName) { + Set groupIdSet = new HashSet<>(); + // NOTE: 需要注意的是,部门Id、部门岗位Id,或者其他类型的分组Id,他们之间一定不能重复。 + TokenData tokenData = TokenData.takeFromRequest(); + Object deptId = tokenData.getDeptId(); + if (deptId != null) { + groupIdSet.add(deptId.toString()); + } + String roleIds = tokenData.getRoleIds(); + if (StrUtil.isNotBlank(tokenData.getRoleIds())) { + groupIdSet.addAll(StrUtil.split(roleIds, ",")); + } + String postIds = tokenData.getPostIds(); + if (StrUtil.isNotBlank(tokenData.getPostIds())) { + groupIdSet.addAll(StrUtil.split(postIds, ",")); + } + String deptPostIds = tokenData.getDeptPostIds(); + if (StrUtil.isNotBlank(deptPostIds)) { + groupIdSet.addAll(StrUtil.split(deptPostIds, ",")); + } + if (CollUtil.isNotEmpty(groupIdSet)) { + query.or().taskCandidateGroupIn(groupIdSet).taskCandidateOrAssigned(loginName).endOr(); + } else { + query.taskCandidateOrAssigned(loginName); + } + } + + private String buildMutiSignAssigneeList(String operationListJson) { + FlowTaskMultiSignAssign multiSignAssignee = null; + List taskOperationList = JSONArray.parseArray(operationListJson, FlowTaskOperation.class); + for (FlowTaskOperation taskOperation : taskOperationList) { + if (FlowApprovalType.MULTI_SIGN.equals(taskOperation.getType())) { + multiSignAssignee = taskOperation.getMultiSignAssignee(); + break; + } + } + org.springframework.util.Assert.notNull(multiSignAssignee, "multiSignAssignee can't be NULL"); + if (UserFilterGroup.USER.equals(multiSignAssignee.getAssigneeType())) { + return multiSignAssignee.getAssigneeList(); + } + Set usernameSet = null; + BaseFlowIdentityExtHelper extHelper = flowCustomExtFactory.getFlowIdentityExtHelper(); + Set idSet = CollUtil.newHashSet(StrUtil.split(multiSignAssignee.getAssigneeList(), ",")); + switch (multiSignAssignee.getAssigneeType()) { + case UserFilterGroup.ROLE -> usernameSet = extHelper.getUsernameListByRoleIds(idSet); + case UserFilterGroup.DEPT -> usernameSet = extHelper.getUsernameListByDeptIds(idSet); + case UserFilterGroup.POST -> usernameSet = extHelper.getUsernameListByPostIds(idSet); + case UserFilterGroup.DEPT_POST -> usernameSet = extHelper.getUsernameListByDeptPostIds(idSet); + default -> { + } + } + return CollUtil.isEmpty(usernameSet) ? null : CollUtil.join(usernameSet, ","); + } + + private Collection getAllElements(Collection flowElements, Collection allElements) { + allElements = allElements == null ? new ArrayList<>() : allElements; + for (FlowElement flowElement : flowElements) { + allElements.add(flowElement); + if (flowElement instanceof SubProcess) { + allElements = getAllElements(((SubProcess) flowElement).getFlowElements(), allElements); + } + } + return allElements; + } + + private void doChangeTask(Task runtimeTask) { + Map allUserTaskMap = + this.getAllUserTaskMap(runtimeTask.getProcessDefinitionId()); + UserTask userTaskModel = allUserTaskMap.get(runtimeTask.getTaskDefinitionKey()); + String completeCondition = userTaskModel.getLoopCharacteristics().getCompletionCondition(); + Execution parentExecution = this.getMultiInstanceRootExecution(runtimeTask); + Object nrOfCompletedInstances = runtimeService.getVariable( + parentExecution.getId(), FlowConstant.NUMBER_OF_COMPLETED_INSTANCES_VAR); + Object nrOfInstances = runtimeService.getVariable( + parentExecution.getId(), FlowConstant.NUMBER_OF_INSTANCES_VAR); + ExpressionFactory factory = new ExpressionFactoryImpl(); + SimpleContext context = new SimpleContext(); + context.setVariable("nrOfCompletedInstances", + factory.createValueExpression(nrOfCompletedInstances, Integer.class)); + context.setVariable("nrOfInstances", + factory.createValueExpression(nrOfInstances, Integer.class)); + ValueExpression e = factory.createValueExpression(context, completeCondition, Boolean.class); + Boolean ok = Convert.convert(Boolean.class, e.getValue(context)); + if (BooleanUtil.isTrue(ok)) { + FlowElement targetKey = userTaskModel.getOutgoingFlows().get(0).getTargetFlowElement(); + ChangeActivityStateBuilder builder = runtimeService.createChangeActivityStateBuilder() + .processInstanceId(runtimeTask.getProcessInstanceId()) + .moveActivityIdTo(userTaskModel.getId(), targetKey.getId()); + builder.localVariable(targetKey.getId(), FlowConstant.MULTI_SIGN_NUM_OF_INSTANCES_VAR, nrOfInstances); + builder.changeState(); + } + } + + private Execution getMultiInstanceRootExecution(Task runtimeTask) { + List executionList = runtimeService.createExecutionQuery() + .processInstanceId(runtimeTask.getProcessInstanceId()) + .activityId(runtimeTask.getTaskDefinitionKey()).list(); + for (Execution e : executionList) { + ExecutionEntityImpl ee = (ExecutionEntityImpl) e; + if (ee.isMultiInstanceRoot()) { + return e; + } + } + Execution execution = executionList.get(0); + return runtimeService.createExecutionQuery() + .processInstanceId(runtimeTask.getProcessInstanceId()) + .executionId(execution.getParentId()).singleResult(); + } + + private List getElementIncomingFlows(FlowElement source) { + List sequenceFlows = null; + if (source instanceof org.flowable.bpmn.model.Task) { + sequenceFlows = ((org.flowable.bpmn.model.Task) source).getIncomingFlows(); + } else if (source instanceof Gateway) { + sequenceFlows = ((Gateway) source).getIncomingFlows(); + } else if (source instanceof SubProcess) { + sequenceFlows = ((SubProcess) source).getIncomingFlows(); + } else if (source instanceof StartEvent) { + sequenceFlows = ((StartEvent) source).getIncomingFlows(); + } else if (source instanceof EndEvent) { + sequenceFlows = ((EndEvent) source).getIncomingFlows(); + } + return sequenceFlows; + } + + private List getElementOutgoingFlows(FlowElement source) { + List sequenceFlows = null; + if (source instanceof org.flowable.bpmn.model.Task) { + sequenceFlows = ((org.flowable.bpmn.model.Task) source).getOutgoingFlows(); + } else if (source instanceof Gateway) { + sequenceFlows = ((Gateway) source).getOutgoingFlows(); + } else if (source instanceof SubProcess) { + sequenceFlows = ((SubProcess) source).getOutgoingFlows(); + } else if (source instanceof StartEvent) { + sequenceFlows = ((StartEvent) source).getOutgoingFlows(); + } else if (source instanceof EndEvent) { + sequenceFlows = ((EndEvent) source).getOutgoingFlows(); + } + return sequenceFlows; + } + + private FlowableListener createListener(String eventName, String listenerClassName) { + FlowableListener listener = new FlowableListener(); + listener.setEvent(eventName); + listener.setImplementationType("class"); + listener.setImplementation(listenerClassName); + return listener; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowCategoryServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowCategoryServiceImpl.java new file mode 100644 index 00000000..de1fb85a --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowCategoryServiceImpl.java @@ -0,0 +1,131 @@ +package com.orangeforms.common.flow.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.github.pagehelper.Page; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.flow.dao.*; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.flow.service.*; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; +import java.util.Set; +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("flowCategoryService") +public class FlowCategoryServiceImpl extends BaseService implements FlowCategoryService { + + @Autowired + private FlowCategoryMapper flowCategoryMapper; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return flowCategoryMapper; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public FlowCategory saveNew(FlowCategory flowCategory) { + flowCategory.setCategoryId(idGenerator.nextLongId()); + TokenData tokenData = TokenData.takeFromRequest(); + flowCategory.setAppCode(tokenData.getAppCode()); + flowCategory.setTenantId(tokenData.getTenantId()); + flowCategory.setUpdateUserId(tokenData.getUserId()); + flowCategory.setCreateUserId(tokenData.getUserId()); + Date now = new Date(); + flowCategory.setUpdateTime(now); + flowCategory.setCreateTime(now); + flowCategoryMapper.insert(flowCategory); + return flowCategory; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(FlowCategory flowCategory, FlowCategory originalFlowCategory) { + TokenData tokenData = TokenData.takeFromRequest(); + flowCategory.setAppCode(tokenData.getAppCode()); + flowCategory.setTenantId(tokenData.getTenantId()); + flowCategory.setUpdateUserId(tokenData.getUserId()); + flowCategory.setCreateUserId(originalFlowCategory.getCreateUserId()); + flowCategory.setUpdateTime(new Date()); + flowCategory.setCreateTime(originalFlowCategory.getCreateTime()); + // 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。 + UpdateWrapper uw = + this.createUpdateQueryForNullValue(flowCategory, flowCategory.getCategoryId()); + return flowCategoryMapper.update(flowCategory, uw) == 1; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long categoryId) { + return flowCategoryMapper.deleteById(categoryId) == 1; + } + + @Override + public List getFlowCategoryList(FlowCategory filter, String orderBy) { + if (filter == null) { + filter = new FlowCategory(); + } + TokenData tokenData = TokenData.takeFromRequest(); + filter.setTenantId(tokenData.getTenantId()); + filter.setAppCode(tokenData.getAppCode()); + return flowCategoryMapper.getFlowCategoryList(filter, orderBy); + } + + @Override + public List getFlowCategoryListWithRelation(FlowCategory filter, String orderBy) { + List resultList = this.getFlowCategoryList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + @Override + public boolean existByCode(String code) { + FlowCategory filter = new FlowCategory(); + filter.setCode(code); + return CollUtil.isNotEmpty(this.getFlowCategoryList(filter, null)); + } + + @Override + public List getInList(Set categoryIds) { + LambdaQueryWrapper qw = new LambdaQueryWrapper<>(); + qw.in(FlowCategory::getCategoryId, categoryIds); + TokenData tokenData = TokenData.takeFromRequest(); + if (tokenData.getAppCode() == null) { + qw.isNull(FlowCategory::getAppCode); + } else { + qw.eq(FlowCategory::getAppCode, tokenData.getAppCode()); + } + if (tokenData.getTenantId() == null) { + qw.isNull(FlowCategory::getTenantId); + } else { + qw.eq(FlowCategory::getTenantId, tokenData.getTenantId()); + } + return flowCategoryMapper.selectList(qw); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowEntryServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowEntryServiceImpl.java new file mode 100644 index 00000000..adb7dca0 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowEntryServiceImpl.java @@ -0,0 +1,490 @@ +package com.orangeforms.common.flow.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.github.pagehelper.Page; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.flow.constant.FlowConstant; +import com.orangeforms.common.flow.dao.FlowEntryMapper; +import com.orangeforms.common.flow.dao.FlowEntryPublishMapper; +import com.orangeforms.common.flow.dao.FlowEntryPublishVariableMapper; +import com.orangeforms.common.flow.listener.*; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.flow.model.constant.FlowEntryStatus; +import com.orangeforms.common.flow.model.constant.FlowVariableType; +import com.orangeforms.common.flow.object.FlowElementExtProperty; +import com.orangeforms.common.flow.object.FlowEntryExtensionData; +import com.orangeforms.common.flow.object.FlowTaskPostCandidateGroup; +import com.orangeforms.common.flow.object.FlowUserTaskExtData; +import com.orangeforms.common.flow.service.*; +import com.orangeforms.common.flow.util.BaseFlowIdentityExtHelper; +import com.orangeforms.common.flow.util.FlowCustomExtFactory; +import com.orangeforms.common.flow.util.FlowRedisKeyUtil; +import com.orangeforms.common.redis.util.CommonRedisUtil; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import lombok.Cleanup; +import lombok.extern.slf4j.Slf4j; +import org.flowable.bpmn.converter.BpmnXMLConverter; +import org.flowable.bpmn.model.*; +import org.flowable.engine.RepositoryService; +import org.flowable.engine.repository.Deployment; +import org.flowable.engine.repository.ProcessDefinition; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.stream.Collectors; + +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("flowEntryService") +public class FlowEntryServiceImpl extends BaseService implements FlowEntryService { + + @Autowired + private FlowEntryMapper flowEntryMapper; + @Autowired + private FlowEntryPublishMapper flowEntryPublishMapper; + @Autowired + private FlowEntryPublishVariableMapper flowEntryPublishVariableMapper; + @Autowired + private FlowEntryVariableService flowEntryVariableService; + @Autowired + private FlowCategoryService flowCategoryService; + @Autowired + private FlowTaskExtService flowTaskExtService; + @Autowired + private FlowApiService flowApiService; + @Autowired + private FlowCustomExtFactory flowCustomExtFactory; + @Autowired + private RepositoryService repositoryService; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private CommonRedisUtil commonRedisUtil; + + private static final Integer FLOW_ENTRY_PUBLISH_TTL = 60 * 60 * 24; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return flowEntryMapper; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public FlowEntry saveNew(FlowEntry flowEntry) { + flowEntry.setEntryId(idGenerator.nextLongId()); + flowEntry.setStatus(FlowEntryStatus.UNPUBLISHED); + TokenData tokenData = TokenData.takeFromRequest(); + flowEntry.setAppCode(tokenData.getAppCode()); + flowEntry.setTenantId(tokenData.getTenantId()); + flowEntry.setUpdateUserId(tokenData.getUserId()); + flowEntry.setCreateUserId(tokenData.getUserId()); + Date now = new Date(); + flowEntry.setUpdateTime(now); + flowEntry.setCreateTime(now); + flowEntryMapper.insert(flowEntry); + this.insertBuiltinEntryVariables(flowEntry.getEntryId()); + return flowEntry; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void publish(FlowEntry flowEntry, String initTaskInfo) throws XMLStreamException { + commonRedisUtil.evictFormCache( + FlowRedisKeyUtil.makeFlowEntryKey(flowEntry.getProcessDefinitionKey())); + FlowCategory flowCategory = flowCategoryService.getById(flowEntry.getCategoryId()); + InputStream xmlStream = new ByteArrayInputStream( + flowEntry.getBpmnXml().getBytes(StandardCharsets.UTF_8)); + @Cleanup XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(xmlStream); + BpmnXMLConverter converter = new BpmnXMLConverter(); + BpmnModel bpmnModel = converter.convertToBpmnModel(reader); + bpmnModel.getMainProcess().setName(flowEntry.getProcessDefinitionName()); + bpmnModel.getMainProcess().setId(flowEntry.getProcessDefinitionKey()); + flowApiService.addProcessInstanceEndListener(bpmnModel, FlowFinishedListener.class); + List flowTaskExtList = flowTaskExtService.buildTaskExtList(bpmnModel); + if (StrUtil.isNotBlank(flowEntry.getExtensionData())) { + FlowEntryExtensionData flowEntryExtensionData = + JSON.parseObject(flowEntry.getExtensionData(), FlowEntryExtensionData.class); + this.mergeTaskNotifyData(flowEntryExtensionData, flowTaskExtList); + } + this.processFlowTaskExtList(flowTaskExtList, bpmnModel); + TokenData tokenData = TokenData.takeFromRequest(); + Deployment deploy = repositoryService.createDeployment() + .addBpmnModel(flowEntry.getProcessDefinitionKey() + ".bpmn", bpmnModel) + .tenantId(tokenData.getTenantId() != null ? tokenData.getTenantId().toString() : tokenData.getAppCode()) + .name(flowEntry.getProcessDefinitionName()) + .key(flowEntry.getProcessDefinitionKey()) + .category(flowCategory.getCode()) + .deploy(); + ProcessDefinition processDefinition = flowApiService.getProcessDefinitionByDeployId(deploy.getId()); + FlowEntryPublish flowEntryPublish = new FlowEntryPublish(); + flowEntryPublish.setEntryPublishId(idGenerator.nextLongId()); + flowEntryPublish.setEntryId(flowEntry.getEntryId()); + flowEntryPublish.setProcessDefinitionId(processDefinition.getId()); + flowEntryPublish.setDeployId(processDefinition.getDeploymentId()); + flowEntryPublish.setPublishVersion(processDefinition.getVersion()); + flowEntryPublish.setActiveStatus(true); + flowEntryPublish.setMainVersion(flowEntry.getStatus().equals(FlowEntryStatus.UNPUBLISHED)); + flowEntryPublish.setCreateUserId(TokenData.takeFromRequest().getUserId()); + flowEntryPublish.setPublishTime(new Date()); + flowEntryPublish.setInitTaskInfo(initTaskInfo); + flowEntryPublish.setExtensionData(flowEntry.getExtensionData()); + flowEntryPublishMapper.insert(flowEntryPublish); + FlowEntry updatedFlowEntry = new FlowEntry(); + updatedFlowEntry.setEntryId(flowEntry.getEntryId()); + updatedFlowEntry.setStatus(FlowEntryStatus.PUBLISHED); + updatedFlowEntry.setLatestPublishTime(new Date()); + // 对于从未发布过的工作,第一次发布的时候会将本地发布置位主版本。 + if (flowEntry.getStatus().equals(FlowEntryStatus.UNPUBLISHED)) { + updatedFlowEntry.setMainEntryPublishId(flowEntryPublish.getEntryPublishId()); + } + flowEntryMapper.updateById(updatedFlowEntry); + FlowEntryVariable flowEntryVariableFilter = new FlowEntryVariable(); + flowEntryVariableFilter.setEntryId(flowEntry.getEntryId()); + List flowEntryVariableList = + flowEntryVariableService.getFlowEntryVariableList(flowEntryVariableFilter, null); + if (CollUtil.isNotEmpty(flowTaskExtList)) { + flowTaskExtList.forEach(t -> t.setProcessDefinitionId(processDefinition.getId())); + flowTaskExtService.saveBatch(flowTaskExtList); + } + this.insertEntryPublishVariables(flowEntryVariableList, flowEntryPublish.getEntryPublishId()); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(FlowEntry flowEntry, FlowEntry originalFlowEntry) { + commonRedisUtil.evictFormCache( + FlowRedisKeyUtil.makeFlowEntryKey(flowEntry.getProcessDefinitionKey())); + TokenData tokenData = TokenData.takeFromRequest(); + flowEntry.setAppCode(tokenData.getAppCode()); + flowEntry.setTenantId(tokenData.getTenantId()); + flowEntry.setUpdateUserId(tokenData.getUserId()); + flowEntry.setCreateUserId(originalFlowEntry.getCreateUserId()); + flowEntry.setUpdateTime(new Date()); + flowEntry.setCreateTime(originalFlowEntry.getCreateTime()); + flowEntry.setPageId(originalFlowEntry.getPageId()); + return flowEntryMapper.updateById(flowEntry) == 1; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long entryId) { + FlowEntry flowEntry = this.getById(entryId); + if (flowEntry != null) { + commonRedisUtil.evictFormCache( + FlowRedisKeyUtil.makeFlowEntryKey(flowEntry.getProcessDefinitionKey())); + } + if (flowEntryMapper.deleteById(entryId) != 1) { + return false; + } + flowEntryVariableService.removeByEntryId(entryId); + return true; + } + + @Override + public List getFlowEntryList(FlowEntry filter, String orderBy) { + if (filter == null) { + filter = new FlowEntry(); + } + TokenData tokenData = TokenData.takeFromRequest(); + filter.setTenantId(tokenData.getTenantId()); + filter.setAppCode(tokenData.getAppCode()); + return flowEntryMapper.getFlowEntryList(filter, orderBy); + } + + @Override + public List getFlowEntryListWithRelation(FlowEntry filter, String orderBy) { + List resultList = this.getFlowEntryList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + Set mainEntryPublishIdSet = resultList.stream() + .map(FlowEntry::getMainEntryPublishId).filter(Objects::nonNull).collect(Collectors.toSet()); + if (CollUtil.isNotEmpty(mainEntryPublishIdSet)) { + List mainEntryPublishList = + flowEntryPublishMapper.selectBatchIds(mainEntryPublishIdSet); + MyModelUtil.makeOneToOneRelation(FlowEntry.class, resultList, FlowEntry::getMainEntryPublishId, + mainEntryPublishList, FlowEntryPublish::getEntryPublishId, "mainFlowEntryPublish"); + } + return resultList; + } + + @Override + public FlowEntry getFlowEntryFromCache(String processDefinitionKey) { + String key = FlowRedisKeyUtil.makeFlowEntryKey(processDefinitionKey); + LambdaQueryWrapper qw = new LambdaQueryWrapper<>(); + qw.eq(FlowEntry::getProcessDefinitionKey, processDefinitionKey); + TokenData tokenData = TokenData.takeFromRequest(); + if (StrUtil.isNotBlank(tokenData.getAppCode())) { + qw.eq(FlowEntry::getAppCode, tokenData.getAppCode()); + } else { + qw.isNull(FlowEntry::getAppCode); + } + if (tokenData.getTenantId() != null) { + qw.eq(FlowEntry::getTenantId, tokenData.getTenantId()); + } else { + qw.isNull(FlowEntry::getTenantId); + } + return commonRedisUtil.getFromCacheWithQueryWrapper(key, qw, flowEntryMapper::selectOne, FlowEntry.class); + } + + @Override + public List getFlowEntryPublishList(Long entryId) { + FlowEntryPublish filter = new FlowEntryPublish(); + filter.setEntryId(entryId); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(filter); + queryWrapper.orderByDesc(FlowEntryPublish::getEntryPublishId); + return flowEntryPublishMapper.selectList(queryWrapper); + } + + @Override + public List getFlowEntryPublishList(Set processDefinitionIdSet) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.in(FlowEntryPublish::getProcessDefinitionId, processDefinitionIdSet); + return flowEntryPublishMapper.selectList(queryWrapper); + } + + @Override + public FlowEntryPublish getFlowEntryPublishFromCache(Long entryPublishId) { + String key = FlowRedisKeyUtil.makeFlowEntryPublishKey(entryPublishId); + return commonRedisUtil.getFromCache( + key, entryPublishId, flowEntryPublishMapper::selectById, FlowEntryPublish.class, FLOW_ENTRY_PUBLISH_TTL); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void updateFlowEntryMainVersion(FlowEntry flowEntry, FlowEntryPublish newMainFlowEntryPublish) { + commonRedisUtil.evictFormCache( + FlowRedisKeyUtil.makeFlowEntryKey(flowEntry.getProcessDefinitionKey())); + commonRedisUtil.evictFormCache( + FlowRedisKeyUtil.makeFlowEntryPublishKey(newMainFlowEntryPublish.getEntryPublishId())); + FlowEntryPublish oldMainFlowEntryPublish = + flowEntryPublishMapper.selectById(flowEntry.getMainEntryPublishId()); + if (oldMainFlowEntryPublish != null) { + commonRedisUtil.evictFormCache( + FlowRedisKeyUtil.makeFlowEntryPublishKey(oldMainFlowEntryPublish.getEntryPublishId())); + oldMainFlowEntryPublish.setMainVersion(false); + flowEntryPublishMapper.updateById(oldMainFlowEntryPublish); + } + newMainFlowEntryPublish.setMainVersion(true); + flowEntryPublishMapper.updateById(newMainFlowEntryPublish); + FlowEntry updatedEntry = new FlowEntry(); + updatedEntry.setEntryId(flowEntry.getEntryId()); + updatedEntry.setMainEntryPublishId(newMainFlowEntryPublish.getEntryPublishId()); + flowEntryMapper.updateById(updatedEntry); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void suspendFlowEntryPublish(FlowEntryPublish flowEntryPublish) { + commonRedisUtil.evictFormCache( + FlowRedisKeyUtil.makeFlowEntryPublishKey(flowEntryPublish.getEntryPublishId())); + FlowEntryPublish updatedEntryPublish = new FlowEntryPublish(); + updatedEntryPublish.setEntryPublishId(flowEntryPublish.getEntryPublishId()); + updatedEntryPublish.setActiveStatus(false); + flowEntryPublishMapper.updateById(updatedEntryPublish); + flowApiService.suspendProcessDefinition(flowEntryPublish.getProcessDefinitionId()); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void activateFlowEntryPublish(FlowEntryPublish flowEntryPublish) { + commonRedisUtil.evictFormCache( + FlowRedisKeyUtil.makeFlowEntryPublishKey(flowEntryPublish.getEntryPublishId())); + FlowEntryPublish updatedEntryPublish = new FlowEntryPublish(); + updatedEntryPublish.setEntryPublishId(flowEntryPublish.getEntryPublishId()); + updatedEntryPublish.setActiveStatus(true); + flowEntryPublishMapper.updateById(updatedEntryPublish); + flowApiService.activateProcessDefinition(flowEntryPublish.getProcessDefinitionId()); + } + + @Override + public boolean existByProcessDefinitionKey(String processDefinitionKey) { + FlowEntry filter = new FlowEntry(); + filter.setProcessDefinitionKey(processDefinitionKey); + return CollUtil.isNotEmpty(this.getFlowEntryList(filter, null)); + } + + @Override + public CallResult verifyRelatedData(FlowEntry flowEntry, FlowEntry originalFlowEntry) { + String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!"; + if (this.needToVerify(flowEntry, originalFlowEntry, FlowEntry::getCategoryId) + && !flowCategoryService.existId(flowEntry.getCategoryId())) { + return CallResult.error(String.format(errorMessageFormat, "流程类别Id")); + } + return CallResult.ok(); + } + + private void insertBuiltinEntryVariables(Long entryId) { + Date now = new Date(); + FlowEntryVariable operationTypeVariable = new FlowEntryVariable(); + operationTypeVariable.setVariableId(idGenerator.nextLongId()); + operationTypeVariable.setEntryId(entryId); + operationTypeVariable.setVariableName(FlowConstant.OPERATION_TYPE_VAR); + operationTypeVariable.setShowName("审批类型"); + operationTypeVariable.setVariableType(FlowVariableType.TASK); + operationTypeVariable.setBuiltin(true); + operationTypeVariable.setCreateTime(now); + flowEntryVariableService.saveNew(operationTypeVariable); + FlowEntryVariable startUserNameVariable = new FlowEntryVariable(); + startUserNameVariable.setVariableId(idGenerator.nextLongId()); + startUserNameVariable.setEntryId(entryId); + startUserNameVariable.setVariableName("startUserName"); + startUserNameVariable.setShowName("流程启动用户"); + startUserNameVariable.setVariableType(FlowVariableType.INSTANCE); + startUserNameVariable.setBuiltin(true); + startUserNameVariable.setCreateTime(now); + flowEntryVariableService.saveNew(startUserNameVariable); + } + + private void insertEntryPublishVariables(List entryVariableList, Long entryPublishId) { + if (CollUtil.isEmpty(entryVariableList)) { + return; + } + List entryPublishVariableList = + MyModelUtil.copyCollectionTo(entryVariableList, FlowEntryPublishVariable.class); + for (FlowEntryPublishVariable variable : entryPublishVariableList) { + variable.setVariableId(idGenerator.nextLongId()); + variable.setEntryPublishId(entryPublishId); + } + flowEntryPublishVariableMapper.insertList(entryPublishVariableList); + } + + private void mergeTaskNotifyData(FlowEntryExtensionData flowEntryExtensionData, List flowTaskExtList) { + if (CollUtil.isEmpty(flowEntryExtensionData.getNotifyTypes())) { + return; + } + List flowTaskNotifyTypes = + flowEntryExtensionData.getNotifyTypes().stream().filter(StrUtil::isNotBlank).collect(Collectors.toList()); + if (CollUtil.isEmpty(flowTaskNotifyTypes)) { + return; + } + for (FlowTaskExt flowTaskExt : flowTaskExtList) { + if (flowTaskExt.getExtraDataJson() == null) { + JSONObject o = new JSONObject(); + o.put(FlowConstant.USER_TASK_NOTIFY_TYPES_KEY, flowTaskNotifyTypes); + flowTaskExt.setExtraDataJson(o.toJSONString()); + } else { + FlowUserTaskExtData taskExtData = + JSON.parseObject(flowTaskExt.getExtraDataJson(), FlowUserTaskExtData.class); + if (CollUtil.isEmpty(taskExtData.getFlowNotifyTypeList())) { + taskExtData.setFlowNotifyTypeList(flowTaskNotifyTypes); + } else { + Set notifyTypesSet = taskExtData.getFlowNotifyTypeList() + .stream().filter(StrUtil::isNotBlank).collect(Collectors.toSet()); + notifyTypesSet.addAll(flowTaskNotifyTypes); + taskExtData.setFlowNotifyTypeList(new LinkedList<>(notifyTypesSet)); + } + flowTaskExt.setExtraDataJson(JSON.toJSONString(taskExtData)); + } + } + } + + private void doAddLatestApprovalStatusListener(Collection elementList) { + List sequenceFlowList = + elementList.stream().filter(SequenceFlow.class::isInstance).toList(); + for (FlowElement sequenceFlow : sequenceFlowList) { + FlowElementExtProperty extProperty = flowTaskExtService.buildFlowElementExt(sequenceFlow); + if (extProperty != null && extProperty.getLatestApprovalStatus() != null) { + List fieldExtensions = new LinkedList<>(); + FieldExtension fieldExtension = new FieldExtension(); + fieldExtension.setFieldName(FlowConstant.LATEST_APPROVAL_STATUS_KEY); + fieldExtension.setStringValue(extProperty.getLatestApprovalStatus().toString()); + fieldExtensions.add(fieldExtension); + flowApiService.addExecutionListener( + sequenceFlow, UpdateLatestApprovalStatusListener.class, "start", fieldExtensions); + } + } + List subProcesseList = elementList.stream() + .filter(SubProcess.class::isInstance).map(SubProcess.class::cast).toList(); + for (SubProcess subProcess : subProcesseList) { + this.doAddLatestApprovalStatusListener(subProcess.getFlowElements()); + } + } + + private void calculateAllElementList(Collection elements, List resultList) { + resultList.addAll(elements); + for (FlowElement element : elements) { + if (element instanceof SubProcess) { + this.calculateAllElementList(((SubProcess) element).getFlowElements(), resultList); + } + } + } + + private void processFlowTaskExtList(List flowTaskExtList, BpmnModel bpmnModel) { + List elementList = new LinkedList<>(); + this.calculateAllElementList(bpmnModel.getMainProcess().getFlowElements(), elementList); + this.doAddLatestApprovalStatusListener(elementList); + Map elementMap = elementList.stream() + .filter(UserTask.class::isInstance).collect(Collectors.toMap(FlowElement::getId, c -> c)); + BaseFlowIdentityExtHelper flowIdentityExtHelper = flowCustomExtFactory.getFlowIdentityExtHelper(); + for (FlowTaskExt t : flowTaskExtList) { + UserTask userTask = (UserTask) elementMap.get(t.getTaskId()); + flowApiService.addTaskCreateListener(userTask, FlowUserTaskListener.class); + Map> attributes = userTask.getAttributes(); + if (CollUtil.isNotEmpty(attributes.get(FlowConstant.USER_TASK_AUTO_SKIP_KEY))) { + flowApiService.addTaskCreateListener(userTask, AutoSkipTaskListener.class); + } + // 如果流程图中包含部门领导审批和上级部门领导审批的选项,就需要注册 FlowCustomExtFactory 工厂中的 + // BaseFlowIdentityExtHelper 对象,该注册操作需要业务模块中实现。 + if (StrUtil.equals(t.getGroupType(), FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER)) { + userTask.setCandidateGroups( + CollUtil.newArrayList("${" + FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER_VAR + "}")); + Assert.notNull(flowIdentityExtHelper); + flowApiService.addTaskCreateListener(userTask, flowIdentityExtHelper.getUpDeptPostLeaderListener()); + } else if (StrUtil.equals(t.getGroupType(), FlowConstant.GROUP_TYPE_DEPT_POST_LEADER)) { + userTask.setCandidateGroups( + CollUtil.newArrayList("${" + FlowConstant.GROUP_TYPE_DEPT_POST_LEADER_VAR + "}")); + Assert.notNull(flowIdentityExtHelper); + flowApiService.addTaskCreateListener(userTask, flowIdentityExtHelper.getDeptPostLeaderListener()); + } else if (StrUtil.equals(t.getGroupType(), FlowConstant.GROUP_TYPE_POST)) { + Assert.notNull(t.getDeptPostListJson()); + List groupDataList = + JSON.parseArray(t.getDeptPostListJson(), FlowTaskPostCandidateGroup.class); + List candidateGroupList = + FlowTaskPostCandidateGroup.buildCandidateGroupList(groupDataList); + userTask.setCandidateGroups(candidateGroupList); + } + this.processFlowTaskExtListener(userTask, t); + } + } + + private void processFlowTaskExtListener(UserTask userTask, FlowTaskExt taskExt) { + if (StrUtil.isBlank(taskExt.getExtraDataJson())) { + return; + } + FlowUserTaskExtData userTaskExtData = + JSON.parseObject(taskExt.getExtraDataJson(), FlowUserTaskExtData.class); + if (CollUtil.isNotEmpty(userTaskExtData.getFlowNotifyTypeList())) { + flowApiService.addTaskCreateListener(userTask, FlowTaskNotifyListener.class); + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowEntryVariableServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowEntryVariableServiceImpl.java new file mode 100644 index 00000000..bba2426f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowEntryVariableServiceImpl.java @@ -0,0 +1,137 @@ +package com.orangeforms.common.flow.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.orangeforms.common.flow.service.*; +import com.orangeforms.common.flow.dao.*; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.github.pagehelper.Page; +import lombok.extern.slf4j.Slf4j; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; + +/** + * 流程变量数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("flowEntryVariableService") +public class FlowEntryVariableServiceImpl extends BaseService implements FlowEntryVariableService { + + @Autowired + private FlowEntryVariableMapper flowEntryVariableMapper; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return flowEntryVariableMapper; + } + + /** + * 保存新增对象。 + * + * @param flowEntryVariable 新增对象。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public FlowEntryVariable saveNew(FlowEntryVariable flowEntryVariable) { + flowEntryVariable.setVariableId(idGenerator.nextLongId()); + flowEntryVariable.setCreateTime(new Date()); + flowEntryVariableMapper.insert(flowEntryVariable); + return flowEntryVariable; + } + + /** + * 更新数据对象。 + * + * @param flowEntryVariable 更新的对象。 + * @param originalFlowEntryVariable 原有数据对象。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(FlowEntryVariable flowEntryVariable, FlowEntryVariable originalFlowEntryVariable) { + flowEntryVariable.setCreateTime(originalFlowEntryVariable.getCreateTime()); + // 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。 + UpdateWrapper uw = this.createUpdateQueryForNullValue(flowEntryVariable, flowEntryVariable.getVariableId()); + return flowEntryVariableMapper.update(flowEntryVariable, uw) == 1; + } + + /** + * 删除指定数据。 + * + * @param variableId 主键Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long variableId) { + return flowEntryVariableMapper.deleteById(variableId) == 1; + } + + /** + * 删除指定流程Id的所有变量。 + * + * @param entryId 流程Id。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void removeByEntryId(Long entryId) { + flowEntryVariableMapper.delete( + new LambdaQueryWrapper().eq(FlowEntryVariable::getEntryId, entryId)); + } + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getFlowEntryVariableListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getFlowEntryVariableList(FlowEntryVariable filter, String orderBy) { + return flowEntryVariableMapper.getFlowEntryVariableList(filter, orderBy); + } + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getFlowEntryVariableList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getFlowEntryVariableListWithRelation(FlowEntryVariable filter, String orderBy) { + List resultList = flowEntryVariableMapper.getFlowEntryVariableList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowMessageServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowMessageServiceImpl.java new file mode 100644 index 00000000..5b0a86cc --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowMessageServiceImpl.java @@ -0,0 +1,385 @@ +package com.orangeforms.common.flow.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.flow.constant.FlowConstant; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.flow.model.constant.FlowMessageOperationType; +import com.orangeforms.common.flow.model.constant.FlowMessageType; +import com.orangeforms.common.flow.dao.FlowMessageIdentityOperationMapper; +import com.orangeforms.common.flow.dao.FlowMessageCandidateIdentityMapper; +import com.orangeforms.common.flow.dao.FlowMessageMapper; +import com.orangeforms.common.flow.object.FlowTaskPostCandidateGroup; +import com.orangeforms.common.flow.service.FlowApiService; +import com.orangeforms.common.flow.service.FlowMessageService; +import com.orangeforms.common.flow.service.FlowTaskExtService; +import com.orangeforms.common.flow.util.FlowCustomExtFactory; +import com.orangeforms.common.flow.vo.TaskInfoVo; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.runtime.ProcessInstance; +import org.flowable.task.api.Task; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; + +/** + * 工作流消息数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("flowMessageService") +public class FlowMessageServiceImpl extends BaseService implements FlowMessageService { + + @Autowired + private FlowMessageMapper flowMessageMapper; + @Autowired + private FlowMessageCandidateIdentityMapper flowMessageCandidateIdentityMapper; + @Autowired + private FlowMessageIdentityOperationMapper flowMessageIdentityOperationMapper; + @Autowired + private FlowTaskExtService flowTaskExtService; + @Autowired + private FlowApiService flowApiService; + @Autowired + private FlowCustomExtFactory flowCustomExtFactory; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return flowMessageMapper; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public FlowMessage saveNew(FlowMessage flowMessage) { + flowMessage.setMessageId(idGenerator.nextLongId()); + TokenData tokenData = TokenData.takeFromRequest(); + if (tokenData != null) { + flowMessage.setTenantId(tokenData.getTenantId()); + flowMessage.setAppCode(tokenData.getAppCode()); + flowMessage.setCreateUserId(tokenData.getUserId()); + flowMessage.setCreateUsername(tokenData.getShowName()); + flowMessage.setUpdateUserId(tokenData.getUserId()); + } + flowMessage.setCreateTime(new Date()); + flowMessage.setUpdateTime(flowMessage.getCreateTime()); + flowMessageMapper.insert(flowMessage); + return flowMessage; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNewRemindMessage(FlowWorkOrder flowWorkOrder) { + List taskList = + flowApiService.getProcessInstanceActiveTaskList(flowWorkOrder.getProcessInstanceId()); + for (Task task : taskList) { + FlowMessage filter = new FlowMessage(); + filter.setTaskId(task.getId()); + List messageList = flowMessageMapper.selectList(new QueryWrapper<>(filter)); + // 同一个任务只能催办一次,多次催办则累加催办次数。 + if (CollUtil.isNotEmpty(messageList)) { + for (FlowMessage flowMessage : messageList) { + flowMessage.setRemindCount(flowMessage.getRemindCount() + 1); + flowMessageMapper.updateById(flowMessage); + } + continue; + } + FlowMessage flowMessage = BeanUtil.copyProperties(flowWorkOrder, FlowMessage.class); + flowMessage.setMessageType(FlowMessageType.REMIND_TYPE); + flowMessage.setRemindCount(1); + flowMessage.setProcessInstanceInitiator(flowWorkOrder.getSubmitUsername()); + flowMessage.setTaskId(task.getId()); + flowMessage.setTaskName(task.getName()); + flowMessage.setTaskStartTime(task.getCreateTime()); + flowMessage.setTaskAssignee(task.getAssignee()); + flowMessage.setTaskFinished(false); + if (TokenData.takeFromRequest() == null) { + Set usernameSet = CollUtil.newHashSet(flowWorkOrder.getSubmitUsername()); + Map m = flowCustomExtFactory.getFlowIdentityExtHelper().mapUserShowNameByLoginName(usernameSet); + flowMessage.setCreateUsername(m.containsKey(flowWorkOrder.getSubmitUsername()) + ? m.get(flowWorkOrder.getSubmitUsername()) : flowWorkOrder.getSubmitUsername()); + } + this.saveNew(flowMessage); + FlowTaskExt flowTaskExt = flowTaskExtService.getByProcessDefinitionIdAndTaskId( + flowWorkOrder.getProcessDefinitionId(), task.getTaskDefinitionKey()); + if (flowTaskExt != null) { + // 插入与当前消息关联任务的候选人 + this.saveMessageCandidateIdentityWithMessage( + flowWorkOrder.getProcessInstanceId(), flowTaskExt, task, flowMessage.getMessageId()); + } + // 插入与当前消息关联任务的指派人。 + if (StrUtil.isNotBlank(task.getAssignee())) { + this.saveMessageCandidateIdentity( + flowMessage.getMessageId(), FlowConstant.GROUP_TYPE_USER_VAR, task.getAssignee()); + } + } + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNewCopyMessage(Task task, JSONObject copyDataJson) { + if (copyDataJson.isEmpty()) { + return; + } + ProcessInstance instance = flowApiService.getProcessInstance(task.getProcessInstanceId()); + FlowMessage flowMessage = new FlowMessage(); + flowMessage.setMessageType(FlowMessageType.COPY_TYPE); + flowMessage.setRemindCount(0); + flowMessage.setProcessDefinitionId(instance.getProcessDefinitionId()); + flowMessage.setProcessDefinitionKey(instance.getProcessDefinitionKey()); + flowMessage.setProcessDefinitionName(instance.getProcessDefinitionName()); + flowMessage.setProcessInstanceId(instance.getProcessInstanceId()); + flowMessage.setProcessInstanceInitiator(instance.getStartUserId()); + flowMessage.setTaskId(task.getId()); + flowMessage.setTaskDefinitionKey(task.getTaskDefinitionKey()); + flowMessage.setTaskName(task.getName()); + flowMessage.setTaskStartTime(task.getCreateTime()); + flowMessage.setTaskAssignee(task.getAssignee()); + flowMessage.setTaskFinished(false); + flowMessage.setOnlineFormData(true); + // 如果是在线表单,这里就保存关联的在线表单Id,便于在线表单业务数据的查找。 + if (BooleanUtil.isTrue(flowMessage.getOnlineFormData())) { + TaskInfoVo taskInfo = JSON.parseObject(task.getFormKey(), TaskInfoVo.class); + flowMessage.setBusinessDataShot(taskInfo.getFormId().toString()); + } + this.saveNew(flowMessage); + for (Map.Entry entry : copyDataJson.entrySet()) { + if (entry.getValue() != null) { + this.saveMessageCandidateIdentityList( + flowMessage.getMessageId(), entry.getKey(), entry.getValue().toString()); + } + } + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void updateFinishedStatusByTaskId(String taskId) { + FlowMessage flowMessage = new FlowMessage(); + flowMessage.setTaskFinished(true); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(FlowMessage::getTaskId, taskId); + flowMessageMapper.update(flowMessage, queryWrapper); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void updateFinishedStatusByProcessInstanceId(String processInstanceId) { + FlowMessage flowMessage = new FlowMessage(); + flowMessage.setTaskFinished(true); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(FlowMessage::getProcessInstanceId, processInstanceId); + flowMessageMapper.update(flowMessage, queryWrapper); + } + + @Override + public List getRemindingMessageListByUser() { + TokenData tokenData = TokenData.takeFromRequest(); + return flowMessageMapper.getRemindingMessageListByUser( + tokenData.getTenantId(), tokenData.getAppCode(), tokenData.getLoginName(), buildGroupIdSet()); + } + + @Override + public List getCopyMessageListByUser(Boolean read) { + TokenData tokenData = TokenData.takeFromRequest(); + return flowMessageMapper.getCopyMessageListByUser( + tokenData.getTenantId(), tokenData.getAppCode(), tokenData.getLoginName(), buildGroupIdSet(), read); + } + + @Override + public boolean isCandidateIdentityOnMessage(Long messageId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(FlowMessageCandidateIdentity::getMessageId, messageId); + queryWrapper.in(FlowMessageCandidateIdentity::getCandidateId, buildGroupIdSet()); + return flowMessageCandidateIdentityMapper.selectCount(queryWrapper) > 0; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void readCopyTask(Long messageId) { + FlowMessageIdentityOperation operation = new FlowMessageIdentityOperation(); + operation.setId(idGenerator.nextLongId()); + operation.setMessageId(messageId); + operation.setLoginName(TokenData.takeFromRequest().getLoginName()); + operation.setOperationType(FlowMessageOperationType.READ_FINISHED); + operation.setOperationTime(new Date()); + flowMessageIdentityOperationMapper.insert(operation); + } + + @Override + public int countRemindingMessageListByUser() { + TokenData tokenData = TokenData.takeFromRequest(); + return flowMessageMapper.countRemindingMessageListByUser( + tokenData.getTenantId(), tokenData.getAppCode(), tokenData.getLoginName(), buildGroupIdSet()); + } + + @Override + public int countCopyMessageByUser() { + TokenData tokenData = TokenData.takeFromRequest(); + return flowMessageMapper.countCopyMessageListByUser( + tokenData.getTenantId(), tokenData.getAppCode(), tokenData.getLoginName(), buildGroupIdSet()); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void removeByProcessInstanceId(String processInstanceId) { + flowMessageCandidateIdentityMapper.deleteByProcessInstanceId(processInstanceId); + flowMessageIdentityOperationMapper.deleteByProcessInstanceId(processInstanceId); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(FlowMessage::getProcessInstanceId, processInstanceId); + flowMessageMapper.delete(queryWrapper); + } + + private Set buildGroupIdSet() { + TokenData tokenData = TokenData.takeFromRequest(); + Set groupIdSet = new HashSet<>(1); + groupIdSet.add(tokenData.getLoginName()); + this.parseAndAddIdArray(groupIdSet, tokenData.getRoleIds()); + this.parseAndAddIdArray(groupIdSet, tokenData.getDeptPostIds()); + this.parseAndAddIdArray(groupIdSet, tokenData.getPostIds()); + if (tokenData.getDeptId() != null) { + groupIdSet.add(tokenData.getDeptId().toString()); + } + return groupIdSet; + } + + private void parseAndAddIdArray(Set groupIdSet, String idArray) { + if (StrUtil.isNotBlank(idArray)) { + if (groupIdSet == null) { + groupIdSet = new HashSet<>(); + } + groupIdSet.addAll(StrUtil.split(idArray, ',')); + } + } + + private void saveMessageCandidateIdentityWithMessage( + String processInstanceId, FlowTaskExt flowTaskExt, Task task, Long messageId) { + List candidates = flowApiService.getCandidateUsernames(flowTaskExt, task.getId()); + if (CollUtil.isNotEmpty(candidates)) { + this.saveMessageCandidateIdentityList( + messageId, FlowConstant.GROUP_TYPE_USER_VAR, CollUtil.join(candidates, ",")); + } + this.saveMessageCandidateIdentityList( + messageId, FlowConstant.GROUP_TYPE_ROLE_VAR, flowTaskExt.getRoleIds()); + this.saveMessageCandidateIdentityList( + messageId, FlowConstant.GROUP_TYPE_DEPT_VAR, flowTaskExt.getDeptIds()); + if (StrUtil.equals(flowTaskExt.getGroupType(), FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER)) { + Object v = flowApiService.getProcessInstanceVariable( + processInstanceId, FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER_VAR); + if (v != null) { + this.saveMessageCandidateIdentity( + messageId, FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER_VAR, v.toString()); + } + } else if (StrUtil.equals(flowTaskExt.getGroupType(), FlowConstant.GROUP_TYPE_DEPT_POST_LEADER)) { + Object v = flowApiService.getProcessInstanceVariable( + processInstanceId, FlowConstant.GROUP_TYPE_DEPT_POST_LEADER_VAR); + if (v != null) { + this.saveMessageCandidateIdentity( + messageId, FlowConstant.GROUP_TYPE_DEPT_POST_LEADER_VAR, v.toString()); + } + } else if (StrUtil.equals(flowTaskExt.getGroupType(), FlowConstant.GROUP_TYPE_POST)) { + Assert.notBlank(flowTaskExt.getDeptPostListJson()); + List groupDataList = + JSONArray.parseArray(flowTaskExt.getDeptPostListJson(), FlowTaskPostCandidateGroup.class); + for (FlowTaskPostCandidateGroup groupData : groupDataList) { + this.saveMessageCandidateIdentity(messageId, processInstanceId, groupData); + } + } + } + + private void saveMessageCandidateIdentity( + Long messageId, String processInstanceId, FlowTaskPostCandidateGroup groupData) { + FlowMessageCandidateIdentity candidateIdentity = new FlowMessageCandidateIdentity(); + candidateIdentity.setId(idGenerator.nextLongId()); + candidateIdentity.setMessageId(messageId); + candidateIdentity.setCandidateType(groupData.getType()); + switch (groupData.getType()) { + case FlowConstant.GROUP_TYPE_ALL_DEPT_POST_VAR: + candidateIdentity.setCandidateId(groupData.getPostId()); + flowMessageCandidateIdentityMapper.insert(candidateIdentity); + break; + case FlowConstant.GROUP_TYPE_DEPT_POST_VAR: + candidateIdentity.setCandidateId(groupData.getDeptPostId()); + flowMessageCandidateIdentityMapper.insert(candidateIdentity); + break; + case FlowConstant.GROUP_TYPE_SELF_DEPT_POST_VAR: + Object v = flowApiService.getProcessInstanceVariable( + processInstanceId, FlowConstant.SELF_DEPT_POST_PREFIX + groupData.getPostId()); + if (v != null) { + candidateIdentity.setCandidateId(v.toString()); + flowMessageCandidateIdentityMapper.insert(candidateIdentity); + } + break; + case FlowConstant.GROUP_TYPE_UP_DEPT_POST_VAR: + Object v2 = flowApiService.getProcessInstanceVariable( + processInstanceId, FlowConstant.UP_DEPT_POST_PREFIX + groupData.getPostId()); + if (v2 != null) { + candidateIdentity.setCandidateId(v2.toString()); + flowMessageCandidateIdentityMapper.insert(candidateIdentity); + } + break; + case FlowConstant.GROUP_TYPE_SIBLING_DEPT_POST_VAR: + Object v3 = flowApiService.getProcessInstanceVariable( + processInstanceId, FlowConstant.SIBLING_DEPT_POST_PREFIX + groupData.getPostId()); + if (v3 != null) { + List candidateIds = StrUtil.split(v3.toString(), ","); + for (String candidateId : candidateIds) { + candidateIdentity.setId(idGenerator.nextLongId()); + candidateIdentity.setCandidateId(candidateId); + flowMessageCandidateIdentityMapper.insert(candidateIdentity); + } + } + break; + default: + break; + } + } + private void saveMessageCandidateIdentity(Long messageId, String candidateType, String candidateId) { + FlowMessageCandidateIdentity candidateIdentity = new FlowMessageCandidateIdentity(); + candidateIdentity.setId(idGenerator.nextLongId()); + candidateIdentity.setMessageId(messageId); + candidateIdentity.setCandidateType(candidateType); + candidateIdentity.setCandidateId(candidateId); + flowMessageCandidateIdentityMapper.insert(candidateIdentity); + } + + private void saveMessageCandidateIdentityList(Long messageId, String candidateType, String identityIds) { + if (StrUtil.isNotBlank(identityIds)) { + for (String identityId : StrUtil.split(identityIds, ',')) { + FlowMessageCandidateIdentity candidateIdentity = new FlowMessageCandidateIdentity(); + candidateIdentity.setId(idGenerator.nextLongId()); + candidateIdentity.setMessageId(messageId); + candidateIdentity.setCandidateType(candidateType); + candidateIdentity.setCandidateId(identityId); + flowMessageCandidateIdentityMapper.insert(candidateIdentity); + } + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowMultiInstanceTransServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowMultiInstanceTransServiceImpl.java new file mode 100644 index 00000000..0266b624 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowMultiInstanceTransServiceImpl.java @@ -0,0 +1,87 @@ +package com.orangeforms.common.flow.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.flow.dao.FlowMultiInstanceTransMapper; +import com.orangeforms.common.flow.model.FlowMultiInstanceTrans; +import com.orangeforms.common.flow.service.FlowMultiInstanceTransService; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; + +/** + * 会签任务操作流水数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("flowMultiInstanceTransService") +public class FlowMultiInstanceTransServiceImpl + extends BaseService implements FlowMultiInstanceTransService { + + @Autowired + private FlowMultiInstanceTransMapper flowMultiInstanceTransMapper; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return flowMultiInstanceTransMapper; + } + + /** + * 保存新增对象。 + * + * @param flowMultiInstanceTrans 新增对象。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public FlowMultiInstanceTrans saveNew(FlowMultiInstanceTrans flowMultiInstanceTrans) { + flowMultiInstanceTrans.setId(idGenerator.nextLongId()); + TokenData tokenData = TokenData.takeFromRequest(); + flowMultiInstanceTrans.setCreateUserId(tokenData.getUserId()); + flowMultiInstanceTrans.setCreateLoginName(tokenData.getLoginName()); + flowMultiInstanceTrans.setCreateUsername(tokenData.getShowName()); + flowMultiInstanceTrans.setCreateTime(new Date()); + flowMultiInstanceTransMapper.insert(flowMultiInstanceTrans); + return flowMultiInstanceTrans; + } + + @Override + public FlowMultiInstanceTrans getByExecutionId(String executionId, String taskId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(FlowMultiInstanceTrans::getExecutionId, executionId); + queryWrapper.eq(FlowMultiInstanceTrans::getTaskId, taskId); + return flowMultiInstanceTransMapper.selectOne(queryWrapper); + } + + @Override + public FlowMultiInstanceTrans getWithAssigneeListByMultiInstanceExecId(String multiInstanceExecId) { + if (multiInstanceExecId == null) { + return null; + } + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(FlowMultiInstanceTrans::getMultiInstanceExecId, multiInstanceExecId); + queryWrapper.isNotNull(FlowMultiInstanceTrans::getAssigneeList); + return flowMultiInstanceTransMapper.selectOne(queryWrapper); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowTaskCommentServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowTaskCommentServiceImpl.java new file mode 100644 index 00000000..a1244b61 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowTaskCommentServiceImpl.java @@ -0,0 +1,142 @@ +package com.orangeforms.common.flow.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.orangeforms.common.flow.service.*; +import com.orangeforms.common.flow.dao.*; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; + +/** + * 流程任务批注数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("flowTaskCommentService") +public class FlowTaskCommentServiceImpl extends BaseService implements FlowTaskCommentService { + + @Autowired + private FlowTaskCommentMapper flowTaskCommentMapper; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return flowTaskCommentMapper; + } + + /** + * 保存新增对象。 + * + * @param flowTaskComment 新增对象。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public FlowTaskComment saveNew(FlowTaskComment flowTaskComment) { + flowTaskComment.setId(idGenerator.nextLongId()); + TokenData tokenData = TokenData.takeFromRequest(); + if (tokenData != null) { + flowTaskComment.setHeadImageUrl(tokenData.getHeadImageUrl()); + flowTaskComment.setCreateUserId(tokenData.getUserId()); + flowTaskComment.setCreateLoginName(tokenData.getLoginName()); + flowTaskComment.setCreateUsername(tokenData.getShowName()); + } + flowTaskComment.setCreateTime(new Date()); + flowTaskCommentMapper.insert(flowTaskComment); + FlowTaskComment.setToRequest(flowTaskComment); + return flowTaskComment; + } + + /** + * 查询指定流程实例Id下的所有审批任务的批注。 + * + * @param processInstanceId 流程实例Id。 + * @return 查询结果集。 + */ + @Override + public List getFlowTaskCommentList(String processInstanceId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(FlowTaskComment::getProcessInstanceId, processInstanceId); + queryWrapper.orderByAsc(FlowTaskComment::getId); + return flowTaskCommentMapper.selectList(queryWrapper); + } + + @Override + public List getFlowTaskCommentListByTaskIds(Set taskIdSet) { + LambdaQueryWrapper queryWrapper = + new LambdaQueryWrapper().in(FlowTaskComment::getTaskId, taskIdSet); + queryWrapper.orderByDesc(FlowTaskComment::getId); + return flowTaskCommentMapper.selectList(queryWrapper); + } + + @Override + public FlowTaskComment getLatestFlowTaskComment(String processInstanceId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(FlowTaskComment::getProcessInstanceId, processInstanceId); + queryWrapper.orderByDesc(FlowTaskComment::getId); + IPage pageData = flowTaskCommentMapper.selectPage(new Page<>(1, 1), queryWrapper); + return CollUtil.isEmpty(pageData.getRecords()) ? null : pageData.getRecords().get(0); + } + + @Override + public FlowTaskComment getLatestFlowTaskComment(String processInstanceId, String taskDefinitionKey) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(FlowTaskComment::getProcessInstanceId, processInstanceId); + queryWrapper.eq(FlowTaskComment::getTaskKey, taskDefinitionKey); + queryWrapper.orderByDesc(FlowTaskComment::getId); + IPage pageData = flowTaskCommentMapper.selectPage(new Page<>(1, 1), queryWrapper); + return CollUtil.isEmpty(pageData.getRecords()) ? null : pageData.getRecords().get(0); + } + + @Override + public FlowTaskComment getFirstFlowTaskComment(String processInstanceId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(FlowTaskComment::getProcessInstanceId, processInstanceId); + queryWrapper.orderByAsc(FlowTaskComment::getId); + IPage pageData = flowTaskCommentMapper.selectPage(new Page<>(1, 1), queryWrapper); + return CollUtil.isEmpty(pageData.getRecords()) ? null : pageData.getRecords().get(0); + } + + @Override + public List getFlowTaskCommentListByExecutionId( + String processInstanceId, String taskId, String executionId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(FlowTaskComment::getProcessInstanceId, processInstanceId); + queryWrapper.eq(FlowTaskComment::getTaskId, taskId); + queryWrapper.eq(FlowTaskComment::getExecutionId, executionId); + queryWrapper.orderByAsc(FlowTaskComment::getCreateTime); + return flowTaskCommentMapper.selectList(queryWrapper); + } + + @Override + public List getFlowTaskCommentListByMultiInstanceExecId(String multiInstanceExecId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(FlowTaskComment::getMultiInstanceExecId, multiInstanceExecId); + return flowTaskCommentMapper.selectList(queryWrapper); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowTaskExtServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowTaskExtServiceImpl.java new file mode 100644 index 00000000..54bd7ac1 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowTaskExtServiceImpl.java @@ -0,0 +1,622 @@ +package com.orangeforms.common.flow.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.core.object.Tuple2; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.flow.constant.FlowApprovalType; +import com.orangeforms.common.flow.constant.FlowConstant; +import com.orangeforms.common.flow.object.FlowElementExtProperty; +import com.orangeforms.common.flow.object.FlowTaskMultiSignAssign; +import com.orangeforms.common.flow.object.FlowUserTaskExtData; +import com.orangeforms.common.flow.service.*; +import com.orangeforms.common.flow.dao.*; +import com.orangeforms.common.flow.model.*; +import com.orangeforms.common.flow.util.BaseFlowIdentityExtHelper; +import com.orangeforms.common.flow.util.FlowCustomExtFactory; +import com.orangeforms.common.flow.vo.FlowUserInfoVo; +import com.orangeforms.common.flow.vo.TaskInfoVo; +import lombok.extern.slf4j.Slf4j; +import org.flowable.bpmn.model.*; +import org.flowable.bpmn.model.Process; +import org.flowable.task.api.TaskInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; + +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("flowTaskExtService") +public class FlowTaskExtServiceImpl extends BaseService implements FlowTaskExtService { + + @Autowired + private FlowTaskExtMapper flowTaskExtMapper; + @Autowired + private FlowEntryVariableService flowEntryVariableService; + @Autowired + private FlowCustomExtFactory flowCustomExtFactory; + @Autowired + private FlowApiService flowApiService; + @Autowired + private FlowMultiInstanceTransService flowMultiInstanceTransService; + @Autowired + private FlowTaskCommentService flowTaskCommentService; + + private static final String ID = "id"; + private static final String TYPE = "type"; + private static final String LABEL = "label"; + private static final String NAME = "name"; + private static final String VALUE = "value"; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return flowTaskExtMapper; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void saveBatch(List flowTaskExtList) { + if (CollUtil.isNotEmpty(flowTaskExtList)) { + flowTaskExtMapper.insertList(flowTaskExtList); + } + } + + @Override + public FlowTaskExt getByProcessDefinitionIdAndTaskId(String processDefinitionId, String taskId) { + FlowTaskExt filter = new FlowTaskExt(); + filter.setProcessDefinitionId(processDefinitionId); + filter.setTaskId(taskId); + return flowTaskExtMapper.selectOne(new QueryWrapper<>(filter)); + } + + @Override + public List getByProcessDefinitionId(String processDefinitionId) { + FlowTaskExt filter = new FlowTaskExt(); + filter.setProcessDefinitionId(processDefinitionId); + return flowTaskExtMapper.selectList(new QueryWrapper<>(filter)); + } + + @Override + public List getCandidateUserInfoList( + String processInstanceId, + FlowTaskExt flowTaskExt, + TaskInfo taskInfo, + boolean isMultiInstanceTask, + boolean historic) { + List resultUserMapList = new LinkedList<>(); + if (!isMultiInstanceTask && this.buildTransferUserList(taskInfo, resultUserMapList)) { + return resultUserMapList; + } + Set loginNameSet = new HashSet<>(); + this.buildFlowUserInfoListByDeptAndRoleIds(flowTaskExt, loginNameSet, resultUserMapList); + BaseFlowIdentityExtHelper flowIdentityExtHelper = flowCustomExtFactory.getFlowIdentityExtHelper(); + Set usernameSet = new HashSet<>(); + switch (flowTaskExt.getGroupType()) { + case FlowConstant.GROUP_TYPE_ASSIGNEE: + usernameSet.add(taskInfo.getAssignee()); + break; + case FlowConstant.GROUP_TYPE_DEPT_POST_LEADER: + String deptPostLeaderId = flowApiService.getExecutionVariableStringWithSafe( + taskInfo.getExecutionId(), FlowConstant.GROUP_TYPE_DEPT_POST_LEADER_VAR); + List userInfoList = + flowIdentityExtHelper.getUserInfoListByDeptPostIds(CollUtil.newHashSet(deptPostLeaderId)); + this.buildUserMapList(userInfoList, loginNameSet, resultUserMapList); + break; + case FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER: + String upDeptPostLeaderId = flowApiService.getExecutionVariableStringWithSafe( + taskInfo.getExecutionId(), FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER_VAR); + List upUserInfoList = + flowIdentityExtHelper.getUserInfoListByDeptPostIds(CollUtil.newHashSet(upDeptPostLeaderId)); + this.buildUserMapList(upUserInfoList, loginNameSet, resultUserMapList); + break; + default: + break; + } + List candidateUsernames = flowApiService.getCandidateUsernames(flowTaskExt, taskInfo.getId()); + if (CollUtil.isNotEmpty(candidateUsernames)) { + usernameSet.addAll(candidateUsernames); + } + if (isMultiInstanceTask) { + List assigneeList = this.getAssigneeList(taskInfo.getExecutionId(), taskInfo.getId()); + if (CollUtil.isNotEmpty(assigneeList)) { + usernameSet.addAll(assigneeList); + } + } + if (CollUtil.isNotEmpty(usernameSet)) { + List userInfoList = flowIdentityExtHelper.getUserInfoListByUsernameSet(usernameSet); + this.buildUserMapList(userInfoList, loginNameSet, resultUserMapList); + } + Tuple2, Set> tuple2 = + flowApiService.getDeptPostIdAndPostIds(flowTaskExt, processInstanceId, historic); + Set postIdSet = tuple2.getSecond(); + Set deptPostIdSet = tuple2.getFirst(); + if (CollUtil.isNotEmpty(postIdSet)) { + List userInfoList = flowIdentityExtHelper.getUserInfoListByPostIds(postIdSet); + this.buildUserMapList(userInfoList, loginNameSet, resultUserMapList); + } + if (CollUtil.isNotEmpty(deptPostIdSet)) { + List userInfoList = flowIdentityExtHelper.getUserInfoListByDeptPostIds(deptPostIdSet); + this.buildUserMapList(userInfoList, loginNameSet, resultUserMapList); + } + return resultUserMapList; + } + + @Override + public List getCandidateUserInfoList( + String processInstanceId, + String executionId, + FlowTaskExt flowTaskExt) { + List resultUserMapList = new LinkedList<>(); + Set loginNameSet = new HashSet<>(); + this.buildFlowUserInfoListByDeptAndRoleIds(flowTaskExt, loginNameSet, resultUserMapList); + Set usernameSet = new HashSet<>(); + BaseFlowIdentityExtHelper flowIdentityExtHelper = flowCustomExtFactory.getFlowIdentityExtHelper(); + switch (flowTaskExt.getGroupType()) { + case FlowConstant.GROUP_TYPE_DEPT_POST_LEADER: + String deptPostLeaderId = flowApiService.getExecutionVariableStringWithSafe( + executionId, FlowConstant.GROUP_TYPE_DEPT_POST_LEADER_VAR); + List userInfoList = + flowIdentityExtHelper.getUserInfoListByDeptPostIds(CollUtil.newHashSet(deptPostLeaderId)); + this.buildUserMapList(userInfoList, loginNameSet, resultUserMapList); + break; + case FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER: + String upDeptPostLeaderId = flowApiService.getExecutionVariableStringWithSafe( + executionId, FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER_VAR); + List upUserInfoList = + flowIdentityExtHelper.getUserInfoListByDeptPostIds(CollUtil.newHashSet(upDeptPostLeaderId)); + this.buildUserMapList(upUserInfoList, loginNameSet, resultUserMapList); + break; + default: + break; + } + List candidateUsernames; + if (StrUtil.isBlank(flowTaskExt.getCandidateUsernames())) { + candidateUsernames = Collections.emptyList(); + } else { + if (!StrUtil.equals(flowTaskExt.getCandidateUsernames(), "${" + FlowConstant.TASK_APPOINTED_ASSIGNEE_VAR + "}")) { + candidateUsernames = StrUtil.split(flowTaskExt.getCandidateUsernames(), ","); + } else { + Object v = flowApiService.getExecutionVariableStringWithSafe(executionId, FlowConstant.TASK_APPOINTED_ASSIGNEE_VAR); + candidateUsernames = v == null ? null : StrUtil.split(v.toString(), ","); + } + } + if (CollUtil.isNotEmpty(candidateUsernames)) { + usernameSet.addAll(candidateUsernames); + } + if (CollUtil.isNotEmpty(usernameSet)) { + List userInfoList = flowIdentityExtHelper.getUserInfoListByUsernameSet(usernameSet); + this.buildUserMapList(userInfoList, loginNameSet, resultUserMapList); + } + Tuple2, Set> tuple2 = + flowApiService.getDeptPostIdAndPostIds(flowTaskExt, processInstanceId, false); + Set postIdSet = tuple2.getSecond(); + Set deptPostIdSet = tuple2.getFirst(); + if (CollUtil.isNotEmpty(postIdSet)) { + List userInfoList = flowIdentityExtHelper.getUserInfoListByPostIds(postIdSet); + this.buildUserMapList(userInfoList, loginNameSet, resultUserMapList); + } + if (CollUtil.isNotEmpty(deptPostIdSet)) { + List userInfoList = flowIdentityExtHelper.getUserInfoListByDeptPostIds(deptPostIdSet); + this.buildUserMapList(userInfoList, loginNameSet, resultUserMapList); + } + return resultUserMapList; + } + + private void buildUserMapList( + List userInfoList, Set loginNameSet, List userMapList) { + if (CollUtil.isEmpty(userInfoList)) { + return; + } + for (FlowUserInfoVo userInfo : userInfoList) { + if (!loginNameSet.contains(userInfo.getLoginName())) { + loginNameSet.add(userInfo.getLoginName()); + userMapList.add(userInfo); + } + } + } + + @Override + public FlowTaskExt buildTaskExtByUserTask(UserTask userTask) { + FlowTaskExt flowTaskExt = new FlowTaskExt(); + flowTaskExt.setTaskId(userTask.getId()); + String formKey = userTask.getFormKey(); + if (StrUtil.isNotBlank(formKey)) { + TaskInfoVo taskInfoVo = JSON.parseObject(formKey, TaskInfoVo.class); + flowTaskExt.setGroupType(taskInfoVo.getGroupType()); + } + JSONObject extraDataJson = this.buildFlowTaskExtensionData(userTask); + if (extraDataJson != null) { + flowTaskExt.setExtraDataJson(extraDataJson.toJSONString()); + } + Map> extensionMap = userTask.getExtensionElements(); + if (MapUtil.isEmpty(extensionMap)) { + return flowTaskExt; + } + List operationList = this.buildOperationListExtensionElement(extensionMap); + if (CollUtil.isNotEmpty(operationList)) { + flowTaskExt.setOperationListJson(JSON.toJSONString(operationList)); + } + List variableList = this.buildVariableListExtensionElement(extensionMap); + if (CollUtil.isNotEmpty(variableList)) { + flowTaskExt.setVariableListJson(JSON.toJSONString(variableList)); + } + JSONObject assigneeListObject = this.buildAssigneeListExtensionElement(extensionMap); + if (assigneeListObject != null) { + flowTaskExt.setAssigneeListJson(JSON.toJSONString(assigneeListObject)); + } + List deptPostList = this.buildDeptPostListExtensionElement(extensionMap); + if (deptPostList != null) { + flowTaskExt.setDeptPostListJson(JSON.toJSONString(deptPostList)); + } + List copyList = this.buildCopyListExtensionElement(extensionMap); + if (copyList != null) { + flowTaskExt.setCopyListJson(JSON.toJSONString(copyList)); + } + JSONObject candidateGroupObject = this.buildUserCandidateGroupsExtensionElement(extensionMap); + if (candidateGroupObject != null) { + String type = candidateGroupObject.getString(TYPE); + String value = candidateGroupObject.getString(VALUE); + switch (type) { + case "DEPT": + flowTaskExt.setDeptIds(value); + break; + case "ROLE": + flowTaskExt.setRoleIds(value); + break; + case "USERS": + flowTaskExt.setCandidateUsernames(value); + break; + default: + break; + } + } + return flowTaskExt; + } + + @Override + public List buildTaskExtList(BpmnModel bpmnModel) { + List processList = bpmnModel.getProcesses(); + List flowTaskExtList = new LinkedList<>(); + for (Process process : processList) { + for (FlowElement element : process.getFlowElements()) { + this.doBuildTaskExtList(element, flowTaskExtList); + } + } + return flowTaskExtList; + } + + @Override + public List buildOperationListExtensionElement(Map> extensionMap) { + List formOperationElements = + this.getMyExtensionElementList(extensionMap, "operationList", "formOperation"); + if (CollUtil.isEmpty(formOperationElements)) { + return Collections.emptyList(); + } + List resultList = new LinkedList<>(); + for (ExtensionElement e : formOperationElements) { + JSONObject operationJsonData = new JSONObject(); + operationJsonData.put(ID, e.getAttributeValue(null, ID)); + operationJsonData.put(LABEL, e.getAttributeValue(null, LABEL)); + operationJsonData.put(TYPE, e.getAttributeValue(null, TYPE)); + operationJsonData.put("showOrder", e.getAttributeValue(null, "showOrder")); + operationJsonData.put("latestApprovalStatus", e.getAttributeValue(null, "latestApprovalStatus")); + String multiSignAssignee = e.getAttributeValue(null, "multiSignAssignee"); + if (StrUtil.isNotBlank(multiSignAssignee)) { + operationJsonData.put("multiSignAssignee", + JSON.parseObject(multiSignAssignee, FlowTaskMultiSignAssign.class)); + } + resultList.add(operationJsonData); + } + return resultList; + } + + @Override + public List buildVariableListExtensionElement(Map> extensionMap) { + List formVariableElements = + this.getMyExtensionElementList(extensionMap, "variableList", "formVariable"); + if (CollUtil.isEmpty(formVariableElements)) { + return Collections.emptyList(); + } + Set variableIdSet = new HashSet<>(); + for (ExtensionElement e : formVariableElements) { + String id = e.getAttributeValue(null, ID); + variableIdSet.add(Long.parseLong(id)); + } + List variableList = flowEntryVariableService.getInList(variableIdSet); + List resultList = new LinkedList<>(); + for (FlowEntryVariable variable : variableList) { + resultList.add((JSONObject) JSON.toJSON(variable)); + } + return resultList; + } + + @Override + public FlowElementExtProperty buildFlowElementExt(FlowElement element) { + JSONObject propertiesData = this.buildFlowElementExtToJson(element); + return propertiesData == null ? null : propertiesData.toJavaObject(FlowElementExtProperty.class); + } + + @Override + public JSONObject buildFlowElementExtToJson(FlowElement element) { + Map> extensionMap = element.getExtensionElements(); + List propertiesElements = + this.getMyExtensionElementList(extensionMap, "properties", "property"); + if (CollUtil.isEmpty(propertiesElements)) { + return null; + } + JSONObject propertiesData = new JSONObject(); + for (ExtensionElement e : propertiesElements) { + String name = e.getAttributeValue(null, NAME); + String value = e.getAttributeValue(null, VALUE); + propertiesData.put(name, value); + } + return propertiesData; + } + + private void doBuildTaskExtList(FlowElement element, List flowTaskExtList) { + if (element instanceof UserTask) { + FlowTaskExt flowTaskExt = this.buildTaskExtByUserTask((UserTask) element); + flowTaskExtList.add(flowTaskExt); + } else if (element instanceof SubProcess) { + Collection flowElements = ((SubProcess) element).getFlowElements(); + for (FlowElement element1 : flowElements) { + this.doBuildTaskExtList(element1, flowTaskExtList); + } + } + } + + private void buildFlowUserInfoListByDeptAndRoleIds( + FlowTaskExt flowTaskExt, Set loginNameSet, List resultUserMapList) { + BaseFlowIdentityExtHelper flowIdentityExtHelper = flowCustomExtFactory.getFlowIdentityExtHelper(); + if (StrUtil.isNotBlank(flowTaskExt.getDeptIds())) { + Set deptIdSet = CollUtil.newHashSet(StrUtil.split(flowTaskExt.getDeptIds(), ',')); + List userInfoList = flowIdentityExtHelper.getUserInfoListByDeptIds(deptIdSet); + this.buildUserMapList(userInfoList, loginNameSet, resultUserMapList); + } + if (StrUtil.isNotBlank(flowTaskExt.getRoleIds())) { + Set roleIdSet = CollUtil.newHashSet(StrUtil.split(flowTaskExt.getRoleIds(), ',')); + List userInfoList = flowIdentityExtHelper.getUserInfoListByRoleIds(roleIdSet); + this.buildUserMapList(userInfoList, loginNameSet, resultUserMapList); + } + } + + private void buildFlowTaskTimeoutExtensionData( + Map> attributeMap, JSONObject extraDataJson) { + List timeoutHandleWayAttributes = attributeMap.get(FlowConstant.TASK_TIMEOUT_HANDLE_WAY); + if (CollUtil.isNotEmpty(timeoutHandleWayAttributes)) { + String handleWay = timeoutHandleWayAttributes.get(0).getValue(); + extraDataJson.put(FlowConstant.TASK_TIMEOUT_HANDLE_WAY, handleWay); + List timeoutHoursAttributes = attributeMap.get(FlowConstant.TASK_TIMEOUT_HOURS); + if (CollUtil.isEmpty(timeoutHoursAttributes)) { + throw new MyRuntimeException("没有设置任务超时小时数!"); + } + Integer timeoutHours = Integer.valueOf(timeoutHoursAttributes.get(0).getValue()); + extraDataJson.put(FlowConstant.TASK_TIMEOUT_HOURS, timeoutHours); + if (StrUtil.equals(handleWay, FlowUserTaskExtData.TIMEOUT_AUTO_COMPLETE)) { + List defaultAssigneeAttributes = + attributeMap.get(FlowConstant.TASK_TIMEOUT_DEFAULT_ASSIGNEE); + if (CollUtil.isEmpty(defaultAssigneeAttributes)) { + throw new MyRuntimeException("没有设置超时任务处理人!"); + } + extraDataJson.put(FlowConstant.TASK_TIMEOUT_DEFAULT_ASSIGNEE, defaultAssigneeAttributes.get(0).getValue()); + } + } + } + + private void buildFlowTaskEmptyUserExtensionData( + Map> attributeMap, JSONObject extraDataJson) { + List emptyUserHandleWayAttributes = attributeMap.get(FlowConstant.EMPTY_USER_HANDLE_WAY); + if (CollUtil.isNotEmpty(emptyUserHandleWayAttributes)) { + String handleWay = emptyUserHandleWayAttributes.get(0).getValue(); + extraDataJson.put(FlowConstant.EMPTY_USER_HANDLE_WAY, handleWay); + if (StrUtil.equals(handleWay, FlowUserTaskExtData.EMPTY_USER_TO_ASSIGNEE)) { + List emptyUserToAssigneeAttributes = attributeMap.get(FlowConstant.EMPTY_USER_TO_ASSIGNEE); + if (CollUtil.isEmpty(emptyUserToAssigneeAttributes)) { + throw new MyRuntimeException("没有设置空审批人的指定处理人!"); + } + extraDataJson.put(FlowConstant.EMPTY_USER_TO_ASSIGNEE, emptyUserToAssigneeAttributes.get(0).getValue()); + } + } + } + + private JSONObject buildFlowTaskExtensionData(UserTask userTask) { + JSONObject extraDataJson = this.buildFlowElementExtToJson(userTask); + Map> attributeMap = userTask.getAttributes(); + if (MapUtil.isEmpty(attributeMap)) { + return extraDataJson; + } + if (extraDataJson == null) { + extraDataJson = new JSONObject(); + } + this.buildFlowTaskTimeoutExtensionData(attributeMap, extraDataJson); + this.buildFlowTaskEmptyUserExtensionData(attributeMap, extraDataJson); + List rejectTypeAttributes = attributeMap.get(FlowConstant.USER_TASK_REJECT_TYPE_KEY); + if (CollUtil.isNotEmpty(rejectTypeAttributes)) { + extraDataJson.put(FlowConstant.USER_TASK_REJECT_TYPE_KEY, rejectTypeAttributes.get(0).getValue()); + } + List sendMsgTypeAttributes = attributeMap.get("sendMessageType"); + if (CollUtil.isNotEmpty(sendMsgTypeAttributes)) { + ExtensionAttribute attribute = sendMsgTypeAttributes.get(0); + extraDataJson.put(FlowConstant.USER_TASK_NOTIFY_TYPES_KEY, StrUtil.split(attribute.getValue(), ",")); + } + return extraDataJson; + } + + private JSONObject buildUserCandidateGroupsExtensionElement(Map> extensionMap) { + JSONObject jsonData = null; + List elementCandidateGroupsList = extensionMap.get("userCandidateGroups"); + if (CollUtil.isEmpty(elementCandidateGroupsList)) { + return jsonData; + } + jsonData = new JSONObject(); + ExtensionElement ee = elementCandidateGroupsList.get(0); + jsonData.put(TYPE, ee.getAttributeValue(null, TYPE)); + jsonData.put(VALUE, ee.getAttributeValue(null, VALUE)); + return jsonData; + } + + private JSONObject buildAssigneeListExtensionElement(Map> extensionMap) { + JSONObject jsonData = null; + List elementAssigneeList = extensionMap.get("assigneeList"); + if (CollUtil.isEmpty(elementAssigneeList)) { + return jsonData; + } + ExtensionElement ee = elementAssigneeList.get(0); + Map> childExtensionMap = ee.getChildElements(); + if (MapUtil.isEmpty(childExtensionMap)) { + return jsonData; + } + List assigneeElements = childExtensionMap.get("assignee"); + if (CollUtil.isEmpty(assigneeElements)) { + return jsonData; + } + JSONArray assigneeIdArray = new JSONArray(); + for (ExtensionElement e : assigneeElements) { + assigneeIdArray.add(e.getAttributeValue(null, ID)); + } + jsonData = new JSONObject(); + String assigneeType = ee.getAttributeValue(null, TYPE); + jsonData.put("assigneeType", assigneeType); + jsonData.put("assigneeList", assigneeIdArray); + return jsonData; + } + + private List buildDeptPostListExtensionElement(Map> extensionMap) { + List deptPostElements = + this.getMyExtensionElementList(extensionMap, "deptPostList", "deptPost"); + if (CollUtil.isEmpty(deptPostElements)) { + return Collections.emptyList(); + } + List resultList = new LinkedList<>(); + for (ExtensionElement e : deptPostElements) { + JSONObject deptPostJsonData = new JSONObject(); + deptPostJsonData.put(ID, e.getAttributeValue(null, ID)); + deptPostJsonData.put(TYPE, e.getAttributeValue(null, TYPE)); + String postId = e.getAttributeValue(null, "postId"); + if (postId != null) { + deptPostJsonData.put("postId", postId); + } + String deptPostId = e.getAttributeValue(null, "deptPostId"); + if (deptPostId != null) { + deptPostJsonData.put("deptPostId", deptPostId); + } + resultList.add(deptPostJsonData); + } + return resultList; + } + + private List buildCopyListExtensionElement(Map> extensionMap) { + List copyElements = + this.getMyExtensionElementList(extensionMap, "copyItemList", "copyItem"); + if (CollUtil.isEmpty(copyElements)) { + return Collections.emptyList(); + } + List resultList = new LinkedList<>(); + for (ExtensionElement e : copyElements) { + JSONObject copyJsonData = new JSONObject(); + String type = e.getAttributeValue(null, TYPE); + copyJsonData.put(TYPE, type); + if (!StrUtil.equalsAny(type, FlowConstant.GROUP_TYPE_DEPT_POST_LEADER_VAR, + FlowConstant.GROUP_TYPE_UP_DEPT_POST_LEADER_VAR, + FlowConstant.GROUP_TYPE_USER_VAR, + FlowConstant.GROUP_TYPE_ROLE_VAR, + FlowConstant.GROUP_TYPE_DEPT_VAR, + FlowConstant.GROUP_TYPE_DEPT_POST_VAR, + FlowConstant.GROUP_TYPE_ALL_DEPT_POST_VAR, + FlowConstant.GROUP_TYPE_SIBLING_DEPT_POST_VAR, + FlowConstant.GROUP_TYPE_SELF_DEPT_POST_VAR, + FlowConstant.GROUP_TYPE_UP_DEPT_POST_VAR)) { + throw new MyRuntimeException("Invalid TYPE [" + type + " ] for CopyItenList Extension!"); + } + String id = e.getAttributeValue(null, ID); + if (StrUtil.isNotBlank(id)) { + copyJsonData.put(ID, id); + } + resultList.add(copyJsonData); + } + return resultList; + } + + private List getMyExtensionElementList( + Map> extensionMap, String rootName, String childName) { + if (extensionMap == null) { + return Collections.emptyList(); + } + List elementList = extensionMap.get(rootName); + if (CollUtil.isEmpty(elementList)) { + return Collections.emptyList(); + } + if (StrUtil.isBlank(childName)) { + return elementList; + } + ExtensionElement ee = elementList.get(0); + Map> childExtensionMap = ee.getChildElements(); + if (MapUtil.isEmpty(childExtensionMap)) { + return Collections.emptyList(); + } + List childrenElements = childExtensionMap.get(childName); + if (CollUtil.isEmpty(childrenElements)) { + return Collections.emptyList(); + } + return childrenElements; + } + + private List getAssigneeList(String executionId, String taskId) { + FlowMultiInstanceTrans flowMultiInstanceTrans = + flowMultiInstanceTransService.getByExecutionId(executionId, taskId); + String multiInstanceExecId; + if (flowMultiInstanceTrans == null) { + multiInstanceExecId = flowApiService.getTaskVariableStringWithSafe( + taskId, FlowConstant.MULTI_SIGN_TASK_EXECUTION_ID_VAR); + } else { + multiInstanceExecId = flowMultiInstanceTrans.getMultiInstanceExecId(); + } + flowMultiInstanceTrans = + flowMultiInstanceTransService.getWithAssigneeListByMultiInstanceExecId(multiInstanceExecId); + return flowMultiInstanceTrans == null ? null + : StrUtil.split(flowMultiInstanceTrans.getAssigneeList(), ","); + } + + private boolean buildTransferUserList(TaskInfo taskInfo, List resultUserMapList) { + BaseFlowIdentityExtHelper flowIdentityExtHelper = flowCustomExtFactory.getFlowIdentityExtHelper(); + List taskCommentList = flowTaskCommentService.getFlowTaskCommentListByExecutionId( + taskInfo.getProcessInstanceId(), taskInfo.getId(), taskInfo.getExecutionId()); + if (CollUtil.isEmpty(taskCommentList)) { + return false; + } + FlowTaskComment transferComment = null; + for (int i = taskCommentList.size() - 1; i >= 0; i--) { + FlowTaskComment comment = taskCommentList.get(i); + if (StrUtil.equalsAny(comment.getApprovalType(), + FlowApprovalType.TRANSFER, FlowApprovalType.INTERVENE)) { + transferComment = comment; + break; + } + } + if (transferComment == null || StrUtil.isBlank(transferComment.getDelegateAssignee())) { + return false; + } + Set loginNameSet = new HashSet<>(StrUtil.split(transferComment.getDelegateAssignee(), ",")); + resultUserMapList.addAll(flowIdentityExtHelper.getUserInfoListByUsernameSet(loginNameSet)); + return true; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowWorkOrderServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowWorkOrderServiceImpl.java new file mode 100644 index 00000000..b36785a9 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/service/impl/FlowWorkOrderServiceImpl.java @@ -0,0 +1,356 @@ +package com.orangeforms.common.flow.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.github.pagehelper.page.PageMethod; +import com.orangeforms.common.core.annotation.DisableDataFilter; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.constant.GlobalDeletedFlag; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.flow.constant.FlowTaskStatus; +import com.orangeforms.common.flow.constant.FlowConstant; +import com.orangeforms.common.flow.dao.FlowWorkOrderExtMapper; +import com.orangeforms.common.flow.dao.FlowWorkOrderMapper; +import com.orangeforms.common.flow.dto.FlowWorkOrderDto; +import com.orangeforms.common.flow.model.FlowEntry; +import com.orangeforms.common.flow.model.FlowWorkOrder; +import com.orangeforms.common.flow.model.FlowWorkOrderExt; +import com.orangeforms.common.flow.util.FlowOperationHelper; +import com.orangeforms.common.flow.vo.FlowWorkOrderVo; +import com.orangeforms.common.flow.service.FlowApiService; +import com.orangeforms.common.flow.service.FlowEntryService; +import com.orangeforms.common.flow.service.FlowWorkOrderService; +import com.orangeforms.common.flow.util.BaseFlowIdentityExtHelper; +import com.orangeforms.common.flow.util.FlowCustomExtFactory; +import com.orangeforms.common.redis.util.CommonRedisUtil; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.runtime.ProcessInstance; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("flowWorkOrderService") +public class FlowWorkOrderServiceImpl extends BaseService implements FlowWorkOrderService { + + @Autowired + private FlowWorkOrderMapper flowWorkOrderMapper; + @Autowired + private FlowWorkOrderExtMapper flowWorkOrderExtMapper; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private FlowCustomExtFactory flowCustomExtFactory; + @Autowired + private FlowApiService flowApiService; + @Autowired + private FlowEntryService flowEntryService; + @Autowired + private CommonRedisUtil commonRedisUtil; + @Autowired + private FlowOperationHelper flowOperationHelper; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return flowWorkOrderMapper; + } + + /** + * 保存新增对象。 + * + * @param instance 流程实例对象。 + * @param dataId 流程实例的BusinessKey。 + * @param onlineTableId 在线数据表的主键Id。 + * @param tableName 面向静态表单所使用的表名。 + * @return 新增的工作流工单对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public FlowWorkOrder saveNew(ProcessInstance instance, Object dataId, Long onlineTableId, String tableName) { + // 正常插入流程工单数据。 + FlowWorkOrder flowWorkOrder = this.createWith(instance); + flowWorkOrder.setWorkOrderCode(this.generateWorkOrderCode(instance.getProcessDefinitionKey())); + flowWorkOrder.setBusinessKey(dataId.toString()); + flowWorkOrder.setOnlineTableId(onlineTableId); + flowWorkOrder.setTableName(tableName); + flowWorkOrder.setFlowStatus(FlowTaskStatus.SUBMITTED); + flowWorkOrderMapper.insert(flowWorkOrder); + return flowWorkOrder; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public FlowWorkOrder saveNewWithDraft( + ProcessInstance instance, Long onlineTableId, String tableName, String masterData, String slaveData) { + FlowWorkOrder flowWorkOrder = this.createWith(instance); + flowWorkOrder.setWorkOrderCode(this.generateWorkOrderCode(instance.getProcessDefinitionKey())); + flowWorkOrder.setOnlineTableId(onlineTableId); + flowWorkOrder.setTableName(tableName); + flowWorkOrder.setFlowStatus(FlowTaskStatus.DRAFT); + JSONObject draftData = new JSONObject(); + if (masterData != null) { + draftData.put(FlowConstant.MASTER_DATA_KEY, masterData); + } + if (slaveData != null) { + draftData.put(FlowConstant.SLAVE_DATA_KEY, slaveData); + } + FlowWorkOrderExt flowWorkOrderExt = + BeanUtil.copyProperties(flowWorkOrder, FlowWorkOrderExt.class); + flowWorkOrderExt.setId(idGenerator.nextLongId()); + flowWorkOrderExt.setDraftData(JSON.toJSONString(draftData)); + flowWorkOrderExtMapper.insert(flowWorkOrderExt); + flowWorkOrderMapper.insert(flowWorkOrder); + return flowWorkOrder; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void updateDraft(Long workOrderId, String masterData, String slaveData) { + JSONObject draftData = new JSONObject(); + if (masterData != null) { + draftData.put(FlowConstant.MASTER_DATA_KEY, masterData); + } + if (slaveData != null) { + draftData.put(FlowConstant.SLAVE_DATA_KEY, slaveData); + } + FlowWorkOrderExt flowWorkOrderExt = new FlowWorkOrderExt(); + flowWorkOrderExt.setDraftData(JSON.toJSONString(draftData)); + flowWorkOrderExt.setUpdateTime(new Date()); + flowWorkOrderExtMapper.update(flowWorkOrderExt, + new LambdaQueryWrapper().eq(FlowWorkOrderExt::getWorkOrderId, workOrderId)); + } + + /** + * 删除指定数据。 + * + * @param workOrderId 主键Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long workOrderId) { + return flowWorkOrderMapper.deleteById(workOrderId) == 1; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void removeByProcessInstanceId(String processInstanceId) { + FlowWorkOrder filter = new FlowWorkOrder(); + filter.setProcessInstanceId(processInstanceId); + super.removeBy(filter); + } + + @Override + public List getFlowWorkOrderList(FlowWorkOrder filter, String orderBy) { + if (filter == null) { + filter = new FlowWorkOrder(); + } + TokenData tokenData = TokenData.takeFromRequest(); + filter.setTenantId(tokenData.getTenantId()); + filter.setAppCode(tokenData.getAppCode()); + return flowWorkOrderMapper.getFlowWorkOrderList(filter, orderBy); + } + + @Override + public List getFlowWorkOrderListWithRelation(FlowWorkOrder filter, String orderBy) { + List resultList = this.getFlowWorkOrderList(filter, orderBy); + this.buildRelationForDataList(resultList, MyRelationParam.dictOnly()); + return resultList; + } + + @Override + public FlowWorkOrder getFlowWorkOrderByProcessInstanceId(String processInstanceId) { + FlowWorkOrder filter = new FlowWorkOrder(); + filter.setProcessInstanceId(processInstanceId); + return flowWorkOrderMapper.selectOne(new QueryWrapper<>(filter)); + } + + @Override + public boolean existByBusinessKey(String tableName, Object businessKey, boolean unfinished) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(FlowWorkOrder::getBusinessKey, businessKey.toString()); + queryWrapper.eq(FlowWorkOrder::getTableName, tableName); + if (unfinished) { + queryWrapper.notIn(FlowWorkOrder::getFlowStatus, + FlowTaskStatus.FINISHED, FlowTaskStatus.CANCELLED, FlowTaskStatus.STOPPED); + } + return flowWorkOrderMapper.selectCount(queryWrapper) > 0; + } + + @Override + public boolean existUnfinished(String processDefinitionKey, Object businessKey) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(FlowWorkOrder::getBusinessKey, businessKey.toString()); + queryWrapper.eq(FlowWorkOrder::getProcessDefinitionKey, processDefinitionKey); + queryWrapper.notIn(FlowWorkOrder::getFlowStatus, + FlowTaskStatus.FINISHED, FlowTaskStatus.CANCELLED, FlowTaskStatus.STOPPED); + return flowWorkOrderMapper.selectCount(queryWrapper) > 0; + } + + @DisableDataFilter + @Transactional(rollbackFor = Exception.class) + @Override + public void updateFlowStatusByProcessInstanceId(String processInstanceId, Integer flowStatus) { + if (flowStatus == null) { + return; + } + FlowWorkOrder flowWorkOrder = new FlowWorkOrder(); + flowWorkOrder.setFlowStatus(flowStatus); + if (FlowTaskStatus.FINISHED != flowStatus) { + flowWorkOrder.setUpdateTime(new Date()); + flowWorkOrder.setUpdateUserId(TokenData.takeFromRequest().getUserId()); + } + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(FlowWorkOrder::getProcessInstanceId, processInstanceId); + flowWorkOrderMapper.update(flowWorkOrder, queryWrapper); + } + + @DisableDataFilter + @Transactional(rollbackFor = Exception.class) + @Override + public void updateLatestApprovalStatusByProcessInstanceId(String processInstanceId, Integer approvalStatus) { + if (approvalStatus == null) { + return; + } + FlowWorkOrder flowWorkOrder = this.getFlowWorkOrderByProcessInstanceId(processInstanceId); + flowWorkOrder.setLatestApprovalStatus(approvalStatus); + flowWorkOrder.setUpdateTime(new Date()); + flowWorkOrder.setUpdateUserId(TokenData.takeFromRequest().getUserId()); + flowWorkOrderMapper.updateById(flowWorkOrder); + flowCustomExtFactory.getOnlineBusinessDataExtHelper().updateFlowStatus(flowWorkOrder); + // 处理在线表单工作流的自定义状态更新。 + flowCustomExtFactory.getOnlineBusinessDataExtHelper().updateFlowStatus(flowWorkOrder); + } + + @Override + public boolean hasDataPermOnFlowWorkOrder(String processInstanceId) { + // 开启数据权限,并进行验证。 + boolean originalFlag = GlobalThreadLocal.setDataFilter(true); + long count; + try { + FlowWorkOrder filter = new FlowWorkOrder(); + filter.setProcessInstanceId(processInstanceId); + count = flowWorkOrderMapper.selectCount(new QueryWrapper<>(filter)); + } finally { + // 恢复之前的数据权限标记 + GlobalThreadLocal.setDataFilter(originalFlag); + } + return count > 0; + } + + @Override + public void fillUserShowNameByLoginName(List dataList) { + BaseFlowIdentityExtHelper identityExtHelper = flowCustomExtFactory.getFlowIdentityExtHelper(); + Set loginNameSet = dataList.stream() + .map(FlowWorkOrderVo::getSubmitUsername).collect(Collectors.toSet()); + if (CollUtil.isEmpty(loginNameSet)) { + return; + } + Map userNameMap = identityExtHelper.mapUserShowNameByLoginName(loginNameSet); + dataList.forEach(workOrder -> { + if (StrUtil.isNotBlank(workOrder.getSubmitUsername())) { + workOrder.setUserShowName(userNameMap.get(workOrder.getSubmitUsername())); + } + }); + } + + @Override + public FlowWorkOrderExt getFlowWorkOrderExtByWorkOrderId(Long workOrderId) { + return flowWorkOrderExtMapper.selectOne( + new LambdaQueryWrapper().eq(FlowWorkOrderExt::getWorkOrderId, workOrderId)); + } + + @Override + public List getFlowWorkOrderExtByWorkOrderIds(Set workOrderIds) { + return flowWorkOrderExtMapper.selectList( + new LambdaQueryWrapper().in(FlowWorkOrderExt::getWorkOrderId, workOrderIds)); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public CallResult removeDraft(FlowWorkOrder flowWorkOrder) { + CallResult r = flowApiService.stopProcessInstance(flowWorkOrder.getProcessInstanceId(), "撤销草稿", true); + if (!r.isSuccess()) { + return r; + } + flowWorkOrderMapper.deleteById(flowWorkOrder.getWorkOrderId()); + return CallResult.ok(); + } + + @Override + public MyPageData getPagedWorkOrderListAndBuildData( + FlowWorkOrderDto flowWorkOrderDtoFilter, MyPageParam pageParam, MyOrderParam orderParam, String processDefinitionKey) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount()); + String orderBy = MyOrderParam.buildOrderBy(orderParam, FlowWorkOrder.class); + FlowWorkOrder filter = flowOperationHelper.makeWorkOrderFilter(flowWorkOrderDtoFilter, processDefinitionKey); + List flowWorkOrderList = this.getFlowWorkOrderList(filter, orderBy); + MyPageData resultData = + MyPageUtil.makeResponseData(flowWorkOrderList, FlowWorkOrderVo.class); + if (CollUtil.isEmpty(resultData.getDataList())) { + return resultData; + } + flowOperationHelper.buildWorkOrderApprovalStatus(processDefinitionKey, resultData.getDataList()); + // 根据工单的提交用户名获取用户的显示名称,便于前端显示。 + // 同时这也是一个如何通过插件方法,将loginName映射到showName的示例, + this.fillUserShowNameByLoginName(resultData.getDataList()); + // 组装工单中需要返回给前端的流程任务数据。 + flowOperationHelper.buildWorkOrderTaskInfo(resultData.getDataList()); + return resultData; + } + + private FlowWorkOrder createWith(ProcessInstance instance) { + TokenData tokenData = TokenData.takeFromRequest(); + Date now = new Date(); + FlowWorkOrder flowWorkOrder = new FlowWorkOrder(); + flowWorkOrder.setWorkOrderId(idGenerator.nextLongId()); + flowWorkOrder.setProcessDefinitionKey(instance.getProcessDefinitionKey()); + flowWorkOrder.setProcessDefinitionName(instance.getProcessDefinitionName()); + flowWorkOrder.setProcessDefinitionId(instance.getProcessDefinitionId()); + flowWorkOrder.setProcessInstanceId(instance.getId()); + flowWorkOrder.setSubmitUsername(tokenData.getLoginName()); + flowWorkOrder.setDeptId(tokenData.getDeptId()); + flowWorkOrder.setAppCode(tokenData.getAppCode()); + flowWorkOrder.setTenantId(tokenData.getTenantId()); + flowWorkOrder.setCreateUserId(tokenData.getUserId()); + flowWorkOrder.setUpdateUserId(tokenData.getUserId()); + flowWorkOrder.setCreateTime(now); + flowWorkOrder.setUpdateTime(now); + flowWorkOrder.setDeletedFlag(GlobalDeletedFlag.NORMAL); + return flowWorkOrder; + } + + private String generateWorkOrderCode(String processDefinitionKey) { + FlowEntry flowEntry = flowEntryService.getFlowEntryFromCache(processDefinitionKey); + if (StrUtil.isBlank(flowEntry.getEncodedRule())) { + return null; + } + ColumnEncodedRule rule = JSON.parseObject(flowEntry.getEncodedRule(), ColumnEncodedRule.class); + if (rule.getIdWidth() == null) { + rule.setIdWidth(10); + } + return commonRedisUtil.generateTransId( + rule.getPrefix(), rule.getPrecisionTo(), rule.getMiddle(), rule.getIdWidth()); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/BaseFlowIdentityExtHelper.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/BaseFlowIdentityExtHelper.java new file mode 100644 index 00000000..30715c8c --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/BaseFlowIdentityExtHelper.java @@ -0,0 +1,253 @@ +package com.orangeforms.common.flow.util; + +import com.orangeforms.common.flow.listener.DeptPostLeaderListener; +import com.orangeforms.common.flow.listener.UpDeptPostLeaderListener; +import com.orangeforms.common.flow.vo.FlowUserInfoVo; +import org.flowable.engine.delegate.TaskListener; + +import java.util.*; + +/** + * 工作流与用户身份相关的自定义扩展接口,需要业务模块自行实现该接口。也可以根据实际需求扩展该接口的方法。 + * 目前支持的主键类型为字符型和长整型,所以这里提供了两套实现接口。可根据实际情况实现其中一套即可。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface BaseFlowIdentityExtHelper { + + /** + * 根据(字符型)部门Id,获取当前用户部门领导所有的部门岗位Id。 + * + * @param deptId 用户所在部门Id。 + * @return 当前用户部门领导所有的部门岗位Id。 + */ + default String getLeaderDeptPostId(String deptId) { + return null; + } + + /** + * 根据(字符型)部门Id,获取当前用户上级部门领导所有的部门岗位Id。 + * + * @param deptId 用户所在部门Id。 + * @return 当前用户上级部门领导所有的部门岗位Id。 + */ + default String getUpLeaderDeptPostId(String deptId) { + return null; + } + + /** + * 获取(字符型)指定部门上级部门的指定岗位集合的DeptPostId集合。 + * + * @param deptId 指定的部门Id。 + * @param postIdSet 指定的岗位Id集合。 + * @return 与该部门Id上级部门关联的岗位Id集合,key对应参数中的postId,value是与key对应的deptPostId。 + */ + default Map getUpDeptPostIdMap(String deptId, Set postIdSet) { + return null; + } + + /** + * 获取(字符型)指定部门的指定岗位集合的DeptPostId集合。 + * + * @param deptId 指定的部门Id。 + * @param postIdSet 指定的岗位Id集合。 + * @return 与部门关联的岗位Id集合,key对应参数中的postId,value是与key对应的deptPostId。 + */ + default Map getDeptPostIdMap(String deptId, Set postIdSet) { + return null; + } + + /** + * 获取(字符型)指定同级部门的指定岗位集合的DeptPostId集合。 + * + * @param deptId 指定的同级部门Id。 + * @param postIdSet 指定的岗位Id集合。 + * @return 与同级部门关联的岗位Id集合,key对应参数中的postId,value是与key对应的deptPostId。 + */ + default Map getSiblingDeptPostIdMap(String deptId, Set postIdSet) { + return null; + } + + /** + * 根据(长整型)部门Id,获取当前用户部门领导所有的部门岗位Id。 + * + * @param deptId 用户所在部门Id。 + * @return 当前用户部门领导所有的部门岗位Id。 + */ + default Long getLeaderDeptPostId(Long deptId) { + return null; + } + + /** + * 根据(长整型)部门Id,获取当前用户上级部门领导所有的部门岗位Id。 + * + * @param deptId 用户所在部门Id。 + * @return 当前用户上级部门领导所有的部门岗位Id。 + */ + default Long getUpLeaderDeptPostId(Long deptId) { + return null; + } + + /** + * 获取(长整型)指定部门的指定岗位集合的DeptPostId集合。 + * + * @param deptId 指定的部门Id。 + * @param postIdSet 指定的岗位Id集合。 + * @return 与部门关联的岗位Id集合,key对应参数中的postId,value是与key对应的deptPostId。 + */ + default Map getDeptPostIdMap(Long deptId, Set postIdSet) { + return null; + } + + /** + * 获取(长整型)指定同级部门的指定岗位集合的DeptPostId集合。 + * + * @param deptId 指定的同级部门Id。 + * @param postIdSet 指定的岗位Id集合。 + * @return 与同级部门关联的岗位Id集合,key对应参数中的postId,value是与key对应的deptPostId。 + */ + default Map getSiblingDeptPostIdMap(Long deptId, Set postIdSet) { + return null; + } + + /** + * 获取(长整型)指定部门上级部门的指定岗位集合的DeptPostId集合。 + * + * @param deptId 指定的部门Id。 + * @param postIdSet 指定的岗位Id集合。 + * @return 与该部门Id上级部门关联的岗位Id集合,key对应参数中的postId,value是与key对应的deptPostId。 + */ + default Map getUpDeptPostIdMap(Long deptId, Set postIdSet) { + return null; + } + + /** + * 根据角色Id集合,查询所属的用户名列表。 + * + * @param roleIdSet 角色Id集合。 + * @return 所属的用户列表。 + */ + default Set getUsernameListByRoleIds(Set roleIdSet) { + return Collections.emptySet(); + } + + /** + * 根据角色Id集合,查询所属的用户对象信息列表。返回的具体数据,用户可自定义。 + * + * @param roleIdSet 角色Id集合。 + * @return 所属的用户对象信息列表。 + */ + default List getUserInfoListByRoleIds(Set roleIdSet) { + return Collections.emptyList(); + } + + /** + * 根据部门Id集合,查询所属的用户名列表。 + * + * @param deptIdSet 部门Id集合。 + * @return 所属的用户列表。 + */ + default Set getUsernameListByDeptIds(Set deptIdSet) { + return Collections.emptySet(); + } + + /** + * 根据部门Id集合,查询所属的用户对象信息列表。返回的具体数据,用户可自定义。 + * + * @param deptIdSet 部门Id集合。 + * @return 所属的用户对象信息列表。 + */ + default List getUserInfoListByDeptIds(Set deptIdSet) { + return Collections.emptyList(); + } + + /** + * 根据岗位Id集合,查询所属的用户名列表。 + * + * @param postIdSet 岗位Id集合。 + * @return 所属的用户列表。 + */ + default Set getUsernameListByPostIds(Set postIdSet) { + return Collections.emptySet(); + } + + /** + * 根据岗位Id集合,查询所属的用户对象信息列表。返回的具体数据,用户可自定义。 + * + * @param postIdSet 岗位Id集合。 + * @return 所属的用户对象信息列表。 + */ + default List getUserInfoListByPostIds(Set postIdSet) { + return Collections.emptyList(); + } + + /** + * 根据部门岗位Id集合,查询所属的用户名列表。 + * + * @param deptPostIdSet 部门岗位Id集合。 + * @return 所属的用户列表。 + */ + default Set getUsernameListByDeptPostIds(Set deptPostIdSet) { + return Collections.emptySet(); + } + + /** + * 根据部门岗位Id集合,查询所属的用户对象信息列表。返回的具体数据,用户可自定义。 + * + * @param deptPostIdSet 部门岗位Id集合。 + * @return 所属的用户对象信息列表。 + */ + default List getUserInfoListByDeptPostIds(Set deptPostIdSet) { + return Collections.emptyList(); + } + + /** + * 根据用户登录名集合,查询所属的用户对象信息列表。返回的具体数据,用户可自定义。 + * + * @param usernameSet 用户登录名集合。 + * @return 用户对象信息列表。 + */ + default List getUserInfoListByUsernameSet(Set usernameSet) { + return Collections.emptyList(); + } + + /** + * 当前服务是否支持数据权限。 + * + * @return true表示支持,否则false。 + */ + default Boolean supprtDataPerm() { + return false; + } + + /** + * 映射用户的登录名到用户的显示名。 + * + * @param loginNameSet 用户登录名集合。 + * @return 用户登录名和显示名的Map,key为登录名,value是显示名。 + */ + default Map mapUserShowNameByLoginName(Set loginNameSet) { + return new HashMap<>(1); + } + + /** + * 获取任务执行人是当前部门领导岗位的任务监听器。 + * 通常会在没有找到领导部门岗位Id的时候,为当前任务指定其他的指派人、候选人或候选组。 + * + * @return 任务监听器。 + */ + default Class getDeptPostLeaderListener() { + return DeptPostLeaderListener.class; + } + + /** + * 获取任务执行人是上级部门领导岗位的任务监听器。 + * 通常会在没有找到领导部门岗位Id的时候,为当前任务指定其他的指派人、候选人或候选组。 + * + * @return 任务监听器。 + */ + default Class getUpDeptPostLeaderListener() { + return UpDeptPostLeaderListener.class; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/BaseFlowNotifyExtHelper.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/BaseFlowNotifyExtHelper.java new file mode 100644 index 00000000..d90cd432 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/BaseFlowNotifyExtHelper.java @@ -0,0 +1,28 @@ +package com.orangeforms.common.flow.util; + +import com.orangeforms.common.flow.vo.FlowTaskVo; +import com.orangeforms.common.flow.vo.FlowUserInfoVo; +import lombok.extern.slf4j.Slf4j; + +import java.util.List; + +/** + * 流程通知扩展帮助实现类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class BaseFlowNotifyExtHelper { + + /** + * 处理消息。 + * + * @param notifyType 通知类型,具体值可参考FlowUserTaskExtData中NOTIFY_TYPE开头的常量。 + * @param userInfoList 待通知的用户信息列表。 + */ + public void doNotify(String notifyType, List userInfoList, FlowTaskVo taskInfo) { + userInfoList.forEach(u -> log.info( + "The user [{}] of Task [{}] is notified by [{}].", u.getLoginName(), taskInfo.getTaskKey(), notifyType)); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/BaseOnlineBusinessDataExtHelper.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/BaseOnlineBusinessDataExtHelper.java new file mode 100644 index 00000000..76b0e2cb --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/BaseOnlineBusinessDataExtHelper.java @@ -0,0 +1,51 @@ +package com.orangeforms.common.flow.util; + +import cn.hutool.core.lang.Assert; +import com.orangeforms.common.flow.base.service.BaseFlowOnlineService; +import com.orangeforms.common.flow.model.FlowWorkOrder; +import lombok.extern.slf4j.Slf4j; + +/** + * 面向在线表单工作流的业务数据扩展帮助实现类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class BaseOnlineBusinessDataExtHelper { + + private BaseFlowOnlineService onlineBusinessService; + + /** + * 设置在线表单的业务处理服务。 + * + * @param onlineBusinessService 在线表单业务处理服务实现类。 + */ + public void setOnlineBusinessService(BaseFlowOnlineService onlineBusinessService) { + this.onlineBusinessService = onlineBusinessService; + } + + /** + * 更新在线表单主表数据的流程状态字段值。 + * + * @param workOrder 工单对象。 + */ + public void updateFlowStatus(FlowWorkOrder workOrder) { + Assert.notNull(workOrder.getOnlineTableId()); + if (this.onlineBusinessService != null && workOrder.getBusinessKey() != null) { + onlineBusinessService.updateFlowStatus(workOrder); + } + } + + /** + * 根据工单对象级联删除业务数据。 + * + * @param workOrder 工单对象。 + */ + public void deleteBusinessData(FlowWorkOrder workOrder) { + Assert.notNull(workOrder.getOnlineTableId()); + if (this.onlineBusinessService != null && workOrder.getBusinessKey() != null) { + onlineBusinessService.deleteBusinessData(workOrder); + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/CustomChangeActivityStateBuilderImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/CustomChangeActivityStateBuilderImpl.java new file mode 100644 index 00000000..aa05956c --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/CustomChangeActivityStateBuilderImpl.java @@ -0,0 +1,29 @@ +package com.orangeforms.common.flow.util; + +import org.flowable.engine.impl.RuntimeServiceImpl; +import org.flowable.engine.impl.runtime.ChangeActivityStateBuilderImpl; +import org.flowable.engine.runtime.ChangeActivityStateBuilder; + +import java.util.List; + +/** + * 自定义修改活动状态构建器实现。主要用于支持多个源节点向多个目标节点跳转的功能。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class CustomChangeActivityStateBuilderImpl extends ChangeActivityStateBuilderImpl { + + public CustomChangeActivityStateBuilderImpl() { + super(); + } + + public CustomChangeActivityStateBuilderImpl(RuntimeServiceImpl runtimeService) { + super(runtimeService); + } + + public ChangeActivityStateBuilder moveActivityIdsToActivityIds(List activityIds, List moveToActivityIds) { + moveActivityIdList.add(new CustomMoveActivityIdContainer(activityIds, moveToActivityIds)); + return this; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/CustomMoveActivityIdContainer.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/CustomMoveActivityIdContainer.java new file mode 100644 index 00000000..66fa2e7e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/CustomMoveActivityIdContainer.java @@ -0,0 +1,24 @@ +package com.orangeforms.common.flow.util; + +import org.flowable.engine.impl.runtime.MoveActivityIdContainer; + +import java.util.List; + +/** + * 自定义移动任务Id的容器类。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class CustomMoveActivityIdContainer extends MoveActivityIdContainer { + + public CustomMoveActivityIdContainer(String singleActivityId, String moveToActivityId) { + super(singleActivityId, moveToActivityId); + } + + public CustomMoveActivityIdContainer(List activityIds, List moveToActivityIds) { + super(activityIds.get(0), moveToActivityIds.get(0)); + this.activityIds = activityIds; + this.moveToActivityIds = moveToActivityIds; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/FlowCustomExtFactory.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/FlowCustomExtFactory.java new file mode 100644 index 00000000..422e016a --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/FlowCustomExtFactory.java @@ -0,0 +1,67 @@ +package com.orangeforms.common.flow.util; + +import org.springframework.stereotype.Component; + +/** + * 工作流自定义扩展工厂类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class FlowCustomExtFactory { + + private BaseFlowIdentityExtHelper flowIdentityExtHelper; + + private BaseOnlineBusinessDataExtHelper onlineBusinessDataExtHelper = new BaseOnlineBusinessDataExtHelper(); + + private BaseFlowNotifyExtHelper flowNotifyExtHelper; + + /** + * 获取业务模块自行实现的用户身份相关的扩展帮助实现类。 + * + * @return 业务模块自行实现的用户身份相关的扩展帮助实现类。 + */ + public BaseFlowIdentityExtHelper getFlowIdentityExtHelper() { + return flowIdentityExtHelper; + } + + /** + * 注册业务模块自行实现的用户身份扩展帮助实现类。 + * + * @param helper 业务模块自行实现的用户身份扩展帮助实现类。 + */ + public void registerFlowIdentityExtHelper(BaseFlowIdentityExtHelper helper) { + this.flowIdentityExtHelper = helper; + } + + /** + * 获取有关在线表单业务数据的扩展帮助实现类。 + * + * @return 有关业务数据的扩展帮助实现类。 + */ + public BaseOnlineBusinessDataExtHelper getOnlineBusinessDataExtHelper() { + return onlineBusinessDataExtHelper; + } + + /** + * 注册流程通知扩展帮助实现类。 + * + * @param helper 流程通知扩展帮助实现类。 + */ + public void registerNotifyExtHelper(BaseFlowNotifyExtHelper helper) { + this.flowNotifyExtHelper = helper; + } + + /** + * 获取流程通知扩展帮助实现类。 + * + * @return 流程消息通知扩展帮助实现类。 + */ + public BaseFlowNotifyExtHelper getFlowNotifyExtHelper() { + if (this.flowNotifyExtHelper == null) { + this.flowNotifyExtHelper = new BaseFlowNotifyExtHelper(); + } + return flowNotifyExtHelper; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/FlowOperationHelper.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/FlowOperationHelper.java new file mode 100644 index 00000000..3b3ebc8e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/FlowOperationHelper.java @@ -0,0 +1,505 @@ +package com.orangeforms.common.flow.util; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.object.ResponseResult; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.flow.constant.FlowApprovalType; +import com.orangeforms.common.flow.constant.FlowConstant; +import com.orangeforms.common.flow.constant.FlowTaskStatus; +import com.orangeforms.common.flow.dto.FlowTaskCommentDto; +import com.orangeforms.common.flow.dto.FlowWorkOrderDto; +import com.orangeforms.common.flow.model.FlowEntry; +import com.orangeforms.common.flow.model.FlowEntryPublish; +import com.orangeforms.common.flow.model.FlowWorkOrder; +import com.orangeforms.common.flow.model.constant.FlowEntryStatus; +import com.orangeforms.common.flow.object.FlowEntryExtensionData; +import com.orangeforms.common.flow.object.FlowRumtimeObject; +import com.orangeforms.common.flow.service.FlowApiService; +import com.orangeforms.common.flow.service.FlowEntryService; +import com.orangeforms.common.flow.service.FlowWorkOrderService; +import com.orangeforms.common.flow.vo.FlowWorkOrderVo; +import com.orangeforms.common.flow.vo.TaskInfoVo; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.history.HistoricProcessInstance; +import org.flowable.engine.runtime.ProcessInstance; +import org.flowable.task.api.Task; +import org.flowable.task.api.TaskInfo; +import org.flowable.task.api.history.HistoricTaskInstance; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 工作流操作的通用帮助对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Component +public class FlowOperationHelper { + + @Autowired + private FlowEntryService flowEntryService; + @Autowired + private FlowApiService flowApiService; + @Autowired + private FlowWorkOrderService flowWorkOrderService; + @Autowired + private FlowCustomExtFactory flowCustomExtFactory; + + /** + * 验证并获取流程对象。 + * + * @param processDefinitionKey 流程引擎的流程定义标识。 + * @return 流程对象。 + */ + public ResponseResult verifyAndGetFlowEntry(String processDefinitionKey) { + String errorMessage; + FlowEntry flowEntry = flowEntryService.getFlowEntryFromCache(processDefinitionKey); + if (flowEntry == null) { + errorMessage = "数据验证失败,该流程并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!flowEntry.getStatus().equals(FlowEntryStatus.PUBLISHED)) { + errorMessage = "数据验证失败,该流程尚未发布,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + FlowEntryPublish flowEntryPublish = + flowEntryService.getFlowEntryPublishFromCache(flowEntry.getMainEntryPublishId()); + flowEntry.setMainFlowEntryPublish(flowEntryPublish); + return ResponseResult.success(flowEntry); + } + + /** + * 验证并获取流程发布对象。 + * + * @param processDefinitionKey 流程引擎的流程定义标识。 + * @return 流程对象。 + */ + public ResponseResult verifyAndGetFlowEntryPublish(String processDefinitionKey) { + // 1. 验证流程数据的合法性。 + ResponseResult flowEntryResult = this.verifyAndGetFlowEntry(processDefinitionKey); + if (!flowEntryResult.isSuccess()) { + return ResponseResult.errorFrom(flowEntryResult); + } + // 2. 验证流程一个用户任务的合法性。 + FlowEntryPublish flowEntryPublish = flowEntryResult.getData().getMainFlowEntryPublish(); + ResponseResult taskInfoResult = this.verifyAndGetInitialTaskInfo(flowEntryPublish, false); + if (!taskInfoResult.isSuccess()) { + return ResponseResult.errorFrom(taskInfoResult); + } + return ResponseResult.success(flowEntryPublish); + } + + /** + * 工作流静态表单的参数验证工具方法。根据流程定义标识,获取关联的流程并对其进行合法性验证。 + * + * @param processDefinitionKey 流程定义标识。 + * @return 返回流程对象。 + */ + public ResponseResult verifyFullAndGetFlowEntry(String processDefinitionKey) { + String errorMessage; + // 验证流程管理数据状态的合法性。 + ResponseResult flowEntryResult = this.verifyAndGetFlowEntry(processDefinitionKey); + if (!flowEntryResult.isSuccess()) { + return ResponseResult.errorFrom(flowEntryResult); + } + // 验证流程一个用户任务的合法性。 + FlowEntryPublish flowEntryPublish = flowEntryResult.getData().getMainFlowEntryPublish(); + if (BooleanUtil.isFalse(flowEntryPublish.getActiveStatus())) { + errorMessage = "数据验证失败,当前流程发布对象已被挂起,不能启动新流程!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + ResponseResult taskInfoResult = + this.verifyAndGetInitialTaskInfo(flowEntryPublish, true); + if (!taskInfoResult.isSuccess()) { + return ResponseResult.errorFrom(taskInfoResult); + } + return flowEntryResult; + } + + /** + * 工作流静态表单的参数验证工具方法。根据参数验证并获取指定的流程任务对象。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 流程任务Id。 + * @param flowTaskComment 流程审批对象。 + * @return 验证后的流程任务对象。 + */ + public ResponseResult verifySubmitAndGetTask( + String processInstanceId, String taskId, FlowTaskCommentDto flowTaskComment) { + // 验证流程任务的合法性。 + Task task = flowApiService.getProcessInstanceActiveTask(processInstanceId, taskId); + ResponseResult taskInfoResult = this.verifyAndGetRuntimeTaskInfo(task); + if (!taskInfoResult.isSuccess()) { + return ResponseResult.errorFrom(taskInfoResult); + } + CallResult assigneeVerifyResult = flowApiService.verifyAssigneeOrCandidateAndClaim(task); + if (!assigneeVerifyResult.isSuccess()) { + return ResponseResult.errorFrom(assigneeVerifyResult); + } + ProcessInstance instance = flowApiService.getProcessInstance(processInstanceId); + if (StrUtil.isBlank(instance.getBusinessKey())) { + return ResponseResult.success(task); + } + String errorMessage; + if (flowTaskComment != null + && StrUtil.equals(flowTaskComment.getApprovalType(), FlowApprovalType.TRANSFER) + && StrUtil.isBlank(flowTaskComment.getDelegateAssignee())) { + errorMessage = "数据验证失败,加签或转办任务指派人不能为空!!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(task); + } + + /** + * 工作流静态表单的参数验证工具方法。根据参数验证并获取指定的流程任务和流程实例。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 流程任务Id。 + * @param flowTaskComment 流程审批对象。 + * @param processDefinitionKey 流程定义标识。 + * @return 验证后的流程运行时常用对象。 + */ + public ResponseResult verifySubmitWithGetInstanceAndTask( + String processInstanceId, String taskId, FlowTaskCommentDto flowTaskComment, String processDefinitionKey) { + ResponseResult taskResult = this.verifySubmitAndGetTask(processInstanceId, taskId, flowTaskComment); + if (!taskResult.isSuccess()) { + return ResponseResult.errorFrom(taskResult); + } + ProcessInstance instance = flowApiService.getProcessInstance(processInstanceId); + if (!StrUtil.equals(instance.getProcessDefinitionKey(), processDefinitionKey)) { + String errorMessage = "数据验证失败,请求流程标识与流程实例不匹配,请核对!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + FlowRumtimeObject o = new FlowRumtimeObject(); + o.setTask(taskResult.getData()); + o.setInstance(instance); + return ResponseResult.success(o); + } + + /** + * 工作流静态表单的参数验证工具方法。根据参数验证并获取指定的历史流程实例对象。 + * 仅当登录用户为任务的分配人时,才能通过验证。 + * + * @param processInstanceId 历史流程实例Id。 + * @param taskId 历史流程任务Id。 + * @return 验证后并返回的历史流程实例对象。 + */ + public ResponseResult verifyAndGetHistoricProcessInstance(String processInstanceId, String taskId) { + String errorMessage; + // 验证流程实例的合法性。 + HistoricProcessInstance instance = flowApiService.getHistoricProcessInstance(processInstanceId); + if (instance == null) { + errorMessage = "数据验证失败,指定的流程实例Id并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + String loginName = TokenData.takeFromRequest().getLoginName(); + if (StrUtil.isBlank(taskId)) { + if (!StrUtil.equals(loginName, instance.getStartUserId()) + && !flowWorkOrderService.hasDataPermOnFlowWorkOrder(processInstanceId)) { + errorMessage = "数据验证失败,指定历史流程的发起人与当前用户不匹配,或者没有查看该工单详情的数据权限!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } else { + HistoricTaskInstance taskInstance = flowApiService.getHistoricTaskInstance(processInstanceId, taskId); + if (taskInstance == null) { + errorMessage = "数据验证失败,指定的任务Id并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!StrUtil.equals(loginName, taskInstance.getAssignee()) + && !flowWorkOrderService.hasDataPermOnFlowWorkOrder(processInstanceId)) { + errorMessage = "数据验证失败,历史任务的指派人与当前用户不匹配,或者没有查看该工单详情的数据权限!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + return ResponseResult.success(instance); + } + + /** + * 工作流静态表单的参数验证工具方法。根据参数验证并获取指定的历史流程实例对象。 + * 仅当登录用户为任务的分配人时,才能通过验证。 + * + * @param processInstanceId 历史流程实例Id。 + * @param taskId 历史流程任务Id。 + * @param processDefinitionKey 流程定义标识。 + * @return 验证后并返回的历史流程实例对象。 + */ + public ResponseResult verifyAndGetHistoricProcessInstance( + String processInstanceId, String taskId, String processDefinitionKey) { + ResponseResult instanceResult = + this.verifyAndGetHistoricProcessInstance(processInstanceId, taskId); + if (!instanceResult.isSuccess()) { + return ResponseResult.errorFrom(instanceResult); + } + HistoricProcessInstance instance = instanceResult.getData(); + if (!StrUtil.equals(instance.getProcessDefinitionKey(), processDefinitionKey)) { + String errorMessage = "数据验证失败,请求流程标识与流程实例不匹配,请核对!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(instance); + } + + /** + * 验证并获取流程的实时任务信息。 + * + * @param task 流程引擎的任务对象。 + * @return 任务信息对象。 + */ + public ResponseResult verifyAndGetRuntimeTaskInfo(Task task) { + String errorMessage; + if (task == null) { + errorMessage = "数据验证失败,指定的任务Id不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!flowApiService.isAssigneeOrCandidate(task)) { + errorMessage = "数据验证失败,当前用户不是指派人也不是候选人之一!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (StrUtil.isBlank(task.getFormKey())) { + errorMessage = "数据验证失败,指定任务的formKey属性不存在,请重新修改流程图!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + TaskInfoVo taskInfo = JSON.parseObject(task.getFormKey(), TaskInfoVo.class); + taskInfo.setTaskKey(task.getTaskDefinitionKey()); + return ResponseResult.success(taskInfo); + } + + /** + * 验证并获取启动任务的对象信息。 + * + * @param flowEntryPublish 流程发布对象。 + * @param checkStarter 是否检查发起用户。 + * @return 第一个可执行的任务信息。 + */ + public ResponseResult verifyAndGetInitialTaskInfo( + FlowEntryPublish flowEntryPublish, boolean checkStarter) { + String errorMessage; + if (StrUtil.isBlank(flowEntryPublish.getInitTaskInfo())) { + errorMessage = "数据验证失败,当前流程发布的数据中,没有包含初始任务信息!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + TaskInfoVo taskInfo = JSON.parseObject(flowEntryPublish.getInitTaskInfo(), TaskInfoVo.class); + if (checkStarter) { + String loginName = TokenData.takeFromRequest().getLoginName(); + if (!StrUtil.equalsAny(taskInfo.getAssignee(), loginName, FlowConstant.START_USER_NAME_VAR)) { + errorMessage = "数据验证失败,该工作流第一个用户任务的指派人并非当前用户,不能执行该操作!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + return ResponseResult.success(taskInfo); + } + + /** + * 判断当前用户是否有当前流程实例的数据上传或下载权限。 + * 如果taskId为空,则验证当前用户是否为当前流程实例的发起人,否则判断是否为当前任务的指派人或候选人。 + * + * @param processInstanceId 流程实例Id。 + * @param taskId 流程任务Id。 + * @return 验证结果。 + */ + public ResponseResult verifyUploadOrDownloadPermission(String processInstanceId, String taskId) { + if (flowApiService.isProcessInstanceStarter(processInstanceId)) { + return ResponseResult.success(); + } + String errorMessage; + if (StrUtil.isBlank(taskId)) { + errorMessage = "数据验证失败,当前用户没有权限下载!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + TaskInfo task = flowApiService.getProcessInstanceActiveTask(processInstanceId, taskId); + if (task == null) { + task = flowApiService.getHistoricTaskInstance(processInstanceId, taskId); + if (task == null) { + errorMessage = "数据验证失败,指定任务Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + } + if (!flowApiService.isAssigneeOrCandidate(task)) { + errorMessage = "数据验证失败,当前用户并非指派人或候选人,因此没有权限下载!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 根据已有的过滤对象,补充添加缺省过滤条件。如流程标识、创建用户等。 + * + * @param filterDto 工单过滤对象。 + * @param processDefinitionKey 流程标识。 + * @return 创建并转换后的流程工单过滤对象。 + */ + public FlowWorkOrder makeWorkOrderFilter(FlowWorkOrderDto filterDto, String processDefinitionKey) { + FlowWorkOrder filter = MyModelUtil.copyTo(filterDto, FlowWorkOrder.class); + if (filter == null) { + filter = new FlowWorkOrder(); + } + filter.setProcessDefinitionKey(processDefinitionKey); + // 下面的方法会帮助构建工单的数据权限过滤条件,和业务希望相比,如果当前系统没有支持数据权限, + // 用户则只能看到自己发起的工单,否则按照数据权限过滤。然而需要特殊处理的是,如果用户的数据 + // 权限中,没有包含能看自己,这里也需要自动给加上。 + BaseFlowIdentityExtHelper flowIdentityExtHelper = flowCustomExtFactory.getFlowIdentityExtHelper(); + if (BooleanUtil.isFalse(flowIdentityExtHelper.supprtDataPerm())) { + filter.setCreateUserId(TokenData.takeFromRequest().getUserId()); + } + return filter; + } + + /** + * 组装工作流工单列表中的流程任务数据。 + * + * @param flowWorkOrderVoList 工作流工单列表。 + */ + public void buildWorkOrderTaskInfo(List flowWorkOrderVoList) { + if (CollUtil.isEmpty(flowWorkOrderVoList)) { + return; + } + Set definitionIdSet = + flowWorkOrderVoList.stream().map(FlowWorkOrderVo::getProcessDefinitionId).collect(Collectors.toSet()); + List flowEntryPublishList = flowEntryService.getFlowEntryPublishList(definitionIdSet); + Map flowEntryPublishMap = + flowEntryPublishList.stream().collect(Collectors.toMap(FlowEntryPublish::getProcessDefinitionId, c -> c)); + for (FlowWorkOrderVo flowWorkOrderVo : flowWorkOrderVoList) { + FlowEntryPublish flowEntryPublish = flowEntryPublishMap.get(flowWorkOrderVo.getProcessDefinitionId()); + flowWorkOrderVo.setInitTaskInfo(flowEntryPublish.getInitTaskInfo()); + } + List unfinishedProcessInstanceIds = flowWorkOrderVoList.stream() + .filter(c -> !c.getFlowStatus().equals(FlowTaskStatus.FINISHED)) + .map(FlowWorkOrderVo::getProcessInstanceId) + .collect(Collectors.toList()); + if (CollUtil.isEmpty(unfinishedProcessInstanceIds)) { + return; + } + List taskList = flowApiService.getTaskListByProcessInstanceIds(unfinishedProcessInstanceIds); + Map> taskMap = + taskList.stream().collect(Collectors.groupingBy(Task::getProcessInstanceId)); + for (FlowWorkOrderVo flowWorkOrderVo : flowWorkOrderVoList) { + List instanceTaskList = taskMap.get(flowWorkOrderVo.getProcessInstanceId()); + if (instanceTaskList == null) { + continue; + } + JSONArray taskArray = new JSONArray(); + for (Task task : instanceTaskList) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("taskId", task.getId()); + jsonObject.put("taskName", task.getName()); + jsonObject.put("taskKey", task.getTaskDefinitionKey()); + jsonObject.put("assignee", task.getAssignee()); + taskArray.add(jsonObject); + } + flowWorkOrderVo.setRuntimeTaskInfoList(taskArray); + } + } + + /** + * 组装工作流工单中的业务数据。 + * + * @param workOrderVoList 工单列表。 + * @param dataList 业务数据列表。 + * @param idGetter 获取业务对象主键字段的返回方法。 + * @param 业务主对象类型。 + * @param 业务主对象的主键字段类型。 + */ + public void buildWorkOrderBusinessData( + List workOrderVoList, List dataList, Function idGetter) { + if (CollUtil.isEmpty(dataList)) { + return; + } + Map dataMap = dataList.stream().collect(Collectors.toMap(idGetter, c -> c)); + K id = idGetter.apply(dataList.get(0)); + for (FlowWorkOrderVo flowWorkOrderVo : workOrderVoList) { + if (StrUtil.isBlank(flowWorkOrderVo.getBusinessKey())) { + continue; + } + Object dataId = flowWorkOrderVo.getBusinessKey(); + if (id instanceof Long) { + dataId = Long.valueOf(flowWorkOrderVo.getBusinessKey()); + } else if (id instanceof Integer) { + dataId = Integer.valueOf(flowWorkOrderVo.getBusinessKey()); + } + T data = dataMap.get(dataId); + if (data != null) { + flowWorkOrderVo.setMasterData(BeanUtil.beanToMap(data)); + } + } + } + + /** + * 验证并根据流程实例Id获取处于草稿状态的流程工单。 + * + * @param processDefinitionKey 流程定义标识。 + * @param processInstanceId 流程实例Id。 + * @return 流程工单。 + */ + public ResponseResult verifyAndGetFlowWorkOrderWithDraft( + String processDefinitionKey, String processInstanceId) { + String errorMessage; + FlowWorkOrder flowWorkOrder = flowWorkOrderService.getFlowWorkOrderByProcessInstanceId(processInstanceId); + if (flowWorkOrder == null) { + errorMessage = "数据验证失败,流程实例关联的工单不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!flowWorkOrder.getFlowStatus().equals(FlowTaskStatus.DRAFT)) { + errorMessage = "数据验证失败,当前流程工单并不处于草稿保存状态!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!flowWorkOrder.getCreateUserId().equals(TokenData.takeFromRequest().getUserId())) { + errorMessage = "数据验证失败,草稿数据保存用户与当前用户不一致!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (processDefinitionKey != null && !flowWorkOrder.getProcessDefinitionKey().equals(processDefinitionKey)) { + errorMessage = "数据验证失败,流程实例和流程定义标识不匹配!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(flowWorkOrder); + } + + /** + * 根据流程定义的扩展数据中的审批状态字典列表数据,组装工单列表中,每个工单对象的审批状态字典数据。 + * @param processDefinitionKey 流程定义标识。 + * @param workOrderVoList 待组装的工单列表。 + */ + public void buildWorkOrderApprovalStatus(String processDefinitionKey, List workOrderVoList) { + FlowEntry flowEntry = flowEntryService.getFlowEntryFromCache(processDefinitionKey); + if (StrUtil.isBlank(flowEntry.getExtensionData())) { + return; + } + FlowEntryExtensionData extensionData = + JSON.parseObject(flowEntry.getExtensionData(), FlowEntryExtensionData.class); + if (CollUtil.isEmpty(extensionData.getApprovalStatusDict())) { + return; + } + Map dictMap = new HashMap<>(extensionData.getApprovalStatusDict().size()); + for (Map m : extensionData.getApprovalStatusDict()) { + dictMap.put(Integer.valueOf(m.get("id")), m.get("name")); + } + for (FlowWorkOrderVo workOrderVo : workOrderVoList) { + if (workOrderVo.getLatestApprovalStatus() != null) { + String name = dictMap.get(workOrderVo.getLatestApprovalStatus()); + if (name != null) { + Map lastestApprovalStatusDictMap = MapUtil.newHashMap(); + lastestApprovalStatusDictMap.put("id", workOrderVo.getLatestApprovalStatus()); + lastestApprovalStatusDictMap.put("name", name); + workOrderVo.setLatestApprovalStatusDictMap(lastestApprovalStatusDictMap); + } + } + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/FlowRedisKeyUtil.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/FlowRedisKeyUtil.java new file mode 100644 index 00000000..b95cd08e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/util/FlowRedisKeyUtil.java @@ -0,0 +1,52 @@ +package com.orangeforms.common.flow.util; + +import cn.hutool.core.util.StrUtil; +import com.orangeforms.common.core.object.TokenData; + +/** + * 工作流 Redis 键生成工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class FlowRedisKeyUtil { + + /** + * 计算流程对象缓存在Redis中的键值。 + * + * @param processDefinitionKey 流程标识。 + * @return 流程对象缓存在Redis中的键值。 + */ + public static String makeFlowEntryKey(String processDefinitionKey) { + String prefix = "FLOW_ENTRY:"; + TokenData tokenData = TokenData.takeFromRequest(); + if (tokenData == null) { + return prefix + processDefinitionKey; + } + String appCode = tokenData.getAppCode(); + if (StrUtil.isBlank(appCode)) { + Long tenantId = tokenData.getTenantId(); + if (tenantId == null) { + return prefix + processDefinitionKey; + } + return prefix + tenantId.toString() + ":" + processDefinitionKey; + } + return prefix + appCode + ":" + processDefinitionKey; + } + + /** + * 流程发布对象缓存在Redis中的键值。 + * + * @param flowEntryPublishId 流程发布主键Id。 + * @return 流程发布对象缓存在Redis中的键值。 + */ + public static String makeFlowEntryPublishKey(Long flowEntryPublishId) { + return "FLOW_ENTRY_PUBLISH:" + flowEntryPublishId; + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FlowRedisKeyUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowCategoryVo.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowCategoryVo.java new file mode 100644 index 00000000..56894a81 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowCategoryVo.java @@ -0,0 +1,71 @@ +package com.orangeforms.common.flow.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 流程分类的Vo对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "流程分类的Vo对象") +@Data +public class FlowCategoryVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long categoryId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Schema(description = "应用编码") + private String appCode; + + /** + * 显示名称。 + */ + @Schema(description = "显示名称") + private String name; + + /** + * 分类编码。 + */ + @Schema(description = "分类编码") + private String code; + + /** + * 实现顺序。 + */ + @Schema(description = "实现顺序") + private Integer showOrder; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者Id。 + */ + @Schema(description = "更新者Id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者Id。 + */ + @Schema(description = "创建者Id") + private Long createUserId; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowEntryPublishVo.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowEntryPublishVo.java new file mode 100644 index 00000000..53c802fa --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowEntryPublishVo.java @@ -0,0 +1,59 @@ +package com.orangeforms.common.flow.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 流程发布信息的Vo对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "流程发布信息的Vo对象") +@Data +public class FlowEntryPublishVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long entryPublishId; + + /** + * 发布版本。 + */ + @Schema(description = "发布版本") + private Integer publishVersion; + + /** + * 流程引擎中的流程定义Id。 + */ + @Schema(description = "流程引擎中的流程定义Id") + private String processDefinitionId; + + /** + * 激活状态。 + */ + @Schema(description = "激活状态") + private Boolean activeStatus; + + /** + * 是否为主版本。 + */ + @Schema(description = "是否为主版本") + private Boolean mainVersion; + + /** + * 创建者Id。 + */ + @Schema(description = "创建者Id") + private Long createUserId; + + /** + * 发布时间。 + */ + @Schema(description = "发布时间") + private Date publishTime; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowEntryVariableVo.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowEntryVariableVo.java new file mode 100644 index 00000000..68ef4d33 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowEntryVariableVo.java @@ -0,0 +1,77 @@ +package com.orangeforms.common.flow.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 流程变量Vo对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "流程变量Vo对象") +@Data +public class FlowEntryVariableVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long variableId; + + /** + * 流程Id。 + */ + @Schema(description = "流程Id") + private Long entryId; + + /** + * 变量名。 + */ + @Schema(description = "变量名") + private String variableName; + + /** + * 显示名。 + */ + @Schema(description = "显示名") + private String showName; + + /** + * 变量类型。 + */ + @Schema(description = "变量类型") + private Integer variableType; + + /** + * 绑定数据源Id。 + */ + @Schema(description = "绑定数据源Id") + private Long bindDatasourceId; + + /** + * 绑定数据源关联Id。 + */ + @Schema(description = "绑定数据源关联Id") + private Long bindRelationId; + + /** + * 绑定字段Id。 + */ + @Schema(description = "绑定字段Id") + private Long bindColumnId; + + /** + * 是否内置。 + */ + @Schema(description = "是否内置") + private Boolean builtin; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowEntryVo.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowEntryVo.java new file mode 100644 index 00000000..b9cdc945 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowEntryVo.java @@ -0,0 +1,157 @@ +package com.orangeforms.common.flow.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 流程的Vo对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "流程的Vo对象") +@Data +public class FlowEntryVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long entryId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Schema(description = "应用编码") + private String appCode; + + /** + * 流程名称。 + */ + @Schema(description = "流程名称") + private String processDefinitionName; + + /** + * 流程标识Key。 + */ + @Schema(description = "流程标识Key") + private String processDefinitionKey; + + /** + * 流程分类。 + */ + @Schema(description = "流程分类") + private Long categoryId; + + /** + * 工作流部署的发布主版本Id。 + */ + @Schema(description = "工作流部署的发布主版本Id") + private Long mainEntryPublishId; + + /** + * 最新发布时间。 + */ + @Schema(description = "最新发布时间") + private Date latestPublishTime; + + /** + * 流程状态。 + */ + @Schema(description = "流程状态") + private Integer status; + + /** + * 流程定义的xml。 + */ + @Schema(description = "流程定义的xml") + private String bpmnXml; + + /** + * 流程图类型。0: 普通流程图,1: 钉钉风格的流程图。 + */ + @Schema(description = "流程图类型。0: 普通流程图,1: 钉钉风格的流程图") + private Integer diagramType; + + /** + * 绑定表单类型。 + */ + @Schema(description = "绑定表单类型") + private Integer bindFormType; + + /** + * 在线表单的页面Id。 + */ + @Schema(description = "在线表单的页面Id") + private Long pageId; + + /** + * 在线表单Id。 + */ + @Schema(description = "在线表单Id") + private Long defaultFormId; + + /** + * 在线表单的缺省路由名称。 + */ + @Schema(description = "在线表单的缺省路由名称") + private String defaultRouterName; + + /** + * 工单表编码字段的编码规则,如果为空则不计算工单编码。 + */ + @Schema(description = "工单表编码字段的编码规则") + private String encodedRule; + + /** + * 流程的自定义扩展数据(JSON格式)。 + */ + @Schema(description = "流程的自定义扩展数据") + private String extensionData; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者Id。 + */ + @Schema(description = "更新者Id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者Id。 + */ + @Schema(description = "创建者Id") + private Long createUserId; + + /** + * categoryId 的一对一关联数据对象,数据对应类型为FlowCategoryVo。 + */ + @Schema(description = "categoryId 的一对一关联数据对象") + private Map flowCategory; + + /** + * mainEntryPublishId 的一对一关联数据对象,数据对应类型为FlowEntryPublishVo。 + */ + @Schema(description = "mainEntryPublishId 的一对一关联数据对象") + private Map mainFlowEntryPublish; + + /** + * 关联的在线表单列表。 + */ + @Schema(description = "关联的在线表单列表") + private List> formList; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowMessageVo.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowMessageVo.java new file mode 100644 index 00000000..8d7d104b --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowMessageVo.java @@ -0,0 +1,137 @@ +package com.orangeforms.common.flow.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 工作流通知消息Vo对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "工作流通知消息Vo对象") +@Data +public class FlowMessageVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long messageId; + + /** + * 消息类型。 + */ + @Schema(description = "消息类型") + private Integer messageType; + + /** + * 消息内容。 + */ + @Schema(description = "消息内容") + private String messageContent; + + /** + * 催办次数。 + */ + @Schema(description = "催办次数") + private Integer remindCount; + + /** + * 工单Id。 + */ + @Schema(description = "工单Id") + private Long workOrderId; + + /** + * 流程定义Id。 + */ + @Schema(description = "流程定义Id") + private String processDefinitionId; + + /** + * 流程定义标识。 + */ + @Schema(description = "流程定义标识") + private String processDefinitionKey; + + /** + * 流程名称。 + */ + @Schema(description = "流程名称") + private String processDefinitionName; + + /** + * 流程实例Id。 + */ + @Schema(description = "流程实例Id") + private String processInstanceId; + + /** + * 流程实例发起者。 + */ + @Schema(description = "流程实例发起者") + private String processInstanceInitiator; + + /** + * 流程任务Id。 + */ + @Schema(description = "流程任务Id") + private String taskId; + + /** + * 流程任务定义标识。 + */ + @Schema(description = "流程任务定义标识") + private String taskDefinitionKey; + + /** + * 流程任务名称。 + */ + @Schema(description = "流程任务名称") + private String taskName; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date taskStartTime; + + /** + * 业务数据快照。 + */ + @Schema(description = "业务数据快照") + private String businessDataShot; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者Id。 + */ + @Schema(description = "更新者Id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者Id。 + */ + @Schema(description = "创建者Id") + private Long createUserId; + + /** + * 创建者显示名。 + */ + @Schema(description = "创建者显示名") + private String createUsername; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowTaskCommentVo.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowTaskCommentVo.java new file mode 100644 index 00000000..c8328b34 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowTaskCommentVo.java @@ -0,0 +1,113 @@ +package com.orangeforms.common.flow.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * FlowTaskCommentVO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "FlowTaskCommentVO对象") +@Data +public class FlowTaskCommentVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long id; + + /** + * 流程实例Id。 + */ + @Schema(description = "流程实例Id") + private String processInstanceId; + + /** + * 任务Id。 + */ + @Schema(description = "任务Id") + private String taskId; + + /** + * 任务标识。 + */ + @Schema(description = "任务标识") + private String taskKey; + + /** + * 任务名称。 + */ + @Schema(description = "任务名称") + private String taskName; + + /** + * 任务的执行Id。 + */ + @Schema(description = "任务的执行Id") + private String executionId; + + /** + * 会签任务的执行Id。 + */ + @Schema(description = "会签任务的执行Id") + private String multiInstanceExecId; + + /** + * 审批类型。 + */ + @Schema(description = "审批类型") + private String approvalType; + + /** + * 批注内容。 + */ + @Schema(description = "批注内容") + private String taskComment; + + /** + * 委托指定人,比如加签、转办等。 + */ + @Schema(description = "委托指定人,比如加签、转办等") + private String delegateAssignee; + + /** + * 自定义数据。开发者可自行扩展,推荐使用JSON格式数据。 + */ + @Schema(description = "自定义数据") + private String customBusinessData; + + /** + * 审批人头像。 + */ + @Schema(description = "审批人头像") + private String headImageUrl; + + /** + * 创建者Id。 + */ + @Schema(description = "创建者Id") + private Long createUserId; + + /** + * 创建者登录名。 + */ + @Schema(description = "创建者登录名") + private String createLoginName; + + /** + * 创建者显示名。 + */ + @Schema(description = "创建者显示名") + private String createUsername; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowTaskVo.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowTaskVo.java new file mode 100644 index 00000000..35e4c367 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowTaskVo.java @@ -0,0 +1,125 @@ +package com.orangeforms.common.flow.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 流程任务Vo对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "流程任务Vo对象") +@Data +public class FlowTaskVo { + + /** + * 流程任务Id。 + */ + @Schema(description = "流程任务Id") + private String taskId; + + /** + * 流程任务名称。 + */ + @Schema(description = "流程任务名称") + private String taskName; + + /** + * 流程任务标识。 + */ + @Schema(description = "流程任务标识") + private String taskKey; + + /** + * 任务的表单信息。 + */ + @Schema(description = "任务的表单信息") + private String taskFormKey; + + /** + * 待办任务开始时间。 + */ + @Schema(description = "待办任务开始时间") + private Date taskStartTime; + + /** + * 流程Id。 + */ + @Schema(description = "流程Id") + private Long entryId; + + /** + * 流程定义Id。 + */ + @Schema(description = "流程定义Id") + private String processDefinitionId; + + /** + * 流程定义名称。 + */ + @Schema(description = "流程定义名称") + private String processDefinitionName; + + /** + * 流程定义标识。 + */ + @Schema(description = "流程定义标识") + private String processDefinitionKey; + + /** + * 流程定义版本。 + */ + @Schema(description = "流程定义版本") + private Integer processDefinitionVersion; + + /** + * 流程实例Id。 + */ + @Schema(description = "流程实例Id") + private String processInstanceId; + + /** + * 流程实例发起人。 + */ + @Schema(description = "流程实例发起人") + private String processInstanceInitiator; + + /** + * 流程实例发起人显示名。 + */ + @Schema(description = "流程实例发起人显示名") + private String showName; + + /** + * 用户头像信息。 + */ + @Schema(description = "用户头像信息") + private String headImageUrl; + + /** + * 流程实例创建时间。 + */ + @Schema(description = "流程实例创建时间") + private Date processInstanceStartTime; + + /** + * 流程实例主表业务数据主键。 + */ + @Schema(description = "流程实例主表业务数据主键") + private String businessKey; + + /** + * 工单编码。 + */ + @Schema(description = "工单编码") + private String workOrderCode; + + /** + * 是否为草稿状态。 + */ + @Schema(description = "是否为草稿状态") + private Boolean isDraft; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowUserInfoVo.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowUserInfoVo.java new file mode 100644 index 00000000..2ceca1fa --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowUserInfoVo.java @@ -0,0 +1,77 @@ +package com.orangeforms.common.flow.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 流程任务的用户信息。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "流程任务的用户信息") +@Data +public class FlowUserInfoVo { + + /** + * 用户Id。 + */ + @Schema(description = "用户Id") + private Long userId; + + /** + * 用户部门Id。 + */ + @Schema(description = "用户部门Id") + private Long deptId; + + /** + * 登录用户名。 + */ + @Schema(description = "登录用户名") + private String loginName; + + /** + * 用户显示名称。 + */ + @Schema(description = "用户显示名称") + private String showName; + + /** + * 用户头像的Url。 + */ + @Schema(description = "用户头像的Url") + private String headImageUrl; + + /** + * 用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)。 + */ + @Schema(description = "用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)") + private Integer userType; + + /** + * 用户状态(0: 正常 1: 锁定)。 + */ + @Schema(description = "用户状态(0: 正常 1: 锁定)") + private Integer userStatus; + + /** + * 用户邮箱。 + */ + @Schema(description = "用户邮箱") + private String email; + + /** + * 用户手机。 + */ + @Schema(description = "用户手机") + private String mobile; + + /** + * 最后审批时间。 + */ + @Schema(description = "最后审批时间") + private Date lastApprovalTime; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowWorkOrderVo.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowWorkOrderVo.java new file mode 100644 index 00000000..3122ed8f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/FlowWorkOrderVo.java @@ -0,0 +1,158 @@ +package com.orangeforms.common.flow.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import com.alibaba.fastjson.JSONArray; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 工作流工单VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "工作流工单Vo对象") +@Data +public class FlowWorkOrderVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long workOrderId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Schema(description = "应用编码") + private String appCode; + + /** + * 工单编码字段。 + */ + @Schema(description = "工单编码字段") + private String workOrderCode; + + /** + * 流程定义标识。 + */ + @Schema(description = "流程定义标识") + private String processDefinitionKey; + + /** + * 流程名称。 + */ + @Schema(description = "流程名称") + private String processDefinitionName; + + /** + * 流程引擎的定义Id。 + */ + @Schema(description = "流程引擎的定义Id") + private String processDefinitionId; + + /** + * 流程实例Id。 + */ + @Schema(description = "流程实例Id") + private String processInstanceId; + + /** + * 在线表单的主表Id。 + */ + @Schema(description = "在线表单的主表Id") + private Long onlineTableId; + + /** + * 业务主键值。 + */ + @Schema(description = "业务主键值") + private String businessKey; + + /** + * 最近的审批状态。 + */ + @Schema(description = "最近的审批状态") + private Integer latestApprovalStatus; + + /** + * 流程状态。参考FlowTaskStatus常量值对象。 + */ + @Schema(description = "流程状态") + private Integer flowStatus; + + /** + * 提交用户登录名称。 + */ + @Schema(description = "提交用户登录名称") + private String submitUsername; + + /** + * 提交用户所在部门Id。 + */ + @Schema(description = "提交用户所在部门Id") + private Long deptId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者Id。 + */ + @Schema(description = "更新者Id") + private Long updateUserId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者Id。 + */ + @Schema(description = "创建者Id") + private Long createUserId; + + /** + * latestApprovalStatus 关联的字典数据。 + */ + @Schema(description = "latestApprovalStatus 常量字典关联数据") + private Map latestApprovalStatusDictMap; + + /** + * flowStatus 常量字典关联数据。 + */ + @Schema(description = "flowStatus 常量字典关联数据") + private Map flowStatusDictMap; + + /** + * 用户的显示名。 + */ + @Schema(description = "用户的显示名") + private String userShowName; + + /** + * FlowEntryPublish对象中的同名字段。 + */ + @Schema(description = "FlowEntryPublish对象中的同名字段") + private String initTaskInfo; + + /** + * 当前实例的运行时任务列表。 + * 正常情况下只有一个,在并行网关下可能存在多个。 + */ + @Schema(description = "实例的运行时任务列表") + private JSONArray runtimeTaskInfoList; + + /** + * 业务主表数据。 + */ + @Schema(description = "业务主表数据") + private Map masterData; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/TaskInfoVo.java b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/TaskInfoVo.java new file mode 100644 index 00000000..2d4f981a --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/java/com/orangeforms/common/flow/vo/TaskInfoVo.java @@ -0,0 +1,85 @@ +package com.orangeforms.common.flow.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import com.alibaba.fastjson.JSONObject; +import lombok.Data; + +import java.util.List; + +/** + * 流程任务信息Vo对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "流程任务信息Vo对象") +@Data +public class TaskInfoVo { + + /** + * 流程节点任务类型。具体值可参考FlowTaskType常量值。 + */ + @Schema(description = "流程节点任务类型") + private Integer taskType; + + /** + * 指定人。 + */ + @Schema(description = "指定人") + private String assignee; + + /** + * 任务标识。 + */ + @Schema(description = "任务标识") + private String taskKey; + + /** + * 是否分配给当前登录用户的标记。 + * 当该值为true时,登录用户启动流程时,就自动完成了第一个用户任务。 + */ + @Schema(description = "是否分配给当前登录用户的标记") + private Boolean assignedMe; + + /** + * 动态表单Id。 + */ + @Schema(description = "动态表单Id") + private Long formId; + + /** + * PC端静态表单路由。 + */ + @Schema(description = "PC端静态表单路由") + private String routerName; + + /** + * 移动端静态表单路由。 + */ + @Schema(description = "移动端静态表单路由") + private String mobileRouterName; + + /** + * 候选组类型。 + */ + @Schema(description = "候选组类型") + private String groupType; + + /** + * 只读标记。 + */ + @Schema(description = "只读标记") + private Boolean readOnly; + + /** + * 前端所需的操作列表。 + */ + @Schema(description = "前端所需的操作列表") + List operationList; + + /** + * 任务节点的自定义变量列表。 + */ + @Schema(description = "任务节点的自定义变量列表") + List variableList; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/resources/META-INF/services/org.flowable.common.engine.impl.EngineConfigurator b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/resources/META-INF/services/org.flowable.common.engine.impl.EngineConfigurator new file mode 100644 index 00000000..eda90b8a --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/resources/META-INF/services/org.flowable.common.engine.impl.EngineConfigurator @@ -0,0 +1 @@ +com.orangeforms.common.flow.config.CustomEngineConfigurator \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..8c6f8611 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-flow/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.orangeforms.common.flow.config.FlowAutoConfig \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-log/pom.xml b/OrangeFormsOpen-MybatisPlus/common/common-log/pom.xml new file mode 100644 index 00000000..4f39b309 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-log/pom.xml @@ -0,0 +1,29 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-log + 1.0.0 + common-log + jar + + + + com.orangeforms + common-sequence + 1.0.0 + + + com.orangeforms + common-swagger + 1.0.0 + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/annotation/IgnoreResponseLog.java b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/annotation/IgnoreResponseLog.java new file mode 100644 index 00000000..00bbe1f6 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/annotation/IgnoreResponseLog.java @@ -0,0 +1,16 @@ +package com.orangeforms.common.log.annotation; + +import java.lang.annotation.*; + +/** + * 忽略接口应答数据记录日志的注解。该注解会被OperationLogAspect处理。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface IgnoreResponseLog { + +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/annotation/OperationLog.java b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/annotation/OperationLog.java new file mode 100644 index 00000000..32f6b591 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/annotation/OperationLog.java @@ -0,0 +1,33 @@ +package com.orangeforms.common.log.annotation; + +import com.orangeforms.common.log.model.constant.SysOperationLogType; + +import java.lang.annotation.*; + +/** + * 操作日志记录注解。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface OperationLog { + + /** + * 描述。 + */ + String description() default ""; + + /** + * 操作类型。 + */ + int type() default SysOperationLogType.OTHER; + + /** + * 是否保存应答结果。 + * 对于类似导出和文件下载之类的接口,该参与应该设置为false。 + */ + boolean saveResponse() default true; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/aop/OperationLogAspect.java b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/aop/OperationLogAspect.java new file mode 100644 index 00000000..b71c5df0 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/aop/OperationLogAspect.java @@ -0,0 +1,265 @@ +package com.orangeforms.common.log.aop; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.BooleanUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.ResponseResult; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.ContextUtil; +import com.orangeforms.common.core.util.IpUtil; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.log.annotation.IgnoreResponseLog; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.config.OperationLogProperties; +import com.orangeforms.common.log.model.SysOperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.log.service.SysOperationLogService; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.Signature; +import org.aspectj.lang.annotation.*; +import org.aspectj.lang.reflect.MethodSignature; +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.util.*; + +/** + * 操作日志记录处理AOP对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Aspect +@Component +@Order(1) +@Slf4j +public class OperationLogAspect { + + @Value("${spring.application.name}") + private String serviceName; + @Autowired + private SysOperationLogService operationLogService; + @Autowired + private OperationLogProperties properties; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 错误信息、请求参数和应答结果字符串的最大长度。 + */ + private static final int MAX_LENGTH = 2000; + + /** + * 所有controller方法。 + */ + @Pointcut("execution(public * com.orangeforms..controller..*(..))") + public void operationLogPointCut() { + // 空注释,避免sonar警告 + } + + @Around("operationLogPointCut()") + public Object around(ProceedingJoinPoint joinPoint) throws Throwable { + // 计时。 + long start = System.currentTimeMillis(); + HttpServletRequest request = ContextUtil.getHttpRequest(); + HttpServletResponse response = ContextUtil.getHttpResponse(); + String traceId = this.getTraceId(request); + request.setAttribute(ApplicationConstant.HTTP_HEADER_TRACE_ID, traceId); + // 将流水号通过应答头返回给前端,便于问题精确定位。 + response.setHeader(ApplicationConstant.HTTP_HEADER_TRACE_ID, traceId); + MDC.put(ApplicationConstant.HTTP_HEADER_TRACE_ID, traceId); + TokenData tokenData = TokenData.takeFromRequest(); + // 为日志框架设定变量,使日志可以输出更多有价值的信息。 + if (tokenData != null) { + MDC.put("sessionId", tokenData.getSessionId()); + MDC.put("userId", tokenData.getUserId().toString()); + } + String[] parameterNames = this.getParameterNames(joinPoint); + Object[] args = joinPoint.getArgs(); + JSONObject jsonArgs = new JSONObject(); + for (int i = 0; i < args.length; i++) { + Object arg = args[i]; + if (this.isNormalArgs(arg)) { + String parameterName = parameterNames[i]; + jsonArgs.put(parameterName, arg); + } + } + String params = jsonArgs.toJSONString(); + SysOperationLog operationLog = null; + OperationLog operationLogAnnotation = null; + boolean saveOperationLog = properties.isEnabled(); + if (saveOperationLog) { + operationLogAnnotation = getMethodAnnotation(joinPoint, OperationLog.class); + saveOperationLog = (operationLogAnnotation != null); + } + if (saveOperationLog) { + operationLog = this.buildSysOperationLog(operationLogAnnotation, joinPoint, params, traceId, tokenData); + } + Object result; + log.info("开始请求,url={}, reqData={}", request.getRequestURI(), params); + try { + // 调用原来的方法 + result = joinPoint.proceed(); + String respData = result == null ? "null" : JSON.toJSONString(result); + Long elapse = System.currentTimeMillis() - start; + if (saveOperationLog) { + this.operationLogPostProcess(operationLogAnnotation, respData, operationLog, result); + } + if (elapse > properties.getSlowLogMs()) { + log.warn("耗时较长的请求完成警告, url={},elapse={}ms reqData={} respData={}", + request.getRequestURI(), elapse, params, respData); + } + if (this.getMethodAnnotation(joinPoint, IgnoreResponseLog.class) == null) { + log.info("请求完成, url={},elapse={}ms, respData={}", request.getRequestURI(), elapse, respData); + } + } catch (Exception e) { + if (saveOperationLog) { + operationLog.setSuccess(false); + operationLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, MAX_LENGTH)); + } + log.error("请求报错,url={}, reqData={}, error={}", request.getRequestURI(), params, e.getMessage()); + throw e; + } finally { + if (saveOperationLog) { + operationLog.setElapse(System.currentTimeMillis() - start); + operationLogService.saveNewAsync(operationLog); + } + MDC.remove(ApplicationConstant.HTTP_HEADER_TRACE_ID); + if (tokenData != null) { + MDC.remove("sessionId"); + MDC.remove("userId"); + } + } + return result; + } + + private SysOperationLog buildSysOperationLog( + OperationLog operationLogAnnotation, + ProceedingJoinPoint joinPoint, + String params, + String traceId, + TokenData tokenData) { + HttpServletRequest request = ContextUtil.getHttpRequest(); + SysOperationLog operationLog = new SysOperationLog(); + operationLog.setLogId(idGenerator.nextLongId()); + operationLog.setTraceId(traceId); + operationLog.setDescription(operationLogAnnotation.description()); + operationLog.setOperationType(operationLogAnnotation.type()); + operationLog.setServiceName(this.serviceName); + operationLog.setApiClass(joinPoint.getTarget().getClass().getName()); + operationLog.setApiMethod(operationLog.getApiClass() + "." + joinPoint.getSignature().getName()); + operationLog.setRequestMethod(request.getMethod()); + operationLog.setRequestUrl(request.getRequestURI()); + if (tokenData != null) { + operationLog.setRequestIp(tokenData.getLoginIp()); + } else { + operationLog.setRequestIp(IpUtil.getRemoteIpAddress(request)); + } + operationLog.setOperationTime(new Date()); + if (params != null) { + if (params.length() <= MAX_LENGTH) { + operationLog.setRequestArguments(params); + } else { + operationLog.setRequestArguments(StringUtils.substring(params, 0, MAX_LENGTH)); + } + } + if (tokenData != null) { + // 对于非多租户系统,该值为空可以忽略。 + operationLog.setTenantId(tokenData.getTenantId()); + operationLog.setSessionId(tokenData.getSessionId()); + operationLog.setOperatorId(tokenData.getUserId()); + operationLog.setOperatorName(tokenData.getLoginName()); + } + return operationLog; + } + + private void operationLogPostProcess( + OperationLog operationLogAnnotation, String respData, SysOperationLog operationLog, Object result) { + if (operationLogAnnotation.saveResponse()) { + if (respData.length() <= MAX_LENGTH) { + operationLog.setResponseResult(respData); + } else { + operationLog.setResponseResult(StringUtils.substring(respData, 0, MAX_LENGTH)); + } + } + // 处理大部分返回ResponseResult的接口。 + if (!(result instanceof ResponseResult)) { + if (ContextUtil.hasRequestContext()) { + operationLog.setSuccess(ContextUtil.getHttpResponse().getStatus() == HttpServletResponse.SC_OK); + } + return; + } + ResponseResult responseResult = (ResponseResult) result; + operationLog.setSuccess(responseResult.isSuccess()); + if (!responseResult.isSuccess()) { + operationLog.setErrorMsg(responseResult.getErrorMessage()); + } + if (operationLog.getOperationType().equals(SysOperationLogType.LOGIN)) { + // 对于登录操作,由于在调用登录方法之前,没有可用的TokenData。 + // 因此如果登录成功,可再次通过TokenData.takeFromRequest()获取TokenData。 + if (BooleanUtil.isTrue(operationLog.getSuccess())) { + // 这里为了保证LoginController.doLogin方法,一定将TokenData存入Request.Attribute之中, + // 我们将不做空值判断,一旦出错,开发者可在调试时立刻发现异常,并根据这里的注释进行修复。 + TokenData tokenData = TokenData.takeFromRequest(); + // 对于非多租户系统,为了保证代码一致性,仍可保留对tenantId的赋值代码。 + operationLog.setTenantId(tokenData.getTenantId()); + operationLog.setSessionId(tokenData.getSessionId()); + operationLog.setOperatorId(tokenData.getUserId()); + operationLog.setOperatorName(tokenData.getLoginName()); + } else { + HttpServletRequest request = ContextUtil.getHttpRequest(); + // 登录操作需要特殊处理,无论是登录成功还是失败,都要记录operator_name字段。 + operationLog.setOperatorName(request.getParameter("loginName")); + } + } + } + + private String[] getParameterNames(ProceedingJoinPoint joinPoint) { + Signature signature = joinPoint.getSignature(); + MethodSignature methodSignature = (MethodSignature) signature; + return methodSignature.getParameterNames(); + } + + private T getMethodAnnotation(JoinPoint joinPoint, Class annotationClazz) { + Signature signature = joinPoint.getSignature(); + MethodSignature methodSignature = (MethodSignature) signature; + Method method = methodSignature.getMethod(); + return method.getAnnotation(annotationClazz); + } + + private String getTraceId(HttpServletRequest request) { + // 获取请求流水号。 + // 对于微服务系统,为了保证traceId在全调用链的唯一性,因此在网关的过滤器中创建了该值。 + String traceId = request.getHeader(ApplicationConstant.HTTP_HEADER_TRACE_ID); + if (StringUtils.isBlank(traceId)) { + traceId = MyCommonUtil.generateUuid(); + } + return traceId; + } + + private boolean isNormalArgs(Object o) { + if (o instanceof List) { + List list = (List) o; + if (CollUtil.isNotEmpty(list)) { + return !(list.get(0) instanceof MultipartFile); + } + } + return !(o instanceof HttpServletRequest) + && !(o instanceof HttpServletResponse) + && !(o instanceof MultipartFile); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/config/CommonLogAutoConfig.java b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/config/CommonLogAutoConfig.java new file mode 100644 index 00000000..54444158 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/config/CommonLogAutoConfig.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.log.config; + +import org.springframework.boot.context.properties.EnableConfigurationProperties; + +/** + * common-log模块的自动配置引导类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EnableConfigurationProperties({OperationLogProperties.class}) +public class CommonLogAutoConfig { +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/config/OperationLogProperties.java b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/config/OperationLogProperties.java new file mode 100644 index 00000000..cd8c95d6 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/config/OperationLogProperties.java @@ -0,0 +1,24 @@ +package com.orangeforms.common.log.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * 操作日志的配置类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ConfigurationProperties(prefix = "common-log.operation-log") +public class OperationLogProperties { + + /** + * 是否采集操作日志。 + */ + private boolean enabled = true; + /** + * 接口调用的毫秒数大于该值后,将输出慢日志警告。 + */ + private long slowLogMs = 50000; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/dao/SysOperationLogMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/dao/SysOperationLogMapper.java new file mode 100644 index 00000000..63e5ec4c --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/dao/SysOperationLogMapper.java @@ -0,0 +1,34 @@ +package com.orangeforms.common.log.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.log.model.SysOperationLog; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 系统操作日志对应的数据访问对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysOperationLogMapper extends BaseDaoMapper { + + /** + * 批量插入。 + * + * @param operationLogList 操作日志列表。 + */ + void insertList(List operationLogList); + + /** + * 根据过滤条件和排序规则,查询操作日志。 + * + * @param sysOperationLogFilter 操作日志的过滤对象。 + * @param orderBy 排序规则。 + * @return 查询列表。 + */ + List getSysOperationLogList( + @Param("sysOperationLogFilter") SysOperationLog sysOperationLogFilter, + @Param("orderBy") String orderBy); +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/dao/mapper/SysOperationLogMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/dao/mapper/SysOperationLogMapper.xml new file mode 100644 index 00000000..f29559f1 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/dao/mapper/SysOperationLogMapper.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_sys_operation_log.operation_type = #{sysOperationLogFilter.operationType} + + + + AND zz_sys_operation_log.request_url LIKE #{safeRequestUrl} + + + AND zz_sys_operation_log.trace_id = #{sysOperationLogFilter.traceId} + + + AND zz_sys_operation_log.success = #{sysOperationLogFilter.success} + + + + AND zz_sys_operation_log.operator_name LIKE #{safeOperatorName} + + + AND zz_sys_operation_log.elapse >= #{sysOperationLogFilter.elapseMin} + + + AND zz_sys_operation_log.elapse <= #{sysOperationLogFilter.elapseMax} + + + AND zz_sys_operation_log.operation_time >= #{sysOperationLogFilter.operationTimeStart} + + + AND zz_sys_operation_log.operation_time <= #{sysOperationLogFilter.operationTimeEnd} + + + + + + INSERT INTO zz_sys_operation_log VALUES + + (#{item.logId}, + #{item.description}, + #{item.operationType}, + #{item.serviceName}, + #{item.apiClass}, + #{item.apiMethod}, + #{item.sessionId}, + #{item.traceId}, + #{item.elapse}, + #{item.requestMethod}, + #{item.requestUrl}, + #{item.requestArguments}, + #{item.responseResult}, + #{item.requestIp}, + #{item.success}, + #{item.errorMsg}, + #{item.tenantId}, + #{item.operatorId}, + #{item.operatorName}, + #{item.operationTime}) + + + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/dto/SysOperationLogDto.java b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/dto/SysOperationLogDto.java new file mode 100644 index 00000000..994f51f0 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/dto/SysOperationLogDto.java @@ -0,0 +1,77 @@ +package com.orangeforms.common.log.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 操作日志记录表 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "操作日志Dto") +@Data +public class SysOperationLogDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long logId; + + /** + * 操作类型。 + * 常量值定义可参考SysOperationLogType对象。 + */ + @Schema(description = "操作类型") + private Integer operationType; + + /** + * 每次请求的Id。 + * 对于微服务之间的调用,在同一个请求的调用链中,该值是相同的。 + */ + @Schema(description = "每次请求的Id") + private String traceId; + + /** + * HTTP 请求地址。 + */ + @Schema(description = "HTTP 请求地址") + private String requestUrl; + + /** + * 应答状态。 + */ + @Schema(description = "应答状态") + private Boolean success; + + /** + * 操作员名称。 + */ + @Schema(description = "操作员名称") + private String operatorName; + + /** + * 调用时长最小值。 + */ + @Schema(description = "调用时长最小值") + private Long elapseMin; + + /** + * 调用时长最大值。 + */ + @Schema(description = "调用时长最大值") + private Long elapseMax; + + /** + * 操作开始时间。 + */ + @Schema(description = "操作开始时间") + private String operationTimeStart; + + /** + * 操作开始时间。 + */ + @Schema(description = "操作开始时间") + private String operationTimeEnd; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/model/SysOperationLog.java b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/model/SysOperationLog.java new file mode 100644 index 00000000..b1b4217e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/model/SysOperationLog.java @@ -0,0 +1,170 @@ +package com.orangeforms.common.log.model; + +import com.baomidou.mybatisplus.annotation.*; +import com.orangeforms.common.core.annotation.TenantFilterColumn; +import lombok.Data; + +import java.util.Date; + +/** + * 操作日志记录表 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName("zz_sys_operation_log") +public class SysOperationLog { + + /** + * 主键Id。 + */ + @TableId(value = "log_id") + private Long logId; + + /** + * 日志描述。 + */ + @TableField(value = "description") + private String description; + + /** + * 操作类型。 + * 常量值定义可参考SysOperationLogType对象。 + */ + @TableField(value = "operation_type") + private Integer operationType; + + /** + * 接口所在服务名称。 + * 通常为spring.application.name配置项的值。 + */ + @TableField(value = "service_name") + private String serviceName; + + /** + * 调用的controller全类名。 + * 之所以为独立字段,是为了便于查询和统计接口的调用频度。 + */ + @TableField(value = "api_class") + private String apiClass; + + /** + * 调用的controller中的方法。 + * 格式为:接口类名 + "." + 方法名。 + */ + @TableField(value = "api_method") + private String apiMethod; + + /** + * 用户会话sessionId。 + * 主要是为了便于统计,以及跟踪查询定位问题。 + */ + @TableField(value = "session_id") + private String sessionId; + + /** + * 每次请求的Id。 + * 对于微服务之间的调用,在同一个请求的调用链中,该值是相同的。 + */ + @TableField(value = "trace_id") + private String traceId; + + /** + * 调用时长。 + */ + @TableField(value = "elapse") + private Long elapse; + + /** + * HTTP 请求方法,如GET。 + */ + @TableField(value = "request_method") + private String requestMethod; + + /** + * HTTP 请求地址。 + */ + @TableField(value = "request_url") + private String requestUrl; + + /** + * controller接口参数。 + */ + @TableField(value = "request_arguments") + private String requestArguments; + + /** + * controller应答结果。 + */ + @TableField(value = "response_result") + private String responseResult; + + /** + * 请求IP。 + */ + @TableField(value = "request_ip") + private String requestIp; + + /** + * 应答状态。 + */ + @TableField(value = "success") + private Boolean success; + + /** + * 错误信息。 + */ + @TableField(value = "error_msg") + private String errorMsg; + + /** + * 租户Id。 + * 仅用于多租户系统,是便于进行对租户的操作查询和统计分析。 + */ + @TenantFilterColumn + @TableField(value = "tenant_id") + private Long tenantId; + + /** + * 操作员Id。 + */ + @TableField(value = "operator_id") + private Long operatorId; + + /** + * 操作员名称。 + */ + @TableField(value = "operator_name") + private String operatorName; + + /** + * 操作时间。 + */ + @TableField(value = "operation_time") + private Date operationTime; + + /** + * 调用时长最小值。 + */ + @TableField(exist = false) + private Long elapseMin; + + /** + * 调用时长最大值。 + */ + @TableField(exist = false) + private Long elapseMax; + + /** + * 操作开始时间。 + */ + @TableField(exist = false) + private String operationTimeStart; + + /** + * 操作结束时间。 + */ + @TableField(exist = false) + private String operationTimeEnd; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/model/constant/SysOperationLogType.java b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/model/constant/SysOperationLogType.java new file mode 100644 index 00000000..ec3edaf5 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/model/constant/SysOperationLogType.java @@ -0,0 +1,145 @@ +package com.orangeforms.common.log.model.constant; + +/** + * 操作日志类型常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class SysOperationLogType { + + /** + * 其他。 + */ + public static final int OTHER = -1; + /** + * 登录。 + */ + public static final int LOGIN = 0; + /** + * 登录移动端。 + */ + public static final int LOGIN_MOBILE = 1; + /** + * 登出。 + */ + public static final int LOGOUT = 5; + /** + * 登出移动端。 + */ + public static final int LOGOUT_MOBILE = 6; + /** + * 新增。 + */ + public static final int ADD = 10; + /** + * 修改。 + */ + public static final int UPDATE = 15; + /** + * 删除。 + */ + public static final int DELETE = 20; + /** + * 批量删除。 + */ + public static final int DELETE_BATCH = 21; + /** + * 新增多对多关联。 + */ + public static final int ADD_M2M = 25; + /** + * 移除多对多关联。 + */ + public static final int DELETE_M2M = 30; + /** + * 批量移除多对多关联。 + */ + public static final int DELETE_M2M_BATCH = 31; + /** + * 查询。 + */ + public static final int LIST = 35; + /** + * 分组查询。 + */ + public static final int LIST_WITH_GROUP = 40; + /** + * 导出。 + */ + public static final int EXPORT = 45; + /** + * 导入。 + */ + public static final int IMPORT = 46; + /** + * 上传。 + */ + public static final int UPLOAD = 50; + /** + * 下载。 + */ + public static final int DOWNLOAD = 55; + /** + * 重置缓存。 + */ + public static final int RELOAD_CACHE = 60; + /** + * 发布。 + */ + public static final int PUBLISH = 65; + /** + * 取消发布。 + */ + public static final int UNPUBLISH = 70; + /** + * 暂停。 + */ + public static final int SUSPEND = 75; + /** + * 恢复。 + */ + public static final int RESUME = 80; + /** + * 启动流程。 + */ + public static final int START_FLOW = 100; + /** + * 停止流程。 + */ + public static final int STOP_FLOW = 105; + /** + * 删除流程。 + */ + public static final int DELETE_FLOW = 110; + /** + * 取消流程。 + */ + public static final int CANCEL_FLOW = 115; + /** + * 提交任务。 + */ + public static final int SUBMIT_TASK = 120; + /** + * 催办任务。 + */ + public static final int REMIND_TASK = 125; + /** + * 干预任务。 + */ + public static final int INTERVENE_FLOW = 126; + /** + * 修复流程的业务数据。 + */ + public static final int FIX_FLOW_BUSINESS_DATA = 127; + /** + * 流程复活。 + */ + public static final int REVIVE_FLOW = 128; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private SysOperationLogType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/service/SysOperationLogService.java b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/service/SysOperationLogService.java new file mode 100644 index 00000000..18c1b087 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/service/SysOperationLogService.java @@ -0,0 +1,45 @@ +package com.orangeforms.common.log.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.log.model.SysOperationLog; + +import java.util.List; + +/** + * 操作日志服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface SysOperationLogService extends IBaseService { + + /** + * 异步的插入一条新操作日志。 + * + * @param operationLog 操作日志对象。 + */ + void saveNewAsync(SysOperationLog operationLog); + + /** + * 插入一条新操作日志。 + * + * @param operationLog 操作日志对象。 + */ + void saveNew(SysOperationLog operationLog); + + /** + * 批量插入。 + * + * @param sysOperationLogList 操作日志列表。 + */ + void batchSave(List sysOperationLogList); + + /** + * 根据过滤条件和排序规则,查询操作日志。 + * + * @param filter 操作日志的过滤对象。 + * @param orderBy 排序规则。 + * @return 查询列表。 + */ + List getSysOperationLogList(SysOperationLog filter, String orderBy); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/service/impl/SysOperationLogServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/service/impl/SysOperationLogServiceImpl.java new file mode 100644 index 00000000..3935df68 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/service/impl/SysOperationLogServiceImpl.java @@ -0,0 +1,84 @@ +package com.orangeforms.common.log.service.impl; + +import com.orangeforms.common.core.annotation.MyDataSource; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.log.dao.SysOperationLogMapper; +import com.orangeforms.common.log.model.SysOperationLog; +import com.orangeforms.common.log.service.SysOperationLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * 操作日志服务实现类。 + * 这里需要重点解释下MyDataSource注解。在单数据源服务中,由于没有DataSourceAspect的切面类,所以该注解不会 + * 有任何作用和影响。然而在多数据源情况下,由于每个服务都有自己的DataSourceType常量对象,表示不同的数据源。 + * 而common-log在公用模块中,不能去依赖业务服务,因此这里给出了一个固定值。我们在业务的DataSourceType中,也要 + * 使用该值ApplicationConstant.OPERATION_LOG_DATASOURCE_TYPE,去关联操作日志所需的数据源配置。 + * + * @author Jerry + * @date 2024-07-02 + */ +@MyDataSource(ApplicationConstant.OPERATION_LOG_DATASOURCE_TYPE) +@Service +public class SysOperationLogServiceImpl extends BaseService implements SysOperationLogService { + + @Autowired + private SysOperationLogMapper sysOperationLogMapper; + + @Override + protected BaseDaoMapper mapper() { + return sysOperationLogMapper; + } + + /** + * 异步插入一条新操作日志。通常用于在橙单中创建的单体工程服务。 + * + * @param operationLog 操作日志对象。 + */ + @Async + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNewAsync(SysOperationLog operationLog) { + sysOperationLogMapper.insert(operationLog); + } + + /** + * 插入一条新操作日志。 + * + * @param operationLog 操作日志对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNew(SysOperationLog operationLog) { + sysOperationLogMapper.insert(operationLog); + } + + /** + * 批量插入。通常用于在橙单中创建的微服务工程服务。 + * + * @param sysOperationLogList 操作日志列表。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void batchSave(List sysOperationLogList) { + sysOperationLogMapper.insertList(sysOperationLogList); + } + + /** + * 根据过滤条件和排序规则,查询操作日志。 + * + * @param filter 操作日志的过滤对象。 + * @param orderBy 排序规则。 + * @return 查询列表。 + */ + @Override + public List getSysOperationLogList(SysOperationLog filter, String orderBy) { + return sysOperationLogMapper.getSysOperationLogList(filter, orderBy); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/vo/SysOperationLogVo.java b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/vo/SysOperationLogVo.java new file mode 100644 index 00000000..983ea9ed --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/java/com/orangeforms/common/log/vo/SysOperationLogVo.java @@ -0,0 +1,144 @@ +package com.orangeforms.common.log.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 操作日志记录表 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "操作日志VO") +@Data +public class SysOperationLogVo { + + /** + * 操作日志主键Id。 + */ + @Schema(description = "操作日志主键Id") + private Long logId; + + /** + * 日志描述。 + */ + @Schema(description = "日志描述") + private String description; + + /** + * 操作类型。 + * 常量值定义可参考SysOperationLogType对象。 + */ + @Schema(description = "操作类型") + private Integer operationType; + + /** + * 接口所在服务名称。 + * 通常为spring.application.name配置项的值。 + */ + @Schema(description = "接口所在服务名称") + private String serviceName; + + /** + * 调用的controller全类名。 + * 之所以为独立字段,是为了便于查询和统计接口的调用频度。 + */ + @Schema(description = "调用的controller全类名") + private String apiClass; + + /** + * 调用的controller中的方法。 + * 格式为:接口类名 + "." + 方法名。 + */ + @Schema(description = "调用的controller中的方法") + private String apiMethod; + + /** + * 用户会话sessionId。 + * 主要是为了便于统计,以及跟踪查询定位问题。 + */ + @Schema(description = "用户会话sessionId") + private String sessionId; + + /** + * 每次请求的Id。 + * 对于微服务之间的调用,在同一个请求的调用链中,该值是相同的。 + */ + @Schema(description = "每次请求的Id") + private String traceId; + + /** + * 调用时长。 + */ + @Schema(description = "调用时长") + private Long elapse; + + /** + * HTTP 请求方法,如GET。 + */ + @Schema(description = "HTTP 请求方法") + private String requestMethod; + + /** + * HTTP 请求地址。 + */ + @Schema(description = "HTTP 请求地址") + private String requestUrl; + + /** + * controller接口参数。 + */ + @Schema(description = "controller接口参数") + private String requestArguments; + + /** + * controller应答结果。 + */ + @Schema(description = "controller应答结果") + private String responseResult; + + /** + * 请求IP。 + */ + @Schema(description = "请求IP") + private String requestIp; + + /** + * 应答状态。 + */ + @Schema(description = "应答状态") + private Boolean success; + + /** + * 错误信息。 + */ + @Schema(description = "错误信息") + private String errorMsg; + + /** + * 租户Id。 + * 仅用于多租户系统,是便于进行对租户的操作查询和统计分析。 + */ + @Schema(description = "租户Id") + private Long tenantId; + + /** + * 操作员Id。 + */ + @Schema(description = "操作员Id") + private Long operatorId; + + /** + * 操作员名称。 + */ + @Schema(description = "操作员名称") + private String operatorName; + + /** + * 操作时间。 + */ + @Schema(description = "操作时间") + private Date operationTime; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..dff1b36f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-log/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.orangeforms.common.log.config.CommonLogAutoConfig \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-minio/pom.xml b/OrangeFormsOpen-MybatisPlus/common/common-minio/pom.xml new file mode 100644 index 00000000..178b8c8e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-minio/pom.xml @@ -0,0 +1,29 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-minio + 1.0.0 + common-minio + jar + + + + io.minio + minio + ${minio.version} + + + com.orangeforms + common-core + 1.0.0 + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-minio/src/main/java/com/orangeforms/common/minio/config/MinioAutoConfiguration.java b/OrangeFormsOpen-MybatisPlus/common/common-minio/src/main/java/com/orangeforms/common/minio/config/MinioAutoConfiguration.java new file mode 100644 index 00000000..d89019ff --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-minio/src/main/java/com/orangeforms/common/minio/config/MinioAutoConfiguration.java @@ -0,0 +1,56 @@ +package com.orangeforms.common.minio.config; + +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.minio.wrapper.MinioTemplate; +import io.minio.BucketExistsArgs; +import io.minio.MakeBucketArgs; +import io.minio.MinioClient; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +/** + * common-minio模块的自动配置引导类。仅当配置项minio.enabled为true的时候加载。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EnableConfigurationProperties(MinioProperties.class) +@ConditionalOnProperty(prefix = "minio", name = "enabled") +public class MinioAutoConfiguration { + + /** + * 将minio原生的客户端类封装成bean对象,便于集成,同时也可以灵活使用客户端的所有功能。 + * + * @param p 属性配置对象。 + * @return minio的原生客户端对象。 + */ + @Bean + @ConditionalOnMissingBean + public MinioClient minioClient(MinioProperties p) { + try { + MinioClient client = MinioClient.builder() + .endpoint(p.getEndpoint()).credentials(p.getAccessKey(), p.getSecretKey()).build(); + if (!client.bucketExists(BucketExistsArgs.builder().bucket(p.getBucketName()).build())) { + client.makeBucket(MakeBucketArgs.builder().bucket(p.getBucketName()).build()); + } + return client; + } catch (Exception e) { + throw new MyRuntimeException(e); + } + } + + /** + * 封装的minio模板类。 + * + * @param p 属性配置对象。 + * @param c minio的原生客户端bean对象。 + * @return minio模板的bean对象。 + */ + @Bean + @ConditionalOnMissingBean + public MinioTemplate minioTemplate(MinioProperties p, MinioClient c) { + return new MinioTemplate(p, c); + } +} \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-minio/src/main/java/com/orangeforms/common/minio/config/MinioProperties.java b/OrangeFormsOpen-MybatisPlus/common/common-minio/src/main/java/com/orangeforms/common/minio/config/MinioProperties.java new file mode 100644 index 00000000..ecdf253d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-minio/src/main/java/com/orangeforms/common/minio/config/MinioProperties.java @@ -0,0 +1,32 @@ +package com.orangeforms.common.minio.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * common-minio模块的配置类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ConfigurationProperties(prefix = "minio") +public class MinioProperties { + + /** + * 访问入口地址。 + */ + private String endpoint; + /** + * 访问安全的key。 + */ + private String accessKey; + /** + * 访问安全的密钥。 + */ + private String secretKey; + /** + * 缺省桶名称。 + */ + private String bucketName; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-minio/src/main/java/com/orangeforms/common/minio/util/MinioUpDownloader.java b/OrangeFormsOpen-MybatisPlus/common/common-minio/src/main/java/com/orangeforms/common/minio/util/MinioUpDownloader.java new file mode 100644 index 00000000..9c2c71a7 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-minio/src/main/java/com/orangeforms/common/minio/util/MinioUpDownloader.java @@ -0,0 +1,115 @@ +package com.orangeforms.common.minio.util; + +import cn.hutool.core.io.IoUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.StrUtil; +import com.orangeforms.common.core.upload.UpDownloaderFactory; +import com.orangeforms.common.core.upload.UploadResponseInfo; +import com.orangeforms.common.core.upload.BaseUpDownloader; +import com.orangeforms.common.core.upload.UploadStoreTypeEnum; +import com.orangeforms.common.minio.wrapper.MinioTemplate; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; + +import jakarta.annotation.PostConstruct; +import jakarta.servlet.http.HttpServletResponse; +import java.io.*; + +/** + * 基于Minio上传和下载文件操作的工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Component +@ConditionalOnProperty(prefix = "minio", name = "enabled") +public class MinioUpDownloader extends BaseUpDownloader { + + @Autowired + private MinioTemplate minioTemplate; + @Autowired + private UpDownloaderFactory factory; + + @PostConstruct + public void doRegister() { + factory.registerUpDownloader(UploadStoreTypeEnum.MINIO_SYSTEM, this); + } + + @Override + public UploadResponseInfo doUpload( + String serviceContextPath, + String rootBaseDir, + String modelName, + String fieldName, + Boolean asImage, + MultipartFile uploadFile) throws IOException { + String uploadPath = super.makeFullPath(null, modelName, fieldName, asImage); + return this.doUploadInternally(serviceContextPath, uploadPath, asImage, uploadFile); + } + + @Override + public UploadResponseInfo doUpload( + String serviceContextPath, + String rootBaseDir, + String uriPath, + MultipartFile uploadFile) throws IOException { + String uploadPath = super.makeFullPath(null, uriPath); + return this.doUploadInternally(serviceContextPath, uploadPath, false, uploadFile); + } + + @Override + public void doDownload( + String rootBaseDir, + String modelName, + String fieldName, + String fileName, + Boolean asImage, + HttpServletResponse response) throws IOException { + String uploadPath = this.makeFullPath(null, modelName, fieldName, asImage); + String fullFileanme = uploadPath + "/" + fileName; + this.downloadInternal(fullFileanme, fileName, response); + } + + @Override + public void doDownload( + String rootBaseDir, + String uriPath, + String fileName, + HttpServletResponse response) throws IOException { + StringBuilder pathBuilder = new StringBuilder(128); + if (StrUtil.isNotBlank(uriPath)) { + pathBuilder.append(uriPath); + } + pathBuilder.append("/"); + String fullFileanme = pathBuilder.append(fileName).toString(); + this.downloadInternal(fullFileanme, fileName, response); + } + + private UploadResponseInfo doUploadInternally( + String serviceContextPath, + String uploadPath, + Boolean asImage, + MultipartFile uploadFile) throws IOException { + UploadResponseInfo responseInfo = super.verifyUploadArgument(asImage, uploadFile); + if (BooleanUtil.isTrue(responseInfo.getUploadFailed())) { + return responseInfo; + } + responseInfo.setUploadPath(uploadPath); + super.fillUploadResponseInfo(responseInfo, serviceContextPath, uploadFile.getOriginalFilename()); + minioTemplate.putObject(uploadPath + "/" + responseInfo.getFilename(), uploadFile.getInputStream()); + return responseInfo; + } + + private void downloadInternal(String fullFileanme, String fileName, HttpServletResponse response) throws IOException { + response.setHeader("content-type", "application/octet-stream"); + response.setContentType("application/octet-stream"); + response.setHeader("Content-Disposition", "attachment;filename=" + fileName); + InputStream in = minioTemplate.getStream(fullFileanme); + IoUtil.copy(in, response.getOutputStream()); + in.close(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-minio/src/main/java/com/orangeforms/common/minio/wrapper/MinioTemplate.java b/OrangeFormsOpen-MybatisPlus/common/common-minio/src/main/java/com/orangeforms/common/minio/wrapper/MinioTemplate.java new file mode 100644 index 00000000..dc29310f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-minio/src/main/java/com/orangeforms/common/minio/wrapper/MinioTemplate.java @@ -0,0 +1,199 @@ +package com.orangeforms.common.minio.wrapper; + +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.minio.config.MinioProperties; +import io.minio.*; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.FileUtils; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; + +/** + * 封装的minio客户端模板类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class MinioTemplate { + + private static final String TMP_DIR = System.getProperty("java.io.tmpdir") + File.separator; + private final MinioProperties properties; + private final MinioClient client; + + public MinioTemplate(MinioProperties properties, MinioClient client) { + super(); + this.properties = properties; + this.client = client; + } + + /** + * 判断bucket是否存在。 + * + * @param bucketName 桶名称。 + * @return 存在返回true,否则false。 + */ + public boolean bucketExists(String bucketName) { + try { + return client.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build()); + } catch (Exception e) { + throw new MyRuntimeException(e); + } + } + + /** + * 创建桶。 + * + * @param bucketName 桶名称。 + */ + public void makeBucket(String bucketName) { + try { + if (!client.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build())) { + client.makeBucket(MakeBucketArgs.builder().bucket(bucketName).build()); + } + } catch (Exception e) { + throw new MyRuntimeException(e); + } + } + + /** + * 存放对象。 + * + * @param bucketName 桶名称。 + * @param objectName 对象名称。 + * @param filename 本地上传的文件名称。 + */ + public void putObject(String bucketName, String objectName, String filename) { + try { + this.putObject(bucketName, objectName, new FileInputStream(filename)); + } catch (Exception e) { + throw new MyRuntimeException(e); + } + } + + /** + * 存放对象。桶名称为配置中的桶名称。 + * + * @param objectName 对象名称。 + * @param filename 本地上传的文件名称。 + */ + public void putObject(String objectName, String filename) { + try { + this.putObject(properties.getBucketName(), objectName, filename); + } catch (Exception e) { + throw new MyRuntimeException(e); + } + } + + /** + * 读取输入流并存放。 + * + * @param bucketName 桶名称。 + * @param objectName 对象名称。 + * @param stream 读取后上传的文件流。 + */ + public void putObject(String bucketName, String objectName, InputStream stream) { + try { + client.putObject(PutObjectArgs.builder() + .bucket(bucketName).object(objectName).stream(stream, stream.available(), -1).build()); + } catch (Exception e) { + throw new MyRuntimeException(e); + } finally { + try { + stream.close(); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + } + } + + /** + * 读取输入流并存放。 + * + * @param objectName 对象名称。 + * @param stream 读取后上传的文件流。 + */ + public void putObject(String objectName, InputStream stream) { + this.putObject(properties.getBucketName(), objectName, stream); + } + + /** + * 移除对象。 + * + * @param bucketName 桶名称。 + * @param objectName 对象名称。 + */ + public void removeObject(String bucketName, String objectName) { + try { + client.removeObject(RemoveObjectArgs.builder().bucket(bucketName).object(objectName).build()); + } catch (Exception e) { + throw new MyRuntimeException(e); + } + } + + /** + * 移除对象。桶名称为配置中的桶名称。 + * + * @param objectName 对象名称。 + */ + public void removeObject(String objectName) { + this.removeObject(properties.getBucketName(), objectName); + } + + /** + * 获取文件输入流。 + * + * @param bucket 桶名称。 + * @param objectName 对象名称。 + * @return 文件的输入流。 + */ + public InputStream getStream(String bucket, String objectName) { + try { + return client.getObject(GetObjectArgs.builder().bucket(bucket).object(objectName).build()); + } catch (Exception e) { + throw new MyRuntimeException(e); + } + } + + /** + * 获取文件输入流。 + * + * @param objectName 对象名称。 + * @return 文件的输入流。 + */ + public InputStream getStream(String objectName) { + return this.getStream(properties.getBucketName(), objectName); + } + + /** + * 获取存储的文件对象。 + * + * @param bucket 桶名称。 + * @param objectName 对象名称。 + * @return 读取后存储到文件的文件对象。 + */ + public File getFile(String bucket, String objectName) throws IOException { + InputStream in = getStream(bucket, objectName); + File dir = new File(TMP_DIR); + if (!dir.exists() || dir.isFile()) { + dir.mkdirs(); + } + File file = new File(TMP_DIR + objectName); + FileUtils.copyInputStreamToFile(in, file); + in.close(); + return file; + } + + /** + * 获取存储的文件对象。桶名称为配置中的桶名称。 + * + * @param objectName 对象名称。 + * @return 读取后存储到文件的文件对象。 + */ + public File getFile(String objectName) throws IOException { + return this.getFile(properties.getBucketName(), objectName); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-minio/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/OrangeFormsOpen-MybatisPlus/common/common-minio/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..a7ba3af4 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-minio/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.orangeforms.common.minio.config.MinioAutoConfiguration \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/pom.xml b/OrangeFormsOpen-MybatisPlus/common/common-online/pom.xml new file mode 100644 index 00000000..c653f38f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/pom.xml @@ -0,0 +1,64 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-online + 1.0.0 + common-online + jar + + + + com.orangeforms + common-satoken + 1.0.0 + + + com.orangeforms + common-dbutil + 1.0.0 + + + com.orangeforms + common-dict + 1.0.0 + + + com.orangeforms + common-datafilter + 1.0.0 + + + com.orangeforms + common-redis + 1.0.0 + + + com.orangeforms + common-sequence + 1.0.0 + + + com.orangeforms + common-log + 1.0.0 + + + com.orangeforms + common-minio + 1.0.0 + + + com.orangeforms + common-swagger + 1.0.0 + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/config/OnlineAutoConfig.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/config/OnlineAutoConfig.java new file mode 100644 index 00000000..2f18a739 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/config/OnlineAutoConfig.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.online.config; + +import org.springframework.boot.context.properties.EnableConfigurationProperties; + +/** + * common-online模块的自动配置引导类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EnableConfigurationProperties({OnlineProperties.class}) +public class OnlineAutoConfig { +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/config/OnlineProperties.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/config/OnlineProperties.java new file mode 100644 index 00000000..17308333 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/config/OnlineProperties.java @@ -0,0 +1,59 @@ +package com.orangeforms.common.online.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +import java.util.List; + +/** + * 在线表单的配置对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ConfigurationProperties(prefix = "common-online") +public class OnlineProperties { + + /** + * 脱敏字段的掩码。只能为单个字符。 + */ + private String maskChar = "*"; + /** + * 在调用render接口的时候,是否打开一级缓存加速页面渲染数据的获取。 + */ + private Boolean enableRenderCache = true; + /** + * 业务表和在线表单内置表是否跨库。 + */ + private Boolean enabledMultiDatabaseWrite = true; + /** + * 仅以该前缀开头的数据表才会成为动态表单的候选数据表,如: zz_。如果为空,则所有表均可被选。 + */ + private String tablePrefix; + /** + * 在线表单业务操作的URL前缀。 + */ + private String urlPrefix; + /** + * 在线表单打印接口的路径 + */ + private String printUrlPath; + /** + * 上传文件的根路径。 + */ + private String uploadFileBaseDir; + /** + * 1: minio 2: aliyun-oss 3: qcloud-cos。 + * 0是本地系统,不推荐使用。 + */ + private Integer distributeStoreType; + /** + * 在线表单查看权限的URL列表。 + */ + private List viewUrlList; + /** + * 在线表单编辑权限的URL列表。 + */ + private List editUrlList; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineColumnController.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineColumnController.java new file mode 100644 index 00000000..52c169db --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineColumnController.java @@ -0,0 +1,517 @@ +package com.orangeforms.common.online.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import io.swagger.v3.oas.annotations.tags.Tag; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.EnumUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.constant.MaskFieldTypeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.dbutil.object.SqlTableColumn; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.online.dto.OnlineColumnDto; +import com.orangeforms.common.online.dto.OnlineColumnRuleDto; +import com.orangeforms.common.online.dto.OnlineRuleDto; +import com.orangeforms.common.online.model.*; +import com.orangeforms.common.online.model.constant.FieldKind; +import com.orangeforms.common.online.service.*; +import com.orangeforms.common.online.vo.OnlineColumnRuleVo; +import com.orangeforms.common.online.vo.OnlineColumnVo; +import com.orangeforms.common.online.vo.OnlineRuleVo; +import com.github.pagehelper.page.PageMethod; +import lombok.extern.slf4j.Slf4j; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 在线表单字段数据接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "在线表单字段数据接口") +@Slf4j +@RestController +@RequestMapping("${common-online.urlPrefix}/onlineColumn") +@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true") +public class OnlineColumnController { + + @Autowired + private OnlineColumnService onlineColumnService; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private OnlineVirtualColumnService onlineVirtualColumnService; + @Autowired + private OnlineDblinkService onlineDblinkService; + @Autowired + private OnlineRuleService onlineRuleService; + @Autowired + private OnlineDictService onlineDictService; + + /** + * 根据数据库表字段信息,在指定在线表中添加在线表字段对象。 + * + * @param dblinkId 数据库链接Id。 + * @param tableName 数据库表名称。 + * @param columnName 数据库表字段名。 + * @param tableId 目的表Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add( + @MyRequestBody Long dblinkId, + @MyRequestBody String tableName, + @MyRequestBody String columnName, + @MyRequestBody Long tableId) { + OnlineDblink dblink = onlineDblinkService.getById(dblinkId); + if (dblink == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + String errorMessage; + SqlTableColumn sqlTableColumn = onlineDblinkService.getDblinkTableColumn(dblink, tableName, columnName); + if (sqlTableColumn == null) { + errorMessage = "数据验证失败,指定的数据表字段不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + ResponseResult verifyResult = this.doVerifyTable(tableId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + onlineColumnService.saveNewList(CollUtil.newLinkedList(sqlTableColumn), tableId); + return ResponseResult.success(); + } + + /** + * 更新字段数据数据。 + * + * @param onlineColumnDto 更新对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody OnlineColumnDto onlineColumnDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineColumnDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineColumn onlineColumn = MyModelUtil.copyTo(onlineColumnDto, OnlineColumn.class); + OnlineColumn originalOnlineColumn = onlineColumnService.getById(onlineColumn.getColumnId()); + if (originalOnlineColumn == null) { + errorMessage = "数据验证失败,当前在线表字段并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + ResponseResult verifyColumnResult = this.doVerifyColumn(onlineColumn, originalOnlineColumn); + if (!verifyColumnResult.isSuccess()) { + return ResponseResult.errorFrom(verifyColumnResult); + } + ResponseResult verifyResult = this.doVerifyTable(originalOnlineColumn.getTableId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (!onlineColumnService.update(onlineColumn, originalOnlineColumn)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 删除字段数据数据。 + * + * @param columnId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long columnId) { + String errorMessage; + if (MyCommonUtil.existBlankArgument(columnId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + // 验证关联Id的数据合法性 + OnlineColumn originalOnlineColumn = onlineColumnService.getById(columnId); + if (originalOnlineColumn == null) { + errorMessage = "数据验证失败,当前在线表字段并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + ResponseResult verifyResult = this.doVerifyTable(originalOnlineColumn.getTableId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineVirtualColumn virtualColumnFilter = new OnlineVirtualColumn(); + virtualColumnFilter.setAggregationColumnId(columnId); + List virtualColumnList = + onlineVirtualColumnService.getOnlineVirtualColumnList(virtualColumnFilter, null); + if (CollUtil.isNotEmpty(virtualColumnList)) { + OnlineVirtualColumn virtualColumn = virtualColumnList.get(0); + errorMessage = "数据验证失败,数据源关联正在被虚拟字段 [" + virtualColumn.getColumnPrompt() + "] 使用,不能被删除!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!onlineColumnService.remove(originalOnlineColumn.getTableId(), columnId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的字段数据列表。 + * + * @param onlineColumnDtoFilter 过滤对象。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("onlinePage.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody OnlineColumnDto onlineColumnDtoFilter, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlineColumn onlineColumnFilter = MyModelUtil.copyTo(onlineColumnDtoFilter, OnlineColumn.class); + List onlineColumnList = + onlineColumnService.getOnlineColumnListWithRelation(onlineColumnFilter); + return ResponseResult.success(MyPageUtil.makeResponseData(onlineColumnList, OnlineColumnVo.class)); + } + + /** + * 查看指定字段数据对象详情。 + * + * @param columnId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("onlinePage.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long columnId) { + if (MyCommonUtil.existBlankArgument(columnId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + OnlineColumn onlineColumn = onlineColumnService.getByIdWithRelation(columnId, MyRelationParam.full()); + if (onlineColumn == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(onlineColumn, OnlineColumnVo.class); + } + + /** + * 将数据库中的表字段信息刷新到已经导入的在线表字段信息。 + * + * @param dblinkId 数据库链接Id。 + * @param tableName 数据库表名称。 + * @param columnName 数据库表字段名。 + * @param columnId 被刷新的在线字段Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @PostMapping("/refresh") + public ResponseResult refresh( + @MyRequestBody Long dblinkId, + @MyRequestBody String tableName, + @MyRequestBody String columnName, + @MyRequestBody Long columnId) { + OnlineDblink dblink = onlineDblinkService.getById(dblinkId); + if (dblink == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + String errorMsg; + SqlTableColumn sqlTableColumn = onlineDblinkService.getDblinkTableColumn(dblink, tableName, columnName); + if (sqlTableColumn == null) { + errorMsg = "数据验证失败,指定的数据表字段不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMsg); + } + OnlineColumn onlineColumn = onlineColumnService.getById(columnId); + if (onlineColumn == null) { + errorMsg = "数据验证失败,指定的在线表字段Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMsg); + } + ResponseResult verifyResult = this.doVerifyTable(onlineColumn.getTableId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + onlineColumnService.refresh(sqlTableColumn, onlineColumn); + return ResponseResult.success(); + } + + /** + * 列出不与指定字段数据存在多对多关系的 [验证规则] 列表数据。通常用于查看添加新 [验证规则] 对象的候选列表。 + * + * @param columnId 主表关联字段。 + * @param onlineRuleDtoFilter [验证规则] 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,返回符合条件的数据列表。 + */ + @SaCheckPermission("onlinePage.all") + @PostMapping("/listNotInOnlineColumnRule") + public ResponseResult> listNotInOnlineColumnRule( + @MyRequestBody Long columnId, + @MyRequestBody OnlineRuleDto onlineRuleDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + ResponseResult verifyResult = this.doVerifyColumn(columnId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlineRule filter = MyModelUtil.copyTo(onlineRuleDtoFilter, OnlineRule.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineRule.class); + List onlineRuleList = + onlineRuleService.getNotInOnlineRuleListByColumnId(columnId, filter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(onlineRuleList, OnlineRuleVo.class)); + } + + /** + * 列出与指定字段数据存在多对多关系的 [验证规则] 列表数据。 + * + * @param columnId 主表关联字段。 + * @param onlineRuleDtoFilter [验证规则] 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,返回符合条件的数据列表。 + */ + @SaCheckPermission("onlinePage.all") + @PostMapping("/listOnlineColumnRule") + public ResponseResult> listOnlineColumnRule( + @MyRequestBody Long columnId, + @MyRequestBody OnlineRuleDto onlineRuleDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + ResponseResult verifyResult = this.doVerifyColumn(columnId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlineRule filter = MyModelUtil.copyTo(onlineRuleDtoFilter, OnlineRule.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineRule.class); + List onlineRuleList = + onlineRuleService.getOnlineRuleListByColumnId(columnId, filter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(onlineRuleList, OnlineRuleVo.class)); + } + + /** + * 批量添加字段数据和 [验证规则] 对象的多对多关联关系数据。 + * + * @param columnId 主表主键Id。 + * @param onlineColumnRuleDtoList 关联对象列表。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.ADD_M2M) + @PostMapping("/addOnlineColumnRule") + public ResponseResult addOnlineColumnRule( + @MyRequestBody Long columnId, @MyRequestBody List onlineColumnRuleDtoList) { + if (MyCommonUtil.existBlankArgument(columnId, onlineColumnRuleDtoList)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + String errorMessage; + for (OnlineColumnRuleDto onlineColumnRule : onlineColumnRuleDtoList) { + errorMessage = MyCommonUtil.getModelValidationError(onlineColumnRule); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + ResponseResult verifyResult = this.doVerifyColumn(columnId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + Set ruleIdSet = onlineColumnRuleDtoList.stream() + .map(OnlineColumnRuleDto::getRuleId).collect(Collectors.toSet()); + List ruleList = onlineRuleService.getInList(ruleIdSet); + if (ruleIdSet.size() != ruleList.size()) { + errorMessage = "数据验证失败,参数中存在非法字段规则Id!"; + return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID, errorMessage); + } + for (OnlineRule rule : ruleList) { + if (BooleanUtil.isFalse(rule.getBuiltin()) + && !StrUtil.equals(rule.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + errorMessage = "数据验证失败,参数中存在不属于该应用的字段规则Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + List onlineColumnRuleList = + MyModelUtil.copyCollectionTo(onlineColumnRuleDtoList, OnlineColumnRule.class); + onlineColumnService.addOnlineColumnRuleList(onlineColumnRuleList, columnId); + return ResponseResult.success(); + } + + /** + * 更新指定字段数据和指定 [验证规则] 的多对多关联数据。 + * + * @param onlineColumnRuleDto 对多对中间表对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/updateOnlineColumnRule") + public ResponseResult updateOnlineColumnRule(@MyRequestBody OnlineColumnRuleDto onlineColumnRuleDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineColumnRuleDto); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + ResponseResult verifyResult = this.doVerifyColumn(onlineColumnRuleDto.getColumnId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineColumnRule onlineColumnRule = MyModelUtil.copyTo(onlineColumnRuleDto, OnlineColumnRule.class); + if (!onlineColumnService.updateOnlineColumnRule(onlineColumnRule)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 显示字段数据和指定 [验证规则] 的多对多关联详情数据。 + * + * @param columnId 主表主键Id。 + * @param ruleId 从表主键Id。 + * @return 应答结果对象,包括中间表详情。 + */ + @SaCheckPermission("onlinePage.all") + @GetMapping("/viewOnlineColumnRule") + public ResponseResult viewOnlineColumnRule( + @RequestParam Long columnId, @RequestParam Long ruleId) { + if (MyCommonUtil.existBlankArgument(columnId, ruleId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + ResponseResult verifyResult = this.doVerifyColumn(columnId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineColumnRule onlineColumnRule = onlineColumnService.getOnlineColumnRule(columnId, ruleId); + if (onlineColumnRule == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + OnlineColumnRuleVo onlineColumnRuleVo = MyModelUtil.copyTo(onlineColumnRule, OnlineColumnRuleVo.class); + return ResponseResult.success(onlineColumnRuleVo); + } + + /** + * 移除指定字段数据和指定 [验证规则] 的多对多关联关系。 + * + * @param columnId 主表主键Id。 + * @param ruleId 从表主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.DELETE_M2M) + @PostMapping("/deleteOnlineColumnRule") + public ResponseResult deleteOnlineColumnRule(@MyRequestBody Long columnId, @MyRequestBody Long ruleId) { + if (MyCommonUtil.existBlankArgument(columnId, ruleId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + ResponseResult verifyResult = this.doVerifyColumn(columnId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (!onlineColumnService.removeOnlineColumnRule(columnId, ruleId)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 以字典形式返回全部字段数据数据集合。字典的键值为[columnId, columnName]。 + * 白名单接口,登录用户均可访问。 + * + * @param filter 过滤对象。 + * @return 应答结果对象,包含的数据为 List>,map中包含两条记录,key的值分别是id和name,value对应具体数据。 + */ + @GetMapping("/listDict") + public ResponseResult>> listDict(@ParameterObject OnlineColumnDto filter) { + List resultList = + onlineColumnService.getListByFilter(MyModelUtil.copyTo(filter, OnlineColumn.class)); + return ResponseResult.success( + MyCommonUtil.toDictDataList(resultList, OnlineColumn::getColumnId, OnlineColumn::getColumnName)); + } + + private ResponseResult doVerifyColumn(Long columnId) { + if (MyCommonUtil.existBlankArgument(columnId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + OnlineColumn onlineColumn = onlineColumnService.getById(columnId); + if (onlineColumn == null) { + return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID); + } + ResponseResult verifyResult = this.doVerifyTable(onlineColumn.getTableId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + return ResponseResult.success(); + } + + private ResponseResult doVerifyColumn(OnlineColumn onlineColumn, OnlineColumn originalOnlineColumn) { + String errorMessage; + if (onlineColumn.getDictId() != null + && ObjectUtil.notEqual(onlineColumn.getDictId(), originalOnlineColumn.getDictId())) { + OnlineDict dict = onlineDictService.getById(onlineColumn.getDictId()); + if (dict == null) { + errorMessage = "数据验证失败,关联的字典Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!StrUtil.equals(dict.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + errorMessage = "数据验证失败,关联的字典Id并不属于当前应用!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + } + if (MyCommonUtil.equalsAny(onlineColumn.getFieldKind(), FieldKind.UPLOAD, FieldKind.UPLOAD_IMAGE) + && onlineColumn.getUploadFileSystemType() == null) { + errorMessage = "数据验证失败,上传字段必须设置上传文件系统类型!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (ObjectUtil.equal(onlineColumn.getFieldKind(), FieldKind.MASK_FIELD)) { + if (onlineColumn.getMaskFieldType() == null) { + errorMessage = "数据验证失败,脱敏字段没有设置脱敏类型!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!EnumUtil.contains(MaskFieldTypeEnum.class, onlineColumn.getMaskFieldType())) { + errorMessage = "数据验证失败,脱敏字段设置的脱敏类型并不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + if (!onlineColumn.getTableId().equals(originalOnlineColumn.getTableId())) { + errorMessage = "数据验证失败,字段的所属表Id不能修改!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(); + } + + private ResponseResult doVerifyTable(Long tableId) { + String errorMessage; + OnlineTable table = onlineTableService.getById(tableId); + if (table == null) { + errorMessage = "数据验证失败,指定的数据表Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!StrUtil.equals(table.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + errorMessage = "数据验证失败,当前应用并不包含该字段所在的表!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDatasourceController.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDatasourceController.java new file mode 100644 index 00000000..18831b3b --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDatasourceController.java @@ -0,0 +1,287 @@ +package com.orangeforms.common.online.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.StrUtil; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.core.validator.AddGroup; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.dbutil.object.SqlTable; +import com.orangeforms.common.dbutil.object.SqlTableColumn; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.online.dto.OnlineDatasourceDto; +import com.orangeforms.common.online.model.*; +import com.orangeforms.common.online.model.constant.PageType; +import com.orangeforms.common.online.service.*; +import com.orangeforms.common.online.vo.OnlineDatasourceVo; +import com.orangeforms.common.online.vo.OnlineTableVo; +import com.github.pagehelper.page.PageMethod; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.dao.DuplicateKeyException; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import java.util.List; + +/** + * 在线表单数据源接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "在线表单数据源接口") +@Slf4j +@RestController +@RequestMapping("${common-online.urlPrefix}/onlineDatasource") +@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true") +public class OnlineDatasourceController { + + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private OnlineFormService onlineFormService; + @Autowired + private OnlinePageService onlinePageService; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private OnlineColumnService onlineColumnService; + @Autowired + private OnlineDblinkService onlineDblinkService; + + /** + * 新增数据模型数据。 + * + * @param onlineDatasourceDto 新增对象。 + * @param pageId 关联的页面Id。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"onlineDatasourceDto.datasourceId"}) + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add( + @MyRequestBody OnlineDatasourceDto onlineDatasourceDto, + @MyRequestBody(required = true) Long pageId) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineDatasourceDto, Default.class, AddGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlinePage onlinePage = onlinePageService.getById(pageId); + if (onlinePage == null) { + errorMessage = "数据验证失败,页面Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + String appCode = TokenData.takeFromRequest().getAppCode(); + if (!StrUtil.equals(onlinePage.getAppCode(), appCode)) { + errorMessage = "数据验证失败,当前应用并不存在该页面!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineDatasource onlineDatasource = MyModelUtil.copyTo(onlineDatasourceDto, OnlineDatasource.class); + if (onlineDatasourceService.existByVariableName(onlineDatasource.getVariableName())) { + errorMessage = "数据验证失败,当前数据源变量已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage); + } + OnlineDblink onlineDblink = onlineDblinkService.getById(onlineDatasourceDto.getDblinkId()); + if (onlineDblink == null) { + errorMessage = "数据验证失败,关联的数据库链接Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!StrUtil.equals(onlineDblink.getAppCode(), appCode)) { + errorMessage = "数据验证失败,当前应用并不存在该数据库链接!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + SqlTable sqlTable = onlineDblinkService.getDblinkTable(onlineDblink, onlineDatasourceDto.getMasterTableName()); + if (sqlTable == null) { + errorMessage = "数据验证失败,指定的数据表名不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + ResponseResult verifyResult = this.doVerifyPrimaryKey(sqlTable, onlinePage); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + try { + onlineDatasource = onlineDatasourceService.saveNew(onlineDatasource, sqlTable, pageId); + } catch (DuplicateKeyException e) { + errorMessage = "数据验证失败,当前应用的数据源变量名已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(onlineDatasource.getDatasourceId()); + } + + /** + * 更新数据模型数据。 + * + * @param onlineDatasourceDto 更新对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody OnlineDatasourceDto onlineDatasourceDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineDatasourceDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineDatasource onlineDatasource = MyModelUtil.copyTo(onlineDatasourceDto, OnlineDatasource.class); + ResponseResult verifyResult = this.doVerifyAndGet(onlineDatasource.getDatasourceId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDatasource originalOnlineDatasource = verifyResult.getData(); + if (!onlineDatasource.getDblinkId().equals(originalOnlineDatasource.getDblinkId())) { + errorMessage = "数据验证失败,不能修改数据库链接Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!onlineDatasource.getMasterTableId().equals(originalOnlineDatasource.getMasterTableId())) { + errorMessage = "数据验证失败,不能修改主表Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!StrUtil.equals(onlineDatasource.getVariableName(), originalOnlineDatasource.getVariableName()) + && onlineDatasourceService.existByVariableName(onlineDatasource.getVariableName())) { + errorMessage = "数据验证失败,当前数据源变量已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage); + } + try { + if (!onlineDatasourceService.update(onlineDatasource, originalOnlineDatasource)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + } catch (DuplicateKeyException e) { + errorMessage = "数据验证失败,当前应用的数据源变量名已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 删除数据模型数据。 + * + * @param datasourceId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long datasourceId) { + String errorMessage; + if (MyCommonUtil.existBlankArgument(datasourceId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + ResponseResult verifyResult = this.doVerifyAndGet(datasourceId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + List formList = onlineFormService.getOnlineFormListByDatasourceId(datasourceId); + if (CollUtil.isNotEmpty(formList)) { + errorMessage = "数据验证失败,当前数据源正在被 [" + formList.get(0).getFormName() + "] 表单占用,请先删除关联数据!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!onlineDatasourceService.remove(datasourceId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的数据模型列表。 + * + * @param onlineDatasourceDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("onlinePage.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody OnlineDatasourceDto onlineDatasourceDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlineDatasource onlineDatasourceFilter = MyModelUtil.copyTo(onlineDatasourceDtoFilter, OnlineDatasource.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineDatasource.class); + List onlineDatasourceList = + onlineDatasourceService.getOnlineDatasourceListWithRelation(onlineDatasourceFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(onlineDatasourceList, OnlineDatasourceVo.class)); + } + + /** + * 查看指定数据模型对象详情。 + * + * @param datasourceId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("onlinePage.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long datasourceId) { + ResponseResult verifyResult = this.doVerifyAndGet(datasourceId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDatasource onlineDatasource = + onlineDatasourceService.getByIdWithRelation(datasourceId, MyRelationParam.full()); + OnlineDatasourceVo onlineDatasourceVo = MyModelUtil.copyTo(onlineDatasource, OnlineDatasourceVo.class); + List tableList = onlineTableService.getOnlineTableListByDatasourceId(datasourceId); + if (CollUtil.isNotEmpty(tableList)) { + onlineDatasourceVo.setTableList(MyModelUtil.copyCollectionTo(tableList, OnlineTableVo.class)); + } + return ResponseResult.success(onlineDatasourceVo); + } + + private ResponseResult doVerifyAndGet(Long datasourceId) { + if (MyCommonUtil.existBlankArgument(datasourceId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + OnlineDatasource onlineDatasource = onlineDatasourceService.getById(datasourceId); + if (onlineDatasource == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + if (!StrUtil.equals(onlineDatasource.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, "数据验证失败,当前应用并不存在该数据源!"); + } + return ResponseResult.success(onlineDatasource); + } + + private ResponseResult doVerifyPrimaryKey(SqlTable sqlTable, OnlinePage onlinePage) { + String errorMessage; + boolean hasPrimaryKey = false; + for (SqlTableColumn tableColumn : sqlTable.getColumnList()) { + if (BooleanUtil.isFalse(tableColumn.getPrimaryKey())) { + continue; + } + if (hasPrimaryKey) { + errorMessage = "数据验证失败,数据表只能包含一个主键字段!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + hasPrimaryKey = true; + // 流程表单的主表主键,不能是自增主键。 + if (BooleanUtil.isTrue(tableColumn.getAutoIncrement()) + && onlinePage.getPageType().equals(PageType.FLOW)) { + errorMessage = "数据验证失败,流程页面所关联的主表主键,不能是自增主键!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + CallResult verifyResult = onlineColumnService.verifyPrimaryKey(tableColumn); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + } + if (!hasPrimaryKey) { + errorMessage = "数据验证失败,数据表必须包含主键字段!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDatasourceRelationController.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDatasourceRelationController.java new file mode 100644 index 00000000..31755e57 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDatasourceRelationController.java @@ -0,0 +1,260 @@ +package com.orangeforms.common.online.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.core.validator.AddGroup; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.dbutil.object.SqlTable; +import com.orangeforms.common.dbutil.object.SqlTableColumn; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.online.dto.OnlineDatasourceRelationDto; +import com.orangeforms.common.online.model.*; +import com.orangeforms.common.online.service.*; +import com.orangeforms.common.online.vo.OnlineDatasourceRelationVo; +import com.github.pagehelper.page.PageMethod; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import java.util.List; + +/** + * 在线表单数据源关联接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "在线表单数据源关联接口") +@Slf4j +@RestController +@RequestMapping("${common-online.urlPrefix}/onlineDatasourceRelation") +@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true") +public class OnlineDatasourceRelationController { + + @Autowired + private OnlineDatasourceRelationService onlineDatasourceRelationService; + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private OnlineVirtualColumnService onlineVirtualColumnService; + @Autowired + private OnlineDblinkService onlineDblinkService; + @Autowired + private OnlineFormService onlineFormService; + + /** + * 新增数据关联数据。 + * + * @param onlineDatasourceRelationDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"onlineDatasourceRelationDto.relationId"}) + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody OnlineDatasourceRelationDto onlineDatasourceRelationDto) { + String errorMessage = MyCommonUtil.getModelValidationError( + onlineDatasourceRelationDto, Default.class, AddGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineDatasourceRelation onlineDatasourceRelation = + MyModelUtil.copyTo(onlineDatasourceRelationDto, OnlineDatasourceRelation.class); + OnlineDatasource onlineDatasource = + onlineDatasourceService.getById(onlineDatasourceRelationDto.getDatasourceId()); + if (onlineDatasource == null) { + errorMessage = "数据验证失败,关联的数据源Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + String appCode = TokenData.takeFromRequest().getAppCode(); + if (!StrUtil.equals(onlineDatasource.getAppCode(), appCode)) { + errorMessage = "数据验证失败,当前应用并不包含该数据源Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineDblink onlineDblink = onlineDblinkService.getById(onlineDatasource.getDblinkId()); + SqlTable slaveTable = onlineDblinkService.getDblinkTable( + onlineDblink, onlineDatasourceRelationDto.getSlaveTableName()); + if (slaveTable == null) { + errorMessage = "数据验证失败,指定的数据表不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + SqlTableColumn slaveColumn = null; + for (SqlTableColumn column : slaveTable.getColumnList()) { + if (column.getColumnName().equals(onlineDatasourceRelationDto.getSlaveColumnName())) { + slaveColumn = column; + break; + } + } + if (slaveColumn == null) { + errorMessage = "数据验证失败,指定的数据表字段 [" + onlineDatasourceRelationDto.getSlaveColumnName() + "] 不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + // 验证关联Id的数据合法性 + CallResult callResult = + onlineDatasourceRelationService.verifyRelatedData(onlineDatasourceRelation, null); + if (!callResult.isSuccess()) { + errorMessage = callResult.getErrorMessage(); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + onlineDatasourceRelation = onlineDatasourceRelationService.saveNew(onlineDatasourceRelation, slaveTable, slaveColumn); + return ResponseResult.success(onlineDatasourceRelation.getRelationId()); + } + + /** + * 更新数据关联数据。 + * + * @param onlineDatasourceRelationDto 更新对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody OnlineDatasourceRelationDto onlineDatasourceRelationDto) { + String errorMessage = MyCommonUtil.getModelValidationError( + onlineDatasourceRelationDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineDatasourceRelation onlineDatasourceRelation = + MyModelUtil.copyTo(onlineDatasourceRelationDto, OnlineDatasourceRelation.class); + ResponseResult verifyResult = + this.doVerifyAndGet(onlineDatasourceRelation.getRelationId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDatasourceRelation originalOnlineDatasourceRelation = verifyResult.getData(); + if (!onlineDatasourceRelationDto.getRelationType().equals(originalOnlineDatasourceRelation.getRelationType())) { + errorMessage = "数据验证失败,不能修改关联类型!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!onlineDatasourceRelationDto.getSlaveTableId().equals(originalOnlineDatasourceRelation.getSlaveTableId())) { + errorMessage = "数据验证失败,不能修改从表Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!onlineDatasourceRelationDto.getDatasourceId().equals(originalOnlineDatasourceRelation.getDatasourceId())) { + errorMessage = "数据验证失败,不能修改数据源Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + // 验证关联Id的数据合法性 + CallResult callResult = onlineDatasourceRelationService + .verifyRelatedData(onlineDatasourceRelation, originalOnlineDatasourceRelation); + if (!callResult.isSuccess()) { + errorMessage = callResult.getErrorMessage(); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!onlineDatasourceRelationService.update(onlineDatasourceRelation, originalOnlineDatasourceRelation)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 删除数据关联数据。 + * + * @param relationId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long relationId) { + String errorMessage; + ResponseResult verifyResult = this.doVerifyAndGet(relationId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDatasourceRelation onlineDatasourceRelation = verifyResult.getData(); + OnlineVirtualColumn virtualColumnFilter = new OnlineVirtualColumn(); + virtualColumnFilter.setRelationId(relationId); + List virtualColumnList = + onlineVirtualColumnService.getOnlineVirtualColumnList(virtualColumnFilter, null); + if (CollUtil.isNotEmpty(virtualColumnList)) { + OnlineVirtualColumn virtualColumn = virtualColumnList.get(0); + errorMessage = "数据验证失败,数据源关联正在被虚拟字段 [" + virtualColumn.getColumnPrompt() + "] 使用,不能被删除!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + List formList = + onlineFormService.getOnlineFormListByTableId(onlineDatasourceRelation.getSlaveTableId()); + if (CollUtil.isNotEmpty(formList)) { + errorMessage = "数据验证失败,当前数据源关联正在被 [" + formList.get(0).getFormName() + "] 表单占用,请先删除关联数据!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!onlineDatasourceRelationService.remove(relationId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的数据关联列表。 + * + * @param onlineDatasourceRelationDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分 页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("onlinePage.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody OnlineDatasourceRelationDto onlineDatasourceRelationDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlineDatasourceRelation onlineDatasourceRelationFilter = + MyModelUtil.copyTo(onlineDatasourceRelationDtoFilter, OnlineDatasourceRelation.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineDatasourceRelation.class); + List onlineDatasourceRelationList = + onlineDatasourceRelationService.getOnlineDatasourceRelationListWithRelation(onlineDatasourceRelationFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(onlineDatasourceRelationList, OnlineDatasourceRelationVo.class)); + } + + /** + * 查看指定数据关联对象详情。 + * + * @param relationId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("onlinePage.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long relationId) { + ResponseResult verifyResult = this.doVerifyAndGet(relationId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDatasourceRelation onlineDatasourceRelation = + onlineDatasourceRelationService.getByIdWithRelation(relationId, MyRelationParam.full()); + return ResponseResult.success(onlineDatasourceRelation, OnlineDatasourceRelationVo.class); + } + + private ResponseResult doVerifyAndGet(Long relationId) { + String errorMessage; + if (MyCommonUtil.existBlankArgument(relationId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + OnlineDatasourceRelation relation = + onlineDatasourceRelationService.getByIdWithRelation(relationId, MyRelationParam.full()); + if (relation == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + if (!StrUtil.equals(relation.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + errorMessage = "数据验证失败,当前应用不包含该数据源关联!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(relation); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDblinkController.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDblinkController.java new file mode 100644 index 00000000..60447f1e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDblinkController.java @@ -0,0 +1,276 @@ +package com.orangeforms.common.online.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import io.swagger.v3.oas.annotations.tags.Tag; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.dbutil.object.SqlTable; +import com.orangeforms.common.dbutil.object.SqlTableColumn; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.online.dto.OnlineDblinkDto; +import com.orangeforms.common.online.model.OnlineDblink; +import com.orangeforms.common.online.service.OnlineDblinkService; +import com.orangeforms.common.online.util.OnlineDataSourceUtil; +import com.orangeforms.common.online.vo.OnlineDblinkVo; +import com.github.pagehelper.page.PageMethod; +import lombok.extern.slf4j.Slf4j; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +/** + * 在线表单数据库链接接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "在线表单数据库链接接口") +@Slf4j +@RestController +@RequestMapping("${common-online.urlPrefix}/onlineDblink") +@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true") +public class OnlineDblinkController { + + @Autowired + private OnlineDblinkService onlineDblinkService; + @Autowired + private OnlineDataSourceUtil dataSourceUtil; + + /** + * 新增数据库链接数据。 + * + * @param onlineDblinkDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @SaCheckPermission("onlineDblink.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody OnlineDblinkDto onlineDblinkDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineDblinkDto, false); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineDblink onlineDblink = MyModelUtil.copyTo(onlineDblinkDto, OnlineDblink.class); + onlineDblink = onlineDblinkService.saveNew(onlineDblink); + return ResponseResult.success(onlineDblink.getDblinkId()); + } + + /** + * 更新数据库链接数据。 + * + * @param onlineDblinkDto 更新对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlineDblink.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody OnlineDblinkDto onlineDblinkDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineDblinkDto, true); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineDblink onlineDblink = MyModelUtil.copyTo(onlineDblinkDto, OnlineDblink.class); + ResponseResult verifyResult = this.doVerifyAndGet(onlineDblinkDto.getDblinkId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDblink originalOnlineDblink = verifyResult.getData(); + if (ObjectUtil.notEqual(onlineDblink.getDblinkType(), originalOnlineDblink.getDblinkType())) { + errorMessage = "数据验证失败,不能修改数据库类型!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + String passwdKey = "password"; + JSONObject configJson = JSON.parseObject(onlineDblink.getConfiguration()); + String password = configJson.getString(passwdKey); + if (StrUtil.isNotBlank(password) && StrUtil.isAllCharMatch(password, c -> '*' == c)) { + password = JSON.parseObject(originalOnlineDblink.getConfiguration()).getString(passwdKey); + configJson.put(passwdKey, password); + onlineDblink.setConfiguration(configJson.toJSONString()); + } + if (!onlineDblinkService.update(onlineDblink, originalOnlineDblink)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 删除数据库链接数据。 + * + * @param dblinkId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlineDblink.all") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long dblinkId) { + String errorMessage; + // 验证关联Id的数据合法性 + ResponseResult verifyResult = this.doVerifyAndGet(dblinkId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (!onlineDblinkService.remove(dblinkId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的数据库链接列表。 + * + * @param onlineDblinkDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("onlineDblink.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody OnlineDblinkDto onlineDblinkDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlineDblink onlineDblinkFilter = MyModelUtil.copyTo(onlineDblinkDtoFilter, OnlineDblink.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineDblink.class); + List onlineDblinkList = + onlineDblinkService.getOnlineDblinkListWithRelation(onlineDblinkFilter, orderBy); + for (OnlineDblink dblink : onlineDblinkList) { + this.maskOffPassword(dblink); + } + return ResponseResult.success(MyPageUtil.makeResponseData(onlineDblinkList, OnlineDblinkVo.class)); + } + + /** + * 查看指定数据库链接对象详情。 + * + * @param dblinkId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("onlineDblink.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long dblinkId) { + ResponseResult verifyResult = this.doVerifyAndGet(dblinkId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDblink onlineDblink = verifyResult.getData(); + onlineDblinkService.buildRelationForData(onlineDblink, MyRelationParam.full()); + if (!StrUtil.equals(onlineDblink.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, "数据验证失败,当前应用并不存在该数据库链接!"); + } + this.maskOffPassword(onlineDblink); + return ResponseResult.success(onlineDblink, OnlineDblinkVo.class); + } + + /** + * 获取指定数据库链接下的所有动态表单依赖的数据表列表。 + * + * @param dblinkId 数据库链接Id。 + * @return 所有动态表单依赖的数据表列表 + */ + @SaCheckPermission("onlineDblink.all") + @GetMapping("/listDblinkTables") + public ResponseResult> listDblinkTables(@RequestParam Long dblinkId) { + OnlineDblink dblink = onlineDblinkService.getById(dblinkId); + if (dblink == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(onlineDblinkService.getDblinkTableList(dblink)); + } + + /** + * 获取指定数据库链接下,指定数据表的所有字段信息。 + * + * @param dblinkId 数据库链接Id。 + * @param tableName 表名。 + * @return 该表的所有字段列表。 + */ + @SaCheckPermission("onlineDblink.all") + @GetMapping("/listDblinkTableColumns") + public ResponseResult> listDblinkTableColumns( + @RequestParam Long dblinkId, @RequestParam String tableName) { + OnlineDblink dblink = onlineDblinkService.getById(dblinkId); + if (dblink == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(onlineDblinkService.getDblinkTableColumnList(dblink, tableName)); + } + + /** + * 测试数据库链接的接口。 + * + * @return 应答结果。 + */ + @GetMapping("/testConnection") + public ResponseResult testConnection(@RequestParam Long dblinkId) { + ResponseResult verifyAndGet = this.doVerifyAndGet(dblinkId); + if (!verifyAndGet.isSuccess()) { + return ResponseResult.errorFrom(verifyAndGet); + } + try { + dataSourceUtil.testConnection(dblinkId); + return ResponseResult.success(); + } catch (Exception e) { + log.error("Failed to test connection with ONLINE_DBLINK_ID [" + dblinkId + "]!", e); + return ResponseResult.error(ErrorCodeEnum.DATA_ACCESS_FAILED, "数据库连接失败!"); + } + } + + /** + * 以字典形式返回全部数据库链接数据集合。字典的键值为[dblinkId, dblinkName]。 + * 白名单接口,登录用户均可访问。 + * + * @param filter 过滤对象。 + * @return 应答结果对象,包含的数据为 List>,map中包含两条记录,key的值分别是id和name,value对应具体数据。 + */ + @GetMapping("/listDict") + public ResponseResult>> listDict(@ParameterObject OnlineDblinkDto filter) { + List resultList = + onlineDblinkService.getOnlineDblinkList(MyModelUtil.copyTo(filter, OnlineDblink.class), null); + return ResponseResult.success( + MyCommonUtil.toDictDataList(resultList, OnlineDblink::getDblinkId, OnlineDblink::getDblinkName)); + } + + private ResponseResult doVerifyAndGet(Long dblinkId) { + if (MyCommonUtil.existBlankArgument(dblinkId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + OnlineDblink onlineDblink = onlineDblinkService.getById(dblinkId); + if (onlineDblink == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + if (!StrUtil.equals(onlineDblink.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + return ResponseResult.error( + ErrorCodeEnum.DATA_VALIDATED_FAILED, "数据验证失败,当前应用并不存在该数据库链接!"); + } + return ResponseResult.success(onlineDblink); + } + + private void maskOffPassword(OnlineDblink dblink) { + String passwdKey = "password"; + JSONObject configJson = JSON.parseObject(dblink.getConfiguration()); + if (configJson.containsKey(passwdKey)) { + String password = configJson.getString(passwdKey); + if (StrUtil.isNotBlank(password)) { + configJson.put(passwdKey, StrUtil.repeat('*', password.length())); + dblink.setConfiguration(configJson.toJSONString()); + } + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDictController.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDictController.java new file mode 100644 index 00000000..3b31c21b --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineDictController.java @@ -0,0 +1,221 @@ +package com.orangeforms.common.online.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.dict.dto.GlobalDictDto; +import com.orangeforms.common.dict.util.GlobalDictOperationHelper; +import com.orangeforms.common.dict.vo.GlobalDictVo; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.online.dto.OnlineDictDto; +import com.orangeforms.common.online.model.OnlineColumn; +import com.orangeforms.common.online.model.OnlineDict; +import com.orangeforms.common.online.model.OnlineTable; +import com.orangeforms.common.online.service.OnlineColumnService; +import com.orangeforms.common.online.service.OnlineTableService; +import com.orangeforms.common.online.service.OnlineDictService; +import com.orangeforms.common.online.vo.OnlineDictVo; +import com.github.pagehelper.page.PageMethod; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import java.util.List; + +/** + * 在线表单字典接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "在线表单字典接口") +@Slf4j +@RestController +@RequestMapping("${common-online.urlPrefix}/onlineDict") +@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true") +public class OnlineDictController { + + @Autowired + private OnlineDictService onlineDictService; + @Autowired + private OnlineColumnService onlineColumnService; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private GlobalDictOperationHelper globalDictOperationHelper; + + /** + * 新增在线表单字典数据。 + * + * @param onlineDictDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"onlineDictDto.dictId"}) + @SaCheckPermission("onlineDict.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody OnlineDictDto onlineDictDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineDictDto); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineDict onlineDict = MyModelUtil.copyTo(onlineDictDto, OnlineDict.class); + // 验证关联Id的数据合法性 + CallResult callResult = onlineDictService.verifyRelatedData(onlineDict, null); + if (!callResult.isSuccess()) { + errorMessage = callResult.getErrorMessage(); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + onlineDict = onlineDictService.saveNew(onlineDict); + return ResponseResult.success(onlineDict.getDictId()); + } + + /** + * 更新在线表单字典数据。 + * + * @param onlineDictDto 更新对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlineDict.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody OnlineDictDto onlineDictDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineDictDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineDict onlineDict = MyModelUtil.copyTo(onlineDictDto, OnlineDict.class); + ResponseResult verifyResult = this.doVerifyAndGet(onlineDict.getDictId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDict originalOnlineDict = verifyResult.getData(); + // 验证关联Id的数据合法性 + CallResult callResult = onlineDictService.verifyRelatedData(onlineDict, originalOnlineDict); + if (!callResult.isSuccess()) { + errorMessage = callResult.getErrorMessage(); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!onlineDictService.update(onlineDict, originalOnlineDict)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 删除在线表单字典数据。 + * + * @param dictId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlineDict.all") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long dictId) { + String errorMessage; + ResponseResult verifyResult = this.doVerifyAndGet(dictId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineColumn filter = new OnlineColumn(); + filter.setDictId(dictId); + List columns = onlineColumnService.getListByFilter(filter); + if (CollUtil.isNotEmpty(columns)) { + OnlineColumn usingColumn = columns.get(0); + OnlineTable table = onlineTableService.getById(usingColumn.getTableId()); + errorMessage = String.format("数据验证失败,数据表 [%s] 字段 [%s] 正在引用该字典,因此不能直接删除!", + table.getTableName(), usingColumn.getColumnName()); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!onlineDictService.remove(dictId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的在线表单字典列表。 + * + * @param onlineDictDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("onlineDict.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody OnlineDictDto onlineDictDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlineDict onlineDictFilter = MyModelUtil.copyTo(onlineDictDtoFilter, OnlineDict.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineDict.class); + List onlineDictList = onlineDictService.getOnlineDictListWithRelation(onlineDictFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(onlineDictList, OnlineDictVo.class)); + } + + /** + * 查看指定在线表单字典对象详情。 + * + * @param dictId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("onlineDict.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long dictId) { + ResponseResult verifyResult = this.doVerifyAndGet(dictId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDict onlineDict = onlineDictService.getByIdWithRelation(dictId, MyRelationParam.full()); + if (onlineDict == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(onlineDict, OnlineDictVo.class); + } + + /** + * 获取全部编码字典列表。 + * NOTE: 白名单接口。 + * + * @param globalDictDtoFilter 过滤对象。 + * @param pageParam 分页参数。 + * @return 字典的数据列表。 + */ + @PostMapping("/listAllGlobalDict") + public ResponseResult> listAllGlobalDict( + @MyRequestBody GlobalDictDto globalDictDtoFilter, + @MyRequestBody MyPageParam pageParam) { + return globalDictOperationHelper.listAllGlobalDict(globalDictDtoFilter, pageParam); + } + + private ResponseResult doVerifyAndGet(Long dictId) { + if (MyCommonUtil.existBlankArgument(dictId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + OnlineDict originalDict = onlineDictService.getById(dictId); + if (originalDict == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + if (!StrUtil.equals(originalDict.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + return ResponseResult.error( + ErrorCodeEnum.DATA_VALIDATED_FAILED, "数据验证失败,当前应用不存在该在线表单字典!"); + } + return ResponseResult.success(originalDict); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineFormController.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineFormController.java new file mode 100644 index 00000000..921ffee7 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineFormController.java @@ -0,0 +1,428 @@ +package com.orangeforms.common.online.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.cache.CacheConfig; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.online.config.OnlineProperties; +import com.orangeforms.common.online.dto.OnlineFormDto; +import com.orangeforms.common.online.model.*; +import com.orangeforms.common.online.service.*; +import com.orangeforms.common.online.vo.OnlineFormVo; +import com.github.pagehelper.page.PageMethod; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.util.Assert; +import org.springframework.web.bind.annotation.*; + +import jakarta.annotation.Resource; +import jakarta.validation.groups.Default; +import java.util.HashSet; +import java.util.List; +import java.util.LinkedList; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 在线表单表单接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "在线表单表单接口") +@Slf4j +@RestController +@RequestMapping("${common-online.urlPrefix}/onlineForm") +@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true") +public class OnlineFormController { + + @Autowired + private OnlineFormService onlineFormService; + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private OnlineDatasourceRelationService onlineDatasourceRelationService; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private OnlineColumnService onlineColumnService; + @Autowired + private OnlineVirtualColumnService onlineVirtualColumnService; + @Autowired + private OnlineDictService onlineDictService; + @Autowired + private OnlineRuleService onlineRuleService; + @Autowired + private OnlineProperties properties; + @Resource(name = "caffeineCacheManager") + private CacheManager cacheManager; + + /** + * 新增在线表单数据。 + * + * @param onlineFormDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"onlineFormDto.formId"}) + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody OnlineFormDto onlineFormDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineFormDto); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineForm onlineForm = MyModelUtil.copyTo(onlineFormDto, OnlineForm.class); + if (onlineFormService.existByFormCode(onlineForm.getFormCode())) { + errorMessage = "数据验证失败,表单编码已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage); + } + // 验证关联Id的数据合法性 + CallResult callResult = onlineFormService.verifyRelatedData(onlineForm, null); + if (!callResult.isSuccess()) { + errorMessage = callResult.getErrorMessage(); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + Set datasourceIdSet = null; + if (CollUtil.isNotEmpty(onlineFormDto.getDatasourceIdList())) { + ResponseResult> verifyDatasourceIdsResult = + this.doVerifyDatasourceIdsAndGet(onlineFormDto.getDatasourceIdList()); + if (!verifyDatasourceIdsResult.isSuccess()) { + return ResponseResult.errorFrom(verifyDatasourceIdsResult); + } + datasourceIdSet = verifyDatasourceIdsResult.getData(); + } + onlineForm = onlineFormService.saveNew(onlineForm, datasourceIdSet); + return ResponseResult.success(onlineForm.getFormId()); + } + + /** + * 更新在线表单数据。 + * + * @param onlineFormDto 更新对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody OnlineFormDto onlineFormDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineFormDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineForm onlineForm = MyModelUtil.copyTo(onlineFormDto, OnlineForm.class); + ResponseResult verifyResult = this.doVerifyAndGet(onlineForm.getFormId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineForm originalOnlineForm = verifyResult.getData(); + // 验证关联Id的数据合法性 + CallResult callResult = onlineFormService.verifyRelatedData(onlineForm, originalOnlineForm); + if (!callResult.isSuccess()) { + errorMessage = callResult.getErrorMessage(); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!StrUtil.equals(onlineForm.getFormCode(), originalOnlineForm.getFormCode()) + && onlineFormService.existByFormCode(onlineForm.getFormCode())) { + errorMessage = "数据验证失败,表单编码已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage); + } + Set datasourceIdSet = null; + if (CollUtil.isNotEmpty(onlineFormDto.getDatasourceIdList())) { + ResponseResult> verifyDatasourceIdsResult = + this.doVerifyDatasourceIdsAndGet(onlineFormDto.getDatasourceIdList()); + if (!verifyDatasourceIdsResult.isSuccess()) { + return ResponseResult.errorFrom(verifyDatasourceIdsResult); + } + datasourceIdSet = verifyDatasourceIdsResult.getData(); + } + if (!onlineFormService.update(onlineForm, originalOnlineForm, datasourceIdSet)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 删除在线表单数据。 + * + * @param formId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long formId) { + String errorMessage; + ResponseResult verifyResult = this.doVerifyAndGet(formId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (!onlineFormService.remove(formId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 克隆一个在线表单对象。 + * + * @param formId 源表单主键Id。 + * @return 新克隆表单主键Id。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/clone") + public ResponseResult clone(@MyRequestBody Long formId) { + ResponseResult verifyResult = this.doVerifyAndGet(formId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineForm form = verifyResult.getData(); + form.setFormName(form.getFormName() + "_copy"); + form.setFormCode(form.getFormCode() + "_copy_" + System.currentTimeMillis()); + List formDatasourceList = onlineFormService.getFormDatasourceListFromCache(formId); + Set datasourceIdSet = formDatasourceList.stream() + .map(OnlineFormDatasource::getDatasourceId).collect(Collectors.toSet()); + onlineFormService.saveNew(form, datasourceIdSet); + return ResponseResult.success(form.getFormId()); + } + + /** + * 列出符合过滤条件的在线表单列表。 + * + * @param onlineFormDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("onlinePage.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody OnlineFormDto onlineFormDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlineForm onlineFormFilter = MyModelUtil.copyTo(onlineFormDtoFilter, OnlineForm.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineForm.class); + List onlineFormList = + onlineFormService.getOnlineFormListWithRelation(onlineFormFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(onlineFormList, OnlineFormVo.class)); + } + + /** + * 查看指定在线表单对象详情。 + * + * @param formId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("onlinePage.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long formId) { + ResponseResult verifyResult = this.doVerifyAndGet(formId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineForm onlineForm = onlineFormService.getByIdWithRelation(formId, MyRelationParam.full()); + OnlineFormVo onlineFormVo = MyModelUtil.copyTo(onlineForm, OnlineFormVo.class); + List formDatasourceList = onlineFormService.getFormDatasourceListFromCache(formId); + if (CollUtil.isNotEmpty(formDatasourceList)) { + onlineFormVo.setDatasourceIdList(formDatasourceList.stream() + .map(OnlineFormDatasource::getDatasourceId).collect(Collectors.toList())); + } + return ResponseResult.success(onlineFormVo); + } + + /** + * 获取指定在线表单对象在前端渲染时所需的所有数据对象。 + * + * @param formId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @GetMapping("/render") + public ResponseResult render(@RequestParam Long formId) { + String errorMessage; + Cache cache = null; + if (BooleanUtil.isTrue(properties.getEnableRenderCache())) { + cache = cacheManager.getCache(CacheConfig.CacheEnum.ONLINE_FORM_RENDER_CACCHE.name()); + Assert.notNull(cache, "Cache ONLINE_FORM_RENDER_CACCHE can't be NULL"); + JSONObject responseData = cache.get(formId, JSONObject.class); + if (responseData != null) { + Object appCode = responseData.get("appCode"); + if (ObjectUtil.notEqual(appCode, TokenData.takeFromRequest().getAppCode())) { + errorMessage = "数据验证失败,当前应用不包含该表单Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(responseData); + } + } + OnlineForm onlineForm = onlineFormService.getOnlineFormFromCache(formId); + if (onlineForm == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + OnlineFormVo onlineFormVo = MyModelUtil.copyTo(onlineForm, OnlineFormVo.class); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("onlineForm", onlineFormVo); + List formDatasourceList = onlineFormService.getFormDatasourceListFromCache(formId); + if (CollUtil.isEmpty(formDatasourceList)) { + return ResponseResult.success(jsonObject); + } + Set datasourceIdSet = formDatasourceList.stream() + .map(OnlineFormDatasource::getDatasourceId).collect(Collectors.toSet()); + List onlineDatasourceList = + onlineDatasourceService.getOnlineDatasourceListFromCache(datasourceIdSet); + jsonObject.put("onlineDatasourceList", onlineDatasourceList); + Set tableIdSet = onlineDatasourceList.stream() + .map(OnlineDatasource::getMasterTableId).collect(Collectors.toSet()); + List onlineDatasourceRelationList = + onlineDatasourceRelationService.getOnlineDatasourceRelationListFromCache(datasourceIdSet); + if (CollUtil.isNotEmpty(onlineDatasourceRelationList)) { + jsonObject.put("onlineDatasourceRelationList", onlineDatasourceRelationList); + tableIdSet.addAll(onlineDatasourceRelationList.stream() + .map(OnlineDatasourceRelation::getSlaveTableId).collect(Collectors.toList())); + } + List onlineTableList = new LinkedList<>(); + List onlineColumnList = new LinkedList<>(); + for (Long tableId : tableIdSet) { + OnlineTable table = onlineTableService.getOnlineTableFromCache(tableId); + onlineTableList.add(table); + onlineColumnList.addAll(table.getColumnMap().values()); + table.setColumnMap(null); + } + jsonObject.put("onlineTableList", onlineTableList); + jsonObject.put("onlineColumnList", onlineColumnList); + List virtualColumnList = + onlineVirtualColumnService.getOnlineVirtualColumnListByTableIds(tableIdSet); + jsonObject.put("onlineVirtualColumnList", virtualColumnList); + Set dictIdSet = onlineColumnList.stream() + .filter(c -> c.getDictId() != null).map(OnlineColumn::getDictId).collect(Collectors.toSet()); + Set widgetDictIdSet = this.extractDictIdSetFromWidgetJson(onlineForm.getWidgetJson()); + CollUtil.addAll(dictIdSet, widgetDictIdSet); + if (CollUtil.isNotEmpty(dictIdSet)) { + List onlineDictList = onlineDictService.getOnlineDictListFromCache(dictIdSet); + if (onlineDictList.size() != dictIdSet.size()) { + Set columnDictIdSet = onlineDictList.stream().map(OnlineDict::getDictId).collect(Collectors.toSet()); + Long notExistDictId = this.findNotExistDictId(dictIdSet, columnDictIdSet); + Assert.notNull(notExistDictId, "notExistDictId can't be NULL"); + errorMessage = String.format("数据验证失败,字典Id [%s] 不存在!", notExistDictId); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + jsonObject.put("onlineDictList", onlineDictList); + } + Set columnIdSet = onlineColumnList.stream().map(OnlineColumn::getColumnId).collect(Collectors.toSet()); + List colunmRuleList = onlineRuleService.getOnlineColumnRuleListByColumnIds(columnIdSet); + if (CollUtil.isNotEmpty(colunmRuleList)) { + jsonObject.put("onlineColumnRuleList", colunmRuleList); + } + jsonObject.put("appCode", TokenData.takeFromRequest().getAppCode()); + if (BooleanUtil.isTrue(properties.getEnableRenderCache())) { + Assert.notNull(cache, "Cache ONLINE_FORM_RENDER_CACCHE can't be NULL"); + cache.put(formId, jsonObject); + } + return ResponseResult.success(jsonObject); + } + + private Long findNotExistDictId(Set originalDictIdSet, Set dictIdSet) { + return originalDictIdSet.stream().filter(d -> !dictIdSet.contains(d)).findFirst().orElse(null); + } + + private ResponseResult doVerifyAndGet(Long formId) { + String errorMessage; + if (MyCommonUtil.existBlankArgument(formId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + // 验证关联Id的数据合法性 + OnlineForm form = onlineFormService.getById(formId); + if (form == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + if (!StrUtil.equals(form.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + errorMessage = "数据验证失败,当前应用不包含该表单!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (ObjectUtil.notEqual(form.getTenantId(), TokenData.takeFromRequest().getTenantId())) { + errorMessage = "数据验证失败,当前租户不包含该表单!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(form); + } + + private ResponseResult> doVerifyDatasourceIdsAndGet(List datasourceIdList) { + String errorMessage; + Set datasourceIdSet = new HashSet<>(datasourceIdList); + List datasourceList = onlineDatasourceService.getInList(datasourceIdSet); + if (datasourceIdSet.size() != datasourceList.size()) { + errorMessage = "数据验证失败,当前在线表单包含不存在的数据源Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + String appCode = TokenData.takeFromRequest().getAppCode(); + for (OnlineDatasource datasource : datasourceList) { + if (!StrUtil.equals(datasource.getAppCode(), appCode)) { + errorMessage = "数据验证失败,存在不是当前应用的数据源!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + return ResponseResult.success(datasourceIdSet); + } + + private Set extractDictIdSetFromWidgetJson(String widgetJson) { + Set dictIdSet = new HashSet<>(); + if (StrUtil.isBlank(widgetJson)) { + return dictIdSet; + } + JSONObject allData = JSON.parseObject(widgetJson); + JSONObject pcData = allData.getJSONObject("pc"); + if (MapUtil.isEmpty(pcData)) { + return dictIdSet; + } + JSONArray widgetListArray = pcData.getJSONArray("widgetList"); + if (CollUtil.isEmpty(widgetListArray)) { + return dictIdSet; + } + for (int i = 0; i < widgetListArray.size(); i++) { + this.recursiveExtractDictId(widgetListArray.getJSONObject(i), dictIdSet); + } + return dictIdSet; + } + + private void recursiveExtractDictId(JSONObject widgetData, Set dictIdSet) { + JSONObject propsData = widgetData.getJSONObject("props"); + if (MapUtil.isNotEmpty(propsData)) { + JSONObject dictInfoData = propsData.getJSONObject("dictInfo"); + if (MapUtil.isNotEmpty(dictInfoData)) { + Long dictId = dictInfoData.getLong("dictId"); + if (dictId != null) { + dictIdSet.add(dictId); + } + } + } + JSONArray childWidgetArray = widgetData.getJSONArray("childWidgetList"); + if (CollUtil.isNotEmpty(childWidgetArray)) { + for (int i = 0; i < childWidgetArray.size(); i++) { + this.recursiveExtractDictId(childWidgetArray.getJSONObject(i), dictIdSet); + } + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineOperationController.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineOperationController.java new file mode 100644 index 00000000..92638650 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineOperationController.java @@ -0,0 +1,1045 @@ +package com.orangeforms.common.online.controller; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.text.StrFormatter; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.CharUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.DictType; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.constant.ObjectFieldType; +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.*; +import com.orangeforms.common.dict.model.GlobalDictItem; +import com.orangeforms.common.dict.service.GlobalDictService; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.online.config.OnlineProperties; +import com.orangeforms.common.online.dto.OnlineFilterDto; +import com.orangeforms.common.online.exception.OnlineRuntimeException; +import com.orangeforms.common.online.model.*; +import com.orangeforms.common.online.model.constant.FieldFilterType; +import com.orangeforms.common.online.model.constant.FieldKind; +import com.orangeforms.common.online.model.constant.RelationType; +import com.orangeforms.common.online.service.*; +import com.orangeforms.common.online.util.OnlineConstant; +import com.orangeforms.common.online.util.OnlineOperationHelper; +import com.orangeforms.common.redis.cache.SessionCacheHelper; +import com.orangeforms.common.redis.util.CommonRedisUtil; +import com.orangeforms.common.satoken.annotation.SaTokenDenyAuth; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletResponse; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.joda.time.DateTime; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 在线表单数据操作接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "在线表单数据操作接口") +@Slf4j +@RestController +@RequestMapping("${common-online.urlPrefix}/onlineOperation") +@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true") +public class OnlineOperationController { + + @Autowired + private OnlineOperationService onlineOperationService; + @Autowired + private OnlineDictService onlineDictService; + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private OnlineDatasourceRelationService onlineDatasourceRelationService; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private OnlineOperationHelper onlineOperationHelper; + @Autowired + private OnlineVirtualColumnService onlineVirtualColumnService; + @Autowired + private OnlineProperties onlineProperties; + @Autowired + private GlobalDictService globalDictService; + @Autowired + private CommonRedisUtil commonRedisUtil; + @Autowired + private SessionCacheHelper sessionCacheHelper; + + /** + * 新增数据接口。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 主表的数据源Id。 + * @param masterData 主表新增数据。 + * @param slaveData 一对多从表新增数据列表。 + * @return 应答结果。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/addDatasource/{datasourceVariableName}") + public ResponseResult addDatasource( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody(required = true) JSONObject masterData, + @MyRequestBody JSONObject slaveData) { + // 验证数据源的合法性,同时获取主表对象。 + ResponseResult datasourceResult = onlineOperationHelper.verifyAndGetDatasource(datasourceId); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + OnlineDatasource datasource = datasourceResult.getData(); + if (!datasource.getVariableName().equals(datasourceVariableName)) { + ContextUtil.getHttpResponse().setStatus(HttpServletResponse.SC_FORBIDDEN); + return ResponseResult.error(ErrorCodeEnum.NO_OPERATION_PERMISSION); + } + OnlineTable masterTable = datasource.getMasterTable(); + if (slaveData == null) { + onlineOperationService.saveNew(masterTable, masterData); + } else { + ResponseResult>> slaveDataListResult = + onlineOperationHelper.buildSlaveDataList(datasourceId, slaveData); + if (!slaveDataListResult.isSuccess()) { + return ResponseResult.errorFrom(slaveDataListResult); + } + onlineOperationService.saveNewWithRelation(masterTable, masterData, slaveDataListResult.getData()); + } + return ResponseResult.success(); + } + + /** + * 新增一对多从表数据接口。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 主表的数据源Id。 + * @param relationId 一对多的关联Id。 + * @param slaveData 一对多从表的新增数据列表。 + * @return 应答结果。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/addOneToManyRelation/{datasourceVariableName}") + public ResponseResult addOneToManyRelation( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody(required = true) Long relationId, + @MyRequestBody(required = true) JSONObject slaveData) { + ResponseResult verifyResult = + this.doVerifyAndGetRelation(datasourceId, datasourceVariableName, relationId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDatasourceRelation relation = verifyResult.getData(); + onlineOperationService.saveNew(relation.getSlaveTable(), slaveData); + return ResponseResult.success(); + } + + /** + * 更新主数据接口。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 主表数据源Id。 + * @param masterData 表数据。这里没有包含的字段将视为NULL。 + * @param slaveData 从表数据,key是relationId。 + * @return 应该结果。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/updateDatasource/{datasourceVariableName}") + public ResponseResult updateDatasource( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody(required = true) JSONObject masterData, + @MyRequestBody JSONObject slaveData) { + ResponseResult datasourceResult = + onlineOperationHelper.verifyAndGetDatasource(datasourceId); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + OnlineDatasource datasource = datasourceResult.getData(); + if (!datasource.getVariableName().equals(datasourceVariableName)) { + ContextUtil.getHttpResponse().setStatus(HttpServletResponse.SC_FORBIDDEN); + return ResponseResult.error(ErrorCodeEnum.NO_OPERATION_PERMISSION); + } + OnlineTable masterTable = datasource.getMasterTable(); + if (slaveData == null) { + if (!onlineOperationService.update(masterTable, masterData)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + } else { + ResponseResult>> slaveDataListResult = + onlineOperationHelper.buildSlaveDataList(datasourceId, slaveData); + if (!slaveDataListResult.isSuccess()) { + return ResponseResult.errorFrom(slaveDataListResult); + } + onlineOperationService.updateWithRelation( + masterTable, masterData, datasourceId, slaveDataListResult.getData()); + } + return ResponseResult.success(); + } + + /** + * 更新一对多关联数据接口。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 主表数据源Id。 + * @param relationId 一对多关联Id。 + * @param slaveData 一对多关联从表数据。这里没有包含的字段将视为NULL。 + * @return 应该结果。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/updateOneToManyRelation/{datasourceVariableName}") + public ResponseResult updateOneToManyRelation( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody(required = true) Long relationId, + @MyRequestBody(required = true) JSONObject slaveData) { + ResponseResult verifyResult = + this.doVerifyAndGetRelation(datasourceId, datasourceVariableName, relationId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineTable slaveTable = verifyResult.getData().getSlaveTable(); + if (!onlineOperationService.update(slaveTable, slaveData)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 删除主数据接口。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 主表数据源Id。 + * @param dataId 待删除的数据表主键Id。 + * @return 应该结果。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/deleteDatasource/{datasourceVariableName}") + public ResponseResult deleteDatasource( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody(required = true) String dataId) { + return this.doDelete(datasourceVariableName, datasourceId, CollUtil.newArrayList(dataId)); + } + + /** + * 批量删除主数据接口。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 主表数据源Id。 + * @param dataIdList 待删除的数据表主键Id列表。 + * @return 应该结果。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.DELETE_BATCH) + @PostMapping("/deleteBatchDatasource/{datasourceVariableName}") + public ResponseResult deleteBatchDatasource( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody(required = true) List dataIdList) { + return this.doDelete(datasourceVariableName, datasourceId, dataIdList); + } + + /** + * 删除一对多关联表单条数据接口。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 主表数据源Id。 + * @param relationId 一对多关联Id。 + * @param dataId 一对多关联表主键Id。 + * @return 应该结果。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/deleteOneToManyRelation/{datasourceVariableName}") + public ResponseResult deleteOneToManyRelation( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody(required = true) Long relationId, + @MyRequestBody(required = true) String dataId) { + return this.doDelete(datasourceVariableName, datasourceId, relationId, CollUtil.newArrayList(dataId)); + } + + /** + * 批量删除一对多关联表单条数据接口。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 主表数据源Id。 + * @param relationId 一对多关联Id。 + * @param dataIdList 一对多关联表主键Id列表。 + * @return 应该结果。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.DELETE_BATCH) + @PostMapping("/deleteBatchOneToManyRelation/{datasourceVariableName}") + public ResponseResult deleteBatchOneToManyRelation( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody(required = true) Long relationId, + @MyRequestBody(required = true) List dataIdList) { + return this.doDelete(datasourceVariableName, datasourceId, relationId, dataIdList); + } + + /** + * 根据数据源Id为动态表单查询数据详情。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 数据源Id。 + * @param dataId 数据主键Id。 + * @return 详情结果。 + */ + @SaTokenDenyAuth + @GetMapping("/viewByDatasourceId/{datasourceVariableName}") + public ResponseResult> viewByDatasourceId( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @RequestParam Long datasourceId, + @RequestParam String dataId) { + // 验证数据源及其关联 + ResponseResult datasourceResult = + this.doVerifyAndGetDatasource(datasourceId, datasourceVariableName); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + OnlineDatasource datasource = datasourceResult.getData(); + ResponseResult> relationListResult = + onlineOperationHelper.verifyAndGetRelationList(datasourceId, null); + if (!relationListResult.isSuccess()) { + return ResponseResult.errorFrom(relationListResult); + } + List allRelationList = relationListResult.getData(); + List oneToOneRelationList = allRelationList.stream() + .filter(r -> r.getRelationType().equals(RelationType.ONE_TO_ONE)).collect(Collectors.toList()); + Map result = onlineOperationService.getMasterData( + datasource.getMasterTable(), oneToOneRelationList, allRelationList, dataId); + return ResponseResult.success(result); + } + + /** + * 根据数据源关联Id为动态表单查询数据详情。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 数据源Id。 + * @param relationId 一对多关联Id。 + * @param dataId 一对多关联数据主键Id。 + * @return 详情结果。 + */ + @SaTokenDenyAuth + @GetMapping("/viewByOneToManyRelationId/{datasourceVariableName}") + public ResponseResult> viewByOneToManyRelationId( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @RequestParam Long datasourceId, + @RequestParam Long relationId, + @RequestParam String dataId) { + ResponseResult verifyResult = + this.doVerifyAndGetRelation(datasourceId, datasourceVariableName, relationId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + Map result = onlineOperationService.getSlaveData(verifyResult.getData(), dataId); + return ResponseResult.success(result); + } + + /** + * 为数据源主表字段下载文件。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 数据源Id。 + * @param dataId 附件所在记录的主键Id。 + * @param fieldName 数据表字段名。 + * @param asImage 是否为图片文件。 + * @param response Http 应答对象。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.DOWNLOAD, saveResponse = false) + @GetMapping("/downloadDatasource/{datasourceVariableName}") + public void downloadDatasource( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @RequestParam Long datasourceId, + @RequestParam(required = false) String dataId, + @RequestParam String fieldName, + @RequestParam String filename, + @RequestParam Boolean asImage, + HttpServletResponse response) throws IOException { + if (MyCommonUtil.existBlankArgument(fieldName, filename, asImage)) { + response.setStatus(HttpServletResponse.SC_BAD_REQUEST); + return; + } + ResponseResult datasourceResult = + onlineOperationHelper.verifyAndGetDatasource(datasourceId); + if (!datasourceResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, ResponseResult.errorFrom(datasourceResult)); + return; + } + OnlineDatasource datasource = datasourceResult.getData(); + if (!datasource.getVariableName().equals(datasourceVariableName)) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, + ResponseResult.error(ErrorCodeEnum.NO_OPERATION_PERMISSION)); + return; + } + OnlineTable masterTable = datasource.getMasterTable(); + onlineOperationHelper.doDownload(masterTable, dataId, fieldName, filename, asImage, response); + } + + /** + * 为数据源一对多关联的从表字段下载文件。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 数据源Id。 + * @param relationId 数据源的一对多关联Id。 + * @param dataId 附件所在记录的主键Id。 + * @param fieldName 数据表字段名。 + * @param asImage 是否为图片文件。 + * @param response Http 应答对象。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.DOWNLOAD, saveResponse = false) + @GetMapping("/downloadOneToManyRelation/{datasourceVariableName}") + public void downloadOneToManyRelation( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @RequestParam Long datasourceId, + @RequestParam Long relationId, + @RequestParam(required = false) String dataId, + @RequestParam String fieldName, + @RequestParam String filename, + @RequestParam Boolean asImage, + HttpServletResponse response) throws IOException { + ResponseResult relationResult = + this.doVerifyAndGetRelation(datasourceId, datasourceVariableName, relationId); + if (!relationResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, ResponseResult.errorFrom(relationResult)); + return; + } + OnlineTable slaveTable = relationResult.getData().getSlaveTable(); + onlineOperationHelper.doDownload(slaveTable, dataId, fieldName, filename, asImage, response); + } + + /** + * 为数据源主表字段上传文件。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 数据源Id。 + * @param fieldName 数据表字段名。 + * @param asImage 是否为图片文件。 + * @param uploadFile 上传文件对象。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.UPLOAD, saveResponse = false) + @PostMapping("/uploadDatasource/{datasourceVariableName}") + public void uploadDatasource( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @RequestParam Long datasourceId, + @RequestParam String fieldName, + @RequestParam Boolean asImage, + @RequestParam("uploadFile") MultipartFile uploadFile) throws IOException { + ResponseResult datasourceResult = + onlineOperationHelper.verifyAndGetDatasource(datasourceId); + if (!datasourceResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, ResponseResult.errorFrom(datasourceResult)); + return; + } + OnlineDatasource datasource = datasourceResult.getData(); + if (!datasource.getVariableName().equals(datasourceVariableName)) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, + ResponseResult.error(ErrorCodeEnum.NO_OPERATION_PERMISSION)); + return; + } + OnlineTable masterTable = datasource.getMasterTable(); + onlineOperationHelper.doUpload(masterTable, fieldName, asImage, uploadFile); + } + + /** + * 为数据源一对多关联的从表字段上传文件。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 数据源Id。 + * @param relationId 数据源的一对多关联Id。 + * @param fieldName 数据表字段名。 + * @param asImage 是否为图片文件。 + * @param uploadFile 上传文件对象。 + */ + @SaTokenDenyAuth + @OperationLog(type = SysOperationLogType.UPLOAD, saveResponse = false) + @PostMapping("/uploadOneToManyRelation/{datasourceVariableName}") + public void uploadOneToManyRelation( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @RequestParam Long datasourceId, + @RequestParam Long relationId, + @RequestParam String fieldName, + @RequestParam Boolean asImage, + @RequestParam("uploadFile") MultipartFile uploadFile) throws IOException { + ResponseResult relationResult = + this.doVerifyAndGetRelation(datasourceId, datasourceVariableName, relationId); + if (!relationResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, ResponseResult.errorFrom(relationResult)); + return; + } + OnlineTable slaveTable = relationResult.getData().getSlaveTable(); + onlineOperationHelper.doUpload(slaveTable, fieldName, asImage, uploadFile); + } + + /** + * 根据数据源Id,以及接口参数,为动态表单查询数据列表。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 数据源Id。 + * @param filterDtoList 多虑数据对象列表。 + * @param orderParam 排序对象。 + * @param pageParam 分页对象。 + */ + @SaTokenDenyAuth + @PostMapping("/listByDatasourceId/{datasourceVariableName}") + public ResponseResult>> listByDatasourceId( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody List filterDtoList, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + // 1. 验证数据源及其关联 + ResponseResult datasourceResult = + this.doVerifyAndGetDatasource(datasourceId, datasourceVariableName); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + OnlineTable masterTable = datasourceResult.getData().getMasterTable(); + ResponseResult> relationListResult = + onlineOperationHelper.verifyAndGetRelationList(datasourceId, null); + if (!relationListResult.isSuccess()) { + return ResponseResult.errorFrom(relationListResult); + } + List allRelationList = relationListResult.getData(); + // 2. 验证数据过滤对象中的表名和字段,确保没有sql注入。 + ResponseResult filterDtoListResult = this.verifyFilterDtoList(filterDtoList); + if (!filterDtoListResult.isSuccess()) { + return ResponseResult.errorFrom(filterDtoListResult); + } + // 3. 解析排序参数,同时确保没有sql注入。 + Map tableMap = new HashMap<>(4); + tableMap.put(masterTable.getTableName(), masterTable); + List oneToOneRelationList = relationListResult.getData().stream() + .filter(r -> r.getRelationType().equals(RelationType.ONE_TO_ONE)).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(oneToOneRelationList)) { + Map relationTableMap = oneToOneRelationList.stream() + .map(OnlineDatasourceRelation::getSlaveTable).collect(Collectors.toMap(OnlineTable::getTableName, c -> c)); + tableMap.putAll(relationTableMap); + } + ResponseResult orderByResult = this.makeOrderBy(orderParam, masterTable, tableMap); + if (!orderByResult.isSuccess()) { + return ResponseResult.errorFrom(orderByResult); + } + String orderBy = orderByResult.getData(); + MyPageData> pageData = onlineOperationService.getMasterDataList( + masterTable, oneToOneRelationList, allRelationList, filterDtoList, orderBy, pageParam); + return ResponseResult.success(pageData); + } + + /** + * 根据数据源Id,以及接口参数,为动态表单导出数据列表。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 数据源Id。 + * @param filterDtoList 多虑数据对象列表。 + * @param orderParam 排序对象。 + * @param exportInfoList 导出字段信息列表。 + */ + @SaTokenDenyAuth + @PostMapping("/exportByDatasourceId/{datasourceVariableName}") + public void exportByDatasourceId( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody List filterDtoList, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody(required = true) List exportInfoList) throws IOException { + // 1. 验证数据源及其关联 + ResponseResult datasourceResult = + onlineOperationHelper.verifyAndGetDatasource(datasourceId); + if (!datasourceResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, datasourceResult); + } + OnlineDatasource datasource = datasourceResult.getData(); + if (!datasource.getVariableName().equals(datasourceVariableName)) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN); + } + OnlineTable masterTable = datasource.getMasterTable(); + ResponseResult> relationListResult = + onlineOperationHelper.verifyAndGetRelationList(datasourceId, null); + if (!relationListResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, relationListResult); + } + List allRelationList = relationListResult.getData(); + // 2. 验证数据过滤对象中的表名和字段,确保没有sql注入。 + ResponseResult filterDtoListResult = this.verifyFilterDtoList(filterDtoList); + if (!filterDtoListResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, filterDtoListResult); + } + // 3. 解析排序参数,同时确保没有sql注入。 + Map tableMap = new HashMap<>(4); + tableMap.put(masterTable.getTableName(), masterTable); + List oneToOneRelationList = relationListResult.getData().stream() + .filter(r -> r.getRelationType().equals(RelationType.ONE_TO_ONE)).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(oneToOneRelationList)) { + Map relationTableMap = oneToOneRelationList.stream() + .map(OnlineDatasourceRelation::getSlaveTable).collect(Collectors.toMap(OnlineTable::getTableName, c -> c)); + tableMap.putAll(relationTableMap); + } + ResponseResult orderByResult = this.makeOrderBy(orderParam, masterTable, tableMap); + if (!orderByResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, orderByResult); + } + String orderBy = orderByResult.getData(); + MyPageData> pageData = onlineOperationService.getMasterDataList( + masterTable, oneToOneRelationList, allRelationList, filterDtoList, orderBy, null); + Map headerMap = this.makeExportHeaderMap(masterTable, allRelationList, exportInfoList); + if (MapUtil.isEmpty(headerMap)) { + ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, + ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, "数据验证失败,没有指定导出头信息!")); + return; + } + this.normalizeExportDataList(pageData.getDataList()); + String filename = datasourceVariableName + "-" + MyDateUtil.toDateTimeString(DateTime.now()) + ".xlsx"; + ExportUtil.doExport(pageData.getDataList(), headerMap, filename); + } + + /** + * 根据数据源Id和数据源关联Id,以及接口参数,为动态表单查询该一对多关联的数据列表。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 数据源Id。 + * @param relationId 数据源的一对多关联Id。 + * @param filterDtoList 多虑数据对象列表。 + * @param orderParam 排序对象。 + * @param pageParam 分页对象。 + * @return 查询结果。 + */ + @SaTokenDenyAuth + @PostMapping("/listByOneToManyRelationId/{datasourceVariableName}") + public ResponseResult>> listByOneToManyRelationId( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody(required = true) Long relationId, + @MyRequestBody List filterDtoList, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + ResponseResult verifyResult = + this.doVerifyAndGetRelation(datasourceId, datasourceVariableName, relationId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDatasourceRelation relation = verifyResult.getData(); + OnlineTable slaveTable = relation.getSlaveTable(); + // 验证数据过滤对象中的表名和字段,确保没有sql注入。 + ResponseResult filterDtoListResult = this.verifyFilterDtoList(filterDtoList); + if (!filterDtoListResult.isSuccess()) { + return ResponseResult.errorFrom(filterDtoListResult); + } + Map tableMap = new HashMap<>(1); + tableMap.put(slaveTable.getTableName(), slaveTable); + if (CollUtil.isNotEmpty(orderParam)) { + for (MyOrderParam.OrderInfo orderInfo : orderParam) { + orderInfo.setFieldName(StrUtil.removePrefix(orderInfo.getFieldName(), + relation.getVariableName() + OnlineConstant.RELATION_TABLE_COLUMN_SEPARATOR)); + } + } + ResponseResult orderByResult = this.makeOrderBy(orderParam, slaveTable, tableMap); + if (!orderByResult.isSuccess()) { + return ResponseResult.errorFrom(orderByResult); + } + String orderBy = orderByResult.getData(); + MyPageData> pageData = + onlineOperationService.getSlaveDataList(relation, filterDtoList, orderBy, pageParam); + return ResponseResult.success(pageData); + } + + /** + * 根据数据源Id和数据源关联Id,以及接口参数,为动态表单查询该一对多关联的数据列表。 + * + * @param datasourceVariableName 数据源名称。 + * @param datasourceId 数据源Id。 + * @param relationId 数据源的一对多关联Id。 + * @param filterDtoList 多虑数据对象列表。 + * @param orderParam 排序对象。 + * @param exportInfoList 导出字段信息列表。 + */ + @SaTokenDenyAuth + @PostMapping("/exportByOneToManyRelationId/{datasourceVariableName}") + public void exportByOneToManyRelationId( + @PathVariable("datasourceVariableName") String datasourceVariableName, + @MyRequestBody(required = true) Long datasourceId, + @MyRequestBody(required = true) Long relationId, + @MyRequestBody List filterDtoList, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody(required = true) List exportInfoList) throws IOException { + ResponseResult relationResult = + this.doVerifyAndGetRelation(datasourceId, datasourceVariableName, relationId); + if (!relationResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, relationResult); + return; + } + OnlineDatasourceRelation relation = relationResult.getData(); + OnlineTable slaveTable = relation.getSlaveTable(); + // 验证数据过滤对象中的表名和字段,确保没有sql注入。 + ResponseResult filterDtoListResult = this.verifyFilterDtoList(filterDtoList); + if (!filterDtoListResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, filterDtoListResult); + return; + } + Map tableMap = new HashMap<>(1); + tableMap.put(slaveTable.getTableName(), slaveTable); + if (CollUtil.isNotEmpty(orderParam)) { + for (MyOrderParam.OrderInfo orderInfo : orderParam) { + orderInfo.setFieldName(StrUtil.removePrefix(orderInfo.getFieldName(), + relation.getVariableName() + OnlineConstant.RELATION_TABLE_COLUMN_SEPARATOR)); + } + } + ResponseResult orderByResult = this.makeOrderBy(orderParam, slaveTable, tableMap); + if (!orderByResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, orderByResult); + return; + } + String orderBy = orderByResult.getData(); + MyPageData> pageData = + onlineOperationService.getSlaveDataList(relation, filterDtoList, orderBy, null); + Map headerMap = + this.makeExportHeaderMap(relation.getSlaveTable(), null, exportInfoList); + if (MapUtil.isEmpty(headerMap)) { + ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, + ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, "数据验证失败,没有指定导出头信息!")); + return; + } + this.normalizeExportDataList(pageData.getDataList()); + String filename = datasourceVariableName + "-relation-" + MyDateUtil.toDateTimeString(DateTime.now()) + ".xlsx"; + ExportUtil.doExport(pageData.getDataList(), headerMap, filename); + } + + /** + * 查询字典数据,并以字典的约定方式,返回数据结果集。 + * + * @param dictId 字典Id。 + * @param filterDtoList 字典的过滤对象列表。 + * @return 字典数据列表。 + */ + @PostMapping("/listDict") + public ResponseResult>> listDict( + @MyRequestBody(required = true) Long dictId, + @MyRequestBody List filterDtoList) { + String errorMessage; + OnlineDict dict = onlineDictService.getOnlineDictFromCache(dictId); + if (dict == null) { + errorMessage = "数据验证失败,字典Id并不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + TokenData tokenData = TokenData.takeFromRequest(); + if (!StrUtil.equals(dict.getAppCode(), tokenData.getAppCode())) { + errorMessage = "数据验证失败,当前应用并不包含该字典Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!dict.getDictType().equals(DictType.TABLE) + && !dict.getDictType().equals(DictType.GLOBAL_DICT)) { + errorMessage = "数据验证失败,该接口仅支持数据表字典和全局编码字典!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (dict.getDictType().equals(DictType.GLOBAL_DICT)) { + List dictItems = + globalDictService.getGlobalDictItemListFromCache(dict.getDictCode(), null); + List> dataMapList = + MyCommonUtil.toDictDataList(dictItems, GlobalDictItem::getItemId, GlobalDictItem::getItemName); + return ResponseResult.success(dataMapList); + } + if (CollUtil.isNotEmpty(filterDtoList)) { + for (OnlineFilterDto filter : filterDtoList) { + if (!this.checkTableAndColumnName(filter.getColumnName())) { + errorMessage = StrFormatter.format( + "数据验证失败,过滤字段名 [{}] 包含 (数字、字母和下划线) 之外的非法字符!", filter.getColumnName()); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + } + List> resultList = onlineOperationService.getDictDataList(dict, filterDtoList); + return ResponseResult.success(resultList); + } + + /** + * 获取在线表单所关联的权限数据,包括权限字列表和权限资源列表。 + * 注:该接口仅用于微服务间调用使用,无需对前端开放。 + * + * @param menuFormIds 菜单关联的表单Id集合。 + * @param viewFormIds 查询权限的表单Id集合。 + * @param editFormIds 编辑权限的表单Id集合。 + * @return 参数中在线表单所关联的权限数据。 + */ + @GetMapping("/calculatePermData") + public ResponseResult> calculatePermData( + @RequestParam Set menuFormIds, + @RequestParam Set viewFormIds, + @RequestParam Set editFormIds) { + return ResponseResult.success(onlineOperationService.calculatePermData(menuFormIds, viewFormIds, editFormIds)); + } + + private ResponseResult doDelete( + String datasourceVariableName, Long datasourceId, List dataIdList) { + ResponseResult datasourceResult = + onlineOperationHelper.verifyAndGetDatasource(datasourceId); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + OnlineDatasource datasource = datasourceResult.getData(); + if (!datasource.getVariableName().equals(datasourceVariableName)) { + ContextUtil.getHttpResponse().setStatus(HttpServletResponse.SC_FORBIDDEN); + return ResponseResult.error(ErrorCodeEnum.NO_OPERATION_PERMISSION); + } + OnlineTable masterTable = datasource.getMasterTable(); + ResponseResult> relationListResult = + onlineOperationHelper.verifyAndGetRelationList(datasourceId, RelationType.ONE_TO_MANY); + if (!relationListResult.isSuccess()) { + return ResponseResult.errorFrom(relationListResult); + } + List relationList = relationListResult.getData(); + for (String dataId : dataIdList) { + if (!onlineOperationService.delete(masterTable, relationList, dataId)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + } + return ResponseResult.success(); + } + + private ResponseResult doDelete( + String datasourceVariableName, Long datasourceId, Long relationId, List dataIdList) { + ResponseResult verifyResult = + this.doVerifyAndGetRelation(datasourceId, datasourceVariableName, relationId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineDatasourceRelation relation = verifyResult.getData(); + for (String dataId : dataIdList) { + if (!onlineOperationService.delete(relation.getSlaveTable(), null, dataId)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + } + return ResponseResult.success(); + } + + private ResponseResult doVerifyAndGetDatasource( + Long datasourceId, String datasourceVariableName) { + ResponseResult datasourceResult = + onlineOperationHelper.verifyAndGetDatasource(datasourceId); + if (!datasourceResult.isSuccess()) { + return ResponseResult.errorFrom(datasourceResult); + } + OnlineDatasource datasource = datasourceResult.getData(); + if (!datasource.getVariableName().equals(datasourceVariableName)) { + ContextUtil.getHttpResponse().setStatus(HttpServletResponse.SC_FORBIDDEN); + return ResponseResult.error(ErrorCodeEnum.NO_OPERATION_PERMISSION); + } + return ResponseResult.success(datasource); + } + + private ResponseResult doVerifyAndGetRelation( + Long datasourceId, String datasourceVariableName, Long relationId) { + OnlineDatasource datasource = onlineDatasourceService.getOnlineDatasourceFromCache(datasourceId); + if (datasource == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, "数据验证失败,数据源Id并不存在!"); + } + if (!datasource.getVariableName().equals(datasourceVariableName)) { + ContextUtil.getHttpResponse().setStatus(HttpServletResponse.SC_FORBIDDEN); + return ResponseResult.error(ErrorCodeEnum.NO_OPERATION_PERMISSION); + } + return onlineOperationHelper.verifyAndGetRelation(datasourceId, relationId); + } + + private ResponseResult verifyFilterDtoList(List filterDtoList) { + if (CollUtil.isEmpty(filterDtoList)) { + return ResponseResult.success(); + } + String errorMessage; + for (OnlineFilterDto filter : filterDtoList) { + if (!this.checkTableAndColumnName(filter.getTableName())) { + errorMessage = StrFormatter.format( + "数据验证失败,过滤表名 [{}] 包含 (数字、字母和下划线) 之外的非法字符!", filter.getColumnName()); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!this.checkTableAndColumnName(filter.getColumnName())) { + errorMessage = StrFormatter.format( + "数据验证失败,过滤字段名 [{}] 包含 (数字、字母和下划线) 之外的非法字符!", filter.getColumnName()); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!filter.getFilterType().equals(FieldFilterType.RANGE_FILTER) + && ObjectUtil.isEmpty(filter.getColumnValue())) { + errorMessage = StrFormatter.format( + "数据验证失败,过滤字段名 [{}] 过滤值不能为空!", filter.getColumnName()); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + return ResponseResult.success(); + } + + private boolean checkTableAndColumnName(String name) { + if (StrUtil.isBlank(name)) { + return true; + } + for (int i = 0; i < name.length(); i++) { + char c = name.charAt(i); + if (!CharUtil.isLetterOrNumber(c) && !CharUtil.equals('_', c, false)) { + return false; + } + } + return true; + } + + private ResponseResult makeOrderBy( + MyOrderParam orderParam, OnlineTable masterTable, Map tableMap) { + if (CollUtil.isEmpty(orderParam)) { + return ResponseResult.success(null); + } + String errorMessage; + StringBuilder sb = new StringBuilder(128); + for (MyOrderParam.OrderInfo orderInfo : orderParam) { + String[] orderArray = StrUtil.splitToArray(orderInfo.getFieldName(), '.'); + // 如果没有前缀,我们就可以默认为主表的字段。 + if (orderArray.length == 1) { + try { + sb.append(this.makeOrderByForOrderInfo(masterTable, orderArray[0], orderInfo)); + } catch (OnlineRuntimeException e) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, e.getMessage()); + } + } else { + String tableName = orderArray[0]; + String columnName = orderArray[1]; + OnlineTable table = tableMap.get(tableName); + if (table == null) { + errorMessage = StrFormatter.format( + "数据验证失败,排序字段 [{}] 的数据表 [{}] 并不属于当前数据源!", + orderInfo.getFieldName(), tableName); + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + try { + sb.append(this.makeOrderByForOrderInfo(table, columnName, orderInfo)); + } catch (OnlineRuntimeException e) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, e.getMessage()); + } + } + } + return ResponseResult.success(sb.substring(0, sb.length() - 2)); + } + + private String makeOrderByForOrderInfo( + OnlineTable table, String columnName, MyOrderParam.OrderInfo orderInfo) { + StringBuilder sb = new StringBuilder(64); + boolean found = false; + for (OnlineColumn column : table.getColumnMap().values()) { + if (column.getColumnName().equals(columnName)) { + sb.append(table.getTableName()).append(".").append(columnName); + if (BooleanUtil.isFalse(orderInfo.getAsc())) { + sb.append(" DESC"); + } + sb.append(", "); + found = true; + break; + } + } + if (!found) { + String errorMessage = StrFormatter.format( + "数据验证失败,排序字段 [{}] 在数据表 [{}] 中并不存在!", + orderInfo.getFieldName(), table.getTableName()); + throw new OnlineRuntimeException(errorMessage); + } + return sb.toString(); + } + + private int makeImportHeaderInfoByFieldType(String objectFieldType) { + return switch (objectFieldType) { + case ObjectFieldType.INTEGER -> ImportUtil.INT_TYPE; + case ObjectFieldType.LONG -> ImportUtil.LONG_TYPE; + case ObjectFieldType.STRING -> ImportUtil.STRING_TYPE; + case ObjectFieldType.BOOLEAN -> ImportUtil.BOOLEAN_TYPE; + case ObjectFieldType.DATE -> ImportUtil.DATE_TYPE; + case ObjectFieldType.DOUBLE -> ImportUtil.DOUBLE_TYPE; + case ObjectFieldType.BIG_DECIMAL -> ImportUtil.BIG_DECIMAL_TYPE; + default -> throw new MyRuntimeException("Unsupport Import FieldType"); + }; + } + + private Map makeExportHeaderMap( + OnlineTable masterTable, + List allRelationList, + List exportInfoList) { + Map headerMap = new LinkedHashMap<>(16); + Map allRelationMap = null; + if (allRelationList != null) { + allRelationMap = allRelationList.stream() + .collect(Collectors.toMap(OnlineDatasourceRelation::getSlaveTableId, r -> r)); + } + for (ExportInfo exportInfo : exportInfoList) { + if (exportInfo.getVirtualColumnId() != null) { + OnlineVirtualColumn virtualColumn = + onlineVirtualColumnService.getById(exportInfo.getVirtualColumnId()); + if (virtualColumn != null) { + headerMap.put(virtualColumn.getObjectFieldName(), exportInfo.showName); + } + continue; + } + if (masterTable != null && exportInfo.getTableId().equals(masterTable.getTableId())) { + OnlineColumn column = masterTable.getColumnMap().get(exportInfo.getColumnId()); + String columnName = this.appendSuffixForDictColumn(column, column.getColumnName()); + headerMap.put(columnName, exportInfo.getShowName()); + } else { + OnlineDatasourceRelation relation = + MapUtil.get(allRelationMap, exportInfo.getTableId(), OnlineDatasourceRelation.class); + if (relation != null) { + OnlineColumn column = relation.getSlaveTable().getColumnMap().get(exportInfo.getColumnId()); + String columnName = this.appendSuffixForDictColumn( + column, relation.getVariableName() + "." + column.getColumnName()); + headerMap.put(columnName, exportInfo.getShowName()); + } + } + } + return headerMap; + } + + private void normalizeExportDataList(List> dataList) { + for (Map columnData : dataList) { + for (Map.Entry entry : columnData.entrySet()) { + if (entry.getValue() instanceof Long || entry.getValue() instanceof BigDecimal) { + columnData.put(entry.getKey(), entry.getValue() == null ? "" : entry.getValue().toString()); + } + } + } + } + + private String appendSuffixForDictColumn(OnlineColumn column, String columnName) { + if (column.getDictId() != null) { + if (ObjectUtil.equal(column.getFieldKind(), FieldKind.DICT_MULTI_SELECT)) { + columnName += "DictMapList"; + } else { + columnName += "DictMap.name"; + } + } + return columnName; + } + + @Data + public static class ExportInfo { + private Long tableId; + private Long columnId; + private Long virtualColumnId; + private String showName; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlinePageController.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlinePageController.java new file mode 100644 index 00000000..25bbedb9 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlinePageController.java @@ -0,0 +1,386 @@ +package com.orangeforms.common.online.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.online.dto.OnlineDatasourceDto; +import com.orangeforms.common.online.dto.OnlinePageDatasourceDto; +import com.orangeforms.common.online.dto.OnlinePageDto; +import com.orangeforms.common.online.model.OnlineDatasource; +import com.orangeforms.common.online.model.OnlineForm; +import com.orangeforms.common.online.model.OnlinePage; +import com.orangeforms.common.online.model.OnlinePageDatasource; +import com.orangeforms.common.online.model.constant.PageStatus; +import com.orangeforms.common.online.service.OnlineDatasourceService; +import com.orangeforms.common.online.service.OnlineFormService; +import com.orangeforms.common.online.service.OnlinePageService; +import com.orangeforms.common.online.vo.OnlineDatasourceVo; +import com.orangeforms.common.online.vo.OnlinePageDatasourceVo; +import com.orangeforms.common.online.vo.OnlinePageVo; +import com.github.pagehelper.page.PageMethod; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.dao.DuplicateKeyException; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 在线表单页面接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "在线表单页面接口") +@Slf4j +@RestController +@RequestMapping("${common-online.urlPrefix}/onlinePage") +@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true") +public class OnlinePageController { + + @Autowired + private OnlinePageService onlinePageService; + @Autowired + private OnlineFormService onlineFormService; + @Autowired + private OnlineDatasourceService onlineDatasourceService; + + /** + * 新增在线表单页面数据。 + * + * @param onlinePageDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"onlinePageDto.pageId"}) + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody OnlinePageDto onlinePageDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlinePageDto); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlinePage onlinePage = MyModelUtil.copyTo(onlinePageDto, OnlinePage.class); + if (onlinePageService.existByPageCode(onlinePage.getPageCode())) { + errorMessage = "数据验证失败,页面编码已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage); + } + try { + onlinePage = onlinePageService.saveNew(onlinePage); + } catch (DuplicateKeyException e) { + errorMessage = "数据验证失败,当前应用的页面编码已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(onlinePage.getPageId()); + } + + /** + * 更新在线表单页面数据。 + * + * @param onlinePageDto 更新对象。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/update") + public ResponseResult update(@MyRequestBody OnlinePageDto onlinePageDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlinePageDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlinePage onlinePage = MyModelUtil.copyTo(onlinePageDto, OnlinePage.class); + ResponseResult verifyResult = this.doVerifyAndGet(onlinePage.getPageId()); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlinePage originalOnlinePage = verifyResult.getData(); + if (!onlinePage.getPageType().equals(originalOnlinePage.getPageType())) { + errorMessage = "数据验证失败,页面类型不能修改!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!StrUtil.equals(onlinePage.getPageCode(), originalOnlinePage.getPageCode()) + && onlinePageService.existByPageCode(onlinePage.getPageCode())) { + errorMessage = "数据验证失败,页面编码已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage); + } + try { + if (!onlinePageService.update(onlinePage, originalOnlinePage)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + } catch (DuplicateKeyException e) { + errorMessage = "数据验证失败,当前应用的页面编码已经存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 更新在线表单页面对象的发布状态字段。 + * + * @param pageId 待更新的页面对象主键Id。 + * @param published 发布状态。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.UPDATE) + @PostMapping("/updatePublished") + public ResponseResult updateStatus( + @MyRequestBody(required = true) Long pageId, + @MyRequestBody(required = true) Boolean published) { + String errorMessage; + ResponseResult verifyResult = this.doVerifyAndGet(pageId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlinePage originalOnlinePage = verifyResult.getData(); + if (!published.equals(originalOnlinePage.getPublished())) { + if (BooleanUtil.isTrue(published) && !originalOnlinePage.getStatus().equals(PageStatus.FORM_DESIGN)) { + errorMessage = "数据验证失败,当前页面状态不为 [设计] 状态,因此不能发布!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + onlinePageService.updatePublished(pageId, published); + } + return ResponseResult.success(); + } + + /** + * 删除在线表单页面数据。 + * + * @param pageId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long pageId) { + String errorMessage; + ResponseResult verifyResult = this.doVerifyAndGet(pageId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (!onlinePageService.remove(pageId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的在线表单页面列表。 + * + * @param onlinePageDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("onlinePage.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody OnlinePageDto onlinePageDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlinePage onlinePageFilter = MyModelUtil.copyTo(onlinePageDtoFilter, OnlinePage.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlinePage.class); + List onlinePageList = onlinePageService.getOnlinePageListWithRelation(onlinePageFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(onlinePageList, OnlinePageVo.class)); + } + + /** + * 获取系统中配置的所有Page和表单的列表。 + * + * @return 系统中配置的所有Page和表单的列表。 + */ + @PostMapping("/listAllPageAndForm") + public ResponseResult listAllPageAndForm() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("pageList", onlinePageService.getOnlinePageList(null, null)); + List formList = onlineFormService.getOnlineFormList(null, null); + formList.forEach(f -> f.setWidgetJson(null)); + jsonObject.put("formList", formList); + return ResponseResult.success(jsonObject); + } + + /** + * 查看指定在线表单页面对象详情。 + * + * @param pageId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("onlinePage.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long pageId) { + ResponseResult verifyResult = this.doVerifyAndGet(pageId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlinePage onlinePage = onlinePageService.getByIdWithRelation(pageId, MyRelationParam.full()); + if (onlinePage == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(onlinePage, OnlinePageVo.class); + } + + /** + * 列出与指定在线表单页面存在多对多关系的在线数据源列表数据。 + * + * @param pageId 主表关联字段。 + * @param onlineDatasourceDtoFilter 在线数据源过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,返回符合条件的数据列表。 + */ + @SaCheckPermission("onlinePage.all") + @PostMapping("/listOnlinePageDatasource") + public ResponseResult> listOnlinePageDatasource( + @MyRequestBody Long pageId, + @MyRequestBody OnlineDatasourceDto onlineDatasourceDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + ResponseResult verifyResult = this.doVerifyAndGet(pageId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlineDatasource filter = MyModelUtil.copyTo(onlineDatasourceDtoFilter, OnlineDatasource.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineDatasource.class); + List onlineDatasourceList = + onlineDatasourceService.getOnlineDatasourceListByPageId(pageId, filter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(onlineDatasourceList, OnlineDatasourceVo.class)); + } + + /** + * 批量添加在线表单页面和在线数据源对象的多对多关联关系数据。 + * + * @param pageId 主表主键Id。 + * @param onlinePageDatasourceDtoList 关联对象列表。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.ADD_M2M) + @PostMapping("/addOnlinePageDatasource") + public ResponseResult addOnlinePageDatasource( + @MyRequestBody Long pageId, + @MyRequestBody(value = "onlinePageDatasourceList") List onlinePageDatasourceDtoList) { + String errorMessage; + ResponseResult verifyResult = this.doVerifyAndGet(pageId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (MyCommonUtil.existBlankArgument(onlinePageDatasourceDtoList)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + for (OnlinePageDatasourceDto onlinePageDatasource : onlinePageDatasourceDtoList) { + errorMessage = MyCommonUtil.getModelValidationError(onlinePageDatasource); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + Set datasourceIdSet = onlinePageDatasourceDtoList.stream() + .map(OnlinePageDatasourceDto::getDatasourceId).collect(Collectors.toSet()); + List datasourceList = onlineDatasourceService.getInList(datasourceIdSet); + if (datasourceIdSet.size() != datasourceList.size()) { + errorMessage = "数据验证失败,当前在线表单包含不存在的数据源Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + String appCode = TokenData.takeFromRequest().getAppCode(); + for (OnlineDatasource datasource : datasourceList) { + if (!StrUtil.equals(datasource.getAppCode(), appCode)) { + errorMessage = "数据验证失败,存在不是当前应用的数据源!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + List onlinePageDatasourceList = + MyModelUtil.copyCollectionTo(onlinePageDatasourceDtoList, OnlinePageDatasource.class); + onlinePageService.addOnlinePageDatasourceList(onlinePageDatasourceList, pageId); + return ResponseResult.success(); + } + + /** + * 显示在线表单页面和指定数据源的多对多关联详情数据。 + * + * @param pageId 主表主键Id。 + * @param datasourceId 从表主键Id。 + * @return 应答结果对象,包括中间表详情。 + */ + @SaCheckPermission("onlinePage.all") + @GetMapping("/viewOnlinePageDatasource") + public ResponseResult viewOnlinePageDatasource( + @RequestParam Long pageId, @RequestParam Long datasourceId) { + ResponseResult verifyResult = this.doVerifyAndGet(pageId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlinePageDatasource onlinePageDatasource = onlinePageService.getOnlinePageDatasource(pageId, datasourceId); + if (onlinePageDatasource == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + OnlinePageDatasourceVo onlinePageDatasourceVo = + MyModelUtil.copyTo(onlinePageDatasource, OnlinePageDatasourceVo.class); + return ResponseResult.success(onlinePageDatasourceVo); + } + + /** + * 移除指定在线表单页面和指定数据源的多对多关联关系。 + * + * @param pageId 主表主键Id。 + * @param datasourceId 从表主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.DELETE_M2M) + @PostMapping("/deleteOnlinePageDatasource") + public ResponseResult deleteOnlinePageDatasource( + @MyRequestBody Long pageId, @MyRequestBody(required = true) Long datasourceId) { + ResponseResult verifyResult = this.doVerifyAndGet(pageId); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (!onlinePageService.removeOnlinePageDatasource(pageId, datasourceId)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + private ResponseResult doVerifyAndGet(Long pageId) { + String errorMessage; + if (MyCommonUtil.existBlankArgument(pageId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + OnlinePage onlinePage = onlinePageService.getById(pageId); + if (onlinePage == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + TokenData tokenData = TokenData.takeFromRequest(); + if (!StrUtil.equals(onlinePage.getAppCode(), tokenData.getAppCode())) { + errorMessage = "数据验证失败,当前应用不存在该页面!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (ObjectUtil.notEqual(onlinePage.getTenantId(), tokenData.getTenantId())) { + errorMessage = "数据验证失败,当前租户不包含该页面!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(onlinePage); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineRuleController.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineRuleController.java new file mode 100644 index 00000000..b5491b5a --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineRuleController.java @@ -0,0 +1,175 @@ +package com.orangeforms.common.online.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +import cn.hutool.core.util.StrUtil; +import cn.hutool.core.util.BooleanUtil; +import com.orangeforms.common.core.annotation.MyRequestBody; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.MyPageUtil; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.online.dto.OnlineRuleDto; +import com.orangeforms.common.online.model.OnlineRule; +import com.orangeforms.common.online.service.OnlineRuleService; +import com.orangeforms.common.online.vo.OnlineRuleVo; +import com.github.pagehelper.page.PageMethod; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; + +import jakarta.validation.groups.Default; +import java.util.List; + +/** + * 在线表单字段验证规则接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "在线表单字段验证规则接口") +@Slf4j +@RestController +@RequestMapping("${common-online.urlPrefix}/onlineRule") +@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true") +public class OnlineRuleController { + + @Autowired + private OnlineRuleService onlineRuleService; + + /** + * 新增验证规则数据。 + * + * @param onlineRuleDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"onlineRuleDto.ruleId"}) + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody OnlineRuleDto onlineRuleDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineRuleDto); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineRule onlineRule = MyModelUtil.copyTo(onlineRuleDto, OnlineRule.class); + onlineRule = onlineRuleService.saveNew(onlineRule); + return ResponseResult.success(onlineRule.getRuleId()); + } + + /** + * 更新验证规则数据。 + * + * @param onlineRuleDto 更新对象。 + * @return 应答结果对象。 + */ + @OperationLog(type = SysOperationLogType.UPDATE) + @SaCheckPermission("onlinePage.all") + @PostMapping("/update") + public ResponseResult update(@MyRequestBody OnlineRuleDto onlineRuleDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineRuleDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineRule onlineRule = MyModelUtil.copyTo(onlineRuleDto, OnlineRule.class); + ResponseResult verifyResult = this.doVerifyAndGet(onlineRule.getRuleId(), false); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineRule originalOnlineRule = verifyResult.getData(); + if (!onlineRuleService.update(onlineRule, originalOnlineRule)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 删除验证规则数据。 + * + * @param ruleId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.DELETE) + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long ruleId) { + String errorMessage; + ResponseResult verifyResult = this.doVerifyAndGet(ruleId, false); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (!onlineRuleService.remove(ruleId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的验证规则列表。 + * + * @param onlineRuleDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("onlinePage.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody OnlineRuleDto onlineRuleDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlineRule onlineRuleFilter = MyModelUtil.copyTo(onlineRuleDtoFilter, OnlineRule.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineRule.class); + List onlineRuleList = onlineRuleService.getOnlineRuleListWithRelation(onlineRuleFilter, orderBy); + return ResponseResult.success(MyPageUtil.makeResponseData(onlineRuleList, OnlineRuleVo.class)); + } + + /** + * 查看指定验证规则对象详情。 + * + * @param ruleId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("onlinePage.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long ruleId) { + ResponseResult verifyResult = this.doVerifyAndGet(ruleId, true); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + OnlineRule onlineRule = verifyResult.getData(); + return ResponseResult.success(onlineRule, OnlineRuleVo.class); + } + + private ResponseResult doVerifyAndGet(Long ruleId, boolean readOnly) { + String errorMessage; + if (MyCommonUtil.existBlankArgument(ruleId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + // 验证关联Id的数据合法性 + OnlineRule rule = onlineRuleService.getById(ruleId); + if (rule == null) { + errorMessage = "数据验证失败,当前在线字段规则并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!readOnly && BooleanUtil.isTrue(rule.getBuiltin())) { + errorMessage = "数据验证失败,内置规则不能删除!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + if (!StrUtil.equals(rule.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + errorMessage = "数据验证失败,当前应用并不包含该规则!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + return ResponseResult.success(rule); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineVirtualColumnController.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineVirtualColumnController.java new file mode 100644 index 00000000..f28e81d1 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/controller/OnlineVirtualColumnController.java @@ -0,0 +1,195 @@ +package com.orangeforms.common.online.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.tags.Tag; +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.common.log.annotation.OperationLog; +import com.orangeforms.common.log.model.constant.SysOperationLogType; +import com.orangeforms.common.online.dto.OnlineVirtualColumnDto; +import com.orangeforms.common.online.model.OnlineVirtualColumn; +import com.orangeforms.common.online.model.constant.VirtualType; +import com.orangeforms.common.online.service.OnlineVirtualColumnService; +import com.orangeforms.common.online.vo.OnlineVirtualColumnVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.*; + +import java.util.*; +import jakarta.validation.groups.Default; + +/** + * 在线表单虚拟字段接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Tag(name = "在线表单虚拟字段接口") +@Slf4j +@RestController +@RequestMapping("${common-online.urlPrefix}/onlineVirtualColumn") +@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true") +public class OnlineVirtualColumnController { + + @Autowired + private OnlineVirtualColumnService onlineVirtualColumnService; + + /** + * 新增虚拟字段数据。 + * + * @param onlineVirtualColumnDto 新增对象。 + * @return 应答结果对象,包含新增对象主键Id。 + */ + @ApiOperationSupport(ignoreParameters = {"onlineVirtualColumnDto.virtualColumnId"}) + @SaCheckPermission("onlinePage.all") + @OperationLog(type = SysOperationLogType.ADD) + @PostMapping("/add") + public ResponseResult add(@MyRequestBody OnlineVirtualColumnDto onlineVirtualColumnDto) { + String errorMessage = MyCommonUtil.getModelValidationError(onlineVirtualColumnDto); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineVirtualColumn onlineVirtualColumn = + MyModelUtil.copyTo(onlineVirtualColumnDto, OnlineVirtualColumn.class); + ResponseResult verifyResult = this.doVerify(onlineVirtualColumn, null); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + onlineVirtualColumn = onlineVirtualColumnService.saveNew(onlineVirtualColumn); + return ResponseResult.success(onlineVirtualColumn.getVirtualColumnId()); + } + + /** + * 更新虚拟字段数据。 + * + * @param onlineVirtualColumnDto 更新对象。 + * @return 应答结果对象。 + */ + @OperationLog(type = SysOperationLogType.UPDATE) + @SaCheckPermission("onlinePage.all") + @PostMapping("/update") + public ResponseResult update(@MyRequestBody OnlineVirtualColumnDto onlineVirtualColumnDto) { + String errorMessage = MyCommonUtil.getModelValidationError( + onlineVirtualColumnDto, Default.class, UpdateGroup.class); + if (errorMessage != null) { + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineVirtualColumn onlineVirtualColumn = + MyModelUtil.copyTo(onlineVirtualColumnDto, OnlineVirtualColumn.class); + OnlineVirtualColumn originalOnlineVirtualColumn = + onlineVirtualColumnService.getById(onlineVirtualColumn.getVirtualColumnId()); + if (originalOnlineVirtualColumn == null) { + errorMessage = "数据验证失败,当前虚拟字段并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + ResponseResult verifyResult = this.doVerify(onlineVirtualColumn, originalOnlineVirtualColumn); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + if (!onlineVirtualColumnService.update(onlineVirtualColumn, originalOnlineVirtualColumn)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(); + } + + /** + * 删除虚拟字段数据。 + * + * @param virtualColumnId 删除对象主键Id。 + * @return 应答结果对象。 + */ + @OperationLog(type = SysOperationLogType.DELETE) + @SaCheckPermission("onlinePage.all") + @PostMapping("/delete") + public ResponseResult delete(@MyRequestBody Long virtualColumnId) { + String errorMessage; + if (MyCommonUtil.existBlankArgument(virtualColumnId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + // 验证关联Id的数据合法性 + OnlineVirtualColumn originalOnlineVirtualColumn = onlineVirtualColumnService.getById(virtualColumnId); + if (originalOnlineVirtualColumn == null) { + errorMessage = "数据验证失败,当前虚拟字段并不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + if (!onlineVirtualColumnService.remove(virtualColumnId)) { + errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!"; + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); + } + return ResponseResult.success(); + } + + /** + * 列出符合过滤条件的虚拟字段列表。 + * + * @param onlineVirtualColumnDtoFilter 过滤对象。 + * @param orderParam 排序参数。 + * @param pageParam 分页参数。 + * @return 应答结果对象,包含查询结果集。 + */ + @SaCheckPermission("onlinePage.all") + @PostMapping("/list") + public ResponseResult> list( + @MyRequestBody OnlineVirtualColumnDto onlineVirtualColumnDtoFilter, + @MyRequestBody MyOrderParam orderParam, + @MyRequestBody MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + OnlineVirtualColumn onlineVirtualColumnFilter = + MyModelUtil.copyTo(onlineVirtualColumnDtoFilter, OnlineVirtualColumn.class); + String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineVirtualColumn.class); + List onlineVirtualColumnList = + onlineVirtualColumnService.getOnlineVirtualColumnListWithRelation(onlineVirtualColumnFilter, orderBy); + MyPageData pageData = + MyPageUtil.makeResponseData(onlineVirtualColumnList, OnlineVirtualColumnVo.class); + return ResponseResult.success(pageData); + } + + /** + * 查看指定虚拟字段对象详情。 + * + * @param virtualColumnId 指定对象主键Id。 + * @return 应答结果对象,包含对象详情。 + */ + @SaCheckPermission("onlinePage.all") + @GetMapping("/view") + public ResponseResult view(@RequestParam Long virtualColumnId) { + if (MyCommonUtil.existBlankArgument(virtualColumnId)) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + OnlineVirtualColumn onlineVirtualColumn = + onlineVirtualColumnService.getByIdWithRelation(virtualColumnId, MyRelationParam.full()); + if (onlineVirtualColumn == null) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + return ResponseResult.success(onlineVirtualColumn, OnlineVirtualColumnVo.class); + } + + private ResponseResult doVerify( + OnlineVirtualColumn virtualColumn, OnlineVirtualColumn originalVirtualColumn) { + if (!virtualColumn.getVirtualType().equals(VirtualType.AGGREGATION)) { + return ResponseResult.success(); + } + if (MyCommonUtil.existBlankArgument( + virtualColumn.getAggregationColumnId(), + virtualColumn.getAggregationTableId(), + virtualColumn.getDatasourceId(), + virtualColumn.getRelationId(), + virtualColumn.getAggregationType())) { + String errorMessage = "数据验证失败,数据源、关联关系、聚合表、聚合字段和聚合类型,均不能为空!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + CallResult verifyResult = onlineVirtualColumnService.verifyRelatedData(virtualColumn, originalVirtualColumn); + if (!verifyResult.isSuccess()) { + return ResponseResult.errorFrom(verifyResult); + } + return ResponseResult.success(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineColumnMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineColumnMapper.java new file mode 100644 index 00000000..fbfc638f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineColumnMapper.java @@ -0,0 +1,24 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineColumn; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 字段数据数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineColumnMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param onlineColumnFilter 主表过滤对象。 + * @return 对象列表。 + */ + List getOnlineColumnList(@Param("onlineColumnFilter") OnlineColumn onlineColumnFilter); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineColumnRuleMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineColumnRuleMapper.java new file mode 100644 index 00000000..84128efd --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineColumnRuleMapper.java @@ -0,0 +1,14 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineColumnRule; + +/** + * 数据字段规则访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineColumnRuleMapper extends BaseDaoMapper { + +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDatasourceMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDatasourceMapper.java new file mode 100644 index 00000000..7f5aaca2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDatasourceMapper.java @@ -0,0 +1,60 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineDatasource; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 数据模型数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineDatasourceMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param onlineDatasourceFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getOnlineDatasourceList( + @Param("onlineDatasourceFilter") OnlineDatasource onlineDatasourceFilter, @Param("orderBy") String orderBy); + + /** + * 根据关联主表Id,获取关联从表数据列表。 + * + * @param pageId 关联主表Id。 + * @param onlineDatasourceFilter 从表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 从表数据列表。 + */ + List getOnlineDatasourceListByPageId( + @Param("pageId") Long pageId, + @Param("onlineDatasourceFilter") OnlineDatasource onlineDatasourceFilter, + @Param("orderBy") String orderBy); + + /** + * 根据在线表单Id集合,获取关联的在线数据源对象列表。 + * + * @param formIdSet 在线表单Id集合。 + * @return 与参数表单Id关联的数据源列表。 + */ + List getOnlineDatasourceListByFormIds(@Param("formIdSet") Set formIdSet); + + /** + * 获取在线表单页面和在线表单数据源变量名的映射关系。 + * + * @param pageIds 页面Id集合。 + * @return 在线表单页面和在线表单数据源变量名的映射关系。 + */ + @Select("SELECT a.page_id, b.variable_name FROM zz_online_page_datasource a, zz_online_datasource b" + + " WHERE a.page_id in (${pageIds}) AND a.datasource_id = b.datasource_id") + List> getPageIdAndVariableNameMapByPageIds(@Param("pageIds") String pageIds); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDatasourceRelationMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDatasourceRelationMapper.java new file mode 100644 index 00000000..d68c13a2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDatasourceRelationMapper.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineDatasourceRelation; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 数据关联数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineDatasourceRelationMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getOnlineDatasourceRelationList( + @Param("filter") OnlineDatasourceRelation filter, @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDatasourceTableMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDatasourceTableMapper.java new file mode 100644 index 00000000..a84fbb66 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDatasourceTableMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineDatasourceTable; + +/** + * 数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineDatasourceTableMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDblinkMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDblinkMapper.java new file mode 100644 index 00000000..1941c7f8 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDblinkMapper.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineDblink; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 数据库链接数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineDblinkMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param onlineDblinkFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getOnlineDblinkList( + @Param("onlineDblinkFilter") OnlineDblink onlineDblinkFilter, @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDictMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDictMapper.java new file mode 100644 index 00000000..b22cca72 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineDictMapper.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineDict; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 在线表单字典数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineDictMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param onlineDictFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getOnlineDictList( + @Param("onlineDictFilter") OnlineDict onlineDictFilter, @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineFormDatasourceMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineFormDatasourceMapper.java new file mode 100644 index 00000000..a8485da4 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineFormDatasourceMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineFormDatasource; + +/** + * 在线表单与数据源多对多关联的数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineFormDatasourceMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineFormMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineFormMapper.java new file mode 100644 index 00000000..5adbad02 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineFormMapper.java @@ -0,0 +1,36 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineForm; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 在线表单数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineFormMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param onlineFormFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getOnlineFormList( + @Param("onlineFormFilter") OnlineForm onlineFormFilter, @Param("orderBy") String orderBy); + + /** + * 根据数据源Id,返回使用该数据源的OnlineForm对象。 + * + * @param datasourceId 数据源Id。 + * @param onlineFormFilter 主表过滤对象。 + * @return 使用该数据源的表单列表。 + */ + List getOnlineFormListByDatasourceId( + @Param("datasourceId") Long datasourceId, @Param("onlineFormFilter") OnlineForm onlineFormFilter); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineOperationMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineOperationMapper.java new file mode 100644 index 00000000..025e437c --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineOperationMapper.java @@ -0,0 +1,259 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.online.dto.OnlineFilterDto; +import com.orangeforms.common.online.object.ColumnData; +import com.orangeforms.common.online.object.JoinTableInfo; +import org.apache.ibatis.annotations.*; + +import java.util.List; +import java.util.Map; + +/** + * 在线表单运行时数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Mapper +public interface OnlineOperationMapper { + + /** + * 插入新数据。 + * + * @param tableName 数据表名。 + * @param columnNames 字段名列表。 + * @param columnValueList 字段值列表。 + */ + @Insert("") + void insert( + @Param("tableName") String tableName, + @Param("columnNames") String columnNames, + @Param("columnValueList") List columnValueList); + + /** + * 更新表数据。 + * + * @param tableName 数据表名。 + * @param updateColumnList 更新字段列表。 + * @param filterList SQL过滤条件列表。 + * @param dataPermFilter 数据权限过滤字符串。 + * @return 更新行数。 + */ + @Update("") + int update( + @Param("tableName") String tableName, + @Param("updateColumnList") List updateColumnList, + @Param("filterList") List filterList, + @Param("dataPermFilter") String dataPermFilter); + + /** + * 删除指定数据。 + * + * @param tableName 表名。 + * @param filterList SQL过滤条件列表。 + * @param dataPermFilter 数据权限过滤字符串。 + * @return 删除行数。 + */ + @Delete("") + int delete( + @Param("tableName") String tableName, + @Param("filterList") List filterList, + @Param("dataPermFilter") String dataPermFilter); + + /** + * 执行动态查询,并返回查询结果集。 + * + * @param masterTableName 主表名称。 + * @param joinInfoList 关联表信息列表。 + * @param selectFields 返回字段列表,逗号分隔。 + * @param filterList SQL过滤条件列表。 + * @param dataPermFilter 数据权限过滤字符串。 + * @param orderBy 排序字符串。 + * @return 查询结果集。 + */ + @Select("") + List> getList( + @Param("masterTableName") String masterTableName, + @Param("joinInfoList") List joinInfoList, + @Param("selectFields") String selectFields, + @Param("filterList") List filterList, + @Param("dataPermFilter") String dataPermFilter, + @Param("orderBy") String orderBy); + + /** + * 以字典键值对的方式返回数据。 + * + * @param tableName 表名称。 + * @param selectFields 返回字段列表,逗号分隔。 + * @param filterList SQL过滤条件列表。 + * @param dataPermFilter 数据权限过滤字符串。 + * @return 查询结果集。 + */ + @Select("") + List> getDictList( + @Param("tableName") String tableName, + @Param("selectFields") String selectFields, + @Param("filterList") List filterList, + @Param("dataPermFilter") String dataPermFilter); + + /** + * 根据指定的表名、显示字段列表、过滤条件字符串和分组字段,返回聚合计算后的查询结果。 + * + * @param selectTable 表名称。 + * @param selectFields 返回字段列表,逗号分隔。 + * @param whereClause SQL常量形式的条件从句。 + * @param groupBy 分组字段列表,逗号分隔。 + * @return 对象可选字段Map列表。 + */ + @Select("") + List> getGroupedListByCondition( + @Param("selectTable") String selectTable, + @Param("selectFields") String selectFields, + @Param("whereClause") String whereClause, + @Param("groupBy") String groupBy); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlinePageDatasourceMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlinePageDatasourceMapper.java new file mode 100644 index 00000000..d486645d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlinePageDatasourceMapper.java @@ -0,0 +1,13 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlinePageDatasource; + +/** + * 在线表单页面和数据源关联对象的数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlinePageDatasourceMapper extends BaseDaoMapper { +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlinePageMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlinePageMapper.java new file mode 100644 index 00000000..7ac0841f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlinePageMapper.java @@ -0,0 +1,36 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlinePage; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 在线表单页面数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlinePageMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param onlinePageFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getOnlinePageList( + @Param("onlinePageFilter") OnlinePage onlinePageFilter, @Param("orderBy") String orderBy); + + /** + /** + * 根据数据源Id,返回使用该数据源的OnlinePage对象。 + * + * @param datasourceId 数据源Id。 + * @return 使用该数据源的页面列表。 + */ + List getOnlinePageListByDatasourceId( + @Param("datasourceId") Long datasourceId, @Param("onlinePageFilter") OnlinePage onlinePageFilter); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineRuleMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineRuleMapper.java new file mode 100644 index 00000000..245ba10b --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineRuleMapper.java @@ -0,0 +1,52 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineRule; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 验证规则数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineRuleMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param onlineRuleFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getOnlineRuleList( + @Param("onlineRuleFilter") OnlineRule onlineRuleFilter, @Param("orderBy") String orderBy); + + /** + * 根据关联主表Id,获取关联从表数据列表。 + * + * @param columnId 关联主表Id。 + * @param onlineRuleFilter 从表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 从表数据列表。 + */ + List getOnlineRuleListByColumnId( + @Param("columnId") Long columnId, + @Param("onlineRuleFilter") OnlineRule onlineRuleFilter, + @Param("orderBy") String orderBy); + + /** + * 根据关联主表Id,获取关联从表中没有和主表建立关联关系的数据列表。 + * + * @param columnId 关联主表Id。 + * @param onlineRuleFilter 过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 与主表没有建立关联的从表数据列表。 + */ + List getNotInOnlineRuleListByColumnId( + @Param("columnId") Long columnId, + @Param("onlineRuleFilter") OnlineRule onlineRuleFilter, + @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineTableMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineTableMapper.java new file mode 100644 index 00000000..238c0bae --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineTableMapper.java @@ -0,0 +1,34 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineTable; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 数据表数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineTableMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param onlineTableFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getOnlineTableList( + @Param("onlineTableFilter") OnlineTable onlineTableFilter, @Param("orderBy") String orderBy); + + /** + * 根据数据源Id,获取该数据源及其关联所引用的数据表列表。 + * + * @param datasourceId 指定的数据源Id。 + * @return 该数据源及其关联所引用的数据表列表。 + */ + List getOnlineTableListByDatasourceId(@Param("datasourceId") Long datasourceId); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineVirtualColumnMapper.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineVirtualColumnMapper.java new file mode 100644 index 00000000..78ca3d20 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/OnlineVirtualColumnMapper.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.online.dao; + +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.online.model.OnlineVirtualColumn; +import org.apache.ibatis.annotations.Param; + +import java.util.*; + +/** + * 虚拟字段数据操作访问接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineVirtualColumnMapper extends BaseDaoMapper { + + /** + * 获取过滤后的对象列表。 + * + * @param onlineVirtualColumnFilter 主表过滤对象。 + * @param orderBy 排序字符串,order by从句的参数。 + * @return 对象列表。 + */ + List getOnlineVirtualColumnList( + @Param("onlineVirtualColumnFilter") OnlineVirtualColumn onlineVirtualColumnFilter, @Param("orderBy") String orderBy); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineColumnMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineColumnMapper.xml new file mode 100644 index 00000000..ede95b2e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineColumnMapper.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_online_column.table_id = #{onlineColumnFilter.tableId} + + + AND zz_online_column.column_name = #{onlineColumnFilter.columnName} + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineColumnRuleMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineColumnRuleMapper.xml new file mode 100644 index 00000000..c5afda31 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineColumnRuleMapper.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDatasourceMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDatasourceMapper.xml new file mode 100644 index 00000000..b148a15b --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDatasourceMapper.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_online_datasource.app_code IS NULL + + + AND zz_online_datasource.app_code = #{onlineDatasourceFilter.appCode} + + + AND zz_online_datasource.variable_name = #{onlineDatasourceFilter.variableName} + + + AND zz_online_datasource.datasource_name = #{onlineDatasourceFilter.datasourceName} + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDatasourceRelationMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDatasourceRelationMapper.xml new file mode 100644 index 00000000..c669d3d2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDatasourceRelationMapper.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_online_datasource_relation.app_code IS NULL + + + AND zz_online_datasource_relation.app_code = #{filter.appCode} + + + AND zz_online_datasource_relation.relation_name = #{filter.relationName} + + + AND zz_online_datasource_relation.datasource_id = #{filter.datasourceId} + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDatasourceTableMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDatasourceTableMapper.xml new file mode 100644 index 00000000..d3ba6aaa --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDatasourceTableMapper.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDblinkMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDblinkMapper.xml new file mode 100644 index 00000000..59f94b1e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDblinkMapper.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_online_dblink.app_code IS NULL + + + AND zz_online_dblink.app_code = #{onlineDblinkFilter.appCode} + + + AND zz_online_dblink.dblink_type = #{onlineDblinkFilter.dblinkType} + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDictMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDictMapper.xml new file mode 100644 index 00000000..cf1fa27e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineDictMapper.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_online_dict.dict_id = #{onlineDictFilter.dictId} + + + AND zz_online_dict.app_code IS NULL + + + AND zz_online_dict.app_code = #{onlineDictFilter.appCode} + + + AND zz_online_dict.dict_name = #{onlineDictFilter.dictName} + + + AND zz_online_dict.dict_type = #{onlineDictFilter.dictType} + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineFormDatasourceMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineFormDatasourceMapper.xml new file mode 100644 index 00000000..5d0924ff --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineFormDatasourceMapper.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineFormMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineFormMapper.xml new file mode 100644 index 00000000..a79415be --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineFormMapper.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_online_form.tenant_id IS NULL + + + AND zz_online_form.tenant_id = #{onlineFormFilter.tenantId} + + + AND zz_online_form.app_code IS NULL + + + AND zz_online_form.app_code = #{onlineFormFilter.appCode} + + + AND zz_online_form.page_id = #{onlineFormFilter.pageId} + + + AND zz_online_form.form_code = #{onlineFormFilter.formCode} + + + + AND zz_online_form.form_name LIKE #{safeFormName} + + + AND zz_online_form.form_type = #{onlineFormFilter.formType} + + + AND zz_online_form.master_table_id = #{onlineFormFilter.masterTableId} + + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlinePageDatasourceMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlinePageDatasourceMapper.xml new file mode 100644 index 00000000..47d8b88d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlinePageDatasourceMapper.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlinePageMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlinePageMapper.xml new file mode 100644 index 00000000..86aeeb21 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlinePageMapper.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_online_page.tenant_id IS NULL + + + AND zz_online_page.tenant_id = #{onlinePageFilter.tenantId} + + + AND zz_online_page.app_code IS NULL + + + AND zz_online_page.app_code = #{onlinePageFilter.appCode} + + + AND zz_online_page.page_code = #{onlinePageFilter.pageCode} + + + + AND zz_online_page.page_name LIKE #{safePageName} + + + AND zz_online_page.page_type = #{onlinePageFilter.pageType} + + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineRuleMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineRuleMapper.xml new file mode 100644 index 00000000..35095622 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineRuleMapper.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + AND (zz_online_rule.app_code IS NULL OR zz_online_rule.builtin = 1) + + + AND (zz_online_rule.app_code = #{onlineRuleFilter.appCode} OR zz_online_rule.builtin = 1) + + + AND zz_online_rule.deleted_flag = ${@com.orangeforms.common.core.constant.GlobalDeletedFlag@NORMAL} + + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineTableMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineTableMapper.xml new file mode 100644 index 00000000..abb2569b --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineTableMapper.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_online_table.app_code IS NULL + + + AND zz_online_table.app_code = #{onlineTableFilter.appCode} + + + AND zz_online_table.table_name = #{onlineTableFilter.tableName} + + + AND zz_online_table.model_name = #{onlineTableFilter.modelName} + + + AND zz_online_table.dblink_id = #{onlineTableFilter.dblinkId} + + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineVirtualColumnMapper.xml b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineVirtualColumnMapper.xml new file mode 100644 index 00000000..1dbc69e8 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dao/mapper/OnlineVirtualColumnMapper.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND zz_online_virtual_column.datasource_id = #{onlineVirtualColumnFilter.datasourceId} + + + AND zz_online_virtual_column.relation_id = #{onlineVirtualColumnFilter.relationId} + + + AND zz_online_virtual_column.table_id = #{onlineVirtualColumnFilter.tableId} + + + AND zz_online_virtual_column.aggregation_column_id = #{onlineVirtualColumnFilter.aggregationColumnId} + + + AND zz_online_virtual_column.virtual_type = #{onlineVirtualColumnFilter.virtualType} + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineColumnDto.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineColumnDto.java new file mode 100644 index 00000000..a3713cbf --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineColumnDto.java @@ -0,0 +1,189 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.validator.ConstDictRef; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.online.model.constant.FieldFilterType; +import com.orangeforms.common.online.model.constant.FieldKind; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 在线表单数据表字段Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单数据表字段Dto对象") +@Data +public class OnlineColumnDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long columnId; + + /** + * 字段名。 + */ + @Schema(description = "字段名") + @NotBlank(message = "数据验证失败,字段名不能为空!") + private String columnName; + + /** + * 数据表Id。 + */ + @Schema(description = "数据表Id") + @NotNull(message = "数据验证失败,数据表Id不能为空!") + private Long tableId; + + /** + * 数据表中的字段类型。 + */ + @Schema(description = "数据表中的字段类型") + @NotBlank(message = "数据验证失败,数据表中的字段类型不能为空!") + private String columnType; + + /** + * 数据表中的完整字段类型(包括了精度和刻度)。 + */ + @Schema(description = "数据表中的完整字段类型") + @NotBlank(message = "数据验证失败,数据表中的完整字段类型(包括了精度和刻度)不能为空!") + private String fullColumnType; + + /** + * 是否为主键。 + */ + @Schema(description = "是否为主键") + @NotNull(message = "数据验证失败,是否为主键不能为空!") + private Boolean primaryKey; + + /** + * 是否是自增主键(0: 不是 1: 是)。 + */ + @Schema(description = "是否是自增主键") + @NotNull(message = "数据验证失败,是否是自增主键(0: 不是 1: 是)不能为空!") + private Boolean autoIncrement; + + /** + * 是否可以为空 (0: 不可以为空 1: 可以为空)。 + */ + @Schema(description = "是否可以为空") + @NotNull(message = "数据验证失败,是否可以为空 (0: 不可以为空 1: 可以为空)不能为空!") + private Boolean nullable; + + /** + * 缺省值。 + */ + @Schema(description = "缺省值") + private String columnDefault; + + /** + * 字段在数据表中的显示位置。 + */ + @Schema(description = "字段在数据表中的显示位置") + @NotNull(message = "数据验证失败,字段在数据表中的显示位置不能为空!") + private Integer columnShowOrder; + + /** + * 数据表中的字段注释。 + */ + @Schema(description = "数据表中的字段注释") + private String columnComment; + + /** + * 对象映射字段名称。 + */ + @Schema(description = "对象映射字段名称") + @NotBlank(message = "数据验证失败,对象映射字段名称不能为空!") + private String objectFieldName; + + /** + * 对象映射字段类型。 + */ + @Schema(description = "对象映射字段类型") + @NotBlank(message = "数据验证失败,对象映射字段类型不能为空!") + private String objectFieldType; + + /** + * 数值型字段的精度(目前仅Oracle使用)。 + */ + @Schema(description = "数值型字段的精度") + private Integer numericPrecision; + + /** + * 数值型字段的刻度(小数点后位数,目前仅Oracle使用)。 + */ + @Schema(description = "数值型字段的刻度") + private Integer numericScale; + + /** + * 过滤类型字段。 + */ + @Schema(description = "过滤类型字段") + @NotNull(message = "数据验证失败,过滤类型字段不能为空!", groups = {UpdateGroup.class}) + @ConstDictRef(constDictClass = FieldFilterType.class, message = "数据验证失败,过滤类型字段为无效值!") + private Integer filterType; + + /** + * 是否是主键的父Id。 + */ + @Schema(description = "是否是主键的父Id") + @NotNull(message = "数据验证失败,是否是主键的父Id不能为空!") + private Boolean parentKey; + + /** + * 是否部门过滤字段。 + */ + @Schema(description = "是否部门过滤字段") + @NotNull(message = "数据验证失败,是否部门过滤字段标记不能为空!") + private Boolean deptFilter; + + /** + * 是否用户过滤字段。 + */ + @Schema(description = "是否用户过滤字段") + @NotNull(message = "数据验证失败,是否用户过滤字段标记不能为空!") + private Boolean userFilter; + + /** + * 字段类别。 + */ + @Schema(description = "字段类别") + @ConstDictRef(constDictClass = FieldKind.class, message = "数据验证失败,字段类别为无效值!") + private Integer fieldKind; + + /** + * 包含的文件文件数量,0表示无限制。 + */ + @Schema(description = "包含的文件文件数量,0表示无限制") + private Integer maxFileCount; + + /** + * 上传文件系统类型。 + */ + @Schema(description = "上传文件系统类型") + private Integer uploadFileSystemType; + + /** + * 脱敏字段类型,具体值可参考MaskFieldTypeEnum枚举。 + */ + @Schema(description = "脱敏字段类型") + private String maskFieldType; + + /** + * 编码规则的JSON格式数据。 + */ + @Schema(description = "编码规则的JSON格式数据") + private String encodedRule; + + /** + * 字典Id。 + */ + @Schema(description = "字典Id") + private Long dictId; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineColumnRuleDto.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineColumnRuleDto.java new file mode 100644 index 00000000..d6789157 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineColumnRuleDto.java @@ -0,0 +1,38 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.validator.UpdateGroup; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotNull; + +/** + * 在线表单数据表字段规则和字段多对多关联Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单数据表字段规则和字段多对多关联Dto对象") +@Data +public class OnlineColumnRuleDto { + + /** + * 字段Id。 + */ + @Schema(description = "字段Id") + @NotNull(message = "数据验证失败,字段Id不能为空!", groups = {UpdateGroup.class}) + private Long columnId; + + /** + * 规则Id。 + */ + @Schema(description = "规则Id") + @NotNull(message = "数据验证失败,规则Id不能为空!", groups = {UpdateGroup.class}) + private Long ruleId; + + /** + * 规则属性数据。 + */ + @Schema(description = "规则属性数据") + private String propDataJson; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDatasourceDto.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDatasourceDto.java new file mode 100644 index 00000000..0fbb006d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDatasourceDto.java @@ -0,0 +1,62 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.validator.AddGroup; +import com.orangeforms.common.core.validator.UpdateGroup; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 在线表单的数据源Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单的数据源Dto对象") +@Data +public class OnlineDatasourceDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long datasourceId; + + /** + * 数据源名称。 + */ + @Schema(description = "数据源名称") + @NotBlank(message = "数据验证失败,数据源名称不能为空!") + private String datasourceName; + + /** + * 数据源变量名,会成为数据访问url的一部分。 + */ + @Schema(description = "数据源变量名,会成为数据访问url的一部分") + @NotBlank(message = "数据验证失败,数据源变量名不能为空!") + private String variableName; + + /** + * 主表所在的数据库链接Id。 + */ + @Schema(description = "主表所在的数据库链接Id") + @NotNull(message = "数据验证失败,数据库链接Id不能为空!") + private Long dblinkId; + + /** + * 主表Id。 + */ + @Schema(description = "主表Id") + @NotNull(message = "数据验证失败,主表Id不能为空!", groups = {UpdateGroup.class}) + private Long masterTableId; + + /** + * 主表表名。 + */ + @Schema(description = "主表表名") + @NotBlank(message = "数据验证失败,主表名不能为空!", groups = {AddGroup.class}) + private String masterTableName; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDatasourceRelationDto.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDatasourceRelationDto.java new file mode 100644 index 00000000..3ad19465 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDatasourceRelationDto.java @@ -0,0 +1,107 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.validator.AddGroup; +import com.orangeforms.common.core.validator.ConstDictRef; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.online.model.constant.RelationType; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 在线表单的数据源关联Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单的数据源关联Dto对象") +@Data +public class OnlineDatasourceRelationDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long relationId; + + /** + * 关联名称。 + */ + @Schema(description = "关联名称") + @NotBlank(message = "数据验证失败,关联名称不能为空!") + private String relationName; + + /** + * 变量名。 + */ + @Schema(description = "变量名") + @NotBlank(message = "数据验证失败,变量名不能为空!") + private String variableName; + + /** + * 主数据源Id。 + */ + @Schema(description = "主数据源Id") + @NotNull(message = "数据验证失败,主数据源Id不能为空!") + private Long datasourceId; + + /** + * 关联类型。 + */ + @Schema(description = "关联类型") + @NotNull(message = "数据验证失败,关联类型不能为空!") + @ConstDictRef(constDictClass = RelationType.class, message = "数据验证失败,关联类型为无效值!") + private Integer relationType; + + /** + * 主表关联字段Id。 + */ + @Schema(description = "主表关联字段Id") + @NotNull(message = "数据验证失败,主表关联字段Id不能为空!") + private Long masterColumnId; + + /** + * 从表Id。 + */ + @Schema(description = "从表Id") + @NotNull(message = "数据验证失败,从表Id不能为空!", groups = {UpdateGroup.class}) + private Long slaveTableId; + + /** + * 从表名。 + */ + @Schema(description = "从表名") + @NotBlank(message = "数据验证失败,从表名不能为空!", groups = {AddGroup.class}) + private String slaveTableName; + + /** + * 从表关联字段Id。 + */ + @Schema(description = "从表关联字段Id") + @NotNull(message = "数据验证失败,从表关联字段Id不能为空!", groups = {UpdateGroup.class}) + private Long slaveColumnId; + + /** + * 从表字段名。 + */ + @Schema(description = "从表字段名") + @NotBlank(message = "数据验证失败,从表字段名不能为空!", groups = {AddGroup.class}) + private String slaveColumnName; + + /** + * 是否级联删除标记。 + */ + @Schema(description = "是否级联删除标记") + @NotNull(message = "数据验证失败,是否级联删除标记不能为空!") + private Boolean cascadeDelete; + + /** + * 是否左连接标记。 + */ + @Schema(description = "是否左连接标记") + @NotNull(message = "数据验证失败,是否左连接标记不能为空!") + private Boolean leftJoin; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDblinkDto.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDblinkDto.java new file mode 100644 index 00000000..2e1f2488 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDblinkDto.java @@ -0,0 +1,53 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.validator.UpdateGroup; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 在线表单数据表所在数据库链接Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单数据表所在数据库链接Dto对象") +@Data +public class OnlineDblinkDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long dblinkId; + + /** + * 链接中文名称。 + */ + @Schema(description = "链接中文名称") + @NotBlank(message = "数据验证失败,链接中文名称不能为空!") + private String dblinkName; + + /** + * 链接描述。 + */ + @Schema(description = "链接中文名称") + private String dblinkDescription; + + /** + * 配置信息。 + */ + @Schema(description = "配置信息") + @NotBlank(message = "数据验证失败,配置信息不能为空!") + private String configuration; + + /** + * 数据库链接类型。 + */ + @Schema(description = "数据库链接类型") + @NotNull(message = "数据验证失败,数据库链接类型不能为空!") + private Integer dblinkType; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDictDto.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDictDto.java new file mode 100644 index 00000000..f25444ce --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineDictDto.java @@ -0,0 +1,128 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.validator.ConstDictRef; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.core.constant.DictType; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 在线表单关联的字典Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单关联的字典Dto对象") +@Data +public class OnlineDictDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long dictId; + + /** + * 字典名称。 + */ + @Schema(description = "字典名称") + @NotBlank(message = "数据验证失败,字典名称不能为空!") + private String dictName; + + /** + * 字典类型。 + */ + @Schema(description = "字典类型") + @NotNull(message = "数据验证失败,字典类型不能为空!") + @ConstDictRef(constDictClass = DictType.class, message = "数据验证失败,字典类型为无效值!") + private Integer dictType; + + /** + * 数据库链接Id。 + */ + @Schema(description = "数据库链接Id") + private Long dblinkId; + + /** + * 字典表名称。 + */ + @Schema(description = "字典表名称") + private String tableName; + + /** + * 全局字典编码。 + */ + @Schema(description = "全局字典编码") + private String dictCode; + + /** + * 字典表键字段名称。 + */ + @Schema(description = "字典表键字段名称") + private String keyColumnName; + + /** + * 字典表父键字段名称。 + */ + @Schema(description = "字典表父键字段名称") + private String parentKeyColumnName; + + /** + * 字典值字段名称。 + */ + @Schema(description = "字典值字段名称") + private String valueColumnName; + + /** + * 逻辑删除字段。 + */ + @Schema(description = "逻辑删除字段") + private String deletedColumnName; + + /** + * 用户过滤滤字段名称。 + */ + @Schema(description = "用户过滤滤字段名称") + private String userFilterColumnName; + + /** + * 部门过滤字段名称。 + */ + @Schema(description = "部门过滤字段名称") + private String deptFilterColumnName; + + /** + * 租户过滤字段名称。 + */ + @Schema(description = "租户过滤字段名称") + private String tenantFilterColumnName; + + /** + * 获取字典数据的url。 + */ + @Schema(description = "获取字典数据的url") + private String dictListUrl; + + /** + * 根据主键id批量获取字典数据的url。 + */ + @Schema(description = "根据主键id批量获取字典数据的url") + private String dictIdsUrl; + + /** + * 字典的JSON数据。 + */ + @Schema(description = "字典的JSON数据") + private String dictDataJson; + + /** + * 是否树形标记。 + */ + @Schema(description = "是否树形标记") + @NotNull(message = "数据验证失败,是否树形标记不能为空!") + private Boolean treeFlag; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineFilterDto.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineFilterDto.java new file mode 100644 index 00000000..8d638b90 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineFilterDto.java @@ -0,0 +1,72 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.online.model.constant.FieldFilterType; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.util.Set; + +/** + * 在线表单数据过滤参数对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单数据过滤参数对象") +@Data +public class OnlineFilterDto { + + /** + * 表名。 + */ + @Schema(description = "表名") + private String tableName; + + /** + * 过滤字段名。 + */ + @Schema(description = "过滤字段名") + private String columnName; + + /** + * 过滤值。 + */ + @Schema(description = "过滤值") + private Object columnValue; + + /** + * 范围比较的最小值。 + */ + @Schema(description = "范围比较的最小值") + private Object columnValueStart; + + /** + * 范围比较的最大值。 + */ + @Schema(description = "范围比较的最大值") + private Object columnValueEnd; + + /** + * 仅当操作符为IN的时候使用。 + */ + @Schema(description = "仅当操作符为IN的时候使用") + private Set columnValueList; + + /** + * 过滤类型,参考FieldFilterType常量对象。缺省值就是等于过滤了。 + */ + @Schema(description = "过滤类型") + private Integer filterType = FieldFilterType.EQUAL_FILTER; + + /** + * 是否为字典多选。 + */ + @Schema(description = "是否为字典多选") + private Boolean dictMultiSelect = false; + + /** + * 是否为Oracle的日期类型。 + */ + private Boolean isOracleDate = false; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineFormDto.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineFormDto.java new file mode 100644 index 00000000..2abcde8c --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineFormDto.java @@ -0,0 +1,91 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.validator.ConstDictRef; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.online.model.constant.FormKind; +import com.orangeforms.common.online.model.constant.FormType; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import java.util.List; + +/** + * 在线表单Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单Dto对象") +@Data +public class OnlineFormDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long formId; + + /** + * 页面id。 + */ + @Schema(description = "页面id") + @NotNull(message = "数据验证失败,页面id不能为空!") + private Long pageId; + + /** + * 表单编码。 + */ + @Schema(description = "表单编码") + private String formCode; + + /** + * 表单名称。 + */ + @Schema(description = "表单名称") + @NotBlank(message = "数据验证失败,表单名称不能为空!") + private String formName; + + /** + * 表单类别。 + */ + @Schema(description = "表单类别") + @NotNull(message = "数据验证失败,表单类别不能为空!") + @ConstDictRef(constDictClass = FormKind.class, message = "数据验证失败,表单类别为无效值!") + private Integer formKind; + + /** + * 表单类型。 + */ + @Schema(description = "表单类型") + @NotNull(message = "数据验证失败,表单类型不能为空!") + @ConstDictRef(constDictClass = FormType.class, message = "数据验证失败,表单类型为无效值!") + private Integer formType; + + /** + * 表单主表id。 + */ + @Schema(description = "表单主表id") + @NotNull(message = "数据验证失败,表单主表id不能为空!") + private Long masterTableId; + + /** + * 当前表单关联的数据源Id集合。 + */ + @Schema(description = "当前表单关联的数据源Id集合") + private List datasourceIdList; + + /** + * 表单组件JSON。 + */ + @Schema(description = "表单组件JSON") + private String widgetJson; + + /** + * 表单参数JSON。 + */ + @Schema(description = "表单参数JSON") + private String paramsJson; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlinePageDatasourceDto.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlinePageDatasourceDto.java new file mode 100644 index 00000000..e6a3c3c3 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlinePageDatasourceDto.java @@ -0,0 +1,39 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.validator.UpdateGroup; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotNull; + +/** + * 在线表单页面和数据源多对多关联Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单页面和数据源多对多关联Dto对象") +@Data +public class OnlinePageDatasourceDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long id; + + /** + * 页面主键Id。 + */ + @Schema(description = "页面主键Id") + @NotNull(message = "数据验证失败,页面主键Id不能为空!") + private Long pageId; + + /** + * 数据源主键Id。 + */ + @Schema(description = "数据源主键Id") + @NotNull(message = "数据验证失败,数据源主键Id不能为空!") + private Long datasourceId; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlinePageDto.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlinePageDto.java new file mode 100644 index 00000000..309c3bf4 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlinePageDto.java @@ -0,0 +1,58 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.validator.ConstDictRef; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.online.model.constant.PageStatus; +import com.orangeforms.common.online.model.constant.PageType; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 在线表单所在页面Dto对象。这里我们可以把页面理解为表单的容器。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单所在页面Dto对象") +@Data +public class OnlinePageDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long pageId; + + /** + * 页面编码。 + */ + @Schema(description = "页面编码") + private String pageCode; + + /** + * 页面名称。 + */ + @Schema(description = "页面名称") + @NotBlank(message = "数据验证失败,页面名称不能为空!") + private String pageName; + + /** + * 页面类型。 + */ + @Schema(description = "页面类型") + @NotNull(message = "数据验证失败,页面类型不能为空!") + @ConstDictRef(constDictClass = PageType.class, message = "数据验证失败,页面类型为无效值!") + private Integer pageType; + + /** + * 页面编辑状态。 + */ + @Schema(description = "页面编辑状态") + @NotNull(message = "数据验证失败,状态不能为空!") + @ConstDictRef(constDictClass = PageStatus.class, message = "数据验证失败,状态为无效值!") + private Integer status; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineRuleDto.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineRuleDto.java new file mode 100644 index 00000000..e89517c0 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineRuleDto.java @@ -0,0 +1,56 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.validator.ConstDictRef; +import com.orangeforms.common.core.validator.UpdateGroup; +import com.orangeforms.common.online.model.constant.RuleType; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 在线表单数据表字段验证规则Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单数据表字段验证规则Dto对象") +@Data +public class OnlineRuleDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long ruleId; + + /** + * 规则名称。 + */ + @Schema(description = "规则名称") + @NotBlank(message = "数据验证失败,规则名称不能为空!") + private String ruleName; + + /** + * 规则类型。 + */ + @Schema(description = "规则类型") + @NotNull(message = "数据验证失败,规则类型不能为空!") + @ConstDictRef(constDictClass = RuleType.class, message = "数据验证失败,规则类型为无效值!") + private Integer ruleType; + + /** + * 内置规则标记。 + */ + @Schema(description = "内置规则标记") + @NotNull(message = "数据验证失败,内置规则标记不能为空!") + private Boolean builtin; + + /** + * 自定义规则的正则表达式。 + */ + @Schema(description = "自定义规则的正则表达式") + private String pattern; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineTableDto.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineTableDto.java new file mode 100644 index 00000000..774f985b --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineTableDto.java @@ -0,0 +1,47 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.validator.UpdateGroup; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 在线表单的数据表Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单的数据表Dto对象") +@Data +public class OnlineTableDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long tableId; + + /** + * 表名称。 + */ + @Schema(description = "表名称") + @NotBlank(message = "数据验证失败,表名称不能为空!") + private String tableName; + + /** + * 实体名称。 + */ + @Schema(description = "实体名称") + @NotBlank(message = "数据验证失败,实体名称不能为空!") + private String modelName; + + /** + * 数据库链接Id。 + */ + @Schema(description = "数据库链接Id") + @NotNull(message = "数据验证失败,数据库链接Id不能为空!") + private Long dblinkId; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineVirtualColumnDto.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineVirtualColumnDto.java new file mode 100644 index 00000000..040850de --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/dto/OnlineVirtualColumnDto.java @@ -0,0 +1,102 @@ +package com.orangeforms.common.online.dto; + +import com.orangeforms.common.core.constant.AggregationType; +import com.orangeforms.common.core.validator.ConstDictRef; +import com.orangeforms.common.core.validator.UpdateGroup; +import io.swagger.v3.oas.annotations.media.Schema; + +import com.orangeforms.common.online.model.constant.VirtualType; +import lombok.Data; + +import jakarta.validation.constraints.*; + +/** + * 在线数据表虚拟字段Dto对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线数据表虚拟字段Dto对象") +@Data +public class OnlineVirtualColumnDto { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + @NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class}) + private Long virtualColumnId; + + /** + * 所在表Id。 + */ + @Schema(description = "所在表Id") + private Long tableId; + + /** + * 字段名称。 + */ + @Schema(description = "字段名称") + @NotBlank(message = "数据验证失败,字段名称不能为空!") + private String objectFieldName; + + /** + * 属性类型。 + */ + @Schema(description = "属性类型") + @NotBlank(message = "数据验证失败,属性类型不能为空!") + private String objectFieldType; + + /** + * 字段提示名。 + */ + @Schema(description = "字段提示名") + @NotBlank(message = "数据验证失败,字段提示名不能为空!") + private String columnPrompt; + + /** + * 虚拟字段类型(0: 聚合)。 + */ + @Schema(description = "虚拟字段类型(0: 聚合)") + @ConstDictRef(constDictClass = VirtualType.class, message = "数据验证失败,虚拟字段类型为无效值!") + @NotNull(message = "数据验证失败,虚拟字段类型(0: 聚合)不能为空!") + private Integer virtualType; + + /** + * 关联数据源Id。 + */ + @Schema(description = "关联数据源Id") + @NotNull(message = "数据验证失败,关联数据源Id不能为空!") + private Long datasourceId; + + /** + * 关联Id。 + */ + @Schema(description = "关联Id") + private Long relationId; + + /** + * 聚合字段所在关联表Id。 + */ + @Schema(description = "聚合字段所在关联表Id") + private Long aggregationTableId; + + /** + * 关联表聚合字段Id。 + */ + @Schema(description = "关联表聚合字段Id") + private Long aggregationColumnId; + + /** + * 聚合类型(0: sum 1: count 2: avg 3: min 4: max)。 + */ + @Schema(description = "聚合类型(0: sum 1: count 2: avg 3: min 4: max)") + @ConstDictRef(constDictClass = AggregationType.class, message = "数据验证失败,虚拟字段聚合计算类型为无效值!") + private Integer aggregationType; + + /** + * 存储过滤条件的json。 + */ + @Schema(description = "存储过滤条件的json") + private String whereClauseJson; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/exception/OnlineRuntimeException.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/exception/OnlineRuntimeException.java new file mode 100644 index 00000000..a2ac52f2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/exception/OnlineRuntimeException.java @@ -0,0 +1,28 @@ +package com.orangeforms.common.online.exception; + +import com.orangeforms.common.core.exception.MyRuntimeException; + +/** + * 在线表单运行时异常。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class OnlineRuntimeException extends MyRuntimeException { + + /** + * 构造函数。 + */ + public OnlineRuntimeException() { + + } + + /** + * 构造函数。 + * + * @param msg 错误信息。 + */ + public OnlineRuntimeException(String msg) { + super(msg); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineColumn.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineColumn.java new file mode 100644 index 00000000..fd2466c4 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineColumn.java @@ -0,0 +1,215 @@ +package com.orangeforms.common.online.model; + +import com.baomidou.mybatisplus.annotation.*; +import com.orangeforms.common.core.annotation.RelationConstDict; +import com.orangeforms.common.core.annotation.RelationOneToOne; +import com.orangeforms.common.online.model.constant.FieldKind; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单数据表字段实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_online_column") +public class OnlineColumn { + + /** + * 主键Id。 + */ + @TableId(value = "column_id") + private Long columnId; + + /** + * 字段名。 + */ + @TableField(value = "column_name") + private String columnName; + + /** + * 数据表Id。 + */ + @TableField(value = "table_id") + private Long tableId; + + /** + * 数据表中的字段类型。 + */ + @TableField(value = "column_type") + private String columnType; + + /** + * 数据表中的完整字段类型(包括了精度和刻度)。 + */ + @TableField(value = "full_column_type") + private String fullColumnType; + + /** + * 是否为主键。 + */ + @TableField(value = "primary_key") + private Boolean primaryKey; + + /** + * 是否是自增主键(0: 不是 1: 是)。 + */ + @TableField(value = "auto_incr") + private Boolean autoIncrement; + + /** + * 是否可以为空 (0: 不可以为空 1: 可以为空)。 + */ + @TableField(value = "nullable") + private Boolean nullable; + + /** + * 缺省值。 + */ + @TableField(value = "column_default") + private String columnDefault; + + /** + * 字段在数据表中的显示位置。 + */ + @TableField(value = "column_show_order") + private Integer columnShowOrder; + + /** + * 数据表中的字段注释。 + */ + @TableField(value = "column_comment") + private String columnComment; + + /** + * 对象映射字段名称。 + */ + @TableField(value = "object_field_name") + private String objectFieldName; + + /** + * 对象映射字段类型。 + */ + @TableField(value = "object_field_type") + private String objectFieldType; + + /** + * 数值型字段的精度(目前仅Oracle使用)。 + */ + @TableField(value = "numeric_precision") + private Integer numericPrecision; + + /** + * 数值型字段的刻度(小数点后位数,目前仅Oracle使用)。 + */ + @TableField(value = "numeric_scale") + private Integer numericScale; + + /** + * 过滤字段类型。 + */ + @TableField(value = "filter_type") + private Integer filterType; + + /** + * 是否是主键的父Id。 + */ + @TableField(value = "parent_key") + private Boolean parentKey; + + /** + * 是否部门过滤字段。 + */ + @TableField(value = "dept_filter") + private Boolean deptFilter; + + /** + * 是否用户过滤字段。 + */ + @TableField(value = "user_filter") + private Boolean userFilter; + + /** + * 字段类别。 + */ + @TableField(value = "field_kind") + private Integer fieldKind; + + /** + * 包含的文件文件数量,0表示无限制。 + */ + @TableField(value = "max_file_count") + private Integer maxFileCount; + + /** + * 上传文件系统类型。 + */ + @TableField(value = "upload_file_system_type") + private Integer uploadFileSystemType; + + /** + * 编码规则的JSON格式数据。 + */ + @TableField(value = "encoded_rule") + private String encodedRule; + + /** + * 脱敏字段类型,具体值可参考MaskFieldTypeEnum枚举。 + */ + @TableField(value = "mask_field_type") + private String maskFieldType; + + /** + * 字典Id。 + */ + @TableField(value = "dict_id") + private Long dictId; + + /** + * 创建时间。 + */ + @TableField(value = "create_time") + private Date createTime; + + /** + * 创建者。 + */ + @TableField(value = "create_user_id") + private Long createUserId; + + /** + * 更新时间。 + */ + @TableField(value = "update_time") + private Date updateTime; + + /** + * 更新者。 + */ + @TableField(value = "update_user_id") + private Long updateUserId; + + /** + * SQL查询时候使用的别名。 + */ + @TableField(exist = false) + private String columnAliasName; + + @RelationConstDict( + masterIdField = "fieldKind", + constantDictClass = FieldKind.class) + @TableField(exist = false) + private Map fieldKindDictMap; + + @RelationOneToOne( + masterIdField = "dictId", + slaveModelClass = OnlineDict.class, + slaveIdField = "dictId", + loadSlaveDict = false) + @TableField(exist = false) + private OnlineDict dictInfo; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineColumnRule.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineColumnRule.java new file mode 100644 index 00000000..f89876e4 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineColumnRule.java @@ -0,0 +1,36 @@ +package com.orangeforms.common.online.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +/** + * 在线表单数据表字段规则和字段多对多关联实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_online_column_rule") +public class OnlineColumnRule { + + /** + * 字段Id。 + */ + @TableField(value = "column_id") + private Long columnId; + + /** + * 规则Id。 + */ + @TableField(value = "rule_id") + private Long ruleId; + + /** + * 规则属性数据。 + */ + @TableField(value = "prop_data_json") + private String propDataJson; + + @TableField(exist = false) + private OnlineRule onlineRule; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDatasource.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDatasource.java new file mode 100644 index 00000000..e7b16a9c --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDatasource.java @@ -0,0 +1,103 @@ +package com.orangeforms.common.online.model; + +import com.baomidou.mybatisplus.annotation.*; +import com.orangeforms.common.core.annotation.RelationDict; +import lombok.Data; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 在线表单的数据源实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_online_datasource") +public class OnlineDatasource { + + /** + * 主键Id。 + */ + @TableId(value = "datasource_id") + private Long datasourceId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @TableField(value = "app_code") + private String appCode; + + /** + * 数据源名称。 + */ + @TableField(value = "datasource_name") + private String datasourceName; + + /** + * 数据源变量名,会成为数据访问url的一部分。 + */ + @TableField(value = "variable_name") + private String variableName; + + /** + * 数据库链接Id。 + */ + @TableField(value = "dblink_id") + private Long dblinkId; + + /** + * 主表Id。 + */ + @TableField(value = "master_table_id") + private Long masterTableId; + + /** + * 创建时间。 + */ + @TableField(value = "create_time") + private Date createTime; + + /** + * 创建者。 + */ + @TableField(value = "create_user_id") + private Long createUserId; + + /** + * 更新时间。 + */ + @TableField(value = "update_time") + private Date updateTime; + + /** + * 更新者。 + */ + @TableField(value = "update_user_id") + private Long updateUserId; + + /** + * datasourceId 的多对多关联的数据对象。 + */ + @TableField(exist = false) + private OnlinePageDatasource onlinePageDatasource; + + /** + * datasourceId 的多对多关联的数据对象。 + */ + @TableField(exist = false) + private List onlineFormDatasourceList; + + @RelationDict( + masterIdField = "masterTableId", + slaveModelClass = OnlineTable.class, + slaveIdField = "tableId", + slaveNameField = "tableName") + @TableField(exist = false) + private Map masterTableIdDictMap; + + @TableField(exist = false) + private OnlineTable masterTable; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDatasourceRelation.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDatasourceRelation.java new file mode 100644 index 00000000..75161e59 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDatasourceRelation.java @@ -0,0 +1,166 @@ +package com.orangeforms.common.online.model; + +import com.baomidou.mybatisplus.annotation.*; +import com.orangeforms.common.core.annotation.RelationConstDict; +import com.orangeforms.common.core.annotation.RelationDict; +import com.orangeforms.common.core.annotation.RelationOneToOne; +import com.orangeforms.common.online.model.constant.RelationType; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单的数据源关联实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_online_datasource_relation") +public class OnlineDatasourceRelation { + + /** + * 主键Id。 + */ + @TableId(value = "relation_id") + private Long relationId; + + /** + * 应用Id。为空时,表示非第三方应用接入。 + */ + @TableField(value = "app_code") + private String appCode; + + /** + * 关联名称。 + */ + @TableField(value = "relation_name") + private String relationName; + + /** + * 变量名。 + */ + @TableField(value = "variable_name") + private String variableName; + + /** + * 主数据源Id。 + */ + @TableField(value = "datasource_id") + private Long datasourceId; + + /** + * 关联类型。 + */ + @TableField(value = "relation_type") + private Integer relationType; + + /** + * 主表关联字段Id。 + */ + @TableField(value = "master_column_id") + private Long masterColumnId; + + /** + * 从表Id。 + */ + @TableField(value = "slave_table_id") + private Long slaveTableId; + + /** + * 从表关联字段Id。 + */ + @TableField(value = "slave_column_id") + private Long slaveColumnId; + + /** + * 删除主表的时候是否级联删除一对一和一对多的从表数据,多对多只是删除关联,不受到这个标记的影响。。 + */ + @TableField(value = "cascade_delete") + private Boolean cascadeDelete; + + /** + * 是否左连接。 + */ + @TableField(value = "left_join") + private Boolean leftJoin; + + /** + * 创建时间。 + */ + @TableField(value = "create_time") + private Date createTime; + + /** + * 创建者。 + */ + @TableField(value = "create_user_id") + private Long createUserId; + + /** + * 更新时间。 + */ + @TableField(value = "update_time") + private Date updateTime; + + /** + * 更新者。 + */ + @TableField(value = "update_user_id") + private Long updateUserId; + + @RelationOneToOne( + masterIdField = "masterColumnId", + slaveModelClass = OnlineColumn.class, + slaveIdField = "columnId") + @TableField(exist = false) + private OnlineColumn masterColumn; + + @RelationOneToOne( + masterIdField = "slaveTableId", + slaveModelClass = OnlineTable.class, + slaveIdField = "tableId") + @TableField(exist = false) + private OnlineTable slaveTable; + + @RelationOneToOne( + masterIdField = "slaveColumnId", + slaveModelClass = OnlineColumn.class, + slaveIdField = "columnId") + @TableField(exist = false) + private OnlineColumn slaveColumn; + + @RelationDict( + masterIdField = "masterColumnId", + equalOneToOneRelationField = "onlineColumn", + slaveModelClass = OnlineColumn.class, + slaveIdField = "columnId", + slaveNameField = "columnName") + @TableField(exist = false) + private Map masterColumnIdDictMap; + + @RelationDict( + masterIdField = "slaveTableId", + equalOneToOneRelationField = "onlineTable", + slaveModelClass = OnlineTable.class, + slaveIdField = "tableId", + slaveNameField = "modelName") + @TableField(exist = false) + private Map slaveTableIdDictMap; + + @RelationDict( + masterIdField = "slaveColumnId", + equalOneToOneRelationField = "onlineColumn", + slaveModelClass = OnlineColumn.class, + slaveIdField = "columnId", + slaveNameField = "columnName") + @TableField(exist = false) + private Map slaveColumnIdDictMap; + + @RelationConstDict( + masterIdField = "relationType", + constantDictClass = RelationType.class) + @TableField(exist = false) + private Map relationTypeDictMap; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDatasourceTable.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDatasourceTable.java new file mode 100644 index 00000000..d4ea5d92 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDatasourceTable.java @@ -0,0 +1,39 @@ +package com.orangeforms.common.online.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +/** + * 数据源及其关联所引用的数据表实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_online_datasource_table") +public class OnlineDatasourceTable { + + /** + * 主键Id。 + */ + @TableId(value = "id") + private Long id; + + /** + * 数据源Id。 + */ + @TableField(value = "datasource_id") + private Long datasourceId; + + /** + * 数据源关联Id。 + */ + @TableField(value = "relation_id") + private Long relationId; + + /** + * 数据表Id。 + */ + @TableField(value = "table_id") + private Long tableId; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDblink.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDblink.java new file mode 100644 index 00000000..635cbe6d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDblink.java @@ -0,0 +1,85 @@ +package com.orangeforms.common.online.model; + +import com.baomidou.mybatisplus.annotation.*; +import com.orangeforms.common.core.annotation.RelationConstDict; +import com.orangeforms.common.dbutil.constant.DblinkType; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单数据表所在数据库链接实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_online_dblink") +public class OnlineDblink { + + /** + * 主键Id。 + */ + @TableId(value = "dblink_id") + private Long dblinkId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @TableField(value = "app_code") + private String appCode; + + /** + * 链接中文名称。 + */ + @TableField(value = "dblink_name") + private String dblinkName; + + /** + * 链接描述。 + */ + @TableField(value = "dblink_description") + private String dblinkDescription; + + /** + * 配置信息。 + */ + private String configuration; + + /** + * 数据库链接类型。 + */ + @TableField(value = "dblink_type") + private Integer dblinkType; + + /** + * 创建时间。 + */ + @TableField(value = "create_time") + private Date createTime; + + /** + * 创建者。 + */ + @TableField(value = "create_user_id") + private Long createUserId; + + /** + * 修改时间。 + */ + @TableField(value = "update_time") + private Date updateTime; + + /** + * 更新者。 + */ + @TableField(value = "update_user_id") + private Long updateUserId; + + @RelationConstDict( + masterIdField = "dblinkType", + constantDictClass = DblinkType.class) + @TableField(exist = false) + private Map dblinkTypeDictMap; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDict.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDict.java new file mode 100644 index 00000000..533995c5 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineDict.java @@ -0,0 +1,167 @@ +package com.orangeforms.common.online.model; + +import com.baomidou.mybatisplus.annotation.*; +import com.orangeforms.common.core.annotation.RelationConstDict; +import com.orangeforms.common.core.annotation.RelationDict; +import com.orangeforms.common.core.constant.DictType; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单关联的字典实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_online_dict") +public class OnlineDict { + + /** + * 主键Id。 + */ + @TableId(value = "dict_id") + private Long dictId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @TableField(value = "app_code") + private String appCode; + + /** + * 字典名称。 + */ + @TableField(value = "dict_name") + private String dictName; + + /** + * 字典类型。 + */ + @TableField(value = "dict_type") + private Integer dictType; + + /** + * 数据库链接Id。 + */ + @TableField(value = "dblink_id") + private Long dblinkId; + + /** + * 字典表名称。 + */ + @TableField(value = "table_name") + private String tableName; + + /** + * 全局字典编码。 + */ + @TableField(value = "dict_code") + private String dictCode; + + /** + * 字典表键字段名称。 + */ + @TableField(value = "key_column_name") + private String keyColumnName; + + /** + * 字典表父键字段名称。 + */ + @TableField(value = "parent_key_column_name") + private String parentKeyColumnName; + + /** + * 字典值字段名称。 + */ + @TableField(value = "value_column_name") + private String valueColumnName; + + /** + * 逻辑删除字段。 + */ + @TableField(value = "deleted_column_name") + private String deletedColumnName; + + /** + * 用户过滤滤字段名称。 + */ + @TableField(value = "user_filter_column_name") + private String userFilterColumnName; + + /** + * 部门过滤字段名称。 + */ + @TableField(value = "dept_filter_column_name") + private String deptFilterColumnName; + + /** + * 租户过滤字段名称。 + */ + @TableField(value = "tenant_filter_column_name") + private String tenantFilterColumnName; + + /** + * 是否树形标记。 + */ + @TableField(value = "tree_flag") + private Boolean treeFlag; + + /** + * 获取字典数据的url。 + */ + @TableField(value = "dict_list_url") + private String dictListUrl; + + /** + * 根据主键id批量获取字典数据的url。 + */ + @TableField(value = "dict_ids_url") + private String dictIdsUrl; + + /** + * 字典的JSON数据。 + */ + @TableField(value = "dict_data_json") + private String dictDataJson; + + /** + * 创建时间。 + */ + @TableField(value = "create_time") + private Date createTime; + + /** + * 创建者。 + */ + @TableField(value = "create_user_id") + private Long createUserId; + + /** + * 更新时间。 + */ + @TableField(value = "update_time") + private Date updateTime; + + /** + * 更新者。 + */ + @TableField(value = "update_user_id") + private Long updateUserId; + + @RelationConstDict( + masterIdField = "dictType", + constantDictClass = DictType.class) + @TableField(exist = false) + private Map dictTypeDictMap; + + @RelationDict( + masterIdField = "dblinkId", + slaveModelClass = OnlineDblink.class, + slaveIdField = "dblinkId", + slaveNameField = "dblinkName") + @TableField(exist = false) + private Map dblinkIdDictMap; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineForm.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineForm.java new file mode 100644 index 00000000..5a4c9a12 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineForm.java @@ -0,0 +1,132 @@ +package com.orangeforms.common.online.model; + +import com.baomidou.mybatisplus.annotation.*; +import com.orangeforms.common.core.annotation.*; +import com.orangeforms.common.online.model.constant.FormType; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_online_form") +public class OnlineForm { + + /** + * 主键Id。 + */ + @TableId(value = "form_id") + private Long formId; + + /** + * 租户Id。 + */ + @TableField(value = "tenant_id") + private Long tenantId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @TableField(value = "app_code") + private String appCode; + + /** + * 页面id。 + */ + @TableField(value = "page_id") + private Long pageId; + + /** + * 表单编码。 + */ + @TableField(value = "form_code") + private String formCode; + + /** + * 表单名称。 + */ + @TableField(value = "form_name") + private String formName; + + /** + * 表单类别。 + */ + @TableField(value = "form_kind") + private Integer formKind; + + /** + * 表单类型。 + */ + @TableField(value = "form_type") + private Integer formType; + + /** + * 表单主表id。 + */ + @TableField(value = "master_table_id") + private Long masterTableId; + + /** + * 表单组件JSON。 + */ + @TableField(value = "widget_json") + private String widgetJson; + + /** + * 表单参数JSON。 + */ + @TableField(value = "params_json") + private String paramsJson; + + /** + * 创建时间。 + */ + @TableField(value = "create_time") + private Date createTime; + + /** + * 创建者。 + */ + @TableField(value = "create_user_id") + private Long createUserId; + + /** + * 更新时间。 + */ + @TableField(value = "update_time") + private Date updateTime; + + /** + * 更新者。 + */ + @TableField(value = "update_user_id") + private Long updateUserId; + + @RelationOneToOne( + masterIdField = "masterTableId", + slaveModelClass = OnlineTable.class, + slaveIdField = "tableId") + @TableField(exist = false) + private OnlineTable onlineTable; + + @RelationDict( + masterIdField = "masterTableId", + equalOneToOneRelationField = "onlineTable", + slaveModelClass = OnlineTable.class, + slaveIdField = "tableId", + slaveNameField = "modelName") + @TableField(exist = false) + private Map masterTableIdDictMap; + + @RelationConstDict( + masterIdField = "formType", + constantDictClass = FormType.class) + @TableField(exist = false) + private Map formTypeDictMap; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineFormDatasource.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineFormDatasource.java new file mode 100644 index 00000000..d1ddef7f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineFormDatasource.java @@ -0,0 +1,33 @@ +package com.orangeforms.common.online.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +/** + * 在线表单和数据源多对多关联实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_online_form_datasource") +public class OnlineFormDatasource { + + /** + * 主键Id。 + */ + @TableId(value = "id") + private Long id; + + /** + * 表单Id。 + */ + @TableField(value = "form_id") + private Long formId; + + /** + * 数据源Id。 + */ + @TableField(value = "datasource_id") + private Long datasourceId; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlinePage.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlinePage.java new file mode 100644 index 00000000..f39e9448 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlinePage.java @@ -0,0 +1,105 @@ +package com.orangeforms.common.online.model; + +import com.baomidou.mybatisplus.annotation.*; +import com.orangeforms.common.core.annotation.RelationConstDict; +import com.orangeforms.common.online.model.constant.PageStatus; +import com.orangeforms.common.online.model.constant.PageType; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单所在页面实体对象。这里我们可以把页面理解为表单的容器。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_online_page") +public class OnlinePage { + + /** + * 主键Id。 + */ + @TableId(value = "page_id") + private Long pageId; + + /** + * 租户Id。 + */ + @TableField(value = "tenant_id") + private Long tenantId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @TableField(value = "app_code") + private String appCode; + + /** + * 页面编码。 + */ + @TableField(value = "page_code") + private String pageCode; + + /** + * 页面名称。 + */ + @TableField(value = "page_name") + private String pageName; + + /** + * 页面类型。 + */ + @TableField(value = "page_type") + private Integer pageType; + + /** + * 页面编辑状态。 + */ + @TableField(value = "status") + private Integer status; + + /** + * 是否发布。 + */ + @TableField(value = "published") + private Boolean published; + + /** + * 创建时间。 + */ + @TableField(value = "create_time") + private Date createTime; + + /** + * 创建者。 + */ + @TableField(value = "create_user_id") + private Long createUserId; + + /** + * 更新时间。 + */ + @TableField(value = "update_time") + private Date updateTime; + + /** + * 更新者。 + */ + @TableField(value = "update_user_id") + private Long updateUserId; + + @RelationConstDict( + masterIdField = "pageType", + constantDictClass = PageType.class) + @TableField(exist = false) + private Map pageTypeDictMap; + + @RelationConstDict( + masterIdField = "status", + constantDictClass = PageStatus.class) + @TableField(exist = false) + private Map statusDictMap; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlinePageDatasource.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlinePageDatasource.java new file mode 100644 index 00000000..b710cec7 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlinePageDatasource.java @@ -0,0 +1,33 @@ +package com.orangeforms.common.online.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +/** + * 在线表单页面和数据源多对多关联实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_online_page_datasource") +public class OnlinePageDatasource { + + /** + * 主键Id。 + */ + @TableId(value = "id") + private Long id; + + /** + * 页面主键Id。 + */ + @TableField(value = "page_id") + private Long pageId; + + /** + * 数据源主键Id。 + */ + @TableField(value = "datasource_id") + private Long datasourceId; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineRule.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineRule.java new file mode 100644 index 00000000..289adfb3 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineRule.java @@ -0,0 +1,99 @@ +package com.orangeforms.common.online.model; + +import com.baomidou.mybatisplus.annotation.*; +import com.orangeforms.common.core.annotation.RelationConstDict; +import com.orangeforms.common.online.model.constant.RuleType; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单数据表字段验证规则实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_online_rule") +public class OnlineRule { + + /** + * 主键Id。 + */ + @TableId(value = "rule_id") + private Long ruleId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @TableField(value = "app_code") + private String appCode; + + /** + * 规则名称。 + */ + @TableField(value = "rule_name") + private String ruleName; + + /** + * 规则类型。 + */ + @TableField(value = "rule_type") + private Integer ruleType; + + /** + * 内置规则标记。 + */ + @TableField(value = "builtin") + private Boolean builtin; + + /** + * 自定义规则的正则表达式。 + */ + @TableField(value = "pattern") + private String pattern; + + /** + * 创建时间。 + */ + @TableField(value = "create_time") + private Date createTime; + + /** + * 更新时间。 + */ + @TableField(value = "update_time") + private Date updateTime; + + /** + * 创建者。 + */ + @TableField(value = "create_user_id") + private Long createUserId; + + /** + * 更新者。 + */ + @TableField(value = "update_user_id") + private Long updateUserId; + + /** + * 逻辑删除标记字段(1: 正常 -1: 已删除)。 + */ + @TableLogic + @TableField(value = "deleted_flag") + private Integer deletedFlag; + + /** + * ruleId 的多对多关联表数据对象。 + */ + @TableField(exist = false) + private OnlineColumnRule onlineColumnRule; + + @RelationConstDict( + masterIdField = "ruleType", + constantDictClass = RuleType.class) + @TableField(exist = false) + private Map ruleTypeDictMap; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineTable.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineTable.java new file mode 100644 index 00000000..ed5e2297 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineTable.java @@ -0,0 +1,99 @@ +package com.orangeforms.common.online.model; + +import com.baomidou.mybatisplus.annotation.*; +import com.orangeforms.common.core.annotation.RelationOneToMany; +import lombok.Data; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 在线表单的数据表实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_online_table") +public class OnlineTable { + + /** + * 主键Id。 + */ + @TableId(value = "table_id") + private Long tableId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @TableField(value = "app_code") + private String appCode; + + /** + * 表名称。 + */ + @TableField(value = "table_name") + private String tableName; + + /** + * 实体名称。 + */ + @TableField(value = "model_name") + private String modelName; + + /** + * 数据库链接Id。 + */ + @TableField(value = "dblink_id") + private Long dblinkId; + + /** + * 创建时间。 + */ + @TableField(value = "create_time") + private Date createTime; + + /** + * 创建者。 + */ + @TableField(value = "create_user_id") + private Long createUserId; + + /** + * 更新时间。 + */ + @TableField(value = "update_time") + private Date updateTime; + + /** + * 更新者。 + */ + @TableField(value = "update_user_id") + private Long updateUserId; + + @RelationOneToMany( + masterIdField = "tableId", + slaveModelClass = OnlineColumn.class, + slaveIdField = "tableId") + @TableField(exist = false) + private List columnList; + + /** + * 该字段会被缓存,因此在线表单执行操作时可以从缓存中读取该数据,并可基于columnId进行快速检索。 + */ + @TableField(exist = false) + private Map columnMap; + + /** + * 当前表的主键字段,该字段仅仅用于动态表单运行时的SQL拼装。 + */ + @TableField(exist = false) + private OnlineColumn primaryKeyColumn; + + /** + * 当前表的逻辑删除字段,该字段仅仅用于动态表单运行时的SQL拼装。 + */ + @TableField(exist = false) + private OnlineColumn logicDeleteColumn; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineVirtualColumn.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineVirtualColumn.java new file mode 100644 index 00000000..f7e12374 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/OnlineVirtualColumn.java @@ -0,0 +1,87 @@ +package com.orangeforms.common.online.model; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +/** + * 在线数据表虚拟字段实体对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@TableName(value = "zz_online_virtual_column") +public class OnlineVirtualColumn { + + /** + * 主键Id。 + */ + @TableId(value = "virtual_column_id") + private Long virtualColumnId; + + /** + * 所在表Id。 + */ + @TableField(value = "table_id") + private Long tableId; + + /** + * 字段名称。 + */ + @TableField(value = "object_field_name") + private String objectFieldName; + + /** + * 属性类型。 + */ + @TableField(value = "object_field_type") + private String objectFieldType; + + /** + * 字段提示名。 + */ + @TableField(value = "column_prompt") + private String columnPrompt; + + /** + * 虚拟字段类型(0: 聚合)。 + */ + @TableField(value = "virtual_type") + private Integer virtualType; + + /** + * 关联数据源Id。 + */ + @TableField(value = "datasource_id") + private Long datasourceId; + + /** + * 关联Id。 + */ + @TableField(value = "relation_id") + private Long relationId; + + /** + * 聚合字段所在关联表Id。 + */ + @TableField(value = "aggregation_table_id") + private Long aggregationTableId; + + /** + * 关联表聚合字段Id。 + */ + @TableField(value = "aggregation_column_id") + private Long aggregationColumnId; + + /** + * 聚合类型(0: count 1: sum 2: avg 3: max 4:min)。 + */ + @TableField(value = "aggregation_type") + private Integer aggregationType; + + /** + * 存储过滤条件的json。 + */ + @TableField(value = "where_clause_json") + private String whereClauseJson; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FieldFilterType.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FieldFilterType.java new file mode 100644 index 00000000..6287a355 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FieldFilterType.java @@ -0,0 +1,79 @@ +package com.orangeforms.common.online.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 字段过滤类型常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FieldFilterType { + + /** + * 无过滤。 + */ + public static final int NO_FILTER = 0; + /** + * 等于过滤。 + */ + public static final int EQUAL_FILTER = 1; + /** + * 范围过滤。 + */ + public static final int RANGE_FILTER = 2; + /** + * 模糊过滤。 + */ + public static final int LIKE_FILTER = 3; + /** + * IN LIST列表过滤。 + */ + public static final int IN_LIST_FILTER = 4; + /** + * 用OR连接的多个模糊查询。 + */ + public static final int MULTI_LIKE = 5; + /** + * NOT IN LIST列表过滤。 + */ + public static final int NOT_IN_LIST_FILTER = 6; + /** + * NOT IN LIST列表过滤。 + */ + public static final int IS_NULL = 7; + /** + * NOT IN LIST列表过滤。 + */ + public static final int IS_NOT_NULL = 8; + + private static final Map DICT_MAP = new HashMap<>(9); + static { + DICT_MAP.put(NO_FILTER, "无过滤"); + DICT_MAP.put(EQUAL_FILTER, "等于过滤"); + DICT_MAP.put(RANGE_FILTER, "范围过滤"); + DICT_MAP.put(LIKE_FILTER, "模糊过滤"); + DICT_MAP.put(IN_LIST_FILTER, "IN LIST列表过滤"); + DICT_MAP.put(MULTI_LIKE, "用OR连接的多个模糊查询"); + DICT_MAP.put(NOT_IN_LIST_FILTER, "NOT IN LIST列表过滤"); + DICT_MAP.put(IS_NULL, "IS NULL"); + DICT_MAP.put(IS_NOT_NULL, "IS NOT NULL"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FieldFilterType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FieldKind.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FieldKind.java new file mode 100644 index 00000000..d8afef0b --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FieldKind.java @@ -0,0 +1,109 @@ +package com.orangeforms.common.online.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 字段类别常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FieldKind { + + /** + * 文件上传字段。 + */ + public static final int UPLOAD = 1; + /** + * 图片上传字段。 + */ + public static final int UPLOAD_IMAGE = 2; + /** + * 富文本字段。 + */ + public static final int RICH_TEXT = 3; + /** + * 字典多选字段。 + */ + public static final int DICT_MULTI_SELECT = 4; + /** + * 创建人部门Id。 + */ + public static final int CREATE_DEPT_ID = 19; + /** + * 创建时间字段。 + */ + public static final int CREATE_TIME = 20; + /** + * 创建人字段。 + */ + public static final int CREATE_USER_ID = 21; + /** + * 更新时间字段。 + */ + public static final int UPDATE_TIME = 22; + /** + * 更新人字段。 + */ + public static final int UPDATE_USER_ID = 23; + /** + * 包含自动编码。 + */ + public static final int AUTO_CODE = 24; + /** + * 流程最后审批状态。 + */ + public static final int FLOW_APPROVAL_STATUS = 25; + /** + * 流程结束状态。 + */ + public static final int FLOW_FINISHED_STATUS = 26; + /** + * 脱敏字段。 + */ + public static final int MASK_FIELD = 27; + /** + * 租户过滤字段。 + */ + public static final int TENANT_FILTER = 28; + /** + * 逻辑删除字段。 + */ + public static final int LOGIC_DELETE = 31; + + private static final Map DICT_MAP = new HashMap<>(9); + static { + DICT_MAP.put(UPLOAD, "文件上传字段"); + DICT_MAP.put(UPLOAD_IMAGE, "图片上传字段"); + DICT_MAP.put(RICH_TEXT, "富文本字段"); + DICT_MAP.put(DICT_MULTI_SELECT, "字典多选字段"); + DICT_MAP.put(CREATE_DEPT_ID, "创建人部门字段"); + DICT_MAP.put(CREATE_TIME, "创建时间字段"); + DICT_MAP.put(CREATE_USER_ID, "创建人字段"); + DICT_MAP.put(UPDATE_TIME, "更新时间字段"); + DICT_MAP.put(UPDATE_USER_ID, "更新人字段"); + DICT_MAP.put(AUTO_CODE, "自动编码字段"); + DICT_MAP.put(FLOW_APPROVAL_STATUS, "流程最后审批状态"); + DICT_MAP.put(FLOW_FINISHED_STATUS, "流程结束状态"); + DICT_MAP.put(MASK_FIELD, "脱敏字段"); + DICT_MAP.put(TENANT_FILTER, "租户过滤字段"); + DICT_MAP.put(LOGIC_DELETE, "逻辑删除字段"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FieldKind() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FormKind.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FormKind.java new file mode 100644 index 00000000..71b22651 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FormKind.java @@ -0,0 +1,44 @@ +package com.orangeforms.common.online.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 表单类别常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FormKind { + + /** + * 弹框。 + */ + public static final int DIALOG = 1; + /** + * 跳页。 + */ + public static final int NEW_PAGE = 5; + + private static final Map DICT_MAP = new HashMap<>(2); + static { + DICT_MAP.put(DIALOG, "弹框列表"); + DICT_MAP.put(NEW_PAGE, "跳页类别"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FormKind() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FormType.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FormType.java new file mode 100644 index 00000000..6b969c20 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/FormType.java @@ -0,0 +1,64 @@ +package com.orangeforms.common.online.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 表单类型常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class FormType { + + /** + * 查询表单。 + */ + public static final int QUERY = 1; + /** + * 左树右表表单。 + */ + public static final int ADVANCED_QUERY = 2; + /** + * 一对一关联数据查询。 + */ + public static final int ONE_TO_ONE_QUERY = 3; + /** + * 编辑表单。 + */ + public static final int EDIT_FORM = 5; + /** + * 流程表单。 + */ + public static final int FLOW = 10; + /** + * 流程工单表单。 + */ + public static final int FLOW_WORK_ORDER = 11; + + private static final Map DICT_MAP = new HashMap<>(2); + static { + DICT_MAP.put(QUERY, "查询表单"); + DICT_MAP.put(ADVANCED_QUERY, "左树右表表单"); + DICT_MAP.put(ONE_TO_ONE_QUERY, "一对一关联数据查询"); + DICT_MAP.put(EDIT_FORM, "编辑表单"); + DICT_MAP.put(FLOW, "流程表单"); + DICT_MAP.put(FLOW_WORK_ORDER, "流程工单表单"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private FormType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/PageStatus.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/PageStatus.java new file mode 100644 index 00000000..6eed451d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/PageStatus.java @@ -0,0 +1,49 @@ +package com.orangeforms.common.online.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 页面状态常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class PageStatus { + + /** + * 编辑基础信息。 + */ + public static final int BASIC = 0; + /** + * 编辑数据模型。 + */ + public static final int DATASOURCE = 1; + /** + * 设计表单。 + */ + public static final int FORM_DESIGN = 2; + + private static final Map DICT_MAP = new HashMap<>(4); + static { + DICT_MAP.put(BASIC, "编辑基础信息"); + DICT_MAP.put(DATASOURCE, "编辑数据模型"); + DICT_MAP.put(FORM_DESIGN, "设计表单"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private PageStatus() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/PageType.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/PageType.java new file mode 100644 index 00000000..45e614a5 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/PageType.java @@ -0,0 +1,49 @@ +package com.orangeforms.common.online.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 页面类型常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class PageType { + + /** + * 业务页面。 + */ + public static final int BIZ = 1; + /** + * 统计页面。 + */ + public static final int STATS = 5; + /** + * 流程页面。 + */ + public static final int FLOW = 10; + + private static final Map DICT_MAP = new HashMap<>(2); + static { + DICT_MAP.put(BIZ, "业务页面"); + DICT_MAP.put(STATS, "统计页面"); + DICT_MAP.put(FLOW, "流程页面"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private PageType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/RelationType.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/RelationType.java new file mode 100644 index 00000000..f14289da --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/RelationType.java @@ -0,0 +1,44 @@ +package com.orangeforms.common.online.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 关联类型常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class RelationType { + + /** + * 一对一关联。 + */ + public static final int ONE_TO_ONE = 0; + /** + * 一对多关联。 + */ + public static final int ONE_TO_MANY = 1; + + private static final Map DICT_MAP = new HashMap<>(2); + static { + DICT_MAP.put(ONE_TO_ONE, "一对一关联"); + DICT_MAP.put(ONE_TO_MANY, "一对多关联"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private RelationType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/RuleType.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/RuleType.java new file mode 100644 index 00000000..f2b5ee76 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/RuleType.java @@ -0,0 +1,69 @@ +package com.orangeforms.common.online.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 验证规则类型常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class RuleType { + + /** + * 只允许整数。 + */ + public static final int INTEGER_ONLY = 1; + /** + * 只允许数字。 + */ + public static final int DIGITAL_ONLY = 2; + /** + * 只允许英文字符。 + */ + public static final int LETTER_ONLY = 3; + /** + * 范围验证。 + */ + public static final int RANGE = 4; + /** + * 邮箱格式验证。 + */ + public static final int EMAIL = 5; + /** + * 手机格式验证。 + */ + public static final int MOBILE = 6; + /** + * 自定义验证。 + */ + public static final int CUSTOM = 100; + + private static final Map DICT_MAP = new HashMap<>(7); + static { + DICT_MAP.put(INTEGER_ONLY, "只允许整数"); + DICT_MAP.put(DIGITAL_ONLY, "只允许数字"); + DICT_MAP.put(LETTER_ONLY, "只允许英文字符"); + DICT_MAP.put(RANGE, "范围验证"); + DICT_MAP.put(EMAIL, "邮箱格式验证"); + DICT_MAP.put(MOBILE, "手机格式验证"); + DICT_MAP.put(CUSTOM, "自定义验证"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private RuleType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/VirtualType.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/VirtualType.java new file mode 100644 index 00000000..3d5b9c42 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/model/constant/VirtualType.java @@ -0,0 +1,39 @@ +package com.orangeforms.common.online.model.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * 在线表单虚拟字段类型常量字典对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +public final class VirtualType { + + /** + * 聚合。 + */ + public static final int AGGREGATION = 0; + + private static final Map DICT_MAP = new HashMap<>(2); + static { + DICT_MAP.put(AGGREGATION, "聚合"); + } + + /** + * 判断参数是否为当前常量字典的合法值。 + * + * @param value 待验证的参数值。 + * @return 合法返回true,否则false。 + */ + public static boolean isValid(Integer value) { + return value != null && DICT_MAP.containsKey(value); + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private VirtualType() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/object/ColumnData.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/object/ColumnData.java new file mode 100644 index 00000000..8b6291f6 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/object/ColumnData.java @@ -0,0 +1,28 @@ +package com.orangeforms.common.online.object; + +import com.orangeforms.common.online.model.OnlineColumn; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 表字段数据对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ColumnData { + + /** + * 在线表字段对象。 + */ + private OnlineColumn column; + + /** + * 字段值。 + */ + private Object columnValue; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/object/ConstDictInfo.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/object/ConstDictInfo.java new file mode 100644 index 00000000..f99e18d3 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/object/ConstDictInfo.java @@ -0,0 +1,24 @@ +package com.orangeforms.common.online.object; + +import lombok.Data; + +import java.util.List; + +/** + * 在线表单常量字典的数据结构。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class ConstDictInfo { + + private List dictData; + + @Data + public static class ConstDictData { + private String type; + private Object id; + private String name; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/object/JoinTableInfo.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/object/JoinTableInfo.java new file mode 100644 index 00000000..4798b332 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/object/JoinTableInfo.java @@ -0,0 +1,28 @@ +package com.orangeforms.common.online.object; + +import lombok.Data; + +/** + * 连接表信息对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +public class JoinTableInfo { + + /** + * 是否左连接。 + */ + private Boolean leftJoin; + + /** + * 连接表表名。 + */ + private String joinTableName; + + /** + * 连接条件。 + */ + private String joinCondition; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineColumnService.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineColumnService.java new file mode 100644 index 00000000..a48a487e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineColumnService.java @@ -0,0 +1,147 @@ +package com.orangeforms.common.online.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.dbutil.object.SqlTableColumn; +import com.orangeforms.common.online.model.OnlineColumn; +import com.orangeforms.common.online.model.OnlineColumnRule; + +import java.util.List; +import java.util.Set; + +/** + * 字段数据数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineColumnService extends IBaseService { + + /** + * 保存新增数据表字段列表。 + * + * @param columnList 新增数据表字段对象列表。 + * @param onlineTableId 在线表对象的主键Id。 + * @return 插入的在线表字段数据。 + */ + List saveNewList(List columnList, Long onlineTableId); + + /** + * 更新数据对象。 + * + * @param onlineColumn 更新的对象。 + * @param originalOnlineColumn 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(OnlineColumn onlineColumn, OnlineColumn originalOnlineColumn); + + /** + * 刷新数据库表字段的数据到在线表字段。 + * + * @param sqlTableColumn 源数据库表字段对象。 + * @param onlineColumn 被刷新的在线表字段对象。 + */ + void refresh(SqlTableColumn sqlTableColumn, OnlineColumn onlineColumn); + + /** + * 删除指定数据。 + * + * @param tableId 表Id。 + * @param columnId 字段Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long tableId, Long columnId); + + /** + * 批量添加多对多关联关系。 + * + * @param onlineColumnRuleList 多对多关联表对象集合。 + * @param columnId 主表Id。 + */ + void addOnlineColumnRuleList(List onlineColumnRuleList, Long columnId); + + /** + * 更新中间表数据。 + * + * @param onlineColumnRule 中间表对象。 + * @return 更新成功与否。 + */ + boolean updateOnlineColumnRule(OnlineColumnRule onlineColumnRule); + + /** + * 获取中间表数据。 + * + * @param columnId 主表Id。 + * @param ruleId 从表Id。 + * @return 中间表对象。 + */ + OnlineColumnRule getOnlineColumnRule(Long columnId, Long ruleId); + + /** + * 移除单条多对多关系。 + * + * @param columnId 主表Id。 + * @param ruleId 从表Id。 + * @return 成功返回true,否则false。 + */ + boolean removeOnlineColumnRule(Long columnId, Long ruleId); + + /** + * 当前服务的支持表为从表,根据主表的主键Id,删除一对多的从表数据。 + * + * @param tableId 主表主键Id。 + * @return 删除数量。 + */ + int removeByTableId(Long tableId); + + /** + * 删除指定数据表Id集合中的表字段。 + * + * @param tableIdSet 待删除的数据表Id集合。 + */ + void removeByTableIdSet(Set tableIdSet); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineColumnListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @return 查询结果集。 + */ + List getOnlineColumnList(OnlineColumn filter); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineColumnList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @return 查询结果集。 + */ + List getOnlineColumnListWithRelation(OnlineColumn filter); + + /** + * 获取指定数据表Id集合的字段对象列表。 + * + * @param tableIdSet 指定的数据表Id集合。 + * @return 数据表Id集合所包含的字段对象列表。 + */ + List getOnlineColumnListByTableIds(Set tableIdSet); + + /** + * 根据表Id和字段列名获取指定字段。 + * + * @param tableId 字段所在表Id。 + * @param columnName 字段名。 + * @return 查询出的字段对象。 + */ + OnlineColumn getOnlineColumnByTableIdAndColumnName(Long tableId, String columnName); + + /** + * 验证主键是否正确。 + * + * @param tableColumn 数据库导入的表字段对象。 + * @return 验证结果。 + */ + CallResult verifyPrimaryKey(SqlTableColumn tableColumn); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDatasourceRelationService.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDatasourceRelationService.java new file mode 100644 index 00000000..a96d86b9 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDatasourceRelationService.java @@ -0,0 +1,85 @@ +package com.orangeforms.common.online.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.dbutil.object.SqlTable; +import com.orangeforms.common.dbutil.object.SqlTableColumn; +import com.orangeforms.common.online.model.OnlineDatasourceRelation; + +import java.util.List; +import java.util.Set; + +/** + * 数据关联数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineDatasourceRelationService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param relation 新增对象。 + * @param slaveSqlTable 新增的关联从数据表对象。 + * @param slaveSqlColumn 新增的关联从数据表对象。 + * @return 返回新增对象。 + */ + OnlineDatasourceRelation saveNew( + OnlineDatasourceRelation relation, SqlTable slaveSqlTable, SqlTableColumn slaveSqlColumn); + + /** + * 更新数据对象。 + * + * @param relation 更新的对象。 + * @param originalRelation 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(OnlineDatasourceRelation relation, OnlineDatasourceRelation originalRelation); + + /** + * 删除指定数据。 + * + * @param relationId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long relationId); + + /** + * 当前服务的支持表为从表,根据主表的主键Id,删除一对多的从表数据。 + * + * @param datasourceId 主表主键Id。 + * @return 删除数量。 + */ + int removeByDatasourceId(Long datasourceId); + + /** + * 查询指定数据源Id的数据源关联对象列表。 + * 从缓存中读取,如果不存在会从数据库中读取并同步到Redis中。 + * + * @param datasourceIdSet 数据源Id集合。 + * @return 在线数据源关联对象列表。 + */ + List getOnlineDatasourceRelationListFromCache(Set datasourceIdSet); + + /** + * 查询指定数据源关联对象。 + * 从缓存中读取,如果不存在会从数据库中读取并同步到Redis中。 + * + * @param datasourceId 数据源Id。 + * @param relationId 数据源关联Id。 + * @return 在线数据源关联对象。 + */ + OnlineDatasourceRelation getOnlineDatasourceRelationFromCache(Long datasourceId, Long relationId); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineDatasourceRelationList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineDatasourceRelationListWithRelation( + OnlineDatasourceRelation filter, String orderBy); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDatasourceService.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDatasourceService.java new file mode 100644 index 00000000..f51dddb5 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDatasourceService.java @@ -0,0 +1,134 @@ +package com.orangeforms.common.online.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.dbutil.object.SqlTable; +import com.orangeforms.common.online.model.OnlineDatasource; +import com.orangeforms.common.online.model.OnlineDatasourceTable; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 数据模型数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineDatasourceService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param onlineDatasource 新增对象。 + * @param sqlTable 新增的数据表对象。 + * @param pageId 关联的页面Id。 + * @return 返回新增对象。 + */ + OnlineDatasource saveNew(OnlineDatasource onlineDatasource, SqlTable sqlTable, Long pageId); + + /** + * 更新数据对象。 + * + * @param onlineDatasource 更新的对象。 + * @param originalOnlineDatasource 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(OnlineDatasource onlineDatasource, OnlineDatasource originalOnlineDatasource); + + /** + * 删除指定数据。 + * + * @param datasourceId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long datasourceId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineDatasourceListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineDatasourceList(OnlineDatasource filter, String orderBy); + + /** + * 查询指定数据源Id的数据源对象。 + * 从缓存中读取,如果不存在会从数据库中读取并同步到Redis中。 + * + * @param datasourceId 数据源Id。 + * @return 在线数据源对象。 + */ + OnlineDatasource getOnlineDatasourceFromCache(Long datasourceId); + + /** + * 查询指定数据源Id集合的数据源列表。 + * 从缓存中读取,如果不存在会从数据库中读取并同步到Redis中。 + * + * @param datasourceIdSet 数据源Id集合。 + * @return 在线数据源对象集合。 + */ + List getOnlineDatasourceListFromCache(Set datasourceIdSet); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineDatasourceList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineDatasourceListWithRelation(OnlineDatasource filter, String orderBy); + + /** + * 在多对多关系中,当前Service的数据表为从表,返回与指定主表主键Id存在对多对关系的列表。 + * + * @param pageId 主表主键Id。 + * @param filter 从表的过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineDatasourceListByPageId(Long pageId, OnlineDatasource filter, String orderBy); + + /** + * 获取指定数据源Id集合所关联的在线表关联数据。 + * + * @param datasourceIdSet 数据源Id集合。 + * @return 数据源和数据表的多对多关联列表。 + */ + List getOnlineDatasourceTableList(Set datasourceIdSet); + + /** + * 根据在线表单Id集合,获取关联的在线数据源对象列表。 + * + * @param readFormIdSet 在线表单Id集合。 + * @return 与参数表单Id关联的数据源列表。 + */ + List getOnlineDatasourceListByFormIds(Set readFormIdSet); + + /** + * 根据主表Id获取在线表单数据源对象。 + * + * @param masterTableId 主表Id。 + * @return 在线表单数据源对象。 + */ + OnlineDatasource getOnlineDatasourceByMasterTableId(Long masterTableId); + + /** + * 判断指定数据源变量是否存在。 + * @param variableName 变量名。 + * @return true存在,否则false。 + */ + boolean existByVariableName(String variableName); + + /** + * 获取在线表单页面和在线表单数据源变量名的映射关系。 + * + * @param pageIds 页面Id集合。 + * @return 在线表单页面和在线表单数据源变量名的映射关系。 + */ + Map getPageIdAndVariableNameMapByPageIds(Set pageIds); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDblinkService.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDblinkService.java new file mode 100644 index 00000000..d04ace46 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDblinkService.java @@ -0,0 +1,99 @@ +package com.orangeforms.common.online.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.dbutil.object.SqlTable; +import com.orangeforms.common.dbutil.object.SqlTableColumn; +import com.orangeforms.common.online.model.OnlineDblink; + +import java.util.List; + +/** + * 数据库链接数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineDblinkService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param onlineDblink 新增对象。 + * @return 返回新增对象。 + */ + OnlineDblink saveNew(OnlineDblink onlineDblink); + + /** + * 更新数据对象。 + * + * @param onlineDblink 更新的对象。 + * @param originalOnlineDblink 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(OnlineDblink onlineDblink, OnlineDblink originalOnlineDblink); + + /** + * 删除指定数据。 + * + * @param dblinkId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long dblinkId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineDblinkListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineDblinkList(OnlineDblink filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineDblinkList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineDblinkListWithRelation(OnlineDblink filter, String orderBy); + + /** + * 获取指定DBLink下面的全部数据表。 + * + * @param dblink 数据库链接对象。 + * @return 全部数据表列表。 + */ + List getDblinkTableList(OnlineDblink dblink); + + /** + * 获取指定DBLink下,指定表名的数据表对象,及其关联字段列表。 + * + * @param dblink 数据库链接对象。 + * @param tableName 数据库中的数据表名。 + * @return 数据表对象。 + */ + SqlTable getDblinkTable(OnlineDblink dblink, String tableName); + + /** + * 获取指定DBLink下,指定表名的字段列表。 + * + * @param dblink 数据库链接对象。 + * @param tableName 数据库中的数据表名。 + * @return 表的字段列表。 + */ + List getDblinkTableColumnList(OnlineDblink dblink, String tableName); + + /** + * 获取指定DBLink下,指定表的字段对象。 + * + * @param dblink 数据库链接对象。 + * @param tableName 数据库中的数据表名。 + * @param columnName 数据库中的数据表的字段名。 + * @return 表的字段对象。 + */ + SqlTableColumn getDblinkTableColumn(OnlineDblink dblink, String tableName, String columnName); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDictService.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDictService.java new file mode 100644 index 00000000..4f2c56bd --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineDictService.java @@ -0,0 +1,78 @@ +package com.orangeforms.common.online.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.online.model.OnlineDict; + +import java.util.List; +import java.util.Set; + +/** + * 在线表单字典数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineDictService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param onlineDict 新增对象。 + * @return 返回新增对象。 + */ + OnlineDict saveNew(OnlineDict onlineDict); + + /** + * 更新数据对象。 + * + * @param onlineDict 更新的对象。 + * @param originalOnlineDict 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(OnlineDict onlineDict, OnlineDict originalOnlineDict); + + /** + * 删除指定数据。 + * + * @param dictId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long dictId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineDictListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineDictList(OnlineDict filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineDictList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineDictListWithRelation(OnlineDict filter, String orderBy); + + /** + * 从缓存中获取字典数据。 + * + * @param dictId 字典Id。 + * @return 在线字典对象。 + */ + OnlineDict getOnlineDictFromCache(Long dictId); + + /** + * 从缓存中获取字典数据集合。 + * + * @param dictIdSet 字典Id集合。 + * @return 在线字典对象集合。 + */ + List getOnlineDictListFromCache(Set dictIdSet); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineFormService.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineFormService.java new file mode 100644 index 00000000..b6334b8d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineFormService.java @@ -0,0 +1,122 @@ +package com.orangeforms.common.online.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.online.model.OnlineForm; +import com.orangeforms.common.online.model.OnlineFormDatasource; + +import java.util.List; +import java.util.Set; + +/** + * 在线表单数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineFormService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param onlineForm 新增对象。 + * @param datasourceIdSet 在线表单关联的数据源Id集合。 + * @return 返回新增对象。 + */ + OnlineForm saveNew(OnlineForm onlineForm, Set datasourceIdSet); + + /** + * 更新数据对象。 + * + * @param onlineForm 更新的对象。 + * @param originalOnlineForm 原有数据对象。 + * @param datasourceIdSet 在线表单关联的数据源Id集合。 + * @return 成功返回true,否则false。 + */ + boolean update(OnlineForm onlineForm, OnlineForm originalOnlineForm, Set datasourceIdSet); + + /** + * 删除指定数据。 + * + * @param formId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long formId); + + /** + * 根据PageId,删除其所属的所有表单,以及表单关联的数据源数据。 + * + * @param pageId 指定的pageId。 + * @return 删除数量。 + */ + int removeByPageId(Long pageId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineFormListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineFormList(OnlineForm filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineFormList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineFormListWithRelation(OnlineForm filter, String orderBy); + + /** + * 获取使用指定数据表的表单列表。 + * + * @param tableId 数据表Id。 + * @return 使用该数据表的表单列表。 + */ + List getOnlineFormListByTableId(Long tableId); + + /** + * 获取指定表单的数据源列表。 + * 从缓存中读取,如果缓存中不存在,从数据库读取后同步更新到缓存。 + * + * @param formId 指定的表单。 + * @return 表单和数据源的多对多关联对象列表。 + */ + List getFormDatasourceListFromCache(Long formId); + + /** + * 查询正在使用当前数据源的表单。 + * + * @param datasourceId 数据源Id。 + * @return 正在使用当前数据源的表单列表。 + */ + List getOnlineFormListByDatasourceId(Long datasourceId); + + /** + * 查询指定PageId集合的在线表单列表。 + * + * @param pageIdSet 页面Id集合。 + * @return 在线表单集合。 + */ + List getOnlineFormListByPageIds(Set pageIdSet); + + /** + * 从缓存中获取表单数据。 + * + * @param formId 表单Id。 + * @return 在线表单对象。 + */ + OnlineForm getOnlineFormFromCache(Long formId); + + /** + * 判断指定编码的表单是否存在。 + * + * @param formCode 表单编码。 + * @return true存在,否则false。 + */ + boolean existByFormCode(String formCode); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineOperationService.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineOperationService.java new file mode 100644 index 00000000..9cde49b9 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineOperationService.java @@ -0,0 +1,220 @@ +package com.orangeforms.common.online.service; + +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.object.MyPageData; +import com.orangeforms.common.core.object.MyPageParam; +import com.orangeforms.common.online.dto.OnlineFilterDto; +import com.orangeforms.common.online.model.OnlineColumn; +import com.orangeforms.common.online.model.OnlineDatasourceRelation; +import com.orangeforms.common.online.model.OnlineDict; +import com.orangeforms.common.online.model.OnlineTable; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 在线表单运行时操作的数据服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineOperationService { + + /** + * 待批量插入的所有表数据。 + * + * @param table 在线表对象。 + * @param dataList 数据对象列表。 + */ + void saveNewBatch(OnlineTable table, List dataList); + + /** + * 待插入的所有表数据。 + * + * @param table 在线表对象。 + * @param data 数据对象。 + * @return 主键值。由于自增主键不能获取插入后的主键值,因此返回NULL。 + */ + Object saveNew(OnlineTable table, JSONObject data); + + /** + * 待插入的主表数据和多个从表数据。 + * + * @param masterTable 主表在线表对象。 + * @param masterData 主表数据对象。 + * @param slaveDataListMap 多个从表的数据字段数据。 + * @return 主表的主键值。由于自增主键不能获取插入后的主键值,因此返回NULL。 + */ + Object saveNewWithRelation( + OnlineTable masterTable, + JSONObject masterData, + Map> slaveDataListMap); + + /** + * 更新表数据。 + * + * @param table 在线表对象。 + * @param data 单条表数据。 + * @return true 更新成功,否则false。 + */ + boolean update(OnlineTable table, JSONObject data); + + /** + * 更新流程字段的状态。 + * + * @param table 数据表。 + * @param dataId 主键Id。 + * @param column 更新字段。 + * @param dataValue 新的数据值。 + * @return true 更新成功,否则false。 + */ + boolean updateColumn(OnlineTable table, String dataId, OnlineColumn column, T dataValue); + + /** + * 级联更新主表和从表数据。 + * + * @param masterTable 主表对象。 + * @param masterData 主表数据。 + * @param datasourceId 主表数据源Id。 + * @param slaveDataListMap 关联从表数据。 + */ + void updateWithRelation( + OnlineTable masterTable, + JSONObject masterData, + Long datasourceId, + Map> slaveDataListMap); + + /** + * 更新关联从表的数据。 + * + * @param masterTable 主表对象。 + * @param masterData 主表数据。 + * @param masterDataId 主表主键Id。 + * @param datasourceId 主表数据源Id。 + * @param relationId 关联Id。 + * @param slaveDataList 从表数据。 + */ + void updateRelationData( + OnlineTable masterTable, + Map masterData, + String masterDataId, + Long datasourceId, + Long relationId, + List slaveDataList); + + /** + * 删除主表数据,及其需要级联删除的一对多关联从表数据。 + * + * @param table 表对象。 + * @param relationList 一对多关联对象列表。 + * @param dataId 主表主键Id值。 + * @return true 删除成功,否则false。 + */ + boolean delete(OnlineTable table, List relationList, String dataId); + + /** + * 删除一对多从表数据中的关联数据。 + * 删除所有字段为slaveColumn,数据值为columnValue,但是主键值不在keptIdSet中的从表关联数据。 + * + * @param slaveTable 一对多从表。 + * @param slaveColumn 从表关联字段。 + * @param columnValue 关联字段的值。 + * @param keptIdSet 被保留从表数据的主键Id值。 + */ + void deleteOneToManySlaveData( + OnlineTable slaveTable, OnlineColumn slaveColumn, String columnValue, Set keptIdSet); + + /** + * 根据主键判断当前数据是否存在。 + * + * @param table 主表对象。 + * @param dataId 主表主键Id值。 + * @return 存在返回true,否则false。 + */ + boolean existId(OnlineTable table, String dataId); + + /** + * 从数据源和一对一数据源关联中,动态获取数据。 + * + * @param table 主表对象。 + * @param oneToOneRelationList 数据源一对一关联列表。 + * @param allRelationList 数据源全部关联列表。 + * @param dataId 主表主键Id值。 + * @return 查询结果。 + */ + Map getMasterData( + OnlineTable table, + List oneToOneRelationList, + List allRelationList, + String dataId); + + /** + * 从一对多数据源关联中,动态获取数据。 + * + * @param relation 一对多数据源关联对象。 + * @param dataId 一对多关联数据主键Id值。 + * @return 查询结果。 + */ + Map getSlaveData(OnlineDatasourceRelation relation, String dataId); + + /** + * 从数据源和一对一数据源关联中,动态获取数据列表。 + * + * @param table 主表对象。 + * @param oneToOneRelationList 数据源一对一关联列表。 + * @param allRelationList 数据源全部关联列表。 + * @param filterList 过滤参数列表。 + * @param orderBy 排序字符串。 + * @param pageParam 分页对象。 + * @return 查询结果集。 + */ + MyPageData> getMasterDataList( + OnlineTable table, + List oneToOneRelationList, + List allRelationList, + List filterList, + String orderBy, + MyPageParam pageParam); + + /** + * 从一对多数据源关联中,动态获取数据列表。 + * + * @param relation 一对多数据源关联对象。 + * @param filterList 过滤参数列表。 + * @param orderBy 排序字符串。 + * @param pageParam 分页对象。 + * @return 查询结果集。 + */ + MyPageData> getSlaveDataList( + OnlineDatasourceRelation relation, List filterList, String orderBy, MyPageParam pageParam); + + /** + * 从字典对象指向的数据表中查询数据,并根据参数进行数据过滤。 + * + * @param dict 字典对象。 + * @param filterList 过滤参数列表。 + * @return 查询结果集。 + */ + List> getDictDataList(OnlineDict dict, List filterList); + + /** + * 为主表及其关联表数据绑定字典数据。 + * + * @param masterTable 主表对象。 + * @param relationList 主表依赖的关联列表。 + * @param dataList 数据列表。 + */ + void buildDataListWithDict( + OnlineTable masterTable, List relationList, List> dataList); + + /** + * 获取在线表单所关联的权限数据,包括权限字列表和权限资源列表。 + * + * @param menuFormIds 菜单关联的表单Id集合。 + * @param viewFormIds 查询权限的表单Id集合。 + * @param editFormIds 编辑权限的表单Id集合。 + * @return 在线表单权限数据。 + */ + Map calculatePermData(Set menuFormIds, Set viewFormIds, Set editFormIds); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlinePageService.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlinePageService.java new file mode 100644 index 00000000..2ba8458b --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlinePageService.java @@ -0,0 +1,138 @@ +package com.orangeforms.common.online.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.online.model.OnlinePage; +import com.orangeforms.common.online.model.OnlinePageDatasource; + +import java.util.List; + +/** + * 在线表单页面数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlinePageService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param onlinePage 新增对象。 + * @return 返回新增对象。 + */ + OnlinePage saveNew(OnlinePage onlinePage); + + /** + * 更新数据对象。 + * + * @param onlinePage 更新的对象。 + * @param originalOnlinePage 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(OnlinePage onlinePage, OnlinePage originalOnlinePage); + + /** + * 更新页面对象的发布状态。 + * + * @param pageId 页面对象Id。 + * @param published 新的状态。 + */ + void updatePublished(Long pageId, Boolean published); + + /** + * 删除指定数据,及其包含的表单和数据源等。 + * + * @param pageId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long pageId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlinePageListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlinePageList(OnlinePage filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlinePageList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlinePageListWithRelation(OnlinePage filter, String orderBy); + + /** + * 批量添加多对多关联关系。 + * + * @param onlinePageDatasourceList 多对多关联表对象集合。 + * @param pageId 主表Id。 + */ + void addOnlinePageDatasourceList(List onlinePageDatasourceList, Long pageId); + + /** + * 获取中间表数据。 + * + * @param pageId 主表Id。 + * @param datasourceId 从表Id。 + * @return 中间表对象。 + */ + OnlinePageDatasource getOnlinePageDatasource(Long pageId, Long datasourceId); + + /** + * 获取在线页面和数据源中间表数据列表。 + * + * @param pageId 主表Id。 + * @return 在线页面和数据源中间表对象列表。 + */ + List getOnlinePageDatasourceListByPageId(Long pageId); + + /** + * 根据数据源Id,返回使用该数据源的OnlinePage对象。 + * + * @param datasourceId 数据源Id。 + * @return 使用该数据源的页面列表。 + */ + List getOnlinePageListByDatasourceId(Long datasourceId); + + /** + * 移除单条多对多关系。 + * + * @param pageId 主表Id。 + * @param datasourceId 从表Id。 + * @return 成功返回true,否则false。 + */ + boolean removeOnlinePageDatasource(Long pageId, Long datasourceId); + + /** + * 判断指定编码的页面是否存在。 + * + * @param pageCode 页面编码。 + * @return true存在,否则false。 + */ + boolean existByPageCode(String pageCode); + + /** + * 查询主键Id集合中不存在的,且租户Id为NULL的在线表单页面列表。 + * + * @param pageIds 主键Id集合。 + * @param orderBy 排序字符串。 + * @return 在线表单页面列表。 + */ + List getNotInListWithNonTenant(List pageIds, String orderBy); + + /** + * 查询主键Id集合中存在的,且租户Id为NULL的在线表单页面列表。 + * + * @param pageIds 主键Id集合。 + * @param orderBy 排序字符串。 + * @return 在线表单页面列表。 + */ + List getInListWithNonTenant(List pageIds, String orderBy); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineRuleService.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineRuleService.java new file mode 100644 index 00000000..f381a43d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineRuleService.java @@ -0,0 +1,91 @@ +package com.orangeforms.common.online.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.online.model.OnlineColumnRule; +import com.orangeforms.common.online.model.OnlineRule; + +import java.util.List; +import java.util.Set; + +/** + * 验证规则数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineRuleService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param onlineRule 新增对象。 + * @return 返回新增对象。 + */ + OnlineRule saveNew(OnlineRule onlineRule); + + /** + * 更新数据对象。 + * + * @param onlineRule 更新的对象。 + * @param originalOnlineRule 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(OnlineRule onlineRule, OnlineRule originalOnlineRule); + + /** + * 删除指定数据。 + * + * @param ruleId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long ruleId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineRuleListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineRuleList(OnlineRule filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineRuleList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineRuleListWithRelation(OnlineRule filter, String orderBy); + + /** + * 在多对多关系中,当前Service的数据表为从表,返回不与指定主表主键Id存在对多对关系的列表。 + * + * @param columnId 主表主键Id。 + * @param filter 从表的过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getNotInOnlineRuleListByColumnId(Long columnId, OnlineRule filter, String orderBy); + + /** + * 在多对多关系中,当前Service的数据表为从表,返回与指定主表主键Id存在对多对关系的列表。 + * + * @param columnId 主表主键Id。 + * @param filter 从表的过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineRuleListByColumnId(Long columnId, OnlineRule filter, String orderBy); + + /** + * 返回指定字段Id列表关联的字段规则对象列表。 + * + * @param columnIdSet 指定的字段Id列表。 + * @return 关联的字段规则对象列表。 + */ + List getOnlineColumnRuleListByColumnIds(Set columnIdSet); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineTableService.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineTableService.java new file mode 100644 index 00000000..e30f7fba --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineTableService.java @@ -0,0 +1,68 @@ +package com.orangeforms.common.online.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.dbutil.object.SqlTable; +import com.orangeforms.common.online.model.OnlineColumn; +import com.orangeforms.common.online.model.OnlineTable; + +import java.util.List; +import java.util.Set; + +/** + * 数据表数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineTableService extends IBaseService { + + /** + * 基于数据库表保存新增对象。 + * + * @param sqlTable 数据库表对象。 + * @return 返回新增对象。 + */ + OnlineTable saveNewFromSqlTable(SqlTable sqlTable); + + /** + * 删除指定表及其关联的字段数据。 + * + * @param tableId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long tableId); + + /** + * 删除指定数据表Id集合中的表,及其关联字段。 + * + * @param tableIdSet 待删除的数据表Id集合。 + */ + void removeByTableIdSet(Set tableIdSet); + + /** + * 根据数据源Id,获取该数据源及其关联所引用的数据表列表。 + * + * @param datasourceId 指定的数据源Id。 + * @return 该数据源及其关联所引用的数据表列表。 + */ + List getOnlineTableListByDatasourceId(Long datasourceId); + + /** + * 从缓存中获取指定的表数据及其关联字段列表。优先从缓存中读取,如果不存在则从数据库中读取,并同步到缓存。 + * 该接口方法仅仅用户在线表单的动态数据操作接口,而非在线表单的配置接口。 + * + * @param tableId 表主键Id。 + * @return 查询后的在线表对象。 + */ + OnlineTable getOnlineTableFromCache(Long tableId); + + /** + * 从缓存中获取指定的表字段。优先从缓存中读取,如果不存在则从数据库中读取,并同步到缓存。 + * 该接口方法仅仅用户在线表单的动态数据操作接口,而非在线表单的配置接口。 + * + * @param tableId 表主键Id。 + * @param columnId 字段Id。 + * @return 查询后的在线表对象。 + */ + OnlineColumn getOnlineColumnFromCache(Long tableId, Long columnId); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineVirtualColumnService.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineVirtualColumnService.java new file mode 100644 index 00000000..710c3a51 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/OnlineVirtualColumnService.java @@ -0,0 +1,68 @@ +package com.orangeforms.common.online.service; + +import com.orangeforms.common.core.base.service.IBaseService; +import com.orangeforms.common.online.model.OnlineVirtualColumn; + +import java.util.*; + +/** + * 虚拟字段数据操作服务接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface OnlineVirtualColumnService extends IBaseService { + + /** + * 保存新增对象。 + * + * @param onlineVirtualColumn 新增对象。 + * @return 返回新增对象。 + */ + OnlineVirtualColumn saveNew(OnlineVirtualColumn onlineVirtualColumn); + + /** + * 更新数据对象。 + * + * @param onlineVirtualColumn 更新的对象。 + * @param originalOnlineVirtualColumn 原有数据对象。 + * @return 成功返回true,否则false。 + */ + boolean update(OnlineVirtualColumn onlineVirtualColumn, OnlineVirtualColumn originalOnlineVirtualColumn); + + /** + * 删除指定数据。 + * + * @param virtualColumnId 主键Id。 + * @return 成功返回true,否则false。 + */ + boolean remove(Long virtualColumnId); + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineVirtualColumnListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineVirtualColumnList(OnlineVirtualColumn filter, String orderBy); + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineVirtualColumnList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + List getOnlineVirtualColumnListWithRelation(OnlineVirtualColumn filter, String orderBy); + + /** + * 根据数据表的集合,查询关联的虚拟字段数据列表。 + * @param tableIdSet 在线数据表Id集合。 + * @return 关联的虚拟字段数据列表。 + */ + List getOnlineVirtualColumnListByTableIds(Set tableIdSet); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineColumnServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineColumnServiceImpl.java new file mode 100644 index 00000000..4e765927 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineColumnServiceImpl.java @@ -0,0 +1,365 @@ +package com.orangeforms.common.online.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.core.lang.Assert; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.constant.ObjectFieldType; +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.upload.UploadStoreTypeEnum; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.dbutil.object.SqlTableColumn; +import com.orangeforms.common.dbutil.provider.DataSourceProvider; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.online.util.OnlineDataSourceUtil; +import com.orangeforms.common.online.util.OnlineRedisKeyUtil; +import com.orangeforms.common.online.dao.OnlineColumnMapper; +import com.orangeforms.common.online.dao.OnlineColumnRuleMapper; +import com.orangeforms.common.online.model.OnlineColumn; +import com.orangeforms.common.online.model.OnlineColumnRule; +import com.orangeforms.common.online.model.constant.FieldFilterType; +import com.orangeforms.common.online.service.OnlineColumnService; +import com.github.pagehelper.Page; +import com.google.common.base.CaseFormat; +import lombok.extern.slf4j.Slf4j; +import org.redisson.api.RedissonClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +/** + * 字段数据数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("onlineColumnService") +public class OnlineColumnServiceImpl extends BaseService implements OnlineColumnService { + + @Autowired + private OnlineColumnMapper onlineColumnMapper; + @Autowired + private OnlineColumnRuleMapper onlineColumnRuleMapper; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private RedissonClient redissonClient; + @Autowired + private OnlineDataSourceUtil dataSourceUtil; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return onlineColumnMapper; + } + + /** + * 保存新增数据表字段列表。 + * + * @param columnList 新增数据表字段对象列表。 + * @param onlineTableId 在线表对象的主键Id。 + * @return 插入的在线表字段数据。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public List saveNewList(List columnList, Long onlineTableId) { + List onlineColumnList = new LinkedList<>(); + if (CollUtil.isEmpty(columnList)) { + return onlineColumnList; + } + this.evictTableCache(onlineTableId); + for (SqlTableColumn column : columnList) { + OnlineColumn onlineColumn = new OnlineColumn(); + BeanUtil.copyProperties(column, onlineColumn, false); + onlineColumn.setColumnId(idGenerator.nextLongId()); + onlineColumn.setTableId(onlineTableId); + this.setDefault(column, onlineColumn); + onlineColumnMapper.insert(onlineColumn); + onlineColumnList.add(onlineColumn); + } + return onlineColumnList; + } + + /** + * 更新数据对象。 + * + * @param onlineColumn 更新的对象。 + * @param originalOnlineColumn 原有数据对象。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(OnlineColumn onlineColumn, OnlineColumn originalOnlineColumn) { + this.evictTableCache(onlineColumn.getTableId()); + onlineColumn.setUpdateTime(new Date()); + onlineColumn.setUpdateUserId(TokenData.takeFromRequest().getUserId()); + onlineColumn.setCreateTime(originalOnlineColumn.getCreateTime()); + onlineColumn.setCreateUserId(originalOnlineColumn.getCreateUserId()); + // 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。 + UpdateWrapper uw = this.createUpdateQueryForNullValue(onlineColumn, onlineColumn.getColumnId()); + return onlineColumnMapper.update(onlineColumn, uw) == 1; + } + + /** + * 刷新数据库表字段的数据到在线表字段。 + * + * @param sqlTableColumn 源数据库表字段对象。 + * @param onlineColumn 被刷新的在线表字段对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void refresh(SqlTableColumn sqlTableColumn, OnlineColumn onlineColumn) { + this.evictTableCache(onlineColumn.getTableId()); + BeanUtil.copyProperties(sqlTableColumn, onlineColumn, false); + String objectFieldName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, onlineColumn.getColumnName()); + onlineColumn.setObjectFieldName(objectFieldName); + String objectFieldType = convertToJavaType(onlineColumn, sqlTableColumn.getDblinkType()); + onlineColumn.setObjectFieldType(objectFieldType); + onlineColumnMapper.updateById(onlineColumn); + } + + /** + * 删除指定数据。 + * + * @param tableId 表Id。 + * @param columnId 字段Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long tableId, Long columnId) { + this.evictTableCache(tableId); + return onlineColumnMapper.deleteById(columnId) == 1; + } + + /** + * 当前服务的支持表为从表,根据主表的主键Id,删除一对多的从表数据。 + * + * @param tableId 主表主键Id。 + * @return 删除数量。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int removeByTableId(Long tableId) { + OnlineColumn deletedObject = new OnlineColumn(); + deletedObject.setTableId(tableId); + return onlineColumnMapper.delete(new QueryWrapper<>(deletedObject)); + } + + /** + * 删除指定数据表Id集合中的表字段。 + * + * @param tableIdSet 待删除的数据表Id集合。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void removeByTableIdSet(Set tableIdSet) { + onlineColumnMapper.delete(new QueryWrapper().lambda().in(OnlineColumn::getTableId, tableIdSet)); + } + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineColumnListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @return 查询结果集。 + */ + @Override + public List getOnlineColumnList(OnlineColumn filter) { + return onlineColumnMapper.getOnlineColumnList(filter); + } + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineColumnList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @return 查询结果集。 + */ + @Override + public List getOnlineColumnListWithRelation(OnlineColumn filter) { + List resultList = onlineColumnMapper.getOnlineColumnList(filter); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + /** + * 获取指定数据表Id集合的字段对象列表。 + * + * @param tableIdSet 指定的数据表Id集合。 + * @return 数据表Id集合所包含的字段对象列表。 + */ + @Override + public List getOnlineColumnListByTableIds(Set tableIdSet) { + return onlineColumnMapper.selectList( + new QueryWrapper().lambda().in(OnlineColumn::getTableId, tableIdSet)); + } + + /** + * 根据表Id和字段列名获取指定字段。 + * + * @param tableId 字段所在表Id。 + * @param columnName 字段名。 + * @return 查询出的字段对象。 + */ + @Override + public OnlineColumn getOnlineColumnByTableIdAndColumnName(Long tableId, String columnName) { + OnlineColumn filter = new OnlineColumn(); + filter.setTableId(tableId); + filter.setColumnName(columnName); + return onlineColumnMapper.selectOne(new QueryWrapper<>(filter)); + } + + @Override + public CallResult verifyPrimaryKey(SqlTableColumn tableColumn) { + Assert.isTrue(tableColumn.getPrimaryKey()); + OnlineColumn onlineColumn = new OnlineColumn(); + BeanUtil.copyProperties(tableColumn, onlineColumn, false); + String javaType = this.convertToJavaType(onlineColumn, tableColumn.getDblinkType()); + if (ObjectFieldType.INTEGER.equals(javaType)) { + if (BooleanUtil.isFalse(onlineColumn.getAutoIncrement())) { + return CallResult.error("字段验证失败,整型主键必须是自增主键!"); + } + } else { + if (!StrUtil.equalsAny(javaType, ObjectFieldType.LONG, ObjectFieldType.STRING)) { + return CallResult.error("字段验证失败,不合法的主键类型 [" + tableColumn.getColumnType() + "]!"); + } + } + return CallResult.ok(); + } + + /** + * 批量添加多对多关联关系。 + * + * @param onlineColumnRuleList 多对多关联表对象集合。 + * @param columnId 主表Id。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void addOnlineColumnRuleList(List onlineColumnRuleList, Long columnId) { + this.evictTableCacheByColumnId(columnId); + for (OnlineColumnRule onlineColumnRule : onlineColumnRuleList) { + onlineColumnRule.setColumnId(columnId); + onlineColumnRuleMapper.insert(onlineColumnRule); + } + } + + /** + * 更新中间表数据。 + * + * @param onlineColumnRule 中间表对象。 + * @return 更新成功与否。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean updateOnlineColumnRule(OnlineColumnRule onlineColumnRule) { + this.evictTableCacheByColumnId(onlineColumnRule.getColumnId()); + OnlineColumnRule filter = new OnlineColumnRule(); + filter.setColumnId(onlineColumnRule.getColumnId()); + filter.setRuleId(onlineColumnRule.getRuleId()); + UpdateWrapper uw = + BaseService.createUpdateQueryForNullValue(onlineColumnRule, OnlineColumnRule.class); + uw.setEntity(filter); + return onlineColumnRuleMapper.update(onlineColumnRule, uw) > 0; + } + + /** + * 获取中间表数据。 + * + * @param columnId 主表Id。 + * @param ruleId 从表Id。 + * @return 中间表对象。 + */ + @Override + public OnlineColumnRule getOnlineColumnRule(Long columnId, Long ruleId) { + OnlineColumnRule filter = new OnlineColumnRule(); + filter.setColumnId(columnId); + filter.setRuleId(ruleId); + return onlineColumnRuleMapper.selectOne(new QueryWrapper<>(filter)); + } + + /** + * 移除单条多对多关系。 + * + * @param columnId 主表Id。 + * @param ruleId 从表Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean removeOnlineColumnRule(Long columnId, Long ruleId) { + this.evictTableCacheByColumnId(columnId); + OnlineColumnRule filter = new OnlineColumnRule(); + filter.setColumnId(columnId); + filter.setRuleId(ruleId); + return onlineColumnRuleMapper.delete(new QueryWrapper<>(filter)) > 0; + } + + private void setDefault(SqlTableColumn column, OnlineColumn onlineColumn) { + String objectFieldName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, onlineColumn.getColumnName()); + onlineColumn.setObjectFieldName(objectFieldName); + String objectFieldType = convertToJavaType(onlineColumn, column.getDblinkType()); + onlineColumn.setObjectFieldType(objectFieldType); + onlineColumn.setFilterType(FieldFilterType.NO_FILTER); + onlineColumn.setParentKey(false); + onlineColumn.setDeptFilter(false); + onlineColumn.setUserFilter(false); + if (onlineColumn.getAutoIncrement() == null) { + onlineColumn.setAutoIncrement(false); + } + onlineColumn.setUploadFileSystemType(UploadStoreTypeEnum.LOCAL_SYSTEM.ordinal()); + Date now = new Date(); + onlineColumn.setUpdateTime(now); + onlineColumn.setCreateTime(now); + onlineColumn.setCreateUserId(TokenData.takeFromRequest().getUserId()); + onlineColumn.setUpdateUserId(onlineColumn.getCreateUserId()); + } + + private void evictTableCache(Long tableId) { + String tableIdKey = OnlineRedisKeyUtil.makeOnlineTableKey(tableId); + redissonClient.getBucket(tableIdKey).delete(); + } + + private void evictTableCacheByColumnId(Long columnId) { + OnlineColumn column = this.getById(columnId); + if (column != null) { + this.evictTableCache(column.getTableId()); + } + } + + private String convertToJavaType(OnlineColumn column, int dblinkType) { + DataSourceProvider provider = dataSourceUtil.getProvider(dblinkType); + if (provider == null) { + throw new MyRuntimeException("Unsupported Data Type"); + } + return provider.convertColumnTypeToJavaType( + column.getColumnType(), column.getNumericPrecision(), column.getNumericScale()); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDatasourceRelationServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDatasourceRelationServiceImpl.java new file mode 100644 index 00000000..4cb53ee5 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDatasourceRelationServiceImpl.java @@ -0,0 +1,289 @@ +package com.orangeforms.common.online.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.alibaba.fastjson.JSONArray; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.dbutil.object.SqlTable; +import com.orangeforms.common.dbutil.object.SqlTableColumn; +import com.orangeforms.common.redis.util.CommonRedisUtil; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.online.util.OnlineRedisKeyUtil; +import com.orangeforms.common.online.dao.OnlineDatasourceRelationMapper; +import com.orangeforms.common.online.dao.OnlineDatasourceTableMapper; +import com.orangeforms.common.online.model.OnlineColumn; +import com.orangeforms.common.online.model.OnlineDatasourceRelation; +import com.orangeforms.common.online.model.OnlineDatasourceTable; +import com.orangeforms.common.online.model.OnlineTable; +import com.orangeforms.common.online.service.OnlineColumnService; +import com.orangeforms.common.online.service.OnlineDatasourceRelationService; +import com.orangeforms.common.online.service.OnlineDatasourceService; +import com.orangeforms.common.online.service.OnlineTableService; +import com.github.pagehelper.Page; +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.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; + +/** + * 数据源关联数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("onlineDatasourceRelationService") +public class OnlineDatasourceRelationServiceImpl + extends BaseService implements OnlineDatasourceRelationService { + + @Autowired + private OnlineDatasourceRelationMapper onlineDatasourceRelationMapper; + @Autowired + private OnlineDatasourceTableMapper onlineDatasourceTableMapper; + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private OnlineColumnService onlineColumnService; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private RedissonClient redissonClient; + @Autowired + private CommonRedisUtil commonRedisUtil; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return onlineDatasourceRelationMapper; + } + + /** + * 保存新增对象。 + * + * @param relation 新增对象。 + * @param slaveSqlTable 新增的关联从数据表对象。 + * @param slaveSqlColumn 新增的关联从数据表对象。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public OnlineDatasourceRelation saveNew( + OnlineDatasourceRelation relation, SqlTable slaveSqlTable, SqlTableColumn slaveSqlColumn) { + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineDataSourceRelationKey(relation.getDatasourceId())); + // 查找数据源关联的数据表,判断当前关联的从表,是否已经存在于zz_online_datasource_table中了。 + // 对于同一个数据源及其关联,同一个数据表只会被创建一次,如果已经和当前数据源的其他Relation, + // 作为从表绑定了,怎么就可以直接使用这个OnlineTable了,否则就会为这个SqlTable,创建对应的OnlineTable。 + List datasourceTableList = + onlineTableService.getOnlineTableListByDatasourceId(relation.getDatasourceId()); + OnlineTable relationSlaveTable = null; + OnlineColumn relationSlaveColumn = null; + for (OnlineTable onlineTable : datasourceTableList) { + if (onlineTable.getTableName().equals(slaveSqlTable.getTableName())) { + relationSlaveTable = onlineTable; + relationSlaveColumn = onlineColumnService.getOnlineColumnByTableIdAndColumnName( + onlineTable.getTableId(), slaveSqlColumn.getColumnName()); + break; + } + } + if (relationSlaveTable == null) { + relationSlaveTable = onlineTableService.saveNewFromSqlTable(slaveSqlTable); + for (OnlineColumn onlineColumn : relationSlaveTable.getColumnList()) { + if (onlineColumn.getColumnName().equals(slaveSqlColumn.getColumnName())) { + relationSlaveColumn = onlineColumn; + break; + } + } + } + TokenData tokenData = TokenData.takeFromRequest(); + relation.setRelationId(idGenerator.nextLongId()); + relation.setAppCode(tokenData.getAppCode()); + relation.setSlaveTableId(relationSlaveTable.getTableId()); + relation.setSlaveColumnId(relationSlaveColumn == null ? null : relationSlaveColumn.getColumnId()); + Date now = new Date(); + relation.setUpdateTime(now); + relation.setCreateTime(now); + relation.setCreateUserId(tokenData.getUserId()); + relation.setUpdateUserId(tokenData.getUserId()); + onlineDatasourceRelationMapper.insert(relation); + OnlineDatasourceTable datasourceTable = new OnlineDatasourceTable(); + datasourceTable.setId(idGenerator.nextLongId()); + datasourceTable.setDatasourceId(relation.getDatasourceId()); + datasourceTable.setRelationId(relation.getRelationId()); + datasourceTable.setTableId(relation.getSlaveTableId()); + onlineDatasourceTableMapper.insert(datasourceTable); + return relation; + } + + /** + * 更新数据对象。 + * + * @param relation 更新的对象。 + * @param originalRelation 原有数据对象。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(OnlineDatasourceRelation relation, OnlineDatasourceRelation originalRelation) { + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineDataSourceRelationKey(relation.getDatasourceId())); + TokenData tokenData = TokenData.takeFromRequest(); + relation.setAppCode(tokenData.getAppCode()); + relation.setUpdateTime(new Date()); + relation.setUpdateUserId(tokenData.getUserId()); + relation.setCreateTime(originalRelation.getCreateTime()); + relation.setCreateUserId(originalRelation.getCreateUserId()); + // 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。 + UpdateWrapper uw = + this.createUpdateQueryForNullValue(relation, relation.getRelationId()); + return onlineDatasourceRelationMapper.update(relation, uw) == 1; + } + + /** + * 删除指定数据。 + * + * @param relationId 主键Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long relationId) { + OnlineDatasourceRelation relation = this.getById(relationId); + if (relation != null) { + commonRedisUtil.evictFormCache( + OnlineRedisKeyUtil.makeOnlineDataSourceRelationKey(relation.getDatasourceId())); + } + if (onlineDatasourceRelationMapper.deleteById(relationId) != 1) { + return false; + } + OnlineDatasourceTable filter = new OnlineDatasourceTable(); + filter.setRelationId(relationId); + QueryWrapper queryWrapper = new QueryWrapper<>(filter); + OnlineDatasourceTable datasourceTable = onlineDatasourceTableMapper.selectOne(queryWrapper); + onlineDatasourceTableMapper.delete(queryWrapper); + filter = new OnlineDatasourceTable(); + filter.setDatasourceId(datasourceTable.getDatasourceId()); + filter.setTableId(datasourceTable.getTableId()); + // 不在有引用该表的时候,可以删除该数据源关联引用的从表了。 + if (onlineDatasourceTableMapper.selectCount(new QueryWrapper<>(filter)) == 0) { + onlineTableService.remove(datasourceTable.getTableId()); + } + return true; + } + + /** + * 当前服务的支持表为从表,根据主表的主键Id,删除一对多的从表数据。 + * + * @param datasourceId 主表主键Id。 + * @return 删除数量。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int removeByDatasourceId(Long datasourceId) { + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineDataSourceRelationKey(datasourceId)); + OnlineDatasourceRelation deletedObject = new OnlineDatasourceRelation(); + deletedObject.setDatasourceId(datasourceId); + return onlineDatasourceRelationMapper.delete(new QueryWrapper<>(deletedObject)); + } + + @Override + public List getOnlineDatasourceRelationListFromCache(Set datasourceIdSet) { + List resultList = new LinkedList<>(); + datasourceIdSet.forEach(datasourceId -> { + String key = OnlineRedisKeyUtil.makeOnlineDataSourceRelationKey(datasourceId); + RBucket bucket = redissonClient.getBucket(key); + if (bucket.isExists()) { + resultList.addAll(JSONArray.parseArray(bucket.get(), OnlineDatasourceRelation.class)); + } else { + OnlineDatasourceRelation filter = new OnlineDatasourceRelation(); + filter.setDatasourceId(datasourceId); + List relationList = this.getListByFilter(filter); + if (CollUtil.isNotEmpty(relationList)) { + resultList.addAll(relationList); + bucket.set(JSONArray.toJSONString(relationList)); + } + } + }); + return resultList; + } + + @Override + public OnlineDatasourceRelation getOnlineDatasourceRelationFromCache(Long datasourceId, Long relationId) { + List relationList = + this.getOnlineDatasourceRelationListFromCache(CollUtil.newHashSet(datasourceId)); + if (CollUtil.isEmpty(relationList)) { + return null; + } + return relationList.stream().filter(r -> r.getRelationId().equals(relationId)).findFirst().orElse(null); + } + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineDatasourceRelationList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineDatasourceRelationListWithRelation( + OnlineDatasourceRelation filter, String orderBy) { + if (filter == null) { + filter = new OnlineDatasourceRelation(); + } + filter.setAppCode(TokenData.takeFromRequest().getAppCode()); + List resultList = + onlineDatasourceRelationMapper.getOnlineDatasourceRelationList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + /** + * 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。 + * + * @param relation 最新数据对象。 + * @param originalRelation 原有数据对象。 + * @return 数据全部正确返回true,否则false。 + */ + @Override + public CallResult verifyRelatedData( + OnlineDatasourceRelation relation, OnlineDatasourceRelation originalRelation) { + String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!"; + if (this.needToVerify(relation, originalRelation, OnlineDatasourceRelation::getMasterColumnId) + && !onlineColumnService.existId(relation.getMasterColumnId())) { + return CallResult.error(String.format(errorMessageFormat, "主表关联字段Id")); + } + if (this.needToVerify(relation, originalRelation, OnlineDatasourceRelation::getSlaveTableId) + && !onlineTableService.existId(relation.getSlaveTableId())) { + return CallResult.error(String.format(errorMessageFormat, "从表Id")); + } + if (this.needToVerify(relation, originalRelation, OnlineDatasourceRelation::getSlaveColumnId) + && !onlineColumnService.existId(relation.getSlaveColumnId())) { + return CallResult.error(String.format(errorMessageFormat, "从表关联字段Id")); + } + return CallResult.ok(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDatasourceServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDatasourceServiceImpl.java new file mode 100644 index 00000000..0efb7d86 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDatasourceServiceImpl.java @@ -0,0 +1,270 @@ +package com.orangeforms.common.online.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.dbutil.object.SqlTable; +import com.orangeforms.common.redis.util.CommonRedisUtil; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.online.dao.OnlineDatasourceMapper; +import com.orangeforms.common.online.dao.OnlineDatasourceTableMapper; +import com.orangeforms.common.online.dao.OnlinePageDatasourceMapper; +import com.orangeforms.common.online.model.OnlineDatasource; +import com.orangeforms.common.online.model.OnlineDatasourceTable; +import com.orangeforms.common.online.model.OnlinePageDatasource; +import com.orangeforms.common.online.model.OnlineTable; +import com.orangeforms.common.online.service.OnlineDatasourceRelationService; +import com.orangeforms.common.online.service.OnlineDatasourceService; +import com.orangeforms.common.online.service.OnlineTableService; +import com.orangeforms.common.online.util.OnlineRedisKeyUtil; +import com.github.pagehelper.Page; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 数据模型数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("onlineDatasourceService") +public class OnlineDatasourceServiceImpl extends BaseService implements OnlineDatasourceService { + + @Autowired + private OnlineDatasourceMapper onlineDatasourceMapper; + @Autowired + private OnlinePageDatasourceMapper onlinePageDatasourceMapper; + @Autowired + private OnlineDatasourceTableMapper onlineDatasourceTableMapper; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private OnlineDatasourceRelationService onlineDatasourceRelationService; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private CommonRedisUtil commonRedisUtil; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return onlineDatasourceMapper; + } + + /** + * 保存新增对象。 + * + * @param onlineDatasource 新增对象。 + * @param sqlTable 新增的数据表对象。 + * @param pageId 关联的页面Id。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public OnlineDatasource saveNew(OnlineDatasource onlineDatasource, SqlTable sqlTable, Long pageId) { + TokenData tokenData = TokenData.takeFromRequest(); + OnlineTable onlineTable = onlineTableService.saveNewFromSqlTable(sqlTable); + onlineDatasource.setDatasourceId(idGenerator.nextLongId()); + onlineDatasource.setAppCode(tokenData.getAppCode()); + onlineDatasource.setMasterTableId(onlineTable.getTableId()); + Date now = new Date(); + onlineDatasource.setUpdateTime(now); + onlineDatasource.setCreateTime(now); + onlineDatasource.setCreateUserId(tokenData.getUserId()); + onlineDatasource.setUpdateUserId(tokenData.getUserId()); + onlineDatasourceMapper.insert(onlineDatasource); + OnlineDatasourceTable datasourceTable = new OnlineDatasourceTable(); + datasourceTable.setId(idGenerator.nextLongId()); + datasourceTable.setDatasourceId(onlineDatasource.getDatasourceId()); + datasourceTable.setTableId(onlineDatasource.getMasterTableId()); + onlineDatasourceTableMapper.insert(datasourceTable); + OnlinePageDatasource onlinePageDatasource = new OnlinePageDatasource(); + onlinePageDatasource.setId(idGenerator.nextLongId()); + onlinePageDatasource.setPageId(pageId); + onlinePageDatasource.setDatasourceId(onlineDatasource.getDatasourceId()); + onlinePageDatasourceMapper.insert(onlinePageDatasource); + return onlineDatasource; + } + + /** + * 更新数据对象。 + * + * @param onlineDatasource 更新的对象。 + * @param originalOnlineDatasource 原有数据对象。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(OnlineDatasource onlineDatasource, OnlineDatasource originalOnlineDatasource) { + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineDataSourceKey(onlineDatasource.getDatasourceId())); + TokenData tokenData = TokenData.takeFromRequest(); + onlineDatasource.setAppCode(tokenData.getAppCode()); + onlineDatasource.setUpdateTime(new Date()); + onlineDatasource.setUpdateUserId(tokenData.getUserId()); + onlineDatasource.setCreateTime(originalOnlineDatasource.getCreateTime()); + onlineDatasource.setCreateUserId(originalOnlineDatasource.getCreateUserId()); + // 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。 + UpdateWrapper uw = + this.createUpdateQueryForNullValue(onlineDatasource, onlineDatasource.getDatasourceId()); + return onlineDatasourceMapper.update(onlineDatasource, uw) == 1; + } + + /** + * 删除指定数据。 + * + * @param datasourceId 主键Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long datasourceId) { + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineDataSourceKey(datasourceId)); + if (onlineDatasourceMapper.deleteById(datasourceId) == 0) { + return false; + } + onlineDatasourceRelationService.removeByDatasourceId(datasourceId); + // 开始删除多对多父表的关联 + OnlinePageDatasource onlinePageDatasource = new OnlinePageDatasource(); + onlinePageDatasource.setDatasourceId(datasourceId); + onlinePageDatasourceMapper.delete(new QueryWrapper<>(onlinePageDatasource)); + OnlineDatasourceTable filter = new OnlineDatasourceTable(); + filter.setDatasourceId(datasourceId); + QueryWrapper queryWrapper = new QueryWrapper<>(filter); + List datasourceTableList = onlineDatasourceTableMapper.selectList(queryWrapper); + onlineDatasourceTableMapper.delete(queryWrapper); + Set tableIdSet = datasourceTableList.stream() + .map(OnlineDatasourceTable::getTableId).collect(Collectors.toSet()); + onlineTableService.removeByTableIdSet(tableIdSet); + return true; + } + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineDatasourceListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineDatasourceList(OnlineDatasource filter, String orderBy) { + if (filter == null) { + filter = new OnlineDatasource(); + } + filter.setAppCode(TokenData.takeFromRequest().getAppCode()); + return onlineDatasourceMapper.getOnlineDatasourceList(filter, orderBy); + } + + @Override + public OnlineDatasource getOnlineDatasourceFromCache(Long datasourceId) { + String key = OnlineRedisKeyUtil.makeOnlineDataSourceKey(datasourceId); + return commonRedisUtil.getFromCache(key, datasourceId, this::getById, OnlineDatasource.class); + } + + @Override + public List getOnlineDatasourceListFromCache(Set datasourceIdSet) { + List resultList = new LinkedList<>(); + datasourceIdSet.forEach(datasourceId -> resultList.add(this.getOnlineDatasourceFromCache(datasourceId))); + return resultList; + } + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineDatasourceList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineDatasourceListWithRelation(OnlineDatasource filter, String orderBy) { + List resultList = this.getOnlineDatasourceList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + /** + * 在多对多关系中,当前Service的数据表为从表,返回与指定主表主键Id存在对多对关系的列表。 + * + * @param pageId 主表主键Id。 + * @param filter 从表的过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineDatasourceListByPageId(Long pageId, OnlineDatasource filter, String orderBy) { + List resultList = + onlineDatasourceMapper.getOnlineDatasourceListByPageId(pageId, filter, orderBy); + this.buildRelationForDataList(resultList, MyRelationParam.dictOnly()); + return resultList; + } + + /** + * 获取指定数据源Id集合所关联的在线表关联数据。 + * + * @param datasourceIdSet 数据源Id集合。 + * @return 数据源和数据表的多对多关联列表。 + */ + @Override + public List getOnlineDatasourceTableList(Set datasourceIdSet) { + return onlineDatasourceTableMapper.selectList(new QueryWrapper() + .lambda().in(OnlineDatasourceTable::getDatasourceId, datasourceIdSet)); + } + + /** + * 根据在线表单Id集合,获取关联的在线数据源对象列表。 + * + * @param formIdSet 在线表单Id集合。 + * @return 与参数表单Id关联的数据源列表。 + */ + @Override + public List getOnlineDatasourceListByFormIds(Set formIdSet) { + return onlineDatasourceMapper.getOnlineDatasourceListByFormIds(formIdSet); + } + + @Override + public OnlineDatasource getOnlineDatasourceByMasterTableId(Long masterTableId) { + return onlineDatasourceMapper.selectOne( + new LambdaQueryWrapper().eq(OnlineDatasource::getMasterTableId, masterTableId)); + } + + @Override + public boolean existByVariableName(String variableName) { + OnlineDatasource filter = new OnlineDatasource(); + filter.setVariableName(variableName); + return CollUtil.isNotEmpty(this.getOnlineDatasourceList(filter, null)); + } + + @Override + public Map getPageIdAndVariableNameMapByPageIds(Set pageIds) { + String ids = CollUtil.join(pageIds, ","); + List> dataList = onlineDatasourceMapper.getPageIdAndVariableNameMapByPageIds(ids); + return dataList.stream() + .collect(Collectors.toMap(c -> (Long) c.get("page_id"), c -> (String) c.get("variable_name"))); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDblinkServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDblinkServiceImpl.java new file mode 100644 index 00000000..24198e62 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDblinkServiceImpl.java @@ -0,0 +1,203 @@ +package com.orangeforms.common.online.service.impl; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.dbutil.constant.DblinkType; +import com.orangeforms.common.dbutil.object.SqlTable; +import com.orangeforms.common.dbutil.object.SqlTableColumn; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.online.config.OnlineProperties; +import com.orangeforms.common.online.dao.OnlineDblinkMapper; +import com.orangeforms.common.online.model.OnlineDblink; +import com.orangeforms.common.online.service.OnlineDblinkService; +import com.orangeforms.common.online.util.OnlineDataSourceUtil; +import com.github.pagehelper.Page; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 数据库链接数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("onlineDblinkService") +public class OnlineDblinkServiceImpl extends BaseService implements OnlineDblinkService { + + @Autowired + private OnlineDblinkMapper onlineDblinkMapper; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private OnlineProperties onlineProperties; + @Autowired + private OnlineDataSourceUtil dataSourceUtil; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return onlineDblinkMapper; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public OnlineDblink saveNew(OnlineDblink onlineDblink) { + onlineDblinkMapper.insert(this.buildDefaultValue(onlineDblink)); + return onlineDblink; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(OnlineDblink onlineDblink, OnlineDblink originalOnlineDblink) { + if (!StrUtil.equals(onlineDblink.getConfiguration(), originalOnlineDblink.getConfiguration())) { + dataSourceUtil.removeDataSource(onlineDblink.getDblinkId()); + } + onlineDblink.setAppCode(TokenData.takeFromRequest().getAppCode()); + onlineDblink.setCreateUserId(originalOnlineDblink.getCreateUserId()); + onlineDblink.setUpdateUserId(TokenData.takeFromRequest().getUserId()); + onlineDblink.setCreateTime(originalOnlineDblink.getCreateTime()); + onlineDblink.setUpdateTime(new Date()); + // 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。 + UpdateWrapper uw = this.createUpdateQueryForNullValue(onlineDblink, onlineDblink.getDblinkId()); + return onlineDblinkMapper.update(onlineDblink, uw) == 1; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long dblinkId) { + dataSourceUtil.removeDataSource(dblinkId); + return onlineDblinkMapper.deleteById(dblinkId) == 1; + } + + @Override + public List getOnlineDblinkList(OnlineDblink filter, String orderBy) { + if (filter == null) { + filter = new OnlineDblink(); + } + filter.setAppCode(TokenData.takeFromRequest().getAppCode()); + return onlineDblinkMapper.getOnlineDblinkList(filter, orderBy); + } + + @Override + public List getOnlineDblinkListWithRelation(OnlineDblink filter, String orderBy) { + List resultList = this.getOnlineDblinkList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + @Override + public List getDblinkTableList(OnlineDblink dblink) { + List resultList = dataSourceUtil.getTableList(dblink.getDblinkId(), null); + if (StrUtil.isNotBlank(onlineProperties.getTablePrefix())) { + resultList = resultList.stream() + .filter(t -> StrUtil.startWith(t.getTableName(), onlineProperties.getTablePrefix())) + .collect(Collectors.toList()); + } + resultList.forEach(t -> t.setDblinkId(dblink.getDblinkId())); + return resultList; + } + + @Override + public SqlTable getDblinkTable(OnlineDblink dblink, String tableName) { + SqlTable sqlTable = dataSourceUtil.getTable(dblink.getDblinkId(), tableName); + sqlTable.setDblinkId(dblink.getDblinkId()); + sqlTable.setColumnList(getDblinkTableColumnList(dblink, tableName)); + return sqlTable; + } + + @Override + public List getDblinkTableColumnList(OnlineDblink dblink, String tableName) { + List columnList = dataSourceUtil.getTableColumnList(dblink.getDblinkId(), tableName); + columnList.forEach(c -> this.makeupSqlTableColumn(c, dblink.getDblinkType())); + return columnList; + } + + @Override + public SqlTableColumn getDblinkTableColumn(OnlineDblink dblink, String tableName, String columnName) { + List columnList = dataSourceUtil.getTableColumnList(dblink.getDblinkId(), tableName); + SqlTableColumn sqlTableColumn = columnList.stream() + .filter(c -> c.getColumnName().equals(columnName)).findFirst().orElse(null); + if (sqlTableColumn != null) { + this.makeupSqlTableColumn(sqlTableColumn, dblink.getDblinkType()); + } + return sqlTableColumn; + } + + private void makeupSqlTableColumn(SqlTableColumn sqlTableColumn, int dblinkType) { + sqlTableColumn.setDblinkType(dblinkType); + switch (dblinkType) { + case DblinkType.POSTGRESQL: + case DblinkType.OPENGAUSS: + if (StrUtil.equalsAny(sqlTableColumn.getColumnType(), "char", "varchar")) { + sqlTableColumn.setFullColumnType( + sqlTableColumn.getColumnType() + "(" + sqlTableColumn.getStringPrecision() + ")"); + } else { + sqlTableColumn.setFullColumnType(sqlTableColumn.getColumnType()); + } + break; + case DblinkType.MYSQL: + sqlTableColumn.setAutoIncrement("auto_increment".equals(sqlTableColumn.getExtra())); + break; + case DblinkType.ORACLE: + if (StrUtil.equalsAny(sqlTableColumn.getColumnType(), "VARCHAR2", "NVARCHAR2", "CHAR", "NCHAR")) { + sqlTableColumn.setFullColumnType( + sqlTableColumn.getColumnType() + "(" + sqlTableColumn.getStringPrecision() + ")"); + } else if (StrUtil.equals(sqlTableColumn.getColumnType(), "NUMBER")) { + sqlTableColumn.setFullColumnType(sqlTableColumn.getColumnType() + + "(" + sqlTableColumn.getNumericPrecision() + "," + sqlTableColumn.getNumericScale() + ")"); + } else { + sqlTableColumn.setFullColumnType(sqlTableColumn.getColumnType()); + } + break; + case DblinkType.DAMENG: + case DblinkType.KINGBASE: + if (StrUtil.equalsAnyIgnoreCase(sqlTableColumn.getColumnType(), "VARCHAR", "VARCHAR2", "CHAR")) { + sqlTableColumn.setFullColumnType( + sqlTableColumn.getColumnType() + "(" + sqlTableColumn.getStringPrecision() + ")"); + } else if (StrUtil.equals(sqlTableColumn.getColumnType(), "NUMBER")) { + sqlTableColumn.setFullColumnType(sqlTableColumn.getColumnType() + + "(" + sqlTableColumn.getNumericPrecision() + "," + sqlTableColumn.getNumericScale() + ")"); + } else { + sqlTableColumn.setFullColumnType(sqlTableColumn.getColumnType()); + } + break; + default: + break; + } + } + + private OnlineDblink buildDefaultValue(OnlineDblink onlineDblink) { + onlineDblink.setDblinkId(idGenerator.nextLongId()); + TokenData tokenData = TokenData.takeFromRequest(); + onlineDblink.setCreateUserId(tokenData.getUserId()); + onlineDblink.setUpdateUserId(tokenData.getUserId()); + Date now = new Date(); + onlineDblink.setCreateTime(now); + onlineDblink.setUpdateTime(now); + onlineDblink.setAppCode(tokenData.getAppCode()); + return onlineDblink; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDictServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDictServiceImpl.java new file mode 100644 index 00000000..0eca2dc1 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineDictServiceImpl.java @@ -0,0 +1,189 @@ +package com.orangeforms.common.online.service.impl; + +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.redis.util.CommonRedisUtil; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.online.util.OnlineRedisKeyUtil; +import com.orangeforms.common.online.dao.OnlineDictMapper; +import com.orangeforms.common.online.model.OnlineDict; +import com.orangeforms.common.online.service.OnlineDblinkService; +import com.orangeforms.common.online.service.OnlineDictService; +import com.github.pagehelper.Page; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +/** + * 在线表单字典数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("onlineDictService") +public class OnlineDictServiceImpl extends BaseService implements OnlineDictService { + + @Autowired + private OnlineDictMapper onlineDictMapper; + @Autowired + private OnlineDblinkService dblinkService; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private CommonRedisUtil commonRedisUtil; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return onlineDictMapper; + } + + /** + * 保存新增对象。 + * + * @param onlineDict 新增对象。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public OnlineDict saveNew(OnlineDict onlineDict) { + onlineDict.setDictId(idGenerator.nextLongId()); + TokenData tokenData = TokenData.takeFromRequest(); + onlineDict.setAppCode(tokenData.getAppCode()); + Date now = new Date(); + onlineDict.setUpdateTime(now); + onlineDict.setCreateTime(now); + onlineDict.setCreateUserId(tokenData.getUserId()); + onlineDict.setUpdateUserId(tokenData.getUserId()); + onlineDictMapper.insert(onlineDict); + return onlineDict; + } + + /** + * 更新数据对象。 + * + * @param onlineDict 更新的对象。 + * @param originalOnlineDict 原有数据对象。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(OnlineDict onlineDict, OnlineDict originalOnlineDict) { + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineDictKey(onlineDict.getDictId())); + TokenData tokenData = TokenData.takeFromRequest(); + onlineDict.setAppCode(tokenData.getAppCode()); + onlineDict.setUpdateTime(new Date()); + onlineDict.setUpdateUserId(tokenData.getUserId()); + onlineDict.setCreateTime(originalOnlineDict.getCreateTime()); + onlineDict.setCreateUserId(originalOnlineDict.getCreateUserId()); + // 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。 + UpdateWrapper uw = this.createUpdateQueryForNullValue(onlineDict, onlineDict.getDictId()); + return onlineDictMapper.update(onlineDict, uw) == 1; + } + + /** + * 删除指定数据。 + * + * @param dictId 主键Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long dictId) { + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineDictKey(dictId)); + return onlineDictMapper.deleteById(dictId) == 1; + } + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineDictListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineDictList(OnlineDict filter, String orderBy) { + if (filter == null) { + filter = new OnlineDict(); + } + filter.setAppCode(TokenData.takeFromRequest().getAppCode()); + return onlineDictMapper.getOnlineDictList(filter, orderBy); + } + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineDictList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineDictListWithRelation(OnlineDict filter, String orderBy) { + List resultList = this.getOnlineDictList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + @Override + public OnlineDict getOnlineDictFromCache(Long dictId) { + String key = OnlineRedisKeyUtil.makeOnlineDictKey(dictId); + return commonRedisUtil.getFromCache(key, dictId, this::getById, OnlineDict.class); + } + + @Override + public List getOnlineDictListFromCache(Set dictIdSet) { + List dictList = new LinkedList<>(); + dictIdSet.forEach(dictId -> { + OnlineDict dict = this.getOnlineDictFromCache(dictId); + if (dict != null) { + dictList.add(dict); + } + }); + return dictList; + } + + /** + * 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。 + * + * @param onlineDict 最新数据对象。 + * @param originalOnlineDict 原有数据对象。 + * @return 数据全部正确返回true,否则false。 + */ + @Override + public CallResult verifyRelatedData(OnlineDict onlineDict, OnlineDict originalOnlineDict) { + String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!"; + //这里是基于字典的验证。 + if (this.needToVerify(onlineDict, originalOnlineDict, OnlineDict::getDblinkId) + && !dblinkService.existId(onlineDict.getDblinkId())) { + return CallResult.error(String.format(errorMessageFormat, "数据库链接主键id")); + } + return CallResult.ok(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineFormServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineFormServiceImpl.java new file mode 100644 index 00000000..60b92227 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineFormServiceImpl.java @@ -0,0 +1,313 @@ +package com.orangeforms.common.online.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.alibaba.fastjson.JSONArray; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.redis.util.CommonRedisUtil; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.online.dao.OnlineFormDatasourceMapper; +import com.orangeforms.common.online.dao.OnlineFormMapper; +import com.orangeforms.common.online.model.OnlineForm; +import com.orangeforms.common.online.model.OnlineFormDatasource; +import com.orangeforms.common.online.service.OnlineFormService; +import com.orangeforms.common.online.service.OnlinePageService; +import com.orangeforms.common.online.service.OnlineTableService; +import com.orangeforms.common.online.util.OnlineRedisKeyUtil; +import com.github.pagehelper.Page; +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.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 在线表单数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("onlineFormService") +public class OnlineFormServiceImpl extends BaseService implements OnlineFormService { + + @Autowired + private OnlineFormMapper onlineFormMapper; + @Autowired + private OnlineFormDatasourceMapper onlineFormDatasourceMapper; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private OnlinePageService onlinePageService; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private CommonRedisUtil commonRedisUtil; + @Autowired + private RedissonClient redissonClient; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return onlineFormMapper; + } + + /** + * 保存新增对象。 + * + * @param onlineForm 新增对象。 + * @param datasourceIdSet 在线表单关联的数据源Id集合。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public OnlineForm saveNew(OnlineForm onlineForm, Set datasourceIdSet) { + onlineForm.setFormId(idGenerator.nextLongId()); + TokenData tokenData = TokenData.takeFromRequest(); + onlineForm.setAppCode(tokenData.getAppCode()); + onlineForm.setTenantId(tokenData.getTenantId()); + Date now = new Date(); + onlineForm.setUpdateTime(now); + onlineForm.setCreateTime(now); + onlineForm.setCreateUserId(tokenData.getUserId()); + onlineForm.setUpdateUserId(tokenData.getUserId()); + onlineFormMapper.insert(onlineForm); + if (CollUtil.isNotEmpty(datasourceIdSet)) { + for (Long datasourceId : datasourceIdSet) { + OnlineFormDatasource onlineFormDatasource = new OnlineFormDatasource(); + onlineFormDatasource.setId(idGenerator.nextLongId()); + onlineFormDatasource.setFormId(onlineForm.getFormId()); + onlineFormDatasource.setDatasourceId(datasourceId); + onlineFormDatasourceMapper.insert(onlineFormDatasource); + } + } + return onlineForm; + } + + /** + * 更新数据对象。 + * + * @param onlineForm 更新的对象。 + * @param originalOnlineForm 原有数据对象。 + * @param datasourceIdSet 在线表单关联的数据源Id集合。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(OnlineForm onlineForm, OnlineForm originalOnlineForm, Set datasourceIdSet) { + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineFormKey(onlineForm.getFormId())); + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineFormDatasourceKey(onlineForm.getFormId())); + TokenData tokenData = TokenData.takeFromRequest(); + onlineForm.setAppCode(tokenData.getAppCode()); + onlineForm.setTenantId(tokenData.getTenantId()); + onlineForm.setUpdateTime(new Date()); + onlineForm.setUpdateUserId(tokenData.getUserId()); + onlineForm.setCreateTime(originalOnlineForm.getCreateTime()); + onlineForm.setCreateUserId(originalOnlineForm.getCreateUserId()); + // 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。 + UpdateWrapper uw = this.createUpdateQueryForNullValue(onlineForm, onlineForm.getFormId()); + if (onlineFormMapper.update(onlineForm, uw) != 1) { + return false; + } + OnlineFormDatasource formDatasourceFilter = new OnlineFormDatasource(); + formDatasourceFilter.setFormId(onlineForm.getFormId()); + onlineFormDatasourceMapper.delete(new QueryWrapper<>(formDatasourceFilter)); + if (CollUtil.isNotEmpty(datasourceIdSet)) { + for (Long datasourceId : datasourceIdSet) { + OnlineFormDatasource onlineFormDatasource = new OnlineFormDatasource(); + onlineFormDatasource.setId(idGenerator.nextLongId()); + onlineFormDatasource.setFormId(onlineForm.getFormId()); + onlineFormDatasource.setDatasourceId(datasourceId); + onlineFormDatasourceMapper.insert(onlineFormDatasource); + } + } + return true; + } + + /** + * 删除指定数据。 + * + * @param formId 主键Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long formId) { + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineFormKey(formId)); + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineFormDatasourceKey(formId)); + if (onlineFormMapper.deleteById(formId) != 1) { + return false; + } + OnlineFormDatasource formDatasourceFilter = new OnlineFormDatasource(); + formDatasourceFilter.setFormId(formId); + onlineFormDatasourceMapper.delete(new QueryWrapper<>(formDatasourceFilter)); + return true; + } + + /** + * 根据PageId,删除其所属的所有表单,以及表单关联的数据源数据。 + * + * @param pageId 指定的pageId。 + * @return 删除数量。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int removeByPageId(Long pageId) { + OnlineForm filter = new OnlineForm(); + filter.setPageId(pageId); + List formList = onlineFormMapper.selectList(new QueryWrapper<>(filter)); + Set formIdSet = formList.stream().map(OnlineForm::getFormId).collect(Collectors.toSet()); + if (CollUtil.isNotEmpty(formIdSet)) { + onlineFormDatasourceMapper.delete( + new QueryWrapper().lambda().in(OnlineFormDatasource::getFormId, formIdSet)); + for (Long formId : formIdSet) { + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineFormKey(formId)); + commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineFormDatasourceKey(formId)); + } + } + return onlineFormMapper.delete(new QueryWrapper<>(filter)); + } + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineFormListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineFormList(OnlineForm filter, String orderBy) { + if (filter == null) { + filter = new OnlineForm(); + } + TokenData tokenData = TokenData.takeFromRequest(); + filter.setTenantId(tokenData.getTenantId()); + filter.setAppCode(tokenData.getAppCode()); + return onlineFormMapper.getOnlineFormList(filter, orderBy); + } + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineFormList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineFormListWithRelation(OnlineForm filter, String orderBy) { + List resultList = this.getOnlineFormList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + /** + * 获取使用指定数据表的表单列表。 + * + * @param tableId 数据表Id。 + * @return 使用该数据表的表单列表。 + */ + @Override + public List getOnlineFormListByTableId(Long tableId) { + OnlineForm filter = new OnlineForm(); + filter.setMasterTableId(tableId); + return this.getOnlineFormList(filter, null); + } + + @Override + public List getFormDatasourceListFromCache(Long formId) { + String key = OnlineRedisKeyUtil.makeOnlineFormDatasourceKey(formId); + RBucket bucket = redissonClient.getBucket(key); + if (bucket.isExists()) { + return JSONArray.parseArray(bucket.get(), OnlineFormDatasource.class); + } + LambdaQueryWrapper queryWrapper = + new QueryWrapper().lambda().eq(OnlineFormDatasource::getFormId, formId); + List resultList = onlineFormDatasourceMapper.selectList(queryWrapper); + bucket.set(JSONArray.toJSONString(resultList)); + return resultList; + } + + /** + * 查询正在使用当前数据源的表单。 + * + * @param datasourceId 数据源Id。 + * @return 正在使用当前数据源的表单列表。 + */ + @Override + public List getOnlineFormListByDatasourceId(Long datasourceId) { + OnlineForm filter = new OnlineForm(); + TokenData tokenData = TokenData.takeFromRequest(); + filter.setTenantId(tokenData.getTenantId()); + filter.setAppCode(tokenData.getAppCode()); + return onlineFormMapper.getOnlineFormListByDatasourceId(datasourceId, filter); + } + + @Override + public OnlineForm getOnlineFormFromCache(Long formId) { + String key = OnlineRedisKeyUtil.makeOnlineFormKey(formId); + return commonRedisUtil.getFromCache(key, formId, this::getById, OnlineForm.class); + } + + @Override + public boolean existByFormCode(String formCode) { + OnlineForm filter = new OnlineForm(); + filter.setFormCode(formCode); + return CollUtil.isNotEmpty(this.getOnlineFormList(filter, null)); + } + + @Override + public List getOnlineFormListByPageIds(Set pageIdSet) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.in(OnlineForm::getPageId, pageIdSet); + return onlineFormMapper.selectList(queryWrapper); + } + + /** + * 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。 + * + * @param onlineForm 最新数据对象。 + * @param originalOnlineForm 原有数据对象。 + * @return 数据全部正确返回true,否则false。 + */ + @Override + public CallResult verifyRelatedData(OnlineForm onlineForm, OnlineForm originalOnlineForm) { + String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!"; + //这里是基于字典的验证。 + if (this.needToVerify(onlineForm, originalOnlineForm, OnlineForm::getMasterTableId) + && !onlineTableService.existId(onlineForm.getMasterTableId())) { + return CallResult.error(String.format(errorMessageFormat, "表单主表id")); + } + //这里是一对多的验证 + if (this.needToVerify(onlineForm, originalOnlineForm, OnlineForm::getPageId) + && !onlinePageService.existId(onlineForm.getPageId())) { + return CallResult.error(String.format(errorMessageFormat, "页面id")); + } + return CallResult.ok(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineOperationServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineOperationServiceImpl.java new file mode 100644 index 00000000..8dde618f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineOperationServiceImpl.java @@ -0,0 +1,1759 @@ +package com.orangeforms.common.online.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.text.StrFormatter; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.github.pagehelper.page.PageMethod; +import com.google.common.collect.LinkedHashMultimap; +import com.google.common.collect.Multimap; +import com.orangeforms.common.core.annotation.MultiDatabaseWriteMethod; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.cache.CacheConfig; +import com.orangeforms.common.core.constant.*; +import com.orangeforms.common.core.exception.NoDataPermException; +import com.orangeforms.common.core.object.*; +import com.orangeforms.common.core.util.*; +import com.orangeforms.common.datafilter.config.DataFilterProperties; +import com.orangeforms.common.dbutil.constant.DblinkType; +import com.orangeforms.common.dbutil.provider.DataSourceProvider; +import com.orangeforms.common.dict.service.GlobalDictService; +import com.orangeforms.common.online.config.OnlineProperties; +import com.orangeforms.common.online.dao.OnlineOperationMapper; +import com.orangeforms.common.online.dto.OnlineFilterDto; +import com.orangeforms.common.online.exception.OnlineRuntimeException; +import com.orangeforms.common.online.model.*; +import com.orangeforms.common.online.model.constant.FieldFilterType; +import com.orangeforms.common.online.model.constant.FieldKind; +import com.orangeforms.common.online.model.constant.RelationType; +import com.orangeforms.common.online.model.constant.VirtualType; +import com.orangeforms.common.online.object.ColumnData; +import com.orangeforms.common.online.object.ConstDictInfo; +import com.orangeforms.common.online.object.JoinTableInfo; +import com.orangeforms.common.online.service.*; +import com.orangeforms.common.online.util.*; +import com.orangeforms.common.redis.util.CommonRedisUtil; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import jakarta.annotation.Resource; +import lombok.Data; +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.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.Serializable; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("onlineOperationService") +public class OnlineOperationServiceImpl implements OnlineOperationService { + + @Autowired + private OnlineOperationMapper onlineOperationMapper; + @Autowired + private OnlineDblinkService onlineDblinkService; + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private OnlineDictService onlineDictService; + @Autowired + private OnlineVirtualColumnService onlineVirtualColumnService; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private OnlineOperationHelper onlineOperationHelper; + @Autowired + private OnlineProperties onlineProperties; + @Autowired + private OnlineCustomExtFactory customExtFactory; + @Autowired + private GlobalDictService globalDictService; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private RedissonClient redissonClient; + @Autowired + private DataFilterProperties dataFilterProperties; + @Autowired + private CommonRedisUtil commonRedisUtil; + @Resource(name = "caffeineCacheManager") + private CacheManager cacheManager; + @Autowired + private OnlineDataSourceUtil dataSourceUtil; + + private static final String DICT_MAP_SUFFIX = "DictMap"; + private static final String DICT_MAP_LIST_SUFFIX = "DictMapList"; + private static final String SELECT = "SELECT "; + private static final String FROM = " FROM "; + private static final String WHERE = " WHERE "; + private static final String AND = " AND "; + + /** + * 聚合返回数据中,聚合键的常量字段名。 + * 如select groupColumn grouped_key, max(aggregationColumn) aggregated_value。 + */ + private static final String KEY_NAME = "grouped_key"; + /** + * 聚合返回数据中,聚合值的常量字段名。 + * 如select groupColumn grouped_key, max(aggregationColumn) aggregated_value。 + */ + private static final String VALUE_NAME = "aggregated_value"; + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public void saveNewBatch(OnlineTable table, List dataList) { + for (JSONObject data : dataList) { + this.saveNew(table, data); + } + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public Object saveNew(OnlineTable table, JSONObject data) { + ResponseResult> columnDataListResult = + onlineOperationHelper.buildTableData(table, data, false, null); + if (!columnDataListResult.isSuccess()) { + throw new OnlineRuntimeException(columnDataListResult.getErrorMessage()); + } + List columnDataList = columnDataListResult.getData(); + String columnNames = this.makeColumnNames(columnDataList); + List columnValueList = new LinkedList<>(); + Object id = null; + // 这里逐个处理每一行数据,特别是非自增主键、createUserId、createTime、逻辑删除等特殊属性的字段。 + for (ColumnData columnData : columnDataList) { + this.makeupColumnValue(columnData); + if (BooleanUtil.isFalse(columnData.getColumn().getAutoIncrement())) { + columnValueList.add(columnData.getColumnValue()); + if (BooleanUtil.isTrue(columnData.getColumn().getPrimaryKey())) { + id = columnData.getColumnValue(); + // 这里必须补齐主键值到JSON对象,后面的从表关联字段值填充可能会用到该值。 + data.put(columnData.getColumn().getColumnName(), id); + } + } + } + onlineOperationMapper.insert(table.getTableName(), columnNames, columnValueList); + return id; + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public Object saveNewWithRelation( + OnlineTable masterTable, + JSONObject masterData, + Map> slaveDataListMap) { + Object id = this.saveNew(masterTable, masterData); + if (slaveDataListMap == null) { + return id; + } + // 迭代多个关联列表。 + for (Map.Entry> entry : slaveDataListMap.entrySet()) { + Long masterColumnId = entry.getKey().getMasterColumnId(); + OnlineColumn masterColumn = masterTable.getColumnMap().get(masterColumnId); + Object columnValue = masterData.get(masterColumn.getColumnName()); + OnlineTable slaveTable = entry.getKey().getSlaveTable(); + OnlineColumn slaveColumn = slaveTable.getColumnMap().get(entry.getKey().getSlaveColumnId()); + // 迭代关联中的数据集合 + for (JSONObject slaveData : entry.getValue()) { + if (!slaveData.containsKey(slaveTable.getPrimaryKeyColumn().getColumnName())) { + slaveData.put(slaveColumn.getColumnName(), columnValue); + this.saveNew(slaveTable, slaveData); + } + } + } + return id; + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(OnlineTable table, JSONObject data) { + ResponseResult> columnDataListResult = + onlineOperationHelper.buildTableData(table, data, true, null); + if (!columnDataListResult.isSuccess()) { + throw new OnlineRuntimeException(columnDataListResult.getErrorMessage()); + } + List columnDataList = columnDataListResult.getData(); + String tableName = table.getTableName(); + List updateColumnList = new LinkedList<>(); + List filterList = new LinkedList<>(); + String dataId = null; + for (ColumnData columnData : columnDataList) { + this.makeupColumnValue(columnData); + // 对于以下几种类型的字段,忽略更新。 + if (BooleanUtil.isTrue(columnData.getColumn().getPrimaryKey()) + || ObjectUtil.equal(columnData.getColumn().getFieldKind(), FieldKind.LOGIC_DELETE)) { + OnlineFilterDto filter = new OnlineFilterDto(); + filter.setTableName(tableName); + filter.setColumnName(columnData.getColumn().getColumnName()); + filter.setColumnValue(columnData.getColumnValue()); + filterList.add(filter); + if (BooleanUtil.isTrue(columnData.getColumn().getPrimaryKey())) { + dataId = columnData.getColumnValue().toString(); + } + continue; + } + if (!MyCommonUtil.equalsAny(columnData.getColumn().getFieldKind(), + FieldKind.CREATE_TIME, FieldKind.CREATE_USER_ID, FieldKind.CREATE_DEPT_ID, FieldKind.TENANT_FILTER)) { + updateColumnList.add(columnData); + } + } + if (CollUtil.isEmpty(updateColumnList)) { + return true; + } + String dataPermFilter = this.buildDataPermFilter(table); + return this.doUpdate(table, updateColumnList, filterList, dataPermFilter); + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public boolean updateColumn(OnlineTable table, String dataId, OnlineColumn column, T dataValue) { + List updateColumnList = new LinkedList<>(); + ColumnData updateColumnData = new ColumnData(); + updateColumnData.setColumn(column); + updateColumnData.setColumnValue(dataValue); + updateColumnList.add(updateColumnData); + List filterList = this.makeDefaultFilter(table, table.getPrimaryKeyColumn(), dataId); + String dataPermFilter = this.buildDataPermFilter(table); + return this.doUpdate(table, updateColumnList, filterList, dataPermFilter); + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public void updateWithRelation( + OnlineTable masterTable, + JSONObject masterData, + Long datasourceId, + Map> slaveDataListMap) { + this.update(masterTable, masterData); + if (slaveDataListMap == null) { + return; + } + String masterDataId = masterData.get(masterTable.getPrimaryKeyColumn().getColumnName()).toString(); + for (Map.Entry> relationEntry : slaveDataListMap.entrySet()) { + Long relationId = relationEntry.getKey().getRelationId(); + this.updateRelationData( + masterTable, masterData, masterDataId, datasourceId, relationId, relationEntry.getValue()); + } + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public void updateRelationData( + OnlineTable masterTable, + Map masterData, + String masterDataId, + Long datasourceId, + Long relationId, + List slaveDataList) { + ResponseResult relationResult = + onlineOperationHelper.verifyAndGetRelation(datasourceId, relationId); + if (!relationResult.isSuccess()) { + throw new OnlineRuntimeException(relationResult.getErrorMessage()); + } + OnlineDatasourceRelation relation = relationResult.getData(); + OnlineTable slaveTable = relation.getSlaveTable(); + if (relation.getRelationType().equals(RelationType.ONE_TO_ONE)) { + JSONObject slaveData = null; + if (CollUtil.isNotEmpty(slaveDataList)) { + slaveData = slaveDataList.get(0); + } + this.saveNewOrUpdateOneToOneRelationData( + masterTable, masterData, masterDataId, slaveTable, slaveData, relation); + } else if (relation.getRelationType().equals(RelationType.ONE_TO_MANY)) { + if (slaveDataList == null) { + return; + } + this.saveNewOrUpdateOneToManyRelationData( + masterTable, masterData, masterDataId, slaveTable, slaveDataList, relation); + } + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public boolean delete(OnlineTable table, List relationList, String dataId) { + List filterList = + this.makeDefaultFilter(table, table.getPrimaryKeyColumn(), dataId); + String dataPermFilter = this.buildDataPermFilter(table); + if (table.getLogicDeleteColumn() == null) { + if (this.doDelete(table, filterList, dataPermFilter) != 1) { + return false; + } + } else { + this.doLogicDelete(table, table.getPrimaryKeyColumn(), dataId, dataPermFilter); + } + if (CollUtil.isEmpty(relationList)) { + return true; + } + Map masterData = getMasterData(table, null, null, dataId); + for (OnlineDatasourceRelation relation : relationList) { + if (BooleanUtil.isFalse(relation.getCascadeDelete())) { + continue; + } + OnlineTable slaveTable = relation.getSlaveTable(); + OnlineColumn slaveColumn = + relation.getSlaveTable().getColumnMap().get(relation.getSlaveColumnId()); + String columnValue = dataId; + if (!relation.getMasterColumnId().equals(table.getPrimaryKeyColumn().getColumnId())) { + OnlineColumn relationMasterColumn = table.getColumnMap().get(relation.getMasterColumnId()); + columnValue = masterData.get(relationMasterColumn.getColumnName()).toString(); + } + List slaveFilterList = + this.makeDefaultFilter(relation.getSlaveTable(), slaveColumn, columnValue); + if (slaveTable.getLogicDeleteColumn() == null) { + this.doDelete(slaveTable, slaveFilterList, null); + } else { + this.doLogicDelete(slaveTable, slaveColumn, columnValue, null); + } + } + return true; + } + + @MultiDatabaseWriteMethod + @Transactional(rollbackFor = Exception.class) + @Override + public void deleteOneToManySlaveData( + OnlineTable table, OnlineColumn column, String columnValue, Set keptIdSet) { + List filterList = this.makeDefaultFilter(table, column, columnValue); + if (CollUtil.isNotEmpty(keptIdSet)) { + OnlineFilterDto keptIdSetFilter = new OnlineFilterDto(); + Set convertedIdSet = + onlineOperationHelper.convertToTypeValue(table.getPrimaryKeyColumn(), keptIdSet); + keptIdSetFilter.setColumnValueList(new HashSet<>(convertedIdSet)); + keptIdSetFilter.setTableName(table.getTableName()); + keptIdSetFilter.setColumnName(table.getPrimaryKeyColumn().getColumnName()); + keptIdSetFilter.setFilterType(FieldFilterType.NOT_IN_LIST_FILTER); + filterList.add(keptIdSetFilter); + } + if (table.getLogicDeleteColumn() == null) { + this.doDelete(table, filterList, null); + } else { + this.doLogicDelete(table, filterList, null); + } + } + + @Override + public boolean existId(OnlineTable table, String dataId) { + return this.getMasterData(table, null, null, dataId) != null; + } + + @Override + public Map getMasterData( + OnlineTable table, + List oneToOneRelationList, + List allRelationList, + String dataId) { + List filterList = + this.makeDefaultFilter(table, table.getPrimaryKeyColumn(), dataId); + // 组件表关联数据。 + List joinInfoList = this.makeJoinInfoList(table, oneToOneRelationList); + // 拼接关联表的select fields字段。 + String selectFields = this.makeSelectFieldsWithRelation(table, oneToOneRelationList); + String dataPermFilter = this.buildDataPermFilter(table); + this.normalizeFiltersSlaveTableAlias(oneToOneRelationList, filterList); + selectFields = this.normalizeSlaveTableAlias(oneToOneRelationList, selectFields); + MyPageData> pageData = this.getList( + table, joinInfoList, selectFields, filterList, dataPermFilter, null, null); + List> resultList = pageData.getDataList(); + this.buildDataListWithDict(resultList, table, oneToOneRelationList); + if (CollUtil.isEmpty(resultList)) { + return null; + } + if (CollUtil.isNotEmpty(allRelationList)) { + // 针对一对多和多对多关联,计算虚拟聚合字段。 + List toManyRelationList = allRelationList.stream() + .filter(r -> !r.getRelationType().equals(RelationType.ONE_TO_ONE)).collect(Collectors.toList()); + this.buildVirtualColumn(resultList, table, toManyRelationList); + } + this.reformatResultListWithOneToOneRelation(resultList, oneToOneRelationList); + return resultList.get(0); + } + + @Override + public Map getSlaveData(OnlineDatasourceRelation relation, String dataId) { + OnlineTable slaveTable = relation.getSlaveTable(); + List filterList = + this.makeDefaultFilter(slaveTable, slaveTable.getPrimaryKeyColumn(), dataId); + // 拼接关联表的select fields字段。 + String selectFields = this.makeSelectFields(slaveTable, null); + String dataPermFilter = this.buildDataPermFilter(slaveTable); + MyPageData> pageData = this.getList( + slaveTable, null, selectFields, filterList, dataPermFilter, null, null); + List> resultList = pageData.getDataList(); + this.buildDataListWithDict(resultList, slaveTable); + return CollUtil.isEmpty(resultList) ? null : resultList.get(0); + } + + @Override + public MyPageData> getMasterDataList( + OnlineTable table, + List oneToOneRelationList, + List allRelationList, + List filterList, + String orderBy, + MyPageParam pageParam) { + this.normalizeFilterList(table, oneToOneRelationList, filterList); + // 组件表关联数据。 + List joinInfoList = this.makeJoinInfoList(table, oneToOneRelationList); + // 拼接关联表的select fields字段。 + String selectFields = this.makeSelectFieldsWithRelation(table, oneToOneRelationList); + String dataPermFilter = this.buildDataPermFilter(table); + this.normalizeFiltersSlaveTableAlias(oneToOneRelationList, filterList); + selectFields = this.normalizeSlaveTableAlias(oneToOneRelationList, selectFields); + orderBy = this.normalizeSlaveTableAlias(oneToOneRelationList, orderBy); + MyPageData> pageData = + this.getList(table, joinInfoList, selectFields, filterList, dataPermFilter, orderBy, pageParam); + List> resultList = pageData.getDataList(); + this.buildDataListWithDict(resultList, table, oneToOneRelationList); + // 针对一对多和多对多关联,计算虚拟聚合字段。 + if (CollUtil.isNotEmpty(allRelationList)) { + List toManyRelationList = allRelationList.stream() + .filter(r -> !r.getRelationType().equals(RelationType.ONE_TO_ONE)).collect(Collectors.toList()); + this.buildVirtualColumn(resultList, table, toManyRelationList); + } + this.reformatResultListWithOneToOneRelation(resultList, oneToOneRelationList); + return pageData; + } + + @Override + public MyPageData> getSlaveDataList( + OnlineDatasourceRelation relation, List filterList, String orderBy, MyPageParam pageParam) { + OnlineTable slaveTable = relation.getSlaveTable(); + this.normalizeFilterList(slaveTable, null, filterList); + // 拼接关联表的select fields字段。 + String selectFields = this.makeSelectFields(slaveTable, null); + String dataPermFilter = this.buildDataPermFilter(slaveTable); + MyPageData> pageData = + this.getList(slaveTable, null, selectFields, filterList, dataPermFilter, orderBy, pageParam); + this.buildDataListWithDict(pageData.getDataList(), slaveTable); + return pageData; + } + + @Override + public List> getDictDataList(OnlineDict dict, List filterList) { + if (StrUtil.isNotBlank(dict.getDeletedColumnName())) { + if (filterList == null) { + filterList = new LinkedList<>(); + } + OnlineFilterDto filter = new OnlineFilterDto(); + filter.setColumnName(dict.getDeletedColumnName()); + filter.setColumnValue(GlobalDeletedFlag.NORMAL); + filterList.add(filter); + } + if (StrUtil.isNotBlank(dict.getTenantFilterColumnName())) { + if (filterList == null) { + filterList = new LinkedList<>(); + } + OnlineFilterDto filter = new OnlineFilterDto(); + filter.setColumnName(dict.getTenantFilterColumnName()); + filter.setColumnValue(TokenData.takeFromRequest().getTenantId()); + filterList.add(filter); + } + String selectFields = this.makeDictSelectFields(dict, false); + String dataPermFilter = this.buildDataPermFilter( + dict.getTableName(), dict.getDeptFilterColumnName(), dict.getUserFilterColumnName()); + return this.getDictList(dict.getDblinkId(), dict.getTableName(), selectFields, filterList, dataPermFilter); + } + + @Override + public void buildDataListWithDict( + OnlineTable masterTable, List relationList, List> dataList) { + this.buildDataListWithDict(dataList, masterTable, relationList); + } + + @Override + public Map calculatePermData(Set menuFormIds, Set viewFormIds, Set editFormIds) { + Map> formMenuPermMap = new HashMap<>(menuFormIds.size()); + for (Long menuFormId : menuFormIds) { + formMenuPermMap.put(menuFormId, new HashSet<>()); + } + Set permCodeSet = new HashSet<>(10); + Set permUrlSet = new HashSet<>(10); + if (CollUtil.isNotEmpty(viewFormIds)) { + List datasourceList = + onlineDatasourceService.getOnlineDatasourceListByFormIds(viewFormIds); + for (OnlineDatasource datasource : datasourceList) { + permCodeSet.add(OnlineUtil.makeViewPermCode(datasource.getVariableName())); + Set permUrls = onlineProperties.getViewUrlList().stream() + .map(url -> url + datasource.getVariableName()).collect(Collectors.toSet()); + permUrlSet.addAll(permUrls); + datasource.getOnlineFormDatasourceList().forEach(formDatasource -> + formMenuPermMap.get(formDatasource.getFormId()).addAll(permUrls)); + } + } + if (CollUtil.isNotEmpty(editFormIds)) { + List datasourceList = + onlineDatasourceService.getOnlineDatasourceListByFormIds(editFormIds); + for (OnlineDatasource datasource : datasourceList) { + permCodeSet.add(OnlineUtil.makeEditPermCode(datasource.getVariableName())); + Set permUrls = onlineProperties.getEditUrlList().stream() + .map(url -> url + datasource.getVariableName()).collect(Collectors.toSet()); + permUrlSet.addAll(permUrls); + datasource.getOnlineFormDatasourceList().forEach(formDatasource -> + formMenuPermMap.get(formDatasource.getFormId()).addAll(permUrls)); + } + } + List onlineWhitelistUrls = CollUtil.newArrayList( + onlineProperties.getUrlPrefix() + "/onlineOperation/listDict", + onlineProperties.getUrlPrefix() + "/onlineForm/render", + onlineProperties.getUrlPrefix() + "/onlineForm/view"); + Map resultMap = new HashMap<>(3); + resultMap.put("permCodeSet", permCodeSet); + resultMap.put("permUrlSet", permUrlSet); + resultMap.put("formMenuPermMap", formMenuPermMap); + resultMap.put("onlineWhitelistUrls", onlineWhitelistUrls); + return resultMap; + } + + private boolean doUpdate( + OnlineTable table, List updateColumns, List filters, String dataPermFilter) { + return onlineOperationMapper.update(table.getTableName(), updateColumns, filters, dataPermFilter) == 1; + } + + private int doDelete(OnlineTable table, List filters, String dataPermFilter) { + return onlineOperationMapper.delete(table.getTableName(), filters, dataPermFilter); + } + + private List> getGroupedListByCondition( + Long dblinkId, String selectTable, String selectFields, String whereClause, String groupBy) { + return onlineOperationMapper.getGroupedListByCondition(selectTable, selectFields, whereClause, groupBy); + } + + private List> getDictList( + Long dblinkId, String tableName, String selectFields, List filterList, String dataPermFilter) { + return onlineOperationMapper.getDictList(tableName, selectFields, filterList, dataPermFilter); + } + + private MyPageData> getList( + OnlineTable table, + List joinInfoList, + String selectFields, + List filterList, + String dataPermFilter, + String orderBy, + MyPageParam pageParam) { + if (pageParam != null) { + PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); + } + List> resultList = onlineOperationMapper.getList( + table.getTableName(), joinInfoList, selectFields, filterList, dataPermFilter, orderBy); + return MyPageUtil.makeResponseData(resultList); + } + + private String makeWhereClause(List filters, String dataPermFilter, List paramList) { + if (CollUtil.isEmpty(filters) && StrUtil.isBlank(dataPermFilter)) { + return ""; + } + StringBuilder where = new StringBuilder(512); + List normalizedFilters = new LinkedList<>(); + if (CollUtil.isNotEmpty(filters)) { + for (OnlineFilterDto filter : filters) { + String filterString = this.makeSubWhereClause(filter, paramList); + if (StrUtil.isNotBlank(filterString)) { + normalizedFilters.add(filterString); + } + } + } + if (CollUtil.isNotEmpty(normalizedFilters)) { + where.append(WHERE); + where.append(CollUtil.join(normalizedFilters, AND)); + } + if (StrUtil.isNotBlank(dataPermFilter)) { + if (CollUtil.isNotEmpty(normalizedFilters)) { + where.append(AND); + } else { + where.append(WHERE); + } + where.append(dataPermFilter); + } + return where.toString(); + } + + private String makeSubWhereClause(OnlineFilterDto filter, List paramList) { + StringBuilder where = new StringBuilder(256); + if (filter.getFilterType().equals(FieldFilterType.EQUAL_FILTER)) { + where.append(this.makeWhereLeftOperator(filter)); + where.append(" = ? "); + paramList.add(filter.getColumnValue()); + } else if (filter.getFilterType().equals(FieldFilterType.RANGE_FILTER)) { + where.append(this.makeRangeFilterClause(filter, paramList)); + } else if (filter.getFilterType().equals(FieldFilterType.LIKE_FILTER)) { + where.append(this.makeWhereLeftOperator(filter)); + where.append(" LIKE ? "); + paramList.add(filter.getColumnValue()); + } else if (filter.getFilterType().equals(FieldFilterType.IN_LIST_FILTER)) { + where.append(this.makeWhereLeftOperator(filter)); + where.append(" IN ( "); + where.append(StrUtil.repeat("?,", filter.getColumnValueList().size())); + where.setLength(where.length() - 1); + where.append(")"); + paramList.addAll(filter.getColumnValueList()); + } else if (filter.getFilterType().equals(FieldFilterType.MULTI_LIKE)) { + where.append("("); + StringBuilder sb = new StringBuilder(128); + sb.append(this.makeWhereLeftOperator(filter)).append(" LIKE ? OR "); + String s = StrUtil.repeat(sb.toString(), filter.getColumnValueList().size()); + where.append(s, 0, s.length() - 4); + where.append(")"); + paramList.addAll(filter.getColumnValueList()); + } else if (filter.getFilterType().equals(FieldFilterType.NOT_IN_LIST_FILTER)) { + where.append(this.makeWhereLeftOperator(filter)); + where.append(" NOT IN ("); + where.append(StrUtil.repeat("?,", filter.getColumnValueList().size())); + where.setLength(where.length() - 1); + where.append(")"); + paramList.addAll(filter.getColumnValueList()); + } else if (filter.getFilterType().equals(FieldFilterType.IS_NULL)) { + where.append(this.makeWhereLeftOperator(filter)); + where.append(" IS NULL "); + } else if (filter.getFilterType().equals(FieldFilterType.IS_NOT_NULL)) { + where.append(this.makeWhereLeftOperator(filter)); + where.append(" IS NOT NULL "); + } + return where.toString(); + } + + private String makeRangeFilterClause(OnlineFilterDto filter, List paramList) { + StringBuilder where = new StringBuilder(256); + if (ObjectUtil.isNotEmpty(filter.getColumnValueStart())) { + where.append(this.makeWhereLeftOperator(filter)); + if (BooleanUtil.isTrue(filter.getIsOracleDate())) { + where.append(" >= ").append(filter.getColumnValueStart()); + } else { + where.append(" >= ? "); + paramList.add(filter.getColumnValueStart()); + } + } + if (ObjectUtil.isNotEmpty(filter.getColumnValueEnd())) { + if (ObjectUtil.isNotEmpty(filter.getColumnValueStart())) { + where.append(AND); + } + where.append(this.makeWhereLeftOperator(filter)); + if (BooleanUtil.isTrue(filter.getIsOracleDate())) { + where.append(" <= ").append(filter.getColumnValueEnd()); + } else { + where.append(" <= ? "); + paramList.add(filter.getColumnValueEnd()); + } + } + return where.toString(); + } + + private String makeWhereLeftOperator(OnlineFilterDto filter) { + if (StrUtil.isBlank(filter.getTableName())) { + return filter.getColumnName(); + } + StringBuilder sb = new StringBuilder(128); + sb.append(filter.getTableName()).append(".").append(filter.getColumnName()); + return sb.toString(); + } + + private void saveNewOrUpdateOneToManyRelationData( + OnlineTable masterTable, + Map masterData, + String masterDataId, + OnlineTable slaveTable, + List relationDataList, + OnlineDatasourceRelation relation) { + if (masterData == null) { + masterData = this.getMasterData(masterTable, null, null, masterDataId); + } + Set idSet = new HashSet<>(relationDataList.size()); + for (JSONObject relationData : relationDataList) { + Object id = relationData.get(relation.getSlaveTable().getPrimaryKeyColumn().getColumnName()); + if (ObjectUtil.isNotEmpty(id)) { + idSet.add(id.toString()); + } + } + // 自动补齐主表关联数据。 + OnlineColumn masterColumn = masterTable.getColumnMap().get(relation.getMasterColumnId()); + Object masterColumnValue = masterData.get(masterColumn.getColumnName()); + OnlineColumn slaveColumn = relation.getSlaveTable().getColumnMap().get(relation.getSlaveColumnId()); + // 在从表中删除本地批量更新不存在的数据。 + this.deleteOneToManySlaveData( + relation.getSlaveTable(), slaveColumn, masterColumnValue.toString(), idSet); + for (JSONObject relationData : relationDataList) { + // 自动补齐主表关联数据。 + relationData.put(slaveColumn.getColumnName(), masterColumnValue); + // 拆解主表和一对多关联从表的输入参数,并构建出数据表的待插入数据列表。 + Object id = relationData.get(relation.getSlaveTable().getPrimaryKeyColumn().getColumnName()); + if (id == null) { + this.saveNew(slaveTable, relationData); + } else { + this.update(slaveTable, relationData); + } + } + } + + private void saveNewOrUpdateOneToOneRelationData( + OnlineTable masterTable, + Map masterData, + String masterDataId, + OnlineTable slaveTable, + JSONObject slaveData, + OnlineDatasourceRelation relation) { + if (MapUtil.isEmpty(slaveData)) { + return; + } + String keyColumnName = slaveTable.getPrimaryKeyColumn().getColumnName(); + String slaveDataId = slaveData.getString(keyColumnName); + if (slaveDataId == null) { + if (masterData == null) { + masterData = this.getMasterData(masterTable, null, null, masterDataId); + } + // 自动补齐主表关联数据。 + OnlineColumn masterColumn = masterTable.getColumnMap().get(relation.getMasterColumnId()); + Object masterColumnValue = masterData.get(masterColumn.getColumnName()); + OnlineColumn slaveColumn = slaveTable.getColumnMap().get(relation.getSlaveColumnId()); + slaveData.put(slaveColumn.getColumnName(), masterColumnValue); + this.saveNew(slaveTable, slaveData); + } else { + Map originalSlaveData = + this.getMasterData(slaveTable, null, null, slaveDataId); + for (Map.Entry entry : originalSlaveData.entrySet()) { + slaveData.putIfAbsent(entry.getKey(), entry.getValue()); + } + if (!this.update(slaveTable, slaveData)) { + throw new OnlineRuntimeException("关联从表 [" + slaveTable.getTableName() + "] 中的更新数据不存在"); + } + } + } + + private void reformatResultListWithOneToOneRelation( + List> resultList, List oneToOneRelationList) { + if (CollUtil.isEmpty(oneToOneRelationList) || CollUtil.isEmpty(resultList)) { + return; + } + for (OnlineDatasourceRelation r : oneToOneRelationList) { + for (Map resultMap : resultList) { + Collection slaveColumnList = r.getSlaveTable().getColumnMap().values(); + Map oneToOneRelationDataMap = new HashMap<>(slaveColumnList.size()); + resultMap.put(r.getVariableName(), oneToOneRelationDataMap); + for (OnlineColumn c : slaveColumnList) { + StringBuilder sb = new StringBuilder(64); + sb.append(r.getVariableName()) + .append(OnlineConstant.RELATION_TABLE_COLUMN_SEPARATOR).append(c.getColumnName()); + Object data = this.removeRelationColumnData(resultMap, sb.toString()); + oneToOneRelationDataMap.put(c.getColumnName(), data); + if (c.getDictId() != null) { + sb.append(DICT_MAP_SUFFIX); + data = this.removeRelationColumnData(resultMap, sb.toString()); + oneToOneRelationDataMap.put(c.getColumnName() + DICT_MAP_SUFFIX, data); + } + } + } + } + } + + private Object removeRelationColumnData(Map resultMap, String name) { + Object data = resultMap.remove(name); + if (data == null) { + data = resultMap.remove("\"" + name + "\""); + } + return data; + } + + private void buildVirtualColumn( + List> resultList, OnlineTable table, List relationList) { + if (CollUtil.isEmpty(resultList) || CollUtil.isEmpty(relationList)) { + return; + } + OnlineVirtualColumn virtualColumnFilter = new OnlineVirtualColumn(); + virtualColumnFilter.setTableId(table.getTableId()); + virtualColumnFilter.setVirtualType(VirtualType.AGGREGATION); + List virtualColumnList = + onlineVirtualColumnService.getOnlineVirtualColumnList(virtualColumnFilter, null); + if (CollUtil.isEmpty(virtualColumnList)) { + return; + } + Map relationMap = + relationList.stream().collect(Collectors.toMap(OnlineDatasourceRelation::getRelationId, r -> r)); + for (OnlineVirtualColumn virtualColumn : virtualColumnList) { + OnlineDatasourceRelation relation = relationMap.get(virtualColumn.getRelationId()); + if (relation.getRelationType().equals(RelationType.ONE_TO_MANY)) { + this.doBuildVirtualColumnForOneToMany(table, resultList, virtualColumn, relation); + } + } + } + + private void doBuildVirtualColumnForOneToMany( + OnlineTable masterTable, + List> resultList, + OnlineVirtualColumn virtualColumn, + OnlineDatasourceRelation relation) { + String slaveTableName = relation.getSlaveTable().getTableName(); + OnlineColumn slaveColumn = + relation.getSlaveTable().getColumnMap().get(relation.getSlaveColumnId()); + String slaveColumnName = slaveColumn.getColumnName(); + OnlineColumn aggregationColumn = + relation.getSlaveTable().getColumnMap().get(virtualColumn.getAggregationColumnId()); + String aggregationColumnName = aggregationColumn.getColumnName(); + Tuple2 selectAndGroupByTuple = makeSelectListAndGroupByClause( + slaveTableName, slaveColumnName, slaveTableName, aggregationColumnName, virtualColumn.getAggregationType()); + String selectList = selectAndGroupByTuple.getFirst(); + String groupBy = selectAndGroupByTuple.getSecond(); + // 开始组装过滤从句。 + List criteriaList = new LinkedList<>(); + // 1. 组装主表数据对从表的过滤条件。 + MyWhereCriteria inlistFilter = new MyWhereCriteria(); + OnlineColumn masterColumn = masterTable.getColumnMap().get(relation.getMasterColumnId()); + String masterColumnName = masterColumn.getColumnName(); + Set masterIdSet = resultList.stream() + .map(r -> r.get(masterColumnName)).filter(Objects::nonNull).collect(Collectors.toSet()); + inlistFilter.setCriteria( + slaveTableName, slaveColumnName, slaveColumn.getObjectFieldType(), MyWhereCriteria.OPERATOR_IN, masterIdSet); + criteriaList.add(inlistFilter); + // 2. 从表逻辑删除字段过滤。 + if (relation.getSlaveTable().getLogicDeleteColumn() != null) { + MyWhereCriteria deleteFilter = new MyWhereCriteria(); + deleteFilter.setCriteria( + slaveTableName, + relation.getSlaveTable().getLogicDeleteColumn().getColumnName(), + relation.getSlaveTable().getLogicDeleteColumn().getObjectFieldType(), + MyWhereCriteria.OPERATOR_EQUAL, + GlobalDeletedFlag.NORMAL); + criteriaList.add(deleteFilter); + } + if (StrUtil.isNotBlank(virtualColumn.getWhereClauseJson())) { + List whereClauseList = + JSONArray.parseArray(virtualColumn.getWhereClauseJson(), VirtualColumnWhereClause.class); + if (CollUtil.isNotEmpty(whereClauseList)) { + for (VirtualColumnWhereClause whereClause : whereClauseList) { + MyWhereCriteria whereClauseFilter = new MyWhereCriteria(); + OnlineColumn c = relation.getSlaveTable().getColumnMap().get(whereClause.getColumnId()); + whereClauseFilter.setCriteria( + slaveTableName, + c.getColumnName(), + c.getObjectFieldType(), + whereClause.getOperatorType(), + whereClause.getValue()); + criteriaList.add(whereClauseFilter); + } + } + } + String criteriaString = MyWhereCriteria.makeCriteriaString(criteriaList); + List> aggregationMapList = + getGroupedListByCondition(masterTable.getDblinkId(), slaveTableName, selectList, criteriaString, groupBy); + this.doMakeAggregationData(resultList, aggregationMapList, masterColumnName, virtualColumn.getObjectFieldName()); + } + + private void doMakeAggregationData( + List> resultList, + List> aggregationMapList, + String masterColumnName, + String virtualColumnName) { + // 根据获取的分组聚合结果集,绑定到主表总的关联字段。 + if (CollUtil.isEmpty(aggregationMapList)) { + return; + } + Map relatedMap = new HashMap<>(aggregationMapList.size()); + for (Map map : aggregationMapList) { + relatedMap.put(map.get(KEY_NAME).toString(), map.get(VALUE_NAME)); + } + for (Map dataObject : resultList) { + String masterIdValue = dataObject.get(masterColumnName).toString(); + if (masterIdValue != null) { + Object value = relatedMap.get(masterIdValue); + if (value != null) { + dataObject.put(virtualColumnName, value); + } + } + } + } + + private Tuple2 makeSelectListAndGroupByClause( + String groupTableName, + String groupColumnName, + String aggregationTableName, + String aggregationColumnName, + Integer aggregationType) { + String aggregationFunc = AggregationType.getAggregationFunction(aggregationType); + // 构建Select List + // 如:r_table.master_id groupedKey, SUM(r_table.aggr_column) aggregated_value + StringBuilder groupedSelectList = new StringBuilder(128); + groupedSelectList.append(groupTableName) + .append(".") + .append(groupColumnName) + .append(" ") + .append(KEY_NAME) + .append(", ") + .append(aggregationFunc) + .append("(") + .append(aggregationTableName) + .append(".") + .append(aggregationColumnName) + .append(") ") + .append(VALUE_NAME) + .append(" "); + StringBuilder groupBy = new StringBuilder(64); + groupBy.append(groupTableName).append(".").append(groupColumnName); + return new Tuple2<>(groupedSelectList.toString(), groupBy.toString()); + } + + private void buildDataListWithDict(List> resultList, OnlineTable slaveTable) { + if (CollUtil.isEmpty(resultList)) { + return; + } + Set dictIdSet = new HashSet<>(); + // 先找主表字段对字典的依赖。 + Multimap dictColumnMap = LinkedHashMultimap.create(); + for (OnlineColumn column : slaveTable.getColumnMap().values()) { + if (column.getDictId() != null) { + dictIdSet.add(column.getDictId()); + column.setColumnAliasName(column.getColumnName()); + dictColumnMap.put(column.getDictId(), column); + } + } + this.doBuildDataListWithDict(resultList, dictIdSet, dictColumnMap); + } + + private void buildDataListWithDict( + List> resultList, + OnlineTable masterTable, + List relationList) { + if (CollUtil.isEmpty(resultList)) { + return; + } + Set dictIdSet = new HashSet<>(); + // 先找主表字段对字典的依赖。 + Multimap dictColumnMap = LinkedHashMultimap.create(); + for (OnlineColumn column : masterTable.getColumnMap().values()) { + if (column.getDictId() != null) { + dictIdSet.add(column.getDictId()); + column.setColumnAliasName(column.getColumnName()); + dictColumnMap.put(column.getDictId(), column); + } + } + // 再找关联表字段对字典的依赖。 + if (CollUtil.isEmpty(relationList)) { + this.doBuildDataListWithDict(resultList, dictIdSet, dictColumnMap); + return; + } + for (OnlineDatasourceRelation relation : relationList) { + for (OnlineColumn column : relation.getSlaveTable().getColumnMap().values()) { + if (column.getDictId() != null) { + dictIdSet.add(column.getDictId()); + String columnAliasName = relation.getVariableName() + + OnlineConstant.RELATION_TABLE_COLUMN_SEPARATOR + column.getColumnName(); + column.setColumnAliasName(columnAliasName); + dictColumnMap.put(column.getDictId(), column); + } + } + } + this.doBuildDataListWithDict(resultList, dictIdSet, dictColumnMap); + } + + private void doBuildDataListWithDict( + List> resultList, Set dictIdSet, Multimap dictColumnMap) { + if (CollUtil.isEmpty(dictIdSet)) { + return; + } + List allDictList = onlineDictService.getOnlineDictListFromCache(dictIdSet); + for (OnlineDict dict : allDictList) { + Collection columnList = dictColumnMap.get(dict.getDictId()); + for (OnlineColumn column : columnList) { + Set dictIdDataSet = this.extractColumnDictIds(resultList, column); + if (CollUtil.isNotEmpty(dictIdDataSet)) { + this.doBindColumnDictData(resultList, column, dict, dictIdDataSet); + } + } + } + } + + private Set extractColumnDictValues(List> dataList, OnlineColumn column) { + Set dictValueDataSet = new HashSet<>(); + for (Map data : dataList) { + String dictValueData = (String) data.get(column.getColumnAliasName()); + if (StrUtil.isNotBlank(dictValueData)) { + if (ObjectUtil.equals(column.getFieldKind(), FieldKind.DICT_MULTI_SELECT)) { + Set dictValueDataList = StrUtil.split(dictValueData, ",") + .stream().filter(StrUtil::isNotBlank).collect(Collectors.toSet()); + CollUtil.addAll(dictValueDataSet, dictValueDataList); + } else { + dictValueDataSet.add(dictValueData); + } + } + } + return dictValueDataSet; + } + + private Set extractColumnDictIds(List> resultList, OnlineColumn column) { + Set dictIdDataSet = new HashSet<>(); + for (Map result : resultList) { + Object dictIdData = result.get(column.getColumnAliasName()); + if (ObjectUtil.isEmpty(dictIdData)) { + continue; + } + if (ObjectUtil.equals(column.getFieldKind(), FieldKind.DICT_MULTI_SELECT)) { + Set dictIdDataList = StrUtil.split(dictIdData.toString(), ",") + .stream().filter(StrUtil::isNotBlank).collect(Collectors.toSet()); + if (ObjectFieldType.LONG.equals(column.getObjectFieldType())) { + dictIdDataList = dictIdDataSet.stream() + .map(c -> (Serializable) Long.valueOf(c.toString())).collect(Collectors.toSet()); + } + CollUtil.addAll(dictIdDataSet, dictIdDataList); + } else { + dictIdDataSet.add((Serializable) dictIdData); + } + } + return dictIdDataSet; + } + + private Map getGlobalDictItemDictMapFromCache(String dictCode, Set itemIds) { + return globalDictService.getGlobalDictItemDictMapFromCache(dictCode, itemIds); + } + + private void doTranslateColumnDictData( + List> dataList, + OnlineColumn column, + OnlineDict dict, + Set dictValueDataSet) { + Map dictResultMap = this.doTranslateColumnDictDataMap(dict, dictValueDataSet); + for (Map data : dataList) { + String dictValueData = (String) data.get(column.getColumnAliasName()); + if (StrUtil.isBlank(dictValueData)) { + continue; + } + if (ObjectUtil.equals(column.getFieldKind(), FieldKind.DICT_MULTI_SELECT)) { + List dictValueDataList = StrUtil.splitTrim(dictValueData, ","); + List dictIdList = dictValueDataList.stream() + .map(dictResultMap::get).filter(Objects::nonNull).collect(Collectors.toList()); + data.put(column.getColumnAliasName(), CollUtil.join(dictIdList, ",")); + } else { + Object dictId = dictResultMap.get(dictValueData); + if (dictId != null) { + data.put(column.getColumnAliasName(), dictId); + } + } + } + } + + private Map doTranslateColumnDictDataMap(OnlineDict dict, Set dictValueDataSet) { + Map dictResultMap = new HashMap<>(dictValueDataSet.size()); + if (dict.getDictType().equals(DictType.CUSTOM)) { + ConstDictInfo dictInfo = + JSONObject.parseObject(dict.getDictDataJson(), ConstDictInfo.class); + List dictDataList = dictInfo.getDictData(); + for (ConstDictInfo.ConstDictData dictData : dictDataList) { + dictResultMap.put(dictData.getName(), dictData.getId()); + } + } else if (dict.getDictType().equals(DictType.GLOBAL_DICT)) { + Map dictDataMap = + this.getGlobalDictItemDictMapFromCache(dict.getDictCode(), null); + dictDataMap.entrySet().stream() + .filter(entry -> dictValueDataSet.contains(entry.getValue())) + .forEach(entry -> dictResultMap.put(entry.getValue(), entry.getKey())); + } else if (dict.getDictType().equals(DictType.TABLE)) { + String selectFields = this.makeDictSelectFields(dict, true); + List filterList = this.createDefaultFilter(dict); + OnlineFilterDto inlistFilter = new OnlineFilterDto(); + inlistFilter.setTableName(dict.getTableName()); + inlistFilter.setColumnName(dict.getValueColumnName()); + inlistFilter.setColumnValueList(dictValueDataSet); + inlistFilter.setFilterType(FieldFilterType.IN_LIST_FILTER); + filterList.add(inlistFilter); + List> dictResultList = + this.getDictList(dict.getDblinkId(), dict.getTableName(), selectFields, filterList, null); + if (CollUtil.isNotEmpty(dictResultList)) { + for (Map dictResult : dictResultList) { + dictResultMap.put(dictResult.get("name").toString(), dictResult.get("id")); + } + } + } else if (dict.getDictType().equals(DictType.URL)) { + this.buildUrlDictDataMap(dict, dictResultMap, false); + } + return dictResultMap; + } + + private Map doBuildColumnDictDataMap(OnlineDict dict, Set dictIdDataSet) { + Map dictResultMap = new HashMap<>(dictIdDataSet.size()); + if (dict.getDictType().equals(DictType.CUSTOM)) { + ConstDictInfo dictInfo = + JSONObject.parseObject(dict.getDictDataJson(), ConstDictInfo.class); + List dictDataList = dictInfo.getDictData(); + for (ConstDictInfo.ConstDictData dictData : dictDataList) { + dictResultMap.put(dictData.getId().toString(), dictData.getName()); + } + } else if (dict.getDictType().equals(DictType.GLOBAL_DICT)) { + Map dictDataMap = + this.getGlobalDictItemDictMapFromCache(dict.getDictCode(), dictIdDataSet); + for (Map.Entry entry : dictDataMap.entrySet()) { + dictResultMap.put(entry.getKey().toString(), entry.getValue()); + } + } else if (dict.getDictType().equals(DictType.TABLE)) { + String selectFields = this.makeDictSelectFields(dict, true); + List filterList = this.createDefaultFilter(dict); + OnlineFilterDto inlistFilter = new OnlineFilterDto(); + inlistFilter.setTableName(dict.getTableName()); + inlistFilter.setColumnName(dict.getKeyColumnName()); + inlistFilter.setColumnValueList(dictIdDataSet); + inlistFilter.setFilterType(FieldFilterType.IN_LIST_FILTER); + filterList.add(inlistFilter); + List> dictResultList = + this.getDictList(dict.getDblinkId(), dict.getTableName(), selectFields, filterList, null); + if (CollUtil.isNotEmpty(dictResultList)) { + for (Map dictResult : dictResultList) { + dictResultMap.put(dictResult.get("id").toString(), dictResult.get("name")); + } + } + } else if (dict.getDictType().equals(DictType.URL)) { + this.buildUrlDictDataMap(dict, dictResultMap, true); + } + return dictResultMap; + } + + private List createDefaultFilter(OnlineDict dict) { + List filterList = new LinkedList<>(); + if (StrUtil.isNotBlank(dict.getDeletedColumnName())) { + OnlineFilterDto filter = new OnlineFilterDto(); + filter.setTableName(dict.getTableName()); + filter.setColumnName(dict.getDeletedColumnName()); + filter.setColumnValue(GlobalDeletedFlag.NORMAL); + filterList.add(filter); + } + return filterList; + } + + private void buildUrlDictDataMap(OnlineDict dict, Map dictResultMap, boolean keyToValue) { + Map param = new HashMap<>(1); + param.put("Authorization", TokenData.takeFromRequest().getToken()); + String responseData = HttpUtil.get(dict.getDictListUrl(), param); + ResponseResult responseResult = + JSON.parseObject(responseData, new TypeReference>() { + }); + if (!responseResult.isSuccess()) { + throw new OnlineRuntimeException(responseResult.getErrorMessage()); + } + JSONArray dictDataArray = responseResult.getData(); + for (int i = 0; i < dictDataArray.size(); i++) { + JSONObject dictData = dictDataArray.getJSONObject(i); + if (keyToValue) { + dictResultMap.put(dictData.getString(dict.getKeyColumnName()), dictData.get(dict.getValueColumnName())); + } else { + dictResultMap.put(dictData.getString(dict.getValueColumnName()), dictData.get(dict.getKeyColumnName())); + } + } + } + + private void doBindColumnDictData( + List> resultList, + OnlineColumn column, + OnlineDict dict, + Set dictIdDataSet) { + Map dictResultMap = this.doBuildColumnDictDataMap(dict, dictIdDataSet); + String dictKeyName; + if (ObjectUtil.equals(column.getFieldKind(), FieldKind.DICT_MULTI_SELECT)) { + dictKeyName = column.getColumnAliasName() + DICT_MAP_LIST_SUFFIX; + } else { + dictKeyName = column.getColumnAliasName() + DICT_MAP_SUFFIX; + } + for (Map result : resultList) { + Object dictIdData = result.get(column.getColumnAliasName()); + if (ObjectUtil.isEmpty(dictIdData)) { + continue; + } + if (ObjectUtil.equals(column.getFieldKind(), FieldKind.DICT_MULTI_SELECT)) { + List dictIdDataList = StrUtil.splitTrim(dictIdData.toString(), ","); + List> dictMapList = new LinkedList<>(); + for (String data : dictIdDataList) { + Object dictNameData = dictResultMap.get(data); + Map dictMap = new HashMap<>(2); + dictMap.put("id", data); + dictMap.put("name", dictNameData); + dictMapList.add(dictMap); + } + result.put(dictKeyName, dictMapList); + } else { + Object dictNameData = dictResultMap.get(dictIdData.toString()); + Map dictMap = new HashMap<>(2); + dictMap.put("id", dictIdData); + dictMap.put("name", dictNameData); + result.put(dictKeyName, dictMap); + } + } + } + + private List makeJoinInfoList( + OnlineTable masterTable, List relationList) { + List joinInfoList = new LinkedList<>(); + if (CollUtil.isEmpty(relationList)) { + return joinInfoList; + } + Map masterTableColumnMap = masterTable.getColumnMap(); + for (OnlineDatasourceRelation relation : relationList) { + JoinTableInfo joinInfo = new JoinTableInfo(); + joinInfo.setLeftJoin(relation.getLeftJoin()); + joinInfo.setJoinTableName(relation.getSlaveTable().getTableName() + " " + relation.getVariableName()); + // 根据配置动态拼接JOIN的关联条件,同时要考虑从表的逻辑删除过滤。 + OnlineColumn masterColumn = masterTableColumnMap.get(relation.getMasterColumnId()); + OnlineColumn slaveColumn = relation.getSlaveTable().getColumnMap().get(relation.getSlaveColumnId()); + StringBuilder conditionBuilder = new StringBuilder(64); + conditionBuilder + .append(masterTable.getTableName()) + .append(".") + .append(masterColumn.getColumnName()) + .append(" = ") + .append(relation.getVariableName()) + .append(".") + .append(slaveColumn.getColumnName()); + if (relation.getSlaveTable().getLogicDeleteColumn() != null) { + conditionBuilder + .append(AND) + .append(relation.getVariableName()) + .append(".") + .append(relation.getSlaveTable().getLogicDeleteColumn().getColumnName()) + .append(" = ") + .append(GlobalDeletedFlag.NORMAL); + } + joinInfo.setJoinCondition(conditionBuilder.toString()); + joinInfoList.add(joinInfo); + } + return joinInfoList; + } + + private String makeSelectFields(OnlineTable table, String relationVariable) { + DataSourceProvider provider = dataSourceUtil.getProvider(table.getDblinkId()); + StringBuilder selectFieldBuider = new StringBuilder(512); + String intString = "SIGNED"; + if (provider.getDblinkType() == DblinkType.POSTGRESQL|| provider.getDblinkType() == DblinkType.OPENGAUSS) { + intString = "INT8"; + } + // 拼装主表的select fields字段。 + for (OnlineColumn column : table.getColumnMap().values()) { + OnlineColumn deletedColumn = table.getLogicDeleteColumn(); + String columnAliasName = column.getColumnName(); + if (relationVariable != null) { + columnAliasName = relationVariable + + OnlineConstant.RELATION_TABLE_COLUMN_SEPARATOR + column.getColumnName(); + } + if (deletedColumn != null && StrUtil.equals(column.getColumnName(), deletedColumn.getColumnName())) { + continue; + } + if (this.castToInteger(column)) { + selectFieldBuider + .append("CAST(") + .append(table.getTableName()) + .append(".") + .append(column.getColumnName()) + .append(" AS ") + .append(intString) + .append(") \"") + .append(columnAliasName) + .append("\","); + } else if ("date".equals(column.getColumnType())) { + selectFieldBuider + .append("CAST(") + .append(table.getTableName()) + .append(".") + .append(column.getColumnName()) + .append(" AS CHAR(10)) \"") + .append(columnAliasName) + .append("\","); + } else { + selectFieldBuider + .append(table.getTableName()) + .append(".") + .append(column.getColumnName()) + .append(" \"") + .append(columnAliasName) + .append("\","); + } + } + return selectFieldBuider.substring(0, selectFieldBuider.length() - 1); + } + + private String makeSelectFieldsWithRelation( + OnlineTable masterTable, List relationList) { + String masterTableSelectFields = this.makeSelectFields(masterTable, null); + if (CollUtil.isEmpty(relationList)) { + return masterTableSelectFields; + } + StringBuilder selectFieldBuider = new StringBuilder(512); + selectFieldBuider.append(masterTableSelectFields).append(","); + for (OnlineDatasourceRelation relation : relationList) { + OnlineTable slaveTable = relation.getSlaveTable(); + String relationTableSelectFields = this.makeSelectFields(slaveTable, relation.getVariableName()); + selectFieldBuider.append(relationTableSelectFields).append(","); + } + return selectFieldBuider.substring(0, selectFieldBuider.length() - 1); + } + + private String makeDictSelectFields(OnlineDict onlineDict, boolean ignoreParentId) { + StringBuilder sb = new StringBuilder(128); + sb.append(onlineDict.getKeyColumnName()).append(" \"id\", "); + sb.append(onlineDict.getValueColumnName()).append(" \"name\""); + if (!ignoreParentId && BooleanUtil.isTrue(onlineDict.getTreeFlag())) { + sb.append(", ").append(onlineDict.getParentKeyColumnName()).append(" \"parentId\""); + } + return sb.toString(); + } + + private boolean castToInteger(OnlineColumn column) { + return "tinyint(1)".equals(column.getFullColumnType()); + } + + private String makeColumnNames(List columnDataList) { + StringBuilder sb = new StringBuilder(512); + for (ColumnData columnData : columnDataList) { + if (BooleanUtil.isTrue(columnData.getColumn().getAutoIncrement())) { + continue; + } + sb.append(columnData.getColumn().getColumnName()).append(","); + } + return sb.substring(0, sb.length() - 1); + } + + private void makeupColumnValue(ColumnData columnData) { + if (BooleanUtil.isTrue(columnData.getColumn().getAutoIncrement())) { + return; + } + if (BooleanUtil.isTrue(columnData.getColumn().getPrimaryKey())) { + if (columnData.getColumnValue() == null + && BooleanUtil.isFalse(columnData.getColumn().getAutoIncrement())) { + if (ObjectFieldType.LONG.equals(columnData.getColumn().getObjectFieldType())) { + columnData.setColumnValue(idGenerator.nextLongId()); + } else { + columnData.setColumnValue(idGenerator.nextStringId()); + } + } + } else if (columnData.getColumn().getFieldKind() != null) { + this.makeupColumnValueForFieldKind(columnData); + } else if (columnData.getColumn().getColumnDefault() != null + && columnData.getColumnValue() == null) { + Object v = onlineOperationHelper.convertToTypeValue( + columnData.getColumn(), columnData.getColumn().getColumnDefault()); + columnData.setColumnValue(v); + } + } + + private void makeupColumnValueForFieldKind(ColumnData columnData) { + switch (columnData.getColumn().getFieldKind()) { + case FieldKind.CREATE_TIME: + case FieldKind.UPDATE_TIME: + columnData.setColumnValue(LocalDateTime.now()); + break; + case FieldKind.CREATE_USER_ID: + case FieldKind.UPDATE_USER_ID: + columnData.setColumnValue(TokenData.takeFromRequest().getUserId()); + break; + case FieldKind.CREATE_DEPT_ID: + columnData.setColumnValue(TokenData.takeFromRequest().getDeptId()); + break; + case FieldKind.LOGIC_DELETE: + columnData.setColumnValue(GlobalDeletedFlag.NORMAL); + break; + default: + break; + } + } + + private List makeDefaultFilter(OnlineTable table, OnlineColumn column, String columnValue) { + List filterList = new LinkedList<>(); + OnlineFilterDto dataIdFilter = new OnlineFilterDto(); + dataIdFilter.setTableName(table.getTableName()); + dataIdFilter.setColumnName(column.getColumnName()); + dataIdFilter.setColumnValue(onlineOperationHelper.convertToTypeValue(column, columnValue)); + filterList.add(dataIdFilter); + if (table.getLogicDeleteColumn() != null) { + OnlineFilterDto filter = new OnlineFilterDto(); + filter.setTableName(table.getTableName()); + filter.setColumnName(table.getLogicDeleteColumn().getColumnName()); + filter.setColumnValue(GlobalDeletedFlag.NORMAL); + filterList.add(filter); + } + return filterList; + } + + private void doLogicDelete( + OnlineTable table, List filterList, String dataPermFilter) { + List updateColumnList = new LinkedList<>(); + ColumnData logicDeleteColumnData = new ColumnData(); + logicDeleteColumnData.setColumn(table.getLogicDeleteColumn()); + logicDeleteColumnData.setColumnValue(GlobalDeletedFlag.DELETED); + updateColumnList.add(logicDeleteColumnData); + this.doUpdate(table, updateColumnList, filterList, dataPermFilter); + } + + private void doLogicDelete( + OnlineTable table, OnlineColumn filterColumn, String filterColumnValue, String dataPermFilter) { + List filterList = new LinkedList<>(); + OnlineFilterDto filter = new OnlineFilterDto(); + filter.setTableName(table.getTableName()); + filter.setColumnName(filterColumn.getColumnName()); + filter.setColumnValue(onlineOperationHelper.convertToTypeValue(filterColumn, filterColumnValue)); + filterList.add(filter); + this.doLogicDelete(table, filterList, dataPermFilter); + } + + private void normalizeFilterList( + OnlineTable table, List oneToOneRelationList, List filterList) { + if (table.getLogicDeleteColumn() != null) { + if (filterList == null) { + filterList = new LinkedList<>(); + } + OnlineFilterDto filter = new OnlineFilterDto(); + filter.setTableName(table.getTableName()); + filter.setColumnName(table.getLogicDeleteColumn().getColumnName()); + filter.setColumnValue(GlobalDeletedFlag.NORMAL); + filterList.add(filter); + } + if (CollUtil.isEmpty(filterList)) { + return; + } + OnlineDblink dblink = onlineDblinkService.getById(table.getDblinkId()); + for (OnlineFilterDto filter : filterList) { + // oracle 日期字段的,后面要重写这段代码,以便具有更好的通用性。 + if (filter.getFilterType().equals(FieldFilterType.RANGE_FILTER)) { + this.makeRangeFilter(dblink, table, oneToOneRelationList, filter); + } + if (BooleanUtil.isTrue(filter.getDictMultiSelect())) { + filter.setFilterType(FieldFilterType.MULTI_LIKE); + List dictValueSet = StrUtil.split(filter.getColumnValue().toString(), ","); + filter.setColumnValueList( + dictValueSet.stream().map(v -> "%" + v + ",%").collect(Collectors.toSet())); + } + if (filter.getFilterType().equals(FieldFilterType.LIKE_FILTER)) { + filter.setColumnValue("%" + filter.getColumnValue() + "%"); + } else if (filter.getFilterType().equals(FieldFilterType.IN_LIST_FILTER) + && ObjectUtil.isNotEmpty(filter.getColumnValue())) { + filter.setColumnValueList( + new HashSet<>(StrUtil.split(filter.getColumnValue().toString(), ","))); + } + } + } + + private String normalizeSlaveTableAlias(List relationList, String s) { + if (CollUtil.isEmpty(relationList) || StrUtil.isBlank(s)) { + return s; + } + for (OnlineDatasourceRelation r : relationList) { + s = StrUtil.replace(s, r.getSlaveTable().getTableName() + ".", r.getVariableName() + "."); + } + return s; + } + + private void normalizeFiltersSlaveTableAlias( + List relationList, List filters) { + if (CollUtil.isEmpty(relationList) || CollUtil.isEmpty(filters)) { + return; + } + for (OnlineDatasourceRelation r : relationList) { + for (OnlineFilterDto filter : filters) { + if (StrUtil.equals(filter.getTableName(), r.getSlaveTable().getTableName())) { + filter.setTableName(r.getVariableName()); + } + } + } + } + + private void makeRangeFilter( + OnlineDblink dblink, + OnlineTable table, + List oneToOneRelationList, + OnlineFilterDto filter) { + if (!dblink.getDblinkType().equals(DblinkType.ORACLE)) { + return; + } + OnlineColumn column = table.getColumnMap().values().stream() + .filter(c -> c.getColumnName().equals(filter.getColumnName())).findFirst().orElse(null); + if (column == null && oneToOneRelationList != null) { + for (OnlineDatasourceRelation r : oneToOneRelationList) { + column = r.getSlaveTable().getColumnMap().values().stream() + .filter(c -> c.getColumnName().equals(filter.getColumnName())).findFirst().orElse(null); + if (column != null) { + break; + } + } + } + org.springframework.util.Assert.notNull(column, "column can't be NULL."); + filter.setIsOracleDate(StrUtil.equals(column.getObjectFieldType(), "Date")); + if (BooleanUtil.isTrue(filter.getIsOracleDate())) { + if (filter.getColumnValueStart() != null) { + filter.setColumnValueStart("TO_DATE('" + filter.getColumnValueStart() + "','YYYY-MM-DD HH24:MI:SS')"); + } + if (filter.getColumnValueEnd() != null) { + filter.setColumnValueEnd("TO_DATE('" + filter.getColumnValueEnd() + "','YYYY-MM-DD HH24:MI:SS')"); + } + } + } + + private String buildDataPermFilter(String tableName, String deptFilterColumnName, String userFilterColumnName) { + if (BooleanUtil.isFalse(dataFilterProperties.getEnabledDataPermFilter())) { + return null; + } + if (!GlobalThreadLocal.enabledDataFilter()) { + return null; + } + return processDataPerm(tableName, deptFilterColumnName, userFilterColumnName); + } + + private String buildDataPermFilter(OnlineTable table) { + if (BooleanUtil.isFalse(dataFilterProperties.getEnabledDataPermFilter())) { + return null; + } + if (!GlobalThreadLocal.enabledDataFilter()) { + return null; + } + String deptFilterColumnName = null; + String userFilterColumnName = null; + for (OnlineColumn column : table.getColumnMap().values()) { + if (BooleanUtil.isTrue(column.getDeptFilter())) { + deptFilterColumnName = column.getColumnName(); + } + if (BooleanUtil.isTrue(column.getUserFilter())) { + userFilterColumnName = column.getColumnName(); + } + } + return processDataPerm(table.getTableName(), deptFilterColumnName, userFilterColumnName); + } + + private String processDataPerm(String tableName, String deptFilterColumnName, String userFilterColumnName) { + TokenData tokenData = TokenData.takeFromRequest(); + if (Boolean.TRUE.equals(tokenData.getIsAdmin())) { + return null; + } + if (StrUtil.isAllBlank(deptFilterColumnName, userFilterColumnName)) { + return null; + } + String dataPermSessionKey = RedisKeyUtil.makeSessionDataPermIdKey(tokenData.getSessionId()); + Object cachedData = this.getCachedData(dataPermSessionKey); + if (cachedData == null) { + throw new NoDataPermException("No Related DataPerm found For OnlineForm Module."); + } + JSONObject allMenuDataPermMap = cachedData instanceof JSONObject + ? (JSONObject) cachedData : JSON.parseObject(cachedData.toString()); + JSONObject menuDataPermMap = this.getAndVerifyMenuDataPerm(allMenuDataPermMap, tableName); + Map dataPermMap = new HashMap<>(8); + for (Map.Entry entry : menuDataPermMap.entrySet()) { + dataPermMap.put(Integer.valueOf(entry.getKey()), entry.getValue().toString()); + } + if (MapUtil.isEmpty(dataPermMap)) { + throw new NoDataPermException(StrFormatter.format( + "No Related OnlineForm DataPerm found for table [{}].", tableName)); + } + if (dataPermMap.containsKey(DataPermRuleType.TYPE_ALL)) { + return null; + } + return doProcessDataPerm(tableName, deptFilterColumnName, userFilterColumnName, dataPermMap); + } + + private JSONObject getAndVerifyMenuDataPerm(JSONObject allMenuDataPermMap, String tableName) { + String menuId = ContextUtil.getHttpRequest().getHeader(ApplicationConstant.HTTP_HEADER_MENU_ID); + if (menuId == null) { + menuId = ContextUtil.getHttpRequest().getParameter(ApplicationConstant.HTTP_HEADER_MENU_ID); + } + if (BooleanUtil.isFalse(dataFilterProperties.getEnableMenuPermVerify()) && menuId == null) { + menuId = ApplicationConstant.DATA_PERM_ALL_MENU_ID; + } + Assert.notNull(menuId); + JSONObject menuDataPermMap = allMenuDataPermMap.getJSONObject(menuId); + if (menuDataPermMap == null) { + menuDataPermMap = allMenuDataPermMap.getJSONObject(ApplicationConstant.DATA_PERM_ALL_MENU_ID); + } + if (menuDataPermMap == null) { + throw new NoDataPermException(StrFormatter.format( + "No Related OnlineForm DataPerm found for menuId [{}] and table [{}].", + menuId, tableName)); + } + if (BooleanUtil.isTrue(dataFilterProperties.getEnableMenuPermVerify())) { + String url = ContextUtil.getHttpRequest().getHeader(ApplicationConstant.HTTP_HEADER_ORIGINAL_REQUEST_URL); + if (StrUtil.isBlank(url)) { + url = ContextUtil.getHttpRequest().getRequestURI(); + } + Assert.notNull(url); + if (!this.verifyMenuPerm(null, url, tableName) && !this.verifyMenuPerm(menuId, url, tableName)) { + String msg = StrFormatter.format("Mismatched OnlineForm DataPerm " + + "for menuId [{}] and url [{}] and SQL_ID [{}].", menuId, url, tableName); + throw new NoDataPermException(msg); + } + } + return menuDataPermMap; + } + + private Object getCachedData(String dataPermSessionKey) { + Object cachedData = null; + Cache cache = cacheManager.getCache(CacheConfig.CacheEnum.DATA_PERMISSION_CACHE.name()); + if (cache == null) { + return cachedData; + } + Cache.ValueWrapper wrapper = cache.get(dataPermSessionKey); + if (wrapper == null) { + cachedData = redissonClient.getBucket(dataPermSessionKey).get(); + if (cachedData != null) { + cache.put(dataPermSessionKey, JSON.parseObject(cachedData.toString())); + } + } else { + cachedData = wrapper.get(); + } + return cachedData; + } + + @SuppressWarnings("unchecked") + private boolean verifyMenuPerm(String menuId, String url, String tableName) { + String sessionId = TokenData.takeFromRequest().getSessionId(); + String menuPermSessionKey; + if (menuId != null) { + menuPermSessionKey = RedisKeyUtil.makeSessionMenuPermKey(sessionId, menuId); + } else { + menuPermSessionKey = RedisKeyUtil.makeSessionWhiteListPermKey(sessionId); + } + Cache cache = cacheManager.getCache(CacheConfig.CacheEnum.MENU_PERM_CACHE.name()); + if (cache == null) { + return false; + } + Cache.ValueWrapper wrapper = cache.get(menuPermSessionKey); + if (wrapper != null) { + Object cacheData = wrapper.get(); + if (cacheData != null) { + return ((Set) cacheData).contains(url); + } + } + RBucket bucket = redissonClient.getBucket(menuPermSessionKey); + if (!bucket.isExists()) { + String msg; + if (menuId == null) { + msg = StrFormatter.format("No Related MenuPerm found " + + "in Redis Cache for WHITE_LIST and tableName [{}] with sessionId [{}].", tableName, sessionId); + } else { + msg = StrFormatter.format("No Related MenuPerm found " + + "in Redis Cache for menuId [{}] and tableName[{}] with sessionId [{}].", menuId, tableName, sessionId); + } + throw new NoDataPermException(msg); + } + Set cachedMenuPermSet = new HashSet<>(JSONArray.parseArray(bucket.get(), String.class)); + cache.put(menuPermSessionKey, cachedMenuPermSet); + return cachedMenuPermSet.contains(url); + } + + private String doProcessDataPerm( + String tableName, String deptFilterColumnName, String userFilterColumnName, Map dataPermMap) { + List criteriaList = new LinkedList<>(); + for (Map.Entry entry : dataPermMap.entrySet()) { + String filterClause = processDataPermRule( + tableName, deptFilterColumnName, userFilterColumnName, entry.getKey(), entry.getValue()); + if (StrUtil.isNotBlank(filterClause)) { + criteriaList.add(filterClause); + } + } + if (CollUtil.isEmpty(criteriaList)) { + return null; + } + StringBuilder filterBuilder = new StringBuilder(128); + filterBuilder.append("("); + filterBuilder.append(CollUtil.join(criteriaList, " OR ")); + filterBuilder.append(")"); + return filterBuilder.toString(); + } + + private String processDataPermRule( + String tableName, String deptFilterColumnName, String userFilterColumnName, Integer ruleType, String dataIds) { + TokenData tokenData = TokenData.takeFromRequest(); + StringBuilder filter = new StringBuilder(128); + if (ruleType != DataPermRuleType.TYPE_USER_ONLY + && ruleType != DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT_USERS + && ruleType != DataPermRuleType.TYPE_DEPT_USERS) { + return this.processDeptDataPermRule(tableName, deptFilterColumnName, ruleType, dataIds); + } + if (StrUtil.isBlank(userFilterColumnName)) { + log.warn("No UserFilterColumn for ONLINE table [{}] but USER_FILTER_DATA_PERM exists", tableName); + return filter.toString(); + } + if (BooleanUtil.isTrue(dataFilterProperties.getAddTableNamePrefix())) { + filter.append(tableName).append("."); + } + if (ruleType == DataPermRuleType.TYPE_USER_ONLY) { + filter.append(userFilterColumnName).append(" = ").append(tokenData.getUserId()); + } else { + filter.append(userFilterColumnName) + .append(" IN (") + .append(dataIds) + .append(") "); + } + return filter.toString(); + } + + private String processDeptDataPermRule( + String tableName, String deptFilterColumnName, Integer ruleType, String deptIds) { + TokenData tokenData = TokenData.takeFromRequest(); + StringBuilder filter = new StringBuilder(256); + if (StrUtil.isBlank(deptFilterColumnName)) { + log.warn("No DeptFilterColumn for ONLINE table [{}] but DEPT_FILTER_DATA_PERM exists", tableName); + return filter.toString(); + } + if (ruleType == DataPermRuleType.TYPE_DEPT_ONLY) { + if (BooleanUtil.isTrue(dataFilterProperties.getAddTableNamePrefix())) { + filter.append(tableName).append("."); + } + filter.append(deptFilterColumnName).append(" = ").append(tokenData.getDeptId()); + } else if (ruleType == DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT) { + filter.append(" EXISTS ") + .append("(SELECT 1 FROM ") + .append(dataFilterProperties.getDeptRelationTablePrefix()) + .append("sys_dept_relation WHERE ") + .append(dataFilterProperties.getDeptRelationTablePrefix()) + .append("sys_dept_relation.parent_dept_id = ") + .append(tokenData.getDeptId()) + .append(AND); + if (BooleanUtil.isTrue(dataFilterProperties.getAddTableNamePrefix())) { + filter.append(tableName).append("."); + } + filter.append(deptFilterColumnName) + .append(" = ") + .append(dataFilterProperties.getDeptRelationTablePrefix()) + .append("sys_dept_relation.dept_id) "); + } else if (ruleType == DataPermRuleType.TYPE_MULTI_DEPT_AND_CHILD_DEPT) { + filter.append(" EXISTS ") + .append("(SELECT 1 FROM ") + .append(dataFilterProperties.getDeptRelationTablePrefix()) + .append("sys_dept_relation WHERE ") + .append(dataFilterProperties.getDeptRelationTablePrefix()) + .append("sys_dept_relation.parent_dept_id IN (") + .append(deptIds) + .append(") AND "); + if (BooleanUtil.isTrue(dataFilterProperties.getAddTableNamePrefix())) { + filter.append(tableName).append("."); + } + filter.append(deptFilterColumnName) + .append(" = ") + .append(dataFilterProperties.getDeptRelationTablePrefix()) + .append("sys_dept_relation.dept_id) "); + } else if (ruleType == DataPermRuleType.TYPE_CUSTOM_DEPT_LIST) { + if (BooleanUtil.isTrue(dataFilterProperties.getAddTableNamePrefix())) { + filter.append(tableName).append("."); + } + filter.append(deptFilterColumnName).append(" IN (").append(deptIds).append(") "); + } + return filter.toString(); + } + + @Data + private static class VirtualColumnWhereClause { + private Long tableId; + private Long columnId; + private Integer operatorType; + private Object value; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlinePageServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlinePageServiceImpl.java new file mode 100644 index 00000000..f130bf17 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlinePageServiceImpl.java @@ -0,0 +1,299 @@ +package com.orangeforms.common.online.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.online.dao.OnlinePageDatasourceMapper; +import com.orangeforms.common.online.dao.OnlinePageMapper; +import com.orangeforms.common.online.model.OnlinePage; +import com.orangeforms.common.online.model.OnlinePageDatasource; +import com.orangeforms.common.online.model.constant.PageStatus; +import com.orangeforms.common.online.service.OnlineDatasourceService; +import com.orangeforms.common.online.service.OnlineFormService; +import com.orangeforms.common.online.service.OnlinePageService; +import com.github.pagehelper.Page; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.LinkedList; +import java.util.List; + +/** + * 在线表单页面数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("onlinePageService") +public class OnlinePageServiceImpl extends BaseService implements OnlinePageService { + + @Autowired + private OnlinePageMapper onlinePageMapper; + @Autowired + private OnlinePageDatasourceMapper onlinePageDatasourceMapper; + @Autowired + private OnlineFormService onlineFormService; + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return onlinePageMapper; + } + + /** + * 保存新增对象。 + * + * @param onlinePage 新增对象。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public OnlinePage saveNew(OnlinePage onlinePage) { + TokenData tokenData = TokenData.takeFromRequest(); + onlinePage.setPageId(idGenerator.nextLongId()); + onlinePage.setAppCode(tokenData.getAppCode()); + onlinePage.setTenantId(tokenData.getTenantId()); + Date now = new Date(); + onlinePage.setUpdateTime(now); + onlinePage.setCreateTime(now); + onlinePage.setCreateUserId(tokenData.getUserId()); + onlinePage.setUpdateUserId(tokenData.getUserId()); + onlinePage.setPublished(false); + MyModelUtil.setDefaultValue(onlinePage, "status", PageStatus.BASIC); + onlinePageMapper.insert(onlinePage); + return onlinePage; + } + + /** + * 更新数据对象。 + * + * @param onlinePage 更新的对象。 + * @param originalOnlinePage 原有数据对象。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(OnlinePage onlinePage, OnlinePage originalOnlinePage) { + TokenData tokenData = TokenData.takeFromRequest(); + onlinePage.setAppCode(tokenData.getAppCode()); + onlinePage.setTenantId(tokenData.getTenantId()); + onlinePage.setUpdateTime(new Date()); + onlinePage.setUpdateUserId(tokenData.getUserId()); + onlinePage.setCreateTime(originalOnlinePage.getCreateTime()); + onlinePage.setCreateUserId(originalOnlinePage.getCreateUserId()); + onlinePage.setPublished(originalOnlinePage.getPublished()); + // 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。 + UpdateWrapper uw = this.createUpdateQueryForNullValue(onlinePage, onlinePage.getPageId()); + return onlinePageMapper.update(onlinePage, uw) == 1; + } + + /** + * 更新页面对象的发布状态。 + * + * @param pageId 页面对象Id。 + * @param published 新的状态。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void updatePublished(Long pageId, Boolean published) { + OnlinePage onlinePage = new OnlinePage(); + onlinePage.setPageId(pageId); + onlinePage.setPublished(published); + onlinePage.setUpdateTime(new Date()); + onlinePage.setUpdateUserId(TokenData.takeFromRequest().getUserId()); + onlinePageMapper.updateById(onlinePage); + } + + /** + * 删除指定数据,及其包含的表单和数据源等。 + * + * @param pageId 主键Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long pageId) { + if (onlinePageMapper.deleteById(pageId) == 0) { + return false; + } + // 开始删除关联表单。 + onlineFormService.removeByPageId(pageId); + // 先获取出关联的表单和数据源。 + OnlinePageDatasource pageDatasourceFilter = new OnlinePageDatasource(); + pageDatasourceFilter.setPageId(pageId); + List pageDatasourceList = + onlinePageDatasourceMapper.selectList(new QueryWrapper<>(pageDatasourceFilter)); + if (CollUtil.isNotEmpty(pageDatasourceList)) { + for (OnlinePageDatasource pageDatasource : pageDatasourceList) { + onlineDatasourceService.remove(pageDatasource.getDatasourceId()); + } + } + return true; + } + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlinePageListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlinePageList(OnlinePage filter, String orderBy) { + if (filter == null) { + filter = new OnlinePage(); + } + TokenData tokenData = TokenData.takeFromRequest(); + filter.setTenantId(tokenData.getTenantId()); + filter.setAppCode(tokenData.getAppCode()); + return onlinePageMapper.getOnlinePageList(filter, orderBy); + } + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlinePageList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlinePageListWithRelation(OnlinePage filter, String orderBy) { + List resultList = this.getOnlinePageList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + /** + * 批量添加多对多关联关系。 + * + * @param onlinePageDatasourceList 多对多关联表对象集合。 + * @param pageId 主表Id。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void addOnlinePageDatasourceList(List onlinePageDatasourceList, Long pageId) { + for (OnlinePageDatasource onlinePageDatasource : onlinePageDatasourceList) { + onlinePageDatasource.setPageId(pageId); + onlinePageDatasourceMapper.insert(onlinePageDatasource); + } + } + + /** + * 获取中间表数据。 + * + * @param pageId 主表Id。 + * @param datasourceId 从表Id。 + * @return 中间表对象。 + */ + @Override + public OnlinePageDatasource getOnlinePageDatasource(Long pageId, Long datasourceId) { + OnlinePageDatasource filter = new OnlinePageDatasource(); + filter.setPageId(pageId); + filter.setDatasourceId(datasourceId); + return onlinePageDatasourceMapper.selectOne(new QueryWrapper<>(filter)); + } + + @Override + public List getOnlinePageDatasourceListByPageId(Long pageId) { + OnlinePageDatasource filter = new OnlinePageDatasource(); + filter.setPageId(pageId); + return onlinePageDatasourceMapper.selectList(new QueryWrapper<>(filter)); + } + + /** + * 根据数据源Id,返回使用该数据源的OnlinePage对象。 + * + * @param datasourceId 数据源Id。 + * @return 使用该数据源的页面列表。 + */ + @Override + public List getOnlinePageListByDatasourceId(Long datasourceId) { + OnlinePage filter = new OnlinePage(); + TokenData tokenData = TokenData.takeFromRequest(); + filter.setTenantId(tokenData.getTenantId()); + filter.setAppCode(tokenData.getAppCode()); + return onlinePageMapper.getOnlinePageListByDatasourceId(datasourceId, filter); + } + + /** + * 移除单条多对多关系。 + * + * @param pageId 主表Id。 + * @param datasourceId 从表Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean removeOnlinePageDatasource(Long pageId, Long datasourceId) { + OnlinePageDatasource filter = new OnlinePageDatasource(); + filter.setPageId(pageId); + filter.setDatasourceId(datasourceId); + return onlinePageDatasourceMapper.delete(new QueryWrapper<>(filter)) > 0; + } + + @Override + public boolean existByPageCode(String pageCode) { + OnlinePage filter = new OnlinePage(); + filter.setPageCode(pageCode); + return CollUtil.isNotEmpty(this.getOnlinePageList(filter, null)); + } + + @Override + public List getNotInListWithNonTenant(List pageIds, String orderBy) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + if (CollUtil.isNotEmpty(pageIds)) { + queryWrapper.notIn(OnlinePage::getPageId, pageIds); + } + queryWrapper.isNull(OnlinePage::getTenantId); + if (StrUtil.isNotBlank(orderBy)) { + queryWrapper.last(" ORDER BY " + orderBy); + } + return onlinePageMapper.selectList(queryWrapper); + } + + @Override + public List getInListWithNonTenant(List pageIds, String orderBy) { + if (CollUtil.isEmpty(pageIds)) { + return new LinkedList<>(); + } + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.in(OnlinePage::getPageId, pageIds); + queryWrapper.isNull(OnlinePage::getTenantId); + if (StrUtil.isNotBlank(orderBy)) { + queryWrapper.last(" ORDER BY " + orderBy); + } + return onlinePageMapper.selectList(queryWrapper); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineRuleServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineRuleServiceImpl.java new file mode 100644 index 00000000..64df1a31 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineRuleServiceImpl.java @@ -0,0 +1,248 @@ +package com.orangeforms.common.online.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.alibaba.fastjson.JSONArray; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.constant.GlobalDeletedFlag; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.MyModelUtil; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.redis.util.CommonRedisUtil; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.online.dao.OnlineColumnRuleMapper; +import com.orangeforms.common.online.dao.OnlineRuleMapper; +import com.orangeforms.common.online.model.OnlineColumnRule; +import com.orangeforms.common.online.model.OnlineRule; +import com.orangeforms.common.online.service.OnlineRuleService; +import com.github.pagehelper.Page; +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.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 验证规则数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("onlineRuleService") +public class OnlineRuleServiceImpl extends BaseService implements OnlineRuleService { + + @Autowired + private OnlineRuleMapper onlineRuleMapper; + @Autowired + private OnlineColumnRuleMapper onlineColumnRuleMapper; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private CommonRedisUtil commonRedisUtil; + @Autowired + private RedissonClient redissonClient; + + /** + * 所有字段规则使用同一个键。 + */ + private static final String ONLINE_RULE_CACHE_KEY = "ONLINE_RULE"; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return onlineRuleMapper; + } + + /** + * 保存新增对象。 + * + * @param onlineRule 新增对象。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public OnlineRule saveNew(OnlineRule onlineRule) { + commonRedisUtil.evictFormCache(ONLINE_RULE_CACHE_KEY); + TokenData tokenData = TokenData.takeFromRequest(); + onlineRule.setRuleId(idGenerator.nextLongId()); + onlineRule.setAppCode(tokenData.getAppCode()); + Date now = new Date(); + onlineRule.setUpdateTime(now); + onlineRule.setCreateTime(now); + onlineRule.setCreateUserId(tokenData.getUserId()); + onlineRule.setUpdateUserId(tokenData.getUserId()); + onlineRule.setBuiltin(false); + onlineRule.setDeletedFlag(GlobalDeletedFlag.NORMAL); + MyModelUtil.setDefaultValue(onlineRule, "pattern", ""); + onlineRuleMapper.insert(onlineRule); + return onlineRule; + } + + /** + * 更新数据对象。 + * + * @param onlineRule 更新的对象。 + * @param originalOnlineRule 原有数据对象。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(OnlineRule onlineRule, OnlineRule originalOnlineRule) { + commonRedisUtil.evictFormCache(ONLINE_RULE_CACHE_KEY); + TokenData tokenData = TokenData.takeFromRequest(); + onlineRule.setAppCode(tokenData.getAppCode()); + onlineRule.setUpdateTime(new Date()); + onlineRule.setUpdateUserId(tokenData.getUserId()); + onlineRule.setCreateTime(originalOnlineRule.getCreateTime()); + onlineRule.setCreateUserId(originalOnlineRule.getCreateUserId()); + UpdateWrapper uw = this.createUpdateQueryForNullValue(onlineRule, onlineRule.getRuleId()); + return onlineRuleMapper.update(onlineRule, uw) == 1; + } + + /** + * 删除指定数据。 + * + * @param ruleId 主键Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long ruleId) { + commonRedisUtil.evictFormCache(ONLINE_RULE_CACHE_KEY); + if (onlineRuleMapper.deleteById(ruleId) == 0) { + return false; + } + // 开始删除多对多父表的关联 + OnlineColumnRule onlineColumnRule = new OnlineColumnRule(); + onlineColumnRule.setRuleId(ruleId); + onlineColumnRuleMapper.delete(new QueryWrapper<>(onlineColumnRule)); + return true; + } + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineRuleListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineRuleList(OnlineRule filter, String orderBy) { + if (filter == null) { + filter = new OnlineRule(); + } + filter.setAppCode(TokenData.takeFromRequest().getAppCode()); + return onlineRuleMapper.getOnlineRuleList(filter, orderBy); + } + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineRuleList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineRuleListWithRelation(OnlineRule filter, String orderBy) { + List resultList = this.getOnlineRuleList(filter, orderBy); + // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 + // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + /** + * 在多对多关系中,当前Service的数据表为从表,返回不与指定主表主键Id存在对多对关系的列表。 + * + * @param columnId 主表主键Id。 + * @param filter 从表的过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getNotInOnlineRuleListByColumnId(Long columnId, OnlineRule filter, String orderBy) { + if (filter == null) { + filter = new OnlineRule(); + } + filter.setAppCode(TokenData.takeFromRequest().getAppCode()); + List resultList = + onlineRuleMapper.getNotInOnlineRuleListByColumnId(columnId, filter, orderBy); + this.buildRelationForDataList(resultList, MyRelationParam.dictOnly()); + return resultList; + } + + /** + * 在多对多关系中,当前Service的数据表为从表,返回与指定主表主键Id存在对多对关系的列表。 + * + * @param columnId 主表主键Id。 + * @param filter 从表的过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineRuleListByColumnId(Long columnId, OnlineRule filter, String orderBy) { + List resultList = + onlineRuleMapper.getOnlineRuleListByColumnId(columnId, filter, orderBy); + this.buildRelationForDataList(resultList, MyRelationParam.dictOnly()); + return resultList; + } + + /** + * 返回指定字段Id列表关联的字段规则对象列表。 + * + * @param columnIdSet 指定的字段Id列表。 + * @return 关联的字段规则对象列表。 + */ + @Override + public List getOnlineColumnRuleListByColumnIds(Set columnIdSet) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.in(OnlineColumnRule::getColumnId, columnIdSet); + List columnRuleList = onlineColumnRuleMapper.selectList(queryWrapper); + if (CollUtil.isEmpty(columnRuleList)) { + return columnRuleList; + } + List ruleList; + RBucket bucket = redissonClient.getBucket(ONLINE_RULE_CACHE_KEY); + if (bucket.isExists()) { + ruleList = JSONArray.parseArray(bucket.get(), OnlineRule.class); + } else { + ruleList = this.getAllList(); + if (CollUtil.isNotEmpty(ruleList)) { + bucket.set(JSONArray.toJSONString(ruleList)); + } + } + if (CollUtil.isEmpty(ruleList)) { + return columnRuleList; + } + Map ruleMap = ruleList.stream().collect(Collectors.toMap(OnlineRule::getRuleId, c -> c)); + for (OnlineColumnRule columnRule : columnRuleList) { + columnRule.setOnlineRule(ruleMap.get(columnRule.getRuleId())); + } + return columnRuleList; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineTableServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineTableServiceImpl.java new file mode 100644 index 00000000..ea2cda24 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineTableServiceImpl.java @@ -0,0 +1,195 @@ +package com.orangeforms.common.online.service.impl; + +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.dbutil.object.SqlTable; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.orangeforms.common.online.dao.OnlineTableMapper; +import com.orangeforms.common.online.model.OnlineColumn; +import com.orangeforms.common.online.model.OnlineTable; +import com.orangeforms.common.online.model.constant.FieldKind; +import com.orangeforms.common.online.service.OnlineColumnService; +import com.orangeforms.common.online.service.OnlineTableService; +import com.orangeforms.common.online.util.OnlineRedisKeyUtil; +import com.google.common.base.CaseFormat; +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.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +/** + * 数据表数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("onlineTableService") +public class OnlineTableServiceImpl extends BaseService implements OnlineTableService { + + @Autowired + private OnlineTableMapper onlineTableMapper; + @Autowired + private OnlineColumnService onlineColumnService; + @Autowired + private IdGeneratorWrapper idGenerator; + @Autowired + private RedissonClient redissonClient; + + /** + * 在线对象表的缺省缓存时间(小时)。 + */ + private static final int DEFAULT_CACHED_TABLE_HOURS = 168; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return onlineTableMapper; + } + + /** + * 基于数据库表保存新增对象。 + * + * @param sqlTable 数据库表对象。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public OnlineTable saveNewFromSqlTable(SqlTable sqlTable) { + OnlineTable onlineTable = new OnlineTable(); + TokenData tokenData = TokenData.takeFromRequest(); + onlineTable.setAppCode(tokenData.getAppCode()); + onlineTable.setDblinkId(sqlTable.getDblinkId()); + onlineTable.setTableId(idGenerator.nextLongId()); + onlineTable.setTableName(sqlTable.getTableName()); + String modelName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, sqlTable.getTableName()); + onlineTable.setModelName(modelName); + Date now = new Date(); + onlineTable.setUpdateTime(now); + onlineTable.setCreateTime(now); + onlineTable.setCreateUserId(tokenData.getUserId()); + onlineTable.setUpdateUserId(tokenData.getUserId()); + onlineTableMapper.insert(onlineTable); + List columnList = onlineColumnService.saveNewList(sqlTable.getColumnList(), onlineTable.getTableId()); + onlineTable.setColumnList(columnList); + return onlineTable; + } + + /** + * 删除指定表及其关联的字段数据。 + * + * @param tableId 主键Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long tableId) { + if (onlineTableMapper.deleteById(tableId) == 0) { + return false; + } + this.evictTableCache(tableId); + onlineColumnService.removeByTableId(tableId); + return true; + } + + /** + * 删除指定数据表Id集合中的表,及其关联字段。 + * + * @param tableIdSet 待删除的数据表Id集合。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void removeByTableIdSet(Set tableIdSet) { + tableIdSet.forEach(this::evictTableCache); + onlineTableMapper.delete( + new QueryWrapper().lambda().in(OnlineTable::getTableId, tableIdSet)); + onlineColumnService.removeByTableIdSet(tableIdSet); + } + + /** + * 根据数据源Id,获取该数据源及其关联所引用的数据表列表。 + * + * @param datasourceId 指定的数据源Id。 + * @return 该数据源及其关联所引用的数据表列表。 + */ + @Override + public List getOnlineTableListByDatasourceId(Long datasourceId) { + return onlineTableMapper.getOnlineTableListByDatasourceId(datasourceId); + } + + /** + * 从缓存中获取指定的表数据及其关联字段列表。优先从缓存中读取,如果不存在则从数据库中读取,并同步到缓存。 + * 该接口方法仅仅用户在线表单的动态数据操作接口,而非在线表单的配置接口。 + * + * @param tableId 表主键Id。 + * @return 查询后的在线表对象。 + */ + @Override + public OnlineTable getOnlineTableFromCache(Long tableId) { + String redisKey = OnlineRedisKeyUtil.makeOnlineTableKey(tableId); + RBucket tableBucket = redissonClient.getBucket(redisKey); + if (tableBucket.isExists()) { + String tableInfo = tableBucket.get(); + return JSON.parseObject(tableInfo, OnlineTable.class); + } + OnlineTable table = this.getByIdWithRelation(tableId, MyRelationParam.full()); + if (table == null) { + return null; + } + for (OnlineColumn column : table.getColumnList()) { + if (BooleanUtil.isTrue(column.getPrimaryKey())) { + table.setPrimaryKeyColumn(column); + continue; + } + if (ObjectUtil.equal(column.getFieldKind(), FieldKind.LOGIC_DELETE)) { + table.setLogicDeleteColumn(column); + } + } + Map columnMap = + table.getColumnList().stream().collect(Collectors.toMap(OnlineColumn::getColumnId, c -> c)); + table.setColumnMap(columnMap); + table.setColumnList(null); + tableBucket.set(JSON.toJSONString(table)); + tableBucket.expire(DEFAULT_CACHED_TABLE_HOURS, TimeUnit.HOURS); + return table; + } + + @Override + public OnlineColumn getOnlineColumnFromCache(Long tableId, Long columnId) { + OnlineTable table = this.getOnlineTableFromCache(tableId); + if (table == null) { + return null; + } + return table.getColumnMap().get(columnId); + } + + private void evictTableCache(Long tableId) { + String tableIdKey = OnlineRedisKeyUtil.makeOnlineTableKey(tableId); + redissonClient.getBucket(tableIdKey).delete(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineVirtualColumnServiceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineVirtualColumnServiceImpl.java new file mode 100644 index 00000000..60d272d3 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/service/impl/OnlineVirtualColumnServiceImpl.java @@ -0,0 +1,180 @@ +package com.orangeforms.common.online.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.orangeforms.common.core.annotation.MyDataSourceResolver; +import com.orangeforms.common.core.base.dao.BaseDaoMapper; +import com.orangeforms.common.core.base.service.BaseService; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.object.CallResult; +import com.orangeforms.common.core.object.MyRelationParam; +import com.orangeforms.common.core.util.DefaultDataSourceResolver; +import com.orangeforms.common.online.dao.OnlineVirtualColumnMapper; +import com.orangeforms.common.online.model.OnlineDatasource; +import com.orangeforms.common.online.model.OnlineVirtualColumn; +import com.orangeforms.common.online.model.constant.VirtualType; +import com.orangeforms.common.online.service.OnlineColumnService; +import com.orangeforms.common.online.service.OnlineDatasourceRelationService; +import com.orangeforms.common.online.service.OnlineDatasourceService; +import com.orangeforms.common.online.service.OnlineVirtualColumnService; +import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper; +import com.github.pagehelper.Page; +import lombok.extern.slf4j.Slf4j; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; + +/** + * 虚拟字段数据操作服务类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@MyDataSourceResolver( + resolver = DefaultDataSourceResolver.class, + intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE) +@Service("onlineVirtualColumnService") +public class OnlineVirtualColumnServiceImpl + extends BaseService implements OnlineVirtualColumnService { + + @Autowired + private OnlineVirtualColumnMapper onlineVirtualColumnMapper; + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private OnlineDatasourceRelationService onlineDatasourceRelationService; + @Autowired + private OnlineColumnService onlineColumnService; + @Autowired + private IdGeneratorWrapper idGenerator; + + /** + * 返回当前Service的主表Mapper对象。 + * + * @return 主表Mapper对象。 + */ + @Override + protected BaseDaoMapper mapper() { + return onlineVirtualColumnMapper; + } + + /** + * 保存新增对象。 + * + * @param virtualColumn 新增对象。 + * @return 返回新增对象。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public OnlineVirtualColumn saveNew(OnlineVirtualColumn virtualColumn) { + virtualColumn.setVirtualColumnId(idGenerator.nextLongId()); + if (virtualColumn.getVirtualType().equals(VirtualType.AGGREGATION)) { + OnlineDatasource datasource = onlineDatasourceService.getById(virtualColumn.getDatasourceId()); + virtualColumn.setTableId(datasource.getMasterTableId()); + } + onlineVirtualColumnMapper.insert(virtualColumn); + return virtualColumn; + } + + /** + * 更新数据对象。 + * + * @param virtualColumn 更新的对象。 + * @param originalVirtualColumn 原有数据对象。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean update(OnlineVirtualColumn virtualColumn, OnlineVirtualColumn originalVirtualColumn) { + if (virtualColumn.getVirtualType().equals(VirtualType.AGGREGATION) + && !virtualColumn.getDatasourceId().equals(originalVirtualColumn.getDatasourceId())) { + OnlineDatasource datasource = onlineDatasourceService.getById(virtualColumn.getDatasourceId()); + virtualColumn.setTableId(datasource.getMasterTableId()); + } + UpdateWrapper uw = + this.createUpdateQueryForNullValue(virtualColumn, virtualColumn.getVirtualColumnId()); + return onlineVirtualColumnMapper.update(virtualColumn, uw) == 1; + } + + /** + * 删除指定数据。 + * + * @param virtualColumnId 主键Id。 + * @return 成功返回true,否则false。 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean remove(Long virtualColumnId) { + return onlineVirtualColumnMapper.deleteById(virtualColumnId) == 1; + } + + /** + * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。 + * 如果需要同时获取关联数据,请移步(getOnlineVirtualColumnListWithRelation)方法。 + * + * @param filter 过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineVirtualColumnList(OnlineVirtualColumn filter, String orderBy) { + return onlineVirtualColumnMapper.getOnlineVirtualColumnList(filter, orderBy); + } + + /** + * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。 + * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。 + * 如果仅仅需要获取主表数据,请移步(getOnlineVirtualColumnList),以便获取更好的查询性能。 + * + * @param filter 主表过滤对象。 + * @param orderBy 排序参数。 + * @return 查询结果集。 + */ + @Override + public List getOnlineVirtualColumnListWithRelation(OnlineVirtualColumn filter, String orderBy) { + List resultList = onlineVirtualColumnMapper.getOnlineVirtualColumnList(filter, orderBy); + int batchSize = resultList instanceof Page ? 0 : 1000; + this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); + return resultList; + } + + /** + * 根据数据表的集合,查询关联的虚拟字段数据列表。 + * @param tableIdSet 在线数据表Id集合。 + * @return 关联的虚拟字段数据列表。 + */ + @Override + public List getOnlineVirtualColumnListByTableIds(Set tableIdSet) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.in(OnlineVirtualColumn::getTableId, tableIdSet); + return onlineVirtualColumnMapper.selectList(queryWrapper); + } + + /** + * 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。 + * + * @param virtualColumn 最新数据对象。 + * @param originalVirtualColumn 原有数据对象。 + * @return 数据全部正确返回true,否则false。 + */ + @Override + public CallResult verifyRelatedData(OnlineVirtualColumn virtualColumn, OnlineVirtualColumn originalVirtualColumn) { + String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!"; + if (this.needToVerify(virtualColumn, originalVirtualColumn, OnlineVirtualColumn::getDatasourceId) + && !onlineDatasourceService.existId(virtualColumn.getDatasourceId())) { + return CallResult.error(String.format(errorMessageFormat, "数据源Id")); + } + if (this.needToVerify(virtualColumn, originalVirtualColumn, OnlineVirtualColumn::getRelationId) + && !onlineDatasourceRelationService.existId(virtualColumn.getRelationId())) { + return CallResult.error(String.format(errorMessageFormat, "数据源关联Id")); + } + if (this.needToVerify(virtualColumn, originalVirtualColumn, OnlineVirtualColumn::getAggregationColumnId) + && !onlineColumnService.existId(virtualColumn.getAggregationColumnId())) { + return CallResult.error(String.format(errorMessageFormat, "聚合字段Id")); + } + return CallResult.ok(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineConstant.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineConstant.java new file mode 100644 index 00000000..f40866dc --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineConstant.java @@ -0,0 +1,21 @@ +package com.orangeforms.common.online.util; + +/** + * 在线表单使用的常量数据。。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class OnlineConstant { + + /** + * 数据源关联变量名和从表字段名之间的连接字符串。 + */ + public static final String RELATION_TABLE_COLUMN_SEPARATOR = "__"; + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private OnlineConstant() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineCustomExtFactory.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineCustomExtFactory.java new file mode 100644 index 00000000..a46868b3 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineCustomExtFactory.java @@ -0,0 +1,33 @@ +package com.orangeforms.common.online.util; + +import org.springframework.stereotype.Component; + +/** + * 在线表单自定义扩展工厂类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class OnlineCustomExtFactory { + + private OnlineCustomMaskFieldHandler customMaskFieldHandler = new OnlineCustomMaskFieldHandler(); + + /** + * 设置自定义脱敏规则处理器对象。推荐设置的对象为Bean对象,并在服务启动过程中完成自动注册,运行时直接使用即可。 + * + * @param customMaskFieldHandler 自定义脱敏规则处理器对象。 + */ + public void setCustomMaskFieldHandler(OnlineCustomMaskFieldHandler customMaskFieldHandler) { + this.customMaskFieldHandler = customMaskFieldHandler; + } + + /** + * 返回在线表单的自定义脱敏规则处理器对象。该Bean对象需要在业务代码中实现自行实现。 + * + * @return 在线表单的自定义脱敏规则处理器对象。 + */ + public OnlineCustomMaskFieldHandler getCustomMaskFieldHandler() { + return customMaskFieldHandler; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineCustomMaskFieldHandler.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineCustomMaskFieldHandler.java new file mode 100644 index 00000000..e99b0e58 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineCustomMaskFieldHandler.java @@ -0,0 +1,25 @@ +package com.orangeforms.common.online.util; + +/** + * 在线表单自定义脱敏处理器的默认实现类。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class OnlineCustomMaskFieldHandler { + + /** + * 处理自定义的脱敏数据。可以根据表名和字段名,使用不同的自定义脱敏规则。 + * + * @param appCode 应用编码。如果不是第三方接入的应用,该值可能为null。 + * @param tableName 在线表单对应的表名。 + * @param columnName 在线表单对应的表字段名 + * @param data 待脱敏的数据。 + * @param maskChar 脱敏掩码字符。 + * @return 脱敏后的数据。 + */ + public String handleMask(String appCode, String tableName, String columnName, String data, char maskChar) { + throw new UnsupportedOperationException( + "在运行时抛出该异常,主要为了及时提醒用户提供自己的处理器实现类。请在业务工程中提供该类的具体实现类!"); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineDataSourceUtil.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineDataSourceUtil.java new file mode 100644 index 00000000..a4b765a9 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineDataSourceUtil.java @@ -0,0 +1,47 @@ +package com.orangeforms.common.online.util; + +import com.orangeforms.common.core.exception.MyRuntimeException; +import com.orangeforms.common.dbutil.provider.DataSourceProvider; +import com.orangeforms.common.dbutil.util.DataSourceUtil; +import com.orangeforms.common.online.model.OnlineDblink; +import com.orangeforms.common.online.service.OnlineDblinkService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 在线表单模块动态加载的数据源工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Component +public class OnlineDataSourceUtil extends DataSourceUtil { + + @Autowired + private OnlineDblinkService dblinkService; + + @Override + protected int getDblinkTypeByDblinkId(Long dblinkId) { + DataSourceProvider provider = this.dblinkProviderMap.get(dblinkId); + if (provider != null) { + return provider.getDblinkType(); + } + OnlineDblink dblink = dblinkService.getById(dblinkId); + if (dblink == null) { + throw new MyRuntimeException("Online DblinkId [" + dblinkId + "] doesn't exist!"); + } + this.dblinkProviderMap.put(dblinkId, this.getProvider(dblink.getDblinkType())); + return dblink.getDblinkType(); + } + + @Override + protected String getDblinkConfigurationByDblinkId(Long dblinkId) { + OnlineDblink dblink = dblinkService.getById(dblinkId); + if (dblink == null) { + throw new MyRuntimeException("Online DblinkId [" + dblinkId + "] doesn't exist!"); + } + return dblink.getConfiguration(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineOperationHelper.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineOperationHelper.java new file mode 100644 index 00000000..c0013375 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineOperationHelper.java @@ -0,0 +1,419 @@ +package com.orangeforms.common.online.util; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.constant.ObjectFieldType; +import com.orangeforms.common.core.object.ResponseResult; +import com.orangeforms.common.core.object.TokenData; +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.UploadStoreTypeEnum; +import com.orangeforms.common.online.config.OnlineProperties; +import com.orangeforms.common.online.model.OnlineColumn; +import com.orangeforms.common.online.model.OnlineDatasource; +import com.orangeforms.common.online.model.OnlineDatasourceRelation; +import com.orangeforms.common.online.model.OnlineTable; +import com.orangeforms.common.online.model.constant.FieldKind; +import com.orangeforms.common.online.model.constant.RelationType; +import com.orangeforms.common.online.object.ColumnData; +import com.orangeforms.common.online.service.OnlineDatasourceRelationService; +import com.orangeforms.common.online.service.OnlineDatasourceService; +import com.orangeforms.common.online.service.OnlineOperationService; +import com.orangeforms.common.online.service.OnlineTableService; +import com.orangeforms.common.redis.cache.SessionCacheHelper; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.io.Serializable; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 在线表单操作的通用帮助对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Component +public class OnlineOperationHelper { + + @Autowired + private OnlineDatasourceService onlineDatasourceService; + @Autowired + private OnlineDatasourceRelationService onlineDatasourceRelationService; + @Autowired + private OnlineTableService onlineTableService; + @Autowired + private OnlineOperationService onlineOperationService; + @Autowired + private OnlineProperties onlineProperties; + @Autowired + private UpDownloaderFactory upDownloaderFactory; + @Autowired + private SessionCacheHelper cacheHelper; + + /** + * 验证并获取数据源数据。 + * + * @param datasourceId 数据源Id。 + * @return 数据源详情数据。 + */ + public ResponseResult verifyAndGetDatasource(Long datasourceId) { + String errorMessage; + OnlineDatasource datasource = onlineDatasourceService.getOnlineDatasourceFromCache(datasourceId); + if (datasource == null) { + return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); + } + if (!StrUtil.equals(datasource.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + errorMessage = "数据验证失败,当前应用不包含该数据源Id"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineTable masterTable = onlineTableService.getOnlineTableFromCache(datasource.getMasterTableId()); + if (masterTable == null) { + errorMessage = "数据验证失败,数据源主表Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + datasource.setMasterTable(masterTable); + return ResponseResult.success(datasource); + } + + /** + * 验证并获取数据源的关联数据。 + * + * @param datasourceId 数据源Id。 + * @param relationId 数据源关联Id。 + * @return 数据源的关联详情数据。 + */ + public ResponseResult verifyAndGetRelation(Long datasourceId, Long relationId) { + String errorMessage; + OnlineDatasourceRelation relation = + onlineDatasourceRelationService.getOnlineDatasourceRelationFromCache(datasourceId, relationId); + if (relation == null || !relation.getDatasourceId().equals(datasourceId)) { + return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); + } + if (!StrUtil.equals(relation.getAppCode(), TokenData.takeFromRequest().getAppCode())) { + errorMessage = "数据验证失败,当前应用不包含该数据源关联Id!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + OnlineTable slaveTable = onlineTableService.getOnlineTableFromCache(relation.getSlaveTableId()); + if (slaveTable == null) { + errorMessage = "数据验证失败,数据源关联 [" + relation.getRelationName() + " ] 引用的从表不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + relation.setSlaveTable(slaveTable); + relation.setSlaveColumn(slaveTable.getColumnMap().get(relation.getSlaveColumnId())); + return ResponseResult.success(relation); + } + + /** + * 验证并获取数据源的指定类型关联数据。 + * + * @param datasourceId 数据源Id。 + * @param relationType 数据源关联类型。 + * @return 数据源指定关联类型的关联数据详情列表。 + */ + public ResponseResult> verifyAndGetRelationList( + Long datasourceId, Integer relationType) { + String errorMessage; + List relationList = onlineDatasourceRelationService + .getOnlineDatasourceRelationListFromCache(CollUtil.newHashSet(datasourceId)); + if (relationType != null) { + relationList = relationList.stream() + .filter(r -> r.getRelationType().equals(relationType)).collect(Collectors.toList()); + } + for (OnlineDatasourceRelation relation : relationList) { + OnlineTable slaveTable = onlineTableService.getOnlineTableFromCache(relation.getSlaveTableId()); + if (slaveTable == null) { + errorMessage = "数据验证失败,数据源关联 [" + relation.getRelationName() + "] 的从表Id不存在!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + relation.setSlaveTable(slaveTable); + } + return ResponseResult.success(relationList); + } + + /** + * 构建在线表的数据记录。 + * + * @param table 在线数据表对象。 + * @param tableData 在线数据表数据。 + * @param forUpdate 是否为更新。 + * @param ignoreSetColumnId 忽略设置的字段Id。 + * @return 在线表的数据记录。 + */ + public ResponseResult> buildTableData( + OnlineTable table, JSONObject tableData, boolean forUpdate, Long ignoreSetColumnId) { + List columnDataList = new LinkedList<>(); + String errorMessage; + for (OnlineColumn column : table.getColumnMap().values()) { + // 判断一下是否为需要自动填入的字段,如果是,这里就都暂时给空值了,后续操作会自动填补。 + // 这里还能避免一次基于tableData的查询,能快几纳秒也是好的。 + if (this.isAutoSettingField(column) || ObjectUtil.equal(column.getColumnId(), ignoreSetColumnId)) { + columnDataList.add(new ColumnData(column, null)); + continue; + } + Object value = this.getColumnValue(tableData, column); + // 对于主键数据的处理。 + if (BooleanUtil.isTrue(column.getPrimaryKey())) { + // 如果是更新则必须包含主键参数。 + if (forUpdate && value == null) { + errorMessage = "数据验证失败,数据表 [" + + table.getTableName() + "] 主键字段 [" + column.getColumnName() + "] 不能为空值!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } else { + if (value == null && !column.getNullable() && StrUtil.isBlank(column.getEncodedRule())) { + errorMessage = "数据验证失败,数据表 [" + + table.getTableName() + "] 字段 [" + column.getColumnName() + "] 不能为空值!"; + return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); + } + } + columnDataList.add(new ColumnData(column, value)); + } + return ResponseResult.success(columnDataList); + } + + /** + * 构建多个一对多从表的数据列表。 + * + * @param datasourceId 数据源Id。 + * @param slaveData 多个一对多从表数据的JSON对象。 + * @return 构建后的多个一对多从表数据列表。 + */ + public ResponseResult>> buildSlaveDataList( + Long datasourceId, JSONObject slaveData) { + if (slaveData == null) { + return ResponseResult.success(null); + } + Map> relationDataMap = new HashMap<>(slaveData.size()); + for (String key : slaveData.keySet()) { + Long relationId = Long.parseLong(key); + ResponseResult relationResult = this.verifyAndGetRelation(datasourceId, relationId); + if (!relationResult.isSuccess()) { + return ResponseResult.errorFrom(relationResult); + } + OnlineDatasourceRelation relation = relationResult.getData(); + List relationDataList = new LinkedList<>(); + relationDataMap.put(relation, relationDataList); + if (relation.getRelationType().equals(RelationType.ONE_TO_MANY)) { + JSONArray slaveObjectArray = slaveData.getJSONArray(key); + for (int i = 0; i < slaveObjectArray.size(); i++) { + relationDataList.add(slaveObjectArray.getJSONObject(i)); + } + } else if (relation.getRelationType().equals(RelationType.ONE_TO_ONE)) { + JSONObject o = slaveData.getJSONObject(key); + if (MapUtil.isNotEmpty(o)) { + relationDataList.add(o); + } + } + } + return ResponseResult.success(relationDataMap); + } + + /** + * 将字符型字段值转换为与参数字段类型匹配的字段值。 + * + * @param column 在线表单字段。 + * @param dataId 字符型字段值。 + * @return 转换后与参数字段类型匹配的字段值。 + */ + public Serializable convertToTypeValue(OnlineColumn column, String dataId) { + if (dataId == null) { + return null; + } + if (column == null) { + return dataId; + } + if ("Long".equals(column.getObjectFieldType())) { + return Long.valueOf(dataId); + } else if ("Integer".equals(column.getObjectFieldType())) { + return Integer.valueOf(dataId); + } + return dataId; + } + + /** + * 将字符型字段值集合转换为与参数字段类型匹配的字段值集合。 + * + * @param column 在线表单字段。 + * @param dataIdSet 字符型字段值集合。 + * @return 转换后与参数字段类型匹配的字段值集合。 + */ + public Set convertToTypeValue(OnlineColumn column, Set dataIdSet) { + Set resultSet = new HashSet<>(); + if (dataIdSet == null) { + return resultSet; + } + if ("Long".equals(column.getObjectFieldType())) { + return dataIdSet.stream().map(Long::valueOf).collect(Collectors.toSet()); + } else if ("Integer".equals(column.getObjectFieldType())) { + return dataIdSet.stream().map(Integer::valueOf).collect(Collectors.toSet()); + } else { + resultSet.addAll(dataIdSet); + } + return resultSet; + } + + /** + * 下载数据。 + * + * @param table 在线表对象。 + * @param dataId 在线表数据主键Id。 + * @param fieldName 数据表字段名。 + * @param filename 下载文件名。 + * @param asImage 是否为图片。 + * @param response HTTP 应对对象。 + */ + public void doDownload( + OnlineTable table, String dataId, String fieldName, String filename, Boolean asImage, HttpServletResponse response) { + // 使用try来捕获异常,是为了保证一旦出现异常可以返回500的错误状态,便于调试。 + // 否则有可能给前端返回的是200的错误码。 + try { + // 如果请求参数中没有包含主键Id,就判断该文件是否为当前session上传的。 + if (ObjectUtil.isEmpty(dataId)) { + if (!cacheHelper.existSessionUploadFile(filename)) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN); + return; + } + } else { + Map dataMap = + onlineOperationService.getMasterData(table, null, null, dataId); + if (dataMap == null) { + ResponseResult.output(HttpServletResponse.SC_NOT_FOUND); + return; + } + String fieldJsonData = (String) dataMap.get(fieldName); + if (!this.canDownload(fieldJsonData, filename)) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN); + return; + } + } + ResponseResult verifyResult = this.doVerifyUpDownloadFileColumn(table, fieldName, asImage); + if (!verifyResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, verifyResult); + return; + } + OnlineColumn downloadColumn = verifyResult.getData(); + if (downloadColumn.getUploadFileSystemType() == null) { + downloadColumn.setUploadFileSystemType(UploadStoreTypeEnum.LOCAL_SYSTEM.ordinal()); + } + if (!downloadColumn.getUploadFileSystemType().equals(UploadStoreTypeEnum.LOCAL_SYSTEM.ordinal())) { + downloadColumn.setUploadFileSystemType(onlineProperties.getDistributeStoreType()); + } + UploadStoreTypeEnum uploadStoreType = + UploadStoreTypeEnum.values()[downloadColumn.getUploadFileSystemType()]; + BaseUpDownloader upDownloader = upDownloaderFactory.get(uploadStoreType); + upDownloader.doDownload(onlineProperties.getUploadFileBaseDir(), + table.getModelName(), fieldName, filename, asImage, response); + } catch (Exception e) { + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + log.error(e.getMessage(), e); + } + } + + /** + * 上传数据。 + * + * @param table 在线表对象。 + * @param fieldName 数据表字段名。 + * @param asImage 是否为图片。 + * @param uploadFile 上传的文件。 + */ + public void doUpload(OnlineTable table, String fieldName, Boolean asImage, MultipartFile uploadFile) + throws IOException { + ResponseResult verifyResult = this.doVerifyUpDownloadFileColumn(table, fieldName, asImage); + if (!verifyResult.isSuccess()) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, verifyResult); + return; + } + OnlineColumn uploadColumn = verifyResult.getData(); + if (uploadColumn.getUploadFileSystemType() == null) { + uploadColumn.setUploadFileSystemType(UploadStoreTypeEnum.LOCAL_SYSTEM.ordinal()); + } + if (!uploadColumn.getUploadFileSystemType().equals(UploadStoreTypeEnum.LOCAL_SYSTEM.ordinal())) { + uploadColumn.setUploadFileSystemType(onlineProperties.getDistributeStoreType()); + } + UploadStoreTypeEnum uploadStoreType = UploadStoreTypeEnum.values()[uploadColumn.getUploadFileSystemType()]; + BaseUpDownloader upDownloader = upDownloaderFactory.get(uploadStoreType); + UploadResponseInfo responseInfo = upDownloader.doUpload(null, + onlineProperties.getUploadFileBaseDir(), table.getModelName(), fieldName, asImage, uploadFile); + if (BooleanUtil.isTrue(responseInfo.getUploadFailed())) { + ResponseResult.output(HttpServletResponse.SC_FORBIDDEN, + ResponseResult.error(ErrorCodeEnum.UPLOAD_FAILED, responseInfo.getErrorMessage())); + return; + } + // 动态表单的下载url和普通表单有所不同,由前端负责动态拼接。 + responseInfo.setDownloadUri(null); + cacheHelper.putSessionUploadFile(responseInfo.getFilename()); + ResponseResult.output(ResponseResult.success(responseInfo)); + } + + private ResponseResult doVerifyUpDownloadFileColumn( + OnlineTable table, String fieldName, Boolean asImage) { + OnlineColumn column = this.getOnlineColumnByName(table, fieldName); + if (column == null) { + return ResponseResult.error(ErrorCodeEnum.INVALID_DATA_FIELD); + } + if (BooleanUtil.isTrue(asImage)) { + if (ObjectUtil.notEqual(column.getFieldKind(), FieldKind.UPLOAD_IMAGE)) { + return ResponseResult.error(ErrorCodeEnum.INVALID_UPLOAD_FIELD); + } + } else { + if (ObjectUtil.notEqual(column.getFieldKind(), FieldKind.UPLOAD)) { + return ResponseResult.error(ErrorCodeEnum.INVALID_UPLOAD_FIELD); + } + } + return ResponseResult.success(column); + } + + private OnlineColumn getOnlineColumnByName(OnlineTable table, String fieldName) { + for (OnlineColumn column : table.getColumnMap().values()) { + if (column.getColumnName().equals(fieldName)) { + return column; + } + } + return null; + } + + private Object getColumnValue(JSONObject tableData, OnlineColumn column) { + Object value = tableData.get(column.getColumnName()); + if (value != null) { + if (ObjectFieldType.LONG.equals(column.getObjectFieldType())) { + value = Long.valueOf(value.toString()); + } else if (ObjectFieldType.DATE.equals(column.getObjectFieldType())) { + value = Convert.toLocalDateTime(value); + } + } + return value; + } + + private boolean isAutoSettingField(OnlineColumn column) { + return ObjectUtil.equal(column.getFieldKind(), FieldKind.CREATE_TIME) + || ObjectUtil.equal(column.getFieldKind(), FieldKind.CREATE_USER_ID) + || ObjectUtil.equal(column.getFieldKind(), FieldKind.UPDATE_TIME) + || ObjectUtil.equal(column.getFieldKind(), FieldKind.UPDATE_USER_ID) + || ObjectUtil.equal(column.getFieldKind(), FieldKind.CREATE_DEPT_ID) + || ObjectUtil.equal(column.getFieldKind(), FieldKind.LOGIC_DELETE); + } + + private boolean canDownload(String fieldJsonData, String filename) { + if (fieldJsonData == null && !cacheHelper.existSessionUploadFile(filename)) { + return false; + } + return BaseUpDownloader.containFile(fieldJsonData, filename) + || cacheHelper.existSessionUploadFile(filename); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineRedisKeyUtil.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineRedisKeyUtil.java new file mode 100644 index 00000000..431ae946 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineRedisKeyUtil.java @@ -0,0 +1,76 @@ +package com.orangeforms.common.online.util; + +/** + * 在线表单 Redis 键生成工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class OnlineRedisKeyUtil { + + /** + * 计算在线表对象缓存在Redis中的键值。 + * + * @param tableId 在线表主键Id。 + * @return 在线表对象缓存在Redis中的键值。 + */ + public static String makeOnlineTableKey(Long tableId) { + return "ONLINE_TABLE:" + tableId; + } + + /** + * 计算在线表单对象缓存在Redis中的键值。 + * + * @param formId 在线表单对象主键Id。 + * @return 在线表单对象缓存在Redis中的键值。 + */ + public static String makeOnlineFormKey(Long formId) { + return "ONLINE_FORM:" + formId; + } + + /** + * 计算在线表单关联数据源对象列表缓存在Redis中的键值。 + * + * @param formId 在线表单对象主键Id。 + * @return 在线表单关联数据源对象列表缓存在Redis中的键值。 + */ + public static String makeOnlineFormDatasourceKey(Long formId) { + return "ONLINE_FORM_DATASOURCE_LIST:" + formId; + } + + /** + * 计算在线数据源对象缓存在Redis中的键值。 + * + * @param datasourceId 在线数据源主键Id。 + * @return 在线数据源对象缓存在Redis中的键值。 + */ + public static String makeOnlineDataSourceKey(Long datasourceId) { + return "ONLINE_DATASOURCE:" + datasourceId; + } + + /** + * 计算在线数据源关联列表对象缓存在Redis中的键值。 + * + * @param datasourceId 在线数据源主键Id。 + * @return 在线数据源关联列表对象缓存在Redis中的键值。 + */ + public static String makeOnlineDataSourceRelationKey(Long datasourceId) { + return "ONLINE_DATASOURCE_RELATION:" + datasourceId; + } + + /** + * 计算在线字典对象缓存在Redis中的键值。 + * + * @param dictId 在线字典主键Id。 + * @return 在线字典对象缓存在Redis中的键值。 + */ + public static String makeOnlineDictKey(Long dictId) { + return "ONLINE_DICT:" + dictId; + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private OnlineRedisKeyUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineUtil.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineUtil.java new file mode 100644 index 00000000..712fe312 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/util/OnlineUtil.java @@ -0,0 +1,36 @@ +package com.orangeforms.common.online.util; + +/** + * 在线表单的工具类。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class OnlineUtil { + + /** + * 根据输入参数,拼接在线表单操作的查看权限字。 + * + * @param datasourceVariableName 数据源变量名。 + * @return 拼接后的在线表单操作的查看权限字。 + */ + public static String makeViewPermCode(String datasourceVariableName) { + return "online:" + datasourceVariableName + ":view"; + } + + /** + * 根据输入参数,拼接在线表单操作的编辑权限字。 + * + * @param datasourceVariableName 数据源变量名。 + * @return 拼接后的在线表单操作的编辑权限字。 + */ + public static String makeEditPermCode(String datasourceVariableName) { + return "online:" + datasourceVariableName + ":edit"; + } + + /** + * 私有构造函数,明确标识该常量类的作用。 + */ + private OnlineUtil() { + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineColumnRuleVo.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineColumnRuleVo.java new file mode 100644 index 00000000..677eb67a --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineColumnRuleVo.java @@ -0,0 +1,33 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 在线表单数据表字段规则和字段多对多关联VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单数据表字段规则和字段多对多关联VO对象") +@Data +public class OnlineColumnRuleVo { + + /** + * 字段Id。 + */ + @Schema(description = "字段Id") + private Long columnId; + + /** + * 规则Id。 + */ + @Schema(description = "规则Id") + private Long ruleId; + + /** + * 规则属性数据。 + */ + @Schema(description = "规则属性数据") + private String propDataJson; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineColumnVo.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineColumnVo.java new file mode 100644 index 00000000..3438eed4 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineColumnVo.java @@ -0,0 +1,204 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单数据表字段规则和字段多对多关联VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单数据表字段规则和字段多对多关联VO对象") +@Data +public class OnlineColumnVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long columnId; + + /** + * 字段名。 + */ + @Schema(description = "字段名") + private String columnName; + + /** + * 数据表Id。 + */ + @Schema(description = "数据表Id") + private Long tableId; + + /** + * 数据表中的字段类型。 + */ + @Schema(description = "数据表中的字段类型") + private String columnType; + + /** + * 数据表中的完整字段类型(包括了精度和刻度)。 + */ + @Schema(description = "数据表中的完整字段类型") + private String fullColumnType; + + /** + * 是否为主键。 + */ + @Schema(description = "是否为主键") + private Boolean primaryKey; + + /** + * 是否是自增主键(0: 不是 1: 是)。 + */ + @Schema(description = "是否是自增主键") + private Boolean autoIncrement; + + /** + * 是否可以为空 (0: 不可以为空 1: 可以为空)。 + */ + @Schema(description = "是否可以为空") + private Boolean nullable; + + /** + * 缺省值。 + */ + @Schema(description = "缺省值") + private String columnDefault; + + /** + * 字段在数据表中的显示位置。 + */ + @Schema(description = "字段在数据表中的显示位置") + private Integer columnShowOrder; + + /** + * 数据表中的字段注释。 + */ + @Schema(description = "数据表中的字段注释") + private String columnComment; + + /** + * 对象映射字段名称。 + */ + @Schema(description = "对象映射字段名称") + private String objectFieldName; + + /** + * 对象映射字段类型。 + */ + @Schema(description = "对象映射字段类型") + private String objectFieldType; + + /** + * 数值型字段的精度(目前仅Oracle使用)。 + */ + @Schema(description = "数值型字段的精度") + private Integer numericPrecision; + + /** + * 数值型字段的刻度(小数点后位数,目前仅Oracle使用)。 + */ + @Schema(description = "数值型字段的刻度") + private Integer numericScale; + + /** + * 过滤类型。 + */ + @Schema(description = "过滤类型") + private Integer filterType; + + /** + * 是否是主键的父Id。 + */ + @Schema(description = "是否是主键的父Id") + private Boolean parentKey; + + /** + * 是否部门过滤字段。 + */ + @Schema(description = "是否部门过滤字段") + private Boolean deptFilter; + + /** + * 是否用户过滤字段。 + */ + @Schema(description = "是否用户过滤字段") + private Boolean userFilter; + + /** + * 字段类别。 + */ + @Schema(description = "字段类别") + private Integer fieldKind; + + /** + * 包含的文件文件数量,0表示无限制。 + */ + @Schema(description = "包含的文件文件数量,0表示无限制") + private Integer maxFileCount; + + /** + * 上传文件系统类型。 + */ + @Schema(description = "上传文件系统类型") + private Integer uploadFileSystemType; + + /** + * 编码规则的JSON格式数据。 + */ + @Schema(description = "编码规则的JSON格式数据") + private String encodedRule; + + /** + * 脱敏字段类型,具体值可参考MaskFieldTypeEnum枚举。 + */ + @Schema(description = "脱敏字段类型") + private String maskFieldType; + + /** + * 字典Id。 + */ + @Schema(description = "字典Id") + private Long dictId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者。 + */ + @Schema(description = "创建者") + private Long createUserId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者。 + */ + @Schema(description = "更新者") + private Long updateUserId; + + /** + * fieldKind 常量字典关联数据。 + */ + @Schema(description = "常量字典关联数据") + private Map fieldKindDictMap; + + /** + * dictId 的一对一关联。 + */ + @Schema(description = "dictId 的一对一关联") + private Map dictInfo; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDatasourceRelationVo.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDatasourceRelationVo.java new file mode 100644 index 00000000..6af755a9 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDatasourceRelationVo.java @@ -0,0 +1,150 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单的数据源关联VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单的数据源关联VO对象") +@Data +public class OnlineDatasourceRelationVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long relationId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Schema(description = "应用编码。为空时,表示非第三方应用接入") + private String appCode; + + /** + * 关联名称。 + */ + @Schema(description = "关联名称") + private String relationName; + + /** + * 变量名。 + */ + @Schema(description = "变量名") + private String variableName; + + /** + * 主数据源Id。 + */ + @Schema(description = "主数据源Id") + private Long datasourceId; + + /** + * 关联类型。 + */ + @Schema(description = "关联类型") + private Integer relationType; + + /** + * 主表关联字段Id。 + */ + @Schema(description = "主表关联字段Id") + private Long masterColumnId; + + /** + * 从表Id。 + */ + @Schema(description = "从表Id") + private Long slaveTableId; + + /** + * 从表关联字段Id。 + */ + @Schema(description = "从表关联字段Id") + private Long slaveColumnId; + + /** + * 删除主表的时候是否级联删除一对一和一对多的从表数据,多对多只是删除关联,不受到这个标记的影响。。 + */ + @Schema(description = "一对多从表级联删除标记") + private Boolean cascadeDelete; + + /** + * 是否左连接。 + */ + @Schema(description = "是否左连接") + private Boolean leftJoin; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者。 + */ + @Schema(description = "创建者") + private Long createUserId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者。 + */ + @Schema(description = "更新者") + private Long updateUserId; + + /** + * masterColumnId 的一对一关联数据对象,数据对应类型为OnlineColumnVo。 + */ + @Schema(description = "masterColumnId字段的一对一关联数据对象") + private Map masterColumn; + + /** + * slaveTableId 的一对一关联数据对象,数据对应类型为OnlineTableVo。 + */ + @Schema(description = "slaveTableId字段的一对一关联数据对象") + private Map slaveTable; + + /** + * slaveColumnId 的一对一关联数据对象,数据对应类型为OnlineColumnVo。 + */ + @Schema(description = "slaveColumnId字段的一对一关联数据对象") + private Map slaveColumn; + + /** + * masterColumnId 字典关联数据。 + */ + @Schema(description = "masterColumnId的字典关联数据") + private Map masterColumnIdDictMap; + + /** + * slaveTableId 字典关联数据。 + */ + @Schema(description = "slaveTableId的字典关联数据") + private Map slaveTableIdDictMap; + + /** + * slaveColumnId 字典关联数据。 + */ + @Schema(description = "slaveColumnId的字典关联数据") + private Map slaveColumnIdDictMap; + + /** + * relationType 常量字典关联数据。 + */ + @Schema(description = "常量字典关联数据") + private Map relationTypeDictMap; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDatasourceVo.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDatasourceVo.java new file mode 100644 index 00000000..160432be --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDatasourceVo.java @@ -0,0 +1,97 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 在线表单的数据源VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单的数据源VO对象") +@Data +public class OnlineDatasourceVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long datasourceId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Schema(description = "应用编码。为空时,表示非第三方应用接入") + private String appCode; + + /** + * 数据源名称。 + */ + @Schema(description = "数据源名称") + private String datasourceName; + + /** + * 数据源变量名,会成为数据访问url的一部分。 + */ + @Schema(description = "数据源变量名") + private String variableName; + + /** + * 数据库链接Id。 + */ + @Schema(description = "数据库链接Id") + private Long dblinkId; + + /** + * 主表Id。 + */ + @Schema(description = "主表Id") + private Long masterTableId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者。 + */ + @Schema(description = "创建者") + private Long createUserId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者。 + */ + @Schema(description = "更新者") + private Long updateUserId; + + /** + * datasourceId 的多对多关联表数据对象,数据对应类型为OnlinePageDatasource。 + */ + @Schema(description = "datasourceId 的多对多关联表数据对象,数据对应类型为OnlinePageDatasource") + private Map onlinePageDatasource; + + /** + * masterTableId 字典关联数据。 + */ + @Schema(description = "masterTableId 字典关联数据") + private Map masterTableIdDictMap; + + /** + * 当前数据源及其关联,引用的数据表对象列表。 + */ + @Schema(description = "当前数据源及其关联,引用的数据表对象列表") + private List tableList; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDblinkVo.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDblinkVo.java new file mode 100644 index 00000000..6415f31c --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDblinkVo.java @@ -0,0 +1,84 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单数据表所在数据库链接VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单数据表所在数据库链接VO对象") +@Data +public class OnlineDblinkVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long dblinkId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Schema(description = "应用编码。为空时,表示非第三方应用接入") + private String appCode; + + /** + * 链接中文名称。 + */ + @Schema(description = "链接中文名称") + private String dblinkName; + + /** + * 链接描述。 + */ + @Schema(description = "链接描述") + private String dblinkDescription; + + /** + * 配置信息。 + */ + @Schema(description = "配置信息") + private String configuration; + + /** + * 数据库链接类型。 + */ + @Schema(description = "数据库链接类型") + private Integer dblinkType; + + /** + * 更新者。 + */ + @Schema(description = "更新者") + private Long updateUserId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 创建者。 + */ + @Schema(description = "创建者") + private Long createUserId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 数据库链接类型常量字典关联数据。 + */ + @Schema(description = "数据库链接类型常量字典关联数据") + private Map dblinkTypeDictMap; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDictVo.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDictVo.java new file mode 100644 index 00000000..804e5c71 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineDictVo.java @@ -0,0 +1,162 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单关联的字典VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单关联的字典VO对象") +@Data +public class OnlineDictVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long dictId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Schema(description = "应用编码。为空时,表示非第三方应用接入") + private String appCode; + + /** + * 字典名称。 + */ + @Schema(description = "字典名称") + private String dictName; + + /** + * 字典类型。 + */ + @Schema(description = "字典类型") + private Integer dictType; + + /** + * 数据库链接Id。 + */ + @Schema(description = "数据库链接Id") + private Long dblinkId; + + /** + * 字典表名称。 + */ + @Schema(description = "字典表名称") + private String tableName; + + /** + * 全局字典编码。 + */ + @Schema(description = "全局字典编码") + private String dictCode; + + /** + * 逻辑删除字段。 + */ + @Schema(description = "逻辑删除字段") + private String deletedColumnName; + + /** + * 用户过滤滤字段名称。 + */ + @Schema(description = "用户过滤滤字段名称") + private String userFilterColumnName; + + /** + * 部门过滤字段名称。 + */ + @Schema(description = "部门过滤字段名称") + private String deptFilterColumnName; + + /** + * 租户过滤字段名称。 + */ + @Schema(description = "租户过滤字段名称") + private String tenantFilterColumnName; + + /** + * 字典表键字段名称。 + */ + @Schema(description = "字典表键字段名称") + private String keyColumnName; + + /** + * 字典表父键字段名称。 + */ + @Schema(description = "字典表父键字段名称") + private String parentKeyColumnName; + + /** + * 字典值字段名称。 + */ + @Schema(description = "字典值字段名称") + private String valueColumnName; + + /** + * 是否树形标记。 + */ + @Schema(description = "是否树形标记") + private Boolean treeFlag; + + /** + * 获取字典数据的url。 + */ + @Schema(description = "获取字典数据的url") + private String dictListUrl; + + /** + * 根据主键id批量获取字典数据的url。 + */ + @Schema(description = "根据主键id批量获取字典数据的url") + private String dictIdsUrl; + + /** + * 字典的JSON数据。 + */ + @Schema(description = "字典的JSON数据") + private String dictDataJson; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者。 + */ + @Schema(description = "创建者") + private Long createUserId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者。 + */ + @Schema(description = "更新者") + private Long updateUserId; + + /** + * dictType 常量字典关联数据。 + */ + @Schema(description = "dictType 常量字典关联数据") + private Map dictTypeDictMap; + + /** + * 数据库链接Id字典关联数据。 + */ + @Schema(description = "数据库链接Id字典关联数据") + private Map dblinkIdDictMap; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineFormVo.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineFormVo.java new file mode 100644 index 00000000..d3373ce8 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineFormVo.java @@ -0,0 +1,127 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 在线表单VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单VO对象") +@Data +public class OnlineFormVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long formId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Schema(description = "应用编码。为空时,表示非第三方应用接入") + private String appCode; + + /** + * 页面Id。 + */ + @Schema(description = "页面Id") + private Long pageId; + + /** + * 表单编码。 + */ + @Schema(description = "表单编码") + private String formCode; + + /** + * 表单名称。 + */ + @Schema(description = "表单名称") + private String formName; + + /** + * 表单类型。 + */ + @Schema(description = "表单类型") + private Integer formType; + + /** + * 表单类别。 + */ + @Schema(description = "表单类别") + private Integer formKind; + + /** + * 表单主表Id。 + */ + @Schema(description = "表单主表Id") + private Long masterTableId; + + /** + * 表单组件JSON。 + */ + @Schema(description = "表单组件JSON") + private String widgetJson; + + /** + * 表单参数JSON。 + */ + @Schema(description = "表单参数JSON") + private String paramsJson; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者。 + */ + @Schema(description = "创建者") + private Long createUserId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者。 + */ + @Schema(description = "更新者") + private Long updateUserId; + + /** + * masterTableId 的一对一关联数据对象,数据对应类型为OnlineTableVo。 + */ + @Schema(description = "asterTableId 的一对一关联数据对象") + private Map onlineTable; + + /** + * masterTableId 字典关联数据。 + */ + @Schema(description = "masterTableId 字典关联数据") + private Map masterTableIdDictMap; + + /** + * formType 常量字典关联数据。 + */ + @Schema(description = "formType 常量字典关联数据") + private Map formTypeDictMap; + + /** + * 当前表单关联的数据源Id集合。 + */ + @Schema(description = "当前表单关联的数据源Id集合") + private List datasourceIdList; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlinePageDatasourceVo.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlinePageDatasourceVo.java new file mode 100644 index 00000000..adb113ff --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlinePageDatasourceVo.java @@ -0,0 +1,33 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 在线表单页面和数据源多对多关联VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单页面和数据源多对多关联VO对象") +@Data +public class OnlinePageDatasourceVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long id; + + /** + * 页面主键Id。 + */ + @Schema(description = "页面主键Id") + private Long pageId; + + /** + * 数据源主键Id。 + */ + @Schema(description = "数据源主键Id") + private Long datasourceId; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlinePageVo.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlinePageVo.java new file mode 100644 index 00000000..bd80de12 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlinePageVo.java @@ -0,0 +1,96 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单所在页面VO对象。这里我们可以把页面理解为表单的容器。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单所在页面VO对象") +@Data +public class OnlinePageVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long pageId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Schema(description = "应用编码。为空时,表示非第三方应用接入") + private String appCode; + + /** + * 页面编码。 + */ + @Schema(description = "页面编码") + private String pageCode; + + /** + * 页面名称。 + */ + @Schema(description = "页面名称") + private String pageName; + + /** + * 页面类型。 + */ + @Schema(description = "页面类型") + private Integer pageType; + + /** + * 页面编辑状态。 + */ + @Schema(description = "页面编辑状态") + private Integer status; + + /** + * 是否发布。 + */ + @Schema(description = "是否发布") + private Boolean published; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者。 + */ + @Schema(description = "创建者") + private Long createUserId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者。 + */ + @Schema(description = "更新者") + private Long updateUserId; + + /** + * pageType 常量字典关联数据。 + */ + @Schema(description = "pageType 常量字典关联数据") + private Map pageTypeDictMap; + + /** + * status 常量字典关联数据。 + */ + @Schema(description = "status 常量字典关联数据") + private Map statusDictMap; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineRuleVo.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineRuleVo.java new file mode 100644 index 00000000..ba88dbec --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineRuleVo.java @@ -0,0 +1,90 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 在线表单数据表字段验证规则VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单数据表字段验证规则VO对象") +@Data +public class OnlineRuleVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long ruleId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Schema(description = "应用编码。为空时,表示非第三方应用接入") + private String appCode; + + /** + * 规则名称。 + */ + @Schema(description = "规则名称") + private String ruleName; + + /** + * 规则类型。 + */ + @Schema(description = "规则类型") + private Integer ruleType; + + /** + * 内置规则标记。 + */ + @Schema(description = "内置规则标记") + private Boolean builtin; + + /** + * 自定义规则的正则表达式。 + */ + @Schema(description = "自定义规则的正则表达式") + private String pattern; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者。 + */ + @Schema(description = "创建者") + private Long createUserId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者。 + */ + @Schema(description = "更新者") + private Long updateUserId; + + /** + * ruleId 的多对多关联表数据对象,数据对应类型为OnlineColumnRuleVo。 + */ + @Schema(description = "ruleId 的多对多关联表数据对象") + private Map onlineColumnRule; + + /** + * ruleType 常量字典关联数据。 + */ + @Schema(description = "ruleType 常量字典关联数据") + private Map ruleTypeDictMap; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineTableVo.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineTableVo.java new file mode 100644 index 00000000..66561baf --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineTableVo.java @@ -0,0 +1,71 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 在线表单的数据表VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线表单的数据表VO对象") +@Data +public class OnlineTableVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long tableId; + + /** + * 应用编码。为空时,表示非第三方应用接入。 + */ + @Schema(description = "应用。为空时,表示非第三方应用接入") + private String appCode; + + /** + * 表名称。 + */ + @Schema(description = "表名称") + private String tableName; + + /** + * 实体名称。 + */ + @Schema(description = "实体名称") + private String modelName; + + /** + * 数据库链接Id。 + */ + @Schema(description = "数据库链接Id") + private Long dblinkId; + + /** + * 创建时间。 + */ + @Schema(description = "创建时间") + private Date createTime; + + /** + * 创建者。 + */ + @Schema(description = "创建者") + private Long createUserId; + + /** + * 更新时间。 + */ + @Schema(description = "更新时间") + private Date updateTime; + + /** + * 更新者。 + */ + @Schema(description = "更新者") + private Long updateUserId; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineVirtualColumnVo.java b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineVirtualColumnVo.java new file mode 100644 index 00000000..2a4ca215 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/java/com/orangeforms/common/online/vo/OnlineVirtualColumnVo.java @@ -0,0 +1,87 @@ +package com.orangeforms.common.online.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 在线数据表虚拟字段VO对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Schema(description = "在线数据表虚拟字段VO对象") +@Data +public class OnlineVirtualColumnVo { + + /** + * 主键Id。 + */ + @Schema(description = "主键Id") + private Long virtualColumnId; + + /** + * 所在表Id。 + */ + @Schema(description = "所在表Id") + private Long tableId; + + /** + * 字段名称。 + */ + @Schema(description = "字段名称") + private String objectFieldName; + + /** + * 属性类型。 + */ + @Schema(description = "属性类型") + private String objectFieldType; + + /** + * 字段提示名。 + */ + @Schema(description = "字段提示名") + private String columnPrompt; + + /** + * 虚拟字段类型(0: 聚合)。 + */ + @Schema(description = "虚拟字段类型(0: 聚合)") + private Integer virtualType; + + /** + * 关联数据源Id。 + */ + @Schema(description = "关联数据源Id") + private Long datasourceId; + + /** + * 关联Id。 + */ + @Schema(description = "关联Id") + private Long relationId; + + /** + * 聚合字段所在关联表Id。 + */ + @Schema(description = "聚合字段所在关联表Id") + private Long aggregationTableId; + + /** + * 关联表聚合字段Id。 + */ + @Schema(description = "关联表聚合字段Id") + private Long aggregationColumnId; + + /** + * 聚合类型(0: count 1: sum 2: avg 3: max 4:min)。 + */ + @Schema(description = "聚合类型(0: count 1: sum 2: avg 3: max 4:min)") + private Integer aggregationType; + + /** + * 存储过滤条件的json。 + */ + @Schema(description = "存储过滤条件的json") + private String whereClauseJson; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..d9cb5fb0 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-online/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.orangeforms.common.online.config.OnlineAutoConfig \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-redis/pom.xml b/OrangeFormsOpen-MybatisPlus/common/common-redis/pom.xml new file mode 100644 index 00000000..c0fe169d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-redis/pom.xml @@ -0,0 +1,29 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-redis + 1.0.0 + common-redis + jar + + + + com.orangeforms + common-core + 1.0.0 + + + org.redisson + redisson + ${redisson.version} + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/RedisDictionaryCache.java b/OrangeFormsOpen-MybatisPlus/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/RedisDictionaryCache.java new file mode 100644 index 00000000..da1c2fc2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/RedisDictionaryCache.java @@ -0,0 +1,263 @@ +package com.orangeforms.common.redis.cache; + +import cn.hutool.core.collection.CollUtil; +import com.alibaba.fastjson.JSON; +import com.orangeforms.common.core.cache.DictionaryCache; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.exception.RedisCacheAccessException; +import lombok.extern.slf4j.Slf4j; +import org.redisson.api.RMap; +import org.redisson.api.RedissonClient; + +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 字典数据Redis缓存对象。 + * + * @param 字典表主键类型。 + * @param 字典表对象类型。 + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class RedisDictionaryCache implements DictionaryCache { + + /** + * 字典数据前缀,便于Redis工具分组显示。 + */ + protected static final String DICT_PREFIX = "DICT-TABLE:"; + /** + * redisson客户端。 + */ + protected final RedissonClient redissonClient; + /** + * 数据存储对象。 + */ + protected final RMap dataMap; + /** + * 字典值对象类型。 + */ + protected final Class valueClazz; + /** + * 获取字典主键数据的函数对象。 + */ + protected final Function idGetter; + + /** + * 当前对象的构造器函数。 + * + * @param redissonClient Redisson的客户端对象。 + * @param dictionaryName 字典表的名称。等同于redis hash对象的key。 + * @param valueClazz 值对象的Class对象。 + * @param idGetter 获取当前类主键字段值的函数对象。 + * @param 字典主键类型。 + * @param 字典对象类型 + * @return 实例化后的字典内存缓存对象。 + */ + public static RedisDictionaryCache create( + RedissonClient redissonClient, + String dictionaryName, + Class valueClazz, + Function idGetter) { + if (idGetter == null) { + throw new IllegalArgumentException("IdGetter can't be NULL."); + } + return new RedisDictionaryCache<>(redissonClient, dictionaryName, valueClazz, idGetter); + } + + /** + * 构造函数。 + * + * @param redissonClient Redisson的客户端对象。 + * @param dictionaryName 字典表的名称。等同于redis hash对象的key。确保全局唯一。 + * @param valueClazz 值对象的Class对象。 + * @param idGetter 获取当前类主键字段值的函数对象。 + */ + public RedisDictionaryCache( + RedissonClient redissonClient, + String dictionaryName, + Class valueClazz, + Function idGetter) { + this.redissonClient = redissonClient; + this.dataMap = redissonClient.getMap( + DICT_PREFIX + dictionaryName + ApplicationConstant.DICT_CACHE_NAME_SUFFIX); + this.valueClazz = valueClazz; + this.idGetter = idGetter; + } + + protected RMap getDataMap() { + return dataMap; + } + + @Override + public List getAll() { + Collection dataList; + String exceptionMessage; + try { + dataList = getDataMap().readAllValues(); + } catch (Exception e) { + exceptionMessage = String.format( + "[%s::getAll] encountered EXCEPTION [%s] for DICT [%s].", + this.getClass().getSimpleName(), e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + if (dataList == null) { + return new LinkedList<>(); + } + return dataList.stream() + .map(data -> JSON.parseObject(data, valueClazz)) + .collect(Collectors.toCollection(LinkedList::new)); + } + + @Override + public List getInList(Set keys) { + if (CollUtil.isEmpty(keys)) { + return new LinkedList<>(); + } + Collection dataList; + String exceptionMessage; + try { + dataList = getDataMap().getAll(keys).values(); + } catch (Exception e) { + exceptionMessage = String.format( + "[%s::getInList] encountered EXCEPTION [%s] for DICT [%s].", + this.getClass().getSimpleName(), e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + if (dataList == null) { + return new LinkedList<>(); + } + return dataList.stream() + .map(data -> JSON.parseObject(data, valueClazz)) + .collect(Collectors.toCollection(LinkedList::new)); + } + + @Override + public V get(K id) { + if (id == null) { + return null; + } + String data; + String exceptionMessage; + try { + data = getDataMap().get(id); + } catch (Exception e) { + exceptionMessage = String.format( + "[%s::get] encountered EXCEPTION [%s] for DICT [%s].", + this.getClass().getSimpleName(), e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + if (data == null) { + return null; + } + return JSON.parseObject(data, valueClazz); + } + + @Override + public int getCount() { + return getDataMap().size(); + } + + @Override + public void put(K id, V data) { + if (id == null || data == null) { + return; + } + String exceptionMessage; + try { + getDataMap().fastPut(id, JSON.toJSONString(data)); + } catch (Exception e) { + exceptionMessage = String.format( + "[%s::put] encountered EXCEPTION [%s] for DICT [%s].", + this.getClass().getSimpleName(), e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + } + + @Override + public void reload(List dataList, boolean force) { + String exceptionMessage; + try { + // 如果不强制刷新,需要先判断缓存中是否存在数据。 + if (!force && this.getCount() > 0) { + return; + } + Map map = null; + if (CollUtil.isNotEmpty(dataList)) { + map = dataList.stream().collect(Collectors.toMap(idGetter, JSON::toJSONString)); + } + RMap localDataMap = getDataMap(); + localDataMap.clear(); + if (map != null) { + localDataMap.putAll(map); + } + } catch (Exception e) { + exceptionMessage = String.format( + "[%s::reload] encountered EXCEPTION [%s] for DICT [%s].", + this.getClass().getSimpleName(), e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + } + + @Override + public V invalidate(K id) { + if (id == null) { + return null; + } + String data; + String exceptionMessage; + try { + data = getDataMap().remove(id); + } catch (Exception e) { + exceptionMessage = String.format( + "[%s::invalidate] encountered EXCEPTION [%s] for DICT [%s].", + this.getClass().getSimpleName(), e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + if (data == null) { + return null; + } + return JSON.parseObject(data, valueClazz); + } + + @SuppressWarnings("unchecked") + @Override + public void invalidateSet(Set keys) { + if (CollUtil.isEmpty(keys)) { + return; + } + Object[] keyArray = keys.toArray(new Object[]{}); + String exceptionMessage; + try { + getDataMap().fastRemove((K[]) keyArray); + } catch (Exception e) { + exceptionMessage = String.format( + "[%s::invalidateSet] encountered EXCEPTION [%s] for DICT [%s].", + this.getClass().getSimpleName(), e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + } + + @Override + public void invalidateAll() { + String exceptionMessage; + try { + getDataMap().clear(); + } catch (Exception e) { + exceptionMessage = String.format( + "[%s::invalidateAll] encountered EXCEPTION [%s] for DICT [%s].", + this.getClass().getSimpleName(), e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/RedisTreeDictionaryCache.java b/OrangeFormsOpen-MybatisPlus/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/RedisTreeDictionaryCache.java new file mode 100644 index 00000000..de910c61 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/RedisTreeDictionaryCache.java @@ -0,0 +1,224 @@ +package com.orangeforms.common.redis.cache; + +import cn.hutool.core.collection.CollUtil; +import com.alibaba.fastjson.JSON; +import lombok.extern.slf4j.Slf4j; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.exception.RedisCacheAccessException; +import com.google.common.collect.LinkedListMultimap; +import com.google.common.collect.Multimap; +import org.redisson.api.RListMultimap; +import org.redisson.api.RedissonClient; + +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 树形字典数据Redis缓存对象。 + * + * @param 字典表主键类型。 + * @param 字典表对象类型。 + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +public class RedisTreeDictionaryCache extends RedisDictionaryCache { + + /** + * 树形数据存储对象。 + */ + private final RListMultimap allTreeMap; + /** + * 获取字典父主键数据的函数对象。 + */ + protected final Function parentIdGetter; + + /** + * 当前对象的构造器函数。 + * + * @param redissonClient Redisson的客户端对象。 + * @param dictionaryName 字典表的名称。等同于redis hash对象的key。 + * @param valueClazz 值对象的Class对象。 + * @param idGetter 获取当前类主键字段值的函数对象。 + * @param parentIdGetter 获取当前类父主键字段值的函数对象。 + * @param 字典主键类型。 + * @param 字典对象类型 + * @return 实例化后的树形字典内存缓存对象。 + */ + public static RedisTreeDictionaryCache create( + RedissonClient redissonClient, + String dictionaryName, + Class valueClazz, + Function idGetter, + Function parentIdGetter) { + if (idGetter == null) { + throw new IllegalArgumentException("IdGetter can't be NULL."); + } + if (parentIdGetter == null) { + throw new IllegalArgumentException("ParentIdGetter can't be NULL."); + } + return new RedisTreeDictionaryCache<>( + redissonClient, dictionaryName, valueClazz, idGetter, parentIdGetter); + } + + /** + * 构造函数。 + * + * @param redissonClient Redisson的客户端对象。 + * @param dictionaryName 字典表的名称。等同于redis hash对象的key。 + * @param valueClazz 值对象的Class对象。 + * @param idGetter 获取当前类主键字段值的函数对象。 + * @param parentIdGetter 获取当前类父主键字段值的函数对象。 + */ + public RedisTreeDictionaryCache( + RedissonClient redissonClient, + String dictionaryName, + Class valueClazz, + Function idGetter, + Function parentIdGetter) { + super(redissonClient, dictionaryName, valueClazz, idGetter); + this.allTreeMap = redissonClient.getListMultimap( + DICT_PREFIX + dictionaryName + ApplicationConstant.TREE_DICT_CACHE_NAME_SUFFIX); + this.parentIdGetter = parentIdGetter; + } + + @Override + public List getListByParentId(K parentId) { + List dataList; + String exceptionMessage; + try { + dataList = allTreeMap.get(parentId); + } catch (Exception e) { + exceptionMessage = String.format( + "Operation of [RedisTreeDictionaryCache::getListByParentId] encountered EXCEPTION [%s] for DICT [%s].", + e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + if (CollUtil.isEmpty(dataList)) { + return new LinkedList<>(); + } + return dataList.stream().map(data -> JSON.parseObject(data, valueClazz)).collect(Collectors.toList()); + } + + @Override + public void reload(List dataList, boolean force) { + String exceptionMessage; + try { + // 如果不强制刷新,需要先判断缓存中是否存在数据。 + if (!force && this.getCount() > 0) { + return; + } + dataMap.clear(); + allTreeMap.clear(); + if (CollUtil.isEmpty(dataList)) { + return; + } + Map map = dataList.stream().collect(Collectors.toMap(idGetter, JSON::toJSONString)); + // 这里现在本地内存构建树形数据关系,然后再批量存入到Redis缓存。 + // 以便减少与Redis的交互,同时提升运行时效率。 + Multimap treeMap = LinkedListMultimap.create(); + for (V data : dataList) { + treeMap.put(parentIdGetter.apply(data), JSON.toJSONString(data)); + } + dataMap.putAll(map, 3000); + for (Map.Entry> entry : treeMap.asMap().entrySet()) { + allTreeMap.putAll(entry.getKey(), entry.getValue()); + } + } catch (Exception e) { + exceptionMessage = String.format( + "Operation of [RedisDictionaryCache::reload] encountered EXCEPTION [%s] for DICT [%s].", + e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + } + + @Override + public void put(K id, V data) { + if (id == null || data == null) { + return; + } + String stringData = JSON.toJSONString(data); + K parentId = parentIdGetter.apply(data); + String exceptionMessage; + try { + String oldData = dataMap.put(id, stringData); + if (oldData != null) { + allTreeMap.remove(parentId, oldData); + } + allTreeMap.put(parentId, stringData); + } catch (Exception e) { + exceptionMessage = String.format( + "Operation of [RedisTreeDictionaryCache::put] encountered EXCEPTION [%s] for DICT [%s].", + e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + } + + @Override + public V invalidate(K id) { + if (id == null) { + return null; + } + V data = null; + String exceptionMessage; + try { + String stringData = dataMap.remove(id); + if (stringData != null) { + data = JSON.parseObject(stringData, valueClazz); + K parentId = parentIdGetter.apply(data); + allTreeMap.remove(parentId, stringData); + } + } catch (Exception e) { + exceptionMessage = String.format( + "Operation of [RedisTreeDictionaryCache::invalidate] encountered EXCEPTION [%s] for DICT [%s].", + e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + return data; + } + + @Override + public void invalidateSet(Set keys) { + if (CollUtil.isEmpty(keys)) { + return; + } + String exceptionMessage; + try { + keys.forEach(id -> { + if (id != null) { + String stringData = dataMap.remove(id); + if (stringData != null) { + K parentId = parentIdGetter.apply(JSON.parseObject(stringData, valueClazz)); + allTreeMap.remove(parentId, stringData); + } + } + }); + } catch (Exception e) { + exceptionMessage = String.format( + "Operation of [RedisTreeDictionaryCache::invalidateSet] encountered EXCEPTION [%s] for DICT [%s].", + e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + } + + @Override + public void invalidateAll() { + String exceptionMessage; + try { + dataMap.clear(); + allTreeMap.clear(); + } catch (Exception e) { + exceptionMessage = String.format( + "Operation of [RedisTreeDictionaryCache::invalidateAll] encountered EXCEPTION [%s] for DICT [%s].", + e.getClass().getSimpleName(), valueClazz.getSimpleName()); + log.warn(exceptionMessage); + throw new RedisCacheAccessException(exceptionMessage, e); + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/RedissonCacheConfig.java b/OrangeFormsOpen-MybatisPlus/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/RedissonCacheConfig.java new file mode 100644 index 00000000..5210be88 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/RedissonCacheConfig.java @@ -0,0 +1,73 @@ +package com.orangeforms.common.redis.cache; + +import com.google.common.collect.Maps; +import org.redisson.api.RedissonClient; +import org.redisson.spring.cache.CacheConfig; +import org.redisson.spring.cache.RedissonSpringCacheManager; +import org.springframework.cache.CacheManager; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; + +import java.util.Map; + +/** + * 使用Redisson作为Redis的分布式缓存库。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Configuration +@EnableCaching +public class RedissonCacheConfig { + + private static final int DEFAULT_TTL = 3600000; + + /** + * 定义cache名称、超时时长(毫秒)。 + */ + public enum CacheEnum { + /** + * session下上传文件名的缓存(时间是24小时)。 + */ + UPLOAD_FILENAME_CACHE(86400000), + /** + * session的打印访问令牌缓存(时间是1小时)。 + */ + PRINT_ACCESS_TOKEN_CACHE(3600000), + /** + * 缺省全局缓存(时间是24小时)。 + */ + GLOBAL_CACHE(86400000); + + /** + * 缓存的时长(单位:毫秒) + */ + private int ttl = DEFAULT_TTL; + + CacheEnum() { + } + + CacheEnum(int ttl) { + this.ttl = ttl; + } + + public int getTtl() { + return ttl; + } + } + + /** + * 初始化缓存配置。 + */ + @Bean + @Primary + public CacheManager cacheManager(RedissonClient redissonClient) { + Map config = Maps.newHashMap(); + for (CacheEnum c : CacheEnum.values()) { + config.put(c.name(), new CacheConfig(c.getTtl(), 0)); + } + return new RedissonSpringCacheManager(redissonClient, config); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/SessionCacheHelper.java b/OrangeFormsOpen-MybatisPlus/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/SessionCacheHelper.java new file mode 100644 index 00000000..4c613c7c --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-redis/src/main/java/com/orangeforms/common/redis/cache/SessionCacheHelper.java @@ -0,0 +1,179 @@ +package com.orangeforms.common.redis.cache; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.text.StrFormatter; +import com.alibaba.fastjson.JSON; +import com.orangeforms.common.core.object.MyPrintInfo; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.exception.MyRuntimeException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * Session数据缓存辅助类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@SuppressWarnings("unchecked") +@Component +public class SessionCacheHelper { + + @Autowired + private CacheManager cacheManager; + + private static final String NO_CACHE_FORMAT_MSG = "No redisson cache [{}]!"; + + /** + * 缓存当前session内,上传过的文件名。 + * + * @param filename 通常是本地存储的文件名,而不是上传时的原始文件名。 + */ + public void putSessionUploadFile(String filename) { + if (filename != null) { + Set sessionUploadFileSet = null; + Cache cache = cacheManager.getCache(RedissonCacheConfig.CacheEnum.UPLOAD_FILENAME_CACHE.name()); + if (cache == null) { + String msg = StrFormatter.format(NO_CACHE_FORMAT_MSG, + RedissonCacheConfig.CacheEnum.UPLOAD_FILENAME_CACHE.name()); + throw new MyRuntimeException(msg); + } + Cache.ValueWrapper valueWrapper = cache.get(TokenData.takeFromRequest().getSessionId()); + if (valueWrapper != null) { + sessionUploadFileSet = (Set) valueWrapper.get(); + } + if (sessionUploadFileSet == null) { + sessionUploadFileSet = new HashSet<>(); + } + sessionUploadFileSet.add(filename); + cache.put(TokenData.takeFromRequest().getSessionId(), sessionUploadFileSet); + } + } + + /** + * 缓存当前Session可以下载的文件集合。 + * + * @param filenameSet 后台服务本地存储的文件名,而不是上传时的原始文件名。 + */ + public void putSessionDownloadableFileNameSet(Set filenameSet) { + if (CollUtil.isEmpty(filenameSet)) { + return; + } + Set sessionUploadFileSet = null; + Cache cache = cacheManager.getCache(RedissonCacheConfig.CacheEnum.UPLOAD_FILENAME_CACHE.name()); + if (cache == null) { + throw new MyRuntimeException(StrFormatter.format(NO_CACHE_FORMAT_MSG, + RedissonCacheConfig.CacheEnum.UPLOAD_FILENAME_CACHE.name())); + } + Cache.ValueWrapper valueWrapper = cache.get(TokenData.takeFromRequest().getSessionId()); + if (valueWrapper != null) { + sessionUploadFileSet = (Set) valueWrapper.get(); + } + if (sessionUploadFileSet == null) { + sessionUploadFileSet = new HashSet<>(); + } + sessionUploadFileSet.addAll(filenameSet); + cache.put(TokenData.takeFromRequest().getSessionId(), sessionUploadFileSet); + } + + /** + * 判断参数中的文件名,是否有当前session上传。 + * + * @param filename 通常是本地存储的文件名,而不是上传时的原始文件名。 + * @return true表示该文件是由当前session上传并存储在本地的,否则false。 + */ + public boolean existSessionUploadFile(String filename) { + if (filename == null) { + return false; + } + Cache cache = cacheManager.getCache(RedissonCacheConfig.CacheEnum.UPLOAD_FILENAME_CACHE.name()); + if (cache == null) { + String msg = StrFormatter.format(NO_CACHE_FORMAT_MSG, + RedissonCacheConfig.CacheEnum.UPLOAD_FILENAME_CACHE.name()); + throw new MyRuntimeException(msg); + } + Cache.ValueWrapper valueWrapper = cache.get(TokenData.takeFromRequest().getSessionId()); + if (valueWrapper == null) { + return false; + } + Object cachedData = valueWrapper.get(); + if (cachedData == null) { + return false; + } + return ((Set) cachedData).contains(filename); + } + + /** + * 缓存当前session内,可打印的安全令牌。 + * + * @param token 打印安全令牌。 + * @param printInfo 打印参数信息。 + */ + public void putSessionPrintTokenAndInfo(String token, MyPrintInfo printInfo) { + Cache cache = cacheManager.getCache(RedissonCacheConfig.CacheEnum.PRINT_ACCESS_TOKEN_CACHE.name()); + if (cache == null) { + String msg = StrFormatter.format(NO_CACHE_FORMAT_MSG, + RedissonCacheConfig.CacheEnum.PRINT_ACCESS_TOKEN_CACHE.name()); + throw new MyRuntimeException(msg); + } + Map sessionPrintTokenMap = null; + Cache.ValueWrapper valueWrapper = cache.get(TokenData.takeFromRequest().getSessionId()); + if (valueWrapper != null) { + sessionPrintTokenMap = (Map) valueWrapper.get(); + } + if (sessionPrintTokenMap == null) { + sessionPrintTokenMap = new HashMap<>(4); + } + sessionPrintTokenMap.put(token, JSON.toJSONString(printInfo)); + cache.put(TokenData.takeFromRequest().getSessionId(), sessionPrintTokenMap); + } + + /** + * 获取当前session中,指定打印令牌所关联的打印信息。 + * + * @param token 打印安全令牌。 + * @return 当前session中,指定打印令牌所关联的打印信息。不存在返回null。 + */ + public MyPrintInfo getSessionPrintInfoByToken(String token) { + Cache cache = cacheManager.getCache(RedissonCacheConfig.CacheEnum.PRINT_ACCESS_TOKEN_CACHE.name()); + if (cache == null) { + String msg = StrFormatter.format(NO_CACHE_FORMAT_MSG, + RedissonCacheConfig.CacheEnum.PRINT_ACCESS_TOKEN_CACHE.name()); + throw new MyRuntimeException(msg); + } + Cache.ValueWrapper valueWrapper = cache.get(TokenData.takeFromRequest().getSessionId()); + if (valueWrapper == null) { + return null; + } + Object cachedData = valueWrapper.get(); + if (cachedData == null) { + return null; + } + String data = ((Map) cachedData).get(token); + if (data == null) { + return null; + } + return JSON.parseObject(data, MyPrintInfo.class); + } + + /** + * 清除当前session的所有缓存数据。 + * + * @param sessionId 当前会话的SessionId。 + */ + public void removeAllSessionCache(String sessionId) { + for (RedissonCacheConfig.CacheEnum c : RedissonCacheConfig.CacheEnum.values()) { + Cache cache = cacheManager.getCache(c.name()); + if (cache != null) { + cache.evict(sessionId); + } + } + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-redis/src/main/java/com/orangeforms/common/redis/config/RedissonConfig.java b/OrangeFormsOpen-MybatisPlus/common/common-redis/src/main/java/com/orangeforms/common/redis/config/RedissonConfig.java new file mode 100644 index 00000000..fecec4b9 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-redis/src/main/java/com/orangeforms/common/redis/config/RedissonConfig.java @@ -0,0 +1,105 @@ +package com.orangeforms.common.redis.config; + +import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.util.StrUtil; +import com.orangeforms.common.core.exception.InvalidRedisModeException; +import org.redisson.Redisson; +import org.redisson.api.RedissonClient; +import org.redisson.config.Config; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Redisson配置类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Configuration +@ConditionalOnProperty(name = "common-redis.redisson.enabled", havingValue = "true") +public class RedissonConfig { + + @Value("${common-redis.redisson.lockWatchdogTimeout}") + private Integer lockWatchdogTimeout; + + @Value("${common-redis.redisson.mode}") + private String mode; + + /** + * 仅仅用于sentinel模式。 + */ + @Value("${common-redis.redisson.masterName:}") + private String masterName; + + @Value("${common-redis.redisson.address}") + private String address; + + @Value("${common-redis.redisson.timeout}") + private Integer timeout; + + @Value("${common-redis.redisson.password:}") + private String password; + + @Value("${common-redis.redisson.pool.poolSize}") + private Integer poolSize; + + @Value("${common-redis.redisson.pool.minIdle}") + private Integer minIdle; + + @Bean + public RedissonClient redissonClient() { + if (StrUtil.isBlank(password)) { + password = null; + } + Config config = new Config(); + if ("single".equals(mode)) { + config.setLockWatchdogTimeout(lockWatchdogTimeout) + .useSingleServer() + .setPassword(password) + .setAddress(address) + .setConnectionPoolSize(poolSize) + .setConnectionMinimumIdleSize(minIdle) + .setConnectTimeout(timeout); + } else if ("cluster".equals(mode)) { + String[] clusterAddresses = StrUtil.splitToArray(address, ','); + config.setLockWatchdogTimeout(lockWatchdogTimeout) + .useClusterServers() + .setPassword(password) + .addNodeAddress(clusterAddresses) + .setConnectTimeout(timeout) + .setMasterConnectionPoolSize(poolSize) + .setMasterConnectionMinimumIdleSize(minIdle); + } else if ("sentinel".equals(mode)) { + String[] sentinelAddresses = StrUtil.splitToArray(address, ','); + config.setLockWatchdogTimeout(lockWatchdogTimeout) + .useSentinelServers() + .setPassword(password) + .setMasterName(masterName) + .addSentinelAddress(sentinelAddresses) + .setConnectTimeout(timeout) + .setMasterConnectionPoolSize(poolSize) + .setMasterConnectionMinimumIdleSize(minIdle); + } else if ("master-slave".equals(mode)) { + String[] masterSlaveAddresses = StrUtil.splitToArray(address, ','); + if (masterSlaveAddresses.length == 1) { + throw new IllegalArgumentException( + "redis.redisson.address MUST have multiple redis addresses for master-slave mode."); + } + String[] slaveAddresses = new String[masterSlaveAddresses.length - 1]; + ArrayUtil.copy(masterSlaveAddresses, 1, slaveAddresses, 0, slaveAddresses.length); + config.setLockWatchdogTimeout(lockWatchdogTimeout) + .useMasterSlaveServers() + .setPassword(password) + .setMasterAddress(masterSlaveAddresses[0]) + .addSlaveAddress(slaveAddresses) + .setConnectTimeout(timeout) + .setMasterConnectionPoolSize(poolSize) + .setMasterConnectionMinimumIdleSize(minIdle); + } else { + throw new InvalidRedisModeException(mode); + } + return Redisson.create(config); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-redis/src/main/java/com/orangeforms/common/redis/util/CommonRedisUtil.java b/OrangeFormsOpen-MybatisPlus/common/common-redis/src/main/java/com/orangeforms/common/redis/util/CommonRedisUtil.java new file mode 100644 index 00000000..0ffd4414 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-redis/src/main/java/com/orangeforms/common/redis/util/CommonRedisUtil.java @@ -0,0 +1,217 @@ +package com.orangeforms.common.redis.util; + +import cn.hutool.core.date.DateField; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.EnumUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import lombok.extern.slf4j.Slf4j; +import org.redisson.api.RAtomicLong; +import org.redisson.api.RBucket; +import org.redisson.api.RedissonClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.io.Serializable; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; + +/** + * Redis的常用工具方法。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Slf4j +@Component +public class CommonRedisUtil { + + @Autowired + private RedissonClient redissonClient; + + private static final Integer DEFAULT_EXPIRE_SECOND = 300; + + /** + * 计算流水号前缀部分。 + * + * @param prefix 前缀字符串。 + * @param precisionTo 精确到的时间单元,目前仅仅支持 YEAR/MONTH/DAYS/HOURS/MINUTES/SECONDS。 + * @param middle 日期和流水号之间的字符串。 + * @return 返回计算后的前缀部分。 + */ + public String calculateTransIdPrefix(String prefix, String precisionTo, String middle) { + String key = prefix; + if (key == null) { + key = ""; + } + DateTime dateTime = new DateTime(); + String fmt = "yyyy"; + String fmt2 = fmt + "MMddHH"; + switch (precisionTo) { + case "YEAR": + break; + case "MONTH": + fmt += "MM"; + break; + case "DAYS": + fmt = fmt + "MMdd"; + break; + case "HOURS": + fmt = fmt2; + break; + case "MINUTES": + fmt = fmt2 + "mm"; + break; + case "SECONDS": + fmt = fmt2 + "mmss"; + break; + default: + throw new UnsupportedOperationException("Only Support YEAR/MONTH/DAYS/HOURS/MINUTES/SECONDS"); + } + key += dateTime.toString(fmt); + return middle != null ? key + middle : key; + } + + /** + * 生成基于时间的流水号方法。 + * + * @param prefix 前缀字符串。 + * @param precisionTo 精确到的时间单元,目前仅仅支持 YEAR/MONTH/DAYS/HOURS/MINUTES/SECONDS。 + * @param middle 日期和流水号之间的字符串。 + * @param idWidth 计算出的流水号宽度,前面补充0。比如idWidth = 3, 输出值为 005/012/123。 + * 需要注意的是,流水号值超出idWidth指定宽度,低位会被截取。 + * @return 基于时间的流水号方法。 + */ + public String generateTransId(String prefix, String precisionTo, String middle, int idWidth) { + TimeUnit unit = EnumUtil.fromString(TimeUnit.class, precisionTo, null); + int unitCount = 1; + if (unit == null) { + unit = TimeUnit.DAYS; + DateTime now = DateTime.now(); + if (StrUtil.equals(precisionTo, "MONTH")) { + DateTime endOfMonthDay = DateUtil.endOfMonth(now); + unitCount = endOfMonthDay.getField(DateField.DAY_OF_MONTH) - now.getField(DateField.DAY_OF_MONTH) + 1; + } else if (StrUtil.equals(precisionTo, "YEAR")) { + DateTime endOfYearDay = DateUtil.endOfYear(now); + unitCount = endOfYearDay.getField(DateField.DAY_OF_YEAR) - now.getField(DateField.DAY_OF_YEAR) + 1; + } + } + String key = this.calculateTransIdPrefix(prefix, precisionTo, middle); + RAtomicLong atomicLong = redissonClient.getAtomicLong(key); + long value = atomicLong.incrementAndGet(); + if (value == 1L) { + atomicLong.expire(unitCount, unit); + } + return key + StrUtil.padPre(String.valueOf(value), idWidth, "0"); + } + + /** + * 为指定的键设置流水号的初始值。 + * + * @param key 指定的键。 + * @param initalValue 初始值。 + */ + public void initTransId(String key, Long initalValue) { + RAtomicLong atomicLong = redissonClient.getAtomicLong(key); + atomicLong.set(initalValue); + } + + /** + * 从缓存中获取数据。如果缓存中不存在则从执行指定的方法获取数据,并将得到的数据同步到缓存。 + * + * @param key 缓存的键。 + * @param id 数据Id。 + * @param f 获取数据的方法。 + * @param clazz 数据对象类型。 + * @return 数据对象。 + */ + public M getFromCache(String key, Serializable id, Function f, Class clazz) { + return this.getFromCache(key, id, f, clazz, null); + } + + /** + * 从缓存中获取数据。如果缓存中不存在则从执行指定的方法获取数据,并将得到的数据同步到缓存。 + * + * @param key 缓存的键。 + * @param filter mybatis plus的过滤对象。 + * @param f 获取数据的方法。 + * @param clazz 数据对象类型。 + * @return 数据对象。 + */ + public N getFromCacheWithQueryWrapper( + String key, LambdaQueryWrapper filter, Function, N> f, Class clazz) { + N m; + RBucket bucket = redissonClient.getBucket(key); + if (!bucket.isExists()) { + m = f.apply(filter); + if (m != null) { + bucket.set(JSON.toJSONString(m), DEFAULT_EXPIRE_SECOND, TimeUnit.SECONDS); + } + } else { + m = JSON.parseObject(bucket.get(), clazz); + } + return m; + } + + /** + * 从缓存中获取数据。如果缓存中不存在则从执行指定的方法获取数据,并将得到的数据同步到缓存。 + * + * @param key 缓存的键。 + * @param filter 过滤对象。 + * @param f 获取数据的方法。 + * @param clazz 数据对象类型。 + * @return 数据对象。 + */ + public N getFromCache(String key, M filter, Function f, Class clazz) { + N m; + RBucket bucket = redissonClient.getBucket(key); + if (!bucket.isExists()) { + m = f.apply(filter); + if (m != null) { + bucket.set(JSON.toJSONString(m), DEFAULT_EXPIRE_SECOND, TimeUnit.SECONDS); + } + } else { + m = JSON.parseObject(bucket.get(), clazz); + } + return m; + } + + /** + * 从缓存中获取数据。如果缓存中不存在则从执行指定的方法获取数据,并将得到的数据同步到缓存。 + * + * @param key 缓存的键。 + * @param id 数据Id。 + * @param f 获取数据的方法。 + * @param clazz 数据对象类型。 + * @param seconds 过期秒数。 + * @return 数据对象。 + */ + public M getFromCache( + String key, Serializable id, Function f, Class clazz, Integer seconds) { + M m; + RBucket bucket = redissonClient.getBucket(key); + if (!bucket.isExists()) { + m = f.apply(id); + if (m != null) { + if (seconds == null) { + seconds = DEFAULT_EXPIRE_SECOND; + } + bucket.set(JSON.toJSONString(m), seconds, TimeUnit.SECONDS); + } + } else { + m = JSON.parseObject(bucket.get(), clazz); + } + return m; + } + + /** + * 移除指定Key。 + * + * @param key 键名。 + */ + public void evictFormCache(String key) { + redissonClient.getBucket(key).delete(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-redis/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/OrangeFormsOpen-MybatisPlus/common/common-redis/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..1cac49fc --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-redis/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.orangeforms.common.redis.config.RedissonConfig \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-satoken/pom.xml b/OrangeFormsOpen-MybatisPlus/common/common-satoken/pom.xml new file mode 100644 index 00000000..d2b782dd --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-satoken/pom.xml @@ -0,0 +1,49 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-satoken + 1.0.0 + common-satoken + jar + + 1.37.0 + + + + + cn.dev33 + sa-token-spring-boot3-starter + ${sa-token.version} + + + + cn.dev33 + sa-token-redis-fastjson + ${sa-token.version} + + + + cn.dev33 + sa-token-alone-redis + ${sa-token.version} + + + + org.apache.commons + commons-pool2 + + + com.orangeforms + common-redis + 1.0.0 + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-satoken/src/main/java/com/orangeforms/common/satoken/annotation/SaTokenDenyAuth.java b/OrangeFormsOpen-MybatisPlus/common/common-satoken/src/main/java/com/orangeforms/common/satoken/annotation/SaTokenDenyAuth.java new file mode 100644 index 00000000..8838858f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-satoken/src/main/java/com/orangeforms/common/satoken/annotation/SaTokenDenyAuth.java @@ -0,0 +1,16 @@ +package com.orangeforms.common.satoken.annotation; + +import java.lang.annotation.*; + +/** + * 所有标记该注解的接口,不能使用SaToken进行权限验证。 + * 必须通过橙单自身的动态验证完成,即基于URL的验证。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface SaTokenDenyAuth { +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-satoken/src/main/java/com/orangeforms/common/satoken/listener/SaTokenPermCodeScanListener.java b/OrangeFormsOpen-MybatisPlus/common/common-satoken/src/main/java/com/orangeforms/common/satoken/listener/SaTokenPermCodeScanListener.java new file mode 100644 index 00000000..662bd7e7 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-satoken/src/main/java/com/orangeforms/common/satoken/listener/SaTokenPermCodeScanListener.java @@ -0,0 +1,26 @@ +package com.orangeforms.common.satoken.listener; + +import com.orangeforms.common.satoken.util.SaTokenUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.ApplicationListener; +import org.springframework.lang.NonNull; +import org.springframework.stereotype.Component; + +/** + * 后台服务启动的时候扫描服务中标有权限字,并同步到Redis,以供接口查询所有使用到的权限字。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class SaTokenPermCodeScanListener implements ApplicationListener { + + @Autowired + private SaTokenUtil saTokenUtil; + + @Override + public void onApplicationEvent(@NonNull ApplicationReadyEvent event) { + saTokenUtil.collectPermCodes(event); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-satoken/src/main/java/com/orangeforms/common/satoken/util/SaTokenUtil.java b/OrangeFormsOpen-MybatisPlus/common/common-satoken/src/main/java/com/orangeforms/common/satoken/util/SaTokenUtil.java new file mode 100644 index 00000000..750c3a4a --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-satoken/src/main/java/com/orangeforms/common/satoken/util/SaTokenUtil.java @@ -0,0 +1,283 @@ +package com.orangeforms.common.satoken.util; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.dev33.satoken.annotation.SaIgnore; +import cn.dev33.satoken.exception.SaTokenException; +import cn.dev33.satoken.session.SaSession; +import cn.dev33.satoken.stp.StpUtil; +import cn.dev33.satoken.strategy.SaStrategy; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.ReflectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.orangeforms.common.core.cache.CacheConfig; +import com.orangeforms.common.core.constant.ApplicationConstant; +import com.orangeforms.common.core.constant.ErrorCodeEnum; +import com.orangeforms.common.core.object.LoginUserInfo; +import com.orangeforms.common.core.object.ResponseResult; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.AopTargetUtil; +import com.orangeforms.common.core.util.MyCommonUtil; +import com.orangeforms.common.core.util.RedisKeyUtil; +import com.orangeforms.common.satoken.annotation.SaTokenDenyAuth; +import org.redisson.api.RMap; +import org.redisson.api.RSet; +import org.redisson.api.RTopic; +import org.redisson.api.RedissonClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.stereotype.Component; +import org.springframework.util.Assert; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.method.HandlerMethod; + +import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import java.lang.reflect.Method; +import java.util.*; + +/** + * 通用工具方法。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class SaTokenUtil { + + @Autowired + private RedissonClient redissonClient; + @Resource(name = "caffeineCacheManager") + private CacheManager cacheManager; + + @Value("${spring.application.name}") + private String applicationName; + + public static final String SA_TOKEN_PERM_CODES_KEY = "SaTokenPermCodes"; + public static final String SA_TOKEN_PERM_CODES_PUBLISH_TOPIC = "SaTokenPermCodesTopic"; + + /** + * 处理免验证接口。目前仅用于微服务的业务服务。 + */ + public void handleNoAuthIntercept() { + if (!StpUtil.isLogin()) { + return; + } + SaSession session = StpUtil.getTokenSession(); + if (session != null) { + TokenData tokenData = JSON.toJavaObject( + (JSONObject) session.get(TokenData.REQUEST_ATTRIBUTE_NAME), TokenData.class); + TokenData.addToRequest(tokenData); + tokenData.setToken(session.getToken()); + } + } + + /** + * 处理权限验证,通常在拦截器中调用。用于微服务中业务服务。 + * + * @param request 当前请求。 + * @param handler 拦截器中的处理器。 + * @return 拦截验证处理结果。 + */ + public ResponseResult handleAuthInterceptEx(HttpServletRequest request, Object handler) { + String appCode = MyCommonUtil.getAppCodeFromRequest(); + if (StrUtil.isNotBlank(appCode)) { + String token = request.getHeader(TokenData.REQUEST_ATTRIBUTE_NAME); + if (StrUtil.isBlank(token)) { + String errorMessage = "第三方登录没有包含Token信息!"; + return ResponseResult.error( + HttpServletResponse.SC_UNAUTHORIZED, ErrorCodeEnum.UNAUTHORIZED_LOGIN, errorMessage); + } + TokenData tokenData = JSON.parseObject(token, TokenData.class); + TokenData.addToRequest(tokenData); + return ResponseResult.success(); + } + String dontAuth = request.getHeader(ApplicationConstant.HTTP_HEADER_DONT_AUTH); + if (BooleanUtil.toBoolean(dontAuth)) { + this.handleNoAuthIntercept(); + return ResponseResult.success(); + } + return this.handleAuthIntercept(request, handler); + } + + /** + * 处理权限验证,通常在拦截器中调用。通常用于单体服务。 + * + * @param request 当前请求。 + * @param handler 拦截器中的处理器。 + * @return 拦截验证处理结果。 + */ + public ResponseResult handleAuthIntercept(HttpServletRequest request, Object handler) { + if (!(handler instanceof HandlerMethod)) { + return ResponseResult.success(); + } + Method method = ((HandlerMethod) handler).getMethod(); + String errorMessage; + //如果没有登录则直接交给satoken注解去验证。 + if (!StpUtil.isLogin()) { + // 如果此 Method 或其所属 Class 标注了 @SaIgnore,则忽略掉鉴权 + if (BooleanUtil.isTrue(SaStrategy.instance.isAnnotationPresent.apply(method, SaIgnore.class))) { + return ResponseResult.success(); + } + errorMessage = "非免登录接口必须包含Token信息!"; + return ResponseResult.error(HttpServletResponse.SC_UNAUTHORIZED, ErrorCodeEnum.UNAUTHORIZED_LOGIN, errorMessage); + } + //对于已经登录的用户一定存在session对象。 + SaSession session = StpUtil.getTokenSession(); + if (session == null) { + errorMessage = "用户会话已过期,请重新登录!"; + return ResponseResult.error(HttpServletResponse.SC_UNAUTHORIZED, ErrorCodeEnum.UNAUTHORIZED_LOGIN, errorMessage); + } + TokenData tokenData = JSON.toJavaObject( + (JSONObject) session.get(TokenData.REQUEST_ATTRIBUTE_NAME), TokenData.class); + TokenData.addToRequest(tokenData); + //将最初前端请求使用的token数据赋值给TokenData对象,以便于再次调用其他API接口时直接使用。 + tokenData.setToken(session.getToken()); + //如果是管理员可以直接跳过验证了。 + //基于橙单内部的权限规则优先验证,主要用于内部的白名单接口,以及在线表单和工作流那些动态接口的权限验证。 + if (Boolean.TRUE.equals(tokenData.getIsAdmin()) + || this.hasPermission(tokenData.getSessionId(), request.getRequestURI())) { + return ResponseResult.success(); + } + //对于应由白名单鉴权的接口,都会添加SaTokenDenyAuth注解,因此这里需要判断一下, + //对于此类接口无需SaToken验证了,而是直接返回未授权,因为基于url的鉴权在上面的hasPermission中完成了。 + if (method.getAnnotation(SaTokenDenyAuth.class) != null) { + return ResponseResult.error(HttpServletResponse.SC_UNAUTHORIZED, ErrorCodeEnum.NO_OPERATION_PERMISSION); + } + try { + //执行基于stoken的注解鉴权。 + SaStrategy.instance.checkMethodAnnotation.accept(method); + } catch (SaTokenException e) { + return ResponseResult.error(HttpServletResponse.SC_UNAUTHORIZED, ErrorCodeEnum.NO_OPERATION_PERMISSION); + } + return ResponseResult.success(); + } + + /** + * 构建satoken的登录Id。 + * + * @return 拼接后的完整登录Id。 + */ + public static String makeLoginId(LoginUserInfo userInfo) { + StringBuilder sb = new StringBuilder(128); + sb.append("SATOKEN_LOGIN:"); + if (userInfo.getTenantId() != null) { + sb.append(userInfo.getTenantId()).append(":"); + } + sb.append(userInfo.getLoginName()).append(":").append(userInfo.getUserId()); + return sb.toString(); + } + + /** + * 获取所有的权限字列表数据。 + * + * @return 所有的权限字列表数据。 + */ + public List getAllPermCodes() { + RMap> permCodeMap = redissonClient.getMap(SA_TOKEN_PERM_CODES_KEY); + if (!permCodeMap.isExists()) { + return CollUtil.empty(String.class); + } + Set permCodeSet = new TreeSet<>(); + for (RMap.Entry> entry : permCodeMap.entrySet()) { + CollUtil.addAll(permCodeSet, permCodeMap.get(entry.getKey())); + } + return new LinkedList<>(permCodeSet); + } + + /** + * 获取所有租户运营应用的权限字列表数据。 + * + * @return 所有的权限字列表数据。 + */ + public List getAllTenantPermCodes() { + RMap> permCodeMap = redissonClient.getMap(SA_TOKEN_PERM_CODES_KEY); + if (!permCodeMap.isExists()) { + return CollUtil.empty(String.class); + } + Set permCodeSet = new TreeSet<>(); + for (RMap.Entry> entry : permCodeMap.entrySet()) { + if (!entry.getKey().equals(ApplicationConstant.TENANT_ADMIN_APP_NAME)) { + CollUtil.addAll(permCodeSet, permCodeMap.get(entry.getKey())); + } + } + return new LinkedList<>(permCodeSet); + } + + /** + * 获取所有租户管理应用的权限字列表数据。 + * + * @return 所有的权限字列表数据。 + */ + public List getAllTenantAdminPermCodes() { + RMap> permCodeMap = redissonClient.getMap(SA_TOKEN_PERM_CODES_KEY); + if (!permCodeMap.isExists()) { + return CollUtil.empty(String.class); + } + Set permCodeSet = new TreeSet<>(); + for (RMap.Entry> entry : permCodeMap.entrySet()) { + if (entry.getKey().equals(ApplicationConstant.TENANT_ADMIN_APP_NAME)) { + CollUtil.addAll(permCodeSet, permCodeMap.get(entry.getKey())); + } + } + return new LinkedList<>(permCodeSet); + } + + /** + * 收集当前服务的SaToken权限字列表,并缓存到Redis,便于统一查询。 + * + * @param event 服务应用的启动事件。 + */ + public void collectPermCodes(ApplicationReadyEvent event) { + redissonClient.getTopic(SA_TOKEN_PERM_CODES_PUBLISH_TOPIC) + .addListener(String.class, (channel, message) -> this.doCollect(event)); + this.doCollect(event); + } + + /** + * 向所有已启动的服务发送权限字同步事件。 + */ + public void publishCollectPermCodes() { + RTopic topic = redissonClient.getTopic(SA_TOKEN_PERM_CODES_PUBLISH_TOPIC); + topic.publish(null); + } + + private void doCollect(ApplicationReadyEvent event) { + Map controllerMap = event.getApplicationContext().getBeansWithAnnotation(RestController.class); + Set permCodes = new HashSet<>(); + for (Map.Entry entry : controllerMap.entrySet()) { + Object targetBean = AopTargetUtil.getTarget(entry.getValue()); + Method[] methods = ReflectUtil.getPublicMethods(targetBean.getClass()); + Arrays.stream(methods) + .map(m -> m.getAnnotation(SaCheckPermission.class)) + .filter(Objects::nonNull) + .forEach(anno -> Collections.addAll(permCodes, anno.value())); + } + RMap> permCodeMap = redissonClient.getMap(SA_TOKEN_PERM_CODES_KEY); + permCodeMap.put(applicationName, permCodes); + } + + @SuppressWarnings("unchecked") + private boolean hasPermission(String sessionId, String url) { + // 为了提升效率,先检索Caffeine的一级缓存,如果不存在,再检索Redis的二级缓存,并将结果存入一级缓存。 + Set localPermSet; + String permKey = RedisKeyUtil.makeSessionPermIdKey(sessionId); + Cache cache = cacheManager.getCache(CacheConfig.CacheEnum.USER_PERMISSION_CACHE.name()); + Assert.notNull(cache, "Cache USER_PERMISSION_CACHE can't be NULL."); + Cache.ValueWrapper wrapper = cache.get(permKey); + if (wrapper == null) { + RSet permSet = redissonClient.getSet(permKey); + localPermSet = permSet.readAll(); + cache.put(permKey, localPermSet); + } else { + localPermSet = (Set) wrapper.get(); + } + return CollUtil.contains(localPermSet, url); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-satoken/src/main/java/com/orangeforms/common/satoken/util/StpInterfaceImpl.java b/OrangeFormsOpen-MybatisPlus/common/common-satoken/src/main/java/com/orangeforms/common/satoken/util/StpInterfaceImpl.java new file mode 100644 index 00000000..d0339da9 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-satoken/src/main/java/com/orangeforms/common/satoken/util/StpInterfaceImpl.java @@ -0,0 +1,62 @@ +package com.orangeforms.common.satoken.util; + +import cn.dev33.satoken.stp.StpInterface; +import com.orangeforms.common.core.cache.CacheConfig; +import com.orangeforms.common.core.object.TokenData; +import com.orangeforms.common.core.util.RedisKeyUtil; +import org.redisson.api.RSet; +import org.redisson.api.RedissonClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.stereotype.Component; +import org.springframework.util.Assert; + +import jakarta.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** + * 自定义权限加载接口实现类 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class StpInterfaceImpl implements StpInterface { + + @Autowired + private RedissonClient redissonClient; + @Resource(name = "caffeineCacheManager") + private CacheManager cacheManager; + + /** + * 返回一个账号所拥有的权限码集合 + */ + @SuppressWarnings("unchecked") + @Override + public List getPermissionList(Object loginId, String loginType) { + TokenData tokenData = TokenData.takeFromRequest(); + String permCodeKey = RedisKeyUtil.makeSessionPermCodeKey(tokenData.getSessionId()); + Cache cache = cacheManager.getCache(CacheConfig.CacheEnum.USER_PERM_CODE_CACHE.name()); + Assert.notNull(cache, "Cache USER_PERM_CODE_CACHE can't be NULL"); + Cache.ValueWrapper wrapper = cache.get(permCodeKey); + if (wrapper != null) { + return (List) wrapper.get(); + } + RSet permCodeSet = redissonClient.getSet(permCodeKey); + Set localPermCodeSet = permCodeSet.readAll(); + List permCodeList = new ArrayList<>(localPermCodeSet); + cache.put(permCodeKey, permCodeList); + return permCodeList; + } + + /** + * 返回一个账号所拥有的角色标识集合 (权限与角色可分开校验) + */ + @Override + public List getRoleList(Object loginId, String loginType) { + return new ArrayList<>(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-sequence/pom.xml b/OrangeFormsOpen-MybatisPlus/common/common-sequence/pom.xml new file mode 100644 index 00000000..36502af3 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-sequence/pom.xml @@ -0,0 +1,24 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-sequence + 1.0.0 + common-sequence + jar + + + + com.orangeforms + common-core + 1.0.0 + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-sequence/src/main/java/com/orangeforms/common/sequence/config/IdGeneratorAutoConfig.java b/OrangeFormsOpen-MybatisPlus/common/common-sequence/src/main/java/com/orangeforms/common/sequence/config/IdGeneratorAutoConfig.java new file mode 100644 index 00000000..327ce435 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-sequence/src/main/java/com/orangeforms/common/sequence/config/IdGeneratorAutoConfig.java @@ -0,0 +1,14 @@ +package com.orangeforms.common.sequence.config; + +import org.springframework.boot.context.properties.EnableConfigurationProperties; + +/** + * common-sequence模块的自动配置引导类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EnableConfigurationProperties({IdGeneratorProperties.class}) +public class IdGeneratorAutoConfig { + +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-sequence/src/main/java/com/orangeforms/common/sequence/config/IdGeneratorProperties.java b/OrangeFormsOpen-MybatisPlus/common/common-sequence/src/main/java/com/orangeforms/common/sequence/config/IdGeneratorProperties.java new file mode 100644 index 00000000..f20076d8 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-sequence/src/main/java/com/orangeforms/common/sequence/config/IdGeneratorProperties.java @@ -0,0 +1,20 @@ +package com.orangeforms.common.sequence.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * common-sequence模块的配置类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ConfigurationProperties(prefix = "common-sequence") +public class IdGeneratorProperties { + + /** + * 基础版生成器所需的WorkNode参数值。仅当advanceIdGenerator为false时生效。 + */ + private Integer snowflakeWorkNode = 1; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-sequence/src/main/java/com/orangeforms/common/sequence/generator/BasicIdGenerator.java b/OrangeFormsOpen-MybatisPlus/common/common-sequence/src/main/java/com/orangeforms/common/sequence/generator/BasicIdGenerator.java new file mode 100644 index 00000000..fccf75de --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-sequence/src/main/java/com/orangeforms/common/sequence/generator/BasicIdGenerator.java @@ -0,0 +1,47 @@ +package com.orangeforms.common.sequence.generator; + +import cn.hutool.core.lang.Snowflake; + +/** + * 基础版snowflake计算工具类。 + * 和SnowflakeIdGenerator相比,相同点是均为基于Snowflake算法的生成器。不同点在于当前类的 + * WorkNodeId是通过配置文件静态指定的。而SnowflakeIdGenerator的WorkNodeId是由zk生成的。 + * + * @author Jerry + * @date 2024-07-02 + */ +public class BasicIdGenerator implements MyIdGenerator { + + private final Snowflake snowflake; + + /** + * 构造函数。 + * + * @param workNode 工作节点。 + */ + public BasicIdGenerator(Integer workNode) { + snowflake = new Snowflake(workNode, 0); + } + + /** + * 获取基于Snowflake算法的数值型Id。 + * 由于底层实现为synchronized方法,因此计算过程串行化,且线程安全。 + * + * @return 计算后的全局唯一Id。 + */ + @Override + public long nextLongId() { + return this.snowflake.nextId(); + } + + /** + * 获取基于Snowflake算法的字符串Id。 + * 由于底层实现为synchronized方法,因此计算过程串行化,且线程安全。 + * + * @return 计算后的全局唯一Id。 + */ + @Override + public String nextStringId() { + return this.snowflake.nextIdStr(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-sequence/src/main/java/com/orangeforms/common/sequence/generator/MyIdGenerator.java b/OrangeFormsOpen-MybatisPlus/common/common-sequence/src/main/java/com/orangeforms/common/sequence/generator/MyIdGenerator.java new file mode 100644 index 00000000..209d3c8e --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-sequence/src/main/java/com/orangeforms/common/sequence/generator/MyIdGenerator.java @@ -0,0 +1,24 @@ +package com.orangeforms.common.sequence.generator; + +/** + * 分布式Id生成器的统一接口。 + * + * @author Jerry + * @date 2024-07-02 + */ +public interface MyIdGenerator { + + /** + * 获取数值型分布式Id。 + * + * @return 生成后的Id。 + */ + long nextLongId(); + + /** + * 获取字符型分布式Id。 + * + * @return 生成后的Id。 + */ + String nextStringId(); +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-sequence/src/main/java/com/orangeforms/common/sequence/wrapper/IdGeneratorWrapper.java b/OrangeFormsOpen-MybatisPlus/common/common-sequence/src/main/java/com/orangeforms/common/sequence/wrapper/IdGeneratorWrapper.java new file mode 100644 index 00000000..441ba9d9 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-sequence/src/main/java/com/orangeforms/common/sequence/wrapper/IdGeneratorWrapper.java @@ -0,0 +1,52 @@ +package com.orangeforms.common.sequence.wrapper; + +import com.orangeforms.common.sequence.config.IdGeneratorProperties; +import com.orangeforms.common.sequence.generator.BasicIdGenerator; +import com.orangeforms.common.sequence.generator.MyIdGenerator; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import jakarta.annotation.PostConstruct; + +/** + * 分布式Id生成器的封装类。该对象可根据配置选择不同的生成器实现类。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Component +public class IdGeneratorWrapper { + + @Autowired + private IdGeneratorProperties properties; + /** + * Id生成器接口对象。 + */ + private MyIdGenerator idGenerator; + + /** + * 今后如果支持更多Id生成器时,可以在该函数内实现不同生成器的动态选择。 + */ + @PostConstruct + public void init() { + idGenerator = new BasicIdGenerator(properties.getSnowflakeWorkNode()); + } + + /** + * 由于底层实现为synchronized方法,因此计算过程串行化,且线程安全。 + * + * @return 计算后的全局唯一Id。 + */ + public long nextLongId() { + return idGenerator.nextLongId(); + } + + /** + * 由于底层实现为synchronized方法,因此计算过程串行化,且线程安全。 + * + * @return 计算后的全局唯一Id。 + */ + public String nextStringId() { + return idGenerator.nextStringId(); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-sequence/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/OrangeFormsOpen-MybatisPlus/common/common-sequence/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..f917b714 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-sequence/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.orangeforms.common.sequence.config.IdGeneratorAutoConfig \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-swagger/pom.xml b/OrangeFormsOpen-MybatisPlus/common/common-swagger/pom.xml new file mode 100644 index 00000000..683c9952 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-swagger/pom.xml @@ -0,0 +1,40 @@ + + + + common + com.orangeforms + 1.0.0 + + 4.0.0 + + common-swagger + 1.0.0 + common-swagger + jar + + + + + com.github.xiaoymin + knife4j-dependencies + ${knife4j.version} + pom + import + + + + + + + com.github.xiaoymin + knife4j-openapi3-jakarta-spring-boot-starter + + + com.orangeforms + common-core + 1.0.0 + + + \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/common-swagger/src/main/java/com/orangeforms/common/swagger/config/SwaggerAutoConfiguration.java b/OrangeFormsOpen-MybatisPlus/common/common-swagger/src/main/java/com/orangeforms/common/swagger/config/SwaggerAutoConfiguration.java new file mode 100644 index 00000000..1ad2a2ae --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-swagger/src/main/java/com/orangeforms/common/swagger/config/SwaggerAutoConfiguration.java @@ -0,0 +1,70 @@ +package com.orangeforms.common.swagger.config; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import org.springdoc.core.models.GroupedOpenApi; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +/** + * 自动加载bean的配置对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@EnableConfigurationProperties(SwaggerProperties.class) +@ConditionalOnProperty(prefix = "common-swagger", name = "enabled") +public class SwaggerAutoConfiguration { + + @Bean + public GroupedOpenApi upmsApi(SwaggerProperties p) { + String[] paths = {"/admin/upms/**"}; + String[] packagedToMatch = {p.getServiceBasePackage() + ".upms.controller"}; + return GroupedOpenApi.builder().group("用户权限分组接口") + .pathsToMatch(paths) + .packagesToScan(packagedToMatch).build(); + } + + @Bean + public GroupedOpenApi bizApi(SwaggerProperties p) { + String[] paths = {"/admin/app/**"}; + String[] packagedToMatch = {p.getServiceBasePackage() + ".app.controller"}; + return GroupedOpenApi.builder().group("业务应用分组接口") + .pathsToMatch(paths) + .packagesToScan(packagedToMatch).build(); + } + + @Bean + public GroupedOpenApi workflowApi(SwaggerProperties p) { + String[] paths = {"/admin/flow/**"}; + String[] packagedToMatch = {p.getBasePackage() + ".common.flow.controller"}; + return GroupedOpenApi.builder().group("工作流通用操作接口") + .pathsToMatch(paths) + .packagesToScan(packagedToMatch).build(); + } + + @Bean + public GroupedOpenApi onlineApi(SwaggerProperties p) { + String[] paths = {"/admin/online/**"}; + String[] packagedToMatch = {p.getBasePackage() + ".common.online.controller"}; + return GroupedOpenApi.builder().group("在线表单操作接口") + .pathsToMatch(paths) + .packagesToScan(packagedToMatch).build(); + } + + @Bean + public GroupedOpenApi reportApi(SwaggerProperties p) { + String[] paths = {"/admin/report/**"}; + String[] packagedToMatch = {p.getBasePackage() + ".common.report.controller"}; + return GroupedOpenApi.builder().group("报表打印操作接口") + .pathsToMatch(paths) + .packagesToScan(packagedToMatch).build(); + } + + @Bean + public OpenAPI customOpenApi(SwaggerProperties p) { + Info info = new Info().title(p.getTitle()).version(p.getVersion()).description(p.getDescription()); + return new OpenAPI().info(info); + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-swagger/src/main/java/com/orangeforms/common/swagger/config/SwaggerProperties.java b/OrangeFormsOpen-MybatisPlus/common/common-swagger/src/main/java/com/orangeforms/common/swagger/config/SwaggerProperties.java new file mode 100644 index 00000000..7f84999f --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-swagger/src/main/java/com/orangeforms/common/swagger/config/SwaggerProperties.java @@ -0,0 +1,45 @@ +package com.orangeforms.common.swagger.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * 配置参数对象。 + * + * @author Jerry + * @date 2024-07-02 + */ +@Data +@ConfigurationProperties("common-swagger") +public class SwaggerProperties { + + /** + * 是否开启Swagger。 + */ + private Boolean enabled; + + /** + * Swagger解析的基础包路径。 + **/ + private String basePackage = ""; + + /** + * Swagger解析的服务包路径。 + **/ + private String serviceBasePackage = ""; + + /** + * ApiInfo中的标题。 + **/ + private String title = ""; + + /** + * ApiInfo中的描述信息。 + **/ + private String description = ""; + + /** + * ApiInfo中的版本信息。 + **/ + private String version = ""; +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-swagger/src/main/java/com/orangeforms/common/swagger/plugin/MyGlobalOperationCustomer.java b/OrangeFormsOpen-MybatisPlus/common/common-swagger/src/main/java/com/orangeforms/common/swagger/plugin/MyGlobalOperationCustomer.java new file mode 100644 index 00000000..4bba5b3b --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-swagger/src/main/java/com/orangeforms/common/swagger/plugin/MyGlobalOperationCustomer.java @@ -0,0 +1,194 @@ +package com.orangeforms.common.swagger.plugin; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.util.StrUtil; +import com.orangeforms.common.core.annotation.MyRequestBody; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.models.Operation; +import lombok.extern.slf4j.Slf4j; +import org.springdoc.core.customizers.GlobalOperationCustomizer; +import org.springframework.stereotype.Component; +import org.springframework.web.method.HandlerMethod; + +import java.lang.annotation.Annotation; +import java.lang.reflect.*; +import java.util.*; +import java.util.stream.Stream; + +/** + * @author xiaoymin@foxmail.com + */ +@Slf4j +@Component +public class MyGlobalOperationCustomer implements GlobalOperationCustomizer { + + /** + * 注解包路径名称 + */ + private static final String REF_KEY = "$ref"; + private static final String REF_SCHEMA_PREFIX = "#/components/schemas/"; + private final Map, Set> cacheClassProperties = MapUtil.newHashMap(); + private static final String EXTENSION_ORANGE_FORM_NAME = "x-orangeforms"; + private static final String EXTENSION_ORANGE_FORM_IGNORE_NAME = "x-orangeforms-ignore-parameters"; + + @Override + public Operation customize(Operation operation, HandlerMethod handlerMethod) { + this.handleSummary(operation, handlerMethod); + if (handlerMethod.getMethod().getParameterCount() <= 0) { + return operation; + } + Parameter[] parameters = handlerMethod.getMethod().getParameters(); + if (ArrayUtil.isEmpty(parameters)) { + return operation; + } + Map properties = MapUtil.newHashMap(); + Map extensions = MapUtil.newHashMap(); + Set ignoreFieldName = CollUtil.newHashSet(); + List required = new ArrayList<>(); + Map paramMap = getParameterDescription(handlerMethod.getMethod()); + for (Parameter parameter : parameters) { + Annotation[] annos = parameter.getAnnotations(); + if (ArrayUtil.isEmpty(annos)) { + continue; + } + long count = Stream.of(annos).filter(anno -> anno.annotationType().equals(MyRequestBody.class)).count(); + if (count > 0) { + this.handleParameterDetail(parameter, properties, paramMap, ignoreFieldName, required); + } + } + if (!properties.isEmpty()) { + extensions.put("properties", properties); + extensions.put("type", "object"); + //required字段 + if (!required.isEmpty()) { + extensions.put("required", required); + } + String generateSchemaName = handlerMethod.getMethod().getName() + "DynamicReq"; + Map orangeExtensions = MapUtil.newHashMap(); + orangeExtensions.put(generateSchemaName, extensions); + //增加扩展属性 + operation.addExtension(EXTENSION_ORANGE_FORM_NAME, orangeExtensions); + if (!ignoreFieldName.isEmpty()) { + operation.addExtension(EXTENSION_ORANGE_FORM_IGNORE_NAME, ignoreFieldName); + } + } + return operation; + } + + private void handleSummary(Operation operation, HandlerMethod handlerMethod) { + io.swagger.v3.oas.annotations.Operation operationAnno = + handlerMethod.getMethod().getAnnotation(io.swagger.v3.oas.annotations.Operation.class); + if (operationAnno == null || StrUtil.isBlank(operationAnno.summary())) { + operation.setSummary(handlerMethod.getMethod().getName()); + } + } + + private void handleParameterDetail( + Parameter parameter, + Map properties, + Map paramMap, + Set ignoreFieldName, + List required) { + Class parameterType = parameter.getType(); + String schemaName = parameterType.getSimpleName(); + //添加忽律参数名称 + ignoreFieldName.addAll(getClassFields(parameterType)); + //处理schema注解别名的情况 + Schema schema = parameterType.getAnnotation(Schema.class); + if (schema != null && StrUtil.isNotBlank(schema.name())) { + schemaName = schema.name(); + } + Map value = MapUtil.newHashMap(); + //此处需要判断parameter的基础数据类型 + if (parameterType.isPrimitive() || parameterType.getName().startsWith("java.lang")) { + //基础数据类型 + ignoreFieldName.add(parameter.getName()); + value.put("type", parameterType.getSimpleName().toLowerCase()); + //判断format + } else if (Collection.class.isAssignableFrom(parameterType)) { + //集合类型 + value.put("type", "array"); + //获取泛型 + getGenericType(parameterType, parameter.getParameterizedType()) + .ifPresent(s -> value.put("items", MapUtil.builder(REF_KEY, REF_SCHEMA_PREFIX + s).build())); + } else { + //引用类型 + value.put(REF_KEY, REF_SCHEMA_PREFIX + schemaName); + } + //补一个description + io.swagger.v3.oas.annotations.Parameter paramAnnotation = paramMap.get(parameter.getName()); + if (paramAnnotation != null) { + //忽略该参数 + ignoreFieldName.add(paramAnnotation.name()); + value.put("description", paramAnnotation.description()); + if (StrUtil.isNotBlank(paramAnnotation.example())) { + value.put("default", paramAnnotation.example()); + } + // required参数 + if (paramAnnotation.required()) { + required.add(parameter.getName()); + } + } + properties.put(parameter.getName(), value); + } + + private Optional getGenericType(Class clazz, Type type) { + Type genericSuperclass = clazz.getGenericSuperclass(); + if (genericSuperclass instanceof ParameterizedType || type instanceof ParameterizedType) { + if (type instanceof ParameterizedType) { + genericSuperclass = type; + } + ParameterizedType parameterizedType = (ParameterizedType) genericSuperclass; + Type[] actualTypeArguments = parameterizedType.getActualTypeArguments(); + return Optional.of(((Class) actualTypeArguments[0]).getSimpleName()); + } + return Optional.empty(); + } + + private Set getClassFields(Class parameterType) { + if (parameterType == null) { + return Collections.emptySet(); + } + if (cacheClassProperties.containsKey(parameterType)) { + return cacheClassProperties.get(parameterType); + } + Set fieldNames = new HashSet<>(); + try { + Field[] fields = parameterType.getDeclaredFields(); + if (fields.length > 0) { + for (Field field : fields) { + fieldNames.add(field.getName()); + } + cacheClassProperties.put(parameterType, fieldNames); + return fieldNames; + } + } catch (Exception e) { + //ignore + } + return Collections.emptySet(); + } + + private Map getParameterDescription(Method method) { + Parameters parameters = method.getAnnotation(Parameters.class); + Map resultMap = MapUtil.newHashMap(); + if (parameters != null) { + io.swagger.v3.oas.annotations.Parameter[] parameters1 = parameters.value(); + if (parameters1 != null && parameters1.length > 0) { + for (io.swagger.v3.oas.annotations.Parameter parameter : parameters1) { + resultMap.put(parameter.name(), parameter); + } + return resultMap; + } + } else { + io.swagger.v3.oas.annotations.Parameter parameter = + method.getAnnotation(io.swagger.v3.oas.annotations.Parameter.class); + if (parameter != null) { + resultMap.put(parameter.name(), parameter); + } + } + return resultMap; + } +} diff --git a/OrangeFormsOpen-MybatisPlus/common/common-swagger/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/OrangeFormsOpen-MybatisPlus/common/common-swagger/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..b94a3251 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/common-swagger/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.orangeforms.common.swagger.config.SwaggerAutoConfiguration \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/common/pom.xml b/OrangeFormsOpen-MybatisPlus/common/pom.xml new file mode 100644 index 00000000..9ba52d48 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/common/pom.xml @@ -0,0 +1,30 @@ + + + + com.orangeforms + OrangeFormsOpen + 1.0.0 + + 4.0.0 + + common + pom + + + common-dbutil + common-ext + common-core + common-log + common-dict + common-datafilter + common-satoken + common-online + common-flow-online + common-flow + common-redis + common-minio + common-sequence + common-swagger + + diff --git a/OrangeFormsOpen-MybatisPlus/pom.xml b/OrangeFormsOpen-MybatisPlus/pom.xml new file mode 100644 index 00000000..cead7df2 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/pom.xml @@ -0,0 +1,171 @@ + + + 4.0.0 + + com.orangeforms + OrangeFormsOpen + 1.0.0 + OrangeFormsOpen + pom + + + 3.1.6 + 3.1.6 + UTF-8 + 17 + 17 + 17 + OrangeFormsOpen + + 2.10.13 + 20.0 + 2.6 + 4.4 + 1.8 + 5.2.2 + 5.0.0 + 5.8.23 + 0.12.3 + 1.2.83 + 1.1.5 + 2.9.3 + 1.18.20 + 8.0.1.Final + 7.0.1 + 3.15.4 + 8.4.5 + 2.0.0 + 4.5.0 + + 1.2.16 + 3.5.4.1 + 1.4.7 + + + + application-webadmin + common + + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-logging + + + + org.springframework.boot + spring-boot-starter-aop + + + + org.springframework.boot + spring-boot-starter-cache + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + org.springframework.security + spring-security-crypto + + + + org.springframework.boot + spring-boot-starter-actuator + + + + de.codecentric + spring-boot-admin-starter-client + ${spring-boot-admin.version} + + + + org.hibernate.validator + hibernate-validator + ${hibernate-validator.version} + + + + org.projectlombok + lombok + provided + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + mysql + mysql-connector-java + 8.0.22 + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + + + + + + src/main/resources + + **/*.* + + false + + + src/main/java + + **/*.xml + + false + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.0 + + + -parameters + + ${maven.compiler.target} + ${maven.compiler.source} + UTF-8 + + + org.projectlombok + lombok + ${lombok.version} + + + + + + + diff --git a/OrangeFormsOpen-MybatisPlus/zz-resource/.DS_Store b/OrangeFormsOpen-MybatisPlus/zz-resource/.DS_Store new file mode 100644 index 00000000..22e57237 Binary files /dev/null and b/OrangeFormsOpen-MybatisPlus/zz-resource/.DS_Store differ diff --git a/OrangeFormsOpen-MybatisPlus/zz-resource/db-scripts/.DS_Store b/OrangeFormsOpen-MybatisPlus/zz-resource/db-scripts/.DS_Store new file mode 100644 index 00000000..5008ddfc Binary files /dev/null and b/OrangeFormsOpen-MybatisPlus/zz-resource/db-scripts/.DS_Store differ diff --git a/OrangeFormsOpen-MybatisPlus/zz-resource/db-scripts/zzdemo-online-open.sql b/OrangeFormsOpen-MybatisPlus/zz-resource/db-scripts/zzdemo-online-open.sql new file mode 100644 index 00000000..c6d3b036 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/zz-resource/db-scripts/zzdemo-online-open.sql @@ -0,0 +1,2888 @@ +/* + Navicat Premium Data Transfer + + Source Server : hw-test + Source Server Type : MySQL + Source Server Version : 80024 + Source Host : 121.37.102.103:3306 + Source Schema : zzdemo-online-open + + Target Server Type : MySQL + Target Server Version : 80024 + File Encoding : 65001 + + Date: 05/07/2024 22:26:38 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for act_evt_log +-- ---------------------------- +DROP TABLE IF EXISTS `act_evt_log`; +CREATE TABLE `act_evt_log` ( + `LOG_NR_` bigint NOT NULL AUTO_INCREMENT, + `TYPE_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TIME_STAMP_` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), + `USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DATA_` longblob, + `LOCK_OWNER_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `LOCK_TIME_` timestamp(3) NULL DEFAULT NULL, + `IS_PROCESSED_` tinyint DEFAULT '0', + PRIMARY KEY (`LOG_NR_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_ge_bytearray +-- ---------------------------- +DROP TABLE IF EXISTS `act_ge_bytearray`; +CREATE TABLE `act_ge_bytearray` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DEPLOYMENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `BYTES_` longblob, + `GENERATED_` tinyint DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_FK_BYTEARR_DEPL` (`DEPLOYMENT_ID_`), + CONSTRAINT `ACT_FK_BYTEARR_DEPL` FOREIGN KEY (`DEPLOYMENT_ID_`) REFERENCES `act_re_deployment` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_ge_bytearray +-- ---------------------------- +BEGIN; +INSERT INTO `act_ge_bytearray` VALUES ('bcd05b07-3aa9-11ef-86ec-acde48001122', 1, 'flowLeave.bpmn', 'bcd05b06-3aa9-11ef-86ec-acde48001122', 0x3C3F786D6C2076657273696F6E3D27312E302720656E636F64696E673D275554462D38273F3E0A3C646566696E6974696F6E7320786D6C6E733D22687474703A2F2F7777772E6F6D672E6F72672F737065632F42504D4E2F32303130303532342F4D4F44454C2220786D6C6E733A7873693D22687474703A2F2F7777772E77332E6F72672F323030312F584D4C536368656D612D696E7374616E63652220786D6C6E733A7873643D22687474703A2F2F7777772E77332E6F72672F323030312F584D4C536368656D612220786D6C6E733A666C6F7761626C653D22687474703A2F2F666C6F7761626C652E6F72672F62706D6E2220786D6C6E733A62706D6E64693D22687474703A2F2F7777772E6F6D672E6F72672F737065632F42504D4E2F32303130303532342F44492220786D6C6E733A6F6D6764633D22687474703A2F2F7777772E6F6D672E6F72672F737065632F44442F32303130303532342F44432220786D6C6E733A6F6D6764693D22687474703A2F2F7777772E6F6D672E6F72672F737065632F44442F32303130303532342F44492220786D6C6E733A62706D6E323D22687474703A2F2F7777772E6F6D672E6F72672F737065632F42504D4E2F32303130303532342F4D4F44454C2220786D6C6E733A64633D22687474703A2F2F7777772E6F6D672E6F72672F737065632F44442F32303130303532342F44432220786D6C6E733A64693D22687474703A2F2F7777772E6F6D672E6F72672F737065632F44442F32303130303532342F44492220747970654C616E67756167653D22687474703A2F2F7777772E77332E6F72672F323030312F584D4C536368656D61222065787072657373696F6E4C616E67756167653D22687474703A2F2F7777772E77332E6F72672F313939392F585061746822207461726765744E616D6573706163653D22687474703A2F2F666C6F7761626C652E6F72672F62706D6E222069643D226469616772616D5F666C6F774C6561766522207873693A736368656D614C6F636174696F6E3D22687474703A2F2F7777772E6F6D672E6F72672F737065632F42504D4E2F32303130303532342F4D4F44454C2042504D4E32302E787364223E0A20203C70726F636573732069643D22666C6F774C6561766522206E616D653D22E8AFB7E58187E794B3E8AFB72220697345786563757461626C653D2274727565223E0A202020203C657874656E73696F6E456C656D656E74733E0A2020202020203C666C6F7761626C653A657865637574696F6E4C697374656E6572206576656E743D22656E642220636C6173733D22636F6D2E6F72616E6765666F726D732E636F6D6D6F6E2E666C6F772E6C697374656E65722E466C6F7746696E69736865644C697374656E6572222F3E0A2020202020203C666C6F7761626C653A70726F706572746965733E0A20202020202020203C666C6F7761626C653A70726F7065727479206E616D653D22244F72616E67654469616772616D54797065222076616C75653D2230222F3E0A2020202020203C2F666C6F7761626C653A70726F706572746965733E0A202020203C2F657874656E73696F6E456C656D656E74733E0A202020203C73746172744576656E742069643D224576656E745F30346233676435222F3E0A202020203C73657175656E6365466C6F772069643D22466C6F775F306438366275772220736F757263655265663D224576656E745F3034623367643522207461726765745265663D2241637469766974795F30766A74763070222F3E0A202020203C73657175656E6365466C6F772069643D22466C6F775F317534306474372220736F757263655265663D2241637469766974795F30766A7476307022207461726765745265663D2241637469766974795F30366731347066222F3E0A202020203C73657175656E6365466C6F772069643D22466C6F775F303573316A306E2220736F757263655265663D2241637469766974795F3036673134706622207461726765745265663D2241637469766974795F30646E37753532222F3E0A202020203C656E644576656E742069643D224576656E745F30697479357767222F3E0A202020203C73657175656E6365466C6F772069643D22466C6F775F31627877637A612220736F757263655265663D2241637469766974795F30646E3775353222207461726765745265663D224576656E745F30697479357767222F3E0A202020203C757365725461736B2069643D2241637469766974795F30766A7476307022206E616D653D22E5BD95E585A52220666C6F7761626C653A61737369676E65653D22247B7374617274557365724E616D657D2220666C6F7761626C653A666F726D4B65793D227B2671756F743B666F726D49642671756F743B3A2671756F743B313830393133323633353633333438373837322671756F743B2C2671756F743B726561644F6E6C792671756F743B3A66616C73652C2671756F743B67726F7570547970652671756F743B3A2671756F743B41535349474E45452671756F743B7D223E0A2020202020203C657874656E73696F6E456C656D656E74733E0A20202020202020203C666C6F7761626C653A7461736B4C697374656E6572206576656E743D226372656174652220636C6173733D22636F6D2E6F72616E6765666F726D732E636F6D6D6F6E2E666C6F772E6C697374656E65722E466C6F77557365725461736B4C697374656E6572222F3E0A20202020202020203C666C6F7761626C653A7461736B4C697374656E6572206576656E743D226372656174652220636C6173733D22636F6D2E6F72616E6765666F726D732E636F6D6D6F6E2E666C6F772E6C697374656E65722E466C6F775461736B4E6F746966794C697374656E6572222F3E0A20202020202020203C666C6F7761626C653A7661726961626C654C6973742F3E0A20202020202020203C666C6F7761626C653A636F70794974656D4C6973742F3E0A20202020202020203C666C6F7761626C653A6F7065726174696F6E4C6973743E0A202020202020202020203C666C6F7761626C653A666F726D4F7065726174696F6E2069643D223137323031363835343036373222206C6162656C3D22E5908CE6848F2220747970653D226167726565222073686F774F726465723D2230222F3E0A20202020202020203C2F666C6F7761626C653A6F7065726174696F6E4C6973743E0A2020202020203C2F657874656E73696F6E456C656D656E74733E0A202020203C2F757365725461736B3E0A202020203C757365725461736B2069643D2241637469766974795F3036673134706622206E616D653D22E5AEA1E689B9412220666C6F7761626C653A61737369676E65653D2261646D696E2220666C6F7761626C653A666F726D4B65793D227B2671756F743B666F726D49642671756F743B3A2671756F743B313830393133323633353633333438373837322671756F743B2C2671756F743B726561644F6E6C792671756F743B3A747275652C2671756F743B67726F7570547970652671756F743B3A2671756F743B41535349474E45452671756F743B7D223E0A2020202020203C657874656E73696F6E456C656D656E74733E0A20202020202020203C666C6F7761626C653A7461736B4C697374656E6572206576656E743D226372656174652220636C6173733D22636F6D2E6F72616E6765666F726D732E636F6D6D6F6E2E666C6F772E6C697374656E65722E466C6F77557365725461736B4C697374656E6572222F3E0A20202020202020203C666C6F7761626C653A7461736B4C697374656E6572206576656E743D226372656174652220636C6173733D22636F6D2E6F72616E6765666F726D732E636F6D6D6F6E2E666C6F772E6C697374656E65722E466C6F775461736B4E6F746966794C697374656E6572222F3E0A20202020202020203C666C6F7761626C653A6F7065726174696F6E4C6973743E0A202020202020202020203C666C6F7761626C653A666F726D4F7065726174696F6E2069643D223137323031363835353530353922206C6162656C3D22E5908CE6848F2220747970653D226167726565222073686F774F726465723D2230222F3E0A202020202020202020203C666C6F7761626C653A666F726D4F7065726174696F6E2069643D223137323031363835353834383522206C6162656C3D22E9A9B3E59B9EE588B0E8B5B7E782B92220747970653D2272656A656374546F5374617274222073686F774F726465723D2230222F3E0A20202020202020203C2F666C6F7761626C653A6F7065726174696F6E4C6973743E0A20202020202020203C666C6F7761626C653A7661726961626C654C6973742F3E0A20202020202020203C666C6F7761626C653A636F70794974656D4C6973742F3E0A2020202020203C2F657874656E73696F6E456C656D656E74733E0A202020203C2F757365725461736B3E0A202020203C757365725461736B2069643D2241637469766974795F30646E3775353222206E616D653D22E5AEA1E689B9422220666C6F7761626C653A61737369676E65653D2261646D696E2220666C6F7761626C653A666F726D4B65793D227B2671756F743B666F726D49642671756F743B3A2671756F743B313830393133323633353633333438373837322671756F743B2C2671756F743B726561644F6E6C792671756F743B3A747275652C2671756F743B67726F7570547970652671756F743B3A2671756F743B41535349474E45452671756F743B7D223E0A2020202020203C657874656E73696F6E456C656D656E74733E0A20202020202020203C666C6F7761626C653A7461736B4C697374656E6572206576656E743D226372656174652220636C6173733D22636F6D2E6F72616E6765666F726D732E636F6D6D6F6E2E666C6F772E6C697374656E65722E466C6F77557365725461736B4C697374656E6572222F3E0A20202020202020203C666C6F7761626C653A7461736B4C697374656E6572206576656E743D226372656174652220636C6173733D22636F6D2E6F72616E6765666F726D732E636F6D6D6F6E2E666C6F772E6C697374656E65722E466C6F775461736B4E6F746966794C697374656E6572222F3E0A20202020202020203C666C6F7761626C653A7661726961626C654C6973742F3E0A20202020202020203C666C6F7761626C653A636F70794974656D4C6973742F3E0A20202020202020203C666C6F7761626C653A6F7065726174696F6E4C6973743E0A202020202020202020203C666C6F7761626C653A666F726D4F7065726174696F6E2069643D223137323031363835373339303322206C6162656C3D22E5908CE6848F2220747970653D226167726565222073686F774F726465723D2230222F3E0A202020202020202020203C666C6F7761626C653A666F726D4F7065726174696F6E2069643D223137323031363835373734393522206C6162656C3D22E9A9B3E59B9E2220747970653D2272656A656374222073686F774F726465723D2230222F3E0A20202020202020203C2F666C6F7761626C653A6F7065726174696F6E4C6973743E0A2020202020203C2F657874656E73696F6E456C656D656E74733E0A202020203C2F757365725461736B3E0A20203C2F70726F636573733E0A20203C62706D6E64693A42504D4E4469616772616D2069643D2242504D4E4469616772616D5F666C6F774C65617665223E0A202020203C62706D6E64693A42504D4E506C616E652062706D6E456C656D656E743D22666C6F774C65617665222069643D2242504D4E506C616E655F666C6F774C65617665223E0A2020202020203C62706D6E64693A42504D4E53686170652062706D6E456C656D656E743D224576656E745F30346233676435222069643D2242504D4E53686170655F4576656E745F30346233676435223E0A20202020202020203C6F6D6764633A426F756E6473206865696768743D2233362E30222077696474683D2233362E302220783D223138322E302220793D223237322E30222F3E0A2020202020203C2F62706D6E64693A42504D4E53686170653E0A2020202020203C62706D6E64693A42504D4E53686170652062706D6E456C656D656E743D224576656E745F30697479357767222069643D2242504D4E53686170655F4576656E745F30697479357767223E0A20202020202020203C6F6D6764633A426F756E6473206865696768743D2233362E30222077696474683D2233362E302220783D223735322E302220793D223237322E30222F3E0A2020202020203C2F62706D6E64693A42504D4E53686170653E0A2020202020203C62706D6E64693A42504D4E53686170652062706D6E456C656D656E743D2241637469766974795F30766A74763070222069643D2242504D4E53686170655F41637469766974795F30766A74763070223E0A20202020202020203C6F6D6764633A426F756E6473206865696768743D2238302E30222077696474683D223130302E302220783D223237302E302220793D223235302E30222F3E0A2020202020203C2F62706D6E64693A42504D4E53686170653E0A2020202020203C62706D6E64693A42504D4E53686170652062706D6E456C656D656E743D2241637469766974795F30366731347066222069643D2242504D4E53686170655F41637469766974795F30366731347066223E0A20202020202020203C6F6D6764633A426F756E6473206865696768743D2238302E30222077696474683D223130302E302220783D223433302E302220793D223235302E30222F3E0A2020202020203C2F62706D6E64693A42504D4E53686170653E0A2020202020203C62706D6E64693A42504D4E53686170652062706D6E456C656D656E743D2241637469766974795F30646E37753532222069643D2242504D4E53686170655F41637469766974795F30646E37753532223E0A20202020202020203C6F6D6764633A426F756E6473206865696768743D2238302E30222077696474683D223130302E302220783D223539302E302220793D223235302E30222F3E0A2020202020203C2F62706D6E64693A42504D4E53686170653E0A2020202020203C62706D6E64693A42504D4E456467652062706D6E456C656D656E743D22466C6F775F30643836627577222069643D2242504D4E456467655F466C6F775F30643836627577223E0A20202020202020203C6F6D6764693A776179706F696E7420783D223231382E302220793D223239302E30222F3E0A20202020202020203C6F6D6764693A776179706F696E7420783D223237302E302220793D223239302E30222F3E0A2020202020203C2F62706D6E64693A42504D4E456467653E0A2020202020203C62706D6E64693A42504D4E456467652062706D6E456C656D656E743D22466C6F775F31753430647437222069643D2242504D4E456467655F466C6F775F31753430647437223E0A20202020202020203C6F6D6764693A776179706F696E7420783D223337302E302220793D223239302E30222F3E0A20202020202020203C6F6D6764693A776179706F696E7420783D223433302E302220793D223239302E30222F3E0A2020202020203C2F62706D6E64693A42504D4E456467653E0A2020202020203C62706D6E64693A42504D4E456467652062706D6E456C656D656E743D22466C6F775F303573316A306E222069643D2242504D4E456467655F466C6F775F303573316A306E223E0A20202020202020203C6F6D6764693A776179706F696E7420783D223533302E302220793D223239302E30222F3E0A20202020202020203C6F6D6764693A776179706F696E7420783D223539302E302220793D223239302E30222F3E0A2020202020203C2F62706D6E64693A42504D4E456467653E0A2020202020203C62706D6E64693A42504D4E456467652062706D6E456C656D656E743D22466C6F775F31627877637A61222069643D2242504D4E456467655F466C6F775F31627877637A61223E0A20202020202020203C6F6D6764693A776179706F696E7420783D223639302E302220793D223239302E30222F3E0A20202020202020203C6F6D6764693A776179706F696E7420783D223735322E302220793D223239302E30222F3E0A2020202020203C2F62706D6E64693A42504D4E456467653E0A202020203C2F62706D6E64693A42504D4E506C616E653E0A20203C2F62706D6E64693A42504D4E4469616772616D3E0A3C2F646566696E6974696F6E733E, 0); +INSERT INTO `act_ge_bytearray` VALUES ('be002878-3aa9-11ef-86ec-acde48001122', 1, 'flowLeave.flowLeave.png', 'bcd05b06-3aa9-11ef-86ec-acde48001122', 0x89504E470D0A1A0A0000000D494844520000031E000001540806000000AA66EA1D0000199149444154785EEDDD79B01C65BD37F00BB85CB7927B8572A554D492F20F4BFFD09257CB7A55AED7124B2C856C040C2698206840B2A86099605C7005028658D79245F00A1AADC06BBD0889318A2C82685834206B02312789D9902472A56FFFBA32A9C93327E19090D3CF99E7F3A9FAD63933D3D3DDC9F9F5FCFA99E9EEF9977F01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080A7A4AAAA67DD77DF7D57DC70C30DFF58B4685175EDB5D7CA30A7FE7F7F62E9D2A58F2C5EBCF8A8F4EFD3EFD45FFB517FEAAFCD945C7F00C5A99BEE95F58B7EB57AF5EA6ACB962DD5B66DDB649813FFEFF1FFBF64C9928D75233E32FD1BF533F5D77ED49FFA6B3325D71F4071E29DBE78D14F9B810C7F56AD5AB5B66EBC37A77FA37EA6FEF289FA93365362FD0114270E2FF04E5F1E89BF43DD78B7A67FA37EA6FEF289FA93365362FD0114278EB14D1B80B497F87BA47FA37EA6FEF28AFA9336535AFD011467A88DF7D10DABAAFB7EF7FDEACEEBCE6A12BFC77DE974B27729ADF1AABFBCA2FE068FFA1B9E94567F00C5194AE3DDBCFEE1EA8E6B3E5FFDF1FF4DDF29715F3C964E2F7B9ED21AAFFACB2BEAAF37EA6FF8525AFD011467288D77C59D0B7B9A6E272BEFBCAA677AD9F394D678D55F5E517FBD517FC397D2EA0FA0384369BC7FFAE5D93D0DB793782C9D5EF63CA5355EF59757D45F6FD4DFF0A5B4FA0328CE501AEF1DD7CEEA69B89DC463E9F4B2E729ADF1AABFBCA2FE7AA3FE862FA5D51F407134DEBC525AE3557F7945FDF546FD0D5F4AAB3F80E20CA5F1C6555CD286DB493C964E2F7B9ED21AAFFACB2BEAAF37EA6FF8525AFD011467288DF79EEBCFEF69B89DC463E9F4B2E729ADF1AABFBCA2FE7AA3FE862FA5D51F407186D278D73DBCACBAE3175FE869BA715F3C964E2F7B9ED21AAFFACB2BEAAF37EA6FF8525AFD011467288D3772FF2D97F434DEB82F9D4EF62EA5355EF59757D4DFE0517FC393D2EA0FA038436ABC5BB756F7FC765E4FE38DFBE2B19EE9658F535AE3557F7945FD0D12F5376C29ADFE008AF3648D37BE99F7EEEBE7F634DD4EE231DFDEFBF4A5B4C6ABFEF28AFADB39EA6F78535AFD011467978D77EBD66AD53D8BABDBFFFFE77A9A6D9A9826A6F5EEDFDEA7B4C6ABFEF28AFADB1EF5D74A4AAB3F80E20CD6789FEC5DBE5DC5BB7F7B9FD21AAFFACB2BEA4FFDB599D2EA0FA0388335DEA1BCCBB7ABC473D3F9C9D0535AE3557F7945FDA9BF36535AFD011467B0C69B36D3A79A747E32F494D678D55F5E517FEAAFCD94567F00C519ACF14A7B29ADF1AABFBCA2FEA4CD94567F7B6AC28409078E1933E6E8D1A3479F57FF5C54E7FE3A8FD5A9B6FF8CDB8BB63F7E744C9FCE03789A6CDCB8F1DF172E5C78D6F9E79FFFC7D9B367AF9D3973E696934E3AE989D820A74C99F2F8B469D3369D71C6190F9D75D659574D9F3EFD7DF553F64BE751128D37AF94D678D55F5E517FD2664AABBFA76AECD8B1FF51EFCB2CA8B36DFB2063A889E917C4F3D379027BE8A69B6E9A72CE39E73C3C79F2E4AA1E6C54575E796575EBADB756F7DE7B6FB56EDDBA2AC4CFB81DF7C7E33366CC7862E2C489DBEA01C835E3C68D3B349D670934DEBC525AE3557F7945FD499B29ADFE86AA1E301C5E0F1C6E1C6440B127B931E6972E0318A265CB96BDFF3BDFF9CE231FFFF8C7AB9FFCE427D59A356B9A41C650C5F4F1BC7A00F28FD34E3BED8A7A833C285D463FD378F34A698D57FDE515F5276DA6B4FA7B3213264CF8D7D1A3475F500F169AA336BA73EAA9A756975D76D96EDF608DC763BAF4B931BF986FCC3F5D26B00BF5F675C0CF7FFEF38531E0B8F8E28BABCD9B37EF3CA2788AE2F9319F7A437C6CFCF8F11F4A97D7AF34DEBC525AE3557F7945FD499B29ADFE76A71E1C1C3276ECD83F760F18C68D1B57CD9F3FBF5AB97265BA0BB35B317D3C2F9E9F0C40FE10CB49970D24EAEDE8C04B2FBDF4EE934F3EB9BAEFBEFBD26D6CAFC4FCEAC1CC96891327CE4E97DB8F34DEBC525AE3557F7945FD499B29ADFE76A51E701C56E7E1EE41C2D9679F5DAD58B122DD65794AE2F9319F64F0B1229697AE03B05DBDED1C78DE79E7AD3FF3CC33ABF5EBD7A7DBD5D322E63B73E6CCC78E3FFEF84BD2E5F71B8D37AF94D678D55F5E517FD2664AABBFC16CFFA463C7A0233EA558B87061BA9BB257627EC9A71F2B7CF20183A8B797032EBDF4D27B62D0112F52FB52CC7FDAB4691B8E3DF6D833D2F5E8271A6F5E29ADF1AABFBCA2FEA4CD94567FA938E7A2FBF0AA134E38A1BAEDB6DBD2DD93A745CC37E6DF35F8F883733E2011E7749C72CA29FBEC938E542C67D2A4499BEA0DF283E9BAF40B8D37AF94D678D55F5E517FD2664AABBFD4F613C9777CD2B1AF061D1D31FFEE4F3E62F9E93A41B1EA0DE4C83891FCE93EA7E3C9C4F2C68F1FBFFE98638E39385DA77EA0F1E695D21AAFFACB2BEA4FDA4C69F5D76DFB2573FFD919045C75D555E9EEC83E11CBE9FAD4E39F2EB50BDBC52573E3AA536D98376FDE23F506796EBA4EFD40E3CD2BA5355EF59757D49FB499D2EAAFDB98AEEFE98813C0875372C2F98DE9BA4171E2CB01E3D38E4D9B36A5DBCBB088E51E77DC711BFBF14B0635DEBC525AE3557F7945FD499B29ADFE3A468D1A754467C73F0E7DDADBAB573D55B1BCEE43AE627DD27584A2C437922F58B020DD5686D525975C726FBD41CE4FD76DA4D378F34A698D57FDE515F5276DA6B4FAEBA8F72D167476FAE3FB36DA10CBEDFAD46341BA8E508C4D9B36BD68CA9429D5C0C040BA9D0CAB7AF9FF336EDCB8D5B366CDDA3F5DC7914CE3CD2BA5355EF59757D49FB499D2EA2FD4FB15FF56EFE86FEBECF40FF7A71D1DB1DCAE81C7B658AF745DA108575F7DF5EC993367A6DB482B264D9AF440BD41FE9F741D7354AFE72FEBFCDFF4FE94C69B57FAA5F1AABF9119F5276DA65FEAAF632875583F7E746787FFD4534F4D773B86552CBF6BF07174BAAE5084B973E7DE7EE59557A6DB472B2EBCF0C23FD41BE357D375CC51D78BC76E5FF834DEBCD22F8D57FD8DCCA83F6933FD527F1D43A9C3FAFEB99DE97EF0831FA4BB1DC32A96DFB5CE73D3758522CC9E3D7BEDADB7DE9A6E1FAD58BA74E9B2D1A3472F4CD731475D2F1EBB7DE1D378F34ABF345EF53732A3FEA4CDF44BFD750CA50EC78E1DBBB8F3F82DB7DC92EE760CAB587E675D62BDBAD7138A3163C68C2DC3FDDD1DBBB27CF9F238D4EA77E93AE6689017BC415FF834DEBCD22F8D7790BA537F2320EA4FDA4CBFD45FC720F5D75387F5CF873AF7B7BDAF13CBEF5AC787927F0E9461CA94294FFCED6F7F4BB78F56AC5BB76E73BD313E9CAE638E0679A14BD3BCF069BC79A55F1AEF20F59646FD6518F5276DA65FEAAF6390BA4B1375F8F7CEEDB6F77562F99D75193B76ECA6F4DF034538EEB8E3AAC71F7F3CDD3E5A51AFC7A6415E384674726FBC5BB76EEDB9AF9F93FE7DFA3D39D7DFF5D75F5F9D7BEEB93DF777F2A73FFDA9FAE94F7FDAFCFEFBDFFFBE5AB9726553AF37DD7453B57AF5EA9EE94742D2BF4FBF27E7FA8B945683E9DFA7B4B4BDAF13CBEF5A9FFF49F7C7A00893274F7EBCED77013AD6AC59F3973123FF138F5F8E1941871A5C7DF5D5D501071C503DFBD9CFEEC9339FF9CC6AC3860D3B4D1F5F3479C8218754AF7CE52BAB97BDEC65715E4ECF3C734EBFBCE33748DD655F7F37DC704375CA29A75453A74E6D72D86187C5DFA28ACB7977EE8BC77FFBDBDF36D3CF9B37AF3AF0C0039BDFA3DEBEFCE52F37BF3FEB59CFAA2EBFFCF29EF98F84A8BF76537A0DF64BFD750C527F3D75189F2C74EE6F7B5FC7271E503BFDF4D337B57DDC63C75D77DD75CB98917B8EC74E0DB723B7C69BE6AF7FFD6B75DA69A7559FFAD4A776CAE1871FDE34E574FA68B673E6CCA93EFAD18F360D7BA435DF7E69BC23B1FE7EF8C31F56FBEDB75F3571E2C426471D755475F0C10757A3478FDE71DFFEFBEFDF5CF9E557BFFA5575C2092754CF7FFEF3AB1FFDE847D5EB5FFFFAEAEB5FFF7A339FE73EF7B9557CE1E9AF7FFDEB6AD9B2653BE61FEF42D7FFE4EA79CF7B5EBC89D1B3FC1CA2FEDACDBEAAC15FFCE2174DED75126FDA1C7AE8A1555C31325D8736D32FF5D731943A1CE31C0FC8CB99679EB92297AB5A5D77DD758B46E055AD7A5EE8BAE5D678BB133B670F3CF04075CE39E754DFFCE637AB6F7FFBDB3BF2E637BFB9FAC0073ED01C5A30D82105314DFDCFAB3EFFF9CFF73C9673FAA5F18EC4FAFBFBDFFF5ECD9831A37AD7BBDE55BDE73DEFA9DEF296B73435F4F6B7BFBDB9FDEE77BFBBFACC673E536DDEBCB9FAD9CF7E567DE4231F6976F0E25098D8E97BEB5BDFDABC231DF78D1F3FBED9B99B3B77EE8EF9C7BBD631BFC879E79DD7B3FC1CA2FEDACDBEAAC16BAEB9A6994FBC667EEB5BDFAA66CF9E5D1D74D041D50B5FF8C2EAB1C71EEB598FB6D22FF5D731943A74552BC8CCAC59B3AECAE57B3CE6CC99B360CCC8F91E8F5DBED075CBADF176A71E74EEF42EDDAE128D3A7DEE11471CD13C16CD387D2CE7F44BE31DA9F53779F2E4EA55AF7A55155F5A7AFCF1C73735F4894F7CA2B91DF7C7E0A133ED77BFFBDDEA452F7A5175CF3DF7347516EF2047C38E9DBE78DEC9279FBC63DA3824300E8979DBDBDED6FC7CE31BDFD8B3EC1CA2FEDACFBEA8C1CEC0E32B5FF94A73FBD1471F6D0633518B31D849D7A1ADF44BFD750CA50EC7F81E0FC84BFD62FB9FF58EE513E906D282C7C78D1BB76CCC08F9E6F2A1CAB1F17672FBEDB737EFE4C5B7A9C6A102175D7451D33C2FB8E0826AE1C285D59BDEF4A6EAFBDFFF7E75C71D77ECF4BCBBEFBEBB391CE1631FFB58337D3C379D77AEE9B7C6FB6472ABBFD8A97BF9CB5FDED4CEFBDFFFFEA67EA209C7ED3867A8B3D377DB6DB755C71E7BEC8EC16D7A98CBA44993769A6FD4694C3B7FFEFCEAC4134F6C7EFFCD6F7ED3B3FCB6A3FEDACFBEA8C1CEC0E3052F7841F5E217BFB8393C2B6EEFEEC4F536525AFD8531197D73F9D4A9539FE81A78F8E672CA346BD6ACFDEB17D06D030303E93632AC56AE5C797DBD21AE8AF549D77124CBB1F176E7B39FFD6CD320E3B081B8824BFC1EE76FBCE31DEF68DEAD5BB26449CF73EA0162F59CE73CA7393F249A719C0B1227CDA5D3E598D21A6F6EF5173B75AF78C52B9A9F1FFEF08777D45EF7FD315D67F0103B7831804877FAE2F8FAEE2BB2BDF39DEF6CA6BFE28A2B9A7390E2F7091326F42CBFEDA8BFF6B32F6AB033F088D7CD38142B5E43E3DC91481CD79FAE435B29ADFE42DDAFFEADDEB7D8D6D9E15FB16245BAFB312C62B95D838E6DB15EE9BA4231A64F9F7E4DBC88B6E98B5FFCE2E5F5C6383F5DB7912EC7C69BE6C73FFE71B3E3F6A52F7DA9699E9138BCE0AEBBEEEA99364ECE8CC7E3B084B81D1F1DC7ED78314DA7CD31A535DEDCEA2F76EA5EFBDAD756B366CD6A4EE4AD57B13AFDF4D39BDBAF79CD6B76ECF4FDF9CF7FAEBEF18D6F347518B707DBE98B01469C6314751A270CC7BCBA93E349E6EAAFFDEC8B1A4C0FB58A9C7FFEF9CD7DF10972BA0E6DA5B4FAEBA8FB531CC6DDF4A9F854B40DB1DCAE81C782741DA128F5C8FBD0FA05F81F9B366D4AB79561B17EFDFA9BEB0D7120D6235DB7912EC7C6DB49FDFFDE0C1CE258E47A55AB4F7FFAD33B06157128559C2819871B74A68FEBD9C76576DFF08637546BD7AEDD717F5C11A6F3BCDCBF17A4B4C69B5BFDC58E5EECC8BDF7BDEF6DCEC7A857B119F4C6EDB8BFFBF095CEF1F5F17BECF4C515866247AFB3D31757631B356A54357DFAF4663E71926F5C0635128FC57D0E7569576EF517D91735D81978BCEF7DEF6B061F5FF8C217AAD7BDEE75CD7DF158BA0E6DA5B4FAEBA8FF46477476FAE313FBE1FED423963776ECD81D8759C5FAA4EB08C5A95F40AFB8F8E28BD3ED6558D4CBFE51BD319E9BAE533FC8B1F176B27CF9F2EA19CF784673B8415C8525AE515FAF7275F3CD37374DF5A52F7D6973D596381724AE7C15EF2AC7C995F7DE7BEF4EF3D9B871E38E435D4E3AE9A49EE5E494D21A6F6EF517971F5DBC78F18EDFEB55ACEEBFFFFEE676AC6BE7FB13E2677CB9695C19280E5D8943FBA2FEEAE6DD1C3F1F173788EF55F8DCE73E57BDE4252F690E69E93E89F7C1071F6CBE9F26CE534AD7A1CDA8BFF6F374D7E019679CD17339DDA8BD18B0447DA6CB6F33A5D55FB77A1FE3C6CE8EFFD9679F9DEE86EC53B1BCAE4F3B6E4CD70D8A74CC31C71C3C61C284C786FB3AD7B7DC724B1C623510CB4FD7A91FE4D878BB133B68F1330E29882F068C01445C9125EE8B4FC0AEBBEEBAE6F7186CC471D0835D5A3712CFF9E4273FD91C9E903E96534A6BBC39D75F9C3FB4AB43FABEF7BDEF55AF7EF5AB9B816C5C7DEDAB5FFD6AF597BFFCA579EC6B5FFB5A75E49147362703C73B89E973738EFACB2BA5D56069F5D7AD1E301E5EEF6BFCB33300B8EAAAABD2DD917D2296D335E8F867AC47BA6E50AC7AC7F24393274FDE1287E00C878181815FD51BE283753E98AE4BBFC8BDF19696D21AAFFACB2BEA4FDA4C69F5971A3D7AF4059D41401C72158712EF4B31FFEE43AC62F9E93A41F1264E9C387BE6CC998FC58BD4BEB475EBD6BBEA0DFF77F546F9D9741DFA89C69B574A6BBCEA2FAFA83F6933A5D55F6AC28409FF5A0F00FED01908C4393BFB6AF011F3AD97B7E31396586E2C3F5D27A076FCF1C75F326DDAB40DFBEA938F8181812531E8A837C4FF4A97DD6F34DEBC525AE3557F7945FD499B29ADFE0653EF771C526745F7271FF1BD554FA7985FF7271DDB977748BA2E4097638F3DF68C8913276E7ABACFF9D87E4EC743FDFE494787C69B574A6BBCEA2FAFA83F6933A5D5DFAED4FB1F87750F3E227102F8DE5EED2A9E9F9C48DE0C3A6279E93A0083A837980F8E1F3F7EFDBC79F31ED9BC7973BA8D3D251B366CB869FBD5AB0662BEE9B2FA95C69B574A6BBCEA2FAFA83F6933A5D5DFEEC4271063BA0EBB8AC4A71FF17D1B2B57AE4C7761762BA68FE7259F72348757C572D26503BB516F4807D51BCEB9C71D77DCC68B2EBAE8DE356BD63C9E6E74BBF1F8C30F3F7CFDECD9B39B2B57C57C627EE932FA99C69B574A6BBCEA2FAFA83F6933A5D5DF9389732EB69F709E0E18AA534F3DB5BAECB2CBAA5B6FBDB5B9AAE3BA75EB9A9D9AF819B7E3FE787CEAD4A93DCF8DF9C57C9DD3017B21BEDCAFDE98E6D7038781134F3CF1C10B2FBCF0B6A54B972E5BBE7CF9436BD7AE7DB4DE1E370F0C0CDC77E79D77DE52BFB85D3B67CE9C05F57396D5CFF96B3CAF1FBF1C702834DEBC525AE3557F7945FD499B29ADFE866AFBA576777CCFC75EE64697CC85A7D77EA3468D7A7BBD617DA51ED12FAC37B2F8D6F1CEB192F1F3E6B83F1E8FE962FA740625D178F34A698D57FDE515F5276DA6B4FA7BAAEAFD96FFA8F76116D4D936C880627789E917C4F3D379020C2B8D37AF94D678D55F5E517FD2664AABBF3D3561C28403EB81C4D1A3478F3EAFFEB9A8CEFD751EDB3EC8889F717BD1F6C78F8EE9D37900B442E3CD2BA5355EF59757D49FB499D2EA0FA0381A6F5E29ADF1AABFBCA2FEA4CD94567F00C5D178F34A698D57FDE515F5276DA6B4FA03288EC69B574A6BBCEA2FAFA83F6933A5D51F407134DEBC525AE3557F7945FD499B29ADFE008AA3F1E695D21AAFFACB2BEA4FDA4C69F507501C8D37AF94D678D55F5E517FD2664AAB3F80E268BC79A5B4C6ABFEF28AFA9336535AFD011447E3CD2BA5355EF59757D49FB499D2EA0FA0381A6F5E29ADF1AABFBCA2FEA4CD94567F00C5D178F34A698D57FDE515F5276DA6B4FA03288EC69B574A6BBCEA2FAFA83F6933A5D51F407134DEBC525AE3557F7945FD499B29ADFE008AA3F1E695D21AAFFACB2BEA4FDA4C69F507501C8D37AF94D678D55F5E517FD2664AAB3F80E268BC79A5B4C6ABFEF28AFA9336535AFD011447E3CD2BA5355EF59757D49FB499D2EA0FA0388B162D7A62CB962D3D0D40863FF5DFE191BAF16E4DFF46FD4CFDE513F5276DA6C4FA0328CED2A54B1F59BD7A754F1390E1CF830F3EF8DF75E3BD39FD1BF533F5974FD49FB49912EB0FA0388B172F3E6AC992251B57AD5AB5D63B7FEDA4FE7F5FF5C0030F5C5E37DD87EA1C99FE8DFA99FA6B3FEA4FFDB59992EB0FA048F1621FEF34D5D916C7D8CAB027FEDFE3FFBFC8A61BFFEEEDFF7EF5D74ED49FFA6B3345D71F000000000000000000000000000000000000000000000000000000C06EFD2FE154B1E7871DBABA0000000049454E44AE426082, 1); +COMMIT; + +-- ---------------------------- +-- Table structure for act_ge_property +-- ---------------------------- +DROP TABLE IF EXISTS `act_ge_property`; +CREATE TABLE `act_ge_property` ( + `NAME_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `VALUE_` varchar(300) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REV_` int DEFAULT NULL, + PRIMARY KEY (`NAME_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_ge_property +-- ---------------------------- +BEGIN; +INSERT INTO `act_ge_property` VALUES ('batch.schema.version', '7.0.1.1', 1); +INSERT INTO `act_ge_property` VALUES ('cfg.execution-related-entities-count', 'true', 1); +INSERT INTO `act_ge_property` VALUES ('cfg.task-related-entities-count', 'true', 1); +INSERT INTO `act_ge_property` VALUES ('common.schema.version', '7.0.1.1', 1); +INSERT INTO `act_ge_property` VALUES ('entitylink.schema.version', '7.0.1.1', 1); +INSERT INTO `act_ge_property` VALUES ('eventsubscription.schema.version', '7.0.1.1', 1); +INSERT INTO `act_ge_property` VALUES ('identitylink.schema.version', '7.0.1.1', 1); +INSERT INTO `act_ge_property` VALUES ('job.schema.version', '7.0.1.1', 1); +INSERT INTO `act_ge_property` VALUES ('next.dbid', '1', 1); +INSERT INTO `act_ge_property` VALUES ('schema.history', 'create(7.0.1.1)', 1); +INSERT INTO `act_ge_property` VALUES ('schema.version', '7.0.1.1', 1); +INSERT INTO `act_ge_property` VALUES ('task.schema.version', '7.0.1.1', 1); +INSERT INTO `act_ge_property` VALUES ('variable.schema.version', '7.0.1.1', 1); +COMMIT; + +-- ---------------------------- +-- Table structure for act_hi_actinst +-- ---------------------------- +DROP TABLE IF EXISTS `act_hi_actinst`; +CREATE TABLE `act_hi_actinst` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT '1', + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CALL_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ACT_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ACT_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `ASSIGNEE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `START_TIME_` datetime(3) NOT NULL, + `END_TIME_` datetime(3) DEFAULT NULL, + `TRANSACTION_ORDER_` int DEFAULT NULL, + `DURATION_` bigint DEFAULT NULL, + `DELETE_REASON_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_HI_ACT_INST_START` (`START_TIME_`), + KEY `ACT_IDX_HI_ACT_INST_END` (`END_TIME_`), + KEY `ACT_IDX_HI_ACT_INST_PROCINST` (`PROC_INST_ID_`,`ACT_ID_`), + KEY `ACT_IDX_HI_ACT_INST_EXEC` (`EXECUTION_ID_`,`ACT_ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_hi_actinst +-- ---------------------------- +BEGIN; +INSERT INTO `act_hi_actinst` VALUES ('0669cc29-3aab-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', '0669cc28-3aab-11ef-86ec-acde48001122', 'Activity_0vjtv0p', '0669cc2a-3aab-11ef-86ec-acde48001122', NULL, '录入', 'userTask', 'admin', '2024-07-05 16:46:09.319', '2024-07-05 16:46:18.402', 1, 9083, NULL, ''); +INSERT INTO `act_hi_actinst` VALUES ('0bd9662c-3aab-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', '0669cc28-3aab-11ef-86ec-acde48001122', 'Flow_1u40dt7', NULL, NULL, NULL, 'sequenceFlow', NULL, '2024-07-05 16:46:18.439', '2024-07-05 16:46:18.439', 1, 0, NULL, ''); +INSERT INTO `act_hi_actinst` VALUES ('0bdf0b7d-3aab-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', '0669cc28-3aab-11ef-86ec-acde48001122', 'Activity_06g14pf', '0bdf328e-3aab-11ef-86ec-acde48001122', NULL, '审批A', 'userTask', 'admin', '2024-07-05 16:46:18.476', NULL, 2, NULL, NULL, ''); +INSERT INTO `act_hi_actinst` VALUES ('e1fbee32-3aaa-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Event_04b3gd5', NULL, NULL, NULL, 'startEvent', NULL, '2024-07-05 16:45:08.201', '2024-07-05 16:45:08.205', 1, 4, NULL, ''); +INSERT INTO `act_hi_actinst` VALUES ('e1fcd893-3aaa-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Flow_0d86buw', NULL, NULL, NULL, 'sequenceFlow', NULL, '2024-07-05 16:45:08.207', '2024-07-05 16:45:08.207', 2, 0, NULL, ''); +INSERT INTO `act_hi_actinst` VALUES ('e1fcd894-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Activity_0vjtv0p', 'e200f745-3aaa-11ef-86ec-acde48001122', NULL, '录入', 'userTask', 'admin', '2024-07-05 16:45:08.207', '2024-07-05 16:45:10.069', 3, 1862, NULL, ''); +INSERT INTO `act_hi_actinst` VALUES ('e31e4e2b-3aaa-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Flow_1u40dt7', NULL, NULL, NULL, 'sequenceFlow', NULL, '2024-07-05 16:45:10.104', '2024-07-05 16:45:10.104', 1, 0, NULL, ''); +INSERT INTO `act_hi_actinst` VALUES ('e322bafc-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Activity_06g14pf', 'e322e20d-3aaa-11ef-86ec-acde48001122', NULL, '审批A', 'userTask', 'admin', '2024-07-05 16:45:10.133', '2024-07-05 16:45:36.454', 2, 26321, NULL, ''); +INSERT INTO `act_hi_actinst` VALUES ('f2d8563f-3aaa-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Flow_05s1j0n', NULL, NULL, NULL, 'sequenceFlow', NULL, '2024-07-05 16:45:36.489', '2024-07-05 16:45:36.489', 1, 0, NULL, ''); +INSERT INTO `act_hi_actinst` VALUES ('f2dcc310-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Activity_0dn7u52', 'f2dcc311-3aaa-11ef-86ec-acde48001122', NULL, '审批B', 'userTask', 'admin', '2024-07-05 16:45:36.518', '2024-07-05 16:45:58.241', 2, 21723, 'Change activity to Activity_06g14pf', ''); +INSERT INTO `act_hi_actinst` VALUES ('ffef78e5-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'ffef51d3-3aaa-11ef-86ec-acde48001122', 'Activity_06g14pf', 'ffef78e6-3aaa-11ef-86ec-acde48001122', NULL, '审批A', 'userTask', 'admin', '2024-07-05 16:45:58.451', '2024-07-05 16:46:09.095', 1, 10644, 'Change activity to Activity_0vjtv0p', ''); +COMMIT; + +-- ---------------------------- +-- Table structure for act_hi_attachment +-- ---------------------------- +DROP TABLE IF EXISTS `act_hi_attachment`; +CREATE TABLE `act_hi_attachment` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DESCRIPTION_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `URL_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CONTENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TIME_` datetime(3) DEFAULT NULL, + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_hi_comment +-- ---------------------------- +DROP TABLE IF EXISTS `act_hi_comment`; +CREATE TABLE `act_hi_comment` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TIME_` datetime(3) NOT NULL, + `USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ACTION_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `MESSAGE_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `FULL_MSG_` longblob, + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_hi_detail +-- ---------------------------- +DROP TABLE IF EXISTS `act_hi_detail`; +CREATE TABLE `act_hi_detail` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ACT_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `VAR_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REV_` int DEFAULT NULL, + `TIME_` datetime(3) NOT NULL, + `BYTEARRAY_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DOUBLE_` double DEFAULT NULL, + `LONG_` bigint DEFAULT NULL, + `TEXT_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TEXT2_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_HI_DETAIL_PROC_INST` (`PROC_INST_ID_`), + KEY `ACT_IDX_HI_DETAIL_ACT_INST` (`ACT_INST_ID_`), + KEY `ACT_IDX_HI_DETAIL_TIME` (`TIME_`), + KEY `ACT_IDX_HI_DETAIL_NAME` (`NAME_`), + KEY `ACT_IDX_HI_DETAIL_TASK_ID` (`TASK_ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_hi_entitylink +-- ---------------------------- +DROP TABLE IF EXISTS `act_hi_entitylink`; +CREATE TABLE `act_hi_entitylink` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `LINK_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` datetime(3) DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PARENT_ELEMENT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REF_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REF_SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REF_SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ROOT_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ROOT_SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HIERARCHY_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_HI_ENT_LNK_SCOPE` (`SCOPE_ID_`,`SCOPE_TYPE_`,`LINK_TYPE_`), + KEY `ACT_IDX_HI_ENT_LNK_REF_SCOPE` (`REF_SCOPE_ID_`,`REF_SCOPE_TYPE_`,`LINK_TYPE_`), + KEY `ACT_IDX_HI_ENT_LNK_ROOT_SCOPE` (`ROOT_SCOPE_ID_`,`ROOT_SCOPE_TYPE_`,`LINK_TYPE_`), + KEY `ACT_IDX_HI_ENT_LNK_SCOPE_DEF` (`SCOPE_DEFINITION_ID_`,`SCOPE_TYPE_`,`LINK_TYPE_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_hi_identitylink +-- ---------------------------- +DROP TABLE IF EXISTS `act_hi_identitylink`; +CREATE TABLE `act_hi_identitylink` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `GROUP_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` datetime(3) DEFAULT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_HI_IDENT_LNK_USER` (`USER_ID_`), + KEY `ACT_IDX_HI_IDENT_LNK_SCOPE` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_HI_IDENT_LNK_SUB_SCOPE` (`SUB_SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_HI_IDENT_LNK_SCOPE_DEF` (`SCOPE_DEFINITION_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_HI_IDENT_LNK_TASK` (`TASK_ID_`), + KEY `ACT_IDX_HI_IDENT_LNK_PROCINST` (`PROC_INST_ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_hi_identitylink +-- ---------------------------- +BEGIN; +INSERT INTO `act_hi_identitylink` VALUES ('06700dbb-3aab-11ef-86ec-acde48001122', NULL, 'assignee', 'admin', '0669cc2a-3aab-11ef-86ec-acde48001122', '2024-07-05 16:46:09.360', NULL, NULL, NULL, NULL, NULL); +INSERT INTO `act_hi_identitylink` VALUES ('0bdf328f-3aab-11ef-86ec-acde48001122', NULL, 'assignee', 'admin', '0bdf328e-3aab-11ef-86ec-acde48001122', '2024-07-05 16:46:18.477', NULL, NULL, NULL, NULL, NULL); +INSERT INTO `act_hi_identitylink` VALUES ('e1fb51eb-3aaa-11ef-86ec-acde48001122', NULL, 'starter', 'admin', NULL, '2024-07-05 16:45:08.198', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL); +INSERT INTO `act_hi_identitylink` VALUES ('e2014566-3aaa-11ef-86ec-acde48001122', NULL, 'assignee', 'admin', 'e200f745-3aaa-11ef-86ec-acde48001122', '2024-07-05 16:45:08.236', NULL, NULL, NULL, NULL, NULL); +INSERT INTO `act_hi_identitylink` VALUES ('e2014567-3aaa-11ef-86ec-acde48001122', NULL, 'participant', 'admin', NULL, '2024-07-05 16:45:08.236', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL); +INSERT INTO `act_hi_identitylink` VALUES ('e2fd319a-3aaa-11ef-86ec-acde48001122', NULL, 'participant', 'admin', NULL, '2024-07-05 16:45:09.887', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL); +INSERT INTO `act_hi_identitylink` VALUES ('e322e20e-3aaa-11ef-86ec-acde48001122', NULL, 'assignee', 'admin', 'e322e20d-3aaa-11ef-86ec-acde48001122', '2024-07-05 16:45:10.134', NULL, NULL, NULL, NULL, NULL); +INSERT INTO `act_hi_identitylink` VALUES ('f2dcea22-3aaa-11ef-86ec-acde48001122', NULL, 'assignee', 'admin', 'f2dcc311-3aaa-11ef-86ec-acde48001122', '2024-07-05 16:45:36.519', NULL, NULL, NULL, NULL, NULL); +INSERT INTO `act_hi_identitylink` VALUES ('ffef78e7-3aaa-11ef-86ec-acde48001122', NULL, 'assignee', 'admin', 'ffef78e6-3aaa-11ef-86ec-acde48001122', '2024-07-05 16:45:58.451', NULL, NULL, NULL, NULL, NULL); +COMMIT; + +-- ---------------------------- +-- Table structure for act_hi_procinst +-- ---------------------------- +DROP TABLE IF EXISTS `act_hi_procinst`; +CREATE TABLE `act_hi_procinst` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT '1', + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `BUSINESS_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `START_TIME_` datetime(3) NOT NULL, + `END_TIME_` datetime(3) DEFAULT NULL, + `DURATION_` bigint DEFAULT NULL, + `START_USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `START_ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `END_ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUPER_PROCESS_INSTANCE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DELETE_REASON_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CALLBACK_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CALLBACK_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REFERENCE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REFERENCE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROPAGATED_STAGE_INST_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `BUSINESS_STATUS_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + UNIQUE KEY `PROC_INST_ID_` (`PROC_INST_ID_`), + KEY `ACT_IDX_HI_PRO_INST_END` (`END_TIME_`), + KEY `ACT_IDX_HI_PRO_I_BUSKEY` (`BUSINESS_KEY_`), + KEY `ACT_IDX_HI_PRO_SUPER_PROCINST` (`SUPER_PROCESS_INSTANCE_ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_hi_procinst +-- ---------------------------- +BEGIN; +INSERT INTO `act_hi_procinst` VALUES ('e1fb2ada-3aaa-11ef-86ec-acde48001122', 1, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', '1809146480452177920', 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', '2024-07-05 16:45:08.196', NULL, NULL, 'admin', 'Event_04b3gd5', NULL, NULL, NULL, '', NULL, NULL, NULL, NULL, NULL, NULL, NULL); +COMMIT; + +-- ---------------------------- +-- Table structure for act_hi_taskinst +-- ---------------------------- +DROP TABLE IF EXISTS `act_hi_taskinst`; +CREATE TABLE `act_hi_taskinst` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT '1', + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROPAGATED_STAGE_INST_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `STATE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PARENT_TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DESCRIPTION_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `OWNER_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ASSIGNEE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `START_TIME_` datetime(3) NOT NULL, + `IN_PROGRESS_TIME_` datetime(3) DEFAULT NULL, + `IN_PROGRESS_STARTED_BY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CLAIM_TIME_` datetime(3) DEFAULT NULL, + `CLAIMED_BY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUSPENDED_TIME_` datetime(3) DEFAULT NULL, + `SUSPENDED_BY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `END_TIME_` datetime(3) DEFAULT NULL, + `COMPLETED_BY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DURATION_` bigint DEFAULT NULL, + `DELETE_REASON_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PRIORITY_` int DEFAULT NULL, + `IN_PROGRESS_DUE_DATE_` datetime(3) DEFAULT NULL, + `DUE_DATE_` datetime(3) DEFAULT NULL, + `FORM_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + `LAST_UPDATED_TIME_` datetime(3) DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_HI_TASK_SCOPE` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_HI_TASK_SUB_SCOPE` (`SUB_SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_HI_TASK_SCOPE_DEF` (`SCOPE_DEFINITION_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_HI_TASK_INST_PROCINST` (`PROC_INST_ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_hi_taskinst +-- ---------------------------- +BEGIN; +INSERT INTO `act_hi_taskinst` VALUES ('0669cc2a-3aab-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', NULL, 'Activity_0vjtv0p', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', '0669cc28-3aab-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, 'completed', '录入', NULL, NULL, NULL, 'admin', '2024-07-05 16:46:09.319', NULL, NULL, NULL, NULL, NULL, NULL, '2024-07-05 16:46:18.298', NULL, 8979, NULL, 50, NULL, NULL, '{\"formId\":\"1809132635633487872\",\"readOnly\":false,\"groupType\":\"ASSIGNEE\"}', NULL, '', '2024-07-05 16:46:18.298'); +INSERT INTO `act_hi_taskinst` VALUES ('0bdf328e-3aab-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', NULL, 'Activity_06g14pf', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', '0669cc28-3aab-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, 'created', '审批A', NULL, NULL, NULL, 'admin', '2024-07-05 16:46:18.476', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 50, NULL, NULL, '{\"formId\":\"1809132635633487872\",\"readOnly\":true,\"groupType\":\"ASSIGNEE\"}', NULL, '', '2024-07-05 16:46:18.477'); +INSERT INTO `act_hi_taskinst` VALUES ('e200f745-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', NULL, 'Activity_0vjtv0p', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, 'completed', '录入', NULL, NULL, NULL, 'admin', '2024-07-05 16:45:08.207', NULL, NULL, NULL, NULL, NULL, NULL, '2024-07-05 16:45:09.922', NULL, 1715, NULL, 50, NULL, NULL, '{\"formId\":\"1809132635633487872\",\"readOnly\":false,\"groupType\":\"ASSIGNEE\"}', NULL, '', '2024-07-05 16:45:09.922'); +INSERT INTO `act_hi_taskinst` VALUES ('e322e20d-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', NULL, 'Activity_06g14pf', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, 'completed', '审批A', NULL, NULL, NULL, 'admin', '2024-07-05 16:45:10.133', NULL, NULL, NULL, NULL, NULL, NULL, '2024-07-05 16:45:36.309', NULL, 26176, NULL, 50, NULL, NULL, '{\"formId\":\"1809132635633487872\",\"readOnly\":true,\"groupType\":\"ASSIGNEE\"}', NULL, '', '2024-07-05 16:45:36.309'); +INSERT INTO `act_hi_taskinst` VALUES ('f2dcc311-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', NULL, 'Activity_0dn7u52', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, 'completed', '审批B', NULL, NULL, NULL, 'admin', '2024-07-05 16:45:36.518', NULL, NULL, NULL, NULL, NULL, NULL, '2024-07-05 16:45:58.349', NULL, 21831, 'Change activity to Activity_06g14pf', 50, NULL, NULL, '{\"formId\":\"1809132635633487872\",\"readOnly\":true,\"groupType\":\"ASSIGNEE\"}', NULL, '', '2024-07-05 16:45:58.349'); +INSERT INTO `act_hi_taskinst` VALUES ('ffef78e6-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', NULL, 'Activity_06g14pf', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'ffef51d3-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, 'completed', '审批A', NULL, NULL, NULL, 'admin', '2024-07-05 16:45:58.451', NULL, NULL, NULL, NULL, NULL, NULL, '2024-07-05 16:46:09.253', NULL, 10802, 'Change activity to Activity_0vjtv0p', 50, NULL, NULL, '{\"formId\":\"1809132635633487872\",\"readOnly\":true,\"groupType\":\"ASSIGNEE\"}', NULL, '', '2024-07-05 16:46:09.253'); +COMMIT; + +-- ---------------------------- +-- Table structure for act_hi_tsk_log +-- ---------------------------- +DROP TABLE IF EXISTS `act_hi_tsk_log`; +CREATE TABLE `act_hi_tsk_log` ( + `ID_` bigint NOT NULL AUTO_INCREMENT, + `TYPE_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `TIME_STAMP_` timestamp(3) NOT NULL, + `USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DATA_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_hi_varinst +-- ---------------------------- +DROP TABLE IF EXISTS `act_hi_varinst`; +CREATE TABLE `act_hi_varinst` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT '1', + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `VAR_TYPE_` varchar(100) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `BYTEARRAY_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DOUBLE_` double DEFAULT NULL, + `LONG_` bigint DEFAULT NULL, + `TEXT_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TEXT2_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `META_INFO_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` datetime(3) DEFAULT NULL, + `LAST_UPDATED_TIME_` datetime(3) DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_HI_PROCVAR_NAME_TYPE` (`NAME_`,`VAR_TYPE_`), + KEY `ACT_IDX_HI_VAR_SCOPE_ID_TYPE` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_HI_VAR_SUB_ID_TYPE` (`SUB_SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_HI_PROCVAR_PROC_INST` (`PROC_INST_ID_`), + KEY `ACT_IDX_HI_PROCVAR_TASK_ID` (`TASK_ID_`), + KEY `ACT_IDX_HI_PROCVAR_EXE` (`EXECUTION_ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_hi_varinst +-- ---------------------------- +BEGIN; +INSERT INTO `act_hi_varinst` VALUES ('e1fb78fc-3aaa-11ef-86ec-acde48001122', 0, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, 'copyDataMap_Activity_0vjtv0p', 'string', NULL, NULL, NULL, NULL, NULL, NULL, '{}', NULL, NULL, '2024-07-05 16:45:08.200', '2024-07-05 16:45:08.200'); +INSERT INTO `act_hi_varinst` VALUES ('e1fbc71d-3aaa-11ef-86ec-acde48001122', 0, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, 'startUserName', 'string', NULL, NULL, NULL, NULL, NULL, NULL, 'admin', NULL, NULL, '2024-07-05 16:45:08.200', '2024-07-05 16:45:08.200'); +INSERT INTO `act_hi_varinst` VALUES ('e1fbc71e-3aaa-11ef-86ec-acde48001122', 0, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, 'initiator', 'string', NULL, NULL, NULL, NULL, NULL, NULL, 'admin', NULL, NULL, '2024-07-05 16:45:08.200', '2024-07-05 16:45:08.200'); +INSERT INTO `act_hi_varinst` VALUES ('e1fbc71f-3aaa-11ef-86ec-acde48001122', 0, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, 'copyDataMap_Activity_06g14pf', 'string', NULL, NULL, NULL, NULL, NULL, NULL, '{}', NULL, NULL, '2024-07-05 16:45:08.200', '2024-07-05 16:45:08.200'); +INSERT INTO `act_hi_varinst` VALUES ('e1fbc720-3aaa-11ef-86ec-acde48001122', 0, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, 'copyDataMap_Activity_0dn7u52', 'string', NULL, NULL, NULL, NULL, NULL, NULL, '{}', NULL, NULL, '2024-07-05 16:45:08.200', '2024-07-05 16:45:08.200'); +INSERT INTO `act_hi_varinst` VALUES ('e2fd0a88-3aaa-11ef-86ec-acde48001122', 2, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, 'submitUser', 'string', NULL, NULL, NULL, NULL, NULL, NULL, 'admin', NULL, NULL, '2024-07-05 16:45:09.886', '2024-07-05 16:46:18.228'); +INSERT INTO `act_hi_varinst` VALUES ('e2fd0a89-3aaa-11ef-86ec-acde48001122', 2, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, 'operationType', 'string', NULL, NULL, NULL, NULL, NULL, NULL, 'agree', NULL, NULL, '2024-07-05 16:45:09.886', '2024-07-05 16:46:18.264'); +INSERT INTO `act_hi_varinst` VALUES ('ffef51d4-3aaa-11ef-86ec-acde48001122', 0, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'ffef51d3-3aaa-11ef-86ec-acde48001122', NULL, 'appointedAssignee', 'string', NULL, NULL, NULL, NULL, NULL, NULL, 'admin', NULL, NULL, '2024-07-05 16:45:58.451', '2024-07-05 16:45:58.451'); +COMMIT; + +-- ---------------------------- +-- Table structure for act_id_bytearray +-- ---------------------------- +DROP TABLE IF EXISTS `act_id_bytearray`; +CREATE TABLE `act_id_bytearray` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `BYTES_` longblob, + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_id_group +-- ---------------------------- +DROP TABLE IF EXISTS `act_id_group`; +CREATE TABLE `act_id_group` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_id_info +-- ---------------------------- +DROP TABLE IF EXISTS `act_id_info`; +CREATE TABLE `act_id_info` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `USER_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TYPE_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `VALUE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PASSWORD_` longblob, + `PARENT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_id_membership +-- ---------------------------- +DROP TABLE IF EXISTS `act_id_membership`; +CREATE TABLE `act_id_membership` ( + `USER_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `GROUP_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + PRIMARY KEY (`USER_ID_`,`GROUP_ID_`), + KEY `ACT_FK_MEMB_GROUP` (`GROUP_ID_`), + CONSTRAINT `ACT_FK_MEMB_GROUP` FOREIGN KEY (`GROUP_ID_`) REFERENCES `act_id_group` (`ID_`), + CONSTRAINT `ACT_FK_MEMB_USER` FOREIGN KEY (`USER_ID_`) REFERENCES `act_id_user` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_id_priv +-- ---------------------------- +DROP TABLE IF EXISTS `act_id_priv`; +CREATE TABLE `act_id_priv` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + PRIMARY KEY (`ID_`), + UNIQUE KEY `ACT_UNIQ_PRIV_NAME` (`NAME_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_id_priv_mapping +-- ---------------------------- +DROP TABLE IF EXISTS `act_id_priv_mapping`; +CREATE TABLE `act_id_priv_mapping` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `PRIV_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `GROUP_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_FK_PRIV_MAPPING` (`PRIV_ID_`), + KEY `ACT_IDX_PRIV_USER` (`USER_ID_`), + KEY `ACT_IDX_PRIV_GROUP` (`GROUP_ID_`), + CONSTRAINT `ACT_FK_PRIV_MAPPING` FOREIGN KEY (`PRIV_ID_`) REFERENCES `act_id_priv` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_id_property +-- ---------------------------- +DROP TABLE IF EXISTS `act_id_property`; +CREATE TABLE `act_id_property` ( + `NAME_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `VALUE_` varchar(300) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REV_` int DEFAULT NULL, + PRIMARY KEY (`NAME_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_id_property +-- ---------------------------- +BEGIN; +INSERT INTO `act_id_property` VALUES ('schema.version', '7.0.1.1', 1); +COMMIT; + +-- ---------------------------- +-- Table structure for act_id_token +-- ---------------------------- +DROP TABLE IF EXISTS `act_id_token`; +CREATE TABLE `act_id_token` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `TOKEN_VALUE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TOKEN_DATE_` timestamp(3) NULL DEFAULT NULL, + `IP_ADDRESS_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `USER_AGENT_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TOKEN_DATA_` varchar(2000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_id_user +-- ---------------------------- +DROP TABLE IF EXISTS `act_id_user`; +CREATE TABLE `act_id_user` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `FIRST_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `LAST_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DISPLAY_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EMAIL_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PWD_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PICTURE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_procdef_info +-- ---------------------------- +DROP TABLE IF EXISTS `act_procdef_info`; +CREATE TABLE `act_procdef_info` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `INFO_JSON_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + UNIQUE KEY `ACT_UNIQ_INFO_PROCDEF` (`PROC_DEF_ID_`), + KEY `ACT_IDX_INFO_PROCDEF` (`PROC_DEF_ID_`), + KEY `ACT_FK_INFO_JSON_BA` (`INFO_JSON_ID_`), + CONSTRAINT `ACT_FK_INFO_JSON_BA` FOREIGN KEY (`INFO_JSON_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_INFO_PROCDEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `act_re_procdef` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_re_deployment +-- ---------------------------- +DROP TABLE IF EXISTS `act_re_deployment`; +CREATE TABLE `act_re_deployment` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + `DEPLOY_TIME_` timestamp(3) NULL DEFAULT NULL, + `DERIVED_FROM_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DERIVED_FROM_ROOT_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PARENT_DEPLOYMENT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ENGINE_VERSION_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_re_deployment +-- ---------------------------- +BEGIN; +INSERT INTO `act_re_deployment` VALUES ('bcd05b06-3aa9-11ef-86ec-acde48001122', '请假申请', 'TEST', 'flowLeave', NULL, '2024-07-05 16:36:56.343', NULL, NULL, 'bcd05b06-3aa9-11ef-86ec-acde48001122', NULL); +COMMIT; + +-- ---------------------------- +-- Table structure for act_re_model +-- ---------------------------- +DROP TABLE IF EXISTS `act_re_model`; +CREATE TABLE `act_re_model` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` timestamp(3) NULL DEFAULT NULL, + `LAST_UPDATE_TIME_` timestamp(3) NULL DEFAULT NULL, + `VERSION_` int DEFAULT NULL, + `META_INFO_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DEPLOYMENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EDITOR_SOURCE_VALUE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EDITOR_SOURCE_EXTRA_VALUE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`), + KEY `ACT_FK_MODEL_SOURCE` (`EDITOR_SOURCE_VALUE_ID_`), + KEY `ACT_FK_MODEL_SOURCE_EXTRA` (`EDITOR_SOURCE_EXTRA_VALUE_ID_`), + KEY `ACT_FK_MODEL_DEPLOYMENT` (`DEPLOYMENT_ID_`), + CONSTRAINT `ACT_FK_MODEL_DEPLOYMENT` FOREIGN KEY (`DEPLOYMENT_ID_`) REFERENCES `act_re_deployment` (`ID_`), + CONSTRAINT `ACT_FK_MODEL_SOURCE` FOREIGN KEY (`EDITOR_SOURCE_VALUE_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_MODEL_SOURCE_EXTRA` FOREIGN KEY (`EDITOR_SOURCE_EXTRA_VALUE_ID_`) REFERENCES `act_ge_bytearray` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_re_procdef +-- ---------------------------- +DROP TABLE IF EXISTS `act_re_procdef`; +CREATE TABLE `act_re_procdef` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `VERSION_` int NOT NULL, + `DEPLOYMENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `RESOURCE_NAME_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DGRM_RESOURCE_NAME_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DESCRIPTION_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HAS_START_FORM_KEY_` tinyint DEFAULT NULL, + `HAS_GRAPHICAL_NOTATION_` tinyint DEFAULT NULL, + `SUSPENSION_STATE_` int DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + `ENGINE_VERSION_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DERIVED_FROM_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DERIVED_FROM_ROOT_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DERIVED_VERSION_` int NOT NULL DEFAULT '0', + PRIMARY KEY (`ID_`), + UNIQUE KEY `ACT_UNIQ_PROCDEF` (`KEY_`,`VERSION_`,`DERIVED_VERSION_`,`TENANT_ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_re_procdef +-- ---------------------------- +BEGIN; +INSERT INTO `act_re_procdef` VALUES ('flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 1, 'http://flowable.org/bpmn', '请假申请', 'flowLeave', 1, 'bcd05b06-3aa9-11ef-86ec-acde48001122', 'flowLeave.bpmn', 'flowLeave.flowLeave.png', NULL, 0, 1, 1, '', NULL, NULL, NULL, 0); +COMMIT; + +-- ---------------------------- +-- Table structure for act_ru_actinst +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_actinst`; +CREATE TABLE `act_ru_actinst` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT '1', + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CALL_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ACT_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ACT_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `ASSIGNEE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `START_TIME_` datetime(3) NOT NULL, + `END_TIME_` datetime(3) DEFAULT NULL, + `DURATION_` bigint DEFAULT NULL, + `TRANSACTION_ORDER_` int DEFAULT NULL, + `DELETE_REASON_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_RU_ACTI_START` (`START_TIME_`), + KEY `ACT_IDX_RU_ACTI_END` (`END_TIME_`), + KEY `ACT_IDX_RU_ACTI_PROC` (`PROC_INST_ID_`), + KEY `ACT_IDX_RU_ACTI_PROC_ACT` (`PROC_INST_ID_`,`ACT_ID_`), + KEY `ACT_IDX_RU_ACTI_EXEC` (`EXECUTION_ID_`), + KEY `ACT_IDX_RU_ACTI_EXEC_ACT` (`EXECUTION_ID_`,`ACT_ID_`), + KEY `ACT_IDX_RU_ACTI_TASK` (`TASK_ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_ru_actinst +-- ---------------------------- +BEGIN; +INSERT INTO `act_ru_actinst` VALUES ('0669cc29-3aab-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', '0669cc28-3aab-11ef-86ec-acde48001122', 'Activity_0vjtv0p', '0669cc2a-3aab-11ef-86ec-acde48001122', NULL, '录入', 'userTask', 'admin', '2024-07-05 16:46:09.319', '2024-07-05 16:46:18.402', 9083, 1, NULL, ''); +INSERT INTO `act_ru_actinst` VALUES ('0bd9662c-3aab-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', '0669cc28-3aab-11ef-86ec-acde48001122', 'Flow_1u40dt7', NULL, NULL, NULL, 'sequenceFlow', NULL, '2024-07-05 16:46:18.439', '2024-07-05 16:46:18.439', 0, 1, NULL, ''); +INSERT INTO `act_ru_actinst` VALUES ('0bdf0b7d-3aab-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', '0669cc28-3aab-11ef-86ec-acde48001122', 'Activity_06g14pf', '0bdf328e-3aab-11ef-86ec-acde48001122', NULL, '审批A', 'userTask', 'admin', '2024-07-05 16:46:18.476', NULL, NULL, 2, NULL, ''); +INSERT INTO `act_ru_actinst` VALUES ('e1fbee32-3aaa-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Event_04b3gd5', NULL, NULL, NULL, 'startEvent', NULL, '2024-07-05 16:45:08.201', '2024-07-05 16:45:08.205', 4, 1, NULL, ''); +INSERT INTO `act_ru_actinst` VALUES ('e1fcd893-3aaa-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Flow_0d86buw', NULL, NULL, NULL, 'sequenceFlow', NULL, '2024-07-05 16:45:08.207', '2024-07-05 16:45:08.207', 0, 2, NULL, ''); +INSERT INTO `act_ru_actinst` VALUES ('e1fcd894-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Activity_0vjtv0p', 'e200f745-3aaa-11ef-86ec-acde48001122', NULL, '录入', 'userTask', 'admin', '2024-07-05 16:45:08.207', '2024-07-05 16:45:10.069', 1862, 3, NULL, ''); +INSERT INTO `act_ru_actinst` VALUES ('e31e4e2b-3aaa-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Flow_1u40dt7', NULL, NULL, NULL, 'sequenceFlow', NULL, '2024-07-05 16:45:10.104', '2024-07-05 16:45:10.104', 0, 1, NULL, ''); +INSERT INTO `act_ru_actinst` VALUES ('e322bafc-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Activity_06g14pf', 'e322e20d-3aaa-11ef-86ec-acde48001122', NULL, '审批A', 'userTask', 'admin', '2024-07-05 16:45:10.133', '2024-07-05 16:45:36.454', 26321, 2, NULL, ''); +INSERT INTO `act_ru_actinst` VALUES ('f2d8563f-3aaa-11ef-86ec-acde48001122', 1, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Flow_05s1j0n', NULL, NULL, NULL, 'sequenceFlow', NULL, '2024-07-05 16:45:36.489', '2024-07-05 16:45:36.489', 0, 1, NULL, ''); +INSERT INTO `act_ru_actinst` VALUES ('f2dcc310-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fbee31-3aaa-11ef-86ec-acde48001122', 'Activity_0dn7u52', 'f2dcc311-3aaa-11ef-86ec-acde48001122', NULL, '审批B', 'userTask', 'admin', '2024-07-05 16:45:36.518', '2024-07-05 16:45:58.241', 21723, 2, 'Change activity to Activity_06g14pf', ''); +INSERT INTO `act_ru_actinst` VALUES ('ffef78e5-3aaa-11ef-86ec-acde48001122', 2, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'ffef51d3-3aaa-11ef-86ec-acde48001122', 'Activity_06g14pf', 'ffef78e6-3aaa-11ef-86ec-acde48001122', NULL, '审批A', 'userTask', 'admin', '2024-07-05 16:45:58.451', '2024-07-05 16:46:09.095', 10644, 1, 'Change activity to Activity_0vjtv0p', ''); +COMMIT; + +-- ---------------------------- +-- Table structure for act_ru_deadletter_job +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_deadletter_job`; +CREATE TABLE `act_ru_deadletter_job` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `EXCLUSIVE_` tinyint(1) DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROCESS_INSTANCE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ELEMENT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ELEMENT_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CORRELATION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXCEPTION_STACK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXCEPTION_MSG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DUEDATE_` timestamp(3) NULL DEFAULT NULL, + `REPEAT_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_CFG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CUSTOM_VALUES_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` timestamp(3) NULL DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_DEADLETTER_JOB_EXCEPTION_STACK_ID` (`EXCEPTION_STACK_ID_`), + KEY `ACT_IDX_DEADLETTER_JOB_CUSTOM_VALUES_ID` (`CUSTOM_VALUES_ID_`), + KEY `ACT_IDX_DEADLETTER_JOB_CORRELATION_ID` (`CORRELATION_ID_`), + KEY `ACT_IDX_DJOB_SCOPE` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_DJOB_SUB_SCOPE` (`SUB_SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_DJOB_SCOPE_DEF` (`SCOPE_DEFINITION_ID_`,`SCOPE_TYPE_`), + KEY `ACT_FK_DEADLETTER_JOB_EXECUTION` (`EXECUTION_ID_`), + KEY `ACT_FK_DEADLETTER_JOB_PROCESS_INSTANCE` (`PROCESS_INSTANCE_ID_`), + KEY `ACT_FK_DEADLETTER_JOB_PROC_DEF` (`PROC_DEF_ID_`), + CONSTRAINT `ACT_FK_DEADLETTER_JOB_CUSTOM_VALUES` FOREIGN KEY (`CUSTOM_VALUES_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_DEADLETTER_JOB_EXCEPTION` FOREIGN KEY (`EXCEPTION_STACK_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_DEADLETTER_JOB_EXECUTION` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `act_ru_execution` (`ID_`), + CONSTRAINT `ACT_FK_DEADLETTER_JOB_PROC_DEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `act_re_procdef` (`ID_`), + CONSTRAINT `ACT_FK_DEADLETTER_JOB_PROCESS_INSTANCE` FOREIGN KEY (`PROCESS_INSTANCE_ID_`) REFERENCES `act_ru_execution` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_ru_entitylink +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_entitylink`; +CREATE TABLE `act_ru_entitylink` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `CREATE_TIME_` datetime(3) DEFAULT NULL, + `LINK_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PARENT_ELEMENT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REF_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REF_SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REF_SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ROOT_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ROOT_SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HIERARCHY_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_ENT_LNK_SCOPE` (`SCOPE_ID_`,`SCOPE_TYPE_`,`LINK_TYPE_`), + KEY `ACT_IDX_ENT_LNK_REF_SCOPE` (`REF_SCOPE_ID_`,`REF_SCOPE_TYPE_`,`LINK_TYPE_`), + KEY `ACT_IDX_ENT_LNK_ROOT_SCOPE` (`ROOT_SCOPE_ID_`,`ROOT_SCOPE_TYPE_`,`LINK_TYPE_`), + KEY `ACT_IDX_ENT_LNK_SCOPE_DEF` (`SCOPE_DEFINITION_ID_`,`SCOPE_TYPE_`,`LINK_TYPE_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_ru_event_subscr +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_event_subscr`; +CREATE TABLE `act_ru_event_subscr` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `EVENT_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `EVENT_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ACTIVITY_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CONFIGURATION_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATED_` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `LOCK_TIME_` timestamp(3) NULL DEFAULT NULL, + `LOCK_OWNER_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_EVENT_SUBSCR_CONFIG_` (`CONFIGURATION_`), + KEY `ACT_IDX_EVENT_SUBSCR_SCOPEREF_` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_FK_EVENT_EXEC` (`EXECUTION_ID_`), + CONSTRAINT `ACT_FK_EVENT_EXEC` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `act_ru_execution` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_ru_execution +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_execution`; +CREATE TABLE `act_ru_execution` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `BUSINESS_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PARENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUPER_EXEC_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ROOT_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `IS_ACTIVE_` tinyint DEFAULT NULL, + `IS_CONCURRENT_` tinyint DEFAULT NULL, + `IS_SCOPE_` tinyint DEFAULT NULL, + `IS_EVENT_SCOPE_` tinyint DEFAULT NULL, + `IS_MI_ROOT_` tinyint DEFAULT NULL, + `SUSPENSION_STATE_` int DEFAULT NULL, + `CACHED_ENT_STATE_` int DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `START_ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `START_TIME_` datetime(3) DEFAULT NULL, + `START_USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `LOCK_TIME_` timestamp(3) NULL DEFAULT NULL, + `LOCK_OWNER_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `IS_COUNT_ENABLED_` tinyint DEFAULT NULL, + `EVT_SUBSCR_COUNT_` int DEFAULT NULL, + `TASK_COUNT_` int DEFAULT NULL, + `JOB_COUNT_` int DEFAULT NULL, + `TIMER_JOB_COUNT_` int DEFAULT NULL, + `SUSP_JOB_COUNT_` int DEFAULT NULL, + `DEADLETTER_JOB_COUNT_` int DEFAULT NULL, + `EXTERNAL_WORKER_JOB_COUNT_` int DEFAULT NULL, + `VAR_COUNT_` int DEFAULT NULL, + `ID_LINK_COUNT_` int DEFAULT NULL, + `CALLBACK_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CALLBACK_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REFERENCE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `REFERENCE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROPAGATED_STAGE_INST_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `BUSINESS_STATUS_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_EXEC_BUSKEY` (`BUSINESS_KEY_`), + KEY `ACT_IDC_EXEC_ROOT` (`ROOT_PROC_INST_ID_`), + KEY `ACT_IDX_EXEC_REF_ID_` (`REFERENCE_ID_`), + KEY `ACT_FK_EXE_PROCINST` (`PROC_INST_ID_`), + KEY `ACT_FK_EXE_PARENT` (`PARENT_ID_`), + KEY `ACT_FK_EXE_SUPER` (`SUPER_EXEC_`), + KEY `ACT_FK_EXE_PROCDEF` (`PROC_DEF_ID_`), + CONSTRAINT `ACT_FK_EXE_PARENT` FOREIGN KEY (`PARENT_ID_`) REFERENCES `act_ru_execution` (`ID_`) ON DELETE CASCADE, + CONSTRAINT `ACT_FK_EXE_PROCDEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `act_re_procdef` (`ID_`), + CONSTRAINT `ACT_FK_EXE_PROCINST` FOREIGN KEY (`PROC_INST_ID_`) REFERENCES `act_ru_execution` (`ID_`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `ACT_FK_EXE_SUPER` FOREIGN KEY (`SUPER_EXEC_`) REFERENCES `act_ru_execution` (`ID_`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_ru_execution +-- ---------------------------- +BEGIN; +INSERT INTO `act_ru_execution` VALUES ('0669cc28-3aab-11ef-86ec-acde48001122', 2, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', NULL, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'Activity_06g14pf', 1, 0, 0, 0, 0, 1, NULL, '', NULL, NULL, '2024-07-05 16:46:09.288', NULL, NULL, NULL, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL); +INSERT INTO `act_ru_execution` VALUES ('e1fb2ada-3aaa-11ef-86ec-acde48001122', 1, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', '1809146480452177920', NULL, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', NULL, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, 1, 0, 1, 0, 0, 1, NULL, '', NULL, 'Event_04b3gd5', '2024-07-05 16:45:08.196', 'admin', NULL, NULL, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL); +COMMIT; + +-- ---------------------------- +-- Table structure for act_ru_external_job +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_external_job`; +CREATE TABLE `act_ru_external_job` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `LOCK_EXP_TIME_` timestamp(3) NULL DEFAULT NULL, + `LOCK_OWNER_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXCLUSIVE_` tinyint(1) DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROCESS_INSTANCE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ELEMENT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ELEMENT_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CORRELATION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `RETRIES_` int DEFAULT NULL, + `EXCEPTION_STACK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXCEPTION_MSG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DUEDATE_` timestamp(3) NULL DEFAULT NULL, + `REPEAT_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_CFG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CUSTOM_VALUES_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` timestamp(3) NULL DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_EXTERNAL_JOB_EXCEPTION_STACK_ID` (`EXCEPTION_STACK_ID_`), + KEY `ACT_IDX_EXTERNAL_JOB_CUSTOM_VALUES_ID` (`CUSTOM_VALUES_ID_`), + KEY `ACT_IDX_EXTERNAL_JOB_CORRELATION_ID` (`CORRELATION_ID_`), + KEY `ACT_IDX_EJOB_SCOPE` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_EJOB_SUB_SCOPE` (`SUB_SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_EJOB_SCOPE_DEF` (`SCOPE_DEFINITION_ID_`,`SCOPE_TYPE_`), + CONSTRAINT `ACT_FK_EXTERNAL_JOB_CUSTOM_VALUES` FOREIGN KEY (`CUSTOM_VALUES_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_EXTERNAL_JOB_EXCEPTION` FOREIGN KEY (`EXCEPTION_STACK_ID_`) REFERENCES `act_ge_bytearray` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_ru_history_job +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_history_job`; +CREATE TABLE `act_ru_history_job` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `LOCK_EXP_TIME_` timestamp(3) NULL DEFAULT NULL, + `LOCK_OWNER_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `RETRIES_` int DEFAULT NULL, + `EXCEPTION_STACK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXCEPTION_MSG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_CFG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CUSTOM_VALUES_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ADV_HANDLER_CFG_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` timestamp(3) NULL DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_ru_identitylink +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_identitylink`; +CREATE TABLE `act_ru_identitylink` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `GROUP_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_IDENT_LNK_USER` (`USER_ID_`), + KEY `ACT_IDX_IDENT_LNK_GROUP` (`GROUP_ID_`), + KEY `ACT_IDX_IDENT_LNK_SCOPE` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_IDENT_LNK_SUB_SCOPE` (`SUB_SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_IDENT_LNK_SCOPE_DEF` (`SCOPE_DEFINITION_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_ATHRZ_PROCEDEF` (`PROC_DEF_ID_`), + KEY `ACT_FK_TSKASS_TASK` (`TASK_ID_`), + KEY `ACT_FK_IDL_PROCINST` (`PROC_INST_ID_`), + CONSTRAINT `ACT_FK_ATHRZ_PROCEDEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `act_re_procdef` (`ID_`), + CONSTRAINT `ACT_FK_IDL_PROCINST` FOREIGN KEY (`PROC_INST_ID_`) REFERENCES `act_ru_execution` (`ID_`), + CONSTRAINT `ACT_FK_TSKASS_TASK` FOREIGN KEY (`TASK_ID_`) REFERENCES `act_ru_task` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_ru_identitylink +-- ---------------------------- +BEGIN; +INSERT INTO `act_ru_identitylink` VALUES ('e1fb51eb-3aaa-11ef-86ec-acde48001122', 1, NULL, 'starter', 'admin', NULL, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL); +INSERT INTO `act_ru_identitylink` VALUES ('e2014567-3aaa-11ef-86ec-acde48001122', 1, NULL, 'participant', 'admin', NULL, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL); +INSERT INTO `act_ru_identitylink` VALUES ('e2fd319a-3aaa-11ef-86ec-acde48001122', 1, NULL, 'participant', 'admin', NULL, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL); +COMMIT; + +-- ---------------------------- +-- Table structure for act_ru_job +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_job`; +CREATE TABLE `act_ru_job` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `LOCK_EXP_TIME_` timestamp(3) NULL DEFAULT NULL, + `LOCK_OWNER_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXCLUSIVE_` tinyint(1) DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROCESS_INSTANCE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ELEMENT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ELEMENT_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CORRELATION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `RETRIES_` int DEFAULT NULL, + `EXCEPTION_STACK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXCEPTION_MSG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DUEDATE_` timestamp(3) NULL DEFAULT NULL, + `REPEAT_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_CFG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CUSTOM_VALUES_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` timestamp(3) NULL DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_JOB_EXCEPTION_STACK_ID` (`EXCEPTION_STACK_ID_`), + KEY `ACT_IDX_JOB_CUSTOM_VALUES_ID` (`CUSTOM_VALUES_ID_`), + KEY `ACT_IDX_JOB_CORRELATION_ID` (`CORRELATION_ID_`), + KEY `ACT_IDX_JOB_SCOPE` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_JOB_SUB_SCOPE` (`SUB_SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_JOB_SCOPE_DEF` (`SCOPE_DEFINITION_ID_`,`SCOPE_TYPE_`), + KEY `ACT_FK_JOB_EXECUTION` (`EXECUTION_ID_`), + KEY `ACT_FK_JOB_PROCESS_INSTANCE` (`PROCESS_INSTANCE_ID_`), + KEY `ACT_FK_JOB_PROC_DEF` (`PROC_DEF_ID_`), + CONSTRAINT `ACT_FK_JOB_CUSTOM_VALUES` FOREIGN KEY (`CUSTOM_VALUES_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_JOB_EXCEPTION` FOREIGN KEY (`EXCEPTION_STACK_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_JOB_EXECUTION` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `act_ru_execution` (`ID_`), + CONSTRAINT `ACT_FK_JOB_PROC_DEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `act_re_procdef` (`ID_`), + CONSTRAINT `ACT_FK_JOB_PROCESS_INSTANCE` FOREIGN KEY (`PROCESS_INSTANCE_ID_`) REFERENCES `act_ru_execution` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_ru_suspended_job +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_suspended_job`; +CREATE TABLE `act_ru_suspended_job` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `EXCLUSIVE_` tinyint(1) DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROCESS_INSTANCE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ELEMENT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ELEMENT_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CORRELATION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `RETRIES_` int DEFAULT NULL, + `EXCEPTION_STACK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXCEPTION_MSG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DUEDATE_` timestamp(3) NULL DEFAULT NULL, + `REPEAT_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_CFG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CUSTOM_VALUES_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` timestamp(3) NULL DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_SUSPENDED_JOB_EXCEPTION_STACK_ID` (`EXCEPTION_STACK_ID_`), + KEY `ACT_IDX_SUSPENDED_JOB_CUSTOM_VALUES_ID` (`CUSTOM_VALUES_ID_`), + KEY `ACT_IDX_SUSPENDED_JOB_CORRELATION_ID` (`CORRELATION_ID_`), + KEY `ACT_IDX_SJOB_SCOPE` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_SJOB_SUB_SCOPE` (`SUB_SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_SJOB_SCOPE_DEF` (`SCOPE_DEFINITION_ID_`,`SCOPE_TYPE_`), + KEY `ACT_FK_SUSPENDED_JOB_EXECUTION` (`EXECUTION_ID_`), + KEY `ACT_FK_SUSPENDED_JOB_PROCESS_INSTANCE` (`PROCESS_INSTANCE_ID_`), + KEY `ACT_FK_SUSPENDED_JOB_PROC_DEF` (`PROC_DEF_ID_`), + CONSTRAINT `ACT_FK_SUSPENDED_JOB_CUSTOM_VALUES` FOREIGN KEY (`CUSTOM_VALUES_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_SUSPENDED_JOB_EXCEPTION` FOREIGN KEY (`EXCEPTION_STACK_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_SUSPENDED_JOB_EXECUTION` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `act_ru_execution` (`ID_`), + CONSTRAINT `ACT_FK_SUSPENDED_JOB_PROC_DEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `act_re_procdef` (`ID_`), + CONSTRAINT `ACT_FK_SUSPENDED_JOB_PROCESS_INSTANCE` FOREIGN KEY (`PROCESS_INSTANCE_ID_`) REFERENCES `act_ru_execution` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_ru_task +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_task`; +CREATE TABLE `act_ru_task` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROPAGATED_STAGE_INST_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `STATE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PARENT_TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DESCRIPTION_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `OWNER_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ASSIGNEE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DELEGATION_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PRIORITY_` int DEFAULT NULL, + `CREATE_TIME_` timestamp(3) NULL DEFAULT NULL, + `IN_PROGRESS_TIME_` datetime(3) DEFAULT NULL, + `IN_PROGRESS_STARTED_BY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CLAIM_TIME_` datetime(3) DEFAULT NULL, + `CLAIMED_BY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUSPENDED_TIME_` datetime(3) DEFAULT NULL, + `SUSPENDED_BY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `IN_PROGRESS_DUE_DATE_` datetime(3) DEFAULT NULL, + `DUE_DATE_` datetime(3) DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUSPENSION_STATE_` int DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + `FORM_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `IS_COUNT_ENABLED_` tinyint DEFAULT NULL, + `VAR_COUNT_` int DEFAULT NULL, + `ID_LINK_COUNT_` int DEFAULT NULL, + `SUB_TASK_COUNT_` int DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_TASK_CREATE` (`CREATE_TIME_`), + KEY `ACT_IDX_TASK_SCOPE` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_TASK_SUB_SCOPE` (`SUB_SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_TASK_SCOPE_DEF` (`SCOPE_DEFINITION_ID_`,`SCOPE_TYPE_`), + KEY `ACT_FK_TASK_EXE` (`EXECUTION_ID_`), + KEY `ACT_FK_TASK_PROCINST` (`PROC_INST_ID_`), + KEY `ACT_FK_TASK_PROCDEF` (`PROC_DEF_ID_`), + CONSTRAINT `ACT_FK_TASK_EXE` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `act_ru_execution` (`ID_`), + CONSTRAINT `ACT_FK_TASK_PROCDEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `act_re_procdef` (`ID_`), + CONSTRAINT `ACT_FK_TASK_PROCINST` FOREIGN KEY (`PROC_INST_ID_`) REFERENCES `act_ru_execution` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_ru_task +-- ---------------------------- +BEGIN; +INSERT INTO `act_ru_task` VALUES ('0bdf328e-3aab-11ef-86ec-acde48001122', 1, '0669cc28-3aab-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, NULL, 'created', '审批A', NULL, NULL, 'Activity_06g14pf', NULL, 'admin', NULL, 50, '2024-07-05 16:46:18.476', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '', '{\"formId\":\"1809132635633487872\",\"readOnly\":true,\"groupType\":\"ASSIGNEE\"}', 1, 0, 0, 0); +COMMIT; + +-- ---------------------------- +-- Table structure for act_ru_timer_job +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_timer_job`; +CREATE TABLE `act_ru_timer_job` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `LOCK_EXP_TIME_` timestamp(3) NULL DEFAULT NULL, + `LOCK_OWNER_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXCLUSIVE_` tinyint(1) DEFAULT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROCESS_INSTANCE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ELEMENT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `ELEMENT_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_DEFINITION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CORRELATION_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `RETRIES_` int DEFAULT NULL, + `EXCEPTION_STACK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `EXCEPTION_MSG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DUEDATE_` timestamp(3) NULL DEFAULT NULL, + `REPEAT_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `HANDLER_CFG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CUSTOM_VALUES_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` timestamp(3) NULL DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_TIMER_JOB_EXCEPTION_STACK_ID` (`EXCEPTION_STACK_ID_`), + KEY `ACT_IDX_TIMER_JOB_CUSTOM_VALUES_ID` (`CUSTOM_VALUES_ID_`), + KEY `ACT_IDX_TIMER_JOB_CORRELATION_ID` (`CORRELATION_ID_`), + KEY `ACT_IDX_TIMER_JOB_DUEDATE` (`DUEDATE_`), + KEY `ACT_IDX_TJOB_SCOPE` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_TJOB_SUB_SCOPE` (`SUB_SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_TJOB_SCOPE_DEF` (`SCOPE_DEFINITION_ID_`,`SCOPE_TYPE_`), + KEY `ACT_FK_TIMER_JOB_EXECUTION` (`EXECUTION_ID_`), + KEY `ACT_FK_TIMER_JOB_PROCESS_INSTANCE` (`PROCESS_INSTANCE_ID_`), + KEY `ACT_FK_TIMER_JOB_PROC_DEF` (`PROC_DEF_ID_`), + CONSTRAINT `ACT_FK_TIMER_JOB_CUSTOM_VALUES` FOREIGN KEY (`CUSTOM_VALUES_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_TIMER_JOB_EXCEPTION` FOREIGN KEY (`EXCEPTION_STACK_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_TIMER_JOB_EXECUTION` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `act_ru_execution` (`ID_`), + CONSTRAINT `ACT_FK_TIMER_JOB_PROC_DEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `act_re_procdef` (`ID_`), + CONSTRAINT `ACT_FK_TIMER_JOB_PROCESS_INSTANCE` FOREIGN KEY (`PROCESS_INSTANCE_ID_`) REFERENCES `act_ru_execution` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for act_ru_variable +-- ---------------------------- +DROP TABLE IF EXISTS `act_ru_variable`; +CREATE TABLE `act_ru_variable` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `BYTEARRAY_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `DOUBLE_` double DEFAULT NULL, + `LONG_` bigint DEFAULT NULL, + `TEXT_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TEXT2_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `META_INFO_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + KEY `ACT_IDX_RU_VAR_SCOPE_ID_TYPE` (`SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_IDX_RU_VAR_SUB_ID_TYPE` (`SUB_SCOPE_ID_`,`SCOPE_TYPE_`), + KEY `ACT_FK_VAR_BYTEARRAY` (`BYTEARRAY_ID_`), + KEY `ACT_IDX_VARIABLE_TASK_ID` (`TASK_ID_`), + KEY `ACT_FK_VAR_EXE` (`EXECUTION_ID_`), + KEY `ACT_FK_VAR_PROCINST` (`PROC_INST_ID_`), + CONSTRAINT `ACT_FK_VAR_BYTEARRAY` FOREIGN KEY (`BYTEARRAY_ID_`) REFERENCES `act_ge_bytearray` (`ID_`), + CONSTRAINT `ACT_FK_VAR_EXE` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `act_ru_execution` (`ID_`), + CONSTRAINT `ACT_FK_VAR_PROCINST` FOREIGN KEY (`PROC_INST_ID_`) REFERENCES `act_ru_execution` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of act_ru_variable +-- ---------------------------- +BEGIN; +INSERT INTO `act_ru_variable` VALUES ('e1fb78fc-3aaa-11ef-86ec-acde48001122', 1, 'string', 'copyDataMap_Activity_0vjtv0p', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{}', NULL, NULL); +INSERT INTO `act_ru_variable` VALUES ('e1fbc71d-3aaa-11ef-86ec-acde48001122', 1, 'string', 'startUserName', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'admin', NULL, NULL); +INSERT INTO `act_ru_variable` VALUES ('e1fbc71e-3aaa-11ef-86ec-acde48001122', 1, 'string', 'initiator', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'admin', NULL, NULL); +INSERT INTO `act_ru_variable` VALUES ('e1fbc71f-3aaa-11ef-86ec-acde48001122', 1, 'string', 'copyDataMap_Activity_06g14pf', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{}', NULL, NULL); +INSERT INTO `act_ru_variable` VALUES ('e1fbc720-3aaa-11ef-86ec-acde48001122', 1, 'string', 'copyDataMap_Activity_0dn7u52', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{}', NULL, NULL); +INSERT INTO `act_ru_variable` VALUES ('e2fd0a88-3aaa-11ef-86ec-acde48001122', 1, 'string', 'submitUser', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'admin', NULL, NULL); +INSERT INTO `act_ru_variable` VALUES ('e2fd0a89-3aaa-11ef-86ec-acde48001122', 1, 'string', 'operationType', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'agree', NULL, NULL); +COMMIT; + +-- ---------------------------- +-- Table structure for flw_channel_definition +-- ---------------------------- +DROP TABLE IF EXISTS `flw_channel_definition`; +CREATE TABLE `flw_channel_definition` ( + `ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `VERSION_` int DEFAULT NULL, + `KEY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `DEPLOYMENT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `CREATE_TIME_` datetime(3) DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `RESOURCE_NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `DESCRIPTION_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `TYPE_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `IMPLEMENTATION_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + UNIQUE KEY `ACT_IDX_CHANNEL_DEF_UNIQ` (`KEY_`,`VERSION_`,`TENANT_ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- ---------------------------- +-- Table structure for flw_ev_databasechangelog +-- ---------------------------- +DROP TABLE IF EXISTS `flw_ev_databasechangelog`; +CREATE TABLE `flw_ev_databasechangelog` ( + `ID` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `AUTHOR` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `FILENAME` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `DATEEXECUTED` datetime NOT NULL, + `ORDEREXECUTED` int NOT NULL, + `EXECTYPE` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `MD5SUM` varchar(35) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `DESCRIPTION` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `COMMENTS` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `TAG` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `LIQUIBASE` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `CONTEXTS` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `LABELS` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `DEPLOYMENT_ID` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- ---------------------------- +-- Records of flw_ev_databasechangelog +-- ---------------------------- +BEGIN; +INSERT INTO `flw_ev_databasechangelog` VALUES ('1', 'flowable', 'org/flowable/eventregistry/db/liquibase/flowable-eventregistry-db-changelog.xml', '2024-01-23 14:13:11', 1, 'EXECUTED', '8:1b0c48c9cf7945be799d868a2626d687', 'createTable tableName=FLW_EVENT_DEPLOYMENT; createTable tableName=FLW_EVENT_RESOURCE; createTable tableName=FLW_EVENT_DEFINITION; createIndex indexName=ACT_IDX_EVENT_DEF_UNIQ, tableName=FLW_EVENT_DEFINITION; createTable tableName=FLW_CHANNEL_DEFIN...', '', NULL, '4.20.0', NULL, NULL, '5990391167'); +INSERT INTO `flw_ev_databasechangelog` VALUES ('2', 'flowable', 'org/flowable/eventregistry/db/liquibase/flowable-eventregistry-db-changelog.xml', '2024-01-23 14:13:11', 2, 'EXECUTED', '8:0ea825feb8e470558f0b5754352b9cda', 'addColumn tableName=FLW_CHANNEL_DEFINITION; addColumn tableName=FLW_CHANNEL_DEFINITION', '', NULL, '4.20.0', NULL, NULL, '5990391167'); +INSERT INTO `flw_ev_databasechangelog` VALUES ('3', 'flowable', 'org/flowable/eventregistry/db/liquibase/flowable-eventregistry-db-changelog.xml', '2024-01-23 14:13:11', 3, 'EXECUTED', '8:3c2bb293350b5cbe6504331980c9dcee', 'customChange', '', NULL, '4.20.0', NULL, NULL, '5990391167'); +COMMIT; + +-- ---------------------------- +-- Table structure for flw_ev_databasechangeloglock +-- ---------------------------- +DROP TABLE IF EXISTS `flw_ev_databasechangeloglock`; +CREATE TABLE `flw_ev_databasechangeloglock` ( + `ID` int NOT NULL, + `LOCKED` bit(1) NOT NULL, + `LOCKGRANTED` datetime DEFAULT NULL, + `LOCKEDBY` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- ---------------------------- +-- Records of flw_ev_databasechangeloglock +-- ---------------------------- +BEGIN; +INSERT INTO `flw_ev_databasechangeloglock` VALUES (1, b'0', NULL, NULL); +COMMIT; + +-- ---------------------------- +-- Table structure for flw_event_definition +-- ---------------------------- +DROP TABLE IF EXISTS `flw_event_definition`; +CREATE TABLE `flw_event_definition` ( + `ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `VERSION_` int DEFAULT NULL, + `KEY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `DEPLOYMENT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `RESOURCE_NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `DESCRIPTION_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + PRIMARY KEY (`ID_`), + UNIQUE KEY `ACT_IDX_EVENT_DEF_UNIQ` (`KEY_`,`VERSION_`,`TENANT_ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- ---------------------------- +-- Table structure for flw_event_deployment +-- ---------------------------- +DROP TABLE IF EXISTS `flw_event_deployment`; +CREATE TABLE `flw_event_deployment` ( + `ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `CATEGORY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `DEPLOY_TIME_` datetime(3) DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `PARENT_DEPLOYMENT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- ---------------------------- +-- Table structure for flw_event_resource +-- ---------------------------- +DROP TABLE IF EXISTS `flw_event_resource`; +CREATE TABLE `flw_event_resource` ( + `ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `DEPLOYMENT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `RESOURCE_BYTES_` longblob, + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- ---------------------------- +-- Table structure for flw_ru_batch +-- ---------------------------- +DROP TABLE IF EXISTS `flw_ru_batch`; +CREATE TABLE `flw_ru_batch` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `TYPE_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `SEARCH_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SEARCH_KEY2_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` datetime(3) NOT NULL, + `COMPLETE_TIME_` datetime(3) DEFAULT NULL, + `STATUS_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `BATCH_DOC_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for flw_ru_batch_part +-- ---------------------------- +DROP TABLE IF EXISTS `flw_ru_batch_part`; +CREATE TABLE `flw_ru_batch_part` ( + `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `REV_` int DEFAULT NULL, + `BATCH_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TYPE_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `SCOPE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SUB_SCOPE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SCOPE_TYPE_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SEARCH_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `SEARCH_KEY2_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME_` datetime(3) NOT NULL, + `COMPLETE_TIME_` datetime(3) DEFAULT NULL, + `STATUS_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `RESULT_DOC_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '', + PRIMARY KEY (`ID_`), + KEY `FLW_IDX_BATCH_PART` (`BATCH_ID_`), + CONSTRAINT `FLW_FK_BATCH_PART_PARENT` FOREIGN KEY (`BATCH_ID_`) REFERENCES `flw_ru_batch` (`ID_`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; + +-- ---------------------------- +-- Table structure for zz_flow_category +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_category`; +CREATE TABLE `zz_flow_category` ( + `category_id` bigint NOT NULL COMMENT '主键Id', + `tenant_id` bigint DEFAULT NULL COMMENT '租户Id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用编码', + `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '显示名称', + `code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '分类编码', + `show_order` int NOT NULL COMMENT '实现顺序', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + PRIMARY KEY (`category_id`) USING BTREE, + KEY `idx_tenant_id` (`tenant_id`) USING BTREE, + KEY `idx_code` (`code`) USING BTREE, + KEY `idx_app_code` (`app_code`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程分类表'; + +-- ---------------------------- +-- Records of zz_flow_category +-- ---------------------------- +BEGIN; +INSERT INTO `zz_flow_category` VALUES (1809051198460792832, NULL, NULL, '测试分类', 'TEST', 1, '2024-07-05 10:26:31', 1809038124504846336, '2024-07-05 10:26:31', 1809038124504846336); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_flow_entry +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_entry`; +CREATE TABLE `zz_flow_entry` ( + `entry_id` bigint NOT NULL COMMENT '主键', + `tenant_id` bigint DEFAULT NULL COMMENT '租户Id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用编码', + `process_definition_name` varchar(200) NOT NULL COMMENT '流程名称', + `process_definition_key` varchar(150) NOT NULL COMMENT '流程标识Key', + `category_id` bigint NOT NULL COMMENT '流程分类', + `main_entry_publish_id` bigint DEFAULT NULL COMMENT '工作流部署的发布主版本Id', + `latest_publish_time` datetime DEFAULT NULL COMMENT '最新发布时间', + `status` int NOT NULL COMMENT '流程状态', + `bpmn_xml` longtext COMMENT '流程定义的xml', + `diagram_type` int NOT NULL COMMENT '流程图类型', + `bind_form_type` int NOT NULL COMMENT '绑定表单类型', + `page_id` bigint DEFAULT NULL COMMENT '在线表单的页面Id', + `default_form_id` bigint DEFAULT NULL COMMENT '在线表单Id', + `default_router_name` varchar(255) DEFAULT NULL COMMENT '静态表单的缺省路由名称', + `encoded_rule` varchar(255) DEFAULT NULL COMMENT '工单表编码字段的编码规则', + `extension_data` varchar(3000) DEFAULT NULL COMMENT '流程的自定义扩展数据', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + PRIMARY KEY (`entry_id`) USING BTREE, + KEY `idx_process_definition_key` (`process_definition_key`) USING BTREE, + KEY `idx_app_code` (`app_code`) USING BTREE, + KEY `idx_category_id` (`category_id`) USING BTREE, + KEY `idx_tenant_id` (`tenant_id`) USING BTREE, + KEY `idx_status` (`status`) USING BTREE, + KEY `idx_process_definition_name` (`process_definition_name`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='流程管理表'; + +-- ---------------------------- +-- Records of zz_flow_entry +-- ---------------------------- +BEGIN; +INSERT INTO `zz_flow_entry` VALUES (1809143991627681792, NULL, NULL, '请假申请', 'flowLeave', 1809051198460792832, 1809144428770627584, '2024-07-05 16:36:59', 1, '\n\n \n \n \n \n \n \n \n Flow_0d86buw\n \n \n \n \n \n Flow_1bxwcza\n \n \n \n \n \n \n \n \n \n \n Flow_0d86buw\n Flow_1u40dt7\n \n \n \n \n \n \n \n \n \n \n Flow_1u40dt7\n Flow_05s1j0n\n \n \n \n \n \n \n \n \n \n \n Flow_05s1j0n\n Flow_1bxwcza\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n', 0, 0, 1809132177523216384, 1809132635633487872, NULL, '{\"middle\":\"DD\",\"idWidth\":5,\"prefix\":\"LL\",\"precisionTo\":\"DAYS\",\"calculateWhenView\":true}', '{\"approvalStatusDict\":[{\"id\":1,\"name\":\"同意\",\"_X_ROW_KEY\":\"row_57\"},{\"id\":2,\"name\":\"拒绝\",\"_X_ROW_KEY\":\"row_58\"},{\"id\":3,\"name\":\"驳回\",\"_X_ROW_KEY\":\"row_59\"},{\"id\":4,\"name\":\"会签同意\",\"_X_ROW_KEY\":\"row_60\"},{\"id\":5,\"name\":\"会签拒绝\",\"_X_ROW_KEY\":\"row_61\"}],\"notifyTypes\":[\"email\"],\"cascadeDeleteBusinessData\":true,\"supportRevive\":false}', '2024-07-05 16:36:39', 1808020007993479168, '2024-07-05 16:35:15', 1808020007993479168); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_flow_entry_publish +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_entry_publish`; +CREATE TABLE `zz_flow_entry_publish` ( + `entry_publish_id` bigint NOT NULL COMMENT '主键Id', + `entry_id` bigint NOT NULL COMMENT '流程Id', + `process_definition_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程引擎的定义Id', + `deploy_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程引擎的部署Id', + `publish_version` int NOT NULL COMMENT '发布版本', + `active_status` bit(1) NOT NULL COMMENT '激活状态', + `main_version` bit(1) NOT NULL COMMENT '是否为主版本', + `extension_data` varchar(3000) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '流程的自定义扩展数据', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + `publish_time` datetime NOT NULL COMMENT '发布时间', + `init_task_info` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '第一个非开始节点任务的附加信息', + `analyzed_node_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '分析后的节点JSON信息', + PRIMARY KEY (`entry_publish_id`) USING BTREE, + UNIQUE KEY `uk_process_definition_id` (`process_definition_id`) USING BTREE, + KEY `idx_entry_id` (`entry_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程发布表'; + +-- ---------------------------- +-- Records of zz_flow_entry_publish +-- ---------------------------- +BEGIN; +INSERT INTO `zz_flow_entry_publish` VALUES (1809144428770627584, 1809143991627681792, 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'bcd05b06-3aa9-11ef-86ec-acde48001122', 1, b'1', b'1', '{\"approvalStatusDict\":[{\"id\":1,\"name\":\"同意\",\"_X_ROW_KEY\":\"row_57\"},{\"id\":2,\"name\":\"拒绝\",\"_X_ROW_KEY\":\"row_58\"},{\"id\":3,\"name\":\"驳回\",\"_X_ROW_KEY\":\"row_59\"},{\"id\":4,\"name\":\"会签同意\",\"_X_ROW_KEY\":\"row_60\"},{\"id\":5,\"name\":\"会签拒绝\",\"_X_ROW_KEY\":\"row_61\"}],\"notifyTypes\":[\"email\"],\"cascadeDeleteBusinessData\":true,\"supportRevive\":false}', 1808020007993479168, '2024-07-05 16:36:59', '{\"assignee\":\"${startUserName}\",\"formId\":1809132635633487872,\"groupType\":\"ASSIGNEE\",\"operationList\":[{\"showOrder\":\"0\",\"id\":\"1720168540672\",\"label\":\"同意\",\"type\":\"agree\"}],\"readOnly\":false,\"taskKey\":\"Activity_0vjtv0p\",\"taskType\":1,\"variableList\":[]}', NULL); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_flow_entry_publish_variable +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_entry_publish_variable`; +CREATE TABLE `zz_flow_entry_publish_variable` ( + `variable_id` bigint NOT NULL COMMENT '主键Id', + `entry_publish_id` bigint NOT NULL COMMENT '流程Id', + `variable_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '变量名', + `show_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '显示名', + `variable_type` int NOT NULL COMMENT '变量类型', + `bind_datasource_id` bigint DEFAULT NULL COMMENT '绑定数据源Id', + `bind_relation_id` bigint DEFAULT NULL COMMENT '绑定数据源关联Id', + `bind_column_id` bigint DEFAULT NULL COMMENT '绑定字段Id', + `builtin` bit(1) NOT NULL COMMENT '是否内置', + PRIMARY KEY (`variable_id`) USING BTREE, + KEY `idx_entry_publish_id` (`entry_publish_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程发布变量表'; + +-- ---------------------------- +-- Records of zz_flow_entry_publish_variable +-- ---------------------------- +BEGIN; +INSERT INTO `zz_flow_entry_publish_variable` VALUES (1809144430116999168, 1809144428770627584, 'operationType', '审批类型', 1, NULL, NULL, NULL, b'1'); +INSERT INTO `zz_flow_entry_publish_variable` VALUES (1809144430116999169, 1809144428770627584, 'startUserName', '流程启动用户', 0, NULL, NULL, NULL, b'1'); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_flow_entry_variable +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_entry_variable`; +CREATE TABLE `zz_flow_entry_variable` ( + `variable_id` bigint NOT NULL COMMENT '主键Id', + `entry_id` bigint NOT NULL COMMENT '流程Id', + `variable_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '变量名', + `show_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '显示名', + `variable_type` int NOT NULL COMMENT '变量类型', + `bind_datasource_id` bigint DEFAULT NULL COMMENT '绑定数据源Id', + `bind_relation_id` bigint DEFAULT NULL COMMENT '绑定数据源关联Id', + `bind_column_id` bigint DEFAULT NULL COMMENT '绑定字段Id', + `builtin` bit(1) NOT NULL COMMENT '是否内置', + `create_time` datetime NOT NULL COMMENT '创建时间', + PRIMARY KEY (`variable_id`) USING BTREE, + UNIQUE KEY `uk_entry_id_variable_name` (`entry_id`,`variable_name`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程变量表'; + +-- ---------------------------- +-- Records of zz_flow_entry_variable +-- ---------------------------- +BEGIN; +INSERT INTO `zz_flow_entry_variable` VALUES (1809143992151969793, 1809143991627681792, 'operationType', '审批类型', 1, NULL, NULL, NULL, b'1', '2024-07-05 16:35:15'); +INSERT INTO `zz_flow_entry_variable` VALUES (1809143992630120448, 1809143991627681792, 'startUserName', '流程启动用户', 0, NULL, NULL, NULL, b'1', '2024-07-05 16:35:15'); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_flow_message +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_message`; +CREATE TABLE `zz_flow_message` ( + `message_id` bigint NOT NULL COMMENT '主键Id', + `tenant_id` bigint DEFAULT NULL COMMENT '租户Id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用Id', + `message_type` tinyint NOT NULL COMMENT '消息类型', + `message_content` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '消息内容', + `remind_count` int DEFAULT '0' COMMENT '催办次数', + `work_order_id` bigint DEFAULT NULL COMMENT '工单Id', + `process_definition_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程定义Id', + `process_definition_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程定义标识', + `process_definition_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程定义名称', + `process_instance_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '流程实例Id', + `process_instance_initiator` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '流程实例发起者', + `task_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '流程任务Id', + `task_definition_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '流程任务定义标识', + `task_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '流程任务名称', + `task_start_time` datetime DEFAULT NULL COMMENT '任务开始时间', + `task_finished` bit(1) NOT NULL DEFAULT b'0' COMMENT '任务是否已完成', + `task_assignee` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '任务指派人登录名', + `business_data_shot` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '业务数据快照', + `online_form_data` bit(1) DEFAULT NULL COMMENT '是否为在线表单消息数据', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + `create_username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '创建者显示名', + PRIMARY KEY (`message_id`) USING BTREE, + KEY `idx_tenant_id` (`tenant_id`) USING BTREE, + KEY `idx_app_code` (`app_code`) USING BTREE, + KEY `idx_notified_username` (`task_assignee`) USING BTREE, + KEY `idx_process_instance_id` (`process_instance_id`) USING BTREE, + KEY `idx_message_type` (`message_type`) USING BTREE, + KEY `idx_task_id` (`task_id`) USING BTREE, + KEY `idx_task_finished` (`task_finished`) USING BTREE, + KEY `idx_update_time` (`update_time`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程消息通知表'; + +-- ---------------------------- +-- Table structure for zz_flow_msg_candidate_identity +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_msg_candidate_identity`; +CREATE TABLE `zz_flow_msg_candidate_identity` ( + `id` bigint NOT NULL COMMENT '主键Id', + `message_id` bigint NOT NULL COMMENT '流程任务Id', + `candidate_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '候选身份类型', + `candidate_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '候选身份Id', + PRIMARY KEY (`id`), + KEY `idx_candidate_id` (`candidate_id`) USING BTREE, + KEY `idx_message_id` (`message_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程消息通知候选人表'; + +-- ---------------------------- +-- Table structure for zz_flow_msg_identity_operation +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_msg_identity_operation`; +CREATE TABLE `zz_flow_msg_identity_operation` ( + `id` bigint NOT NULL COMMENT '主键Id', + `message_id` bigint NOT NULL COMMENT '流程任务Id', + `login_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '用户登录名', + `operation_type` int NOT NULL COMMENT '操作类型', + `operation_time` datetime NOT NULL COMMENT '操作时间', + PRIMARY KEY (`id`), + KEY `idx_message_id` (`message_id`) USING BTREE, + KEY `idx_login_name` (`login_name`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程消息候选人操作表'; + +-- ---------------------------- +-- Table structure for zz_flow_multi_instance_trans +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_multi_instance_trans`; +CREATE TABLE `zz_flow_multi_instance_trans` ( + `id` bigint NOT NULL COMMENT '主键Id', + `process_instance_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程实例Id', + `task_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '任务Id', + `task_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '任务标识', + `multi_instance_exec_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '会签任务的执行Id', + `execution_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '任务的执行Id', + `assignee_list` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '会签指派人列表', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + `create_login_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '创建者登录名', + `create_username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '创建者用户名', + `create_time` datetime NOT NULL COMMENT '创建时间', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_execution_id_task_id` (`execution_id`,`task_id`) USING BTREE, + KEY `idx_multi_instance_exec_id` (`multi_instance_exec_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程多实例任务审批流水表'; + +-- ---------------------------- +-- Table structure for zz_flow_task_comment +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_task_comment`; +CREATE TABLE `zz_flow_task_comment` ( + `id` bigint NOT NULL COMMENT '主键Id', + `process_instance_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程实例Id', + `task_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '任务Id', + `task_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '任务标识', + `task_name` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '任务名称', + `target_task_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '目标任务标识', + `execution_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '任务的执行Id', + `multi_instance_exec_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '会签任务的执行Id', + `approval_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '审批类型', + `task_comment` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '批注内容', + `delegate_assignee` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '委托指定人,比如加签、转办等', + `custom_business_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '自定义数据。开发者可自行扩展,推荐使用JSON格式数据', + `head_image_url` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '审批用户头像', + `create_user_id` bigint DEFAULT NULL COMMENT '创建者Id', + `create_login_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '创建者登录名', + `create_username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '创建者用户名', + `create_time` datetime NOT NULL COMMENT '创建时间', + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_multi_instance_exec_id` (`multi_instance_exec_id`) USING BTREE, + KEY `idx_process_instance_id` (`process_instance_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程任务审批表'; + +-- ---------------------------- +-- Records of zz_flow_task_comment +-- ---------------------------- +BEGIN; +INSERT INTO `zz_flow_task_comment` VALUES (1809146487481831424, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e200f745-3aaa-11ef-86ec-acde48001122', 'Activity_0vjtv0p', '录入', NULL, 'e1fbee31-3aaa-11ef-86ec-acde48001122', NULL, 'agree', NULL, NULL, NULL, NULL, 1808020007993479168, 'admin', '管理员', '2024-07-05 16:45:10'); +INSERT INTO `zz_flow_task_comment` VALUES (1809146598064656384, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'e322e20d-3aaa-11ef-86ec-acde48001122', 'Activity_06g14pf', '审批A', NULL, 'e1fbee31-3aaa-11ef-86ec-acde48001122', NULL, 'agree', '11', NULL, NULL, NULL, 1808020007993479168, 'admin', '管理员', '2024-07-05 16:45:36'); +INSERT INTO `zz_flow_task_comment` VALUES (1809146699361292288, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'f2dcc311-3aaa-11ef-86ec-acde48001122', 'Activity_0dn7u52', '审批B', NULL, NULL, NULL, 'reject', '11', NULL, NULL, NULL, 1808020007993479168, 'admin', '管理员', '2024-07-05 16:46:00'); +INSERT INTO `zz_flow_task_comment` VALUES (1809146743762194432, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 'ffef78e6-3aaa-11ef-86ec-acde48001122', 'Activity_06g14pf', '审批A', NULL, NULL, NULL, 'reject', '33', NULL, NULL, NULL, 1808020007993479168, 'admin', '管理员', '2024-07-05 16:46:11'); +INSERT INTO `zz_flow_task_comment` VALUES (1809146774330281984, 'e1fb2ada-3aaa-11ef-86ec-acde48001122', '0669cc2a-3aab-11ef-86ec-acde48001122', 'Activity_0vjtv0p', '录入', NULL, '0669cc28-3aab-11ef-86ec-acde48001122', NULL, 'agree', '44', NULL, NULL, NULL, 1808020007993479168, 'admin', '管理员', '2024-07-05 16:46:18'); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_flow_task_ext +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_task_ext`; +CREATE TABLE `zz_flow_task_ext` ( + `process_definition_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程引擎的定义Id', + `task_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程引擎任务Id', + `operation_list_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '操作列表JSON', + `variable_list_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '变量列表JSON', + `assignee_list_json` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '存储多实例的assigneeList的JSON', + `group_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '分组类型', + `dept_post_list_json` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '保存岗位相关的数据', + `role_ids` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '保存角色Id数据', + `dept_ids` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '保存部门Id数据', + `candidate_usernames` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '保存候选组用户名数据', + `copy_list_json` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '抄送相关的数据', + `extra_data_json` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '用户任务的扩展属性,存储为JSON的字符串格式', + PRIMARY KEY (`process_definition_id`,`task_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程流程图任务扩展表'; + +-- ---------------------------- +-- Records of zz_flow_task_ext +-- ---------------------------- +BEGIN; +INSERT INTO `zz_flow_task_ext` VALUES ('flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'Activity_06g14pf', '[{\"showOrder\":\"0\",\"id\":\"1720168555059\",\"label\":\"同意\",\"type\":\"agree\"},{\"showOrder\":\"0\",\"id\":\"1720168558485\",\"label\":\"驳回到起点\",\"type\":\"rejectToStart\"}]', NULL, NULL, 'ASSIGNEE', '[]', NULL, NULL, NULL, '[]', '{\"flowNotifyTypeList\":[\"email\"]}'); +INSERT INTO `zz_flow_task_ext` VALUES ('flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'Activity_0dn7u52', '[{\"showOrder\":\"0\",\"id\":\"1720168573903\",\"label\":\"同意\",\"type\":\"agree\"},{\"showOrder\":\"0\",\"id\":\"1720168577495\",\"label\":\"驳回\",\"type\":\"reject\"}]', NULL, NULL, 'ASSIGNEE', '[]', NULL, NULL, NULL, '[]', '{\"flowNotifyTypeList\":[\"email\"]}'); +INSERT INTO `zz_flow_task_ext` VALUES ('flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'Activity_0vjtv0p', '[{\"showOrder\":\"0\",\"id\":\"1720168540672\",\"label\":\"同意\",\"type\":\"agree\"}]', NULL, NULL, 'ASSIGNEE', '[]', NULL, NULL, NULL, '[]', '{\"flowNotifyTypeList\":[\"email\"]}'); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_flow_work_order +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_work_order`; +CREATE TABLE `zz_flow_work_order` ( + `work_order_id` bigint NOT NULL COMMENT '主键Id', + `tenant_id` bigint DEFAULT NULL COMMENT '租户Id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用编码', + `work_order_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '工单编码字段', + `process_definition_key` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程定义标识', + `process_definition_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '流程名称', + `process_definition_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程引擎的定义Id', + `process_instance_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '流程实例Id', + `online_table_id` bigint DEFAULT NULL COMMENT '在线表单的主表Id', + `table_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '用于静态表单的表名', + `business_key` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '业务主键值', + `task_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '未完成的任务Id', + `task_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '未完成的任务名称', + `task_definition_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '未完成的任务标识', + `latest_approval_status` int DEFAULT NULL COMMENT '最近的审批状态', + `flow_status` int NOT NULL DEFAULT '0' COMMENT '流程状态', + `submit_username` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '提交用户登录名称', + `dept_id` bigint NOT NULL COMMENT '提交用户所在部门Id', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + `deleted_flag` int NOT NULL COMMENT '删除标记(1: 正常 -1: 已删除)', + PRIMARY KEY (`work_order_id`) USING BTREE, + UNIQUE KEY `uk_process_instance_id` (`process_instance_id`) USING BTREE, + UNIQUE KEY `uk_work_order_code` (`work_order_code`) USING BTREE, + KEY `idx_tenant_id` (`tenant_id`) USING BTREE, + KEY `idx_app_code` (`app_code`) USING BTREE, + KEY `idx_process_definition_key` (`process_definition_key`) USING BTREE, + KEY `idx_create_user_id` (`create_user_id`) USING BTREE, + KEY `idx_create_time` (`create_time`) USING BTREE, + KEY `idx_dept_id` (`dept_id`) USING BTREE, + KEY `idx_table_name` (`table_name`) USING BTREE, + KEY `idx_business_key` (`business_key`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程工单表'; + +-- ---------------------------- +-- Records of zz_flow_work_order +-- ---------------------------- +BEGIN; +INSERT INTO `zz_flow_work_order` VALUES (1809146486244511744, NULL, NULL, 'LL20240705DD00001', 'flowLeave', '请假申请', 'flowLeave:1:be0642f9-3aa9-11ef-86ec-acde48001122', 'e1fb2ada-3aaa-11ef-86ec-acde48001122', 1809132251556876288, NULL, '1809146480452177920', NULL, NULL, NULL, NULL, 1, 'admin', 1808020008341606402, '2024-07-05 16:46:18', 1808020007993479168, '2024-07-05 16:45:09', 1808020007993479168, 1); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_flow_work_order_ext +-- ---------------------------- +DROP TABLE IF EXISTS `zz_flow_work_order_ext`; +CREATE TABLE `zz_flow_work_order_ext` ( + `id` bigint NOT NULL COMMENT '主键Id', + `work_order_id` bigint NOT NULL COMMENT '工单Id', + `draft_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '草稿数据', + `business_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '业务数据', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + `deleted_flag` int NOT NULL COMMENT '删除标记(1: 正常 -1: 已删除)', + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_work_order_id` (`work_order_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='流程工单扩展表'; + +-- ---------------------------- +-- Table structure for zz_global_dict +-- ---------------------------- +DROP TABLE IF EXISTS `zz_global_dict`; +CREATE TABLE `zz_global_dict` ( + `dict_id` bigint NOT NULL COMMENT '主键Id', + `dict_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '字典编码', + `dict_name` varchar(2048) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '字典中文名称', + `create_user_id` bigint NOT NULL COMMENT '创建用户Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `update_user_id` bigint NOT NULL COMMENT '更新用户名', + `update_time` datetime NOT NULL COMMENT '更新时间', + `deleted_flag` int NOT NULL COMMENT '逻辑删除字段', + PRIMARY KEY (`dict_id`), + KEY `idx_dict_code` (`dict_code`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='全局字典表'; + +-- ---------------------------- +-- Table structure for zz_global_dict_item +-- ---------------------------- +DROP TABLE IF EXISTS `zz_global_dict_item`; +CREATE TABLE `zz_global_dict_item` ( + `id` bigint NOT NULL COMMENT '主键Id', + `dict_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '字典编码', + `item_id` varchar(64) COLLATE utf8mb4_bin NOT NULL COMMENT '字典数据项Id', + `item_name` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '字典数据项名称', + `show_order` int NOT NULL COMMENT '显示顺序', + `status` int NOT NULL COMMENT '字典状态', + `create_user_id` bigint NOT NULL COMMENT '创建用户Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `update_user_id` bigint NOT NULL COMMENT '更新用户名', + `update_time` datetime NOT NULL COMMENT '更新时间', + `deleted_flag` int NOT NULL COMMENT '逻辑删除字段', + PRIMARY KEY (`id`), + KEY `idx_show_order` (`show_order`) USING BTREE, + KEY `idx_dict_code_item_id` (`dict_code`,`item_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='全局字典项目表'; + +-- ---------------------------- +-- Table structure for zz_online_column +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_column`; +CREATE TABLE `zz_online_column` ( + `column_id` bigint NOT NULL COMMENT '主键Id', + `column_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '字段名', + `table_id` bigint NOT NULL COMMENT '数据表Id', + `column_type` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '数据表中的字段类型', + `full_column_type` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '数据表中的完整字段类型(包括了精度和刻度)', + `primary_key` bit(1) NOT NULL COMMENT '是否为主键', + `auto_incr` bit(1) NOT NULL COMMENT '是否是自增主键(0: 不是 1: 是)', + `nullable` bit(1) NOT NULL COMMENT '是否可以为空 (0: 不可以为空 1: 可以为空)', + `column_default` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT '缺省值', + `column_show_order` int NOT NULL COMMENT '字段在数据表中的显示位置', + `column_comment` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT '数据表中的字段注释', + `object_field_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '对象映射字段名称', + `object_field_type` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '对象映射字段类型', + `numeric_precision` int DEFAULT NULL COMMENT '数值型字段的精度', + `numeric_scale` int DEFAULT NULL COMMENT '数值型字段的刻度', + `filter_type` int NOT NULL DEFAULT '1' COMMENT '字段过滤类型', + `parent_key` bit(1) NOT NULL COMMENT '是否是主键的父Id', + `dept_filter` bit(1) NOT NULL COMMENT '是否部门过滤字段', + `user_filter` bit(1) NOT NULL COMMENT '是否用户过滤字段', + `field_kind` int DEFAULT NULL COMMENT '字段类别', + `max_file_count` int DEFAULT NULL COMMENT '包含的文件文件数量,0表示无限制', + `upload_file_system_type` int DEFAULT '0' COMMENT '上传文件系统类型', + `encoded_rule` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '编码规则的JSON格式数据', + `mask_field_type` varchar(64) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '脱敏字段类型', + `dict_id` bigint DEFAULT NULL COMMENT '字典Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者', + PRIMARY KEY (`column_id`), + KEY `idx_table_id` (`table_id`) USING BTREE, + KEY `idx_dict_id` (`dict_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单字段表'; + +-- ---------------------------- +-- Records of zz_online_column +-- ---------------------------- +BEGIN; +INSERT INTO `zz_online_column` VALUES (1809132252005666816, 'id', 1809132251556876288, 'bigint', 'bigint', b'1', b'0', b'0', NULL, 1, '主键Id', 'id', 'Long', 19, NULL, 0, b'0', b'0', b'0', NULL, NULL, 0, NULL, NULL, NULL, '2024-07-05 15:48:36', 1808020007993479168, '2024-07-05 15:48:36', 1808020007993479168); +INSERT INTO `zz_online_column` VALUES (1809132252425097216, 'user_id', 1809132251556876288, 'bigint', 'bigint', b'0', b'0', b'0', NULL, 2, '请假用户', 'userId', 'Long', 19, NULL, 0, b'0', b'0', b'0', 21, NULL, 0, NULL, NULL, NULL, '2024-07-05 15:48:36', 1808020007993479168, '2024-07-05 15:48:47', 1808020007993479168); +INSERT INTO `zz_online_column` VALUES (1809132252852916224, 'leave_reason', 1809132251556876288, 'varchar', 'varchar(512)', b'0', b'0', b'0', NULL, 3, '请假原因', 'leaveReason', 'String', NULL, NULL, 0, b'0', b'0', b'0', NULL, NULL, 0, NULL, NULL, NULL, '2024-07-05 15:48:36', 1808020007993479168, '2024-07-05 15:53:47', 1808020007993479168); +INSERT INTO `zz_online_column` VALUES (1809132253377204224, 'leave_type', 1809132251556876288, 'int', 'int', b'0', b'0', b'0', NULL, 4, '请假类型', 'leaveType', 'Integer', 10, NULL, 0, b'0', b'0', b'0', NULL, NULL, 0, NULL, NULL, NULL, '2024-07-05 15:48:36', 1808020007993479168, '2024-07-05 15:53:44', 1808020007993479168); +INSERT INTO `zz_online_column` VALUES (1809132253733720064, 'leave_begin_time', 1809132251556876288, 'datetime', 'datetime', b'0', b'0', b'0', NULL, 5, '开始时间', 'leaveBeginTime', 'Date', NULL, NULL, 0, b'0', b'0', b'0', NULL, NULL, 0, NULL, NULL, NULL, '2024-07-05 15:48:36', 1808020007993479168, '2024-07-05 15:53:50', 1808020007993479168); +INSERT INTO `zz_online_column` VALUES (1809132254102818816, 'leave_end_time', 1809132251556876288, 'datetime', 'datetime', b'0', b'0', b'0', NULL, 6, '结束时间', 'leaveEndTime', 'Date', NULL, NULL, 0, b'0', b'0', b'0', NULL, NULL, 0, NULL, NULL, NULL, '2024-07-05 15:48:36', 1808020007993479168, '2024-07-05 15:53:54', 1808020007993479168); +INSERT INTO `zz_online_column` VALUES (1809132254388031488, 'apply_time', 1809132251556876288, 'datetime', 'datetime', b'0', b'0', b'0', NULL, 7, '申请时间', 'applyTime', 'Date', NULL, NULL, 0, b'0', b'0', b'0', 20, NULL, 0, NULL, NULL, NULL, '2024-07-05 15:48:36', 1808020007993479168, '2024-07-05 15:53:57', 1808020007993479168); +INSERT INTO `zz_online_column` VALUES (1809132254782296064, 'approval_status', 1809132251556876288, 'int', 'int', b'0', b'0', b'1', NULL, 8, '最后审批状态', 'approvalStatus', 'Integer', 10, NULL, 0, b'0', b'0', b'0', 26, NULL, 0, NULL, NULL, NULL, '2024-07-05 15:48:36', 1808020007993479168, '2024-07-05 15:53:59', 1808020007993479168); +INSERT INTO `zz_online_column` VALUES (1809132255327555584, 'flow_status', 1809132251556876288, 'int', 'int', b'0', b'0', b'1', NULL, 9, '流程状态', 'flowStatus', 'Integer', 10, NULL, 0, b'0', b'0', b'0', 25, NULL, 0, NULL, NULL, NULL, '2024-07-05 15:48:36', 1808020007993479168, '2024-07-05 15:49:44', 1808020007993479168); +INSERT INTO `zz_online_column` VALUES (1809132255679877120, 'username', 1809132251556876288, 'varchar', 'varchar(255)', b'0', b'0', b'1', NULL, 10, '用户名', 'username', 'String', NULL, NULL, 0, b'0', b'0', b'0', NULL, NULL, 0, NULL, NULL, NULL, '2024-07-05 15:48:36', 1808020007993479168, '2024-07-05 15:49:49', 1808020007993479168); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_online_column_rule +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_column_rule`; +CREATE TABLE `zz_online_column_rule` ( + `column_id` bigint NOT NULL COMMENT '字段Id', + `rule_id` bigint NOT NULL COMMENT '规则Id', + `prop_data_json` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '规则属性数据', + PRIMARY KEY (`column_id`,`rule_id`) USING BTREE, + KEY `idx_rule_id` (`rule_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单字段和字段规则关联中间表'; + +-- ---------------------------- +-- Table structure for zz_online_datasource +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_datasource`; +CREATE TABLE `zz_online_datasource` ( + `datasource_id` bigint NOT NULL COMMENT '主键Id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用编码', + `datasource_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '数据源名称', + `variable_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '数据源变量名', + `dblink_id` bigint NOT NULL COMMENT '数据库链接Id', + `master_table_id` bigint NOT NULL COMMENT '主表Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者', + PRIMARY KEY (`datasource_id`), + UNIQUE KEY `uk_app_code_variable_name` (`app_code`,`variable_name`) USING BTREE, + KEY `idx_master_table_id` (`master_table_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单数据源表'; + +-- ---------------------------- +-- Records of zz_online_datasource +-- ---------------------------- +BEGIN; +INSERT INTO `zz_online_datasource` VALUES (1809132255981867008, NULL, '请假申请', 'dsLeave', 1809055300360081408, 1809132251556876288, '2024-07-05 15:48:37', 1808020007993479168, '2024-07-05 15:48:37', 1808020007993479168); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_online_datasource_relation +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_datasource_relation`; +CREATE TABLE `zz_online_datasource_relation` ( + `relation_id` bigint NOT NULL COMMENT '主键Id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用编码', + `relation_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '关联名称', + `variable_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '变量名', + `datasource_id` bigint NOT NULL COMMENT '主数据源Id', + `relation_type` int NOT NULL COMMENT '关联类型', + `master_column_id` bigint NOT NULL COMMENT '主表关联字段Id', + `slave_table_id` bigint NOT NULL COMMENT '从表Id', + `slave_column_id` bigint NOT NULL COMMENT '从表关联字段Id', + `cascade_delete` bit(1) NOT NULL COMMENT '删除主表的时候是否级联删除一对一和一对多的从表数据,多对多只是删除关联,不受到这个标记的影响。', + `left_join` bit(1) NOT NULL COMMENT '是否左连接', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者', + PRIMARY KEY (`relation_id`) USING BTREE, + UNIQUE KEY `uk_datasource_id_variable_name` (`datasource_id`,`variable_name`) USING BTREE, + KEY `idx_app_code` (`app_code`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单数据源关联表'; + +-- ---------------------------- +-- Table structure for zz_online_datasource_table +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_datasource_table`; +CREATE TABLE `zz_online_datasource_table` ( + `id` bigint NOT NULL COMMENT '主键Id', + `datasource_id` bigint NOT NULL COMMENT '数据源Id', + `relation_id` bigint DEFAULT NULL COMMENT '数据源关联Id', + `table_id` bigint NOT NULL COMMENT '数据表Id', + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_relation_id` (`relation_id`) USING BTREE, + KEY `idx_datasource_id` (`datasource_id`) USING BTREE, + KEY `idx_table_id` (`table_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单数据源和数据表关联的中间表'; + +-- ---------------------------- +-- Records of zz_online_datasource_table +-- ---------------------------- +BEGIN; +INSERT INTO `zz_online_datasource_table` VALUES (1809132256292245504, 1809132255981867008, NULL, 1809132251556876288); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_online_dblink +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_dblink`; +CREATE TABLE `zz_online_dblink` ( + `dblink_id` bigint NOT NULL COMMENT '主键Id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用编码', + `dblink_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '链接中文名称', + `dblink_description` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '链接描述', + `dblink_type` int NOT NULL COMMENT '数据源类型', + `configuration` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '配置信息', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者', + PRIMARY KEY (`dblink_id`), + KEY `idx_dblink_type` (`dblink_type`) USING BTREE, + KEY `idx_app_code` (`app_code`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单数据库链接表'; + +-- ---------------------------- +-- Records of zz_online_dblink +-- ---------------------------- +BEGIN; +INSERT INTO `zz_online_dblink` VALUES (1809055300360081408, NULL, 'mysql-test', NULL, 0, '{\"sid\":true,\"initialPoolSize\":5,\"minPoolSize\":5,\"maxPoolSize\":50,\"host\":\"localhost\",\"port\":3306,\"database\":\"zzdemo-online-open\",\"username\":\"root\",\"password\":\"123456\"}', '2024-07-05 10:42:49', 1809038124504846336, '2024-07-05 10:42:49', 1809038124504846336); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_online_dict +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_dict`; +CREATE TABLE `zz_online_dict` ( + `dict_id` bigint NOT NULL COMMENT '主键Id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用编码', + `dict_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '字典名称', + `dict_type` int NOT NULL COMMENT '字典类型', + `dblink_id` bigint DEFAULT NULL COMMENT '数据库链接Id', + `table_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '字典表名称', + `dict_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '全局字典编码', + `key_column_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '字典表键字段名称', + `parent_key_column_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '字典表父键字段名称', + `value_column_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '字典值字段名称', + `deleted_column_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '逻辑删除字段', + `user_filter_column_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '用户过滤滤字段名称', + `dept_filter_column_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '部门过滤滤字段名称', + `tenant_filter_column_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '租户过滤字段名称', + `tree_flag` bit(1) NOT NULL COMMENT '是否树形标记', + `dict_list_url` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '获取字典列表数据的url', + `dict_ids_url` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '根据主键id批量获取字典数据的url', + `dict_data_json` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '字典的JSON数据', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者', + PRIMARY KEY (`dict_id`) USING BTREE, + KEY `idx_app_code` (`app_code`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单字典表'; + +-- ---------------------------- +-- Table structure for zz_online_form +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_form`; +CREATE TABLE `zz_online_form` ( + `form_id` bigint NOT NULL COMMENT '主键Id', + `tenant_id` bigint DEFAULT NULL COMMENT '租户id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用编码', + `page_id` bigint NOT NULL COMMENT '页面id', + `form_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '表单编码', + `form_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '表单名称', + `form_kind` int NOT NULL COMMENT '表单类别', + `form_type` int NOT NULL COMMENT '表单类型', + `master_table_id` bigint NOT NULL COMMENT '表单主表id', + `widget_json` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '表单组件JSON', + `params_json` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '表单参数JSON', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者', + PRIMARY KEY (`form_id`) USING BTREE, + UNIQUE KEY `uk_page_id_form_code` (`page_id`,`form_code`) USING BTREE, + KEY `idx_tenant_id` (`tenant_id`) USING BTREE, + KEY `idx_app_code` (`app_code`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单表单表'; + +-- ---------------------------- +-- Records of zz_online_form +-- ---------------------------- +BEGIN; +INSERT INTO `zz_online_form` VALUES (1809132635633487872, NULL, NULL, 1809132177523216384, 'formFlowLeave', '请假申请', 5, 10, 1809132251556876288, '{\"pc\":{\"gutter\":20,\"labelWidth\":100,\"labelPosition\":\"right\",\"operationList\":[],\"customFieldList\":[],\"widgetList\":[{\"widgetType\":3,\"bindData\":{\"defaultValue\":{},\"tableId\":\"1809132251556876288\",\"columnId\":\"1809132253377204224\",\"dataType\":0},\"showName\":\"请假类型\",\"variableName\":\"leaveType\",\"props\":{\"span\":24,\"placeholder\":\"\",\"step\":1,\"controls\":true,\"required\":true,\"disabled\":false,\"dictInfo\":{\"paramList\":[]},\"actions\":{}},\"eventList\":[],\"childWidgetList\":[],\"style\":{}},{\"widgetType\":1,\"bindData\":{\"defaultValue\":{},\"tableId\":\"1809132251556876288\",\"columnId\":\"1809132252852916224\",\"dataType\":0},\"showName\":\"请假原因\",\"variableName\":\"leaveReason\",\"props\":{\"span\":24,\"type\":\"text\",\"placeholder\":\"\",\"show-password\":false,\"show-word-limit\":false,\"required\":true,\"disabled\":false,\"dictInfo\":{\"paramList\":[]},\"actions\":{}},\"eventList\":[],\"childWidgetList\":[],\"style\":{}},{\"widgetType\":20,\"bindData\":{\"defaultValue\":{},\"tableId\":\"1809132251556876288\",\"columnId\":\"1809132253733720064\",\"dataType\":0},\"showName\":\"开始时间\",\"variableName\":\"leaveBeginTime\",\"props\":{\"span\":12,\"placeholder\":\"\",\"type\":\"date\",\"required\":true,\"disabled\":false,\"dictInfo\":{\"paramList\":[]},\"actions\":{}},\"eventList\":[],\"childWidgetList\":[],\"style\":{},\"supportOperation\":false},{\"widgetType\":20,\"bindData\":{\"defaultValue\":{},\"tableId\":\"1809132251556876288\",\"columnId\":\"1809132254102818816\",\"dataType\":0},\"showName\":\"结束时间\",\"variableName\":\"leaveEndTime\",\"props\":{\"span\":12,\"placeholder\":\"\",\"type\":\"date\",\"required\":true,\"disabled\":false,\"dictInfo\":{\"paramList\":[]},\"actions\":{}},\"eventList\":[],\"childWidgetList\":[],\"style\":{},\"supportOperation\":false}],\"formEventList\":[],\"maskFieldList\":[],\"width\":800,\"fullscreen\":true}}', NULL, '2024-07-05 15:50:07', 1808020007993479168, '2024-07-05 16:34:21', 1808020007993479168); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_online_form_datasource +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_form_datasource`; +CREATE TABLE `zz_online_form_datasource` ( + `id` bigint NOT NULL COMMENT '主键Id', + `form_id` bigint NOT NULL COMMENT '表单Id', + `datasource_id` bigint NOT NULL COMMENT '数据源Id', + PRIMARY KEY (`id`), + KEY `idx_form_id` (`form_id`) USING BTREE, + KEY `idx_datasource_id` (`datasource_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单表单和数据源关联中间表'; + +-- ---------------------------- +-- Records of zz_online_form_datasource +-- ---------------------------- +BEGIN; +INSERT INTO `zz_online_form_datasource` VALUES (1809143766578106368, 1809132635633487872, 1809132255981867008); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_online_page +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_page`; +CREATE TABLE `zz_online_page` ( + `page_id` bigint NOT NULL COMMENT '主键Id', + `tenant_id` bigint DEFAULT NULL COMMENT '租户id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用编码', + `page_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '页面编码', + `page_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '页面名称', + `page_type` int NOT NULL COMMENT '页面类型', + `status` int NOT NULL COMMENT '页面编辑状态', + `published` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否发布', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者', + PRIMARY KEY (`page_id`) USING BTREE, + KEY `idx_tenant_id` (`tenant_id`) USING BTREE, + KEY `idx_app_code` (`app_code`) USING BTREE, + KEY `idx_page_code` (`page_code`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单页面表'; + +-- ---------------------------- +-- Records of zz_online_page +-- ---------------------------- +BEGIN; +INSERT INTO `zz_online_page` VALUES (1809132177523216384, NULL, NULL, 'flowLeave', '请假申请', 10, 2, b'1', '2024-07-05 15:48:18', 1808020007993479168, '2024-07-05 16:34:27', 1808020007993479168); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_online_page_datasource +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_page_datasource`; +CREATE TABLE `zz_online_page_datasource` ( + `id` bigint NOT NULL COMMENT '主键Id', + `page_id` bigint NOT NULL COMMENT '页面主键Id', + `datasource_id` bigint NOT NULL COMMENT '数据源主键Id', + PRIMARY KEY (`id`), + KEY `idx_page_id` (`page_id`) USING BTREE, + KEY `idx_datasource_id` (`datasource_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单页面和数据源关联中间表'; + +-- ---------------------------- +-- Records of zz_online_page_datasource +-- ---------------------------- +BEGIN; +INSERT INTO `zz_online_page_datasource` VALUES (1809132256564875264, 1809132177523216384, 1809132255981867008); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_online_rule +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_rule`; +CREATE TABLE `zz_online_rule` ( + `rule_id` bigint NOT NULL COMMENT '主键Id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用编码', + `rule_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '规则名称', + `rule_type` int NOT NULL COMMENT '规则类型', + `builtin` bit(1) NOT NULL COMMENT '内置规则标记', + `pattern` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '自定义规则的正则表达式', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者', + `deleted_flag` int NOT NULL COMMENT '逻辑删除标记', + PRIMARY KEY (`rule_id`) USING BTREE, + KEY `idx_app_code` (`app_code`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单字段规则表'; + +-- ---------------------------- +-- Records of zz_online_rule +-- ---------------------------- +BEGIN; +INSERT INTO `zz_online_rule` VALUES (1, NULL, '只允许整数', 1, b'1', NULL, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, 1); +INSERT INTO `zz_online_rule` VALUES (2, NULL, '只允许数字', 2, b'1', NULL, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, 1); +INSERT INTO `zz_online_rule` VALUES (3, NULL, '只允许英文字符', 3, b'1', NULL, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, 1); +INSERT INTO `zz_online_rule` VALUES (4, NULL, '范围验证', 4, b'1', NULL, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, 1); +INSERT INTO `zz_online_rule` VALUES (5, NULL, '邮箱格式验证', 5, b'1', NULL, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, 1); +INSERT INTO `zz_online_rule` VALUES (6, NULL, '手机格式验证', 6, b'1', NULL, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, 1); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_online_table +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_table`; +CREATE TABLE `zz_online_table` ( + `table_id` bigint NOT NULL COMMENT '主键Id', + `app_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应用编码', + `table_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '表名称', + `model_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '实体名称', + `dblink_id` bigint NOT NULL COMMENT '数据库链接Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `create_user_id` bigint NOT NULL COMMENT '创建者', + `update_time` datetime NOT NULL COMMENT '更新时间', + `update_user_id` bigint NOT NULL COMMENT '更新者', + PRIMARY KEY (`table_id`), + KEY `idx_dblink_id` (`dblink_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单数据表'; + +-- ---------------------------- +-- Records of zz_online_table +-- ---------------------------- +BEGIN; +INSERT INTO `zz_online_table` VALUES (1809132251556876288, NULL, 'zz_test_flow_leave', 'ZzTestFlowLeave', 1809055300360081408, '2024-07-05 15:48:35', 1808020007993479168, '2024-07-05 15:48:35', 1808020007993479168); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_online_virtual_column +-- ---------------------------- +DROP TABLE IF EXISTS `zz_online_virtual_column`; +CREATE TABLE `zz_online_virtual_column` ( + `virtual_column_id` bigint NOT NULL COMMENT '主键Id', + `table_id` bigint NOT NULL COMMENT '所在表Id', + `object_field_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '字段名称', + `object_field_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '属性类型', + `column_prompt` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '字段提示名', + `virtual_type` int NOT NULL COMMENT '虚拟字段类型(0: 聚合)', + `datasource_id` bigint NOT NULL COMMENT '关联数据源Id', + `relation_id` bigint DEFAULT NULL COMMENT '关联Id', + `aggregation_table_id` bigint DEFAULT NULL COMMENT '聚合字段所在关联表Id', + `aggregation_column_id` bigint DEFAULT NULL COMMENT '关联表聚合字段Id', + `aggregation_type` int DEFAULT NULL COMMENT '聚合类型(0: sum 1: count 2: avg 3: min 4: max)', + `where_clause_json` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '存储过滤条件的json', + PRIMARY KEY (`virtual_column_id`) USING BTREE, + KEY `idx_database_id` (`datasource_id`) USING BTREE, + KEY `idx_relation_id` (`relation_id`) USING BTREE, + KEY `idx_table_id` (`table_id`) USING BTREE, + KEY `idx_aggregation_column_id` (`aggregation_column_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='在线表单虚拟字段表'; + +-- ---------------------------- +-- Table structure for zz_sys_data_perm +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_data_perm`; +CREATE TABLE `zz_sys_data_perm` ( + `data_perm_id` bigint NOT NULL COMMENT '主键', + `data_perm_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '显示名称', + `rule_type` tinyint NOT NULL COMMENT '数据权限规则类型(0: 全部可见 1: 只看自己 2: 只看本部门 3: 本部门及子部门 4: 多部门及子部门 5: 自定义部门列表)。', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `update_user_id` bigint NOT NULL COMMENT '更新者Id', + `update_time` datetime NOT NULL COMMENT '最后更新时间', + PRIMARY KEY (`data_perm_id`) USING BTREE, + KEY `idx_create_time` (`create_time`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='数据权限表'; + +-- ---------------------------- +-- Records of zz_sys_data_perm +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_data_perm` VALUES (1809037881759502336, '查看全部', 0, 1808020007993479168, '2024-07-05 09:33:36', 1808020007993479168, '2024-07-05 09:33:36'); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_data_perm_dept +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_data_perm_dept`; +CREATE TABLE `zz_sys_data_perm_dept` ( + `data_perm_id` bigint NOT NULL COMMENT '数据权限Id', + `dept_id` bigint NOT NULL COMMENT '部门Id', + PRIMARY KEY (`data_perm_id`,`dept_id`), + KEY `idx_dept_id` (`dept_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='数据权限和部门关联表'; + +-- ---------------------------- +-- Table structure for zz_sys_data_perm_menu +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_data_perm_menu`; +CREATE TABLE `zz_sys_data_perm_menu` ( + `data_perm_id` bigint NOT NULL COMMENT '数据权限Id', + `menu_id` bigint NOT NULL COMMENT '菜单Id', + PRIMARY KEY (`data_perm_id`,`menu_id`), + KEY `idx_menu_id` (`menu_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='数据权限和菜单关联表'; + +-- ---------------------------- +-- Table structure for zz_sys_data_perm_user +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_data_perm_user`; +CREATE TABLE `zz_sys_data_perm_user` ( + `data_perm_id` bigint NOT NULL COMMENT '数据权限Id', + `user_id` bigint NOT NULL COMMENT '用户Id', + PRIMARY KEY (`data_perm_id`,`user_id`), + KEY `idx_user_id` (`user_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='数据权限和用户关联表'; + +-- ---------------------------- +-- Records of zz_sys_data_perm_user +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_data_perm_user` VALUES (1809037881759502336, 1809038124504846336); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_dept +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_dept`; +CREATE TABLE `zz_sys_dept` ( + `dept_id` bigint NOT NULL COMMENT '部门Id', + `parent_id` bigint DEFAULT NULL COMMENT '父部门Id', + `dept_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '部门名称', + `show_order` int NOT NULL COMMENT '兄弟部分之间的显示顺序,数字越小越靠前', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `update_user_id` bigint NOT NULL COMMENT '更新者Id', + `update_time` datetime NOT NULL COMMENT '最后更新时间', + `deleted_flag` int NOT NULL COMMENT '删除标记(1: 正常 -1: 已删除)', + PRIMARY KEY (`dept_id`) USING BTREE, + KEY `idx_parent_id` (`parent_id`) USING BTREE, + KEY `idx_show_order` (`show_order`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=COMPACT COMMENT='部门管理表'; + +-- ---------------------------- +-- Records of zz_sys_dept +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_dept` VALUES (1808020008341606402, NULL, '公司总部', 1, 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00', 1); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_dept_post +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_dept_post`; +CREATE TABLE `zz_sys_dept_post` ( + `dept_post_id` bigint NOT NULL COMMENT '主键Id', + `dept_id` bigint NOT NULL COMMENT '部门Id', + `post_id` bigint NOT NULL COMMENT '岗位Id', + `post_show_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '部门岗位显示名称', + PRIMARY KEY (`dept_post_id`) USING BTREE, + KEY `idx_post_id` (`post_id`) USING BTREE, + KEY `idx_dept_id` (`dept_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- ---------------------------- +-- Records of zz_sys_dept_post +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_dept_post` VALUES (1809038003536924672, 1808020008341606402, 1809037927934595072, '领导岗位'); +INSERT INTO `zz_sys_dept_post` VALUES (1809038003968937984, 1808020008341606402, 1809037967663042560, '普通员工'); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_dept_relation +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_dept_relation`; +CREATE TABLE `zz_sys_dept_relation` ( + `parent_dept_id` bigint NOT NULL COMMENT '父部门Id', + `dept_id` bigint NOT NULL COMMENT '部门Id', + PRIMARY KEY (`parent_dept_id`,`dept_id`), + KEY `idx_dept_id` (`dept_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=COMPACT COMMENT='部门关联关系表'; + +-- ---------------------------- +-- Records of zz_sys_dept_relation +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_dept_relation` VALUES (1808020008341606402, 1808020008341606402); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_menu +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_menu`; +CREATE TABLE `zz_sys_menu` ( + `menu_id` bigint NOT NULL COMMENT '主键Id', + `parent_id` bigint DEFAULT NULL COMMENT '父菜单Id,目录菜单的父菜单为null', + `menu_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '菜单显示名称', + `menu_type` int NOT NULL COMMENT '(0: 目录 1: 菜单 2: 按钮 3: UI片段)', + `form_router_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '前端表单路由名称,仅用于menu_type为1的菜单类型', + `online_form_id` bigint DEFAULT NULL COMMENT '在线表单主键Id', + `online_menu_perm_type` int DEFAULT NULL COMMENT '在线表单菜单的权限控制类型', + `report_page_id` bigint DEFAULT NULL COMMENT '统计页面主键Id', + `online_flow_entry_id` bigint DEFAULT NULL COMMENT '仅用于在线表单的流程Id', + `show_order` int NOT NULL COMMENT '菜单显示顺序 (值越小,排序越靠前)', + `icon` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '菜单图标', + `extra_data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '附加信息', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `update_user_id` bigint NOT NULL COMMENT '更新者Id', + `update_time` datetime NOT NULL COMMENT '最后更新时间', + PRIMARY KEY (`menu_id`) USING BTREE, + KEY `idx_show_order` (`show_order`) USING BTREE, + KEY `idx_parent_id` (`parent_id`) USING BTREE, + KEY `idx_menu_type` (`menu_type`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=COMPACT COMMENT='菜单和操作权限管理表'; + +-- ---------------------------- +-- Records of zz_sys_menu +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_menu` VALUES (1392786476428693504, NULL, '在线表单', 0, NULL, NULL, NULL, NULL, NULL, 2, 'el-icon-c-scale-to-original', NULL, 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1392786549942259712, 1392786476428693504, '字典管理', 1, 'formOnlineDict', NULL, NULL, NULL, NULL, 2, NULL, '{\"permCodeList\":[\"onlineDict.all\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1392786950682841088, 1392786476428693504, '表单管理', 1, 'formOnlinePage', NULL, NULL, NULL, NULL, 3, NULL, '{\"permCodeList\":[\"onlinePage.all\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1418057714138877952, NULL, '流程管理', 0, NULL, NULL, NULL, NULL, NULL, 3, 'el-icon-s-operation', NULL, 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1418057835631087616, 1418057714138877952, '流程分类', 1, 'formFlowCategory', NULL, NULL, NULL, NULL, 1, NULL, '{\"permCodeList\":[\"flowCategory.all\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1418058289182150656, 1418057714138877952, '流程设计', 1, 'formFlowEntry', NULL, NULL, NULL, NULL, 2, NULL, '{\"permCodeList\":[\"flowEntry.all\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1418058744037642240, 1418057714138877952, '流程实例', 1, 'formAllInstance', NULL, NULL, NULL, NULL, 3, NULL, '{\"permCodeList\":[\"flowOperation.all\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1418059005175009280, NULL, '任务管理', 0, NULL, NULL, NULL, NULL, NULL, 4, 'el-icon-tickets', NULL, 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1418059167532322816, 1418059005175009280, '待办任务', 1, 'formMyTask', NULL, NULL, NULL, NULL, 1, NULL, NULL, 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1418059283920064512, 1418059005175009280, '历史任务', 1, 'formMyHistoryTask', NULL, NULL, NULL, NULL, 3, NULL, NULL, 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1423161217970606080, 1418059005175009280, '已办任务', 1, 'formMyApprovedTask', NULL, NULL, NULL, NULL, 2, NULL, NULL, 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1634009076981567488, 1392786476428693504, '数据库链接', 1, 'formOnlineDblink', NULL, NULL, NULL, NULL, 1, NULL, '{\"permCodeList\":[\"onlineDblink.all\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020011080486913, NULL, '系统管理', 0, NULL, NULL, NULL, NULL, NULL, 1, 'el-icon-setting', '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020012825317376, 1808020011080486913, '用户管理', 1, 'formSysUser', NULL, NULL, NULL, NULL, 100, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020012825317377, 1808020011080486913, '部门管理', 1, 'formSysDept', NULL, NULL, NULL, NULL, 105, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020012825317378, 1808020011080486913, '角色管理', 1, 'formSysRole', NULL, NULL, NULL, NULL, 110, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020012825317379, 1808020011080486913, '数据权限管理', 1, 'formSysDataPerm', NULL, NULL, NULL, NULL, 115, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020012825317380, 1808020011080486913, '岗位管理', 1, 'formSysPost', NULL, NULL, NULL, NULL, 106, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020012825317381, 1808020011080486913, '菜单管理', 1, 'formSysMenu', NULL, NULL, NULL, NULL, 120, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020012825317384, 1808020011080486913, '字典管理', 1, 'formSysDict', NULL, NULL, NULL, NULL, 135, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020012825317385, 1808020011080486913, '操作日志', 1, 'formSysOperationLog', NULL, NULL, NULL, NULL, 140, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020012825317386, 1808020011080486913, '在线用户', 1, 'formSysLoginUser', NULL, NULL, NULL, NULL, 145, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148866, 1808020012825317376, '显示', 3, NULL, NULL, NULL, NULL, NULL, 1, NULL, '{\"menuCode\":\"formSysUser:fragmentSysUser\",\"permCodeList\":[\"sysUser.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148867, 1808020012825317376, '新增', 3, NULL, NULL, NULL, NULL, NULL, 2, NULL, '{\"menuCode\":\"formSysUser:fragmentSysUser:add\",\"permCodeList\":[\"sysUser.add\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148868, 1808020012825317376, '编辑', 3, NULL, NULL, NULL, NULL, NULL, 3, NULL, '{\"menuCode\":\"formSysUser:fragmentSysUser:update\",\"permCodeList\":[\"sysUser.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148869, 1808020012825317376, '删除', 3, NULL, NULL, NULL, NULL, NULL, 4, NULL, '{\"menuCode\":\"formSysUser:fragmentSysUser:delete\",\"permCodeList\":[\"sysUser.delete\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148870, 1808020012825317376, '重置密码', 3, NULL, NULL, NULL, NULL, NULL, 5, NULL, '{\"menuCode\":\"formSysUser:fragmentSysUser:resetPassword\",\"permCodeList\":[\"sysUser.resetPassword\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148872, 1808020012825317377, '显示', 3, NULL, NULL, NULL, NULL, NULL, 1, NULL, '{\"menuCode\":\"formSysDept:fragmentSysDept\",\"permCodeList\":[\"sysDept.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148873, 1808020012825317377, '新增', 3, NULL, NULL, NULL, NULL, NULL, 2, '', '{\"bindType\":0,\"menuCode\":\"formSysDept:fragmentSysDept:add\",\"permCodeList\":[\"sysDept.add\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-05 09:51:07'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148874, 1808020012825317377, '编辑', 3, NULL, NULL, NULL, NULL, NULL, 3, NULL, '{\"menuCode\":\"formSysDept:fragmentSysDept:update\",\"permCodeList\":[\"sysDept.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148875, 1808020012825317377, '删除', 3, NULL, NULL, NULL, NULL, NULL, 4, NULL, '{\"menuCode\":\"formSysDept:fragmentSysDept:delete\",\"permCodeList\":[\"sysDept.delete\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148876, 1808020012825317377, '设置岗位', 3, NULL, NULL, NULL, NULL, NULL, 5, NULL, '{\"menuCode\":\"formSysDept:fragmentSysDept:editPost\",\"permCodeList\":[\"sysDept.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148877, 1808020012825317377, '查看岗位', 3, NULL, NULL, NULL, NULL, NULL, 6, NULL, '{\"menuCode\":\"formSysDept:fragmentSysDept:viewPost\",\"permCodeList\":[\"sysDept.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148879, 1808020012825317378, '角色管理', 2, NULL, NULL, NULL, NULL, NULL, 1, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148880, 1808020012825317378, '用户授权', 2, NULL, NULL, NULL, NULL, NULL, 2, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148881, 1808020075098148879, '显示', 3, NULL, NULL, NULL, NULL, NULL, 1, NULL, '{\"menuCode\":\"formSysRole:fragmentSysRole\",\"permCodeList\":[\"sysRole.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148882, 1808020075098148879, '新增', 3, NULL, NULL, NULL, NULL, NULL, 2, NULL, '{\"menuCode\":\"formSysRole:fragmentSysRole:add\",\"permCodeList\":[\"sysRole.add\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148883, 1808020075098148879, '编辑', 3, NULL, NULL, NULL, NULL, NULL, 3, NULL, '{\"menuCode\":\"formSysRole:fragmentSysRole:update\",\"permCodeList\":[\"sysRole.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148884, 1808020075098148879, '删除', 3, NULL, NULL, NULL, NULL, NULL, 4, NULL, '{\"menuCode\":\"formSysRole:fragmentSysRole:delete\",\"permCodeList\":[\"sysRole.delete\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148885, 1808020075098148880, '显示', 3, NULL, NULL, NULL, NULL, NULL, 1, NULL, '{\"menuCode\":\"formSysRole:fragmentSysRoleUser\",\"permCodeList\":[\"sysRole.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148886, 1808020075098148880, '授权用户', 3, NULL, NULL, NULL, NULL, NULL, 2, NULL, '{\"menuCode\":\"formSysRole:fragmentSysRoleUser:addUserRole\",\"permCodeList\":[\"sysRole.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148887, 1808020075098148880, '移除用户', 3, NULL, NULL, NULL, NULL, NULL, 3, NULL, '{\"menuCode\":\"formSysRole:fragmentSysRoleUser:deleteUserRole\",\"permCodeList\":[\"sysRole.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148889, 1808020012825317379, '数据权限管理', 2, NULL, NULL, NULL, NULL, NULL, 1, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148890, 1808020012825317379, '用户授权', 2, NULL, NULL, NULL, NULL, NULL, 2, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148891, 1808020075098148889, '显示', 3, NULL, NULL, NULL, NULL, NULL, 1, NULL, '{\"menuCode\":\"formSysDataPerm:fragmentSysDataPerm\",\"permCodeList\":[\"sysDataPerm.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148892, 1808020075098148889, '新增', 3, NULL, NULL, NULL, NULL, NULL, 2, NULL, '{\"menuCode\":\"formSysDataPerm:fragmentSysDataPerm:add\",\"permCodeList\":[\"sysDataPerm.add\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148893, 1808020075098148889, '编辑', 3, NULL, NULL, NULL, NULL, NULL, 3, NULL, '{\"menuCode\":\"formSysDataPerm:fragmentSysDataPerm:update\",\"permCodeList\":[\"sysDataPerm.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148894, 1808020075098148889, '删除', 3, NULL, NULL, NULL, NULL, NULL, 4, NULL, '{\"menuCode\":\"formSysDataPerm:fragmentSysDataPerm:delete\",\"permCodeList\":[\"sysDataPerm.delete\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148895, 1808020075098148890, '显示', 3, NULL, NULL, NULL, NULL, NULL, 1, NULL, '{\"menuCode\":\"formSysDataPerm:fragmentSysDataPermUser\",\"permCodeList\":[\"sysDataPerm.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148896, 1808020075098148890, '授权用户', 3, NULL, NULL, NULL, NULL, NULL, 2, NULL, '{\"menuCode\":\"formSysDataPerm:fragmentSysDataPermUser:addDataPermUser\",\"permCodeList\":[\"sysDataPerm.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148897, 1808020075098148890, '移除用户', 3, NULL, NULL, NULL, NULL, NULL, 3, NULL, '{\"menuCode\":\"formSysDataPerm:fragmentSysDataPermUser:deleteDataPermUser\",\"permCodeList\":[\"sysDataPerm.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148899, 1808020012825317380, '岗位管理', 2, NULL, NULL, NULL, NULL, NULL, 1, NULL, '', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148900, 1808020075098148899, '显示', 3, NULL, NULL, NULL, NULL, NULL, 1, NULL, '{\"menuCode\":\"formSysPost:fragmentSysPost\",\"permCodeList\":[\"sysPost.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148901, 1808020075098148899, '新增', 3, NULL, NULL, NULL, NULL, NULL, 2, NULL, '{\"menuCode\":\"formSysPost:fragmentSysPost:add\",\"permCodeList\":[\"sysPost.add\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148902, 1808020075098148899, '编辑', 3, NULL, NULL, NULL, NULL, NULL, 3, NULL, '{\"menuCode\":\"formSysPost:fragmentSysPost:update\",\"permCodeList\":[\"sysPost.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148903, 1808020075098148899, '删除', 3, NULL, NULL, NULL, NULL, NULL, 4, NULL, '{\"menuCode\":\"formSysPost:fragmentSysPost:delete\",\"permCodeList\":[\"sysPost.delete\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148905, 1808020012825317381, '显示', 3, NULL, NULL, NULL, NULL, NULL, 1, NULL, '{\"menuCode\":\"formSysMenu:fragmentSysMenu\",\"permCodeList\":[\"sysMenu.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148906, 1808020012825317381, '新增', 3, NULL, NULL, NULL, NULL, NULL, 2, NULL, '{\"menuCode\":\"formSysMenu:fragmentSysMenu:add\",\"permCodeList\":[\"sysMenu.add\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148907, 1808020012825317381, '编辑', 3, NULL, NULL, NULL, NULL, NULL, 3, NULL, '{\"menuCode\":\"formSysMenu:fragmentSysMenu:update\",\"permCodeList\":[\"sysMenu.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075098148908, 1808020012825317381, '删除', 3, NULL, NULL, NULL, NULL, NULL, 4, NULL, '{\"menuCode\":\"formSysMenu:fragmentSysMenu:delete\",\"permCodeList\":[\"sysMenu.delete\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075102343171, 1808020012825317384, '显示', 3, NULL, NULL, NULL, NULL, NULL, 1, NULL, '{\"menuCode\":\"formSysDict:fragmentSysDict\",\"permCodeList\":[\"globalDict.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075102343172, 1808020012825317384, '新增', 3, NULL, NULL, NULL, NULL, NULL, 2, NULL, '{\"menuCode\":\"formSysDict:fragmentSysDict:add\",\"permCodeList\":[\"globalDict.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075102343173, 1808020012825317384, '编辑', 3, NULL, NULL, NULL, NULL, NULL, 3, NULL, '{\"menuCode\":\"formSysDict:fragmentSysDict:update\",\"permCodeList\":[\"globalDict.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075102343174, 1808020012825317384, '删除', 3, NULL, NULL, NULL, NULL, NULL, 4, NULL, '{\"menuCode\":\"formSysDict:fragmentSysDict:delete\",\"permCodeList\":[\"globalDict.update\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075102343175, 1808020012825317384, '同步缓存', 3, NULL, NULL, NULL, NULL, NULL, 5, NULL, '{\"menuCode\":\"formSysDict:fragmentSysDict:reloadCache\",\"permCodeList\":[\"globalDict.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075102343177, 1808020012825317385, '显示', 3, NULL, NULL, NULL, NULL, NULL, 1, NULL, '{\"menuCode\":\"formSysOperationLog:fragmentSysOperationLog\",\"permCodeList\":[\"sysOperationLog.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075102343179, 1808020012825317386, '显示', 3, NULL, NULL, NULL, NULL, NULL, 1, NULL, '{\"menuCode\":\"formSysLoginUser:fragmentLoginUser\",\"permCodeList\":[\"loginUser.view\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +INSERT INTO `zz_sys_menu` VALUES (1808020075102343180, 1808020012825317386, '强制下线', 3, NULL, NULL, NULL, NULL, NULL, 2, NULL, '{\"menuCode\":\"formSysLoginUser:fragmentLoginUser:delete\",\"permCodeList\":[\"loginUser.delete\"]}', 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00'); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_operation_log +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_operation_log`; +CREATE TABLE `zz_sys_operation_log` ( + `log_id` bigint NOT NULL COMMENT '主键Id', + `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '日志描述', + `operation_type` int DEFAULT NULL COMMENT '操作类型', + `service_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '接口所在服务名称', + `api_class` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '调用的controller全类名', + `api_method` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '调用的controller中的方法', + `session_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '用户会话sessionId', + `trace_id` char(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '每次请求的Id', + `elapse` int DEFAULT NULL COMMENT '调用时长', + `request_method` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'HTTP 请求方法,如GET', + `request_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'HTTP 请求地址', + `request_arguments` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT 'controller接口参数', + `response_result` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'controller应答结果', + `request_ip` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '请求IP', + `success` bit(1) DEFAULT NULL COMMENT '应答状态', + `error_msg` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '错误信息', + `tenant_id` bigint DEFAULT NULL COMMENT '租户Id', + `operator_id` bigint DEFAULT NULL COMMENT '操作员Id', + `operator_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '操作员名称', + `operation_time` datetime DEFAULT NULL COMMENT '操作时间', + PRIMARY KEY (`log_id`), + KEY `idx_trace_id_idx` (`trace_id`), + KEY `idx_operation_type_idx` (`operation_type`), + KEY `idx_operation_time_idx` (`operation_time`) USING BTREE, + KEY `idx_success` (`success`) USING BTREE, + KEY `idx_elapse` (`elapse`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='系统操作日志表'; + +-- ---------------------------- +-- Records of zz_sys_operation_log +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_operation_log` VALUES (1809037495178891264, '', 0, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.LoginController', 'com.orangeforms.webadmin.upms.controller.LoginController.doLogin', NULL, 'c5eafaee0e294b3b8fe1ddc47a73aa6f', 526, 'POST', '/admin/upms/login/doLogin', '{\"password\":\"U7kblCgd8NWaoUrEH%2B0j0ocRESztOUkH4L1eMANf40rAVWfgTmw8w1D2QeH2b99bxJQRCoELhiJDo3NbdN8sodZf%2BWa%2BRoH8URHmG1qziSMw4C%2Fc40gR1x4vclxMrq9jN1d3yP2gVljlaxVmMQcVsLqGsgcxfvyucwYzClifRUY%3D\",\"loginName\":\"admin\"}', NULL, '192.168.43.167', b'0', '用户名或密码错误,请重试!', NULL, NULL, NULL, '2024-07-05 09:32:04'); +INSERT INTO `zz_sys_operation_log` VALUES (1809037516607590400, '', 0, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.LoginController', 'com.orangeforms.webadmin.upms.controller.LoginController.doLogin', NULL, 'f1104bc680014a999321a6ca3c240485', 136, 'POST', '/admin/upms/login/doLogin', '{\"password\":\"MYjsPjZgslAadC1%2FhwPRNyG5yvtl%2BRVWJGOj0MfPNNJyTMMBgPrymEsoMsR%2FnSog7TdIborw%2BYgO9o31KFowqf3I3Gw6oI0qXkDbJKBqeDqkKKoOa95J9ITm7TKHKYcKu15xhmQvmU1OIMs59A2w39Cx1Z58I7gtbtHHL34iVJg%3D\",\"loginName\":\"admin\"}', NULL, '192.168.43.167', b'0', '用户名或密码错误,请重试!', NULL, NULL, NULL, '2024-07-05 09:32:09'); +INSERT INTO `zz_sys_operation_log` VALUES (1809037535469375488, '', 0, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.LoginController', 'com.orangeforms.webadmin.upms.controller.LoginController.doLogin', 'Authorization:login:token-session:5fb5b15d-2b4c-4063-ae55-5b0ec195fa39', '58de29f3ec22457d8f4f980a350cf623', 579, 'POST', '/admin/upms/login/doLogin', '{\"password\":\"i%2BcOZFUuWVmCCh%2B1ZhtpXTD8RNG1S4GMABC0dZssCPYckczkR%2FeRSuiYCMlDLaUa1oN%2BPeZRvj3zPKmDcuDyi0Jewxq7kTFyFAy%2Fbrep5MD3i2X%2BtV9B%2FT3CMMdbdOMa1OVP1AUO%2FBbmGdu0iK3UpvL608mJx1vqbpLRynYBazc%3D\",\"loginName\":\"admin\"}', NULL, '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 09:32:13'); +INSERT INTO `zz_sys_operation_log` VALUES (1809037772132978688, '', 10, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.SysRoleController', 'com.orangeforms.webadmin.upms.controller.SysRoleController.add', 'Authorization:login:token-session:5fb5b15d-2b4c-4063-ae55-5b0ec195fa39', 'cd5eb86b69094458881aa6dcb04aa766', 5496, 'POST', '/admin/upms/sysRole/add', '{\"menuIdListString\":\"1392786476428693504,1392786549942259712,1392786950682841088,1634009076981567488,1418057714138877952,1418057835631087616,1418058289182150656,1418058744037642240,1418059005175009280,1418059167532322816,1418059283920064512,1423161217970606080,1808020011080486913,1808020012825317376,1808020075098148866,1808020075098148867,1808020075098148868,1808020075098148869,1808020075098148870,1808020012825317377,1808020075098148872,1808020075098148873,1808020075098148874,1808020075098148875,1808020075098148876,1808020075098148877,1808020012825317378,1808020075098148879,1808020075098148881,1808020075098148882,1808020075098148883,1808020075098148884,1808020075098148880,1808020075098148885,1808020075098148886,1808020075098148887,1808020012825317379,1808020075098148889,1808020075098148891,1808020075098148892,1808020075098148893,1808020075098148894,1808020075098148890,1808020075098148895,1808020075098148896,1808020075098148897,1808020012825317380,1808020075098148899,1808020075098148900,1808020075098148901,1808020075098148902,1808020075098148903,1808020012825317381,1808020075098148905,1808020075098148906,1808020075098148907,1808020075098148908,1808020012825317384,1808020075102343171,1808020075102343172,1808020075102343173,1808020075102343174,1808020075102343175,1808020012825317385,1808020075102343177,1808020012825317386,1808020075102343179,1808020075102343180\",\"sysRoleDto\":{\"roleName\":\"查看全部\"}}', '{\"data\":1809037772728569856,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 09:33:10'); +INSERT INTO `zz_sys_operation_log` VALUES (1809037881738530816, '', 10, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.SysDataPermController', 'com.orangeforms.webadmin.upms.controller.SysDataPermController.add', 'Authorization:login:token-session:5fb5b15d-2b4c-4063-ae55-5b0ec195fa39', '85746a39a3a34191884eb30453ecc237', 220, 'POST', '/admin/upms/sysDataPerm/add', '{\"sysDataPermDto\":{\"dataPermName\":\"查看全部\",\"ruleType\":0},\"menuIdListString\":\"\"}', '{\"data\":1809037881759502336,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 09:33:36'); +INSERT INTO `zz_sys_operation_log` VALUES (1809037927917817856, '', 10, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.SysPostController', 'com.orangeforms.webadmin.upms.controller.SysPostController.add', 'Authorization:login:token-session:5fb5b15d-2b4c-4063-ae55-5b0ec195fa39', 'fa4bf0f0b80748249bdfb4c78bb93b8d', 190, 'POST', '/admin/upms/sysPost/add', '{\"sysPostDto\":{\"leaderPost\":true,\"postLevel\":1,\"postName\":\"领导岗位\"}}', '{\"data\":1809037927934595072,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 09:33:47'); +INSERT INTO `zz_sys_operation_log` VALUES (1809037967658848256, '', 10, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.SysPostController', 'com.orangeforms.webadmin.upms.controller.SysPostController.add', 'Authorization:login:token-session:5fb5b15d-2b4c-4063-ae55-5b0ec195fa39', '04da87ca21294e0296af2e162999e396', 228, 'POST', '/admin/upms/sysPost/add', '{\"sysPostDto\":{\"postLevel\":10,\"postName\":\"普通员工\"}}', '{\"data\":1809037967663042560,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 09:33:56'); +INSERT INTO `zz_sys_operation_log` VALUES (1809038123905060864, '', 10, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.SysUserController', 'com.orangeforms.webadmin.upms.controller.SysUserController.add', 'Authorization:login:token-session:5fb5b15d-2b4c-4063-ae55-5b0ec195fa39', '99bb05eadf944b54a194db3152773b13', 635, 'POST', '/admin/upms/sysUser/add', '{\"sysUserDto\":{\"deptId\":1808020008341606402,\"loginName\":\"userA\",\"password\":\"123456\",\"showName\":\"员工A\",\"userStatus\":0,\"userType\":2},\"dataPermIdListString\":\"1809037881759502336\",\"deptPostIdListString\":\"1809038003968937984\",\"roleIdListString\":\"1809037772728569856\"}', '{\"data\":1809038124504846336,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 09:34:34'); +INSERT INTO `zz_sys_operation_log` VALUES (1809042287854882816, '', 15, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.SysMenuController', 'com.orangeforms.webadmin.upms.controller.SysMenuController.update', 'Authorization:login:token-session:5fb5b15d-2b4c-4063-ae55-5b0ec195fa39', '68dd67ca9821460caee6986c5c3c3354', 420, 'POST', '/admin/upms/sysMenu/update', '{\"sysMenuDto\":{\"extraData\":\"{\\\"bindType\\\":0,\\\"menuCode\\\":\\\"formSysDept:fragmentSysDept:add\\\",\\\"permCodeList\\\":[\\\"sysDept.add\\\"]}\",\"icon\":\"\",\"menuId\":1808020075098148873,\"menuName\":\"新增\",\"menuType\":3,\"parentId\":1808020012825317377,\"showOrder\":2}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 09:51:06'); +INSERT INTO `zz_sys_operation_log` VALUES (1809050375580291072, '', 5, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.LoginController', 'com.orangeforms.webadmin.upms.controller.LoginController.doLogout', 'Authorization:login:token-session:5fb5b15d-2b4c-4063-ae55-5b0ec195fa39', '8611984bfad74113bcc5f5a2d30f0557', 36, 'POST', '/admin/upms/login/doLogout', '{}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 10:23:15'); +INSERT INTO `zz_sys_operation_log` VALUES (1809050381297127424, '', 0, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.LoginController', 'com.orangeforms.webadmin.upms.controller.LoginController.doLogin', NULL, 'bb940a20dbac4f11b7d448ebe11668c4', 466, 'POST', '/admin/upms/login/doLogin', '{\"password\":\"jiRS2mxriWjx778WM%2FJql65bpRfu7BaqVkPrDySclvJ7%2B%2B0KSuAIZ557bEFocQnCWbfLJwRFokTUDastSpEeiFAsd1kwv6oZyQimj4KCyDtin6P6gPsn2GRQrFKACkOKBXY70FeGgQvaVwWBEGo6EzdfJw9adJOGf2WIigrIajk%3D\",\"loginName\":\"admin\"}', NULL, '192.168.43.167', b'0', '用户名或密码错误,请重试!', NULL, NULL, NULL, '2024-07-05 10:23:16'); +INSERT INTO `zz_sys_operation_log` VALUES (1809050432673157120, '', 0, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.LoginController', 'com.orangeforms.webadmin.upms.controller.LoginController.doLogin', NULL, 'ffe77e34ec35454da6e71b0cef7f2ea8', 143, 'POST', '/admin/upms/login/doLogin', '{\"password\":\"Kdkf8xz%2Fay2lKRidpUGWBJM7%2BlvxTVpjdSNLCuL1yx6LbVvTPo7PD5zFBLKMPWeSrtostyAFybz6lAAHpdCnQWjmbBbpMExTmY74O12EQySXOQBwrmH3yltq9MXJI5qRJ24imMxYyTvcX2yDMbEfDF3zcC404GvTgX0gexCmTjs%3D\",\"loginName\":\"userA\"}', NULL, '192.168.43.167', b'0', '用户名或密码错误,请重试!', NULL, NULL, NULL, '2024-07-05 10:23:28'); +INSERT INTO `zz_sys_operation_log` VALUES (1809050456257728512, '', 0, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.LoginController', 'com.orangeforms.webadmin.upms.controller.LoginController.doLogin', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', 'b43789173f9244aa803866db7bafca73', 460, 'POST', '/admin/upms/login/doLogin', '{\"password\":\"gYCq1nWZHSsvg35HCgnRzw23kN3PRTZJY%2Bt2bcZWliYf11o14OHEDhsH12nCC4LYn00UEDoYWbbMdiwNzQFmcgmbJq4%2Fu6uxURokHpI%2BEexZnL5IzWBb2P53hGBwUkOO36jRfbTm%2B0qRtIbpATs74jpc1L%2FFbT18%2Fj%2FN9C3bpq4%3D\",\"loginName\":\"userA\"}', NULL, '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:23:34'); +INSERT INTO `zz_sys_operation_log` VALUES (1809050496074256384, '', 15, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.SysUserController', 'com.orangeforms.webadmin.upms.controller.SysUserController.update', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', '8926e20ea352417aab2234d2de2c1fea', 903, 'POST', '/admin/upms/sysUser/update', '{\"sysUserDto\":{\"deptId\":1808020008341606402,\"loginName\":\"userA\",\"showName\":\"员工A\",\"userId\":1809038124504846336,\"userStatus\":0,\"userType\":2},\"dataPermIdListString\":\"1809037881759502336\",\"deptPostIdListString\":\"1809038003968937984\",\"roleIdListString\":\"1809037772728569856\"}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:23:43'); +INSERT INTO `zz_sys_operation_log` VALUES (1809051198259466240, '', 10, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowCategoryController', 'com.orangeforms.common.flow.controller.FlowCategoryController.add', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', 'cd9d22e5fd194e7dac6c90531cab52dd', 249, 'POST', '/admin/flow/flowCategory/add', '{\"flowCategoryDto\":{\"code\":\"TEST\",\"name\":\"测试分类\",\"showOrder\":1}}', '{\"data\":1809051198460792832,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:26:31'); +INSERT INTO `zz_sys_operation_log` VALUES (1809052045043306496, '', 10, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryController', 'com.orangeforms.common.flow.controller.FlowEntryController.add', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', '66225485743a44df81882b0b70885c69', 478, 'POST', '/admin/flow/flowEntry/add', '{\"flowEntryDto\":{\"bindFormType\":1,\"categoryId\":1809051198460792832,\"defaultRouterName\":\"AAA\",\"diagramType\":0,\"encodedRule\":\"{\\\"middle\\\":\\\"DD\\\",\\\"idWidth\\\":5,\\\"prefix\\\":\\\"AA\\\",\\\"precisionTo\\\":\\\"DAYS\\\",\\\"calculateWhenView\\\":true}\",\"extensionData\":\"{\\\"approvalStatusDict\\\":[{\\\"id\\\":1,\\\"name\\\":\\\"同意\\\"},{\\\"id\\\":2,\\\"name\\\":\\\"拒绝\\\"},{\\\"id\\\":3,\\\"name\\\":\\\"驳回\\\"},{\\\"id\\\":4,\\\"name\\\":\\\"会签同意\\\"},{\\\"id\\\":5,\\\"name\\\":\\\"会签拒绝\\\"}],\\\"notifyTypes\\\":[],\\\"cascadeDeleteBusinessData\\\":false,\\\"supportRevive\\\":false}\",\"processDefinitionKey\":\"AAA\",\"processDefinitionName\":\"AAA\"}}', '{\"data\":1809052045395628032,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:29:53'); +INSERT INTO `zz_sys_operation_log` VALUES (1809052080904605696, '', 10, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryVariableController', 'com.orangeforms.common.flow.controller.FlowEntryVariableController.add', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', 'c7804ebbe24d492b82c23cb5f3b25879', 225, 'POST', '/admin/flow/flowEntryVariable/add', '{\"flowEntryVariableDto\":{\"builtin\":false,\"entryId\":1809052045395628032,\"showName\":\"AAA\",\"variableName\":\"aaa\",\"variableType\":1}}', '{\"data\":1809052080921382912,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:30:01'); +INSERT INTO `zz_sys_operation_log` VALUES (1809052112206696448, '', 15, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryController', 'com.orangeforms.common.flow.controller.FlowEntryController.update', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', '9c28172a4ac74b448439334f0ea44d34', 306, 'POST', '/admin/flow/flowEntry/update', '{\"flowEntryDto\":{\"bindFormType\":1,\"categoryId\":1809051198460792832,\"defaultRouterName\":\"AAA\",\"diagramType\":0,\"encodedRule\":\"{\\\"middle\\\":\\\"DD\\\",\\\"idWidth\\\":5,\\\"prefix\\\":\\\"AA\\\",\\\"precisionTo\\\":\\\"DAYS\\\",\\\"calculateWhenView\\\":true}\",\"entryId\":1809052045395628032,\"extensionData\":\"{\\\"approvalStatusDict\\\":[{\\\"id\\\":1,\\\"name\\\":\\\"同意\\\",\\\"_X_ROW_KEY\\\":\\\"row_28\\\"},{\\\"id\\\":2,\\\"name\\\":\\\"拒绝\\\",\\\"_X_ROW_KEY\\\":\\\"row_29\\\"},{\\\"id\\\":3,\\\"name\\\":\\\"驳回\\\",\\\"_X_ROW_KEY\\\":\\\"row_30\\\"},{\\\"id\\\":4,\\\"name\\\":\\\"会签同意\\\",\\\"_X_ROW_KEY\\\":\\\"row_31\\\"},{\\\"id\\\":5,\\\"name\\\":\\\"会签拒绝\\\",\\\"_X_ROW_KEY\\\":\\\"row_32\\\"},{\\\"name\\\":\\\"AAA\\\",\\\"id\\\":11}],\\\"notifyTypes\\\":[]}\",\"processDefinitionKey\":\"AAA\",\"processDefinitionName\":\"AAA\"}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:30:09'); +INSERT INTO `zz_sys_operation_log` VALUES (1809052122159779840, '', 15, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryController', 'com.orangeforms.common.flow.controller.FlowEntryController.update', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', 'c9af56a061bb4a87a964cb617f4f9c15', 201, 'POST', '/admin/flow/flowEntry/update', '{\"flowEntryDto\":{\"bindFormType\":1,\"categoryId\":1809051198460792832,\"defaultRouterName\":\"AAA\",\"diagramType\":0,\"encodedRule\":\"{\\\"middle\\\":\\\"DD\\\",\\\"idWidth\\\":5,\\\"prefix\\\":\\\"AA\\\",\\\"precisionTo\\\":\\\"DAYS\\\",\\\"calculateWhenView\\\":true}\",\"entryId\":1809052045395628032,\"extensionData\":\"{\\\"approvalStatusDict\\\":[{\\\"id\\\":1,\\\"name\\\":\\\"同意\\\",\\\"_X_ROW_KEY\\\":\\\"row_28\\\"},{\\\"id\\\":2,\\\"name\\\":\\\"拒绝\\\",\\\"_X_ROW_KEY\\\":\\\"row_29\\\"},{\\\"id\\\":3,\\\"name\\\":\\\"驳回\\\",\\\"_X_ROW_KEY\\\":\\\"row_30\\\"},{\\\"id\\\":4,\\\"name\\\":\\\"会签同意\\\",\\\"_X_ROW_KEY\\\":\\\"row_31\\\"},{\\\"id\\\":5,\\\"name\\\":\\\"会签拒绝\\\",\\\"_X_ROW_KEY\\\":\\\"row_32\\\"},{\\\"name\\\":\\\"AAA\\\",\\\"id\\\":11,\\\"_X_ROW_KEY\\\":\\\"row_33\\\"}],\\\"notifyTypes\\\":[],\\\"cascadeDeleteBusinessData\\\":false,\\\"supportRevive\\\":false}\",\"processDefinitionKey\":\"AAA\",\"processDefinitionName\":\"AAA\"}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:30:11'); +INSERT INTO `zz_sys_operation_log` VALUES (1809052746851028992, '', 15, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryController', 'com.orangeforms.common.flow.controller.FlowEntryController.update', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', '6609a8762f6c49af9f570b746a30b8ac', 297, 'POST', '/admin/flow/flowEntry/update', '{\"flowEntryDto\":{\"bindFormType\":1,\"categoryId\":1809051198460792832,\"defaultRouterName\":\"AAA\",\"diagramType\":0,\"encodedRule\":\"{\\\"middle\\\":\\\"DD\\\",\\\"idWidth\\\":5,\\\"prefix\\\":\\\"AA\\\",\\\"precisionTo\\\":\\\"DAYS\\\",\\\"calculateWhenView\\\":true}\",\"entryId\":1809052045395628032,\"extensionData\":\"{\\\"approvalStatusDict\\\":[{\\\"id\\\":1,\\\"name\\\":\\\"同意\\\",\\\"_X_ROW_KEY\\\":\\\"row_28\\\"},{\\\"id\\\":2,\\\"name\\\":\\\"拒绝\\\",\\\"_X_ROW_KEY\\\":\\\"row_29\\\"},{\\\"id\\\":3,\\\"name\\\":\\\"驳回\\\",\\\"_X_ROW_KEY\\\":\\\"row_30\\\"},{\\\"id\\\":4,\\\"name\\\":\\\"会签同意\\\",\\\"_X_ROW_KEY\\\":\\\"row_31\\\"},{\\\"id\\\":5,\\\"name\\\":\\\"会签拒绝\\\",\\\"_X_ROW_KEY\\\":\\\"row_32\\\"},{\\\"name\\\":\\\"AAA\\\",\\\"id\\\":11,\\\"_X_ROW_KEY\\\":\\\"row_33\\\"}],\\\"notifyTypes\\\":[],\\\"cascadeDeleteBusinessData\\\":false,\\\"supportRevive\\\":false}\",\"processDefinitionKey\":\"AAA\",\"processDefinitionName\":\"AAA\",\"status\":0}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:32:40'); +INSERT INTO `zz_sys_operation_log` VALUES (1809052753826156544, '', 15, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryController', 'com.orangeforms.common.flow.controller.FlowEntryController.update', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', 'b1c15eb123b14ae68876d1e026b8f498', 267, 'POST', '/admin/flow/flowEntry/update', '{\"flowEntryDto\":{\"bindFormType\":1,\"categoryId\":1809051198460792832,\"defaultRouterName\":\"AAA\",\"diagramType\":0,\"encodedRule\":\"{\\\"middle\\\":\\\"DD\\\",\\\"idWidth\\\":5,\\\"prefix\\\":\\\"AA\\\",\\\"precisionTo\\\":\\\"DAYS\\\",\\\"calculateWhenView\\\":true}\",\"entryId\":1809052045395628032,\"extensionData\":\"{\\\"approvalStatusDict\\\":[{\\\"id\\\":1,\\\"name\\\":\\\"同意\\\",\\\"_X_ROW_KEY\\\":\\\"row_28\\\"},{\\\"id\\\":2,\\\"name\\\":\\\"拒绝\\\",\\\"_X_ROW_KEY\\\":\\\"row_29\\\"},{\\\"id\\\":3,\\\"name\\\":\\\"驳回\\\",\\\"_X_ROW_KEY\\\":\\\"row_30\\\"},{\\\"id\\\":4,\\\"name\\\":\\\"会签同意\\\",\\\"_X_ROW_KEY\\\":\\\"row_31\\\"},{\\\"id\\\":5,\\\"name\\\":\\\"会签拒绝\\\",\\\"_X_ROW_KEY\\\":\\\"row_32\\\"},{\\\"name\\\":\\\"AAA\\\",\\\"id\\\":11,\\\"_X_ROW_KEY\\\":\\\"row_33\\\"}],\\\"notifyTypes\\\":[],\\\"cascadeDeleteBusinessData\\\":false,\\\"supportRevive\\\":false}\",\"processDefinitionKey\":\"AAA\",\"processDefinitionName\":\"AAA\",\"status\":0}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:32:42'); +INSERT INTO `zz_sys_operation_log` VALUES (1809055300347498496, '', 10, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineDblinkController', 'com.orangeforms.common.online.controller.OnlineDblinkController.add', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', '4552709db33b4ac38520c97cbfbd84fb', 180, 'POST', '/admin/online/onlineDblink/add', '{\"onlineDblinkDto\":{\"configuration\":\"{\\\"sid\\\":true,\\\"initialPoolSize\\\":5,\\\"minPoolSize\\\":5,\\\"maxPoolSize\\\":50,\\\"host\\\":\\\"121.37.102.103\\\",\\\"port\\\":3306,\\\"database\\\":\\\"zzdemo-online-open\\\",\\\"username\\\":\\\"root\\\",\\\"password\\\":\\\"TianLiujielei231\\\"}\",\"dblinkName\":\"mysql-test\",\"dblinkType\":0}}', '{\"data\":1809055300360081408,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:42:49'); +INSERT INTO `zz_sys_operation_log` VALUES (1809055451015286784, '', 10, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlinePageController', 'com.orangeforms.common.online.controller.OnlinePageController.add', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', 'f6a28f34b7d94f0ca0ea0efdb23b59b6', 307, 'POST', '/admin/online/onlinePage/add', '{\"onlinePageDto\":{\"pageCode\":\"test\",\"pageName\":\"test\",\"pageType\":1,\"status\":1}}', '{\"data\":1809055451229196288,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:43:25'); +INSERT INTO `zz_sys_operation_log` VALUES (1809055625460584448, '', 10, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineDatasourceController', 'com.orangeforms.common.online.controller.OnlineDatasourceController.add', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', 'cc233f444b9741e79e85902c6ced44c5', 2989, 'POST', '/admin/online/onlineDatasource/add', '{\"onlineDatasourceDto\":{\"datasourceName\":\"test\",\"dblinkId\":1809055300360081408,\"masterTableName\":\"zz_flow_entry\",\"variableName\":\"test\"},\"pageId\":1809055451229196288}', '{\"data\":1809055636340609024,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:44:06'); +INSERT INTO `zz_sys_operation_log` VALUES (1809055701822083072, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlinePageController', 'com.orangeforms.common.online.controller.OnlinePageController.update', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', 'b9943033448544c5a5dcb93fe450bbeb', 245, 'POST', '/admin/online/onlinePage/update', '{\"onlinePageDto\":{\"pageCode\":\"test\",\"pageId\":1809055451229196288,\"pageName\":\"test\",\"pageType\":1,\"status\":2}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:44:25'); +INSERT INTO `zz_sys_operation_log` VALUES (1809055740065746944, '', 10, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineFormController', 'com.orangeforms.common.online.controller.OnlineFormController.add', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', 'abc44f1518ed471597d38fad6161e8ae', 589, 'POST', '/admin/online/onlineForm/add', '{\"onlineFormDto\":{\"datasourceIdList\":[1809055636340609024],\"formCode\":\"aaa\",\"formKind\":5,\"formName\":\"aaa\",\"formType\":1,\"masterTableId\":1809055626488188928,\"pageId\":1809055451229196288,\"paramsJson\":\"[]\",\"widgetJson\":\"{\\\"pc\\\":{\\\"filterItemWidth\\\":350,\\\"gutter\\\":20,\\\"labelWidth\\\":100,\\\"labelPosition\\\":\\\"right\\\",\\\"tableWidget\\\":{\\\"widgetType\\\":100,\\\"bindData\\\":{\\\"defaultValue\\\":{}},\\\"operationList\\\":[{\\\"id\\\":1,\\\"type\\\":10,\\\"name\\\":\\\"批量删除\\\",\\\"enabled\\\":false,\\\"builtin\\\":true,\\\"rowOperation\\\":false,\\\"btnType\\\":\\\"danger\\\",\\\"plain\\\":true,\\\"readOnly\\\":false,\\\"showOrder\\\":0,\\\"eventList\\\":[]},{\\\"id\\\":2,\\\"type\\\":0,\\\"name\\\":\\\"新建\\\",\\\"enabled\\\":false,\\\"builtin\\\":true,\\\"rowOperation\\\":false,\\\"btnType\\\":\\\"primary\\\",\\\"plain\\\":false,\\\"readOnly\\\":false,\\\"showOrder\\\":1,\\\"eventList\\\":[]},{\\\"id\\\":3,\\\"type\\\":1,\\\"name\\\":\\\"编辑\\\",\\\"enabled\\\":false,\\\"builtin\\\":true,\\\"rowOperation\\\":true,\\\"btnClass\\\":\\\"table-btn success\\\",\\\"readOnly\\\":false,\\\"showOrder\\\":10,\\\"eventList\\\":[]},{\\\"id\\\":4,\\\"type\\\":2,\\\"name\\\":\\\"删除\\\",\\\"enabled\\\":false,\\\"builtin\\\":true,\\\"rowOperation\\\":true,\\\"btnClass\\\":\\\"table-btn delete\\\",\\\"readOnly\\\":false,\\\"showOrder\\\":15,\\\"eventList\\\":[]}],\\\"showName\\\":\\\"表格组件\\\",\\\"variableName\\\":\\\"table1720147467397\\\",\\\"props\\\":{\\\"span\\\":24,\\\"height\\\":300,\\\"paddingBottom\\\":0,\\\"paged\\\":true,\\\"pageSize\\\":10,\\\"operationColumnWidth\\\":160,\\\"tableColumnList\\\":[]},\\\"eventList\\\":[],\\\"childWidgetList\\\":[],\\\"style\\\":{},\\\"supportOperation\\\":true},\\\"leftWidget\\\":{\\\"widgetType\\\":13,\\\"bindData\\\":{\\\"defaultValue\\\":{}},\\\"showName\\\":\\\"树形选择组件\\\",\\\"variableName\\\":\\\"tree1720147467397\\\",\\\"props\\\":{\\\"span\\\":24,\\\"height\\\":300,\\\"dictInfo\\\":{},\\\"required\\\":false,\\\"disabled\\\":false},\\\"eventList\\\":[],\\\"childWidgetList\\\":[],\\\"style\\\":{},\\\"supportOperation\\\":false},\\\"operationList\\\":[{\\\"id\\\":0,\\\"type\\\":3,\\\"name\\\":\\\"导出\\\",\\\"enabled\\\":false,\\\"builtin\\\":true,\\\"rowOperation\\\":false,\\\"btnType\\\":\\\"primary\\\",\\\"plain\\\":true,\\\"paramList\\\":[],\\\"eventList\\\":[],\\\"readOnly\\\":false,\\\"showOrder\\\":0},{\\\"id\\\":1,\\\"type\\\":10,\\\"name\\\":\\\"批量删除\\\",\\\"en', '{\"data\":1809055741093351424,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:44:34'); +INSERT INTO `zz_sys_operation_log` VALUES (1809056459653124096, '', 20, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineFormController', 'com.orangeforms.common.online.controller.OnlineFormController.delete', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', '406cd42f8c3a408fa8928e94a8ebdcc6', 329, 'POST', '/admin/online/onlineForm/delete', '{\"formId\":1809055741093351424}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:47:25'); +INSERT INTO `zz_sys_operation_log` VALUES (1809056484886056960, '', 20, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineFormController', 'com.orangeforms.common.online.controller.OnlineFormController.delete', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', 'ac3418b76d474c99862e49acab906011', 76, 'POST', '/admin/online/onlineForm/delete', '{\"formId\":1809055741093351424}', '{\"errorCode\":\"DATA_NOT_EXIST\",\"errorMessage\":\"数据不存在,请刷新后重试!\",\"success\":false}', '192.168.43.167', b'0', '数据不存在,请刷新后重试!', NULL, 1809038124504846336, 'userA', '2024-07-05 10:47:31'); +INSERT INTO `zz_sys_operation_log` VALUES (1809056769645744128, '', 10, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineFormController', 'com.orangeforms.common.online.controller.OnlineFormController.add', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', '5ac915cc240f4463817134fbcba16d94', 508, 'POST', '/admin/online/onlineForm/add', '{\"onlineFormDto\":{\"datasourceIdList\":[1809055636340609024],\"formCode\":\"aaa\",\"formKind\":5,\"formName\":\"aaa\",\"formType\":1,\"masterTableId\":1809055626488188928,\"pageId\":1809055451229196288,\"paramsJson\":\"[]\",\"widgetJson\":\"{\\\"pc\\\":{\\\"filterItemWidth\\\":350,\\\"gutter\\\":20,\\\"labelWidth\\\":100,\\\"labelPosition\\\":\\\"right\\\",\\\"tableWidget\\\":{\\\"widgetType\\\":100,\\\"bindData\\\":{\\\"defaultValue\\\":{}},\\\"operationList\\\":[{\\\"id\\\":1,\\\"type\\\":10,\\\"name\\\":\\\"批量删除\\\",\\\"enabled\\\":false,\\\"builtin\\\":true,\\\"rowOperation\\\":false,\\\"btnType\\\":\\\"danger\\\",\\\"plain\\\":true,\\\"readOnly\\\":false,\\\"showOrder\\\":0,\\\"eventList\\\":[]},{\\\"id\\\":2,\\\"type\\\":0,\\\"name\\\":\\\"新建\\\",\\\"enabled\\\":false,\\\"builtin\\\":true,\\\"rowOperation\\\":false,\\\"btnType\\\":\\\"primary\\\",\\\"plain\\\":false,\\\"readOnly\\\":false,\\\"showOrder\\\":1,\\\"eventList\\\":[]},{\\\"id\\\":3,\\\"type\\\":1,\\\"name\\\":\\\"编辑\\\",\\\"enabled\\\":false,\\\"builtin\\\":true,\\\"rowOperation\\\":true,\\\"btnClass\\\":\\\"table-btn success\\\",\\\"readOnly\\\":false,\\\"showOrder\\\":10,\\\"eventList\\\":[]},{\\\"id\\\":4,\\\"type\\\":2,\\\"name\\\":\\\"删除\\\",\\\"enabled\\\":false,\\\"builtin\\\":true,\\\"rowOperation\\\":true,\\\"btnClass\\\":\\\"table-btn delete\\\",\\\"readOnly\\\":false,\\\"showOrder\\\":15,\\\"eventList\\\":[]}],\\\"showName\\\":\\\"表格组件\\\",\\\"variableName\\\":\\\"table1720147715974\\\",\\\"props\\\":{\\\"span\\\":24,\\\"height\\\":300,\\\"paddingBottom\\\":0,\\\"paged\\\":true,\\\"pageSize\\\":10,\\\"operationColumnWidth\\\":160,\\\"tableColumnList\\\":[]},\\\"eventList\\\":[],\\\"childWidgetList\\\":[],\\\"style\\\":{},\\\"supportOperation\\\":true},\\\"leftWidget\\\":{\\\"widgetType\\\":13,\\\"bindData\\\":{\\\"defaultValue\\\":{}},\\\"showName\\\":\\\"树形选择组件\\\",\\\"variableName\\\":\\\"tree1720147715974\\\",\\\"props\\\":{\\\"span\\\":24,\\\"height\\\":300,\\\"dictInfo\\\":{},\\\"required\\\":false,\\\"disabled\\\":false},\\\"eventList\\\":[],\\\"childWidgetList\\\":[],\\\"style\\\":{},\\\"supportOperation\\\":false},\\\"operationList\\\":[{\\\"id\\\":0,\\\"type\\\":3,\\\"name\\\":\\\"导出\\\",\\\"enabled\\\":false,\\\"builtin\\\":true,\\\"rowOperation\\\":false,\\\"btnType\\\":\\\"primary\\\",\\\"plain\\\":true,\\\"paramList\\\":[],\\\"eventList\\\":[],\\\"readOnly\\\":false,\\\"showOrder\\\":0},{\\\"id\\\":1,\\\"type\\\":10,\\\"name\\\":\\\"批量删除\\\",\\\"en', '{\"data\":1809056770480410624,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:48:39'); +INSERT INTO `zz_sys_operation_log` VALUES (1809057010251993088, '', 10, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineFormController', 'com.orangeforms.common.online.controller.OnlineFormController.clone', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', '32321e03b4ac418ca5d6fea8ac744a09', 453, 'POST', '/admin/online/onlineForm/clone', '{\"formId\":1809056770480410624}', '{\"data\":1809057010814029824,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:49:37'); +INSERT INTO `zz_sys_operation_log` VALUES (1809057028065202176, '', 20, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineFormController', 'com.orangeforms.common.online.controller.OnlineFormController.delete', 'Authorization:login:token-session:ae6bfe73-43ea-4a84-a6fb-528e90c339de', '45d08665cef04be4b9a20cc8b9e3505d', 302, 'POST', '/admin/online/onlineForm/delete', '{\"formId\":1809057010814029824}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1809038124504846336, 'userA', '2024-07-05 10:49:41'); +INSERT INTO `zz_sys_operation_log` VALUES (1809131899889651712, '', 0, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.LoginController', 'com.orangeforms.webadmin.upms.controller.LoginController.doLogin', NULL, '17cfa5afe5374abda116be3f69094fcf', 497, 'POST', '/admin/upms/login/doLogin', '{\"password\":\"ekih%2BFzFR03abVnW2zJLYZJ%2FEHw2EpMZKuW9698GRI6zsXrhLXX1UjKEN11L31%2BrePfnFLvp%2Bk408bZ6CLtfjhTjRR9wbOzPocmtbK063VM%2F7Crw9nAlaSEobYPwWlHuiugw8CcVPPWAAfiSz2yoedg5%2BBbBDx4SnWKKPz7K59Y%3D\",\"loginName\":\"admin\"}', NULL, '192.168.43.167', b'0', '用户名或密码错误,请重试!', NULL, NULL, NULL, '2024-07-05 15:47:12'); +INSERT INTO `zz_sys_operation_log` VALUES (1809131924610879488, '', 0, 'application-webadmin', 'com.orangeforms.webadmin.upms.controller.LoginController', 'com.orangeforms.webadmin.upms.controller.LoginController.doLogin', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'd2af8f5c698e4e6b8b610163e5908217', 547, 'POST', '/admin/upms/login/doLogin', '{\"password\":\"n1NyIK3vu4fhzT5kFQRSYQvehBUqZ2RK6VOeDT7NKd7Tj7Z78CV6Yg73TdJSKLH7PtQ1yrzCPE7QijTH3CCPqg6x%2FDE0ndlm0GPAmdcG8c1LKu4RrV%2BM37grdKeOtbCbohG4uishREJ9jovLiZI8twfRGCnzqEs3bKBjPybBdDw%3D\",\"loginName\":\"admin\"}', NULL, '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:47:18'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132075907813376, '', 20, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlinePageController', 'com.orangeforms.common.online.controller.OnlinePageController.delete', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'f9258eaefc164f9db3a6792c03dbaa82', 1429, 'POST', '/admin/online/onlinePage/delete', '{\"pageId\":1809055451229196288}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:47:54'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132176877293568, '', 10, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlinePageController', 'com.orangeforms.common.online.controller.OnlinePageController.add', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'f41bdd39fc984cf38b2cca8ccbefaaa1', 343, 'POST', '/admin/online/onlinePage/add', '{\"onlinePageDto\":{\"pageCode\":\"flowLeave\",\"pageName\":\"请假申请\",\"pageType\":10,\"status\":1}}', '{\"data\":1809132177523216384,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:48:18'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132250441191424, '', 10, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineDatasourceController', 'com.orangeforms.common.online.controller.OnlineDatasourceController.add', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '0db3da9d6b6048bab73a3fe445297ae1', 1653, 'POST', '/admin/online/onlineDatasource/add', '{\"onlineDatasourceDto\":{\"datasourceName\":\"请假申请\",\"dblinkId\":1809055300360081408,\"masterTableName\":\"zz_test_flow_leave\",\"variableName\":\"dsLeave\"},\"pageId\":1809132177523216384}', '{\"data\":1809132255981867008,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:48:35'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132300521181184, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '58819dae9e9f442fb21f5cadb3c5d326', 270, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"请假用户\",\"columnId\":1809132252425097216,\"columnName\":\"user_id\",\"columnShowOrder\":2,\"columnType\":\"bigint\",\"deptFilter\":false,\"fieldKind\":21,\"filterType\":0,\"fullColumnType\":\"bigint\",\"nullable\":false,\"numericPrecision\":19,\"objectFieldName\":\"userId\",\"objectFieldType\":\"Long\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:48:47'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132348223000576, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '4e7166af1f55482ea6189787d6a661fe', 267, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"开始时间\",\"columnId\":1809132253733720064,\"columnName\":\"leave_begin_time\",\"columnShowOrder\":5,\"columnType\":\"datetime\",\"deptFilter\":false,\"filterType\":0,\"fullColumnType\":\"datetime\",\"nullable\":false,\"objectFieldName\":\"leaveBeginTime\",\"objectFieldType\":\"Date\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:48:59'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132364907941888, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '5ea928dfa368402b9bcd8a8259c93097', 256, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"结束时间\",\"columnId\":1809132254102818816,\"columnName\":\"leave_end_time\",\"columnShowOrder\":6,\"columnType\":\"datetime\",\"deptFilter\":false,\"filterType\":0,\"fullColumnType\":\"datetime\",\"nullable\":false,\"objectFieldName\":\"leaveEndTime\",\"objectFieldType\":\"Date\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:49:03'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132399720665088, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'a0c6b421cd5f4f0aa6810db4abe0d301', 683, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"申请时间\",\"columnId\":1809132254388031488,\"columnName\":\"apply_time\",\"columnShowOrder\":7,\"columnType\":\"datetime\",\"deptFilter\":false,\"fieldKind\":20,\"filterType\":0,\"fullColumnType\":\"datetime\",\"nullable\":false,\"objectFieldName\":\"applyTime\",\"objectFieldType\":\"Date\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:49:11'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132453835575296, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '4a0b9a2c8a614820941b95772b82e6ba', 366, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"最后审批状态\",\"columnId\":1809132254782296064,\"columnName\":\"approval_status\",\"columnShowOrder\":8,\"columnType\":\"int\",\"deptFilter\":false,\"fieldKind\":26,\"filterType\":0,\"fullColumnType\":\"int\",\"nullable\":true,\"numericPrecision\":10,\"objectFieldName\":\"approvalStatus\",\"objectFieldType\":\"Integer\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:49:24'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132505723310080, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'e54070a44ae2487bb4810a3d920d7988', 1179, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"流程状态\",\"columnId\":1809132255327555584,\"columnName\":\"flow_status\",\"columnShowOrder\":9,\"columnType\":\"int\",\"deptFilter\":false,\"fieldKind\":26,\"filterType\":0,\"fullColumnType\":\"int\",\"nullable\":true,\"numericPrecision\":10,\"objectFieldName\":\"flowStatus\",\"objectFieldType\":\"Integer\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:49:36'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132536761159680, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '5f0e57d9c5df44a3907bd4878183c68a', 271, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"流程状态\",\"columnId\":1809132255327555584,\"columnName\":\"flow_status\",\"columnShowOrder\":9,\"columnType\":\"int\",\"deptFilter\":false,\"fieldKind\":25,\"filterType\":0,\"fullColumnType\":\"int\",\"nullable\":true,\"numericPrecision\":10,\"objectFieldName\":\"flowStatus\",\"objectFieldType\":\"Integer\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:49:43'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132559511064576, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '28063f6a43804db882504597d2d77353', 306, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"用户名\",\"columnId\":1809132255679877120,\"columnName\":\"username\",\"columnShowOrder\":10,\"columnType\":\"varchar\",\"deptFilter\":false,\"filterType\":0,\"fullColumnType\":\"varchar(255)\",\"nullable\":true,\"objectFieldName\":\"username\",\"objectFieldType\":\"String\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:49:49'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132570206539776, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlinePageController', 'com.orangeforms.common.online.controller.OnlinePageController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '48ce554a01704633a62a3aabbc394b2f', 210, 'POST', '/admin/online/onlinePage/update', '{\"onlinePageDto\":{\"pageCode\":\"flowLeave\",\"pageId\":1809132177523216384,\"pageName\":\"请假申请\",\"pageType\":10,\"status\":2}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:49:51'); +INSERT INTO `zz_sys_operation_log` VALUES (1809132634748489728, '', 10, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineFormController', 'com.orangeforms.common.online.controller.OnlineFormController.add', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '546500c7cc10417d91f89582652f820b', 506, 'POST', '/admin/online/onlineForm/add', '{\"onlineFormDto\":{\"datasourceIdList\":[1809132255981867008],\"formCode\":\"formFlowLeave\",\"formKind\":5,\"formName\":\"请假申请\",\"formType\":10,\"masterTableId\":1809132251556876288,\"pageId\":1809132177523216384,\"paramsJson\":\"[]\",\"widgetJson\":\"{\\\"pc\\\":{\\\"gutter\\\":20,\\\"labelWidth\\\":100,\\\"labelPosition\\\":\\\"right\\\",\\\"customFieldList\\\":[],\\\"widgetList\\\":[],\\\"formEventList\\\":[],\\\"maskFieldList\\\":[],\\\"allowEventList\\\":[\\\"formCreated\\\",\\\"afterLoadFormData\\\",\\\"beforeCommitFormData\\\"],\\\"fullscreen\\\":true,\\\"supportOperation\\\":false,\\\"width\\\":800}}\"}}', '{\"data\":1809132635633487872,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:50:07'); +INSERT INTO `zz_sys_operation_log` VALUES (1809133545088618496, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '413482d6eeac4cdcb05b7423026c3f8d', 306, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"请假类型\",\"columnId\":1809132253377204224,\"columnName\":\"leave_type\",\"columnShowOrder\":4,\"columnType\":\"int\",\"deptFilter\":false,\"filterType\":0,\"fullColumnType\":\"int\",\"nullable\":false,\"numericPrecision\":10,\"objectFieldName\":\"leaveType\",\"objectFieldType\":\"Integer\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:53:44'); +INSERT INTO `zz_sys_operation_log` VALUES (1809133558430699520, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '9dad13d8ce3d4e94b0bf01b544f0c04b', 329, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"请假原因\",\"columnId\":1809132252852916224,\"columnName\":\"leave_reason\",\"columnShowOrder\":3,\"columnType\":\"varchar\",\"deptFilter\":false,\"filterType\":0,\"fullColumnType\":\"varchar(512)\",\"nullable\":false,\"objectFieldName\":\"leaveReason\",\"objectFieldType\":\"String\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:53:47'); +INSERT INTO `zz_sys_operation_log` VALUES (1809133570850033664, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '6573018ce2c547b8ab633c45affb8094', 294, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"开始时间\",\"columnId\":1809132253733720064,\"columnName\":\"leave_begin_time\",\"columnShowOrder\":5,\"columnType\":\"datetime\",\"deptFilter\":false,\"filterType\":0,\"fullColumnType\":\"datetime\",\"nullable\":false,\"objectFieldName\":\"leaveBeginTime\",\"objectFieldType\":\"Date\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:53:50'); +INSERT INTO `zz_sys_operation_log` VALUES (1809133584934506496, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '3c4aad5641704fd991b3b9717d60f039', 386, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"结束时间\",\"columnId\":1809132254102818816,\"columnName\":\"leave_end_time\",\"columnShowOrder\":6,\"columnType\":\"datetime\",\"deptFilter\":false,\"filterType\":0,\"fullColumnType\":\"datetime\",\"nullable\":false,\"objectFieldName\":\"leaveEndTime\",\"objectFieldType\":\"Date\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:53:53'); +INSERT INTO `zz_sys_operation_log` VALUES (1809133598788292608, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '1fd06e9d5bec413a8e1437968ee99920', 327, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"申请时间\",\"columnId\":1809132254388031488,\"columnName\":\"apply_time\",\"columnShowOrder\":7,\"columnType\":\"datetime\",\"deptFilter\":false,\"fieldKind\":20,\"filterType\":0,\"fullColumnType\":\"datetime\",\"nullable\":false,\"objectFieldName\":\"applyTime\",\"objectFieldType\":\"Date\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:53:57'); +INSERT INTO `zz_sys_operation_log` VALUES (1809133609777369088, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineColumnController', 'com.orangeforms.common.online.controller.OnlineColumnController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '67104da4ba934ce9904d3c5c646b4836', 281, 'POST', '/admin/online/onlineColumn/update', '{\"onlineColumnDto\":{\"autoIncrement\":false,\"columnComment\":\"最后审批状态\",\"columnId\":1809132254782296064,\"columnName\":\"approval_status\",\"columnShowOrder\":8,\"columnType\":\"int\",\"deptFilter\":false,\"fieldKind\":26,\"filterType\":0,\"fullColumnType\":\"int\",\"nullable\":true,\"numericPrecision\":10,\"objectFieldName\":\"approvalStatus\",\"objectFieldType\":\"Integer\",\"parentKey\":false,\"primaryKey\":false,\"tableId\":1809132251556876288,\"uploadFileSystemType\":0,\"userFilter\":false}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:53:59'); +INSERT INTO `zz_sys_operation_log` VALUES (1809133618182754304, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlinePageController', 'com.orangeforms.common.online.controller.OnlinePageController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'f3aea6a5c397400eb272d364f6b1870e', 218, 'POST', '/admin/online/onlinePage/update', '{\"onlinePageDto\":{\"pageCode\":\"flowLeave\",\"pageId\":1809132177523216384,\"pageName\":\"请假申请\",\"pageType\":10,\"status\":2}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 15:54:01'); +INSERT INTO `zz_sys_operation_log` VALUES (1809143621992058880, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineFormController', 'com.orangeforms.common.online.controller.OnlineFormController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'ec8cccdd9b5c42e69b2f100bc1307a59', 636, 'POST', '/admin/online/onlineForm/update', '{\"onlineFormDto\":{\"datasourceIdList\":[1809132255981867008],\"formCode\":\"formFlowLeave\",\"formId\":1809132635633487872,\"formKind\":5,\"formName\":\"请假申请\",\"formType\":10,\"masterTableId\":1809132251556876288,\"pageId\":1809132177523216384,\"widgetJson\":\"{\\\"pc\\\":{\\\"gutter\\\":20,\\\"labelWidth\\\":100,\\\"labelPosition\\\":\\\"right\\\",\\\"operationList\\\":[],\\\"customFieldList\\\":[],\\\"widgetList\\\":[{\\\"widgetType\\\":1,\\\"bindData\\\":{\\\"defaultValue\\\":{},\\\"tableId\\\":\\\"1809132251556876288\\\",\\\"columnId\\\":\\\"1809132252852916224\\\",\\\"dataType\\\":0},\\\"showName\\\":\\\"请假原因\\\",\\\"variableName\\\":\\\"leaveReason\\\",\\\"props\\\":{\\\"span\\\":24,\\\"type\\\":\\\"text\\\",\\\"placeholder\\\":\\\"\\\",\\\"show-password\\\":false,\\\"show-word-limit\\\":false,\\\"required\\\":true,\\\"disabled\\\":false,\\\"dictInfo\\\":{\\\"paramList\\\":[]},\\\"actions\\\":{}},\\\"eventList\\\":[],\\\"childWidgetList\\\":[],\\\"style\\\":{},\\\"supportOperation\\\":false}],\\\"formEventList\\\":[],\\\"maskFieldList\\\":[],\\\"width\\\":800,\\\"fullscreen\\\":true}}\"}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:33:46'); +INSERT INTO `zz_sys_operation_log` VALUES (1809143691172909056, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineFormController', 'com.orangeforms.common.online.controller.OnlineFormController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'dc39d01f441c439fa6f3e36eaf50529b', 405, 'POST', '/admin/online/onlineForm/update', '{\"onlineFormDto\":{\"datasourceIdList\":[1809132255981867008],\"formCode\":\"formFlowLeave\",\"formId\":1809132635633487872,\"formKind\":5,\"formName\":\"请假申请\",\"formType\":10,\"masterTableId\":1809132251556876288,\"pageId\":1809132177523216384,\"widgetJson\":\"{\\\"pc\\\":{\\\"gutter\\\":20,\\\"labelWidth\\\":100,\\\"labelPosition\\\":\\\"right\\\",\\\"operationList\\\":[],\\\"customFieldList\\\":[],\\\"widgetList\\\":[{\\\"widgetType\\\":3,\\\"bindData\\\":{\\\"defaultValue\\\":{},\\\"tableId\\\":\\\"1809132251556876288\\\",\\\"columnId\\\":\\\"1809132253377204224\\\",\\\"dataType\\\":0},\\\"showName\\\":\\\"请假类型\\\",\\\"variableName\\\":\\\"leaveType\\\",\\\"props\\\":{\\\"span\\\":24,\\\"placeholder\\\":\\\"\\\",\\\"step\\\":1,\\\"controls\\\":true,\\\"required\\\":true,\\\"disabled\\\":false,\\\"dictInfo\\\":{\\\"paramList\\\":[]},\\\"actions\\\":{}},\\\"eventList\\\":[],\\\"childWidgetList\\\":[],\\\"style\\\":{},\\\"supportOperation\\\":false},{\\\"widgetType\\\":1,\\\"bindData\\\":{\\\"defaultValue\\\":{},\\\"tableId\\\":\\\"1809132251556876288\\\",\\\"columnId\\\":\\\"1809132252852916224\\\",\\\"dataType\\\":0},\\\"showName\\\":\\\"请假原因\\\",\\\"variableName\\\":\\\"leaveReason\\\",\\\"props\\\":{\\\"span\\\":24,\\\"type\\\":\\\"text\\\",\\\"placeholder\\\":\\\"\\\",\\\"show-password\\\":false,\\\"show-word-limit\\\":false,\\\"required\\\":true,\\\"disabled\\\":false,\\\"dictInfo\\\":{\\\"paramList\\\":[]},\\\"actions\\\":{}},\\\"eventList\\\":[],\\\"childWidgetList\\\":[],\\\"style\\\":{}}],\\\"formEventList\\\":[],\\\"maskFieldList\\\":[],\\\"width\\\":800,\\\"fullscreen\\\":true}}\"}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:34:03'); +INSERT INTO `zz_sys_operation_log` VALUES (1809143765026213888, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlineFormController', 'com.orangeforms.common.online.controller.OnlineFormController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '38feac5b0a75448d8557d336ddbbff53', 590, 'POST', '/admin/online/onlineForm/update', '{\"onlineFormDto\":{\"datasourceIdList\":[1809132255981867008],\"formCode\":\"formFlowLeave\",\"formId\":1809132635633487872,\"formKind\":5,\"formName\":\"请假申请\",\"formType\":10,\"masterTableId\":1809132251556876288,\"pageId\":1809132177523216384,\"widgetJson\":\"{\\\"pc\\\":{\\\"gutter\\\":20,\\\"labelWidth\\\":100,\\\"labelPosition\\\":\\\"right\\\",\\\"operationList\\\":[],\\\"customFieldList\\\":[],\\\"widgetList\\\":[{\\\"widgetType\\\":3,\\\"bindData\\\":{\\\"defaultValue\\\":{},\\\"tableId\\\":\\\"1809132251556876288\\\",\\\"columnId\\\":\\\"1809132253377204224\\\",\\\"dataType\\\":0},\\\"showName\\\":\\\"请假类型\\\",\\\"variableName\\\":\\\"leaveType\\\",\\\"props\\\":{\\\"span\\\":24,\\\"placeholder\\\":\\\"\\\",\\\"step\\\":1,\\\"controls\\\":true,\\\"required\\\":true,\\\"disabled\\\":false,\\\"dictInfo\\\":{\\\"paramList\\\":[]},\\\"actions\\\":{}},\\\"eventList\\\":[],\\\"childWidgetList\\\":[],\\\"style\\\":{}},{\\\"widgetType\\\":1,\\\"bindData\\\":{\\\"defaultValue\\\":{},\\\"tableId\\\":\\\"1809132251556876288\\\",\\\"columnId\\\":\\\"1809132252852916224\\\",\\\"dataType\\\":0},\\\"showName\\\":\\\"请假原因\\\",\\\"variableName\\\":\\\"leaveReason\\\",\\\"props\\\":{\\\"span\\\":24,\\\"type\\\":\\\"text\\\",\\\"placeholder\\\":\\\"\\\",\\\"show-password\\\":false,\\\"show-word-limit\\\":false,\\\"required\\\":true,\\\"disabled\\\":false,\\\"dictInfo\\\":{\\\"paramList\\\":[]},\\\"actions\\\":{}},\\\"eventList\\\":[],\\\"childWidgetList\\\":[],\\\"style\\\":{}},{\\\"widgetType\\\":20,\\\"bindData\\\":{\\\"defaultValue\\\":{},\\\"tableId\\\":\\\"1809132251556876288\\\",\\\"columnId\\\":\\\"1809132253733720064\\\",\\\"dataType\\\":0},\\\"showName\\\":\\\"开始时间\\\",\\\"variableName\\\":\\\"leaveBeginTime\\\",\\\"props\\\":{\\\"span\\\":12,\\\"placeholder\\\":\\\"\\\",\\\"type\\\":\\\"date\\\",\\\"required\\\":true,\\\"disabled\\\":false,\\\"dictInfo\\\":{\\\"paramList\\\":[]},\\\"actions\\\":{}},\\\"eventList\\\":[],\\\"childWidgetList\\\":[],\\\"style\\\":{},\\\"supportOperation\\\":false},{\\\"widgetType\\\":20,\\\"bindData\\\":{\\\"defaultValue\\\":{},\\\"tableId\\\":\\\"1809132251556876288\\\",\\\"columnId\\\":\\\"1809132254102818816\\\",\\\"dataType\\\":0},\\\"showName\\\":\\\"结束时间\\\",\\\"variableName\\\":\\\"leaveEndTime\\\",\\\"props\\\":{\\\"span\\\":12,\\\"placeholder\\\":\\\"\\\",\\\"type\\\":\\\"date\\\",\\\"required\\\":true,\\\"disabled\\\":false,\\\"dictInfo\\\":{\\\"paramList\\\":[]},\\\"actions\\\":{}},\\\"eve', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:34:21'); +INSERT INTO `zz_sys_operation_log` VALUES (1809143792943501312, '', 15, 'application-webadmin', 'com.orangeforms.common.online.controller.OnlinePageController', 'com.orangeforms.common.online.controller.OnlinePageController.updateStatus', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'f373e5187505453b8a73de82f3487b77', 307, 'POST', '/admin/online/onlinePage/updatePublished', '{\"published\":true,\"pageId\":1809132177523216384}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:34:27'); +INSERT INTO `zz_sys_operation_log` VALUES (1809143848773881856, '', 20, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryController', 'com.orangeforms.common.flow.controller.FlowEntryController.delete', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '9a4914d35bed44ad9363c8d9152f09ba', 374, 'POST', '/admin/flow/flowEntry/delete', '{\"entryId\":1809052045395628032}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:34:40'); +INSERT INTO `zz_sys_operation_log` VALUES (1809143990952398848, '', 10, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryController', 'com.orangeforms.common.flow.controller.FlowEntryController.add', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '280442aa890542d8b436c40e8b65c3c8', 564, 'POST', '/admin/flow/flowEntry/add', '{\"flowEntryDto\":{\"bindFormType\":0,\"categoryId\":1809051198460792832,\"defaultFormId\":1809132635633487872,\"diagramType\":0,\"encodedRule\":\"{\\\"middle\\\":\\\"DD\\\",\\\"idWidth\\\":5,\\\"prefix\\\":\\\"LL\\\",\\\"precisionTo\\\":\\\"DAYS\\\",\\\"calculateWhenView\\\":true}\",\"extensionData\":\"{\\\"approvalStatusDict\\\":[{\\\"id\\\":1,\\\"name\\\":\\\"同意\\\"},{\\\"id\\\":2,\\\"name\\\":\\\"拒绝\\\"},{\\\"id\\\":3,\\\"name\\\":\\\"驳回\\\"},{\\\"id\\\":4,\\\"name\\\":\\\"会签同意\\\"},{\\\"id\\\":5,\\\"name\\\":\\\"会签拒绝\\\"}],\\\"notifyTypes\\\":[\\\"email\\\"],\\\"cascadeDeleteBusinessData\\\":true,\\\"supportRevive\\\":false}\",\"pageId\":1809132177523216384,\"processDefinitionKey\":\"flowLeave\",\"processDefinitionName\":\"请假申请\"}}', '{\"data\":1809143991627681792,\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:35:14'); +INSERT INTO `zz_sys_operation_log` VALUES (1809144002897776640, '', 15, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryController', 'com.orangeforms.common.flow.controller.FlowEntryController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '059610f822e649e894e551173c416ac0', 249, 'POST', '/admin/flow/flowEntry/update', '{\"flowEntryDto\":{\"bindFormType\":0,\"categoryId\":1809051198460792832,\"defaultFormId\":1809132635633487872,\"diagramType\":0,\"encodedRule\":\"{\\\"middle\\\":\\\"DD\\\",\\\"idWidth\\\":5,\\\"prefix\\\":\\\"LL\\\",\\\"precisionTo\\\":\\\"DAYS\\\",\\\"calculateWhenView\\\":true}\",\"entryId\":1809143991627681792,\"extensionData\":\"{\\\"approvalStatusDict\\\":[{\\\"id\\\":1,\\\"name\\\":\\\"同意\\\",\\\"_X_ROW_KEY\\\":\\\"row_57\\\"},{\\\"id\\\":2,\\\"name\\\":\\\"拒绝\\\",\\\"_X_ROW_KEY\\\":\\\"row_58\\\"},{\\\"id\\\":3,\\\"name\\\":\\\"驳回\\\",\\\"_X_ROW_KEY\\\":\\\"row_59\\\"},{\\\"id\\\":4,\\\"name\\\":\\\"会签同意\\\",\\\"_X_ROW_KEY\\\":\\\"row_60\\\"},{\\\"id\\\":5,\\\"name\\\":\\\"会签拒绝\\\",\\\"_X_ROW_KEY\\\":\\\"row_61\\\"}],\\\"notifyTypes\\\":[\\\"email\\\"],\\\"cascadeDeleteBusinessData\\\":true,\\\"supportRevive\\\":false}\",\"pageId\":1809132177523216384,\"processDefinitionKey\":\"flowLeave\",\"processDefinitionName\":\"请假申请\"}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:35:17'); +INSERT INTO `zz_sys_operation_log` VALUES (1809144278463549440, '', 15, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryController', 'com.orangeforms.common.flow.controller.FlowEntryController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'c0aff90acd7542fc905229d237403dcc', 304, 'POST', '/admin/flow/flowEntry/update', '{\"flowEntryDto\":{\"bindFormType\":0,\"bpmnXml\":\"\\n\\n \\n \\n \\n \\n \\n \\n \\n Flow_0d86buw\\n \\n \\n \\n \\n \\n Flow_1bxwcza\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n\\n \\n \\n \\n \\n \\n \\n \\n Flow_0d86buw\\n \\n \\n \\n \\n \\n Flow_1bxwcza\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n\\n \\n \\n \\n \\n \\n \\n \\n Flow_0d86buw\\n \\n \\n \\n \\n \\n Flow_1bxwcza\\n \\n \\n \\n \\n \\n \\n \\n \\n ', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:36:35'); +INSERT INTO `zz_sys_operation_log` VALUES (1809144345769545728, '', 15, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryController', 'com.orangeforms.common.flow.controller.FlowEntryController.update', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'e16fbd18283347a6bb899a40fac80441', 238, 'POST', '/admin/flow/flowEntry/update', '{\"flowEntryDto\":{\"bindFormType\":0,\"bpmnXml\":\"\\n\\n \\n \\n \\n \\n \\n \\n \\n Flow_0d86buw\\n \\n \\n \\n \\n \\n Flow_1bxwcza\\n \\n \\n \\n \\n \\n \\n \\n \\n ', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:36:39'); +INSERT INTO `zz_sys_operation_log` VALUES (1809144417529892864, '', 65, 'application-webadmin', 'com.orangeforms.common.flow.controller.FlowEntryController', 'com.orangeforms.common.flow.controller.FlowEntryController.publish', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'b71e69dbde6b4f868601d8c9a42f0e03', 3149, 'POST', '/admin/flow/flowEntry/publish', '{\"entryId\":1809143991627681792}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:36:56'); +INSERT INTO `zz_sys_operation_log` VALUES (1809146479772700672, '', 100, 'application-webadmin', 'com.orangeforms.common.flow.online.controller.FlowOnlineOperationController', 'com.orangeforms.common.flow.online.controller.FlowOnlineOperationController.startPreview', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', '8cd4a46b301a48de878e676ce5aadd47', 3835, 'POST', '/admin/flow/flowOnlineOperation/startPreview', '{\"masterData\":{\"leave_begin_time\":\"2024-07-05 00:00:00\",\"leave_type\":1,\"leave_reason\":\"111\",\"leave_end_time\":\"2024-07-08 00:00:00\"},\"flowTaskCommentDto\":{\"approvalType\":\"agree\"},\"taskVariableData\":{},\"processDefinitionKey\":\"flowLeave\",\"copyData\":{}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:45:08'); +INSERT INTO `zz_sys_operation_log` VALUES (1809146595745206272, '', 120, 'application-webadmin', 'com.orangeforms.common.flow.online.controller.FlowOnlineOperationController', 'com.orangeforms.common.flow.online.controller.FlowOnlineOperationController.submitUserTask', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'eadd3fe01b3244a4826a245ae15c328f', 2462, 'POST', '/admin/flow/flowOnlineOperation/submitUserTask', '{\"processInstanceId\":\"e1fb2ada-3aaa-11ef-86ec-acde48001122\",\"masterData\":{\"leave_begin_time\":\"2024-07-05 00:00:00\",\"leave_type\":1,\"user_id\":\"1808020007993479168\",\"apply_time\":\"2024-07-05 16:45:08\",\"id\":\"1809146480452177920\",\"leave_reason\":\"111\",\"leave_end_time\":\"2024-07-08 00:00:00\"},\"flowTaskCommentDto\":{\"approvalType\":\"agree\",\"taskComment\":\"11\"},\"taskVariableData\":{},\"taskId\":\"e322e20d-3aaa-11ef-86ec-acde48001122\",\"copyData\":{}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:45:35'); +INSERT INTO `zz_sys_operation_log` VALUES (1809146772417679360, '', 120, 'application-webadmin', 'com.orangeforms.common.flow.online.controller.FlowOnlineOperationController', 'com.orangeforms.common.flow.online.controller.FlowOnlineOperationController.submitUserTask', 'Authorization:login:token-session:9c33d665-b097-42b9-ada3-08b9f2586c94', 'bb806b13041349cc8a12fa2d5de5a028', 2310, 'POST', '/admin/flow/flowOnlineOperation/submitUserTask', '{\"processInstanceId\":\"e1fb2ada-3aaa-11ef-86ec-acde48001122\",\"masterData\":{\"leave_begin_time\":\"2024-07-05 00:00:00\",\"leave_type\":1,\"user_id\":\"1808020007993479168\",\"apply_time\":\"2024-07-05 16:45:08\",\"id\":\"1809146480452177920\",\"leave_reason\":\"111\",\"leave_end_time\":\"2024-07-08 00:00:00\"},\"flowTaskCommentDto\":{\"approvalType\":\"agree\",\"taskComment\":\"44\"},\"taskVariableData\":{},\"taskId\":\"0669cc2a-3aab-11ef-86ec-acde48001122\",\"copyData\":{}}', '{\"errorCode\":\"NO-ERROR\",\"errorMessage\":\"NO-MESSAGE\",\"success\":true}', '192.168.43.167', b'1', NULL, NULL, 1808020007993479168, 'admin', '2024-07-05 16:46:18'); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_perm_whitelist +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_perm_whitelist`; +CREATE TABLE `zz_sys_perm_whitelist` ( + `perm_url` varchar(512) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '权限资源的url', + `module_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT '权限资源所属模块名字(通常是Controller的名字)', + `perm_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT '权限的名称', + PRIMARY KEY (`perm_url`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='权限资源白名单表(认证用户均可访问的url资源)'; + +-- ---------------------------- +-- Table structure for zz_sys_post +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_post`; +CREATE TABLE `zz_sys_post` ( + `post_id` bigint NOT NULL COMMENT '岗位Id', + `post_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '岗位名称', + `post_level` int NOT NULL COMMENT '岗位层级,数值越小级别越高', + `leader_post` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否领导岗位', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `update_user_id` bigint NOT NULL COMMENT '更新者Id', + `update_time` datetime NOT NULL COMMENT '最后更新时间', + PRIMARY KEY (`post_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- ---------------------------- +-- Records of zz_sys_post +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_post` VALUES (1809037927934595072, '领导岗位', 1, b'1', 1808020007993479168, '2024-07-05 09:33:47', 1808020007993479168, '2024-07-05 09:33:47'); +INSERT INTO `zz_sys_post` VALUES (1809037967663042560, '普通员工', 10, b'0', 1808020007993479168, '2024-07-05 09:33:56', 1808020007993479168, '2024-07-05 09:33:56'); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_role +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_role`; +CREATE TABLE `zz_sys_role` ( + `role_id` bigint NOT NULL COMMENT '主键Id', + `role_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '角色名称', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `update_user_id` bigint NOT NULL COMMENT '更新者Id', + `update_time` datetime NOT NULL COMMENT '最后更新时间', + PRIMARY KEY (`role_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=COMPACT COMMENT='系统角色表'; + +-- ---------------------------- +-- Records of zz_sys_role +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_role` VALUES (1809037772728569856, '查看全部', 1808020007993479168, '2024-07-05 09:33:10', 1808020007993479168, '2024-07-05 09:33:10'); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_role_menu +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_role_menu`; +CREATE TABLE `zz_sys_role_menu` ( + `role_id` bigint NOT NULL COMMENT '角色Id', + `menu_id` bigint NOT NULL COMMENT '菜单Id', + PRIMARY KEY (`role_id`,`menu_id`) USING BTREE, + KEY `idx_menu_id` (`menu_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=COMPACT COMMENT='角色与菜单对应关系表'; + +-- ---------------------------- +-- Records of zz_sys_role_menu +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1392786476428693504); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1392786549942259712); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1392786950682841088); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1418057714138877952); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1418057835631087616); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1418058289182150656); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1418058744037642240); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1418059005175009280); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1418059167532322816); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1418059283920064512); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1423161217970606080); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1634009076981567488); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020011080486913); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020012825317376); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020012825317377); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020012825317378); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020012825317379); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020012825317380); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020012825317381); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020012825317384); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020012825317385); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020012825317386); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148866); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148867); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148868); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148869); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148870); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148872); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148873); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148874); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148875); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148876); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148877); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148879); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148880); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148881); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148882); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148883); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148884); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148885); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148886); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148887); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148889); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148890); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148891); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148892); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148893); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148894); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148895); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148896); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148897); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148899); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148900); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148901); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148902); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148903); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148905); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148906); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148907); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075098148908); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075102343171); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075102343172); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075102343173); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075102343174); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075102343175); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075102343177); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075102343179); +INSERT INTO `zz_sys_role_menu` VALUES (1809037772728569856, 1808020075102343180); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_user +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_user`; +CREATE TABLE `zz_sys_user` ( + `user_id` bigint NOT NULL COMMENT '主键Id', + `login_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '用户登录名称', + `password` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '密码', + `show_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '用户显示名称', + `dept_id` bigint NOT NULL COMMENT '用户所在部门Id', + `head_image_url` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '用户头像的Url', + `user_type` int NOT NULL COMMENT '用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)', + `user_status` int NOT NULL COMMENT '状态(0: 正常 1: 锁定)', + `email` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '用户邮箱', + `mobile` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '用户手机', + `create_user_id` bigint NOT NULL COMMENT '创建者Id', + `create_time` datetime NOT NULL COMMENT '创建时间', + `update_user_id` bigint NOT NULL COMMENT '更新者Id', + `update_time` datetime NOT NULL COMMENT '最后更新时间', + `deleted_flag` int NOT NULL COMMENT '删除标记(1: 正常 -1: 已删除)', + PRIMARY KEY (`user_id`) USING BTREE, + UNIQUE KEY `uk_login_name` (`login_name`) USING BTREE, + KEY `idx_dept_id` (`dept_id`) USING BTREE, + KEY `idx_status` (`user_status`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=COMPACT COMMENT='系统用户表'; + +-- ---------------------------- +-- Records of zz_sys_user +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_user` VALUES (1808020007993479168, 'admin', '$2a$10$C1/DwnlXP3s.HOFsmL60Resq0juaRt6/WK8JCzcNbgbpueUMs71Um', '管理员', 1808020008341606402, NULL, 0, 0, NULL, NULL, 1808020007993479168, '2024-07-03 00:00:00', 1808020007993479168, '2024-07-03 00:00:00', 1); +INSERT INTO `zz_sys_user` VALUES (1809038124504846336, 'userA', '$2a$10$perpVEYWNTE0.oP0C7L5beiv1EYs3XEn0qkgOKwB8Rm7p/BDGYLEa', '员工A', 1808020008341606402, NULL, 2, 0, NULL, NULL, 1808020007993479168, '2024-07-05 09:34:34', 1809038124504846336, '2024-07-05 10:23:44', 1); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_user_post +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_user_post`; +CREATE TABLE `zz_sys_user_post` ( + `user_id` bigint NOT NULL COMMENT '用户Id', + `dept_post_id` bigint NOT NULL COMMENT '部门岗位Id', + `post_id` bigint NOT NULL COMMENT '岗位Id', + PRIMARY KEY (`user_id`,`dept_post_id`) USING BTREE, + KEY `idx_post_id` (`post_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- ---------------------------- +-- Records of zz_sys_user_post +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_user_post` VALUES (1809038124504846336, 1809038003968937984, 1809037967663042560); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_sys_user_role +-- ---------------------------- +DROP TABLE IF EXISTS `zz_sys_user_role`; +CREATE TABLE `zz_sys_user_role` ( + `user_id` bigint NOT NULL COMMENT '用户Id', + `role_id` bigint NOT NULL COMMENT '角色Id', + PRIMARY KEY (`user_id`,`role_id`) USING BTREE, + KEY `idx_role_id` (`role_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=COMPACT COMMENT='用户与角色对应关系表'; + +-- ---------------------------- +-- Records of zz_sys_user_role +-- ---------------------------- +BEGIN; +INSERT INTO `zz_sys_user_role` VALUES (1809038124504846336, 1809037772728569856); +COMMIT; + +-- ---------------------------- +-- Table structure for zz_test_flow_leave +-- ---------------------------- +DROP TABLE IF EXISTS `zz_test_flow_leave`; +CREATE TABLE `zz_test_flow_leave` ( + `id` bigint NOT NULL COMMENT '主键Id', + `user_id` bigint NOT NULL COMMENT '请假用户Id', + `leave_reason` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '请假原因', + `leave_type` int NOT NULL COMMENT '请假类型', + `leave_begin_time` datetime NOT NULL COMMENT '请假开始时间', + `leave_end_time` datetime NOT NULL COMMENT '请假结束时间', + `apply_time` datetime NOT NULL COMMENT '申请时间', + `approval_status` int DEFAULT NULL COMMENT '最后审批状态', + `flow_status` int DEFAULT NULL COMMENT '流程状态', + `username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '用户名', + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_user_id` (`user_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- ---------------------------- +-- Records of zz_test_flow_leave +-- ---------------------------- +BEGIN; +INSERT INTO `zz_test_flow_leave` VALUES (1734132261424467969, 1440911410581213417, '测试', 1, '2023-12-11 00:00:00', '2024-01-02 00:00:00', '2023-12-11 16:45:24', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1734132937084899329, 1440911410581213417, '测试', 1, '2023-12-11 00:00:00', '2024-01-10 00:00:00', '2023-12-11 16:48:05', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1734760286021226497, 1440911410581213417, '22', 2, '2023-12-12 00:00:00', '2023-12-14 00:00:00', '2023-12-13 10:20:57', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1735571074717847553, 1440911410581213417, '123', 1, '2023-12-07 00:00:00', '2023-12-08 00:00:00', '2023-12-15 16:02:44', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1735644235845079041, 1440911410581213417, '111', 1, '2023-12-14 00:00:00', '2023-12-16 00:00:00', '2023-12-15 20:53:27', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1735959007710941185, 1440911410581213417, '123123', 2, '2023-12-16 00:00:00', '2023-12-22 00:00:00', '2023-12-16 17:44:15', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1736002626216005633, 1440911410581213417, '213213', 1, '2023-12-15 00:00:00', '2024-01-18 00:00:00', '2023-12-16 20:37:34', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1736249711238582272, 1440911410581213417, 'qqq', 2, '2023-12-15 00:00:00', '2024-01-17 00:00:00', '2023-12-17 12:59:24', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1736653319645958144, 1440911410581213417, '呃呃呃', 1, '2023-12-18 00:00:00', '2023-12-20 00:00:00', '2023-12-18 15:43:12', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1736916738529824769, 1440911410581213417, '请假', 2, '2023-12-21 00:00:00', '2023-12-23 00:00:00', '2023-12-19 09:09:55', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737101008917499905, 1440911410581213417, 'fff', 3, '2023-12-19 00:00:00', '2023-12-20 00:00:00', '2023-12-19 21:22:09', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737314824108380161, 1440911410581213417, '有事', 1, '2023-12-01 00:00:00', '2023-12-09 00:00:00', '2023-12-20 11:31:46', NULL, 3, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737358381695373313, 1440911410581213417, '123', 2, '2023-12-13 00:00:00', '2024-01-19 00:00:00', '2023-12-20 14:24:51', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737615175483133953, 1440911410581213417, '尴尬', 1, '2023-12-21 00:00:00', '2023-12-22 00:00:00', '2023-12-21 07:25:16', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737641283461058561, 1440911410581213417, '测试', 1, '2023-12-21 00:00:00', '2023-12-28 00:00:00', '2023-12-21 09:09:00', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737646632062685184, 1440911410581213417, '风复古', 1, '2023-12-22 00:00:00', '2023-12-22 00:00:00', '2023-12-21 09:30:16', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737661659834486784, 1440911410581213417, '想咋就咋', 3, '2023-12-22 00:00:00', '2023-12-22 00:00:00', '2023-12-21 10:29:59', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737662716845232128, 1440911410581213417, '黑胡椒', 1, '2023-12-18 00:00:00', '2023-12-22 00:00:00', '2023-12-21 10:34:11', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737666820992667648, 1440911410581213417, '111', 1, '2023-12-22 00:00:00', '2023-12-20 00:00:00', '2023-12-21 10:50:29', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737666823148539905, 1440911410581213417, '111', 1, '2023-12-22 00:00:00', '2023-12-20 00:00:00', '2023-12-21 10:50:30', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737666824016760833, 1440911410581213417, '111', 1, '2023-12-22 00:00:00', '2023-12-20 00:00:00', '2023-12-21 10:50:30', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737666824809484289, 1440911410581213417, '111', 1, '2023-12-22 00:00:00', '2023-12-20 00:00:00', '2023-12-21 10:50:30', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1737747164756447233, 1440911410581213417, 'c', 1, '2023-12-23 00:00:00', '2024-01-13 00:00:00', '2023-12-21 16:09:45', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1738557159815254017, 1440911410581213417, '测试新增', 2, '2023-12-22 00:00:00', '2024-01-12 00:00:00', '2023-12-23 21:48:22', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1738586314833399809, 1440911410581213417, '轻机枪', 1, '2023-12-22 00:00:00', '2023-12-29 00:00:00', '2023-12-23 23:44:13', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1738590302731505665, 1440911410581213417, '测试', 2, '2023-12-23 00:00:00', '2024-01-04 00:00:00', '2023-12-24 00:00:04', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1738593079201370113, 1440911410581213417, '测试', 1, '2024-01-04 00:00:00', '2024-01-11 00:00:00', '2023-12-24 00:11:06', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1738597715752783872, 1440911410581213417, '消息 抄送发', 1, '2023-12-13 00:00:00', '2024-01-25 00:00:00', '2023-12-24 00:29:32', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1738598397780168705, 1440911410581213417, ' 额', 1, '2023-12-13 00:00:00', '2023-12-13 00:00:00', '2023-12-24 00:32:14', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1738614127170949120, 1440911410581213417, '超市那个', 1, '2023-12-13 00:00:00', '2023-12-24 00:00:00', '2023-12-24 01:34:44', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1739529776575549440, 1440911410581213417, '33232', 1, '2023-12-07 00:00:00', '2024-01-16 00:00:00', '2023-12-26 14:13:12', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1739534951415549952, 1440911410581213417, '111', 1, '2024-01-25 00:00:00', '2024-01-27 00:00:00', '2023-12-26 14:33:46', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1739860694376910849, 1440911410581213417, '111', 1, '2023-12-27 00:00:00', '2023-12-28 00:00:00', '2023-12-27 12:08:09', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1740031035300646913, 1440911410581213417, '测试抄送', 1, '2024-01-03 00:00:00', '2024-01-11 00:00:00', '2023-12-27 23:25:02', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1741067028283789313, 1440911410581213417, '测试抄送', 1, '2023-12-29 00:00:00', '2024-02-08 00:00:00', '2023-12-30 20:01:42', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1741068565080969217, 1440911410581213417, '亲近抄送', 1, '2024-02-08 00:00:00', '2024-01-19 00:00:00', '2023-12-30 20:07:48', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1741075078512119809, 1440911410581213417, '测试抄送', 1, '2023-12-30 00:00:00', '2024-01-26 00:00:00', '2023-12-30 20:33:41', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1741077243179831297, 1440911410581213417, '测试抄送', 1, '2023-12-30 00:00:00', '2024-01-12 00:00:00', '2023-12-30 20:42:17', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1741082898645127169, 1440911410581213417, '11111', 1, '2023-12-13 00:00:00', '2023-12-29 00:00:00', '2023-12-30 21:04:45', NULL, 3, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1742075427653947392, 1440911410581213417, '6666', 1, '2024-01-02 00:00:00', '2024-01-27 00:00:00', '2024-01-02 14:48:43', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1743138899498110977, 1440911410581213417, '2222', 1, '2024-01-10 00:00:00', '2024-01-10 00:00:00', '2024-01-05 13:14:34', NULL, 3, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1743236528957558784, 1440911410581213417, 'dsfsadffsdf', 1, '2024-01-09 00:00:00', '2024-01-31 00:00:00', '2024-01-05 19:42:31', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1743236847603027968, 1440911410581213417, 'sdfaff', 1, '2024-01-11 00:00:00', '2024-02-06 00:00:00', '2024-01-05 19:43:47', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1743236894344351745, 1440911410581213417, 'dsfsdfasdf', 1, '2024-01-11 00:00:00', '2024-02-14 00:00:00', '2024-01-05 19:43:58', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1743236965743988737, 1440911410581213417, 'zxczxc', 1, '2024-01-20 00:00:00', '2024-02-12 00:00:00', '2024-01-05 19:44:15', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1743529562567872512, 1440911410581213417, '休息', 1, '2024-01-12 00:00:00', '2024-01-13 00:00:00', '2024-01-06 15:06:56', NULL, 3, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1743570048200478721, 1440911410581213417, '是一款..是,', 1, '2024-01-07 00:00:00', '2024-01-31 00:00:00', '2024-01-06 17:47:48', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1743847321545740288, 1440911410581213417, '测试请假', 3, '2024-01-08 00:00:00', '2024-01-24 00:00:00', '2024-01-07 12:09:35', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1743848671104995328, 1440911410581213417, '请假新增测试', 1, '2024-01-15 00:00:00', '2024-01-16 00:00:00', '2024-01-07 12:14:57', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1743894439526404097, 1440911410581213417, '测试', 2, '2024-01-07 00:00:00', '2024-01-24 00:00:00', '2024-01-07 15:16:49', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1745342183466078208, 1440911410581213417, 'asdfasdf', 1, '2024-01-02 00:00:00', '2024-02-02 00:00:00', '2024-01-11 15:09:38', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1745343819995418625, 1440911410581213417, 'adfasd', 1, '2024-01-06 00:00:00', '2024-02-06 00:00:00', '2024-01-11 15:16:08', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1745639100335001600, 1440911410581213417, '1234', 1, '2024-01-12 00:00:00', '2024-01-19 00:00:00', '2024-01-12 10:49:29', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1745641568804540417, 1440911410581213417, '123', 1, '2024-01-12 00:00:00', '2024-01-19 00:00:00', '2024-01-12 10:59:17', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1746710995184652289, 1440911410581213417, '11111111111111', 3, '2024-01-16 00:00:00', '2024-01-25 00:00:00', '2024-01-15 09:48:48', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1746821158071701504, 1440911410581213417, 'sfasdf', 1, '2024-02-14 00:00:00', '2024-02-16 00:00:00', '2024-01-15 17:06:33', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1747175673463574529, 1440911410581213417, '1111', 1, '2024-01-16 00:00:00', '2024-01-17 00:00:00', '2024-01-16 16:35:16', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1784199563469393920, 1779777400603676672, '111', 1, '2024-04-01 00:00:00', '2024-04-04 00:00:00', '2024-04-27 20:34:59', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1784202480981118976, 1779777400603676672, '请假', 1, '2024-04-22 00:00:00', '2024-04-24 00:00:00', '2024-04-27 20:46:35', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1784211196795162625, 1779777400603676672, '请假三天', 1, '2024-04-02 00:00:00', '2024-04-05 00:00:00', '2024-04-27 21:21:13', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1784221100561928192, 1779777400603676672, '请假出去玩', 1, '2024-04-08 00:00:00', '2024-04-15 00:00:00', '2024-04-27 22:00:34', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1784556947194777601, 1779777400603676672, '111', 1, '2024-04-03 00:00:00', '2024-04-11 00:00:00', '2024-04-28 20:15:06', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1785508179405180928, 1779777400603676672, '11', 1, '2024-05-08 00:00:00', '2024-05-10 00:00:00', '2024-05-01 11:14:58', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1787771104035606528, 1779777400603676672, '111', 1, '2024-05-07 00:00:00', '2024-05-08 00:00:00', '2024-05-07 17:07:01', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1787771998559014913, 1779777400603676672, '2222', 1, '2024-05-07 00:00:00', '2024-05-15 00:00:00', '2024-05-07 17:10:34', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1787817506019217408, 1779777400603676672, '111', 1, '2024-05-08 00:00:00', '2024-05-16 00:00:00', '2024-05-07 20:11:24', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1787852380893614081, 1779777400603676672, '1111', 1, '2024-05-14 00:00:00', '2024-05-08 00:00:00', '2024-05-07 22:29:59', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1787853112791273472, 1779777400603676672, '1111', 1, '2024-05-08 00:00:00', '2024-05-16 00:00:00', '2024-05-07 22:32:53', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1788107566534889472, 1779777400603676672, '111', 1, '2024-05-08 00:00:00', '2024-05-09 00:00:00', '2024-05-08 15:24:00', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1788112135096635392, 1779777400603676672, '111', 1, '2024-05-08 00:00:00', '2024-05-09 00:00:00', '2024-05-08 15:42:09', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1788112525678612480, 1779777400603676672, '1111', 2, '2024-05-09 00:00:00', '2024-05-10 00:00:00', '2024-05-08 15:43:42', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1788741582820741120, 1779777400603676672, '秀', 2, '2024-05-07 00:00:00', '2024-05-08 00:00:00', '2024-05-10 09:23:21', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1791767263255203841, 1779777400603676672, '1111', 1, '2024-05-20 00:00:00', '2024-05-21 00:00:00', '2024-05-18 17:46:20', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1792492440158998528, 1779777400603676672, '111222', 2, '2024-05-07 00:00:00', '2024-05-22 00:00:00', '2024-05-20 17:47:55', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1792829634757267456, 1779777400603676672, '1111', 2, '2024-05-14 00:00:00', '2024-05-15 00:00:00', '2024-05-21 16:07:49', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1793489840575090688, 1779777400603676672, '1111', 1, '2024-05-16 00:00:00', '2024-05-24 00:00:00', '2024-05-23 11:51:14', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1795696352311644160, 1779777400603676672, 'dd', 1, '2024-05-02 00:00:00', '2024-05-10 00:00:00', '2024-05-29 13:59:07', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1795992839696420865, 1779777400603676672, 'admin', 1, '2024-05-02 00:00:00', '2024-05-18 00:00:00', '2024-05-30 09:37:16', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1795994391077195776, 1779777400603676672, '1111222', 1, '2024-05-15 00:00:00', '2024-05-16 00:00:00', '2024-05-30 09:43:25', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796109769098924033, 1779777400603676672, '1111', 1, '2024-05-08 00:00:00', '2024-05-10 00:00:00', '2024-05-30 17:21:54', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796110123517612032, 1779777400603676672, '1111222', 1, '2024-05-16 00:00:00', '2024-05-18 00:00:00', '2024-05-30 17:23:18', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796164077765005312, 1779777400603676672, 'admin', 1, '2024-05-10 00:00:00', '2024-06-05 00:00:00', '2024-05-30 20:57:42', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796164941607079936, 1779777400603676672, 'admin', 1, '2024-05-17 00:00:00', '2024-06-12 00:00:00', '2024-05-30 21:01:08', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796173926594777088, 1779777400603676672, 'dd', 1, '2024-05-10 00:00:00', '2024-05-09 00:00:00', '2024-05-30 21:36:50', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796178444468359168, 1779777400603676672, 'x', 1, '2024-05-14 00:00:00', '2024-05-15 00:00:00', '2024-05-30 21:54:47', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796181839363182593, 1779777400603676672, '111', 1, '2024-05-16 00:00:00', '2024-06-18 00:00:00', '2024-05-30 22:08:17', NULL, 4, 'admin'); +INSERT INTO `zz_test_flow_leave` VALUES (1796182559164469249, 1779777400603676672, '4444', 1, '2024-05-08 00:00:00', '2024-05-10 00:00:00', '2024-05-30 22:11:08', NULL, 4, 'admin'); +INSERT INTO `zz_test_flow_leave` VALUES (1796183035536740352, 1779777400603676672, 'dd', 1, '2024-05-18 00:00:00', '2024-05-11 00:00:00', '2024-05-30 22:13:02', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796183248754184192, 1779777400603676672, '11', 1, '2024-05-07 00:00:00', '2024-05-08 00:00:00', '2024-05-30 22:13:53', NULL, 5, 'userTJ2'); +INSERT INTO `zz_test_flow_leave` VALUES (1796185777676226560, 1779777400603676672, 'd', 1, '2024-05-09 00:00:00', '2024-05-09 00:00:00', '2024-05-30 22:23:56', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796187020805017600, 1779777400603676672, 'd', 1, '2024-05-03 00:00:00', '2024-05-03 00:00:00', '2024-05-30 22:28:52', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796188059113361408, 1779777400603676672, 'd', 1, '2024-05-17 00:00:00', '2024-05-17 00:00:00', '2024-05-30 22:33:00', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796188876033757184, 1779777400603676672, 'dd', 1, '2024-05-02 00:00:00', '2024-05-02 00:00:00', '2024-05-30 22:36:14', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796189604152348672, 1779777400603676672, 'dd', 1, '2024-05-03 00:00:00', '2024-05-03 00:00:00', '2024-05-30 22:39:08', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796190467956674560, 1779777400603676672, 'dd', 1, '2024-05-10 00:00:00', '2024-05-16 00:00:00', '2024-05-30 22:42:34', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796191454335340544, 1779777400603676672, 'jk', 1, '2024-05-10 00:00:00', '2024-05-02 00:00:00', '2024-05-30 22:46:29', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796192461547114496, 1779777400603676672, 'd', 1, '2024-05-02 00:00:00', '2024-05-09 00:00:00', '2024-05-30 22:50:29', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796195394187694080, 1779777400603676672, 'dd', 1, '2024-05-03 00:00:00', '2024-05-10 00:00:00', '2024-05-30 23:02:08', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796197180806008832, 1779777400603676672, 'ddd', 1, '2024-05-10 00:00:00', '2024-05-10 00:00:00', '2024-05-30 23:09:14', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796201309611757568, 1779777400603676672, 'dd', 1, '2024-05-17 00:00:00', '2024-05-17 00:00:00', '2024-05-30 23:25:39', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796202010052136960, 1779777400603676672, 'dd', 1, '2024-05-03 00:00:00', '2024-05-03 00:00:00', '2024-05-30 23:28:26', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796204072726958080, 1779777400603676672, 'd', 1, '2024-05-10 00:00:00', '2024-05-10 00:00:00', '2024-05-30 23:36:37', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796354567839944704, 1779777400603676672, 'admin', 1, '2024-05-17 00:00:00', '2024-06-13 00:00:00', '2024-05-31 09:34:38', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796361013583417344, 1779777400603676672, 'admin', 1, '2024-05-11 00:00:00', '2024-06-10 00:00:00', '2024-05-31 10:00:15', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1796442194475749377, 1779777400603676672, 'd', 1, '2024-05-10 00:00:00', '2024-06-06 00:00:00', '2024-05-31 15:22:50', NULL, 4, 'admin'); +INSERT INTO `zz_test_flow_leave` VALUES (1796453212681670656, 1779777400603676672, 'admin', 1, '2024-05-18 00:00:00', '2024-06-10 00:00:00', '2024-05-31 16:06:37', NULL, 4, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1797540170921152512, 1779777400603676672, '111', 1, '2024-06-04 00:00:00', '2024-06-06 00:00:00', '2024-06-03 16:05:48', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1799012020255723520, 1779777400603676672, '1111', 1, '2024-06-12 00:00:00', '2024-06-14 00:00:00', '2024-06-07 17:34:24', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1800522684333821952, 1779777400603676672, '111', 1, '2024-06-12 00:00:00', '2024-06-12 00:00:00', '2024-06-11 21:37:15', NULL, 5, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1800529322327412736, 1799417106157015040, '1111', 1, '2024-06-13 00:00:00', '2024-06-19 00:00:00', '2024-06-11 22:03:37', NULL, NULL, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1807764854329577473, 1779777400603676672, '111', 1, '2024-07-02 00:00:00', '2024-07-11 00:00:00', '2024-07-01 21:15:03', 11, 1, NULL); +INSERT INTO `zz_test_flow_leave` VALUES (1809146480452177920, 1808020007993479168, '111', 1, '2024-07-05 00:00:00', '2024-07-08 00:00:00', '2024-07-05 16:45:08', NULL, NULL, NULL); +COMMIT; + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/OrangeFormsOpen-MybatisPlus/zz-resource/docker-files/.DS_Store b/OrangeFormsOpen-MybatisPlus/zz-resource/docker-files/.DS_Store new file mode 100644 index 00000000..09c3fef0 Binary files /dev/null and b/OrangeFormsOpen-MybatisPlus/zz-resource/docker-files/.DS_Store differ diff --git a/OrangeFormsOpen-MybatisPlus/zz-resource/docker-files/docker-compose.yml b/OrangeFormsOpen-MybatisPlus/zz-resource/docker-files/docker-compose.yml new file mode 100644 index 00000000..3a47c75d --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/zz-resource/docker-files/docker-compose.yml @@ -0,0 +1,33 @@ +version: '3.2' + +services: + + redis: + container_name: redis + build: + context: services/redis/ + args: + - REDIS_VER=4 + ports: + - "6379:6379" + volumes: + - ./services/redis/redis.conf:/usr/local/etc/redis/redis.conf:rw + - ./data/redis:/data:rw + - ./logs/redis:/var/log/:rw + +# minio1: +# image: minio/minio:latest +# environment: +# # spring boot服务中的配置项需要与该值相同。 +# # nginx访问页面的登录名和密码。密码不能少于8个字符。 +# - MINIO_ACCESS_KEY=admin +# - MINIO_SECRET_KEY=admin123456 +# volumes: +# - ./data/minio:/data +# - ./services/minio/config:/root/.minio +# ports: +# # 这个是给Java的minio客户端使用的端口。 +# - "19000:9000" +# # 对主机控制台暴露19001接口,nginx需要将请求导入该端口号。 +# - "19001:9001" +# command: server /data --console-address ":9001" diff --git a/OrangeFormsOpen-MybatisPlus/zz-resource/docker-files/services/redis/Dockerfile b/OrangeFormsOpen-MybatisPlus/zz-resource/docker-files/services/redis/Dockerfile new file mode 100644 index 00000000..924bd9d6 --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/zz-resource/docker-files/services/redis/Dockerfile @@ -0,0 +1,13 @@ +ARG REDIS_VER + +FROM redis:${REDIS_VER} + +COPY redis.conf /usr/local/etc/redis/redis.conf +CMD ["redis-server", "/usr/local/etc/redis/redis.conf"] + +# 设置时区为上海 +ENV TZ=Asia/Shanghai +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +# Ubuntu软件源选择中国的服务器 +RUN sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list \ No newline at end of file diff --git a/OrangeFormsOpen-MybatisPlus/zz-resource/docker-files/services/redis/redis.conf b/OrangeFormsOpen-MybatisPlus/zz-resource/docker-files/services/redis/redis.conf new file mode 100644 index 00000000..2eecfa5a --- /dev/null +++ b/OrangeFormsOpen-MybatisPlus/zz-resource/docker-files/services/redis/redis.conf @@ -0,0 +1,1307 @@ +# Redis configuration file example. +# +# Note that in order to read the configuration file, Redis must be +# started with the file path as first argument: +# +# ./redis-server /path/to/redis.conf + +# Note on units: when memory size is needed, it is possible to specify +# it in the usual form of 1k 5GB 4M and so forth: +# +# 1k => 1000 bytes +# 1kb => 1024 bytes +# 1m => 1000000 bytes +# 1mb => 1024*1024 bytes +# 1g => 1000000000 bytes +# 1gb => 1024*1024*1024 bytes +# +# units are case insensitive so 1GB 1Gb 1gB are all the same. + +################################## INCLUDES ################################### + +# Include one or more other config files here. This is useful if you +# have a standard template that goes to all Redis servers but also need +# to customize a few per-server settings. Include files can include +# other files, so use this wisely. +# +# Notice option "include" won't be rewritten by command "CONFIG REWRITE" +# from admin or Redis Sentinel. Since Redis always uses the last processed +# line as value of a configuration directive, you'd better put includes +# at the beginning of this file to avoid overwriting config change at runtime. +# +# If instead you are interested in using includes to override configuration +# options, it is better to use include as the last line. +# +# include /path/to/local.conf +# include /path/to/other.conf + +################################## MODULES ##################################### + +# Load modules at startup. If the server is not able to load modules +# it will abort. It is possible to use multiple loadmodule directives. +# +# loadmodule /path/to/my_module.so +# loadmodule /path/to/other_module.so + +################################## NETWORK ##################################### + +# By default, if no "bind" configuration directive is specified, Redis listens +# for connections from all the network interfaces available on the server. +# It is possible to listen to just one or multiple selected interfaces using +# the "bind" configuration directive, followed by one or more IP addresses. +# +# Examples: +# +# bind 192.168.1.100 10.0.0.1 +# bind 127.0.0.1 ::1 +# +# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the +# internet, binding to all the interfaces is dangerous and will expose the +# instance to everybody on the internet. So by default we uncomment the +# following bind directive, that will force Redis to listen only into +# the IPv4 lookback interface address (this means Redis will be able to +# accept connections only from clients running into the same computer it +# is running). +# +# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES +# JUST COMMENT THE FOLLOWING LINE. +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +bind 0.0.0.0 + +# Protected mode is a layer of security protection, in order to avoid that +# Redis instances left open on the internet are accessed and exploited. +# +# When protected mode is on and if: +# +# 1) The server is not binding explicitly to a set of addresses using the +# "bind" directive. +# 2) No password is configured. +# +# The server only accepts connections from clients connecting from the +# IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain +# sockets. +# +# By default protected mode is enabled. You should disable it only if +# you are sure you want clients from other hosts to connect to Redis +# even if no authentication is configured, nor a specific set of interfaces +# are explicitly listed using the "bind" directive. +protected-mode yes + +# Accept connections on the specified port, default is 6379 (IANA #815344). +# If port 0 is specified Redis will not listen on a TCP socket. +port 6379 + +# TCP listen() backlog. +# +# In high requests-per-second environments you need an high backlog in order +# to avoid slow clients connections issues. Note that the Linux kernel +# will silently truncate it to the value of /proc/sys/net/core/somaxconn so +# make sure to raise both the value of somaxconn and tcp_max_syn_backlog +# in order to get the desired effect. +tcp-backlog 511 + +# Unix socket. +# +# Specify the path for the Unix socket that will be used to listen for +# incoming connections. There is no default, so Redis will not listen +# on a unix socket when not specified. +# +# unixsocket /tmp/redis.sock +# unixsocketperm 700 + +# Close the connection after a client is idle for N seconds (0 to disable) +timeout 0 + +# TCP keepalive. +# +# If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence +# of communication. This is useful for two reasons: +# +# 1) Detect dead peers. +# 2) Take the connection alive from the point of view of network +# equipment in the middle. +# +# On Linux, the specified value (in seconds) is the period used to send ACKs. +# Note that to close the connection the double of the time is needed. +# On other kernels the period depends on the kernel configuration. +# +# A reasonable value for this option is 300 seconds, which is the new +# Redis default starting with Redis 3.2.1. +tcp-keepalive 300 + +################################# GENERAL ##################################### + +# By default Redis does not run as a daemon. Use 'yes' if you need it. +# Note that Redis will write a pid file in /var/run/redis.pid when daemonized. +daemonize no + +# If you run Redis from upstart or systemd, Redis can interact with your +# supervision tree. Options: +# supervised no - no supervision interaction +# supervised upstart - signal upstart by putting Redis into SIGSTOP mode +# supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET +# supervised auto - detect upstart or systemd method based on +# UPSTART_JOB or NOTIFY_SOCKET environment variables +# Note: these supervision methods only signal "process is ready." +# They do not enable continuous liveness pings back to your supervisor. +supervised no + +# If a pid file is specified, Redis writes it where specified at startup +# and removes it at exit. +# +# When the server runs non daemonized, no pid file is created if none is +# specified in the configuration. When the server is daemonized, the pid file +# is used even if not specified, defaulting to "/var/run/redis.pid". +# +# Creating a pid file is best effort: if Redis is not able to create it +# nothing bad happens, the server will start and run normally. +pidfile /var/run/redis_6379.pid + +# Specify the server verbosity level. +# This can be one of: +# debug (a lot of information, useful for development/testing) +# verbose (many rarely useful info, but not a mess like the debug level) +# notice (moderately verbose, what you want in production probably) +# warning (only very important / critical messages are logged) +loglevel notice + +# Specify the log file name. Also the empty string can be used to force +# Redis to log on the standard output. Note that if you use standard +# output for logging but daemonize, logs will be sent to /dev/null +logfile /var/log/redis_6379.log + +# To enable logging to the system logger, just set 'syslog-enabled' to yes, +# and optionally update the other syslog parameters to suit your needs. +# syslog-enabled no + +# Specify the syslog identity. +# syslog-ident redis + +# Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7. +# syslog-facility local0 + +# Set the number of databases. The default database is DB 0, you can select +# a different one on a per-connection basis using SELECT where +# dbid is a number between 0 and 'databases'-1 +databases 16 + +# By default Redis shows an ASCII art logo only when started to log to the +# standard output and if the standard output is a TTY. Basically this means +# that normally a logo is displayed only in interactive sessions. +# +# However it is possible to force the pre-4.0 behavior and always show a +# ASCII art logo in startup logs by setting the following option to yes. +always-show-logo yes + +################################ SNAPSHOTTING ################################ +# +# Save the DB on disk: +# +# save +# +# Will save the DB if both the given number of seconds and the given +# number of write operations against the DB occurred. +# +# In the example below the behaviour will be to save: +# after 900 sec (15 min) if at least 1 key changed +# after 300 sec (5 min) if at least 10 keys changed +# after 60 sec if at least 10000 keys changed +# +# Note: you can disable saving completely by commenting out all "save" lines. +# +# It is also possible to remove all the previously configured save +# points by adding a save directive with a single empty string argument +# like in the following example: +# +# save "" + +save 900 1 +save 300 10 +save 60 10000 + +# By default Redis will stop accepting writes if RDB snapshots are enabled +# (at least one save point) and the latest background save failed. +# This will make the user aware (in a hard way) that data is not persisting +# on disk properly, otherwise chances are that no one will notice and some +# disaster will happen. +# +# If the background saving process will start working again Redis will +# automatically allow writes again. +# +# However if you have setup your proper monitoring of the Redis server +# and persistence, you may want to disable this feature so that Redis will +# continue to work as usual even if there are problems with disk, +# permissions, and so forth. +stop-writes-on-bgsave-error yes + +# Compress string objects using LZF when dump .rdb databases? +# For default that's set to 'yes' as it's almost always a win. +# If you want to save some CPU in the saving child set it to 'no' but +# the dataset will likely be bigger if you have compressible values or keys. +rdbcompression yes + +# Since version 5 of RDB a CRC64 checksum is placed at the end of the file. +# This makes the format more resistant to corruption but there is a performance +# hit to pay (around 10%) when saving and loading RDB files, so you can disable it +# for maximum performances. +# +# RDB files created with checksum disabled have a checksum of zero that will +# tell the loading code to skip the check. +rdbchecksum yes + +# The filename where to dump the DB +dbfilename dump.rdb + +# The working directory. +# +# The DB will be written inside this directory, with the filename specified +# above using the 'dbfilename' configuration directive. +# +# The Append Only File will also be created inside this directory. +# +# Note that you must specify a directory here, not a file name. +dir ./ + +################################# REPLICATION ################################# + +# Master-Slave replication. Use slaveof to make a Redis instance a copy of +# another Redis server. A few things to understand ASAP about Redis replication. +# +# 1) Redis replication is asynchronous, but you can configure a master to +# stop accepting writes if it appears to be not connected with at least +# a given number of slaves. +# 2) Redis slaves are able to perform a partial resynchronization with the +# master if the replication link is lost for a relatively small amount of +# time. You may want to configure the replication backlog size (see the next +# sections of this file) with a sensible value depending on your needs. +# 3) Replication is automatic and does not need user intervention. After a +# network partition slaves automatically try to reconnect to masters +# and resynchronize with them. +# +# slaveof + +# If the master is password protected (using the "requirepass" configuration +# directive below) it is possible to tell the slave to authenticate before +# starting the replication synchronization process, otherwise the master will +# refuse the slave request. +# +# masterauth + +# When a slave loses its connection with the master, or when the replication +# is still in progress, the slave can act in two different ways: +# +# 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will +# still reply to client requests, possibly with out of date data, or the +# data set may just be empty if this is the first synchronization. +# +# 2) if slave-serve-stale-data is set to 'no' the slave will reply with +# an error "SYNC with master in progress" to all the kind of commands +# but to INFO and SLAVEOF. +# +slave-serve-stale-data yes + +# You can configure a slave instance to accept writes or not. Writing against +# a slave instance may be useful to store some ephemeral data (because data +# written on a slave will be easily deleted after resync with the master) but +# may also cause problems if clients are writing to it because of a +# misconfiguration. +# +# Since Redis 2.6 by default slaves are read-only. +# +# Note: read only slaves are not designed to be exposed to untrusted clients +# on the internet. It's just a protection layer against misuse of the instance. +# Still a read only slave exports by default all the administrative commands +# such as CONFIG, DEBUG, and so forth. To a limited extent you can improve +# security of read only slaves using 'rename-command' to shadow all the +# administrative / dangerous commands. +slave-read-only yes + +# Replication SYNC strategy: disk or socket. +# +# ------------------------------------------------------- +# WARNING: DISKLESS REPLICATION IS EXPERIMENTAL CURRENTLY +# ------------------------------------------------------- +# +# New slaves and reconnecting slaves that are not able to continue the replication +# process just receiving differences, need to do what is called a "full +# synchronization". An RDB file is transmitted from the master to the slaves. +# The transmission can happen in two different ways: +# +# 1) Disk-backed: The Redis master creates a new process that writes the RDB +# file on disk. Later the file is transferred by the parent +# process to the slaves incrementally. +# 2) Diskless: The Redis master creates a new process that directly writes the +# RDB file to slave sockets, without touching the disk at all. +# +# With disk-backed replication, while the RDB file is generated, more slaves +# can be queued and served with the RDB file as soon as the current child producing +# the RDB file finishes its work. With diskless replication instead once +# the transfer starts, new slaves arriving will be queued and a new transfer +# will start when the current one terminates. +# +# When diskless replication is used, the master waits a configurable amount of +# time (in seconds) before starting the transfer in the hope that multiple slaves +# will arrive and the transfer can be parallelized. +# +# With slow disks and fast (large bandwidth) networks, diskless replication +# works better. +repl-diskless-sync no + +# When diskless replication is enabled, it is possible to configure the delay +# the server waits in order to spawn the child that transfers the RDB via socket +# to the slaves. +# +# This is important since once the transfer starts, it is not possible to serve +# new slaves arriving, that will be queued for the next RDB transfer, so the server +# waits a delay in order to let more slaves arrive. +# +# The delay is specified in seconds, and by default is 5 seconds. To disable +# it entirely just set it to 0 seconds and the transfer will start ASAP. +repl-diskless-sync-delay 5 + +# Slaves send PINGs to server in a predefined interval. It's possible to change +# this interval with the repl_ping_slave_period option. The default value is 10 +# seconds. +# +# repl-ping-slave-period 10 + +# The following option sets the replication timeout for: +# +# 1) Bulk transfer I/O during SYNC, from the point of view of slave. +# 2) Master timeout from the point of view of slaves (data, pings). +# 3) Slave timeout from the point of view of masters (REPLCONF ACK pings). +# +# It is important to make sure that this value is greater than the value +# specified for repl-ping-slave-period otherwise a timeout will be detected +# every time there is low traffic between the master and the slave. +# +# repl-timeout 60 + +# Disable TCP_NODELAY on the slave socket after SYNC? +# +# If you select "yes" Redis will use a smaller number of TCP packets and +# less bandwidth to send data to slaves. But this can add a delay for +# the data to appear on the slave side, up to 40 milliseconds with +# Linux kernels using a default configuration. +# +# If you select "no" the delay for data to appear on the slave side will +# be reduced but more bandwidth will be used for replication. +# +# By default we optimize for low latency, but in very high traffic conditions +# or when the master and slaves are many hops away, turning this to "yes" may +# be a good idea. +repl-disable-tcp-nodelay no + +# Set the replication backlog size. The backlog is a buffer that accumulates +# slave data when slaves are disconnected for some time, so that when a slave +# wants to reconnect again, often a full resync is not needed, but a partial +# resync is enough, just passing the portion of data the slave missed while +# disconnected. +# +# The bigger the replication backlog, the longer the time the slave can be +# disconnected and later be able to perform a partial resynchronization. +# +# The backlog is only allocated once there is at least a slave connected. +# +# repl-backlog-size 1mb + +# After a master has no longer connected slaves for some time, the backlog +# will be freed. The following option configures the amount of seconds that +# need to elapse, starting from the time the last slave disconnected, for +# the backlog buffer to be freed. +# +# Note that slaves never free the backlog for timeout, since they may be +# promoted to masters later, and should be able to correctly "partially +# resynchronize" with the slaves: hence they should always accumulate backlog. +# +# A value of 0 means to never release the backlog. +# +# repl-backlog-ttl 3600 + +# The slave priority is an integer number published by Redis in the INFO output. +# It is used by Redis Sentinel in order to select a slave to promote into a +# master if the master is no longer working correctly. +# +# A slave with a low priority number is considered better for promotion, so +# for instance if there are three slaves with priority 10, 100, 25 Sentinel will +# pick the one with priority 10, that is the lowest. +# +# However a special priority of 0 marks the slave as not able to perform the +# role of master, so a slave with priority of 0 will never be selected by +# Redis Sentinel for promotion. +# +# By default the priority is 100. +slave-priority 100 + +# It is possible for a master to stop accepting writes if there are less than +# N slaves connected, having a lag less or equal than M seconds. +# +# The N slaves need to be in "online" state. +# +# The lag in seconds, that must be <= the specified value, is calculated from +# the last ping received from the slave, that is usually sent every second. +# +# This option does not GUARANTEE that N replicas will accept the write, but +# will limit the window of exposure for lost writes in case not enough slaves +# are available, to the specified number of seconds. +# +# For example to require at least 3 slaves with a lag <= 10 seconds use: +# +# min-slaves-to-write 3 +# min-slaves-max-lag 10 +# +# Setting one or the other to 0 disables the feature. +# +# By default min-slaves-to-write is set to 0 (feature disabled) and +# min-slaves-max-lag is set to 10. + +# A Redis master is able to list the address and port of the attached +# slaves in different ways. For example the "INFO replication" section +# offers this information, which is used, among other tools, by +# Redis Sentinel in order to discover slave instances. +# Another place where this info is available is in the output of the +# "ROLE" command of a master. +# +# The listed IP and address normally reported by a slave is obtained +# in the following way: +# +# IP: The address is auto detected by checking the peer address +# of the socket used by the slave to connect with the master. +# +# Port: The port is communicated by the slave during the replication +# handshake, and is normally the port that the slave is using to +# list for connections. +# +# However when port forwarding or Network Address Translation (NAT) is +# used, the slave may be actually reachable via different IP and port +# pairs. The following two options can be used by a slave in order to +# report to its master a specific set of IP and port, so that both INFO +# and ROLE will report those values. +# +# There is no need to use both the options if you need to override just +# the port or the IP address. +# +# slave-announce-ip 5.5.5.5 +# slave-announce-port 1234 + +################################## SECURITY ################################### + +# Require clients to issue AUTH before processing any other +# commands. This might be useful in environments in which you do not trust +# others with access to the host running redis-server. +# +# This should stay commented out for backward compatibility and because most +# people do not need auth (e.g. they run their own servers). +# +# Warning: since Redis is pretty fast an outside user can try up to +# 150k passwords per second against a good box. This means that you should +# use a very strong password otherwise it will be very easy to break. +# +# requirepass foobared + +# Command renaming. +# +# It is possible to change the name of dangerous commands in a shared +# environment. For instance the CONFIG command may be renamed into something +# hard to guess so that it will still be available for internal-use tools +# but not available for general clients. +# +# Example: +# +# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52 +# +# It is also possible to completely kill a command by renaming it into +# an empty string: +# +# rename-command CONFIG "" +# +# Please note that changing the name of commands that are logged into the +# AOF file or transmitted to slaves may cause problems. + +################################### CLIENTS #################################### + +# Set the max number of connected clients at the same time. By default +# this limit is set to 10000 clients, however if the Redis server is not +# able to configure the process file limit to allow for the specified limit +# the max number of allowed clients is set to the current file limit +# minus 32 (as Redis reserves a few file descriptors for internal uses). +# +# Once the limit is reached Redis will close all the new connections sending +# an error 'max number of clients reached'. +# +# maxclients 10000 + +############################## MEMORY MANAGEMENT ################################ + +# Set a memory usage limit to the specified amount of bytes. +# When the memory limit is reached Redis will try to remove keys +# according to the eviction policy selected (see maxmemory-policy). +# +# If Redis can't remove keys according to the policy, or if the policy is +# set to 'noeviction', Redis will start to reply with errors to commands +# that would use more memory, like SET, LPUSH, and so on, and will continue +# to reply to read-only commands like GET. +# +# This option is usually useful when using Redis as an LRU or LFU cache, or to +# set a hard memory limit for an instance (using the 'noeviction' policy). +# +# WARNING: If you have slaves attached to an instance with maxmemory on, +# the size of the output buffers needed to feed the slaves are subtracted +# from the used memory count, so that network problems / resyncs will +# not trigger a loop where keys are evicted, and in turn the output +# buffer of slaves is full with DELs of keys evicted triggering the deletion +# of more keys, and so forth until the database is completely emptied. +# +# In short... if you have slaves attached it is suggested that you set a lower +# limit for maxmemory so that there is some free RAM on the system for slave +# output buffers (but this is not needed if the policy is 'noeviction'). +# +# maxmemory + +# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory +# is reached. You can select among five behaviors: +# +# volatile-lru -> Evict using approximated LRU among the keys with an expire set. +# allkeys-lru -> Evict any key using approximated LRU. +# volatile-lfu -> Evict using approximated LFU among the keys with an expire set. +# allkeys-lfu -> Evict any key using approximated LFU. +# volatile-random -> Remove a random key among the ones with an expire set. +# allkeys-random -> Remove a random key, any key. +# volatile-ttl -> Remove the key with the nearest expire time (minor TTL) +# noeviction -> Don't evict anything, just return an error on write operations. +# +# LRU means Least Recently Used +# LFU means Least Frequently Used +# +# Both LRU, LFU and volatile-ttl are implemented using approximated +# randomized algorithms. +# +# Note: with any of the above policies, Redis will return an error on write +# operations, when there are no suitable keys for eviction. +# +# At the date of writing these commands are: set setnx setex append +# incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd +# sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby +# zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby +# getset mset msetnx exec sort +# +# The default is: +# +# maxmemory-policy noeviction + +# LRU, LFU and minimal TTL algorithms are not precise algorithms but approximated +# algorithms (in order to save memory), so you can tune it for speed or +# accuracy. For default Redis will check five keys and pick the one that was +# used less recently, you can change the sample size using the following +# configuration directive. +# +# The default of 5 produces good enough results. 10 Approximates very closely +# true LRU but costs more CPU. 3 is faster but not very accurate. +# +# maxmemory-samples 5 + +############################# LAZY FREEING #################################### + +# Redis has two primitives to delete keys. One is called DEL and is a blocking +# deletion of the object. It means that the server stops processing new commands +# in order to reclaim all the memory associated with an object in a synchronous +# way. If the key deleted is associated with a small object, the time needed +# in order to execute the DEL command is very small and comparable to most other +# O(1) or O(log_N) commands in Redis. However if the key is associated with an +# aggregated value containing millions of elements, the server can block for +# a long time (even seconds) in order to complete the operation. +# +# For the above reasons Redis also offers non blocking deletion primitives +# such as UNLINK (non blocking DEL) and the ASYNC option of FLUSHALL and +# FLUSHDB commands, in order to reclaim memory in background. Those commands +# are executed in constant time. Another thread will incrementally free the +# object in the background as fast as possible. +# +# DEL, UNLINK and ASYNC option of FLUSHALL and FLUSHDB are user-controlled. +# It's up to the design of the application to understand when it is a good +# idea to use one or the other. However the Redis server sometimes has to +# delete keys or flush the whole database as a side effect of other operations. +# Specifically Redis deletes objects independently of a user call in the +# following scenarios: +# +# 1) On eviction, because of the maxmemory and maxmemory policy configurations, +# in order to make room for new data, without going over the specified +# memory limit. +# 2) Because of expire: when a key with an associated time to live (see the +# EXPIRE command) must be deleted from memory. +# 3) Because of a side effect of a command that stores data on a key that may +# already exist. For example the RENAME command may delete the old key +# content when it is replaced with another one. Similarly SUNIONSTORE +# or SORT with STORE option may delete existing keys. The SET command +# itself removes any old content of the specified key in order to replace +# it with the specified string. +# 4) During replication, when a slave performs a full resynchronization with +# its master, the content of the whole database is removed in order to +# load the RDB file just transfered. +# +# In all the above cases the default is to delete objects in a blocking way, +# like if DEL was called. However you can configure each case specifically +# in order to instead release memory in a non-blocking way like if UNLINK +# was called, using the following configuration directives: + +lazyfree-lazy-eviction no +lazyfree-lazy-expire no +lazyfree-lazy-server-del no +slave-lazy-flush no + +############################## APPEND ONLY MODE ############################### + +# By default Redis asynchronously dumps the dataset on disk. This mode is +# good enough in many applications, but an issue with the Redis process or +# a power outage may result into a few minutes of writes lost (depending on +# the configured save points). +# +# The Append Only File is an alternative persistence mode that provides +# much better durability. For instance using the default data fsync policy +# (see later in the config file) Redis can lose just one second of writes in a +# dramatic event like a server power outage, or a single write if something +# wrong with the Redis process itself happens, but the operating system is +# still running correctly. +# +# AOF and RDB persistence can be enabled at the same time without problems. +# If the AOF is enabled on startup Redis will load the AOF, that is the file +# with the better durability guarantees. +# +# Please check http://redis.io/topics/persistence for more information. + +appendonly no + +# The name of the append only file (default: "appendonly.aof") + +appendfilename "appendonly.aof" + +# The fsync() call tells the Operating System to actually write data on disk +# instead of waiting for more data in the output buffer. Some OS will really flush +# data on disk, some other OS will just try to do it ASAP. +# +# Redis supports three different modes: +# +# no: don't fsync, just let the OS flush the data when it wants. Faster. +# always: fsync after every write to the append only log. Slow, Safest. +# everysec: fsync only one time every second. Compromise. +# +# The default is "everysec", as that's usually the right compromise between +# speed and data safety. It's up to you to understand if you can relax this to +# "no" that will let the operating system flush the output buffer when +# it wants, for better performances (but if you can live with the idea of +# some data loss consider the default persistence mode that's snapshotting), +# or on the contrary, use "always" that's very slow but a bit safer than +# everysec. +# +# More details please check the following article: +# http://antirez.com/post/redis-persistence-demystified.html +# +# If unsure, use "everysec". + +# appendfsync always +appendfsync everysec +# appendfsync no + +# When the AOF fsync policy is set to always or everysec, and a background +# saving process (a background save or AOF log background rewriting) is +# performing a lot of I/O against the disk, in some Linux configurations +# Redis may block too long on the fsync() call. Note that there is no fix for +# this currently, as even performing fsync in a different thread will block +# our synchronous write(2) call. +# +# In order to mitigate this problem it's possible to use the following option +# that will prevent fsync() from being called in the main process while a +# BGSAVE or BGREWRITEAOF is in progress. +# +# This means that while another child is saving, the durability of Redis is +# the same as "appendfsync none". In practical terms, this means that it is +# possible to lose up to 30 seconds of log in the worst scenario (with the +# default Linux settings). +# +# If you have latency problems turn this to "yes". Otherwise leave it as +# "no" that is the safest pick from the point of view of durability. + +no-appendfsync-on-rewrite no + +# Automatic rewrite of the append only file. +# Redis is able to automatically rewrite the log file implicitly calling +# BGREWRITEAOF when the AOF log size grows by the specified percentage. +# +# This is how it works: Redis remembers the size of the AOF file after the +# latest rewrite (if no rewrite has happened since the restart, the size of +# the AOF at startup is used). +# +# This base size is compared to the current size. If the current size is +# bigger than the specified percentage, the rewrite is triggered. Also +# you need to specify a minimal size for the AOF file to be rewritten, this +# is useful to avoid rewriting the AOF file even if the percentage increase +# is reached but it is still pretty small. +# +# Specify a percentage of zero in order to disable the automatic AOF +# rewrite feature. + +auto-aof-rewrite-percentage 100 +auto-aof-rewrite-min-size 64mb + +# An AOF file may be found to be truncated at the end during the Redis +# startup process, when the AOF data gets loaded back into memory. +# This may happen when the system where Redis is running +# crashes, especially when an ext4 filesystem is mounted without the +# data=ordered option (however this can't happen when Redis itself +# crashes or aborts but the operating system still works correctly). +# +# Redis can either exit with an error when this happens, or load as much +# data as possible (the default now) and start if the AOF file is found +# to be truncated at the end. The following option controls this behavior. +# +# If aof-load-truncated is set to yes, a truncated AOF file is loaded and +# the Redis server starts emitting a log to inform the user of the event. +# Otherwise if the option is set to no, the server aborts with an error +# and refuses to start. When the option is set to no, the user requires +# to fix the AOF file using the "redis-check-aof" utility before to restart +# the server. +# +# Note that if the AOF file will be found to be corrupted in the middle +# the server will still exit with an error. This option only applies when +# Redis will try to read more data from the AOF file but not enough bytes +# will be found. +aof-load-truncated yes + +# When rewriting the AOF file, Redis is able to use an RDB preamble in the +# AOF file for faster rewrites and recoveries. When this option is turned +# on the rewritten AOF file is composed of two different stanzas: +# +# [RDB file][AOF tail] +# +# When loading Redis recognizes that the AOF file starts with the "REDIS" +# string and loads the prefixed RDB file, and continues loading the AOF +# tail. +# +# This is currently turned off by default in order to avoid the surprise +# of a format change, but will at some point be used as the default. +aof-use-rdb-preamble no + +################################ LUA SCRIPTING ############################### + +# Max execution time of a Lua script in milliseconds. +# +# If the maximum execution time is reached Redis will log that a script is +# still in execution after the maximum allowed time and will start to +# reply to queries with an error. +# +# When a long running script exceeds the maximum execution time only the +# SCRIPT KILL and SHUTDOWN NOSAVE commands are available. The first can be +# used to stop a script that did not yet called write commands. The second +# is the only way to shut down the server in the case a write command was +# already issued by the script but the user doesn't want to wait for the natural +# termination of the script. +# +# Set it to 0 or a negative value for unlimited execution without warnings. +lua-time-limit 5000 + +################################ REDIS CLUSTER ############################### +# +# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# WARNING EXPERIMENTAL: Redis Cluster is considered to be stable code, however +# in order to mark it as "mature" we need to wait for a non trivial percentage +# of users to deploy it in production. +# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# +# Normal Redis instances can't be part of a Redis Cluster; only nodes that are +# started as cluster nodes can. In order to start a Redis instance as a +# cluster node enable the cluster support uncommenting the following: +# +# cluster-enabled yes + +# Every cluster node has a cluster configuration file. This file is not +# intended to be edited by hand. It is created and updated by Redis nodes. +# Every Redis Cluster node requires a different cluster configuration file. +# Make sure that instances running in the same system do not have +# overlapping cluster configuration file names. +# +# cluster-config-file nodes-6379.conf + +# Cluster node timeout is the amount of milliseconds a node must be unreachable +# for it to be considered in failure state. +# Most other internal time limits are multiple of the node timeout. +# +# cluster-node-timeout 15000 + +# A slave of a failing master will avoid to start a failover if its data +# looks too old. +# +# There is no simple way for a slave to actually have an exact measure of +# its "data age", so the following two checks are performed: +# +# 1) If there are multiple slaves able to failover, they exchange messages +# in order to try to give an advantage to the slave with the best +# replication offset (more data from the master processed). +# Slaves will try to get their rank by offset, and apply to the start +# of the failover a delay proportional to their rank. +# +# 2) Every single slave computes the time of the last interaction with +# its master. This can be the last ping or command received (if the master +# is still in the "connected" state), or the time that elapsed since the +# disconnection with the master (if the replication link is currently down). +# If the last interaction is too old, the slave will not try to failover +# at all. +# +# The point "2" can be tuned by user. Specifically a slave will not perform +# the failover if, since the last interaction with the master, the time +# elapsed is greater than: +# +# (node-timeout * slave-validity-factor) + repl-ping-slave-period +# +# So for example if node-timeout is 30 seconds, and the slave-validity-factor +# is 10, and assuming a default repl-ping-slave-period of 10 seconds, the +# slave will not try to failover if it was not able to talk with the master +# for longer than 310 seconds. +# +# A large slave-validity-factor may allow slaves with too old data to failover +# a master, while a too small value may prevent the cluster from being able to +# elect a slave at all. +# +# For maximum availability, it is possible to set the slave-validity-factor +# to a value of 0, which means, that slaves will always try to failover the +# master regardless of the last time they interacted with the master. +# (However they'll always try to apply a delay proportional to their +# offset rank). +# +# Zero is the only value able to guarantee that when all the partitions heal +# the cluster will always be able to continue. +# +# cluster-slave-validity-factor 10 + +# Cluster slaves are able to migrate to orphaned masters, that are masters +# that are left without working slaves. This improves the cluster ability +# to resist to failures as otherwise an orphaned master can't be failed over +# in case of failure if it has no working slaves. +# +# Slaves migrate to orphaned masters only if there are still at least a +# given number of other working slaves for their old master. This number +# is the "migration barrier". A migration barrier of 1 means that a slave +# will migrate only if there is at least 1 other working slave for its master +# and so forth. It usually reflects the number of slaves you want for every +# master in your cluster. +# +# Default is 1 (slaves migrate only if their masters remain with at least +# one slave). To disable migration just set it to a very large value. +# A value of 0 can be set but is useful only for debugging and dangerous +# in production. +# +# cluster-migration-barrier 1 + +# By default Redis Cluster nodes stop accepting queries if they detect there +# is at least an hash slot uncovered (no available node is serving it). +# This way if the cluster is partially down (for example a range of hash slots +# are no longer covered) all the cluster becomes, eventually, unavailable. +# It automatically returns available as soon as all the slots are covered again. +# +# However sometimes you want the subset of the cluster which is working, +# to continue to accept queries for the part of the key space that is still +# covered. In order to do so, just set the cluster-require-full-coverage +# option to no. +# +# cluster-require-full-coverage yes + +# In order to setup your cluster make sure to read the documentation +# available at http://redis.io web site. + +########################## CLUSTER DOCKER/NAT support ######################## + +# In certain deployments, Redis Cluster nodes address discovery fails, because +# addresses are NAT-ted or because ports are forwarded (the typical case is +# Docker and other containers). +# +# In order to make Redis Cluster working in such environments, a static +# configuration where each node knows its public address is needed. The +# following two options are used for this scope, and are: +# +# * cluster-announce-ip +# * cluster-announce-port +# * cluster-announce-bus-port +# +# Each instruct the node about its address, client port, and cluster message +# bus port. The information is then published in the header of the bus packets +# so that other nodes will be able to correctly map the address of the node +# publishing the information. +# +# If the above options are not used, the normal Redis Cluster auto-detection +# will be used instead. +# +# Note that when remapped, the bus port may not be at the fixed offset of +# clients port + 10000, so you can specify any port and bus-port depending +# on how they get remapped. If the bus-port is not set, a fixed offset of +# 10000 will be used as usually. +# +# Example: +# +# cluster-announce-ip 10.1.1.5 +# cluster-announce-port 6379 +# cluster-announce-bus-port 6380 + +################################## SLOW LOG ################################### + +# The Redis Slow Log is a system to log queries that exceeded a specified +# execution time. The execution time does not include the I/O operations +# like talking with the client, sending the reply and so forth, +# but just the time needed to actually execute the command (this is the only +# stage of command execution where the thread is blocked and can not serve +# other requests in the meantime). +# +# You can configure the slow log with two parameters: one tells Redis +# what is the execution time, in microseconds, to exceed in order for the +# command to get logged, and the other parameter is the length of the +# slow log. When a new command is logged the oldest one is removed from the +# queue of logged commands. + +# The following time is expressed in microseconds, so 1000000 is equivalent +# to one second. Note that a negative number disables the slow log, while +# a value of zero forces the logging of every command. +slowlog-log-slower-than 10000 + +# There is no limit to this length. Just be aware that it will consume memory. +# You can reclaim memory used by the slow log with SLOWLOG RESET. +slowlog-max-len 128 + +################################ LATENCY MONITOR ############################## + +# The Redis latency monitoring subsystem samples different operations +# at runtime in order to collect data related to possible sources of +# latency of a Redis instance. +# +# Via the LATENCY command this information is available to the user that can +# print graphs and obtain reports. +# +# The system only logs operations that were performed in a time equal or +# greater than the amount of milliseconds specified via the +# latency-monitor-threshold configuration directive. When its value is set +# to zero, the latency monitor is turned off. +# +# By default latency monitoring is disabled since it is mostly not needed +# if you don't have latency issues, and collecting data has a performance +# impact, that while very small, can be measured under big load. Latency +# monitoring can easily be enabled at runtime using the command +# "CONFIG SET latency-monitor-threshold " if needed. +latency-monitor-threshold 0 + +############################# EVENT NOTIFICATION ############################## + +# Redis can notify Pub/Sub clients about events happening in the key space. +# This feature is documented at http://redis.io/topics/notifications +# +# For instance if keyspace events notification is enabled, and a client +# performs a DEL operation on key "foo" stored in the Database 0, two +# messages will be published via Pub/Sub: +# +# PUBLISH __keyspace@0__:foo del +# PUBLISH __keyevent@0__:del foo +# +# It is possible to select the events that Redis will notify among a set +# of classes. Every class is identified by a single character: +# +# K Keyspace events, published with __keyspace@__ prefix. +# E Keyevent events, published with __keyevent@__ prefix. +# g Generic commands (non-type specific) like DEL, EXPIRE, RENAME, ... +# $ String commands +# l List commands +# s Set commands +# h Hash commands +# z Sorted set commands +# x Expired events (events generated every time a key expires) +# e Evicted events (events generated when a key is evicted for maxmemory) +# A Alias for g$lshzxe, so that the "AKE" string means all the events. +# +# The "notify-keyspace-events" takes as argument a string that is composed +# of zero or multiple characters. The empty string means that notifications +# are disabled. +# +# Example: to enable list and generic events, from the point of view of the +# event name, use: +# +# notify-keyspace-events Elg +# +# Example 2: to get the stream of the expired keys subscribing to channel +# name __keyevent@0__:expired use: +# +# notify-keyspace-events Ex +# +# By default all notifications are disabled because most users don't need +# this feature and the feature has some overhead. Note that if you don't +# specify at least one of K or E, no events will be delivered. +notify-keyspace-events "" + +############################### ADVANCED CONFIG ############################### + +# Hashes are encoded using a memory efficient data structure when they have a +# small number of entries, and the biggest entry does not exceed a given +# threshold. These thresholds can be configured using the following directives. +hash-max-ziplist-entries 512 +hash-max-ziplist-value 64 + +# Lists are also encoded in a special way to save a lot of space. +# The number of entries allowed per internal list node can be specified +# as a fixed maximum size or a maximum number of elements. +# For a fixed maximum size, use -5 through -1, meaning: +# -5: max size: 64 Kb <-- not recommended for normal workloads +# -4: max size: 32 Kb <-- not recommended +# -3: max size: 16 Kb <-- probably not recommended +# -2: max size: 8 Kb <-- good +# -1: max size: 4 Kb <-- good +# Positive numbers mean store up to _exactly_ that number of elements +# per list node. +# The highest performing option is usually -2 (8 Kb size) or -1 (4 Kb size), +# but if your use case is unique, adjust the settings as necessary. +list-max-ziplist-size -2 + +# Lists may also be compressed. +# Compress depth is the number of quicklist ziplist nodes from *each* side of +# the list to *exclude* from compression. The head and tail of the list +# are always uncompressed for fast push/pop operations. Settings are: +# 0: disable all list compression +# 1: depth 1 means "don't start compressing until after 1 node into the list, +# going from either the head or tail" +# So: [head]->node->node->...->node->[tail] +# [head], [tail] will always be uncompressed; inner nodes will compress. +# 2: [head]->[next]->node->node->...->node->[prev]->[tail] +# 2 here means: don't compress head or head->next or tail->prev or tail, +# but compress all nodes between them. +# 3: [head]->[next]->[next]->node->node->...->node->[prev]->[prev]->[tail] +# etc. +list-compress-depth 0 + +# Sets have a special encoding in just one case: when a set is composed +# of just strings that happen to be integers in radix 10 in the range +# of 64 bit signed integers. +# The following configuration setting sets the limit in the size of the +# set in order to use this special memory saving encoding. +set-max-intset-entries 512 + +# Similarly to hashes and lists, sorted sets are also specially encoded in +# order to save a lot of space. This encoding is only used when the length and +# elements of a sorted set are below the following limits: +zset-max-ziplist-entries 128 +zset-max-ziplist-value 64 + +# HyperLogLog sparse representation bytes limit. The limit includes the +# 16 bytes header. When an HyperLogLog using the sparse representation crosses +# this limit, it is converted into the dense representation. +# +# A value greater than 16000 is totally useless, since at that point the +# dense representation is more memory efficient. +# +# The suggested value is ~ 3000 in order to have the benefits of +# the space efficient encoding without slowing down too much PFADD, +# which is O(N) with the sparse encoding. The value can be raised to +# ~ 10000 when CPU is not a concern, but space is, and the data set is +# composed of many HyperLogLogs with cardinality in the 0 - 15000 range. +hll-sparse-max-bytes 3000 + +# Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in +# order to help rehashing the main Redis hash table (the one mapping top-level +# keys to values). The hash table implementation Redis uses (see dict.c) +# performs a lazy rehashing: the more operation you run into a hash table +# that is rehashing, the more rehashing "steps" are performed, so if the +# server is idle the rehashing is never complete and some more memory is used +# by the hash table. +# +# The default is to use this millisecond 10 times every second in order to +# actively rehash the main dictionaries, freeing memory when possible. +# +# If unsure: +# use "activerehashing no" if you have hard latency requirements and it is +# not a good thing in your environment that Redis can reply from time to time +# to queries with 2 milliseconds delay. +# +# use "activerehashing yes" if you don't have such hard requirements but +# want to free memory asap when possible. +activerehashing yes + +# The client output buffer limits can be used to force disconnection of clients +# that are not reading data from the server fast enough for some reason (a +# common reason is that a Pub/Sub client can't consume messages as fast as the +# publisher can produce them). +# +# The limit can be set differently for the three different classes of clients: +# +# normal -> normal clients including MONITOR clients +# slave -> slave clients +# pubsub -> clients subscribed to at least one pubsub channel or pattern +# +# The syntax of every client-output-buffer-limit directive is the following: +# +# client-output-buffer-limit +# +# A client is immediately disconnected once the hard limit is reached, or if +# the soft limit is reached and remains reached for the specified number of +# seconds (continuously). +# So for instance if the hard limit is 32 megabytes and the soft limit is +# 16 megabytes / 10 seconds, the client will get disconnected immediately +# if the size of the output buffers reach 32 megabytes, but will also get +# disconnected if the client reaches 16 megabytes and continuously overcomes +# the limit for 10 seconds. +# +# By default normal clients are not limited because they don't receive data +# without asking (in a push way), but just after a request, so only +# asynchronous clients may create a scenario where data is requested faster +# than it can read. +# +# Instead there is a default limit for pubsub and slave clients, since +# subscribers and slaves receive data in a push fashion. +# +# Both the hard or the soft limit can be disabled by setting them to zero. +client-output-buffer-limit normal 0 0 0 +client-output-buffer-limit slave 256mb 64mb 60 +client-output-buffer-limit pubsub 32mb 8mb 60 + +# Client query buffers accumulate new commands. They are limited to a fixed +# amount by default in order to avoid that a protocol desynchronization (for +# instance due to a bug in the client) will lead to unbound memory usage in +# the query buffer. However you can configure it here if you have very special +# needs, such us huge multi/exec requests or alike. +# +# client-query-buffer-limit 1gb + +# In the Redis protocol, bulk requests, that are, elements representing single +# strings, are normally limited ot 512 mb. However you can change this limit +# here. +# +# proto-max-bulk-len 512mb + +# Redis calls an internal function to perform many background tasks, like +# closing connections of clients in timeout, purging expired keys that are +# never requested, and so forth. +# +# Not all tasks are performed with the same frequency, but Redis checks for +# tasks to perform according to the specified "hz" value. +# +# By default "hz" is set to 10. Raising the value will use more CPU when +# Redis is idle, but at the same time will make Redis more responsive when +# there are many keys expiring at the same time, and timeouts may be +# handled with more precision. +# +# The range is between 1 and 500, however a value over 100 is usually not +# a good idea. Most users should use the default of 10 and raise this up to +# 100 only in environments where very low latency is required. +hz 10 + +# When a child rewrites the AOF file, if the following option is enabled +# the file will be fsync-ed every 32 MB of data generated. This is useful +# in order to commit the file to the disk more incrementally and avoid +# big latency spikes. +aof-rewrite-incremental-fsync yes + +# Redis LFU eviction (see maxmemory setting) can be tuned. However it is a good +# idea to start with the default settings and only change them after investigating +# how to improve the performances and how the keys LFU change over time, which +# is possible to inspect via the OBJECT FREQ command. +# +# There are two tunable parameters in the Redis LFU implementation: the +# counter logarithm factor and the counter decay time. It is important to +# understand what the two parameters mean before changing them. +# +# The LFU counter is just 8 bits per key, it's maximum value is 255, so Redis +# uses a probabilistic increment with logarithmic behavior. Given the value +# of the old counter, when a key is accessed, the counter is incremented in +# this way: +# +# 1. A random number R between 0 and 1 is extracted. +# 2. A probability P is calculated as 1/(old_value*lfu_log_factor+1). +# 3. The counter is incremented only if R < P. +# +# The default lfu-log-factor is 10. This is a table of how the frequency +# counter changes with a different number of accesses with different +# logarithmic factors: +# +# +--------+------------+------------+------------+------------+------------+ +# | factor | 100 hits | 1000 hits | 100K hits | 1M hits | 10M hits | +# +--------+------------+------------+------------+------------+------------+ +# | 0 | 104 | 255 | 255 | 255 | 255 | +# +--------+------------+------------+------------+------------+------------+ +# | 1 | 18 | 49 | 255 | 255 | 255 | +# +--------+------------+------------+------------+------------+------------+ +# | 10 | 10 | 18 | 142 | 255 | 255 | +# +--------+------------+------------+------------+------------+------------+ +# | 100 | 8 | 11 | 49 | 143 | 255 | +# +--------+------------+------------+------------+------------+------------+ +# +# NOTE: The above table was obtained by running the following commands: +# +# redis-benchmark -n 1000000 incr foo +# redis-cli object freq foo +# +# NOTE 2: The counter initial value is 5 in order to give new objects a chance +# to accumulate hits. +# +# The counter decay time is the time, in minutes, that must elapse in order +# for the key counter to be divided by two (or decremented if it has a value +# less <= 10). +# +# The default value for the lfu-decay-time is 1. A Special value of 0 means to +# decay the counter every time it happens to be scanned. +# +# lfu-log-factor 10 +# lfu-decay-time 1 + +########################### ACTIVE DEFRAGMENTATION ####################### +# +# WARNING THIS FEATURE IS EXPERIMENTAL. However it was stress tested +# even in production and manually tested by multiple engineers for some +# time. +# +# What is active defragmentation? +# ------------------------------- +# +# Active (online) defragmentation allows a Redis server to compact the +# spaces left between small allocations and deallocations of data in memory, +# thus allowing to reclaim back memory. +# +# Fragmentation is a natural process that happens with every allocator (but +# less so with Jemalloc, fortunately) and certain workloads. Normally a server +# restart is needed in order to lower the fragmentation, or at least to flush +# away all the data and create it again. However thanks to this feature +# implemented by Oran Agra for Redis 4.0 this process can happen at runtime +# in an "hot" way, while the server is running. +# +# Basically when the fragmentation is over a certain level (see the +# configuration options below) Redis will start to create new copies of the +# values in contiguous memory regions by exploiting certain specific Jemalloc +# features (in order to understand if an allocation is causing fragmentation +# and to allocate it in a better place), and at the same time, will release the +# old copies of the data. This process, repeated incrementally for all the keys +# will cause the fragmentation to drop back to normal values. +# +# Important things to understand: +# +# 1. This feature is disabled by default, and only works if you compiled Redis +# to use the copy of Jemalloc we ship with the source code of Redis. +# This is the default with Linux builds. +# +# 2. You never need to enable this feature if you don't have fragmentation +# issues. +# +# 3. Once you experience fragmentation, you can enable this feature when +# needed with the command "CONFIG SET activedefrag yes". +# +# The configuration parameters are able to fine tune the behavior of the +# defragmentation process. If you are not sure about what they mean it is +# a good idea to leave the defaults untouched. + +# Enabled active defragmentation +# activedefrag yes + +# Minimum amount of fragmentation waste to start active defrag +# active-defrag-ignore-bytes 100mb + +# Minimum percentage of fragmentation to start active defrag +# active-defrag-threshold-lower 10 + +# Maximum percentage of fragmentation at which we use maximum effort +# active-defrag-threshold-upper 100 + +# Minimal effort for defrag in CPU percentage +# active-defrag-cycle-min 25 + +# Maximal effort for defrag in CPU percentage +# active-defrag-cycle-max 75 + diff --git a/OrangeFormsOpen-VUE3/.editorconfig b/OrangeFormsOpen-VUE3/.editorconfig new file mode 100644 index 00000000..c61b6c7c --- /dev/null +++ b/OrangeFormsOpen-VUE3/.editorconfig @@ -0,0 +1,24 @@ +# editorconfig.org +#项目里读editorcongig文件时,读到此文件即可,不用继续往上搜索 +root = true + +# 规范指定:全部文件 +[*] +# 文档的字符编码:使用UTF-8 - Unicode 字符编码; +# 常见的字符编码有两种:1.UTF-8 - Unicode 字符编码;2.ISO-8859-1 - 拉丁字母表的字符编码。 +charset = utf-8 +#tab类型:空格(不使用制表符) +indent_style = space +#tab键长度是两个空格 +indent_size = 2 +#跟系统有关。win用cr lf,linux/unix用lf,mac用cr。 +end_of_line = lf +#保存文件时,在最后一行后加上一行空行 +insert_final_newline = true +#去掉每行代码最后多余的空格 +trim_trailing_whitespace = true + +[*.md] +insert_final_newline = false +trim_trailing_whitespace = false + diff --git a/OrangeFormsOpen-VUE3/.env.development b/OrangeFormsOpen-VUE3/.env.development new file mode 100644 index 00000000..aec1dbb3 --- /dev/null +++ b/OrangeFormsOpen-VUE3/.env.development @@ -0,0 +1,2 @@ +VITE_SERVER_HOST='http://localhost:8082/' +VITE_PROJECT_NAME='橙单演示工程' diff --git a/OrangeFormsOpen-VUE3/.env.production b/OrangeFormsOpen-VUE3/.env.production new file mode 100644 index 00000000..1db60839 --- /dev/null +++ b/OrangeFormsOpen-VUE3/.env.production @@ -0,0 +1,2 @@ +VITE_SERVER_HOST='http://localhost:8082/' +VITE_PROJECT_NAME='橙单项目' \ No newline at end of file diff --git a/OrangeFormsOpen-VUE3/.eslintignore b/OrangeFormsOpen-VUE3/.eslintignore new file mode 100644 index 00000000..5e6a1d9b --- /dev/null +++ b/OrangeFormsOpen-VUE3/.eslintignore @@ -0,0 +1,7 @@ +node_modules +dist/ +test +src/vite-env.d.ts +/src/pages/workflow/package/* +/src/components/Verifition/* +/src/components/SpreadSheet/* \ No newline at end of file diff --git a/OrangeFormsOpen-VUE3/.eslintrc-auto-import.json b/OrangeFormsOpen-VUE3/.eslintrc-auto-import.json new file mode 100644 index 00000000..2639e71a --- /dev/null +++ b/OrangeFormsOpen-VUE3/.eslintrc-auto-import.json @@ -0,0 +1,68 @@ +{ + "globals": { + "Component": true, + "ComponentPublicInstance": true, + "ComputedRef": true, + "EffectScope": true, + "ExtractDefaultPropTypes": true, + "ExtractPropTypes": true, + "ExtractPublicPropTypes": true, + "InjectionKey": true, + "PropType": true, + "Ref": true, + "VNode": true, + "WritableComputedRef": true, + "computed": true, + "createApp": true, + "customRef": true, + "defineAsyncComponent": true, + "defineComponent": true, + "effectScope": true, + "getCurrentInstance": true, + "getCurrentScope": true, + "h": true, + "inject": true, + "isProxy": true, + "isReactive": true, + "isReadonly": true, + "isRef": true, + "markRaw": true, + "nextTick": true, + "onActivated": true, + "onBeforeMount": true, + "onBeforeUnmount": true, + "onBeforeUpdate": true, + "onDeactivated": true, + "onErrorCaptured": true, + "onMounted": true, + "onRenderTracked": true, + "onRenderTriggered": true, + "onScopeDispose": true, + "onServerPrefetch": true, + "onUnmounted": true, + "onUpdated": true, + "provide": true, + "reactive": true, + "readonly": true, + "ref": true, + "resolveComponent": true, + "shallowReactive": true, + "shallowReadonly": true, + "shallowRef": true, + "toRaw": true, + "toRef": true, + "toRefs": true, + "toValue": true, + "triggerRef": true, + "unref": true, + "useAttrs": true, + "useCssModule": true, + "useCssVars": true, + "useSlots": true, + "watch": true, + "watchEffect": true, + "watchPostEffect": true, + "watchSyncEffect": true, + "showDialog": true + } +} diff --git a/OrangeFormsOpen-VUE3/.eslintrc.cjs b/OrangeFormsOpen-VUE3/.eslintrc.cjs new file mode 100644 index 00000000..d9cfddb8 --- /dev/null +++ b/OrangeFormsOpen-VUE3/.eslintrc.cjs @@ -0,0 +1,67 @@ +module.exports = { + root: true, + env: { + browser: true, + es2021: true, + node: true, + }, + extends: [ + './.eslintrc-auto-import.json', + 'eslint:recommended', + 'plugin:vue/vue3-essential', + 'plugin:@typescript-eslint/recommended', + 'plugin:import/typescript', + 'plugin:import/recommended', + 'plugin:prettier/recommended', + ], + settings: { + node: { + extensions: ['.ts', '.tsx'], + moduleDirectory: ['node_modules', 'src'], + }, + 'import/resolver': { + typescript: {}, + }, + }, + overrides: [ + //这里是添加的代码 + { + files: [ + 'src/pages/**/*.vue', + 'src/pages/**/**/*.vue', + 'src/components/**/*.vue', + 'src/components/**/**/index.vue', + ], // 匹配views和二级目录中的index.vue + rules: { + 'vue/multi-word-component-names': 'off', + }, //给上面匹配的文件指定规则 + }, + ], + parser: 'vue-eslint-parser', + parserOptions: { + parser: '@typescript-eslint/parser', + ecmaVersion: 'latest', + sourceType: 'module', + }, + rules: { + 'prettier/prettier': 'error', + 'linebreak-style': ['error', 'unix'], + 'vue/comment-directive': 'off', + 'vue/multi-word-component-names': 'off', + '@typescript-eslint/no-unused-vars': 'off', + 'import/extensions': [ + 'error', + 'ignorePackages', + { + ts: 'never', + tsx: 'never', + }, + ], + 'import/order': [ + 'error', + { + groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object'], + }, + ], + }, +}; diff --git a/OrangeFormsOpen-VUE3/.gitignore b/OrangeFormsOpen-VUE3/.gitignore new file mode 100644 index 00000000..727148ad --- /dev/null +++ b/OrangeFormsOpen-VUE3/.gitignore @@ -0,0 +1,4 @@ +node_modules +dist +.stylelintcache +.DS_Store diff --git a/OrangeFormsOpen-VUE3/.prettierrc.cjs b/OrangeFormsOpen-VUE3/.prettierrc.cjs new file mode 100644 index 00000000..93cbb7a8 --- /dev/null +++ b/OrangeFormsOpen-VUE3/.prettierrc.cjs @@ -0,0 +1,20 @@ +module.exports = { + printWidth: 100, // 每行代码长度(默认80) + tabWidth: 2, // 每个tab相当于多少个空格(默认2) + useTabs: false, // 是否使用tab进行缩进(默认false) + singleQuote: true, // 使用单引号(默认false) + semi: true, // 声明结尾使用分号(默认true) + trailingComma: 'all', // 多行使用拖尾逗号(默认none) + bracketSpacing: true, // 对象字面量的大括号间使用空格(默认true) + jsxBracketSameLine: false, // 多行JSX中的>放置在最后一行的结尾,而不是另起一行(默认false) + arrowParens: 'avoid', // 只有一个参数的箭头函数的参数是否带圆括号(默认avoid) + jsxBracketSameLine: false, + "overrides": [ + { + "files": "*.html", + "options": { + "parser": "html" + } + } + ] +}; diff --git a/OrangeFormsOpen-VUE3/.vscode/settings.json b/OrangeFormsOpen-VUE3/.vscode/settings.json new file mode 100644 index 00000000..3fe7bd98 --- /dev/null +++ b/OrangeFormsOpen-VUE3/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit", + "source.fixAll.stylelint": "explicit" + }, + "eslint.validate": ["javascript", "vue", "html", "typescript"], + "css.validate": false, + "scss.validate": false, + "stylelint.validate": ["css", "postcss", "scss", "vue", "sass"] +} diff --git a/OrangeFormsOpen-VUE3/README.md b/OrangeFormsOpen-VUE3/README.md new file mode 100644 index 00000000..34b74b6a --- /dev/null +++ b/OrangeFormsOpen-VUE3/README.md @@ -0,0 +1,25 @@ +# 探索前端前沿技术,并创建相关的模板 + +## 主要内容 + +### 主要工具包 + +* vite4 vue3 pinia vue-router axios ts element-plus vant + +### 主要规范工化工具 + +* eslint规范及配置 +* prettier规范及配置 +* stylelint规范及配置 + +### 推荐的约束 + +* 推荐使用vscode编辑器 安装eslint插件 prettier插件 Volar插件 +* 推荐使用node 18.16.1 版本 + +### 使用方式 + +* 克隆项目到本地 +* 进入项目根目录 执行 npm install 安装依赖 +* 启动项目 npm run dev +* 访问 diff --git a/OrangeFormsOpen-VUE3/components.d.ts b/OrangeFormsOpen-VUE3/components.d.ts new file mode 100644 index 00000000..2be5a445 --- /dev/null +++ b/OrangeFormsOpen-VUE3/components.d.ts @@ -0,0 +1,141 @@ +/* eslint-disable */ +/* prettier-ignore */ +// @ts-nocheck +// Generated by unplugin-vue-components +// Read more: https://github.com/vuejs/core/pull/3399 +export {} + +declare module 'vue' { + export interface GlobalComponents { + AdvanceQuery: typeof import('./src/components/AdvanceQuery/index.vue')['default'] + BarChart: typeof import('./src/components/Charts/barChart.vue')['default'] + Base: typeof import('./src/components/Charts/base.vue')['default'] + BreadCrumb: typeof import('./src/components/layout/components/BreadCrumb.vue')['default'] + CarouselChart: typeof import('./src/components/Charts/carouselChart.vue')['default'] + CommonList: typeof import('./src/components/Charts/commonList.vue')['default'] + DataCard: typeof import('./src/components/Charts/dataCard.vue')['default'] + DataProgressCard: typeof import('./src/components/Charts/dataProgressCard.vue')['default'] + DataViewTable: typeof import('./src/components/Charts/dataViewTable.vue')['default'] + DateRange: typeof import('./src/components/DateRange/index.vue')['default'] + DeptSelect: typeof import('./src/components/DeptSelect/index.vue')['default'] + DeptSelectDlg: typeof import('./src/components/DeptSelect/DeptSelectDlg.vue')['default'] + ElAlert: typeof import('element-plus/es')['ElAlert'] + ElAside: typeof import('element-plus/es')['ElAside'] + ElBadge: typeof import('element-plus/es')['ElBadge'] + ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb'] + ElBreadcrumbItem: typeof import('element-plus/es')['ElBreadcrumbItem'] + ElButton: typeof import('element-plus/es')['ElButton'] + ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup'] + ElCard: typeof import('element-plus/es')['ElCard'] + ElCarousel: typeof import('element-plus/es')['ElCarousel'] + ElCarouselItem: typeof import('element-plus/es')['ElCarouselItem'] + ElCascader: typeof import('element-plus/es')['ElCascader'] + ElCheckbox: typeof import('element-plus/es')['ElCheckbox'] + ElCol: typeof import('element-plus/es')['ElCol'] + ElCollapse: typeof import('element-plus/es')['ElCollapse'] + ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem'] + ElColorPicker: typeof import('element-plus/es')['ElColorPicker'] + ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider'] + ElContainer: typeof import('element-plus/es')['ElContainer'] + ElDatePicker: typeof import('element-plus/es')['ElDatePicker'] + ElDialog: typeof import('element-plus/es')['ElDialog'] + ElDivider: typeof import('element-plus/es')['ElDivider'] + ElDrawer: typeof import('element-plus/es')['ElDrawer'] + ElDropdown: typeof import('element-plus/es')['ElDropdown'] + ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem'] + ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu'] + ElEmpty: typeof import('element-plus/es')['ElEmpty'] + ElFooter: typeof import('element-plus/es')['ElFooter'] + ElForm: typeof import('element-plus/es')['ElForm'] + ElFormItem: typeof import('element-plus/es')['ElFormItem'] + ElHeader: typeof import('element-plus/es')['ElHeader'] + ElIcon: typeof import('element-plus/es')['ElIcon'] + ElIconArrowDown: typeof import('@element-plus/icons-vue')['ArrowDown'] + ElIconArrowLeft: typeof import('@element-plus/icons-vue')['ArrowLeft'] + ElIconArrowRight: typeof import('@element-plus/icons-vue')['ArrowRight'] + ElIconCaretBottom: typeof import('@element-plus/icons-vue')['CaretBottom'] + ElIconClose: typeof import('@element-plus/icons-vue')['Close'] + ElImage: typeof import('element-plus/es')['ElImage'] + ElInput: typeof import('element-plus/es')['ElInput'] + ElInputNumber: typeof import('element-plus/es')['ElInputNumber'] + ElLink: typeof import('element-plus/es')['ElLink'] + ElMain: typeof import('element-plus/es')['ElMain'] + ElMenu: typeof import('element-plus/es')['ElMenu'] + ElMenuItem: typeof import('element-plus/es')['ElMenuItem'] + ElOption: typeof import('element-plus/es')['ElOption'] + ElPagination: typeof import('element-plus/es')['ElPagination'] + ElPopover: typeof import('element-plus/es')['ElPopover'] + ElProgress: typeof import('element-plus/es')['ElProgress'] + ElRadio: typeof import('element-plus/es')['ElRadio'] + ElRadioButton: typeof import('element-plus/es')['ElRadioButton'] + ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup'] + ElRow: typeof import('element-plus/es')['ElRow'] + ElScrollbar: typeof import('element-plus/es')['ElScrollbar'] + ElSelect: typeof import('element-plus/es')['ElSelect'] + ElSlider: typeof import('element-plus/es')['ElSlider'] + ElSubMenu: typeof import('element-plus/es')['ElSubMenu'] + ElSwitch: typeof import('element-plus/es')['ElSwitch'] + ElTable: typeof import('element-plus/es')['ElTable'] + ElTableColumn: typeof import('element-plus/es')['ElTableColumn'] + ElTabPane: typeof import('element-plus/es')['ElTabPane'] + ElTabs: typeof import('element-plus/es')['ElTabs'] + ElTag: typeof import('element-plus/es')['ElTag'] + ElTooltip: typeof import('element-plus/es')['ElTooltip'] + ElTree: typeof import('element-plus/es')['ElTree'] + ElUpload: typeof import('element-plus/es')['ElUpload'] + FilterBox: typeof import('./src/components/FilterBox/index.vue')['default'] + FunnelChart: typeof import('./src/components/Charts/funnelChart.vue')['default'] + FunnelChartV3: typeof import('./src/components/Charts/funnelChartV3.vue')['default'] + GaugeChart: typeof import('./src/components/Charts/gaugeChart.vue')['default'] + Icons: typeof import('./src/components/icons/index.vue')['default'] + IconSelect: typeof import('./src/components/IconSelect/index.vue')['default'] + InputNumberRange: typeof import('./src/components/InputNumberRange/index.vue')['default'] + Layout: typeof import('./src/components/Dialog/layout.vue')['default'] + LineChart: typeof import('./src/components/Charts/lineChart.vue')['default'] + MultiColumn: typeof import('./src/components/layout/components/multi-column.vue')['default'] + MultiColumnMenu: typeof import('./src/components/layout/components/multi-column-menu.vue')['default'] + MultiItemBox: typeof import('./src/components/MultiItemBox/index.vue')['default'] + MultiItemList: typeof import('./src/components/MultiItemList/index.vue')['default'] + PageCloseButton: typeof import('./src/components/PageCloseButton/index.vue')['default'] + PieChart: typeof import('./src/components/Charts/pieChart.vue')['default'] + PivotTable: typeof import('./src/components/Charts/pivotTable.vue')['default'] + PivotTableColumn: typeof import('./src/components/Charts/pivotTableColumn.vue')['default'] + Progress: typeof import('./src/components/Progress/index.vue')['default'] + ProgressBar: typeof import('./src/components/Charts/progressBar.vue')['default'] + ProgressCircle: typeof import('./src/components/Charts/progressCircle.vue')['default'] + RadarChart: typeof import('./src/components/Charts/radarChart.vue')['default'] + RadarChartV3: typeof import('./src/components/Charts/radarChartV3.vue')['default'] + RichEditor: typeof import('./src/components/RichEditor/index.vue')['default'] + RichText: typeof import('./src/components/Charts/richText.vue')['default'] + RightAddBtn: typeof import('./src/components/Btns/RightAddBtn.vue')['default'] + RouterLink: typeof import('vue-router')['RouterLink'] + RouterView: typeof import('vue-router')['RouterView'] + ScatterChart: typeof import('./src/components/Charts/scatterChart.vue')['default'] + ScriptEditor: typeof import('./src/components/ScriptEditor/index.vue')['default'] + Sidebar: typeof import('./src/components/layout/components/Sidebar.vue')['default'] + StepBar: typeof import('./src/components/StepBar/index.vue')['default'] + StepItem: typeof import('./src/components/StepBar/stepItem.vue')['default'] + SubMenu: typeof import('./src/components/layout/components/SubMenu.vue')['default'] + TableBox: typeof import('./src/components/TableBox/index.vue')['default'] + TableProgressColumn: typeof import('./src/components/TableProgressColumn/index.vue')['default'] + TagItem: typeof import('./src/components/layout/components/TagItem.vue')['default'] + TagPanel: typeof import('./src/components/layout/components/TagPanel.vue')['default'] + ThirdParty: typeof import('./src/components/thirdParty/index.vue')['default'] + UserSelect: typeof import('./src/components/UserSelect/index.vue')['default'] + UserSelectDlg: typeof import('./src/components/UserSelect/UserSelectDlg.vue')['default'] + VanButton: typeof import('vant/es')['Button'] + VanCellGroup: typeof import('vant/es')['CellGroup'] + VanCheckbox: typeof import('vant/es')['Checkbox'] + VanCheckboxGroup: typeof import('vant/es')['CheckboxGroup'] + VanForm: typeof import('vant/es')['Form'] + VanRadio: typeof import('vant/es')['Radio'] + VanRadioGroup: typeof import('vant/es')['RadioGroup'] + VanRate: typeof import('vant/es')['Rate'] + VanSearch: typeof import('vant/es')['Search'] + VanSidebar: typeof import('vant/es')['Sidebar'] + VanSidebarItem: typeof import('vant/es')['SidebarItem'] + VanStepper: typeof import('vant/es')['Stepper'] + VanSwitch: typeof import('vant/es')['Switch'] + VanUploader: typeof import('vant/es')['Uploader'] + } +} diff --git a/OrangeFormsOpen-VUE3/index.html b/OrangeFormsOpen-VUE3/index.html new file mode 100644 index 00000000..a3dda7ba --- /dev/null +++ b/OrangeFormsOpen-VUE3/index.html @@ -0,0 +1,13 @@ + + + + + + + 加载中 + + +
+ + + diff --git a/OrangeFormsOpen-VUE3/package-lock.json b/OrangeFormsOpen-VUE3/package-lock.json new file mode 100644 index 00000000..69f8b207 --- /dev/null +++ b/OrangeFormsOpen-VUE3/package-lock.json @@ -0,0 +1,12498 @@ +{ + "name": "vite", + "version": "0.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "vite", + "version": "0.0.0", + "dependencies": { + "@highlightjs/vue-plugin": "^2.1.0", + "@layui/layui-vue": "^2.11.5", + "@wangeditor/editor": "^5.1.23", + "@wangeditor/editor-for-vue": "^5.1.12", + "ace-builds": "^1.32.2", + "axios": "^1.5.1", + "bpmn-js-token-simulation": "^0.10.0", + "clipboard": "^2.0.11", + "crypto-js": "^4.2.0", + "dayjs": "^1.11.10", + "echarts": "^5.5.0", + "ejs": "^3.1.9", + "element-plus": "^2.7.3", + "highlight.js": "^11.9.0", + "jsencrypt": "^3.3.2", + "json-bigint": "^1.0.0", + "pinia": "^2.1.6", + "pinia-plugin-persist": "^1.0.0", + "vant": "^4.7.3", + "vue": "^3.3.8", + "vue-draggable-plus": "^0.3.1", + "vue-json-viewer": "^3.0.4", + "vue-router": "^4.2.5", + "vxe-table": "^4.5.13", + "xe-utils": "^3.5.14", + "xml-js": "^1.6.11" + }, + "devDependencies": { + "@types/ejs": "^3.1.5", + "@types/json-bigint": "^1.0.4", + "@types/node": "^18.11.17", + "@typescript-eslint/eslint-plugin": "^5.46.1", + "@typescript-eslint/parser": "^5.46.1", + "@vant/auto-import-resolver": "^1.0.2", + "@vitejs/plugin-vue": "^4.0.0", + "autoprefixer": "^10.4.16", + "bpmn-js": "^7.4.0", + "bpmn-js-properties-panel": "^0.37.2", + "eslint": "^8.30.0", + "eslint-config-prettier": "^8.5.0", + "eslint-import-resolver-typescript": "^3.6.1", + "eslint-plugin-import": "^2.29.0", + "eslint-plugin-prettier": "^4.2.1", + "eslint-plugin-vue": "^9.8.0", + "postcss": "^8.4.20", + "postcss-html": "^1.5.0", + "postcss-preset-env": "^7.8.3", + "postcss-scss": "^4.0.6", + "prettier": "2.8.1", + "sass": "^1.57.1", + "typescript": "^4.9.3", + "unplugin-auto-import": "^0.16.7", + "unplugin-vue-components": "^0.25.2", + "vite": "^4.0.0", + "vite-plugin-eslint": "^1.8.1", + "vue-eslint-parser": "^9.1.0", + "vue-tsc": "^1.0.11" + } + }, + "node_modules/@antfu/utils": { + "version": "0.7.6", + "resolved": "https://registry.npmmirror.com/@antfu/utils/-/utils-0.7.6.tgz", + "integrity": "sha512-pvFiLP2BeOKA/ZOS6jxx4XhKzdVLHDhGlFEaZ2flWWYf2xOqVniqpk38I04DFRyz+L0ASggl7SkItTc+ZLju4w==", + "dev": true + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.23.4", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.23.4.tgz", + "integrity": "sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ==", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.19.1", + "resolved": "https://registry.npmmirror.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", + "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.23.0", + "resolved": "https://registry.npmmirror.com/@babel/parser/-/parser-7.23.0.tgz", + "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==", + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/runtime": { + "version": "7.23.8", + "resolved": "https://registry.npmmirror.com/@babel/runtime/-/runtime-7.23.8.tgz", + "integrity": "sha512-Y7KbAP984rn1VGMbGqKmBLio9V7y5Je9GvU4rQPCPinCyNfUcToxIXl06d59URp/F3LwinvODxab5N/G6qggkw==", + "dependencies": { + "regenerator-runtime": "^0.14.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.21.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.21.0.tgz", + "integrity": "sha512-uR7NWq2VNFnDi7EYqiRz2Jv/VQIu38tu64Zy8TX2nQFQ6etJ9V/Rr2msW8BS132mum2rL645qpDrLtAJtVpuow==", + "dependencies": { + "@babel/helper-string-parser": "^7.19.4", + "@babel/helper-validator-identifier": "^7.19.1", + "to-fast-properties": "^2.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@bpmn-io/extract-process-variables": { + "version": "0.3.0", + "resolved": "https://registry.npmmirror.com/@bpmn-io/extract-process-variables/-/extract-process-variables-0.3.0.tgz", + "integrity": "sha512-cZMPBvVUXBn7++ZaOVQQGvhrMnFVcOP218yfYBKUv0EMYjo775ust/ZmfIgWd8llT4myXA6dPz12wcYXUBR1Bg==", + "dev": true, + "dependencies": { + "min-dash": "^3.5.2" + }, + "peerDependencies": { + "camunda-bpmn-moddle": "^4.x" + } + }, + "node_modules/@csstools/postcss-cascade-layers": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-cascade-layers/-/postcss-cascade-layers-1.1.1.tgz", + "integrity": "sha512-+KdYrpKC5TgomQr2DlZF4lDEpHcoxnj5IGddYYfBWJAKfj1JtuHUIqMa+E1pJJ+z3kvDViWMqyqPlG4Ja7amQA==", + "dev": true, + "dependencies": { + "@csstools/selector-specificity": "^2.0.2", + "postcss-selector-parser": "^6.0.10" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/@csstools/postcss-color-function": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-color-function/-/postcss-color-function-1.1.1.tgz", + "integrity": "sha512-Bc0f62WmHdtRDjf5f3e2STwRAl89N2CLb+9iAwzrv4L2hncrbDwnQD9PCq0gtAt7pOI2leIV08HIBUd4jxD8cw==", + "dev": true, + "dependencies": { + "@csstools/postcss-progressive-custom-properties": "^1.1.0", + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/@csstools/postcss-font-format-keywords": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-font-format-keywords/-/postcss-font-format-keywords-1.0.1.tgz", + "integrity": "sha512-ZgrlzuUAjXIOc2JueK0X5sZDjCtgimVp/O5CEqTcs5ShWBa6smhWYbS0x5cVc/+rycTDbjjzoP0KTDnUneZGOg==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/@csstools/postcss-hwb-function": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-hwb-function/-/postcss-hwb-function-1.0.2.tgz", + "integrity": "sha512-YHdEru4o3Rsbjmu6vHy4UKOXZD+Rn2zmkAmLRfPet6+Jz4Ojw8cbWxe1n42VaXQhD3CQUXXTooIy8OkVbUcL+w==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/@csstools/postcss-ic-unit": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-ic-unit/-/postcss-ic-unit-1.0.1.tgz", + "integrity": "sha512-Ot1rcwRAaRHNKC9tAqoqNZhjdYBzKk1POgWfhN4uCOE47ebGcLRqXjKkApVDpjifL6u2/55ekkpnFcp+s/OZUw==", + "dev": true, + "dependencies": { + "@csstools/postcss-progressive-custom-properties": "^1.1.0", + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/@csstools/postcss-is-pseudo-class": { + "version": "2.0.7", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-is-pseudo-class/-/postcss-is-pseudo-class-2.0.7.tgz", + "integrity": "sha512-7JPeVVZHd+jxYdULl87lvjgvWldYu+Bc62s9vD/ED6/QTGjy0jy0US/f6BG53sVMTBJ1lzKZFpYmofBN9eaRiA==", + "dev": true, + "dependencies": { + "@csstools/selector-specificity": "^2.0.0", + "postcss-selector-parser": "^6.0.10" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/@csstools/postcss-nested-calc": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-nested-calc/-/postcss-nested-calc-1.0.0.tgz", + "integrity": "sha512-JCsQsw1wjYwv1bJmgjKSoZNvf7R6+wuHDAbi5f/7MbFhl2d/+v+TvBTU4BJH3G1X1H87dHl0mh6TfYogbT/dJQ==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/@csstools/postcss-normalize-display-values": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-normalize-display-values/-/postcss-normalize-display-values-1.0.1.tgz", + "integrity": "sha512-jcOanIbv55OFKQ3sYeFD/T0Ti7AMXc9nM1hZWu8m/2722gOTxFg7xYu4RDLJLeZmPUVQlGzo4jhzvTUq3x4ZUw==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/@csstools/postcss-oklab-function": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-oklab-function/-/postcss-oklab-function-1.1.1.tgz", + "integrity": "sha512-nJpJgsdA3dA9y5pgyb/UfEzE7W5Ka7u0CX0/HIMVBNWzWemdcTH3XwANECU6anWv/ao4vVNLTMxhiPNZsTK6iA==", + "dev": true, + "dependencies": { + "@csstools/postcss-progressive-custom-properties": "^1.1.0", + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/@csstools/postcss-progressive-custom-properties": { + "version": "1.3.0", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-progressive-custom-properties/-/postcss-progressive-custom-properties-1.3.0.tgz", + "integrity": "sha512-ASA9W1aIy5ygskZYuWams4BzafD12ULvSypmaLJT2jvQ8G0M3I8PRQhC0h7mG0Z3LI05+agZjqSR9+K9yaQQjA==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.3" + } + }, + "node_modules/@csstools/postcss-stepped-value-functions": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-stepped-value-functions/-/postcss-stepped-value-functions-1.0.1.tgz", + "integrity": "sha512-dz0LNoo3ijpTOQqEJLY8nyaapl6umbmDcgj4AD0lgVQ572b2eqA1iGZYTTWhrcrHztWDDRAX2DGYyw2VBjvCvQ==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/@csstools/postcss-text-decoration-shorthand": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-text-decoration-shorthand/-/postcss-text-decoration-shorthand-1.0.0.tgz", + "integrity": "sha512-c1XwKJ2eMIWrzQenN0XbcfzckOLLJiczqy+YvfGmzoVXd7pT9FfObiSEfzs84bpE/VqfpEuAZ9tCRbZkZxxbdw==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/@csstools/postcss-trigonometric-functions": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-trigonometric-functions/-/postcss-trigonometric-functions-1.0.2.tgz", + "integrity": "sha512-woKaLO///4bb+zZC2s80l+7cm07M7268MsyG3M0ActXXEFi6SuhvriQYcb58iiKGbjwwIU7n45iRLEHypB47Og==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/@csstools/postcss-unset-value": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-unset-value/-/postcss-unset-value-1.0.2.tgz", + "integrity": "sha512-c8J4roPBILnelAsdLr4XOAR/GsTm0GJi4XpcfvoWk3U6KiTCqiFYc63KhRMQQX35jYMp4Ao8Ij9+IZRgMfJp1g==", + "dev": true, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/@csstools/selector-specificity": { + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/@csstools/selector-specificity/-/selector-specificity-2.0.2.tgz", + "integrity": "sha512-IkpVW/ehM1hWKln4fCA3NzJU8KwD+kIOvPZA4cqxoJHtE21CCzjyp+Kxbu0i5I4tBNOlXPL9mjwnWlL0VEG4Fg==", + "dev": true, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2", + "postcss-selector-parser": "^6.0.10" + } + }, + "node_modules/@ctrl/tinycolor": { + "version": "3.6.1", + "resolved": "https://registry.npmmirror.com/@ctrl/tinycolor/-/tinycolor-3.6.1.tgz", + "integrity": "sha512-SITSV6aIXsuVNV3f3O0f2n/cgyEDWoSqtZMYiAmcsYHydcKrOz3gUxB/iXd/Qf08+IZX4KpgNbvUdMBmWz+kcA==", + "engines": { + "node": ">=10" + } + }, + "node_modules/@element-plus/icons-vue": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@element-plus/icons-vue/-/icons-vue-2.3.1.tgz", + "integrity": "sha512-XxVUZv48RZAd87ucGS48jPf6pKu0yV5UCg9f4FFwtrYxXOwWuVJo6wOvSLKEoMQKjv8GsX/mhP6UsC1lRwbUWg==", + "peerDependencies": { + "vue": "^3.2.0" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/android-arm/-/android-arm-0.16.9.tgz", + "integrity": "sha512-kW5ccqWHVOOTGUkkJbtfoImtqu3kA1PFkivM+9QPFSHphPfPBlBalX9eDRqPK+wHCqKhU48/78T791qPgC9e9A==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/android-arm64/-/android-arm64-0.16.9.tgz", + "integrity": "sha512-ndIAZJUeLx4O+4AJbFQCurQW4VRUXjDsUvt1L+nP8bVELOWdmdCEOtlIweCUE6P+hU0uxYbEK2AEP0n5IVQvhg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/android-x64/-/android-x64-0.16.9.tgz", + "integrity": "sha512-UbMcJB4EHrAVOnknQklREPgclNU2CPet2h+sCBCXmF2mfoYWopBn/CfTfeyOkb/JglOcdEADqAljFndMKnFtOw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/darwin-arm64/-/darwin-arm64-0.16.9.tgz", + "integrity": "sha512-d7D7/nrt4CxPul98lx4PXhyNZwTYtbdaHhOSdXlZuu5zZIznjqtMqLac8Bv+IuT6SVHiHUwrkL6ywD7mOgLW+A==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/darwin-x64/-/darwin-x64-0.16.9.tgz", + "integrity": "sha512-LZc+Wlz06AkJYtwWsBM3x2rSqTG8lntDuftsUNQ3fCx9ZttYtvlDcVtgb+NQ6t9s6K5No5zutN3pcjZEC2a4iQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.16.9.tgz", + "integrity": "sha512-gIj0UQZlQo93CHYouHKkpzP7AuruSaMIm1etcWIxccFEVqCN1xDr6BWlN9bM+ol/f0W9w3hx3HDuEwcJVtGneQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/freebsd-x64/-/freebsd-x64-0.16.9.tgz", + "integrity": "sha512-GNors4vaMJ7lzGOuhzNc7jvgsQZqErGA8rsW+nck8N1nYu86CvsJW2seigVrQQWOV4QzEP8Zf3gm+QCjA2hnBQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-arm/-/linux-arm-0.16.9.tgz", + "integrity": "sha512-cNx1EF99c2t1Ztn0lk9N+MuwBijGF8mH6nx9GFsB3e0lpUpPkCE/yt5d+7NP9EwJf5uzqdjutgVYoH1SNqzudA==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-arm64/-/linux-arm64-0.16.9.tgz", + "integrity": "sha512-YPxQunReYp8RQ1FvexFrOEqqf+nLbS3bKVZF5FRT2uKM7Wio7BeATqAwO02AyrdSEntt3I5fhFsujUChIa8CZg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-ia32/-/linux-ia32-0.16.9.tgz", + "integrity": "sha512-zb12ixDIKNwFpIqR00J88FFitVwOEwO78EiUi8wi8FXlmSc3GtUuKV/BSO+730Kglt0B47+ZrJN1BhhOxZaVrw==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-loong64/-/linux-loong64-0.16.9.tgz", + "integrity": "sha512-X8te4NLxtHiNT6H+4Pfm5RklzItA1Qy4nfyttihGGX+Koc53Ar20ViC+myY70QJ8PDEOehinXZj/F7QK3A+MKQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-mips64el/-/linux-mips64el-0.16.9.tgz", + "integrity": "sha512-ZqyMDLt02c5smoS3enlF54ndK5zK4IpClLTxF0hHfzHJlfm4y8IAkIF8LUW0W7zxcKy7oAwI7BRDqeVvC120SA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-ppc64/-/linux-ppc64-0.16.9.tgz", + "integrity": "sha512-k+ca5W5LDBEF3lfDwMV6YNXwm4wEpw9krMnNvvlNz3MrKSD2Eb2c861O0MaKrZkG/buTQAP4vkavbLwgIe6xjg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-riscv64/-/linux-riscv64-0.16.9.tgz", + "integrity": "sha512-GuInVdogjmg9DhgkEmNipHkC+3tzkanPJzgzTC2ihsvrruLyFoR1YrTGixblNSMPudQLpiqkcwGwwe0oqfrvfA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-s390x/-/linux-s390x-0.16.9.tgz", + "integrity": "sha512-49wQ0aYkvwXonGsxc7LuuLNICMX8XtO92Iqmug5Qau0kpnV6SP34jk+jIeu4suHwAbSbRhVFtDv75yRmyfQcHw==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-x64/-/linux-x64-0.16.9.tgz", + "integrity": "sha512-Nx4oKEAJ6EcQlt4dK7qJyuZUoXZG7CAeY22R7rqZijFzwFfMOD+gLP56uV7RrV86jGf8PeRY8TBsRmOcZoG42w==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/netbsd-x64/-/netbsd-x64-0.16.9.tgz", + "integrity": "sha512-d0WnpgJ+FTiMZXEQ1NOv9+0gvEhttbgKEvVqWWAtl1u9AvlspKXbodKHzQ5MLP6YV1y52Xp+p8FMYqj8ykTahg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/openbsd-x64/-/openbsd-x64-0.16.9.tgz", + "integrity": "sha512-jccK11278dvEscHFfMk5EIPjF4wv1qGD0vps7mBV1a6TspdR36O28fgPem/SA/0pcsCPHjww5ouCLwP+JNAFlw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/sunos-x64/-/sunos-x64-0.16.9.tgz", + "integrity": "sha512-OetwTSsv6mIDLqN7I7I2oX9MmHGwG+AP+wKIHvq+6sIHwcPPJqRx+DJB55jy9JG13CWcdcQno/7V5MTJ5a0xfQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/win32-arm64/-/win32-arm64-0.16.9.tgz", + "integrity": "sha512-tKSSSK6unhxbGbHg+Cc+JhRzemkcsX0tPBvG0m5qsWbkShDK9c+/LSb13L18LWVdOQZwuA55Vbakxmt6OjBDOQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/win32-ia32/-/win32-ia32-0.16.9.tgz", + "integrity": "sha512-ZTQ5vhNS5gli0KK8I6/s6+LwXmNEfq1ftjnSVyyNm33dBw8zDpstqhGXYUbZSWWLvkqiRRjgxgmoncmi6Yy7Ng==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/win32-x64/-/win32-x64-0.16.9.tgz", + "integrity": "sha512-C4ZX+YFIp6+lPrru3tpH6Gaapy8IBRHw/e7l63fzGDhn/EaiGpQgbIlT5paByyy+oMvRFQoxxyvC4LE0AjJMqQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "1.4.0", + "resolved": "https://registry.npmmirror.com/@eslint/eslintrc/-/eslintrc-1.4.0.tgz", + "integrity": "sha512-7yfvXy6MWLgWSFsLhz5yH3iQ52St8cdUY6FoGieKkRDVxuxmrNuUetIuu6cmjNWwniUHiWXjxCr5tTXDrbYS5A==", + "dev": true, + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.4.0", + "globals": "^13.19.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/@eslint/eslintrc/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/@eslint/eslintrc/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/@floating-ui/core": { + "version": "1.5.0", + "resolved": "https://registry.npmmirror.com/@floating-ui/core/-/core-1.5.0.tgz", + "integrity": "sha512-kK1h4m36DQ0UHGj5Ah4db7R0rHemTqqO0QLvUqi1/mUUp3LuAWbWxdxSIf/XsnH9VS6rRVPLJCncjRzUvyCLXg==", + "dependencies": { + "@floating-ui/utils": "^0.1.3" + } + }, + "node_modules/@floating-ui/dom": { + "version": "1.5.3", + "resolved": "https://registry.npmmirror.com/@floating-ui/dom/-/dom-1.5.3.tgz", + "integrity": "sha512-ClAbQnEqJAKCJOEbbLo5IUlZHkNszqhuxS4fHAVxRPXPya6Ysf2G8KypnYcOTpx6I8xcgF9bbHb6g/2KpbV8qA==", + "dependencies": { + "@floating-ui/core": "^1.4.2", + "@floating-ui/utils": "^0.1.3" + } + }, + "node_modules/@floating-ui/utils": { + "version": "0.1.6", + "resolved": "https://registry.npmmirror.com/@floating-ui/utils/-/utils-0.1.6.tgz", + "integrity": "sha512-OfX7E2oUDYxtBvsuS4e/jSn4Q9Qb6DzgeYtsAdkPZ47znpoNsMgZw0+tVijiv3uGNR6dgNlty6r9rzIzHjtd/A==" + }, + "node_modules/@highlightjs/vue-plugin": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/@highlightjs/vue-plugin/-/vue-plugin-2.1.0.tgz", + "integrity": "sha512-E+bmk4ncca+hBEYRV2a+1aIzIV0VSY/e5ArjpuSN9IO7wBJrzUE2u4ESCwrbQD7sAy+jWQjkV5qCCWgc+pu7CQ==", + "peerDependencies": { + "highlight.js": "^11.0.1", + "vue": "^3" + } + }, + "node_modules/@humanwhocodes/config-array": { + "version": "0.11.8", + "resolved": "https://registry.npmmirror.com/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", + "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", + "dev": true, + "dependencies": { + "@humanwhocodes/object-schema": "^1.2.1", + "debug": "^4.1.1", + "minimatch": "^3.0.5" + }, + "engines": { + "node": ">=10.10.0" + } + }, + "node_modules/@humanwhocodes/config-array/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/@humanwhocodes/config-array/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "engines": { + "node": ">=12.22" + } + }, + "node_modules/@humanwhocodes/object-schema": { + "version": "1.2.1", + "resolved": "https://registry.npmmirror.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", + "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", + "dev": true + }, + "node_modules/@intlify/core-base": { + "version": "9.1.10", + "resolved": "https://registry.npmjs.org/@intlify/core-base/-/core-base-9.1.10.tgz", + "integrity": "sha512-So9CNUavB/IsZ+zBmk2Cv6McQp6vc2wbGi1S0XQmJ8Vz+UFcNn9MFXAe9gY67PreIHrbLsLxDD0cwo1qsxM1Nw==", + "dependencies": { + "@intlify/devtools-if": "9.1.10", + "@intlify/message-compiler": "9.1.10", + "@intlify/message-resolver": "9.1.10", + "@intlify/runtime": "9.1.10", + "@intlify/shared": "9.1.10", + "@intlify/vue-devtools": "9.1.10" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/@intlify/devtools-if": { + "version": "9.1.10", + "resolved": "https://registry.npmjs.org/@intlify/devtools-if/-/devtools-if-9.1.10.tgz", + "integrity": "sha512-SHaKoYu6sog3+Q8js1y3oXLywuogbH1sKuc7NSYkN3GElvXSBaMoCzW+we0ZSFqj/6c7vTNLg9nQ6rxhKqYwnQ==", + "dependencies": { + "@intlify/shared": "9.1.10" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/@intlify/message-compiler": { + "version": "9.1.10", + "resolved": "https://registry.npmjs.org/@intlify/message-compiler/-/message-compiler-9.1.10.tgz", + "integrity": "sha512-+JiJpXff/XTb0EadYwdxOyRTB0hXNd4n1HaJ/a4yuV960uRmPXaklJsedW0LNdcptd/hYUZtCkI7Lc9J5C1gxg==", + "dependencies": { + "@intlify/message-resolver": "9.1.10", + "@intlify/shared": "9.1.10", + "source-map": "0.6.1" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/@intlify/message-resolver": { + "version": "9.1.10", + "resolved": "https://registry.npmjs.org/@intlify/message-resolver/-/message-resolver-9.1.10.tgz", + "integrity": "sha512-5YixMG/M05m0cn9+gOzd4EZQTFRUu8RGhzxJbR1DWN21x/Z3bJ8QpDYj6hC4FwBj5uKsRfKpJQ3Xqg98KWoA+w==", + "engines": { + "node": ">= 10" + } + }, + "node_modules/@intlify/runtime": { + "version": "9.1.10", + "resolved": "https://registry.npmjs.org/@intlify/runtime/-/runtime-9.1.10.tgz", + "integrity": "sha512-7QsuByNzpe3Gfmhwq6hzgXcMPpxz8Zxb/XFI6s9lQdPLPe5Lgw4U1ovRPZTOs6Y2hwitR3j/HD8BJNGWpJnOFA==", + "dependencies": { + "@intlify/message-compiler": "9.1.10", + "@intlify/message-resolver": "9.1.10", + "@intlify/shared": "9.1.10" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/@intlify/shared": { + "version": "9.1.10", + "resolved": "https://registry.npmjs.org/@intlify/shared/-/shared-9.1.10.tgz", + "integrity": "sha512-Om54xJeo1Vw+K1+wHYyXngE8cAbrxZHpWjYzMR9wCkqbhGtRV5VLhVc214Ze2YatPrWlS2WSMOWXR8JktX/IgA==", + "engines": { + "node": ">= 10" + } + }, + "node_modules/@intlify/vue-devtools": { + "version": "9.1.10", + "resolved": "https://registry.npmjs.org/@intlify/vue-devtools/-/vue-devtools-9.1.10.tgz", + "integrity": "sha512-5l3qYARVbkWAkagLu1XbDUWRJSL8br1Dj60wgMaKB0+HswVsrR6LloYZTg7ozyvM621V6+zsmwzbQxbVQyrytQ==", + "dependencies": { + "@intlify/message-resolver": "9.1.10", + "@intlify/runtime": "9.1.10", + "@intlify/shared": "9.1.10" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.3", + "resolved": "https://registry.npmmirror.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", + "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", + "dependencies": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmmirror.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmmirror.com/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/source-map": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.5.tgz", + "integrity": "sha512-UTYAUj/wviwdsMfzoSJspJxbkH5o1snzwX0//0ENX1u/55kkZZkcTZP6u9bwKGkv+dkk9at4m1Cpt0uY80kcpQ==", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmmirror.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmmirror.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "node_modules/@layui/icons-vue": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@layui/icons-vue/-/icons-vue-1.1.0.tgz", + "integrity": "sha512-ndc53qyUZSslUkO8ZHeBMh6i4gSTtAUqsPpKQZWML0JH6E/X3LIySe6LATeqEMmD7wWSnHJ+WBVGO4ij85Dk1g==" + }, + "node_modules/@layui/layer-vue": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@layui/layer-vue/-/layer-vue-2.1.1.tgz", + "integrity": "sha512-lk9UoDQmLvtqrgdK+zeizp8KZy8pQfzX7dzHhAv+Qc74L1WC2jipb2hpYmaksiKX1lihy0D9eWWycMbnRn7V9A==", + "dependencies": { + "@layui/icons-vue": "1.1.0" + } + }, + "node_modules/@layui/layui-vue": { + "version": "2.11.5", + "resolved": "https://registry.npmjs.org/@layui/layui-vue/-/layui-vue-2.11.5.tgz", + "integrity": "sha512-KZ5xrOm+B27yrEMWSuIGPLgLxUjISWuq0ecU4BcwrasCjEklfLS9UZBQp3peRWRsD6PGXP/cet1qQiD0AnUCJg==", + "dependencies": { + "@babel/types": "7.21.0", + "@ctrl/tinycolor": "^3.4.1", + "@layui/icons-vue": "1.1.0", + "@layui/layer-vue": "2.1.1", + "@rollup/plugin-terser": "0.4.3", + "@types/qrcode": "1.5.0", + "@umijs/ssr-darkreader": "^4.9.45", + "@vueuse/core": "8.7.3", + "async-validator": "^4.1.1", + "cropperjs": "^1.5.12", + "dayjs": "^1.11.7", + "evtd": "^0.2.3", + "jsbarcode": "3.11.5", + "qrcode": "1.5.0", + "vue-i18n": "9.1.10" + } + }, + "node_modules/@layui/layui-vue/node_modules/@vueuse/core": { + "version": "8.7.3", + "resolved": "https://registry.npmjs.org/@vueuse/core/-/core-8.7.3.tgz", + "integrity": "sha512-jpBnyG9b4wXgk0Dz3I71lfhD0o53t1tZR+NoAQ+17zJy7MP/VDfGIkq8GcqpDwmptLCmGiGVipkPbWmDGMic8Q==", + "dependencies": { + "@vueuse/metadata": "8.7.3", + "@vueuse/shared": "8.7.3", + "vue-demi": "*" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "@vue/composition-api": "^1.1.0", + "vue": "^2.6.0 || ^3.2.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + }, + "vue": { + "optional": true + } + } + }, + "node_modules/@layui/layui-vue/node_modules/@vueuse/metadata": { + "version": "8.7.3", + "resolved": "https://registry.npmjs.org/@vueuse/metadata/-/metadata-8.7.3.tgz", + "integrity": "sha512-spf9kgCsBEFbQb90I6SIqAWh1yP5T1JoJGj+/04+VTMIHXKzn3iecmHUalg8QEOCPNtnFQGNEw5OLg0L39eizg==", + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/@layui/layui-vue/node_modules/@vueuse/shared": { + "version": "8.7.3", + "resolved": "https://registry.npmjs.org/@vueuse/shared/-/shared-8.7.3.tgz", + "integrity": "sha512-PMc/h6cEakJ4+5VuNUGi7RnbA6CkLvtG2230x8w3zYJpW1P6Qphh9+dFFvHn7TX+RlaicF5ND0RX1NxWmAoW7w==", + "dependencies": { + "vue-demi": "*" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "@vue/composition-api": "^1.1.0", + "vue": "^2.6.0 || ^3.2.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + }, + "vue": { + "optional": true + } + } + }, + "node_modules/@layui/layui-vue/node_modules/vue-demi": { + "version": "0.14.6", + "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.14.6.tgz", + "integrity": "sha512-8QA7wrYSHKaYgUxDA5ZC24w+eHm3sYCbp0EzcDwKqN3p6HqtTCGR/GVsPyZW92unff4UlcSh++lmqDWN3ZIq4w==", + "hasInstallScript": true, + "bin": { + "vue-demi-fix": "bin/vue-demi-fix.js", + "vue-demi-switch": "bin/vue-demi-switch.js" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "@vue/composition-api": "^1.0.0-rc.1", + "vue": "^3.0.0-0 || ^2.6.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + } + } + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmmirror.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmmirror.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmmirror.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@popperjs/core": { + "name": "@sxzz/popperjs-es", + "version": "2.11.7", + "resolved": "https://registry.npmmirror.com/@sxzz/popperjs-es/-/popperjs-es-2.11.7.tgz", + "integrity": "sha512-Ccy0NlLkzr0Ex2FKvh2X+OyERHXJ88XJ1MXtsI9y9fGexlaXaVTPzBCRBwIxFkORuOb+uBqeu+RqnpgYTEZRUQ==" + }, + "node_modules/@rollup/plugin-terser": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.4.3.tgz", + "integrity": "sha512-EF0oejTMtkyhrkwCdg0HJ0IpkcaVg1MMSf2olHb2Jp+1mnLM04OhjpJWGma4HobiDTF0WCyViWuvadyE9ch2XA==", + "dependencies": { + "serialize-javascript": "^6.0.1", + "smob": "^1.0.0", + "terser": "^5.17.4" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.x || ^3.x" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/pluginutils": { + "version": "4.2.1", + "resolved": "https://registry.npmmirror.com/@rollup/pluginutils/-/pluginutils-4.2.1.tgz", + "integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==", + "dev": true, + "dependencies": { + "estree-walker": "^2.0.1", + "picomatch": "^2.2.2" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/@transloadit/prettier-bytes": { + "version": "0.0.7", + "resolved": "https://registry.npmmirror.com/@transloadit/prettier-bytes/-/prettier-bytes-0.0.7.tgz", + "integrity": "sha512-VeJbUb0wEKbcwaSlj5n+LscBl9IPgLPkHVGBkh00cztv6X4L/TJXK58LzFuBKX7/GAfiGhIwH67YTLTlzvIzBA==" + }, + "node_modules/@types/ejs": { + "version": "3.1.5", + "resolved": "https://registry.npmmirror.com/@types/ejs/-/ejs-3.1.5.tgz", + "integrity": "sha512-nv+GSx77ZtXiJzwKdsASqi+YQ5Z7vwHsTP0JY2SiQgjGckkBRKZnk8nIM+7oUZ1VCtuTz0+By4qVR7fqzp/Dfg==", + "dev": true + }, + "node_modules/@types/eslint": { + "version": "8.4.10", + "resolved": "https://registry.npmmirror.com/@types/eslint/-/eslint-8.4.10.tgz", + "integrity": "sha512-Sl/HOqN8NKPmhWo2VBEPm0nvHnu2LL3v9vKo8MEq0EtbJ4eVzGPl41VNPvn5E1i5poMk4/XD8UriLHpJvEP/Nw==", + "dev": true, + "dependencies": { + "@types/estree": "*", + "@types/json-schema": "*" + } + }, + "node_modules/@types/estree": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/@types/estree/-/estree-1.0.0.tgz", + "integrity": "sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ==", + "dev": true + }, + "node_modules/@types/event-emitter": { + "version": "0.3.5", + "resolved": "https://registry.npmmirror.com/@types/event-emitter/-/event-emitter-0.3.5.tgz", + "integrity": "sha512-zx2/Gg0Eg7gwEiOIIh5w9TrhKKTeQh7CPCOPNc0el4pLSwzebA8SmnHwZs2dWlLONvyulykSwGSQxQHLhjGLvQ==" + }, + "node_modules/@types/json-bigint": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@types/json-bigint/-/json-bigint-1.0.4.tgz", + "integrity": "sha512-ydHooXLbOmxBbubnA7Eh+RpBzuaIiQjh8WGJYQB50JFGFrdxW7JzVlyEV7fAXw0T2sqJ1ysTneJbiyNLqZRAag==", + "dev": true + }, + "node_modules/@types/json-schema": { + "version": "7.0.11", + "resolved": "https://registry.npmmirror.com/@types/json-schema/-/json-schema-7.0.11.tgz", + "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", + "dev": true + }, + "node_modules/@types/json5": { + "version": "0.0.29", + "resolved": "https://registry.npmmirror.com/@types/json5/-/json5-0.0.29.tgz", + "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", + "dev": true + }, + "node_modules/@types/lodash": { + "version": "4.14.201", + "resolved": "https://registry.npmmirror.com/@types/lodash/-/lodash-4.14.201.tgz", + "integrity": "sha512-y9euML0cim1JrykNxADLfaG0FgD1g/yTHwUs/Jg9ZIU7WKj2/4IW9Lbb1WZbvck78W/lfGXFfe+u2EGfIJXdLQ==" + }, + "node_modules/@types/lodash-es": { + "version": "4.17.11", + "resolved": "https://registry.npmmirror.com/@types/lodash-es/-/lodash-es-4.17.11.tgz", + "integrity": "sha512-eCw8FYAWHt2DDl77s+AMLLzPn310LKohruumpucZI4oOFJkIgnlaJcy23OKMJxx4r9PeTF13Gv6w+jqjWQaYUg==", + "dependencies": { + "@types/lodash": "*" + } + }, + "node_modules/@types/node": { + "version": "18.11.17", + "resolved": "https://registry.npmmirror.com/@types/node/-/node-18.11.17.tgz", + "integrity": "sha512-HJSUJmni4BeDHhfzn6nF0sVmd1SMezP7/4F0Lq+aXzmp2xm9O7WXrUtHW/CHlYVtZUbByEvWidHqRtcJXGF2Ng==" + }, + "node_modules/@types/qrcode": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.5.0.tgz", + "integrity": "sha512-x5ilHXRxUPIMfjtM+1vf/GPTRWZ81nqscursm5gMznJeK9M0YnZ1c3bEvRLQ0zSSgedLx1J6MGL231ObQGGhaA==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/semver": { + "version": "7.3.13", + "resolved": "https://registry.npmmirror.com/@types/semver/-/semver-7.3.13.tgz", + "integrity": "sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==", + "dev": true + }, + "node_modules/@types/sortablejs": { + "version": "1.15.7", + "resolved": "https://registry.npmmirror.com/@types/sortablejs/-/sortablejs-1.15.7.tgz", + "integrity": "sha512-PvgWCx1Lbgm88FdQ6S7OGvLIjWS66mudKPlfdrWil0TjsO5zmoZmzoKiiwRShs1dwPgrlkr0N4ewuy0/+QUXYQ==", + "peer": true + }, + "node_modules/@types/web-bluetooth": { + "version": "0.0.16", + "resolved": "https://registry.npmmirror.com/@types/web-bluetooth/-/web-bluetooth-0.0.16.tgz", + "integrity": "sha512-oh8q2Zc32S6gd/j50GowEjKLoOVOwHP/bWVjKJInBwQqdOYMdPrf1oVlelTlyfFK3CKxL1uahMDAr+vy8T7yMQ==" + }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "5.46.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.46.1.tgz", + "integrity": "sha512-YpzNv3aayRBwjs4J3oz65eVLXc9xx0PDbIRisHj+dYhvBn02MjYOD96P8YGiWEIFBrojaUjxvkaUpakD82phsA==", + "dev": true, + "dependencies": { + "@typescript-eslint/scope-manager": "5.46.1", + "@typescript-eslint/type-utils": "5.46.1", + "@typescript-eslint/utils": "5.46.1", + "debug": "^4.3.4", + "ignore": "^5.2.0", + "natural-compare-lite": "^1.4.0", + "regexpp": "^3.2.0", + "semver": "^7.3.7", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^5.0.0", + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "5.46.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/parser/-/parser-5.46.1.tgz", + "integrity": "sha512-RelQ5cGypPh4ySAtfIMBzBGyrNerQcmfA1oJvPj5f+H4jI59rl9xxpn4bonC0tQvUKOEN7eGBFWxFLK3Xepneg==", + "dev": true, + "dependencies": { + "@typescript-eslint/scope-manager": "5.46.1", + "@typescript-eslint/types": "5.46.1", + "@typescript-eslint/typescript-estree": "5.46.1", + "debug": "^4.3.4" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "5.46.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/scope-manager/-/scope-manager-5.46.1.tgz", + "integrity": "sha512-iOChVivo4jpwUdrJZyXSMrEIM/PvsbbDOX1y3UCKjSgWn+W89skxWaYXACQfxmIGhPVpRWK/VWPYc+bad6smIA==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.46.1", + "@typescript-eslint/visitor-keys": "5.46.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "5.46.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/type-utils/-/type-utils-5.46.1.tgz", + "integrity": "sha512-V/zMyfI+jDmL1ADxfDxjZ0EMbtiVqj8LUGPAGyBkXXStWmCUErMpW873zEHsyguWCuq2iN4BrlWUkmuVj84yng==", + "dev": true, + "dependencies": { + "@typescript-eslint/typescript-estree": "5.46.1", + "@typescript-eslint/utils": "5.46.1", + "debug": "^4.3.4", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "*" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/types": { + "version": "5.46.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/types/-/types-5.46.1.tgz", + "integrity": "sha512-Z5pvlCaZgU+93ryiYUwGwLl9AQVB/PQ1TsJ9NZ/gHzZjN7g9IAn6RSDkpCV8hqTwAiaj6fmCcKSQeBPlIpW28w==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "5.46.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.46.1.tgz", + "integrity": "sha512-j9W4t67QiNp90kh5Nbr1w92wzt+toiIsaVPnEblB2Ih2U9fqBTyqV9T3pYWZBRt6QoMh/zVWP59EpuCjc4VRBg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.46.1", + "@typescript-eslint/visitor-keys": "5.46.1", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "semver": "^7.3.7", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "5.46.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/utils/-/utils-5.46.1.tgz", + "integrity": "sha512-RBdBAGv3oEpFojaCYT4Ghn4775pdjvwfDOfQ2P6qzNVgQOVrnSPe5/Pb88kv7xzYQjoio0eKHKB9GJ16ieSxvA==", + "dev": true, + "dependencies": { + "@types/json-schema": "^7.0.9", + "@types/semver": "^7.3.12", + "@typescript-eslint/scope-manager": "5.46.1", + "@typescript-eslint/types": "5.46.1", + "@typescript-eslint/typescript-estree": "5.46.1", + "eslint-scope": "^5.1.1", + "eslint-utils": "^3.0.0", + "semver": "^7.3.7" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmmirror.com/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmmirror.com/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "5.46.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.46.1.tgz", + "integrity": "sha512-jczZ9noovXwy59KjRTk1OftT78pwygdcmCuBf8yMoWt/8O8l+6x2LSEze0E4TeepXK4MezW3zGSyoDRZK7Y9cg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.46.1", + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/@umijs/ssr-darkreader": { + "version": "4.9.45", + "resolved": "https://registry.npmjs.org/@umijs/ssr-darkreader/-/ssr-darkreader-4.9.45.tgz", + "integrity": "sha512-XlcwzSYQ/SRZpHdwIyMDS4FOGX5kP4U/2g2mykyn/iPQTK4xTiQAyBu6UnnDnn7d5P8s7Atzh1C7H0ETNOypJg==", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/darkreader" + } + }, + "node_modules/@uppy/companion-client": { + "version": "2.2.2", + "resolved": "https://registry.npmmirror.com/@uppy/companion-client/-/companion-client-2.2.2.tgz", + "integrity": "sha512-5mTp2iq97/mYSisMaBtFRry6PTgZA6SIL7LePteOV5x0/DxKfrZW3DEiQERJmYpHzy7k8johpm2gHnEKto56Og==", + "dependencies": { + "@uppy/utils": "^4.1.2", + "namespace-emitter": "^2.0.1" + } + }, + "node_modules/@uppy/core": { + "version": "2.3.4", + "resolved": "https://registry.npmmirror.com/@uppy/core/-/core-2.3.4.tgz", + "integrity": "sha512-iWAqppC8FD8mMVqewavCz+TNaet6HPXitmGXpGGREGrakZ4FeuWytVdrelydzTdXx6vVKkOmI2FLztGg73sENQ==", + "dependencies": { + "@transloadit/prettier-bytes": "0.0.7", + "@uppy/store-default": "^2.1.1", + "@uppy/utils": "^4.1.3", + "lodash.throttle": "^4.1.1", + "mime-match": "^1.0.2", + "namespace-emitter": "^2.0.1", + "nanoid": "^3.1.25", + "preact": "^10.5.13" + } + }, + "node_modules/@uppy/store-default": { + "version": "2.1.1", + "resolved": "https://registry.npmmirror.com/@uppy/store-default/-/store-default-2.1.1.tgz", + "integrity": "sha512-xnpTxvot2SeAwGwbvmJ899ASk5tYXhmZzD/aCFsXePh/v8rNvR2pKlcQUH7cF/y4baUGq3FHO/daKCok/mpKqQ==" + }, + "node_modules/@uppy/utils": { + "version": "4.1.3", + "resolved": "https://registry.npmmirror.com/@uppy/utils/-/utils-4.1.3.tgz", + "integrity": "sha512-nTuMvwWYobnJcytDO3t+D6IkVq/Qs4Xv3vyoEZ+Iaf8gegZP+rEyoaFT2CK5XLRMienPyqRqNbIfRuFaOWSIFw==", + "dependencies": { + "lodash.throttle": "^4.1.1" + } + }, + "node_modules/@uppy/xhr-upload": { + "version": "2.1.3", + "resolved": "https://registry.npmmirror.com/@uppy/xhr-upload/-/xhr-upload-2.1.3.tgz", + "integrity": "sha512-YWOQ6myBVPs+mhNjfdWsQyMRWUlrDLMoaG7nvf/G6Y3GKZf8AyjFDjvvJ49XWQ+DaZOftGkHmF1uh/DBeGivJQ==", + "dependencies": { + "@uppy/companion-client": "^2.2.2", + "@uppy/utils": "^4.1.2", + "nanoid": "^3.1.25" + }, + "peerDependencies": { + "@uppy/core": "^2.3.3" + } + }, + "node_modules/@vant/auto-import-resolver": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/@vant/auto-import-resolver/-/auto-import-resolver-1.0.2.tgz", + "integrity": "sha512-5SYC1izl36KID+3F4pqFtYD8VFK6m1pdulft99sjSkUN4GBX9OslRnsJA0g7xS+0YrytjDuxxBk04YLYIxaYMg==", + "dev": true + }, + "node_modules/@vant/popperjs": { + "version": "1.3.0", + "resolved": "https://registry.npmmirror.com/@vant/popperjs/-/popperjs-1.3.0.tgz", + "integrity": "sha512-hB+czUG+aHtjhaEmCJDuXOep0YTZjdlRR+4MSmIFnkCQIxJaXLQdSsR90XWvAI2yvKUI7TCGqR8pQg2RtvkMHw==" + }, + "node_modules/@vant/use": { + "version": "1.6.0", + "resolved": "https://registry.npmmirror.com/@vant/use/-/use-1.6.0.tgz", + "integrity": "sha512-PHHxeAASgiOpSmMjceweIrv2AxDZIkWXyaczksMoWvKV2YAYEhoizRuk/xFnKF+emUIi46TsQ+rvlm/t2BBCfA==", + "peerDependencies": { + "vue": "^3.0.0" + } + }, + "node_modules/@vitejs/plugin-vue": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/@vitejs/plugin-vue/-/plugin-vue-4.0.0.tgz", + "integrity": "sha512-e0X4jErIxAB5oLtDqbHvHpJe/uWNkdpYV83AOG2xo2tEVSzCzewgJMtREZM30wXnM5ls90hxiOtAuVU6H5JgbA==", + "dev": true, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "peerDependencies": { + "vite": "^4.0.0", + "vue": "^3.2.25" + } + }, + "node_modules/@volar/language-core": { + "version": "1.0.14", + "resolved": "https://registry.npmmirror.com/@volar/language-core/-/language-core-1.0.14.tgz", + "integrity": "sha512-j1tMQgw0qCV2amM4qDJNG/zc0yj3ay8HoWNt05IaiCPsULtSSpF/9+F6Izvn0DF7nWOd6MUHTxaQAeZwLfr56Q==", + "dev": true, + "dependencies": { + "@volar/source-map": "1.0.14", + "@vue/reactivity": "^3.2.45", + "muggle-string": "^0.1.0" + } + }, + "node_modules/@volar/source-map": { + "version": "1.0.14", + "resolved": "https://registry.npmmirror.com/@volar/source-map/-/source-map-1.0.14.tgz", + "integrity": "sha512-8pHCbEWHWaSDGb/FM9zRIW1lY1OAo16MENVSQGCgTwz7PWf3Gw6WW3TFVKCtzaFhLjPH0i5e9hALy7vBPbSHoA==", + "dev": true, + "dependencies": { + "muggle-string": "^0.1.0" + } + }, + "node_modules/@volar/typescript": { + "version": "1.0.14", + "resolved": "https://registry.npmmirror.com/@volar/typescript/-/typescript-1.0.14.tgz", + "integrity": "sha512-67qcjjz7KGFhMCG9EKMA9qJK3BRGQecO4dGyAKfMfClZ/PaVoKfDvJvYo89McGTQ8SeczD48I9TPnaJM0zK8JQ==", + "dev": true, + "dependencies": { + "@volar/language-core": "1.0.14" + } + }, + "node_modules/@volar/vue-language-core": { + "version": "1.0.14", + "resolved": "https://registry.npmmirror.com/@volar/vue-language-core/-/vue-language-core-1.0.14.tgz", + "integrity": "sha512-grJ4dQ7c/suZmBBmZtw2O2XeDX+rtgpdBtHxMug1NMPRDxj5EZ9WGphWtGnMQj8RyVgpz9ByvV5GbQjk4/wfBw==", + "dev": true, + "dependencies": { + "@volar/language-core": "1.0.14", + "@volar/source-map": "1.0.14", + "@vue/compiler-dom": "^3.2.45", + "@vue/compiler-sfc": "^3.2.45", + "@vue/reactivity": "^3.2.45", + "@vue/shared": "^3.2.45", + "minimatch": "^5.1.0", + "vue-template-compiler": "^2.7.14" + } + }, + "node_modules/@volar/vue-typescript": { + "version": "1.0.14", + "resolved": "https://registry.npmmirror.com/@volar/vue-typescript/-/vue-typescript-1.0.14.tgz", + "integrity": "sha512-2P0QeGLLY05fDTu8GqY8SR2+jldXRTrkQdD2Nc0sVOjMJ7j3RYYY0wJyZ9hCBDuxV4Micc6jdB8nKS0yxQgNvA==", + "deprecated": "WARNING: This project has been renamed to @vue/typescript. Install using @vue/typescript instead.", + "dev": true, + "dependencies": { + "@volar/typescript": "1.0.14", + "@volar/vue-language-core": "1.0.14" + } + }, + "node_modules/@vue/compiler-core": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.3.8.tgz", + "integrity": "sha512-hN/NNBUECw8SusQvDSqqcVv6gWq8L6iAktUR0UF3vGu2OhzRqcOiAno0FmBJWwxhYEXRlQJT5XnoKsVq1WZx4g==", + "dependencies": { + "@babel/parser": "^7.23.0", + "@vue/shared": "3.3.8", + "estree-walker": "^2.0.2", + "source-map-js": "^1.0.2" + } + }, + "node_modules/@vue/compiler-dom": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.3.8.tgz", + "integrity": "sha512-+PPtv+p/nWDd0AvJu3w8HS0RIm/C6VGBIRe24b9hSyNWOAPEUosFZ5diwawwP8ip5sJ8n0Pe87TNNNHnvjs0FQ==", + "dependencies": { + "@vue/compiler-core": "3.3.8", + "@vue/shared": "3.3.8" + } + }, + "node_modules/@vue/compiler-sfc": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.3.8.tgz", + "integrity": "sha512-WMzbUrlTjfYF8joyT84HfwwXo+8WPALuPxhy+BZ6R4Aafls+jDBnSz8PDz60uFhuqFbl3HxRfxvDzrUf3THwpA==", + "dependencies": { + "@babel/parser": "^7.23.0", + "@vue/compiler-core": "3.3.8", + "@vue/compiler-dom": "3.3.8", + "@vue/compiler-ssr": "3.3.8", + "@vue/reactivity-transform": "3.3.8", + "@vue/shared": "3.3.8", + "estree-walker": "^2.0.2", + "magic-string": "^0.30.5", + "postcss": "^8.4.31", + "source-map-js": "^1.0.2" + } + }, + "node_modules/@vue/compiler-ssr": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.3.8.tgz", + "integrity": "sha512-hXCqQL/15kMVDBuoBYpUnSYT8doDNwsjvm3jTefnXr+ytn294ySnT8NlsFHmTgKNjwpuFy7XVV8yTeLtNl/P6w==", + "dependencies": { + "@vue/compiler-dom": "3.3.8", + "@vue/shared": "3.3.8" + } + }, + "node_modules/@vue/devtools-api": { + "version": "6.5.0", + "resolved": "https://registry.npmmirror.com/@vue/devtools-api/-/devtools-api-6.5.0.tgz", + "integrity": "sha512-o9KfBeaBmCKl10usN4crU53fYtC1r7jJwdGKjPT24t348rHxgfpZ0xL3Xm/gLUYnc0oTp8LAmrxOeLyu6tbk2Q==" + }, + "node_modules/@vue/reactivity": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.3.8.tgz", + "integrity": "sha512-ctLWitmFBu6mtddPyOKpHg8+5ahouoTCRtmAHZAXmolDtuZXfjL2T3OJ6DL6ezBPQB1SmMnpzjiWjCiMYmpIuw==", + "dependencies": { + "@vue/shared": "3.3.8" + } + }, + "node_modules/@vue/reactivity-transform": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/@vue/reactivity-transform/-/reactivity-transform-3.3.8.tgz", + "integrity": "sha512-49CvBzmZNtcHua0XJ7GdGifM8GOXoUMOX4dD40Y5DxI3R8OUhMlvf2nvgUAcPxaXiV5MQQ1Nwy09ADpnLQUqRw==", + "dependencies": { + "@babel/parser": "^7.23.0", + "@vue/compiler-core": "3.3.8", + "@vue/shared": "3.3.8", + "estree-walker": "^2.0.2", + "magic-string": "^0.30.5" + } + }, + "node_modules/@vue/runtime-core": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.3.8.tgz", + "integrity": "sha512-qurzOlb6q26KWQ/8IShHkMDOuJkQnQcTIp1sdP4I9MbCf9FJeGVRXJFr2mF+6bXh/3Zjr9TDgURXrsCr9bfjUw==", + "dependencies": { + "@vue/reactivity": "3.3.8", + "@vue/shared": "3.3.8" + } + }, + "node_modules/@vue/runtime-dom": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.3.8.tgz", + "integrity": "sha512-Noy5yM5UIf9UeFoowBVgghyGGPIDPy1Qlqt0yVsUdAVbqI8eeMSsTqBtauaEoT2UFXUk5S64aWVNJN4MJ2vRdA==", + "dependencies": { + "@vue/runtime-core": "3.3.8", + "@vue/shared": "3.3.8", + "csstype": "^3.1.2" + } + }, + "node_modules/@vue/server-renderer": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.3.8.tgz", + "integrity": "sha512-zVCUw7RFskvPuNlPn/8xISbrf0zTWsTSdYTsUTN1ERGGZGVnRxM2QZ3x1OR32+vwkkCm0IW6HmJ49IsPm7ilLg==", + "dependencies": { + "@vue/compiler-ssr": "3.3.8", + "@vue/shared": "3.3.8" + }, + "peerDependencies": { + "vue": "3.3.8" + } + }, + "node_modules/@vue/shared": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.3.8.tgz", + "integrity": "sha512-8PGwybFwM4x8pcfgqEQFy70NaQxASvOC5DJwLQfpArw1UDfUXrJkdxD3BhVTMS+0Lef/TU7YO0Jvr0jJY8T+mw==" + }, + "node_modules/@vueuse/core": { + "version": "9.13.0", + "resolved": "https://registry.npmmirror.com/@vueuse/core/-/core-9.13.0.tgz", + "integrity": "sha512-pujnclbeHWxxPRqXWmdkKV5OX4Wk4YeK7wusHqRwU0Q7EFusHoqNA/aPhB6KCh9hEqJkLAJo7bb0Lh9b+OIVzw==", + "dependencies": { + "@types/web-bluetooth": "^0.0.16", + "@vueuse/metadata": "9.13.0", + "@vueuse/shared": "9.13.0", + "vue-demi": "*" + } + }, + "node_modules/@vueuse/core/node_modules/vue-demi": { + "version": "0.14.6", + "resolved": "https://registry.npmmirror.com/vue-demi/-/vue-demi-0.14.6.tgz", + "integrity": "sha512-8QA7wrYSHKaYgUxDA5ZC24w+eHm3sYCbp0EzcDwKqN3p6HqtTCGR/GVsPyZW92unff4UlcSh++lmqDWN3ZIq4w==", + "hasInstallScript": true, + "bin": { + "vue-demi-fix": "bin/vue-demi-fix.js", + "vue-demi-switch": "bin/vue-demi-switch.js" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "@vue/composition-api": "^1.0.0-rc.1", + "vue": "^3.0.0-0 || ^2.6.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + } + } + }, + "node_modules/@vueuse/metadata": { + "version": "9.13.0", + "resolved": "https://registry.npmmirror.com/@vueuse/metadata/-/metadata-9.13.0.tgz", + "integrity": "sha512-gdU7TKNAUVlXXLbaF+ZCfte8BjRJQWPCa2J55+7/h+yDtzw3vOoGQDRXzI6pyKyo6bXFT5/QoPE4hAknExjRLQ==" + }, + "node_modules/@vueuse/shared": { + "version": "9.13.0", + "resolved": "https://registry.npmmirror.com/@vueuse/shared/-/shared-9.13.0.tgz", + "integrity": "sha512-UrnhU+Cnufu4S6JLCPZnkWh0WwZGUp72ktOF2DFptMlOs3TOdVv8xJN53zhHGARmVOsz5KqOls09+J1NR6sBKw==", + "dependencies": { + "vue-demi": "*" + } + }, + "node_modules/@vueuse/shared/node_modules/vue-demi": { + "version": "0.14.6", + "resolved": "https://registry.npmmirror.com/vue-demi/-/vue-demi-0.14.6.tgz", + "integrity": "sha512-8QA7wrYSHKaYgUxDA5ZC24w+eHm3sYCbp0EzcDwKqN3p6HqtTCGR/GVsPyZW92unff4UlcSh++lmqDWN3ZIq4w==", + "hasInstallScript": true, + "bin": { + "vue-demi-fix": "bin/vue-demi-fix.js", + "vue-demi-switch": "bin/vue-demi-switch.js" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "@vue/composition-api": "^1.0.0-rc.1", + "vue": "^3.0.0-0 || ^2.6.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + } + } + }, + "node_modules/@wangeditor/basic-modules": { + "version": "1.1.7", + "resolved": "https://registry.npmmirror.com/@wangeditor/basic-modules/-/basic-modules-1.1.7.tgz", + "integrity": "sha512-cY9CPkLJaqF05STqfpZKWG4LpxTMeGSIIF1fHvfm/mz+JXatCagjdkbxdikOuKYlxDdeqvOeBmsUBItufDLXZg==", + "dependencies": { + "is-url": "^1.2.4" + }, + "peerDependencies": { + "@wangeditor/core": "1.x", + "dom7": "^3.0.0", + "lodash.throttle": "^4.1.1", + "nanoid": "^3.2.0", + "slate": "^0.72.0", + "snabbdom": "^3.1.0" + } + }, + "node_modules/@wangeditor/code-highlight": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/@wangeditor/code-highlight/-/code-highlight-1.0.3.tgz", + "integrity": "sha512-iazHwO14XpCuIWJNTQTikqUhGKyqj+dUNWJ9288Oym9M2xMVHvnsOmDU2sgUDWVy+pOLojReMPgXCsvvNlOOhw==", + "dependencies": { + "prismjs": "^1.23.0" + }, + "peerDependencies": { + "@wangeditor/core": "1.x", + "dom7": "^3.0.0", + "slate": "^0.72.0", + "snabbdom": "^3.1.0" + } + }, + "node_modules/@wangeditor/core": { + "version": "1.1.19", + "resolved": "https://registry.npmmirror.com/@wangeditor/core/-/core-1.1.19.tgz", + "integrity": "sha512-KevkB47+7GhVszyYF2pKGKtCSj/YzmClsD03C3zTt+9SR2XWT5T0e3yQqg8baZpcMvkjs1D8Dv4fk8ok/UaS2Q==", + "dependencies": { + "@types/event-emitter": "^0.3.3", + "event-emitter": "^0.3.5", + "html-void-elements": "^2.0.0", + "i18next": "^20.4.0", + "scroll-into-view-if-needed": "^2.2.28", + "slate-history": "^0.66.0" + }, + "peerDependencies": { + "@uppy/core": "^2.1.1", + "@uppy/xhr-upload": "^2.0.3", + "dom7": "^3.0.0", + "is-hotkey": "^0.2.0", + "lodash.camelcase": "^4.3.0", + "lodash.clonedeep": "^4.5.0", + "lodash.debounce": "^4.0.8", + "lodash.foreach": "^4.5.0", + "lodash.isequal": "^4.5.0", + "lodash.throttle": "^4.1.1", + "lodash.toarray": "^4.4.0", + "nanoid": "^3.2.0", + "slate": "^0.72.0", + "snabbdom": "^3.1.0" + } + }, + "node_modules/@wangeditor/editor": { + "version": "5.1.23", + "resolved": "https://registry.npmmirror.com/@wangeditor/editor/-/editor-5.1.23.tgz", + "integrity": "sha512-0RxfeVTuK1tktUaPROnCoFfaHVJpRAIE2zdS0mpP+vq1axVQpLjM8+fCvKzqYIkH0Pg+C+44hJpe3VVroSkEuQ==", + "dependencies": { + "@uppy/core": "^2.1.1", + "@uppy/xhr-upload": "^2.0.3", + "@wangeditor/basic-modules": "^1.1.7", + "@wangeditor/code-highlight": "^1.0.3", + "@wangeditor/core": "^1.1.19", + "@wangeditor/list-module": "^1.0.5", + "@wangeditor/table-module": "^1.1.4", + "@wangeditor/upload-image-module": "^1.0.2", + "@wangeditor/video-module": "^1.1.4", + "dom7": "^3.0.0", + "is-hotkey": "^0.2.0", + "lodash.camelcase": "^4.3.0", + "lodash.clonedeep": "^4.5.0", + "lodash.debounce": "^4.0.8", + "lodash.foreach": "^4.5.0", + "lodash.isequal": "^4.5.0", + "lodash.throttle": "^4.1.1", + "lodash.toarray": "^4.4.0", + "nanoid": "^3.2.0", + "slate": "^0.72.0", + "snabbdom": "^3.1.0" + } + }, + "node_modules/@wangeditor/editor-for-vue": { + "version": "5.1.12", + "resolved": "https://registry.npmmirror.com/@wangeditor/editor-for-vue/-/editor-for-vue-5.1.12.tgz", + "integrity": "sha512-0Ds3D8I+xnpNWezAeO7HmPRgTfUxHLMd9JKcIw+QzvSmhC5xUHbpCcLU+KLmeBKTR/zffnS5GQo6qi3GhTMJWQ==", + "peerDependencies": { + "@wangeditor/editor": ">=5.1.0", + "vue": "^3.0.5" + } + }, + "node_modules/@wangeditor/list-module": { + "version": "1.0.5", + "resolved": "https://registry.npmmirror.com/@wangeditor/list-module/-/list-module-1.0.5.tgz", + "integrity": "sha512-uDuYTP6DVhcYf7mF1pTlmNn5jOb4QtcVhYwSSAkyg09zqxI1qBqsfUnveeDeDqIuptSJhkh81cyxi+MF8sEPOQ==", + "peerDependencies": { + "@wangeditor/core": "1.x", + "dom7": "^3.0.0", + "slate": "^0.72.0", + "snabbdom": "^3.1.0" + } + }, + "node_modules/@wangeditor/table-module": { + "version": "1.1.4", + "resolved": "https://registry.npmmirror.com/@wangeditor/table-module/-/table-module-1.1.4.tgz", + "integrity": "sha512-5saanU9xuEocxaemGdNi9t8MCDSucnykEC6jtuiT72kt+/Hhh4nERYx1J20OPsTCCdVr7hIyQenFD1iSRkIQ6w==", + "peerDependencies": { + "@wangeditor/core": "1.x", + "dom7": "^3.0.0", + "lodash.isequal": "^4.5.0", + "lodash.throttle": "^4.1.1", + "nanoid": "^3.2.0", + "slate": "^0.72.0", + "snabbdom": "^3.1.0" + } + }, + "node_modules/@wangeditor/upload-image-module": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/@wangeditor/upload-image-module/-/upload-image-module-1.0.2.tgz", + "integrity": "sha512-z81lk/v71OwPDYeQDxj6cVr81aDP90aFuywb8nPD6eQeECtOymrqRODjpO6VGvCVxVck8nUxBHtbxKtjgcwyiA==", + "peerDependencies": { + "@uppy/core": "^2.0.3", + "@uppy/xhr-upload": "^2.0.3", + "@wangeditor/basic-modules": "1.x", + "@wangeditor/core": "1.x", + "dom7": "^3.0.0", + "lodash.foreach": "^4.5.0", + "slate": "^0.72.0", + "snabbdom": "^3.1.0" + } + }, + "node_modules/@wangeditor/video-module": { + "version": "1.1.4", + "resolved": "https://registry.npmmirror.com/@wangeditor/video-module/-/video-module-1.1.4.tgz", + "integrity": "sha512-ZdodDPqKQrgx3IwWu4ZiQmXI8EXZ3hm2/fM6E3t5dB8tCaIGWQZhmqd6P5knfkRAd3z2+YRSRbxOGfoRSp/rLg==", + "peerDependencies": { + "@uppy/core": "^2.1.4", + "@uppy/xhr-upload": "^2.0.7", + "@wangeditor/core": "1.x", + "dom7": "^3.0.0", + "nanoid": "^3.2.0", + "slate": "^0.72.0", + "snabbdom": "^3.1.0" + } + }, + "node_modules/ace-builds": { + "version": "1.32.2", + "resolved": "https://registry.npmmirror.com/ace-builds/-/ace-builds-1.32.2.tgz", + "integrity": "sha512-mnJAc803p+7eeDt07r6XI7ufV7VdkpPq4gJZT8Jb3QsowkaBTVy4tdBgPrVT0WbXLm0toyEQXURKSVNj/7dfJQ==" + }, + "node_modules/acorn": { + "version": "8.10.0", + "resolved": "https://registry.npmmirror.com/acorn/-/acorn-8.10.0.tgz", + "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmmirror.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmmirror.com/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmmirror.com/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmmirror.com/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, + "node_modules/array-buffer-byte-length": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/array-buffer-byte-length/-/array-buffer-byte-length-1.0.0.tgz", + "integrity": "sha512-LPuwb2P+NrQw3XhxGc36+XSvuBPopovXYTR9Ew++Du9Yb/bx5AzBfrIsBoj0EZUifjQU+sHL21sseZ3jerWO/A==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "is-array-buffer": "^3.0.1" + } + }, + "node_modules/array-includes": { + "version": "3.1.7", + "resolved": "https://registry.npmmirror.com/array-includes/-/array-includes-3.1.7.tgz", + "integrity": "sha512-dlcsNBIiWhPkHdOEEKnehA+RNUWDc4UqFtnIXU4uuYDPtA4LDkr7qip2p0VvFAEXNDr0yWZ9PJyIRiGjRLQzwQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "get-intrinsic": "^1.2.1", + "is-string": "^1.0.7" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/array.prototype.findlastindex": { + "version": "1.2.3", + "resolved": "https://registry.npmmirror.com/array.prototype.findlastindex/-/array.prototype.findlastindex-1.2.3.tgz", + "integrity": "sha512-LzLoiOMAxvy+Gd3BAq3B7VeIgPdo+Q8hthvKtXybMvRV0jrXfJM/t8mw7nNlpEcVlVUnCnM2KSX4XU5HmpodOA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "es-shim-unscopables": "^1.0.0", + "get-intrinsic": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/array.prototype.flat": { + "version": "1.3.2", + "resolved": "https://registry.npmmirror.com/array.prototype.flat/-/array.prototype.flat-1.3.2.tgz", + "integrity": "sha512-djYB+Zx2vLewY8RWlNCUdHjDXs2XOgm602S9E7P/UpHgfeHL00cRiIF+IN/G/aUJ7kGPb6yO/ErDI5V2s8iycA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "es-shim-unscopables": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/array.prototype.flatmap": { + "version": "1.3.2", + "resolved": "https://registry.npmmirror.com/array.prototype.flatmap/-/array.prototype.flatmap-1.3.2.tgz", + "integrity": "sha512-Ewyx0c9PmpcsByhSW4r+9zDU7sGjFc86qf/kKtuSCRdhfbk0SNLLkaT5qvcHnRGgc5NP/ly/y+qkXkqONX54CQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "es-shim-unscopables": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/arraybuffer.prototype.slice": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/arraybuffer.prototype.slice/-/arraybuffer.prototype.slice-1.0.2.tgz", + "integrity": "sha512-yMBKppFur/fbHu9/6USUe03bZ4knMYiwFBcyiaXB8Go0qNehwX6inYPzK9U0NeQvGxKthcmHcaR8P5MStSRBAw==", + "dev": true, + "dependencies": { + "array-buffer-byte-length": "^1.0.0", + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "get-intrinsic": "^1.2.1", + "is-array-buffer": "^3.0.2", + "is-shared-array-buffer": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/async": { + "version": "3.2.5", + "resolved": "https://registry.npmmirror.com/async/-/async-3.2.5.tgz", + "integrity": "sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==" + }, + "node_modules/async-validator": { + "version": "4.2.5", + "resolved": "https://registry.npmmirror.com/async-validator/-/async-validator-4.2.5.tgz", + "integrity": "sha512-7HhHjtERjqlNbZtqNqy2rckN/SpOOlmDliet+lP7k+eKZEjPk3DgyeU9lIXLdeLz0uBbbVp+9Qdow9wJWgwwfg==" + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmmirror.com/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "node_modules/autoprefixer": { + "version": "10.4.16", + "resolved": "https://registry.npmmirror.com/autoprefixer/-/autoprefixer-10.4.16.tgz", + "integrity": "sha512-7vd3UC6xKp0HLfua5IjZlcXvGAGy7cBAXTg2lyQ/8WpNhd6SiZ8Be+xm3FyBSYJx5GKcpRCzBh7RH4/0dnY+uQ==", + "dev": true, + "dependencies": { + "browserslist": "^4.21.10", + "caniuse-lite": "^1.0.30001538", + "fraction.js": "^4.3.6", + "normalize-range": "^0.1.2", + "picocolors": "^1.0.0", + "postcss-value-parser": "^4.2.0" + }, + "bin": { + "autoprefixer": "bin/autoprefixer" + }, + "engines": { + "node": "^10 || ^12 || >=14" + }, + "peerDependencies": { + "postcss": "^8.1.0" + } + }, + "node_modules/available-typed-arrays": { + "version": "1.0.5", + "resolved": "https://registry.npmmirror.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz", + "integrity": "sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/axios": { + "version": "1.5.1", + "resolved": "https://registry.npmmirror.com/axios/-/axios-1.5.1.tgz", + "integrity": "sha512-Q28iYCWzNHjAm+yEAot5QaAMxhMghWLFVf7rRdwhUI+c2jix2DUXjAHXVi+s1ibs3mjPO/cCgbA++3BjD0vP/A==", + "dependencies": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "node_modules/bignumber.js": { + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.2.tgz", + "integrity": "sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==", + "engines": { + "node": "*" + } + }, + "node_modules/binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmmirror.com/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", + "dev": true + }, + "node_modules/bpmn-js": { + "version": "7.5.0", + "resolved": "https://registry.npmmirror.com/bpmn-js/-/bpmn-js-7.5.0.tgz", + "integrity": "sha512-0ANaE6Bikg1GmkcvO7RK0MQPX+EKYKBc+q7OWk39/16NcCdNZ/4UiRcCr9n0u1VUCIDsSU/jJ79TIZFnV5CNjw==", + "dev": true, + "dependencies": { + "bpmn-moddle": "^7.0.4", + "css.escape": "^1.5.1", + "diagram-js": "^6.8.2", + "diagram-js-direct-editing": "^1.6.1", + "ids": "^1.0.0", + "inherits": "^2.0.4", + "min-dash": "^3.5.2", + "min-dom": "^3.1.3", + "object-refs": "^0.3.0", + "tiny-svg": "^2.2.2" + } + }, + "node_modules/bpmn-js-properties-panel": { + "version": "0.37.6", + "resolved": "https://registry.npmmirror.com/bpmn-js-properties-panel/-/bpmn-js-properties-panel-0.37.6.tgz", + "integrity": "sha512-1rP9r6ItL1gKqXezXnpr9eVsQtdufH6TNqxUs11Q68CtxeBAs0l1wEHw2f01i9ceHHxItmrZUTndqnASi89EYA==", + "dev": true, + "dependencies": { + "@bpmn-io/extract-process-variables": "^0.3.0", + "ids": "^1.0.0", + "inherits": "^2.0.1", + "lodash": "^4.17.20", + "min-dom": "^3.1.3", + "scroll-tabs": "^1.0.1", + "selection-update": "^0.1.2" + }, + "peerDependencies": { + "bpmn-js": "^3.x || ^4.x || ^5.x || ^6.x || ^7.x" + } + }, + "node_modules/bpmn-js-token-simulation": { + "version": "0.10.0", + "resolved": "https://registry.npmmirror.com/bpmn-js-token-simulation/-/bpmn-js-token-simulation-0.10.0.tgz", + "integrity": "sha512-QuZQ/KVXKt9Vl+XENyOBoTW2Aw+uKjuBlKdCJL6El7AyM7DkJ5bZkSYURshId1SkBDdYg2mJ1flSmsrhGuSfwg==", + "dependencies": { + "min-dash": "^3.3.0", + "min-dom": "^0.2.0", + "svg.js": "^2.6.3" + } + }, + "node_modules/bpmn-js-token-simulation/node_modules/min-dom": { + "version": "0.2.0", + "resolved": "https://registry.npmmirror.com/min-dom/-/min-dom-0.2.0.tgz", + "integrity": "sha512-VmxugbnAcVZGqvepjhOA4d4apmrpX8mMaRS+/jo0dI5Yorzrr4Ru9zc9KVALlY/+XakVCb8iQ+PYXljihQcsNw==", + "dependencies": { + "component-classes": "^1.2.3", + "component-closest": "^0.1.4", + "component-delegate": "^0.2.3", + "component-event": "^0.1.4", + "component-matches-selector": "^0.1.5", + "component-query": "^0.0.3", + "domify": "^1.3.1" + } + }, + "node_modules/bpmn-moddle": { + "version": "7.1.3", + "resolved": "https://registry.npmmirror.com/bpmn-moddle/-/bpmn-moddle-7.1.3.tgz", + "integrity": "sha512-ZcBfw0NSOdYTSXFKEn7MOXHItz7VfLZTrFYKO8cK6V8ZzGjCcdiLIOiw7Lctw1PJsihhLiZQS8Htj2xKf+NwCg==", + "dev": true, + "dependencies": { + "min-dash": "^3.5.2", + "moddle": "^5.0.2", + "moddle-xml": "^9.0.6" + } + }, + "node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmmirror.com/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browserslist": { + "version": "4.22.1", + "resolved": "https://registry.npmmirror.com/browserslist/-/browserslist-4.22.1.tgz", + "integrity": "sha512-FEVc202+2iuClEhZhrWy6ZiAcRLvNMyYcxZ8raemul1DYVOVdFsbqckWLdsixQZCpJlwe77Z3UTalE7jsjnKfQ==", + "dev": true, + "dependencies": { + "caniuse-lite": "^1.0.30001541", + "electron-to-chromium": "^1.4.535", + "node-releases": "^2.0.13", + "update-browserslist-db": "^1.0.13" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" + }, + "node_modules/call-bind": { + "version": "1.0.5", + "resolved": "https://registry.npmmirror.com/call-bind/-/call-bind-1.0.5.tgz", + "integrity": "sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.1", + "set-function-length": "^1.1.1" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmmirror.com/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmmirror.com/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "engines": { + "node": ">=6" + } + }, + "node_modules/camunda-bpmn-moddle": { + "version": "4.5.0", + "resolved": "https://registry.npmmirror.com/camunda-bpmn-moddle/-/camunda-bpmn-moddle-4.5.0.tgz", + "integrity": "sha512-g3d2ZaCac52WIXP3kwmYrBEkhm0nnXcWYNj5STDkmiWpDTKUzTj4ZIt38IRpci1Uj3a/rZACvXLnQj8xKFyp/w==", + "dev": true, + "peer": true, + "dependencies": { + "min-dash": "^3.0.0" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001550", + "resolved": "https://registry.npmmirror.com/caniuse-lite/-/caniuse-lite-1.0.30001550.tgz", + "integrity": "sha512-p82WjBYIypO0ukTsd/FG3Xxs+4tFeaY9pfT4amQL8KWtYH7H9nYwReGAbMTJ0hsmRO8IfDtsS6p3ZWj8+1c2RQ==", + "dev": true + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmmirror.com/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmmirror.com/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "dev": true, + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/chokidar/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmmirror.com/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/clipboard": { + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.11.tgz", + "integrity": "sha512-C+0bbOqkezLIsmWSvlsXS0Q0bmkugu7jcfMIACB+RDEntIzQIkdr148we28AfSloQLRdZlYL/QYyrq05j/3Faw==", + "dependencies": { + "good-listener": "^1.2.2", + "select": "^1.1.2", + "tiny-emitter": "^2.0.0" + } + }, + "node_modules/cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmmirror.com/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmmirror.com/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, + "node_modules/component-classes": { + "version": "1.2.6", + "resolved": "https://registry.npmmirror.com/component-classes/-/component-classes-1.2.6.tgz", + "integrity": "sha512-hPFGULxdwugu1QWW3SvVOCUHLzO34+a2J6Wqy0c5ASQkfi9/8nZcBB0ZohaEbXOQlCflMAEMmEWk7u7BVs4koA==", + "dependencies": { + "component-indexof": "0.0.3" + } + }, + "node_modules/component-closest": { + "version": "0.1.4", + "resolved": "https://registry.npmmirror.com/component-closest/-/component-closest-0.1.4.tgz", + "integrity": "sha512-NF9hMj6JKGM5sb6wP/dg7GdJOttaIH9PcTsUNdWcrvu7Kw/5R5swQAFpgaYEHlARrNMyn4Wf7O1PlRej+pt76Q==", + "dependencies": { + "component-matches-selector": "~0.1.5" + } + }, + "node_modules/component-delegate": { + "version": "0.2.4", + "resolved": "https://registry.npmmirror.com/component-delegate/-/component-delegate-0.2.4.tgz", + "integrity": "sha512-OlpcB/6Fi+kXQPh/TfXnSvvmrU04ghz7vcJh/jgLF0Ni+I+E3WGlKJQbBGDa5X+kVUG8WxOgjP+8iWbz902fPg==", + "dependencies": { + "component-closest": "*", + "component-event": "*" + } + }, + "node_modules/component-event": { + "version": "0.1.4", + "resolved": "https://registry.npmmirror.com/component-event/-/component-event-0.1.4.tgz", + "integrity": "sha512-GMwOG8MnUHP1l8DZx1ztFO0SJTFnIzZnBDkXAj8RM2ntV2A6ALlDxgbMY1Fvxlg6WPQ+5IM/a6vg4PEYbjg/Rw==" + }, + "node_modules/component-indexof": { + "version": "0.0.3", + "resolved": "https://registry.npmmirror.com/component-indexof/-/component-indexof-0.0.3.tgz", + "integrity": "sha512-puDQKvx/64HZXb4hBwIcvQLaLgux8o1CbWl39s41hrIIZDl1lJiD5jc22gj3RBeGK0ovxALDYpIbyjqDUUl0rw==" + }, + "node_modules/component-matches-selector": { + "version": "0.1.7", + "resolved": "https://registry.npmmirror.com/component-matches-selector/-/component-matches-selector-0.1.7.tgz", + "integrity": "sha512-Yb2+pVBvrqkQVpPaDBF0DYXRreBveXJNrpJs9FnFu8PF6/5IIcz5oDZqiH9nB5hbD2/TmFVN5ZCxBzqu7yFFYQ==", + "dependencies": { + "component-query": "*", + "global-object": "^1.0.0" + } + }, + "node_modules/component-query": { + "version": "0.0.3", + "resolved": "https://registry.npmmirror.com/component-query/-/component-query-0.0.3.tgz", + "integrity": "sha512-VgebQseT1hz1Ps7vVp2uaSg+N/gsI5ts3AZUSnN6GMA2M82JH7o+qYifWhmVE/e8w/H48SJuA3nA9uX8zRe95Q==" + }, + "node_modules/compute-scroll-into-view": { + "version": "1.0.20", + "resolved": "https://registry.npmmirror.com/compute-scroll-into-view/-/compute-scroll-into-view-1.0.20.tgz", + "integrity": "sha512-UCB0ioiyj8CRjtrvaceBLqqhZCVP+1B8+NWQhmdsm0VXOJtobBCf1dBQmebCCo34qZmUwZfIH2MZLqNHazrfjg==" + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmmirror.com/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + }, + "node_modules/cropperjs": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/cropperjs/-/cropperjs-1.6.1.tgz", + "integrity": "sha512-F4wsi+XkDHCOMrHMYjrTEE4QBOrsHHN5/2VsVAaRq8P7E5z7xQpT75S+f/9WikmBEailas3+yo+6zPIomW+NOA==" + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmmirror.com/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/crypto-js": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz", + "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==" + }, + "node_modules/css-blank-pseudo": { + "version": "3.0.3", + "resolved": "https://registry.npmmirror.com/css-blank-pseudo/-/css-blank-pseudo-3.0.3.tgz", + "integrity": "sha512-VS90XWtsHGqoM0t4KpH053c4ehxZ2E6HtGI7x68YFV0pTo/QmkV/YFA+NnlvK8guxZVNWGQhVNJGC39Q8XF4OQ==", + "dev": true, + "dependencies": { + "postcss-selector-parser": "^6.0.9" + }, + "bin": { + "css-blank-pseudo": "dist/cli.cjs" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/css-has-pseudo": { + "version": "3.0.4", + "resolved": "https://registry.npmmirror.com/css-has-pseudo/-/css-has-pseudo-3.0.4.tgz", + "integrity": "sha512-Vse0xpR1K9MNlp2j5w1pgWIJtm1a8qS0JwS9goFYcImjlHEmywP9VUF05aGBXzGpDJF86QXk4L0ypBmwPhGArw==", + "dev": true, + "dependencies": { + "postcss-selector-parser": "^6.0.9" + }, + "bin": { + "css-has-pseudo": "dist/cli.cjs" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/css-prefers-color-scheme": { + "version": "6.0.3", + "resolved": "https://registry.npmmirror.com/css-prefers-color-scheme/-/css-prefers-color-scheme-6.0.3.tgz", + "integrity": "sha512-4BqMbZksRkJQx2zAjrokiGMd07RqOa2IxIrrN10lyBe9xhn9DEvjUK79J6jkeiv9D9hQFXKb6g1jwU62jziJZA==", + "dev": true, + "bin": { + "css-prefers-color-scheme": "dist/cli.cjs" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/css.escape": { + "version": "1.5.1", + "resolved": "https://registry.npmmirror.com/css.escape/-/css.escape-1.5.1.tgz", + "integrity": "sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==", + "dev": true + }, + "node_modules/cssdb": { + "version": "7.2.0", + "resolved": "https://registry.npmmirror.com/cssdb/-/cssdb-7.2.0.tgz", + "integrity": "sha512-JYlIsE7eKHSi0UNuCyo96YuIDFqvhGgHw4Ck6lsN+DP0Tp8M64UTDT2trGbkMDqnCoEjks7CkS0XcjU0rkvBdg==", + "dev": true + }, + "node_modules/cssesc": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/cssesc/-/cssesc-3.0.0.tgz", + "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", + "dev": true, + "bin": { + "cssesc": "bin/cssesc" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/csstype": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", + "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==" + }, + "node_modules/d": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/d/-/d-1.0.1.tgz", + "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", + "dependencies": { + "es5-ext": "^0.10.50", + "type": "^1.0.1" + } + }, + "node_modules/dayjs": { + "version": "1.11.10", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz", + "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==" + }, + "node_modules/de-indent": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/de-indent/-/de-indent-1.0.2.tgz", + "integrity": "sha512-e/1zu3xH5MQryN2zdVaF0OrdNLUbvWxzMbi+iNA6Bky7l1RoP8a2fIbRocyHclXt/arDrrR6lL3TqFD9pMQTsg==", + "dev": true + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmmirror.com/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmmirror.com/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true + }, + "node_modules/define-data-property": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/define-data-property/-/define-data-property-1.1.1.tgz", + "integrity": "sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.2.1", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/define-properties": { + "version": "1.2.1", + "resolved": "https://registry.npmmirror.com/define-properties/-/define-properties-1.2.1.tgz", + "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", + "dev": true, + "dependencies": { + "define-data-property": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/delegate": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz", + "integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==" + }, + "node_modules/diagram-js": { + "version": "6.8.2", + "resolved": "https://registry.npmmirror.com/diagram-js/-/diagram-js-6.8.2.tgz", + "integrity": "sha512-5EKYHjW2mmGsn9/jSenSkm8cScK5sO9eETBRQNIIzgZjxBDJn6eX964L2d7/vrAW9SeuijGUsztL9+NUinSsNg==", + "dev": true, + "dependencies": { + "css.escape": "^1.5.1", + "didi": "^4.0.0", + "hammerjs": "^2.0.1", + "inherits": "^2.0.1", + "min-dash": "^3.5.0", + "min-dom": "^3.1.2", + "object-refs": "^0.3.0", + "path-intersection": "^2.2.0", + "tiny-svg": "^2.2.1" + } + }, + "node_modules/diagram-js-direct-editing": { + "version": "1.8.0", + "resolved": "https://registry.npmmirror.com/diagram-js-direct-editing/-/diagram-js-direct-editing-1.8.0.tgz", + "integrity": "sha512-B4Xj+PJfgBjbPEzT3uZQEkZI5xHFB0Izc+7BhDFuHidzrEMzQKZrFGdA3PqfWhReHf3dp+iB6Tt11G9eGNjKMw==", + "dev": true, + "dependencies": { + "min-dash": "^3.5.2", + "min-dom": "^3.1.3" + }, + "peerDependencies": { + "diagram-js": "*" + } + }, + "node_modules/didi": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/didi/-/didi-4.0.0.tgz", + "integrity": "sha512-AzMElh8mCHOPWPCWfGjoJRla31fMXUT6+287W5ef3IPmtuBcyG9+MkFS7uPP6v3t2Cl086KwWfRB9mESa0OsHQ==", + "dev": true + }, + "node_modules/dijkstrajs": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.3.tgz", + "integrity": "sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA==" + }, + "node_modules/dir-glob": { + "version": "3.0.1", + "resolved": "https://registry.npmmirror.com/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dev": true, + "dependencies": { + "path-type": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "dev": true, + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + } + }, + "node_modules/dom-zindex": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dom-zindex/-/dom-zindex-1.0.1.tgz", + "integrity": "sha512-M/MERVDZ8hguvjl6MAlLWSLYLS7PzEyXaTb5gEeJ+SF+e9iUC0sdvlzqe91MMDHBoy+nqw7wKcUOrDSyvMCrRg==" + }, + "node_modules/dom7": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/dom7/-/dom7-3.0.0.tgz", + "integrity": "sha512-oNlcUdHsC4zb7Msx7JN3K0Nro1dzJ48knvBOnDPKJ2GV9wl1i5vydJZUSyOfrkKFDZEud/jBsTk92S/VGSAe/g==", + "dependencies": { + "ssr-window": "^3.0.0-alpha.1" + } + }, + "node_modules/domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmmirror.com/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "dev": true + }, + "node_modules/domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmmirror.com/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "dev": true, + "dependencies": { + "domelementtype": "^2.3.0" + }, + "engines": { + "node": ">= 4" + } + }, + "node_modules/domify": { + "version": "1.4.2", + "resolved": "https://registry.npmmirror.com/domify/-/domify-1.4.2.tgz", + "integrity": "sha512-m4yreHcUWHBncGVV7U+yQzc12vIlq0jMrtHZ5mW6dQMiL/7skSYNVX9wqKwOtyO9SGCgevrAFEgOCAHmamHTUA==" + }, + "node_modules/domutils": { + "version": "3.0.1", + "resolved": "https://registry.npmmirror.com/domutils/-/domutils-3.0.1.tgz", + "integrity": "sha512-z08c1l761iKhDFtfXO04C7kTdPBLi41zwOZl00WS8b5eiaebNpY00HKbztwBq+e3vyqWNwWF3mP9YLUeqIrF+Q==", + "dev": true, + "dependencies": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.1" + } + }, + "node_modules/echarts": { + "version": "5.5.0", + "resolved": "https://registry.npmmirror.com/echarts/-/echarts-5.5.0.tgz", + "integrity": "sha512-rNYnNCzqDAPCr4m/fqyUFv7fD9qIsd50S6GDFgO1DxZhncCsNsG7IfUlAlvZe5oSEQxtsjnHiUuppzccry93Xw==", + "dependencies": { + "tslib": "2.3.0", + "zrender": "5.5.0" + } + }, + "node_modules/echarts/node_modules/tslib": { + "version": "2.3.0", + "resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.3.0.tgz", + "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==" + }, + "node_modules/ejs": { + "version": "3.1.9", + "resolved": "https://registry.npmmirror.com/ejs/-/ejs-3.1.9.tgz", + "integrity": "sha512-rC+QVNMJWv+MtPgkt0y+0rVEIdbtxVADApW9JXrUVlzHetgcyczP/E7DJmWJ4fJCZF2cPcBk0laWO9ZHMG3DmQ==", + "dependencies": { + "jake": "^10.8.5" + }, + "bin": { + "ejs": "bin/cli.js" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/electron-to-chromium": { + "version": "1.4.559", + "resolved": "https://registry.npmmirror.com/electron-to-chromium/-/electron-to-chromium-1.4.559.tgz", + "integrity": "sha512-iS7KhLYCSJbdo3rUSkhDTVuFNCV34RKs2UaB9Ecr7VlqzjjWW//0nfsFF5dtDmyXlZQaDYYtID5fjtC/6lpRug==", + "dev": true + }, + "node_modules/element-plus": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/element-plus/-/element-plus-2.7.3.tgz", + "integrity": "sha512-OaqY1kQ2xzNyRFyge3fzM7jqMwux+464RBEqd+ybRV9xPiGxtgnj/sVK4iEbnKnzQIa9XK03DOIFzoToUhu1DA==", + "dependencies": { + "@ctrl/tinycolor": "^3.4.1", + "@element-plus/icons-vue": "^2.3.1", + "@floating-ui/dom": "^1.0.1", + "@popperjs/core": "npm:@sxzz/popperjs-es@^2.11.7", + "@types/lodash": "^4.14.182", + "@types/lodash-es": "^4.17.6", + "@vueuse/core": "^9.1.0", + "async-validator": "^4.2.5", + "dayjs": "^1.11.3", + "escape-html": "^1.0.3", + "lodash": "^4.17.21", + "lodash-es": "^4.17.21", + "lodash-unified": "^1.0.2", + "memoize-one": "^6.0.0", + "normalize-wheel-es": "^1.2.0" + }, + "peerDependencies": { + "vue": "^3.2.0" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "node_modules/encode-utf8": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/encode-utf8/-/encode-utf8-1.0.3.tgz", + "integrity": "sha512-ucAnuBEhUK4boH2HjVYG5Q2mQyPorvv0u/ocS+zhdw0S8AlHYY+GOFhP1Gio5z4icpP2ivFSvhtFjQi8+T9ppw==" + }, + "node_modules/enhanced-resolve": { + "version": "5.15.0", + "resolved": "https://registry.npmmirror.com/enhanced-resolve/-/enhanced-resolve-5.15.0.tgz", + "integrity": "sha512-LXYT42KJ7lpIKECr2mAXIaMldcNCh/7E0KBKOu4KSfkHmP+mZmSs+8V5gBAqisWBy0OO4W5Oyys0GO1Y8KtdKg==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.4", + "tapable": "^2.2.0" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/entities": { + "version": "4.4.0", + "resolved": "https://registry.npmmirror.com/entities/-/entities-4.4.0.tgz", + "integrity": "sha512-oYp7156SP8LkeGD0GF85ad1X9Ai79WtRsZ2gxJqtBuzH+98YUV6jkHEKlZkMbcrjJjIVJNIDP/3WL9wQkoPbWA==", + "dev": true, + "engines": { + "node": ">=0.12" + } + }, + "node_modules/es-abstract": { + "version": "1.22.3", + "resolved": "https://registry.npmmirror.com/es-abstract/-/es-abstract-1.22.3.tgz", + "integrity": "sha512-eiiY8HQeYfYH2Con2berK+To6GrK2RxbPawDkGq4UiCQQfZHb6wX9qQqkbpPqaxQFcl8d9QzZqo0tGE0VcrdwA==", + "dev": true, + "dependencies": { + "array-buffer-byte-length": "^1.0.0", + "arraybuffer.prototype.slice": "^1.0.2", + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.5", + "es-set-tostringtag": "^2.0.1", + "es-to-primitive": "^1.2.1", + "function.prototype.name": "^1.1.6", + "get-intrinsic": "^1.2.2", + "get-symbol-description": "^1.0.0", + "globalthis": "^1.0.3", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0", + "internal-slot": "^1.0.5", + "is-array-buffer": "^3.0.2", + "is-callable": "^1.2.7", + "is-negative-zero": "^2.0.2", + "is-regex": "^1.1.4", + "is-shared-array-buffer": "^1.0.2", + "is-string": "^1.0.7", + "is-typed-array": "^1.1.12", + "is-weakref": "^1.0.2", + "object-inspect": "^1.13.1", + "object-keys": "^1.1.1", + "object.assign": "^4.1.4", + "regexp.prototype.flags": "^1.5.1", + "safe-array-concat": "^1.0.1", + "safe-regex-test": "^1.0.0", + "string.prototype.trim": "^1.2.8", + "string.prototype.trimend": "^1.0.7", + "string.prototype.trimstart": "^1.0.7", + "typed-array-buffer": "^1.0.0", + "typed-array-byte-length": "^1.0.0", + "typed-array-byte-offset": "^1.0.0", + "typed-array-length": "^1.0.4", + "unbox-primitive": "^1.0.2", + "which-typed-array": "^1.1.13" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/es-set-tostringtag/-/es-set-tostringtag-2.0.2.tgz", + "integrity": "sha512-BuDyupZt65P9D2D2vA/zqcI3G5xRsklm5N3xCwuiy+/vKy8i0ifdsQP1sLgO4tZDSCaQUSnmC48khknGMV3D2Q==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.2.2", + "has-tostringtag": "^1.0.0", + "hasown": "^2.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-shim-unscopables": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/es-shim-unscopables/-/es-shim-unscopables-1.0.2.tgz", + "integrity": "sha512-J3yBRXCzDu4ULnQwxyToo/OjdMx6akgVC7K6few0a7F/0wLtmKKN7I73AH5T2836UuXRqN7Qg+IIUw/+YJksRw==", + "dev": true, + "dependencies": { + "hasown": "^2.0.0" + } + }, + "node_modules/es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmmirror.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "dependencies": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es5-ext": { + "version": "0.10.62", + "resolved": "https://registry.npmmirror.com/es5-ext/-/es5-ext-0.10.62.tgz", + "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", + "hasInstallScript": true, + "dependencies": { + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.3", + "next-tick": "^1.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/es6-iterator": { + "version": "2.0.3", + "resolved": "https://registry.npmmirror.com/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==", + "dependencies": { + "d": "1", + "es5-ext": "^0.10.35", + "es6-symbol": "^3.1.1" + } + }, + "node_modules/es6-symbol": { + "version": "3.1.3", + "resolved": "https://registry.npmmirror.com/es6-symbol/-/es6-symbol-3.1.3.tgz", + "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", + "dependencies": { + "d": "^1.0.1", + "ext": "^1.1.2" + } + }, + "node_modules/esbuild": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/esbuild/-/esbuild-0.16.9.tgz", + "integrity": "sha512-gkH83yHyijMSZcZFs1IWew342eMdFuWXmQo3zkDPTre25LIPBJsXryg02M3u8OpTwCJdBkdaQwqKkDLnAsAeLQ==", + "dev": true, + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/android-arm": "0.16.9", + "@esbuild/android-arm64": "0.16.9", + "@esbuild/android-x64": "0.16.9", + "@esbuild/darwin-arm64": "0.16.9", + "@esbuild/darwin-x64": "0.16.9", + "@esbuild/freebsd-arm64": "0.16.9", + "@esbuild/freebsd-x64": "0.16.9", + "@esbuild/linux-arm": "0.16.9", + "@esbuild/linux-arm64": "0.16.9", + "@esbuild/linux-ia32": "0.16.9", + "@esbuild/linux-loong64": "0.16.9", + "@esbuild/linux-mips64el": "0.16.9", + "@esbuild/linux-ppc64": "0.16.9", + "@esbuild/linux-riscv64": "0.16.9", + "@esbuild/linux-s390x": "0.16.9", + "@esbuild/linux-x64": "0.16.9", + "@esbuild/netbsd-x64": "0.16.9", + "@esbuild/openbsd-x64": "0.16.9", + "@esbuild/sunos-x64": "0.16.9", + "@esbuild/win32-arm64": "0.16.9", + "@esbuild/win32-ia32": "0.16.9", + "@esbuild/win32-x64": "0.16.9" + } + }, + "node_modules/escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmmirror.com/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/eslint": { + "version": "8.30.0", + "resolved": "https://registry.npmmirror.com/eslint/-/eslint-8.30.0.tgz", + "integrity": "sha512-MGADB39QqYuzEGov+F/qb18r4i7DohCDOfatHaxI2iGlPuC65bwG2gxgO+7DkyL38dRFaRH7RaRAgU6JKL9rMQ==", + "dev": true, + "dependencies": { + "@eslint/eslintrc": "^1.4.0", + "@humanwhocodes/config-array": "^0.11.8", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", + "ajv": "^6.10.0", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "doctrine": "^3.0.0", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^7.1.1", + "eslint-utils": "^3.0.0", + "eslint-visitor-keys": "^3.3.0", + "espree": "^9.4.0", + "esquery": "^1.4.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "grapheme-splitter": "^1.0.4", + "ignore": "^5.2.0", + "import-fresh": "^3.0.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-sdsl": "^4.1.4", + "js-yaml": "^4.1.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.1", + "regexpp": "^3.2.0", + "strip-ansi": "^6.0.1", + "strip-json-comments": "^3.1.0", + "text-table": "^0.2.0" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/eslint-config-prettier": { + "version": "8.5.0", + "resolved": "https://registry.npmmirror.com/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz", + "integrity": "sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==", + "dev": true, + "bin": { + "eslint-config-prettier": "bin/cli.js" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, + "node_modules/eslint-import-resolver-node": { + "version": "0.3.9", + "resolved": "https://registry.npmmirror.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz", + "integrity": "sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==", + "dev": true, + "dependencies": { + "debug": "^3.2.7", + "is-core-module": "^2.13.0", + "resolve": "^1.22.4" + } + }, + "node_modules/eslint-import-resolver-node/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmmirror.com/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-import-resolver-typescript": { + "version": "3.6.1", + "resolved": "https://registry.npmmirror.com/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.6.1.tgz", + "integrity": "sha512-xgdptdoi5W3niYeuQxKmzVDTATvLYqhpwmykwsh7f6HIOStGWEIL9iqZgQDF9u9OEzrRwR8no5q2VT+bjAujTg==", + "dev": true, + "dependencies": { + "debug": "^4.3.4", + "enhanced-resolve": "^5.12.0", + "eslint-module-utils": "^2.7.4", + "fast-glob": "^3.3.1", + "get-tsconfig": "^4.5.0", + "is-core-module": "^2.11.0", + "is-glob": "^4.0.3" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "*", + "eslint-plugin-import": "*" + } + }, + "node_modules/eslint-module-utils": { + "version": "2.8.0", + "resolved": "https://registry.npmmirror.com/eslint-module-utils/-/eslint-module-utils-2.8.0.tgz", + "integrity": "sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw==", + "dev": true, + "dependencies": { + "debug": "^3.2.7" + }, + "engines": { + "node": ">=4" + }, + "peerDependenciesMeta": { + "eslint": { + "optional": true + } + } + }, + "node_modules/eslint-module-utils/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmmirror.com/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-plugin-import": { + "version": "2.29.0", + "resolved": "https://registry.npmmirror.com/eslint-plugin-import/-/eslint-plugin-import-2.29.0.tgz", + "integrity": "sha512-QPOO5NO6Odv5lpoTkddtutccQjysJuFxoPS7fAHO+9m9udNHvTCPSAMW9zGAYj8lAIdr40I8yPCdUYrncXtrwg==", + "dev": true, + "dependencies": { + "array-includes": "^3.1.7", + "array.prototype.findlastindex": "^1.2.3", + "array.prototype.flat": "^1.3.2", + "array.prototype.flatmap": "^1.3.2", + "debug": "^3.2.7", + "doctrine": "^2.1.0", + "eslint-import-resolver-node": "^0.3.9", + "eslint-module-utils": "^2.8.0", + "hasown": "^2.0.0", + "is-core-module": "^2.13.1", + "is-glob": "^4.0.3", + "minimatch": "^3.1.2", + "object.fromentries": "^2.0.7", + "object.groupby": "^1.0.1", + "object.values": "^1.1.7", + "semver": "^6.3.1", + "tsconfig-paths": "^3.14.2" + }, + "engines": { + "node": ">=4" + }, + "peerDependencies": { + "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" + } + }, + "node_modules/eslint-plugin-import/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/eslint-plugin-import/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmmirror.com/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-plugin-import/node_modules/doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "dev": true, + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/eslint-plugin-import/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/eslint-plugin-import/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmmirror.com/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/eslint-plugin-prettier": { + "version": "4.2.1", + "resolved": "https://registry.npmmirror.com/eslint-plugin-prettier/-/eslint-plugin-prettier-4.2.1.tgz", + "integrity": "sha512-f/0rXLXUt0oFYs8ra4w49wYZBG5GKZpAYsJSm6rnYL5uVDjd+zowwMwVZHnAjf4edNrKpCDYfXDgmRE/Ak7QyQ==", + "dev": true, + "dependencies": { + "prettier-linter-helpers": "^1.0.0" + }, + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "eslint": ">=7.28.0", + "prettier": ">=2.0.0" + }, + "peerDependenciesMeta": { + "eslint-config-prettier": { + "optional": true + } + } + }, + "node_modules/eslint-plugin-vue": { + "version": "9.8.0", + "resolved": "https://registry.npmmirror.com/eslint-plugin-vue/-/eslint-plugin-vue-9.8.0.tgz", + "integrity": "sha512-E/AXwcTzunyzM83C2QqDHxepMzvI2y6x+mmeYHbVDQlKFqmKYvRrhaVixEeeG27uI44p9oKDFiyCRw4XxgtfHA==", + "dev": true, + "dependencies": { + "eslint-utils": "^3.0.0", + "natural-compare": "^1.4.0", + "nth-check": "^2.0.1", + "postcss-selector-parser": "^6.0.9", + "semver": "^7.3.5", + "vue-eslint-parser": "^9.0.1", + "xml-name-validator": "^4.0.0" + }, + "engines": { + "node": "^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.2.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/eslint-scope": { + "version": "7.1.1", + "resolved": "https://registry.npmmirror.com/eslint-scope/-/eslint-scope-7.1.1.tgz", + "integrity": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==", + "dev": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/eslint-utils": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/eslint-utils/-/eslint-utils-3.0.0.tgz", + "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^2.0.0" + }, + "engines": { + "node": "^10.0.0 || ^12.0.0 || >= 14.0.0" + }, + "peerDependencies": { + "eslint": ">=5" + } + }, + "node_modules/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "3.3.0", + "resolved": "https://registry.npmmirror.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", + "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/eslint/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/eslint/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/espree": { + "version": "9.4.1", + "resolved": "https://registry.npmmirror.com/espree/-/espree-9.4.1.tgz", + "integrity": "sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg==", + "dev": true, + "dependencies": { + "acorn": "^8.8.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/esquery": { + "version": "1.4.0", + "resolved": "https://registry.npmmirror.com/esquery/-/esquery-1.4.0.tgz", + "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", + "dev": true, + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmmirror.com/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmmirror.com/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==" + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmmirror.com/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/event-emitter": { + "version": "0.3.5", + "resolved": "https://registry.npmmirror.com/event-emitter/-/event-emitter-0.3.5.tgz", + "integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==", + "dependencies": { + "d": "1", + "es5-ext": "~0.10.14" + } + }, + "node_modules/evtd": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/evtd/-/evtd-0.2.4.tgz", + "integrity": "sha512-qaeGN5bx63s/AXgQo8gj6fBkxge+OoLddLniox5qtLAEY5HSnuSlISXVPxnSae1dWblvTh4/HoMIB+mbMsvZzw==" + }, + "node_modules/ext": { + "version": "1.7.0", + "resolved": "https://registry.npmmirror.com/ext/-/ext-1.7.0.tgz", + "integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==", + "dependencies": { + "type": "^2.7.2" + } + }, + "node_modules/ext/node_modules/type": { + "version": "2.7.2", + "resolved": "https://registry.npmmirror.com/type/-/type-2.7.2.tgz", + "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==" + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmmirror.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "node_modules/fast-diff": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/fast-diff/-/fast-diff-1.2.0.tgz", + "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==", + "dev": true + }, + "node_modules/fast-glob": { + "version": "3.3.1", + "resolved": "https://registry.npmmirror.com/fast-glob/-/fast-glob-3.3.1.tgz", + "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fast-glob/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmmirror.com/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmmirror.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true + }, + "node_modules/fastq": { + "version": "1.14.0", + "resolved": "https://registry.npmmirror.com/fastq/-/fastq-1.14.0.tgz", + "integrity": "sha512-eR2D+V9/ExcbF9ls441yIuN6TI2ED1Y2ZcA5BmMtJsOkWOFRJQ0Jt0g1UwqXJJVAb+V+umH5Dfr8oh4EVP7VVg==", + "dev": true, + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/file-entry-cache": { + "version": "6.0.1", + "resolved": "https://registry.npmmirror.com/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", + "dev": true, + "dependencies": { + "flat-cache": "^3.0.4" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/filelist": { + "version": "1.0.4", + "resolved": "https://registry.npmmirror.com/filelist/-/filelist-1.0.4.tgz", + "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==", + "dependencies": { + "minimatch": "^5.0.1" + } + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmmirror.com/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmmirror.com/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/flat-cache": { + "version": "3.0.4", + "resolved": "https://registry.npmmirror.com/flat-cache/-/flat-cache-3.0.4.tgz", + "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", + "dev": true, + "dependencies": { + "flatted": "^3.1.0", + "rimraf": "^3.0.2" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/flatted": { + "version": "3.2.7", + "resolved": "https://registry.npmmirror.com/flatted/-/flatted-3.2.7.tgz", + "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", + "dev": true + }, + "node_modules/follow-redirects": { + "version": "1.15.3", + "resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.3.tgz", + "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/for-each": { + "version": "0.3.3", + "resolved": "https://registry.npmmirror.com/for-each/-/for-each-0.3.3.tgz", + "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", + "dev": true, + "dependencies": { + "is-callable": "^1.1.3" + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fraction.js": { + "version": "4.3.7", + "resolved": "https://registry.npmmirror.com/fraction.js/-/fraction.js-4.3.7.tgz", + "integrity": "sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmmirror.com/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmmirror.com/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true + }, + "node_modules/function.prototype.name": { + "version": "1.1.6", + "resolved": "https://registry.npmmirror.com/function.prototype.name/-/function.prototype.name-1.1.6.tgz", + "integrity": "sha512-Z5kx79swU5P27WEayXM1tBi5Ze/lbIyiNgU3qyXUOf9b2rgXYyF9Dy9Cx+IQv/Lc8WCG6L82zwUPpSS9hGehIg==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "functions-have-names": "^1.2.3" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/functions-have-names": { + "version": "1.2.3", + "resolved": "https://registry.npmmirror.com/functions-have-names/-/functions-have-names-1.2.3.tgz", + "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", + "dev": true + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-intrinsic": { + "version": "1.2.2", + "resolved": "https://registry.npmmirror.com/get-intrinsic/-/get-intrinsic-1.2.2.tgz", + "integrity": "sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.2", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0" + } + }, + "node_modules/get-symbol-description": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/get-symbol-description/-/get-symbol-description-1.0.0.tgz", + "integrity": "sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/get-tsconfig": { + "version": "4.7.2", + "resolved": "https://registry.npmmirror.com/get-tsconfig/-/get-tsconfig-4.7.2.tgz", + "integrity": "sha512-wuMsz4leaj5hbGgg4IvDU0bqJagpftG5l5cXIAvo8uZrqn0NJqwtfupTN00VnkQJPcIRrxYrm1Ue24btpCha2A==", + "dev": true, + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmmirror.com/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + } + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmmirror.com/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/glob/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/glob/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/global-object": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/global-object/-/global-object-1.0.0.tgz", + "integrity": "sha512-mSPSkY6UsHv6hgW0V2dfWBWTS8TnPnLx3ECVNoWp6rBI2Bg66VYoqGoTFlH/l7XhAZ/l+StYlntXlt87BEeCcg==" + }, + "node_modules/globals": { + "version": "13.19.0", + "resolved": "https://registry.npmmirror.com/globals/-/globals-13.19.0.tgz", + "integrity": "sha512-dkQ957uSRWHw7CFXLUtUHQI3g3aWApYhfNR2O6jn/907riyTYKVBmxYVROkBcY614FSSeSJh7Xm7SrUWCxvJMQ==", + "dev": true, + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/globalthis": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/globalthis/-/globalthis-1.0.3.tgz", + "integrity": "sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA==", + "dev": true, + "dependencies": { + "define-properties": "^1.1.3" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/globby": { + "version": "11.1.0", + "resolved": "https://registry.npmmirror.com/globby/-/globby-11.1.0.tgz", + "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", + "dev": true, + "dependencies": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.9", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^3.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/good-listener": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz", + "integrity": "sha512-goW1b+d9q/HIwbVYZzZ6SsTr4IgE+WA44A0GmPIQstuOrgsFcT7VEJ48nmr9GaRtNu0XTKacFLGnBPAM6Afouw==", + "dependencies": { + "delegate": "^3.1.2" + } + }, + "node_modules/gopd": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/gopd/-/gopd-1.0.1.tgz", + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.1.3" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.10", + "resolved": "https://registry.npmmirror.com/graceful-fs/-/graceful-fs-4.2.10.tgz", + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", + "dev": true + }, + "node_modules/grapheme-splitter": { + "version": "1.0.4", + "resolved": "https://registry.npmmirror.com/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", + "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", + "dev": true + }, + "node_modules/hammerjs": { + "version": "2.0.8", + "resolved": "https://registry.npmmirror.com/hammerjs/-/hammerjs-2.0.8.tgz", + "integrity": "sha512-tSQXBXS/MWQOn/RKckawJ61vvsDpCom87JgxiYdGwHdOa0ht0vzUWDlfioofFCRU0L+6NGDt6XzbgoJvZkMeRQ==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/has-bigints": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/has-bigints/-/has-bigints-1.0.2.tgz", + "integrity": "sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==", + "dev": true + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz", + "integrity": "sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.2.2" + } + }, + "node_modules/has-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/has-proto/-/has-proto-1.0.1.tgz", + "integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/has-tostringtag/-/has-tostringtag-1.0.0.tgz", + "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", + "dev": true, + "dependencies": { + "has-symbols": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/hasown": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/hasown/-/hasown-2.0.0.tgz", + "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true, + "bin": { + "he": "bin/he" + } + }, + "node_modules/highlight.js": { + "version": "11.9.0", + "resolved": "https://registry.npmmirror.com/highlight.js/-/highlight.js-11.9.0.tgz", + "integrity": "sha512-fJ7cW7fQGCYAkgv4CPfwFHrfd/cLS4Hau96JuJ+ZTOWhjnhoeN1ub1tFmALm/+lW5z4WCAuAV9bm05AP0mS6Gw==", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/html-void-elements": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/html-void-elements/-/html-void-elements-2.0.1.tgz", + "integrity": "sha512-0quDb7s97CfemeJAnW9wC0hw78MtW7NU3hqtCD75g2vFlDLt36llsYD7uB7SUzojLMP24N5IatXf7ylGXiGG9A==" + }, + "node_modules/htmlparser2": { + "version": "8.0.1", + "resolved": "https://registry.npmmirror.com/htmlparser2/-/htmlparser2-8.0.1.tgz", + "integrity": "sha512-4lVbmc1diZC7GUJQtRQ5yBAeUCL1exyMwmForWkRLnwyzWBFxN633SALPMGYaWZvKe9j1pRZJpauvmxENSp/EA==", + "dev": true, + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "domutils": "^3.0.1", + "entities": "^4.3.0" + } + }, + "node_modules/i18next": { + "version": "20.6.1", + "resolved": "https://registry.npmmirror.com/i18next/-/i18next-20.6.1.tgz", + "integrity": "sha512-yCMYTMEJ9ihCwEQQ3phLo7I/Pwycf8uAx+sRHwwk5U9Aui/IZYgQRyMqXafQOw5QQ7DM1Z+WyEXWIqSuJHhG2A==", + "dependencies": { + "@babel/runtime": "^7.12.0" + } + }, + "node_modules/ids": { + "version": "1.0.5", + "resolved": "https://registry.npmmirror.com/ids/-/ids-1.0.5.tgz", + "integrity": "sha512-XQ0yom/4KWTL29sLG+tyuycy7UmeaM/79GRtSJq6IG9cJGIPeBz5kwDCguie3TwxaMNIc3WtPi0cTa1XYHicpw==", + "dev": true + }, + "node_modules/ignore": { + "version": "5.2.2", + "resolved": "https://registry.npmmirror.com/ignore/-/ignore-5.2.2.tgz", + "integrity": "sha512-m1MJSy4Z2NAcyhoYpxQeBsc1ZdNQwYjN0wGbLBlnVArdJ90Gtr8IhNSfZZcCoR0fM/0E0BJ0mf1KnLNDOCJP4w==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/immer": { + "version": "9.0.21", + "resolved": "https://registry.npmmirror.com/immer/-/immer-9.0.21.tgz", + "integrity": "sha512-bc4NBHqOqSfRW7POMkHd51LvClaeMXpm8dx0e8oE2GORbq5aRK7Bxl4FyzVLdGtLmvLKL7BTDBG5ACQm4HWjTA==" + }, + "node_modules/immutable": { + "version": "4.1.0", + "resolved": "https://registry.npmmirror.com/immutable/-/immutable-4.1.0.tgz", + "integrity": "sha512-oNkuqVTA8jqG1Q6c+UglTOD1xhC1BtjKI7XkCXRkZHrN5m18/XsnUp8Q89GkQO/z+0WjonSvl0FLhDYftp46nQ==", + "dev": true + }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmmirror.com/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmmirror.com/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/indexof": { + "version": "0.0.1", + "resolved": "https://registry.npmmirror.com/indexof/-/indexof-0.0.1.tgz", + "integrity": "sha512-i0G7hLJ1z0DE8dsqJa2rycj9dBmNKgXBvotXtZYXakU9oivfB9Uj2ZBC27qqef2U58/ZLwalxa1X/RDCdkHtVg==", + "dev": true + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmmirror.com/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmmirror.com/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/internal-slot": { + "version": "1.0.6", + "resolved": "https://registry.npmmirror.com/internal-slot/-/internal-slot-1.0.6.tgz", + "integrity": "sha512-Xj6dv+PsbtwyPpEflsejS+oIZxmMlV44zAhG479uYu89MsjcYOhCFnNyKrkJrihbsiasQyY0afoCl/9BLR65bg==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.2.2", + "hasown": "^2.0.0", + "side-channel": "^1.0.4" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/is-array-buffer": { + "version": "3.0.2", + "resolved": "https://registry.npmmirror.com/is-array-buffer/-/is-array-buffer-3.0.2.tgz", + "integrity": "sha512-y+FyyR/w8vfIRq4eQcM1EYgSTnmHXPqaF+IgzgraytCFq5Xh8lllDVmAZolPJiZttZLeFSINPYMaEJ7/vWUa1w==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.2.0", + "is-typed-array": "^1.1.10" + } + }, + "node_modules/is-bigint": { + "version": "1.0.4", + "resolved": "https://registry.npmmirror.com/is-bigint/-/is-bigint-1.0.4.tgz", + "integrity": "sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==", + "dev": true, + "dependencies": { + "has-bigints": "^1.0.1" + } + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-boolean-object": { + "version": "1.1.2", + "resolved": "https://registry.npmmirror.com/is-boolean-object/-/is-boolean-object-1.1.2.tgz", + "integrity": "sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/is-callable": { + "version": "1.2.7", + "resolved": "https://registry.npmmirror.com/is-callable/-/is-callable-1.2.7.tgz", + "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/is-core-module": { + "version": "2.13.1", + "resolved": "https://registry.npmmirror.com/is-core-module/-/is-core-module-2.13.1.tgz", + "integrity": "sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==", + "dev": true, + "dependencies": { + "hasown": "^2.0.0" + } + }, + "node_modules/is-date-object": { + "version": "1.0.5", + "resolved": "https://registry.npmmirror.com/is-date-object/-/is-date-object-1.0.5.tgz", + "integrity": "sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==", + "dev": true, + "dependencies": { + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmmirror.com/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmmirror.com/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-hotkey": { + "version": "0.2.0", + "resolved": "https://registry.npmmirror.com/is-hotkey/-/is-hotkey-0.2.0.tgz", + "integrity": "sha512-UknnZK4RakDmTgz4PI1wIph5yxSs/mvChWs9ifnlXsKuXgWmOkY/hAE0H/k2MIqH0RlRye0i1oC07MCRSD28Mw==" + }, + "node_modules/is-negative-zero": { + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/is-negative-zero/-/is-negative-zero-2.0.2.tgz", + "integrity": "sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmmirror.com/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-number-object": { + "version": "1.0.7", + "resolved": "https://registry.npmmirror.com/is-number-object/-/is-number-object-1.0.7.tgz", + "integrity": "sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==", + "dev": true, + "dependencies": { + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmmirror.com/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-plain-object": { + "version": "5.0.0", + "resolved": "https://registry.npmmirror.com/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-regex": { + "version": "1.1.4", + "resolved": "https://registry.npmmirror.com/is-regex/-/is-regex-1.1.4.tgz", + "integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/is-shared-array-buffer": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz", + "integrity": "sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2" + } + }, + "node_modules/is-string": { + "version": "1.0.7", + "resolved": "https://registry.npmmirror.com/is-string/-/is-string-1.0.7.tgz", + "integrity": "sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==", + "dev": true, + "dependencies": { + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/is-symbol": { + "version": "1.0.4", + "resolved": "https://registry.npmmirror.com/is-symbol/-/is-symbol-1.0.4.tgz", + "integrity": "sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==", + "dev": true, + "dependencies": { + "has-symbols": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/is-typed-array": { + "version": "1.1.12", + "resolved": "https://registry.npmmirror.com/is-typed-array/-/is-typed-array-1.1.12.tgz", + "integrity": "sha512-Z14TF2JNG8Lss5/HMqt0//T9JeHXttXy5pH/DBU4vi98ozO2btxzq9MwYDZYnKwU8nRsz/+GVFVRDq3DkVuSPg==", + "dev": true, + "dependencies": { + "which-typed-array": "^1.1.11" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/is-url": { + "version": "1.2.4", + "resolved": "https://registry.npmmirror.com/is-url/-/is-url-1.2.4.tgz", + "integrity": "sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww==" + }, + "node_modules/is-weakref": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/is-weakref/-/is-weakref-1.0.2.tgz", + "integrity": "sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2" + } + }, + "node_modules/isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmmirror.com/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "dev": true + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, + "node_modules/jake": { + "version": "10.8.7", + "resolved": "https://registry.npmmirror.com/jake/-/jake-10.8.7.tgz", + "integrity": "sha512-ZDi3aP+fG/LchyBzUM804VjddnwfSfsdeYkwt8NcbKRvo4rFkjhs456iLFn3k2ZUWvNe4i48WACDbza8fhq2+w==", + "dependencies": { + "async": "^3.2.3", + "chalk": "^4.0.2", + "filelist": "^1.0.4", + "minimatch": "^3.1.2" + }, + "bin": { + "jake": "bin/cli.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/jake/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/jake/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/js-sdsl": { + "version": "4.2.0", + "resolved": "https://registry.npmmirror.com/js-sdsl/-/js-sdsl-4.2.0.tgz", + "integrity": "sha512-dyBIzQBDkCqCu+0upx25Y2jGdbTGxE9fshMsCdK0ViOongpV+n5tXRcZY9v7CaVQ79AGS9KA1KHtojxiM7aXSQ==", + "dev": true + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmmirror.com/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/jsbarcode": { + "version": "3.11.5", + "resolved": "https://registry.npmjs.org/jsbarcode/-/jsbarcode-3.11.5.tgz", + "integrity": "sha512-zv3KsH51zD00I/LrFzFSM6dst7rDn0vIMzaiZFL7qusTjPZiPtxg3zxetp0RR7obmjTw4f6NyGgbdkBCgZUIrA==", + "bin": { + "auto.js": "bin/barcodes/CODE128/auto.js", + "Barcode.js": "bin/barcodes/Barcode.js", + "barcodes": "bin/barcodes", + "canvas.js": "bin/renderers/canvas.js", + "checksums.js": "bin/barcodes/MSI/checksums.js", + "codabar": "bin/barcodes/codabar", + "CODE128": "bin/barcodes/CODE128", + "CODE128_AUTO.js": "bin/barcodes/CODE128/CODE128_AUTO.js", + "CODE128.js": "bin/barcodes/CODE128/CODE128.js", + "CODE128A.js": "bin/barcodes/CODE128/CODE128A.js", + "CODE128B.js": "bin/barcodes/CODE128/CODE128B.js", + "CODE128C.js": "bin/barcodes/CODE128/CODE128C.js", + "CODE39": "bin/barcodes/CODE39", + "constants.js": "bin/barcodes/ITF/constants.js", + "defaults.js": "bin/options/defaults.js", + "EAN_UPC": "bin/barcodes/EAN_UPC", + "EAN.js": "bin/barcodes/EAN_UPC/EAN.js", + "EAN13.js": "bin/barcodes/EAN_UPC/EAN13.js", + "EAN2.js": "bin/barcodes/EAN_UPC/EAN2.js", + "EAN5.js": "bin/barcodes/EAN_UPC/EAN5.js", + "EAN8.js": "bin/barcodes/EAN_UPC/EAN8.js", + "encoder.js": "bin/barcodes/EAN_UPC/encoder.js", + "ErrorHandler.js": "bin/exceptions/ErrorHandler.js", + "exceptions": "bin/exceptions", + "exceptions.js": "bin/exceptions/exceptions.js", + "fixOptions.js": "bin/help/fixOptions.js", + "GenericBarcode": "bin/barcodes/GenericBarcode", + "getOptionsFromElement.js": "bin/help/getOptionsFromElement.js", + "getRenderProperties.js": "bin/help/getRenderProperties.js", + "help": "bin/help", + "index.js": "bin/renderers/index.js", + "index.tmp.js": "bin/barcodes/index.tmp.js", + "ITF": "bin/barcodes/ITF", + "ITF.js": "bin/barcodes/ITF/ITF.js", + "ITF14.js": "bin/barcodes/ITF/ITF14.js", + "JsBarcode.js": "bin/JsBarcode.js", + "linearizeEncodings.js": "bin/help/linearizeEncodings.js", + "merge.js": "bin/help/merge.js", + "MSI": "bin/barcodes/MSI", + "MSI.js": "bin/barcodes/MSI/MSI.js", + "MSI10.js": "bin/barcodes/MSI/MSI10.js", + "MSI1010.js": "bin/barcodes/MSI/MSI1010.js", + "MSI11.js": "bin/barcodes/MSI/MSI11.js", + "MSI1110.js": "bin/barcodes/MSI/MSI1110.js", + "object.js": "bin/renderers/object.js", + "options": "bin/options", + "optionsFromStrings.js": "bin/help/optionsFromStrings.js", + "pharmacode": "bin/barcodes/pharmacode", + "renderers": "bin/renderers", + "shared.js": "bin/renderers/shared.js", + "svg.js": "bin/renderers/svg.js", + "UPC.js": "bin/barcodes/EAN_UPC/UPC.js", + "UPCE.js": "bin/barcodes/EAN_UPC/UPCE.js" + } + }, + "node_modules/jsencrypt": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/jsencrypt/-/jsencrypt-3.3.2.tgz", + "integrity": "sha512-arQR1R1ESGdAxY7ZheWr12wCaF2yF47v5qpB76TtV64H1pyGudk9Hvw8Y9tb/FiTIaaTRUyaSnm5T/Y53Ghm/A==" + }, + "node_modules/json-bigint": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz", + "integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==", + "dependencies": { + "bignumber.js": "^9.0.0" + } + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmmirror.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true + }, + "node_modules/json5": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", + "dev": true, + "dependencies": { + "minimist": "^1.2.0" + }, + "bin": { + "json5": "lib/cli.js" + } + }, + "node_modules/jsonc-parser": { + "version": "3.2.0", + "resolved": "https://registry.npmmirror.com/jsonc-parser/-/jsonc-parser-3.2.0.tgz", + "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==", + "dev": true + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmmirror.com/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/local-pkg": { + "version": "0.4.3", + "resolved": "https://registry.npmmirror.com/local-pkg/-/local-pkg-0.4.3.tgz", + "integrity": "sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==", + "dev": true, + "engines": { + "node": ">=14" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmmirror.com/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmmirror.com/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "node_modules/lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmmirror.com/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==" + }, + "node_modules/lodash-unified": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/lodash-unified/-/lodash-unified-1.0.3.tgz", + "integrity": "sha512-WK9qSozxXOD7ZJQlpSqOT+om2ZfcT4yO+03FuzAHD0wF6S0l0090LRPDx3vhTTLZ8cFKpBn+IOcVXK6qOcIlfQ==", + "peerDependencies": { + "@types/lodash-es": "*", + "lodash": "*", + "lodash-es": "*" + } + }, + "node_modules/lodash.camelcase": { + "version": "4.3.0", + "resolved": "https://registry.npmmirror.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", + "integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==" + }, + "node_modules/lodash.clonedeep": { + "version": "4.5.0", + "resolved": "https://registry.npmmirror.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==" + }, + "node_modules/lodash.debounce": { + "version": "4.0.8", + "resolved": "https://registry.npmmirror.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz", + "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==" + }, + "node_modules/lodash.foreach": { + "version": "4.5.0", + "resolved": "https://registry.npmmirror.com/lodash.foreach/-/lodash.foreach-4.5.0.tgz", + "integrity": "sha512-aEXTF4d+m05rVOAUG3z4vZZ4xVexLKZGF0lIxuHZ1Hplpk/3B6Z1+/ICICYRLm7c41Z2xiejbkCkJoTlypoXhQ==" + }, + "node_modules/lodash.isequal": { + "version": "4.5.0", + "resolved": "https://registry.npmmirror.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz", + "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==" + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmmirror.com/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true + }, + "node_modules/lodash.throttle": { + "version": "4.1.1", + "resolved": "https://registry.npmmirror.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz", + "integrity": "sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ==" + }, + "node_modules/lodash.toarray": { + "version": "4.4.0", + "resolved": "https://registry.npmmirror.com/lodash.toarray/-/lodash.toarray-4.4.0.tgz", + "integrity": "sha512-QyffEA3i5dma5q2490+SgCvDN0pXLmRGSyAANuVi0HQ01Pkfr9fuoKQW8wm1wGBnJITs/mS7wQvS6VshUEBFCw==" + }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmmirror.com/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/magic-string": { + "version": "0.30.5", + "resolved": "https://registry.npmmirror.com/magic-string/-/magic-string-0.30.5.tgz", + "integrity": "sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.15" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/matches-selector": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/matches-selector/-/matches-selector-1.2.0.tgz", + "integrity": "sha512-c4vLwYWyl+Ji+U43eU/G5FwxWd4ZH0ePUsFs5y0uwD9HUEFBXUQ1zUUan+78IpRD+y4pUfG0nAzNM292K7ItvA==", + "dev": true + }, + "node_modules/memoize-one": { + "version": "6.0.0", + "resolved": "https://registry.npmmirror.com/memoize-one/-/memoize-one-6.0.0.tgz", + "integrity": "sha512-rkpe71W0N0c0Xz6QD0eJETuWAJGnJ9afsl1srmwPrI+yBCkge5EycXXbYRyvL29zZVUWQCY7InPRCv3GDXuZNw==" + }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmmirror.com/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmmirror.com/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dev": true, + "dependencies": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-match": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/mime-match/-/mime-match-1.0.2.tgz", + "integrity": "sha512-VXp/ugGDVh3eCLOBCiHZMYWQaTNUHv2IJrut+yXA6+JbLPXHglHwfS/5A5L0ll+jkCY7fIzRJcH6OIunF+c6Cg==", + "dependencies": { + "wildcard": "^1.1.0" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmmirror.com/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/min-dash": { + "version": "3.8.1", + "resolved": "https://registry.npmmirror.com/min-dash/-/min-dash-3.8.1.tgz", + "integrity": "sha512-evumdlmIlg9mbRVPbC4F5FuRhNmcMS5pvuBUbqb1G9v09Ro0ImPEgz5n3khir83lFok1inKqVDjnKEg3GpDxQg==" + }, + "node_modules/min-dom": { + "version": "3.2.1", + "resolved": "https://registry.npmmirror.com/min-dom/-/min-dom-3.2.1.tgz", + "integrity": "sha512-v6YCmnDzxk4rRJntWTUiwggLupPw/8ZSRqUq0PDaBwVZEO/wYzCH4SKVBV+KkEvf3u0XaWHly5JEosPtqRATZA==", + "dev": true, + "dependencies": { + "component-event": "^0.1.4", + "domify": "^1.3.1", + "indexof": "0.0.1", + "matches-selector": "^1.2.0", + "min-dash": "^3.8.1" + } + }, + "node_modules/minimatch": { + "version": "5.1.1", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-5.1.1.tgz", + "integrity": "sha512-362NP+zlprccbEt/SkxKfRMHnNY85V74mVnpUpNyr3F35covl09Kec7/sEFLt3RA4oXmewtoaanoIf67SE5Y5g==", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/minimist": { + "version": "1.2.7", + "resolved": "https://registry.npmmirror.com/minimist/-/minimist-1.2.7.tgz", + "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==", + "dev": true + }, + "node_modules/mitt": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/mitt/-/mitt-1.2.0.tgz", + "integrity": "sha512-r6lj77KlwqLhIUku9UWYes7KJtsczvolZkzp8hbaDPPaE24OmWl5s539Mytlj22siEQKosZ26qCBgda2PKwoJw==", + "dev": true + }, + "node_modules/mlly": { + "version": "1.4.2", + "resolved": "https://registry.npmmirror.com/mlly/-/mlly-1.4.2.tgz", + "integrity": "sha512-i/Ykufi2t1EZ6NaPLdfnZk2AX8cs0d+mTzVKuPfqPKPatxLApaBoxJQ9x1/uckXtrS/U5oisPMDkNs0yQTaBRg==", + "dev": true, + "dependencies": { + "acorn": "^8.10.0", + "pathe": "^1.1.1", + "pkg-types": "^1.0.3", + "ufo": "^1.3.0" + } + }, + "node_modules/moddle": { + "version": "5.0.4", + "resolved": "https://registry.npmmirror.com/moddle/-/moddle-5.0.4.tgz", + "integrity": "sha512-Kjb+hjuzO+YlojNGxEUXvdhLYTHTtAABDlDcJTtTcn5MbJF9Zkv4I1Fyvp3Ypmfgg1EfHDZ3PsCQTuML9JD6wg==", + "dev": true, + "dependencies": { + "min-dash": "^3.0.0" + } + }, + "node_modules/moddle-xml": { + "version": "9.0.6", + "resolved": "https://registry.npmmirror.com/moddle-xml/-/moddle-xml-9.0.6.tgz", + "integrity": "sha512-tl0reHpsY/aKlLGhXeFlQWlYAQHFxTkFqC8tq8jXRYpQSnLVw13T6swMaourLd7EXqHdWsc+5ggsB+fEep6xZQ==", + "dev": true, + "dependencies": { + "min-dash": "^3.5.2", + "moddle": "^5.0.2", + "saxen": "^8.1.2" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmmirror.com/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/muggle-string": { + "version": "0.1.0", + "resolved": "https://registry.npmmirror.com/muggle-string/-/muggle-string-0.1.0.tgz", + "integrity": "sha512-Tr1knR3d2mKvvWthlk7202rywKbiOm4rVFLsfAaSIhJ6dt9o47W4S+JMtWhd/PW9Wrdew2/S2fSvhz3E2gkfEg==", + "dev": true + }, + "node_modules/namespace-emitter": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/namespace-emitter/-/namespace-emitter-2.0.1.tgz", + "integrity": "sha512-N/sMKHniSDJBjfrkbS/tpkPj4RAbvW3mr8UAzvlMHyun93XEm83IAvhWtJVHo+RHn/oO8Job5YN4b+wRjSVp5g==" + }, + "node_modules/nanoid": { + "version": "3.3.6", + "resolved": "https://registry.npmmirror.com/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmmirror.com/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true + }, + "node_modules/natural-compare-lite": { + "version": "1.4.0", + "resolved": "https://registry.npmmirror.com/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", + "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", + "dev": true + }, + "node_modules/next-tick": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/next-tick/-/next-tick-1.1.0.tgz", + "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" + }, + "node_modules/node-releases": { + "version": "2.0.13", + "resolved": "https://registry.npmmirror.com/node-releases/-/node-releases-2.0.13.tgz", + "integrity": "sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==", + "dev": true + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/normalize-range": { + "version": "0.1.2", + "resolved": "https://registry.npmmirror.com/normalize-range/-/normalize-range-0.1.2.tgz", + "integrity": "sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/normalize-wheel-es": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/normalize-wheel-es/-/normalize-wheel-es-1.2.0.tgz", + "integrity": "sha512-Wj7+EJQ8mSuXr2iWfnujrimU35R2W4FAErEyTmJoJ7ucwTn2hOUSsRehMb5RSYkxXGTM7Y9QpvPmp++w5ftoJw==" + }, + "node_modules/nth-check": { + "version": "2.1.1", + "resolved": "https://registry.npmmirror.com/nth-check/-/nth-check-2.1.1.tgz", + "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", + "dev": true, + "dependencies": { + "boolbase": "^1.0.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.1", + "resolved": "https://registry.npmmirror.com/object-inspect/-/object-inspect-1.13.1.tgz", + "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==", + "dev": true + }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object-refs": { + "version": "0.3.0", + "resolved": "https://registry.npmmirror.com/object-refs/-/object-refs-0.3.0.tgz", + "integrity": "sha512-eP0ywuoWOaDoiake/6kTJlPJhs+k0qNm4nYRzXLNHj6vh+5M3i9R1epJTdxIPGlhWc4fNRQ7a6XJNCX+/L4FOQ==", + "dev": true + }, + "node_modules/object.assign": { + "version": "4.1.4", + "resolved": "https://registry.npmmirror.com/object.assign/-/object.assign-4.1.4.tgz", + "integrity": "sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "has-symbols": "^1.0.3", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object.fromentries": { + "version": "2.0.7", + "resolved": "https://registry.npmmirror.com/object.fromentries/-/object.fromentries-2.0.7.tgz", + "integrity": "sha512-UPbPHML6sL8PI/mOqPwsH4G6iyXcCGzLin8KvEPenOZN5lpCNBZZQ+V62vdjB1mQHrmqGQt5/OJzemUA+KJmEA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object.groupby": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/object.groupby/-/object.groupby-1.0.1.tgz", + "integrity": "sha512-HqaQtqLnp/8Bn4GL16cj+CUYbnpe1bh0TtEaWvybszDG4tgxCJuRpV8VGuvNaI1fAnI4lUJzDG55MXcOH4JZcQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "get-intrinsic": "^1.2.1" + } + }, + "node_modules/object.values": { + "version": "1.1.7", + "resolved": "https://registry.npmmirror.com/object.values/-/object.values-1.1.7.tgz", + "integrity": "sha512-aU6xnDFYT3x17e/f0IiiwlGPTy2jzMySGfUB4fq6z7CV8l85CWHDk5ErhyhpfDHhrOMwGFhSQkhMGHaIotA6Ng==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmmirror.com/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/optionator": { + "version": "0.9.1", + "resolved": "https://registry.npmmirror.com/optionator/-/optionator-0.9.1.tgz", + "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "dev": true, + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.3" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmmirror.com/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmmirror.com/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmmirror.com/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "engines": { + "node": ">=6" + } + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-intersection": { + "version": "2.2.1", + "resolved": "https://registry.npmmirror.com/path-intersection/-/path-intersection-2.2.1.tgz", + "integrity": "sha512-9u8xvMcSfuOiStv9bPdnRJQhGQXLKurew94n4GPQCdH1nj9QKC9ObbNoIpiRq8skiOBxKkt277PgOoFgAt3/rA==", + "dev": true + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmmirror.com/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmmirror.com/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "node_modules/path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/pathe": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/pathe/-/pathe-1.1.1.tgz", + "integrity": "sha512-d+RQGp0MAYTIaDBIMmOfMwz3E+LOZnxx1HZd5R18mmCZY0QBlK0LDZfPc8FW8Ed2DlvsuE6PRjroDY+wg4+j/Q==", + "dev": true + }, + "node_modules/picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/pinia": { + "version": "2.1.6", + "resolved": "https://registry.npmmirror.com/pinia/-/pinia-2.1.6.tgz", + "integrity": "sha512-bIU6QuE5qZviMmct5XwCesXelb5VavdOWKWaB17ggk++NUwQWWbP5YnsONTk3b752QkW9sACiR81rorpeOMSvQ==", + "dependencies": { + "@vue/devtools-api": "^6.5.0", + "vue-demi": ">=0.14.5" + }, + "peerDependencies": { + "@vue/composition-api": "^1.4.0", + "typescript": ">=4.4.4", + "vue": "^2.6.14 || ^3.3.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + }, + "typescript": { + "optional": true + } + } + }, + "node_modules/pinia-plugin-persist": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/pinia-plugin-persist/-/pinia-plugin-persist-1.0.0.tgz", + "integrity": "sha512-M4hBBd8fz/GgNmUPaaUsC29y1M09lqbXrMAHcusVoU8xlQi1TqgkWnnhvMikZwr7Le/hVyMx8KUcumGGrR6GVw==", + "dependencies": { + "vue-demi": "^0.12.1" + }, + "peerDependencies": { + "@vue/composition-api": "^1.0.0", + "pinia": "^2.0.0", + "vue": "^2.0.0 || >=3.0.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + } + } + }, + "node_modules/pinia-plugin-persist/node_modules/vue-demi": { + "version": "0.12.5", + "resolved": "https://registry.npmmirror.com/vue-demi/-/vue-demi-0.12.5.tgz", + "integrity": "sha512-BREuTgTYlUr0zw0EZn3hnhC3I6gPWv+Kwh4MCih6QcAeaTlaIX0DwOVN0wHej7hSvDPecz4jygy/idsgKfW58Q==", + "hasInstallScript": true, + "bin": { + "vue-demi-fix": "bin/vue-demi-fix.js", + "vue-demi-switch": "bin/vue-demi-switch.js" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "@vue/composition-api": "^1.0.0-rc.1", + "vue": "^3.0.0-0 || ^2.6.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + } + } + }, + "node_modules/pinia/node_modules/vue-demi": { + "version": "0.14.6", + "resolved": "https://registry.npmmirror.com/vue-demi/-/vue-demi-0.14.6.tgz", + "integrity": "sha512-8QA7wrYSHKaYgUxDA5ZC24w+eHm3sYCbp0EzcDwKqN3p6HqtTCGR/GVsPyZW92unff4UlcSh++lmqDWN3ZIq4w==", + "hasInstallScript": true, + "bin": { + "vue-demi-fix": "bin/vue-demi-fix.js", + "vue-demi-switch": "bin/vue-demi-switch.js" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "@vue/composition-api": "^1.0.0-rc.1", + "vue": "^3.0.0-0 || ^2.6.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + } + } + }, + "node_modules/pkg-types": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/pkg-types/-/pkg-types-1.0.3.tgz", + "integrity": "sha512-nN7pYi0AQqJnoLPC9eHFQ8AcyaixBUOwvqc5TDnIKCMEE6I0y8P7OKA7fPexsXGCGxQDl/cmrLAp26LhcwxZ4A==", + "dev": true, + "dependencies": { + "jsonc-parser": "^3.2.0", + "mlly": "^1.2.0", + "pathe": "^1.1.0" + } + }, + "node_modules/pngjs": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz", + "integrity": "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==", + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/postcss": { + "version": "8.4.31", + "resolved": "https://registry.npmmirror.com/postcss/-/postcss-8.4.31.tgz", + "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", + "dependencies": { + "nanoid": "^3.3.6", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/postcss-attribute-case-insensitive": { + "version": "5.0.2", + "resolved": "https://registry.npmmirror.com/postcss-attribute-case-insensitive/-/postcss-attribute-case-insensitive-5.0.2.tgz", + "integrity": "sha512-XIidXV8fDr0kKt28vqki84fRK8VW8eTuIa4PChv2MqKuT6C9UjmSKzen6KaWhWEoYvwxFCa7n/tC1SZ3tyq4SQ==", + "dev": true, + "dependencies": { + "postcss-selector-parser": "^6.0.10" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/postcss-clamp": { + "version": "4.1.0", + "resolved": "https://registry.npmmirror.com/postcss-clamp/-/postcss-clamp-4.1.0.tgz", + "integrity": "sha512-ry4b1Llo/9zz+PKC+030KUnPITTJAHeOwjfAyyB60eT0AorGLdzp52s31OsPRHRf8NchkgFoG2y6fCfn1IV1Ow==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": ">=7.6.0" + }, + "peerDependencies": { + "postcss": "^8.4.6" + } + }, + "node_modules/postcss-color-functional-notation": { + "version": "4.2.4", + "resolved": "https://registry.npmmirror.com/postcss-color-functional-notation/-/postcss-color-functional-notation-4.2.4.tgz", + "integrity": "sha512-2yrTAUZUab9s6CpxkxC4rVgFEVaR6/2Pipvi6qcgvnYiVqZcbDHEoBDhrXzyb7Efh2CCfHQNtcqWcIruDTIUeg==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/postcss-color-hex-alpha": { + "version": "8.0.4", + "resolved": "https://registry.npmmirror.com/postcss-color-hex-alpha/-/postcss-color-hex-alpha-8.0.4.tgz", + "integrity": "sha512-nLo2DCRC9eE4w2JmuKgVA3fGL3d01kGq752pVALF68qpGLmx2Qrk91QTKkdUqqp45T1K1XV8IhQpcu1hoAQflQ==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-color-rebeccapurple": { + "version": "7.1.1", + "resolved": "https://registry.npmmirror.com/postcss-color-rebeccapurple/-/postcss-color-rebeccapurple-7.1.1.tgz", + "integrity": "sha512-pGxkuVEInwLHgkNxUc4sdg4g3py7zUeCQ9sMfwyHAT+Ezk8a4OaaVZ8lIY5+oNqA/BXXgLyXv0+5wHP68R79hg==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/postcss-custom-media": { + "version": "8.0.2", + "resolved": "https://registry.npmmirror.com/postcss-custom-media/-/postcss-custom-media-8.0.2.tgz", + "integrity": "sha512-7yi25vDAoHAkbhAzX9dHx2yc6ntS4jQvejrNcC+csQJAXjj15e7VcWfMgLqBNAbOvqi5uIa9huOVwdHbf+sKqg==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.3" + } + }, + "node_modules/postcss-custom-properties": { + "version": "12.1.11", + "resolved": "https://registry.npmmirror.com/postcss-custom-properties/-/postcss-custom-properties-12.1.11.tgz", + "integrity": "sha512-0IDJYhgU8xDv1KY6+VgUwuQkVtmYzRwu+dMjnmdMafXYv86SWqfxkc7qdDvWS38vsjaEtv8e0vGOUQrAiMBLpQ==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/postcss-custom-selectors": { + "version": "6.0.3", + "resolved": "https://registry.npmmirror.com/postcss-custom-selectors/-/postcss-custom-selectors-6.0.3.tgz", + "integrity": "sha512-fgVkmyiWDwmD3JbpCmB45SvvlCD6z9CG6Ie6Iere22W5aHea6oWa7EM2bpnv2Fj3I94L3VbtvX9KqwSi5aFzSg==", + "dev": true, + "dependencies": { + "postcss-selector-parser": "^6.0.4" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.3" + } + }, + "node_modules/postcss-dir-pseudo-class": { + "version": "6.0.5", + "resolved": "https://registry.npmmirror.com/postcss-dir-pseudo-class/-/postcss-dir-pseudo-class-6.0.5.tgz", + "integrity": "sha512-eqn4m70P031PF7ZQIvSgy9RSJ5uI2171O/OO/zcRNYpJbvaeKFUlar1aJ7rmgiQtbm0FSPsRewjpdS0Oew7MPA==", + "dev": true, + "dependencies": { + "postcss-selector-parser": "^6.0.10" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/postcss-double-position-gradients": { + "version": "3.1.2", + "resolved": "https://registry.npmmirror.com/postcss-double-position-gradients/-/postcss-double-position-gradients-3.1.2.tgz", + "integrity": "sha512-GX+FuE/uBR6eskOK+4vkXgT6pDkexLokPaz/AbJna9s5Kzp/yl488pKPjhy0obB475ovfT1Wv8ho7U/cHNaRgQ==", + "dev": true, + "dependencies": { + "@csstools/postcss-progressive-custom-properties": "^1.1.0", + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/postcss-env-function": { + "version": "4.0.6", + "resolved": "https://registry.npmmirror.com/postcss-env-function/-/postcss-env-function-4.0.6.tgz", + "integrity": "sha512-kpA6FsLra+NqcFnL81TnsU+Z7orGtDTxcOhl6pwXeEq1yFPpRMkCDpHhrz8CFQDr/Wfm0jLiNQ1OsGGPjlqPwA==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-focus-visible": { + "version": "6.0.4", + "resolved": "https://registry.npmmirror.com/postcss-focus-visible/-/postcss-focus-visible-6.0.4.tgz", + "integrity": "sha512-QcKuUU/dgNsstIK6HELFRT5Y3lbrMLEOwG+A4s5cA+fx3A3y/JTq3X9LaOj3OC3ALH0XqyrgQIgey/MIZ8Wczw==", + "dev": true, + "dependencies": { + "postcss-selector-parser": "^6.0.9" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-focus-within": { + "version": "5.0.4", + "resolved": "https://registry.npmmirror.com/postcss-focus-within/-/postcss-focus-within-5.0.4.tgz", + "integrity": "sha512-vvjDN++C0mu8jz4af5d52CB184ogg/sSxAFS+oUJQq2SuCe7T5U2iIsVJtsCp2d6R4j0jr5+q3rPkBVZkXD9fQ==", + "dev": true, + "dependencies": { + "postcss-selector-parser": "^6.0.9" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-font-variant": { + "version": "5.0.0", + "resolved": "https://registry.npmmirror.com/postcss-font-variant/-/postcss-font-variant-5.0.0.tgz", + "integrity": "sha512-1fmkBaCALD72CK2a9i468mA/+tr9/1cBxRRMXOUaZqO43oWPR5imcyPjXwuv7PXbCid4ndlP5zWhidQVVa3hmA==", + "dev": true, + "peerDependencies": { + "postcss": "^8.1.0" + } + }, + "node_modules/postcss-gap-properties": { + "version": "3.0.5", + "resolved": "https://registry.npmmirror.com/postcss-gap-properties/-/postcss-gap-properties-3.0.5.tgz", + "integrity": "sha512-IuE6gKSdoUNcvkGIqdtjtcMtZIFyXZhmFd5RUlg97iVEvp1BZKV5ngsAjCjrVy+14uhGBQl9tzmi1Qwq4kqVOg==", + "dev": true, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/postcss-html": { + "version": "1.5.0", + "resolved": "https://registry.npmmirror.com/postcss-html/-/postcss-html-1.5.0.tgz", + "integrity": "sha512-kCMRWJRHKicpA166kc2lAVUGxDZL324bkj/pVOb6RhjB0Z5Krl7mN0AsVkBhVIRZZirY0lyQXG38HCVaoKVNoA==", + "dev": true, + "dependencies": { + "htmlparser2": "^8.0.0", + "js-tokens": "^8.0.0", + "postcss": "^8.4.0", + "postcss-safe-parser": "^6.0.0" + }, + "engines": { + "node": "^12 || >=14" + } + }, + "node_modules/postcss-html/node_modules/js-tokens": { + "version": "8.0.0", + "resolved": "https://registry.npmmirror.com/js-tokens/-/js-tokens-8.0.0.tgz", + "integrity": "sha512-PC7MzqInq9OqKyTXfIvQNcjMkODJYC8A17kAaQgeW79yfhqTWSOfjHYQ2mDDcwJ96Iibtwkfh0C7R/OvqPlgVA==", + "dev": true + }, + "node_modules/postcss-image-set-function": { + "version": "4.0.7", + "resolved": "https://registry.npmmirror.com/postcss-image-set-function/-/postcss-image-set-function-4.0.7.tgz", + "integrity": "sha512-9T2r9rsvYzm5ndsBE8WgtrMlIT7VbtTfE7b3BQnudUqnBcBo7L758oc+o+pdj/dUV0l5wjwSdjeOH2DZtfv8qw==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/postcss-initial": { + "version": "4.0.1", + "resolved": "https://registry.npmmirror.com/postcss-initial/-/postcss-initial-4.0.1.tgz", + "integrity": "sha512-0ueD7rPqX8Pn1xJIjay0AZeIuDoF+V+VvMt/uOnn+4ezUKhZM/NokDeP6DwMNyIoYByuN/94IQnt5FEkaN59xQ==", + "dev": true, + "peerDependencies": { + "postcss": "^8.0.0" + } + }, + "node_modules/postcss-lab-function": { + "version": "4.2.1", + "resolved": "https://registry.npmmirror.com/postcss-lab-function/-/postcss-lab-function-4.2.1.tgz", + "integrity": "sha512-xuXll4isR03CrQsmxyz92LJB2xX9n+pZJ5jE9JgcnmsCammLyKdlzrBin+25dy6wIjfhJpKBAN80gsTlCgRk2w==", + "dev": true, + "dependencies": { + "@csstools/postcss-progressive-custom-properties": "^1.1.0", + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/postcss-logical": { + "version": "5.0.4", + "resolved": "https://registry.npmmirror.com/postcss-logical/-/postcss-logical-5.0.4.tgz", + "integrity": "sha512-RHXxplCeLh9VjinvMrZONq7im4wjWGlRJAqmAVLXyZaXwfDWP73/oq4NdIp+OZwhQUMj0zjqDfM5Fj7qby+B4g==", + "dev": true, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-media-minmax": { + "version": "5.0.0", + "resolved": "https://registry.npmmirror.com/postcss-media-minmax/-/postcss-media-minmax-5.0.0.tgz", + "integrity": "sha512-yDUvFf9QdFZTuCUg0g0uNSHVlJ5X1lSzDZjPSFaiCWvjgsvu8vEVxtahPrLMinIDEEGnx6cBe6iqdx5YWz08wQ==", + "dev": true, + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "postcss": "^8.1.0" + } + }, + "node_modules/postcss-nesting": { + "version": "10.2.0", + "resolved": "https://registry.npmmirror.com/postcss-nesting/-/postcss-nesting-10.2.0.tgz", + "integrity": "sha512-EwMkYchxiDiKUhlJGzWsD9b2zvq/r2SSubcRrgP+jujMXFzqvANLt16lJANC+5uZ6hjI7lpRmI6O8JIl+8l1KA==", + "dev": true, + "dependencies": { + "@csstools/selector-specificity": "^2.0.0", + "postcss-selector-parser": "^6.0.10" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/postcss-opacity-percentage": { + "version": "1.1.3", + "resolved": "https://registry.npmmirror.com/postcss-opacity-percentage/-/postcss-opacity-percentage-1.1.3.tgz", + "integrity": "sha512-An6Ba4pHBiDtyVpSLymUUERMo2cU7s+Obz6BTrS+gxkbnSBNKSuD0AVUc+CpBMrpVPKKfoVz0WQCX+Tnst0i4A==", + "dev": true, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/postcss-overflow-shorthand": { + "version": "3.0.4", + "resolved": "https://registry.npmmirror.com/postcss-overflow-shorthand/-/postcss-overflow-shorthand-3.0.4.tgz", + "integrity": "sha512-otYl/ylHK8Y9bcBnPLo3foYFLL6a6Ak+3EQBPOTR7luMYCOsiVTUk1iLvNf6tVPNGXcoL9Hoz37kpfriRIFb4A==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/postcss-page-break": { + "version": "3.0.4", + "resolved": "https://registry.npmmirror.com/postcss-page-break/-/postcss-page-break-3.0.4.tgz", + "integrity": "sha512-1JGu8oCjVXLa9q9rFTo4MbeeA5FMe00/9C7lN4va606Rdb+HkxXtXsmEDrIraQ11fGz/WvKWa8gMuCKkrXpTsQ==", + "dev": true, + "peerDependencies": { + "postcss": "^8" + } + }, + "node_modules/postcss-place": { + "version": "7.0.5", + "resolved": "https://registry.npmmirror.com/postcss-place/-/postcss-place-7.0.5.tgz", + "integrity": "sha512-wR8igaZROA6Z4pv0d+bvVrvGY4GVHihBCBQieXFY3kuSuMyOmEnnfFzHl/tQuqHZkfkIVBEbDvYcFfHmpSet9g==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/postcss-preset-env": { + "version": "7.8.3", + "resolved": "https://registry.npmmirror.com/postcss-preset-env/-/postcss-preset-env-7.8.3.tgz", + "integrity": "sha512-T1LgRm5uEVFSEF83vHZJV2z19lHg4yJuZ6gXZZkqVsqv63nlr6zabMH3l4Pc01FQCyfWVrh2GaUeCVy9Po+Aag==", + "dev": true, + "dependencies": { + "@csstools/postcss-cascade-layers": "^1.1.1", + "@csstools/postcss-color-function": "^1.1.1", + "@csstools/postcss-font-format-keywords": "^1.0.1", + "@csstools/postcss-hwb-function": "^1.0.2", + "@csstools/postcss-ic-unit": "^1.0.1", + "@csstools/postcss-is-pseudo-class": "^2.0.7", + "@csstools/postcss-nested-calc": "^1.0.0", + "@csstools/postcss-normalize-display-values": "^1.0.1", + "@csstools/postcss-oklab-function": "^1.1.1", + "@csstools/postcss-progressive-custom-properties": "^1.3.0", + "@csstools/postcss-stepped-value-functions": "^1.0.1", + "@csstools/postcss-text-decoration-shorthand": "^1.0.0", + "@csstools/postcss-trigonometric-functions": "^1.0.2", + "@csstools/postcss-unset-value": "^1.0.2", + "autoprefixer": "^10.4.13", + "browserslist": "^4.21.4", + "css-blank-pseudo": "^3.0.3", + "css-has-pseudo": "^3.0.4", + "css-prefers-color-scheme": "^6.0.3", + "cssdb": "^7.1.0", + "postcss-attribute-case-insensitive": "^5.0.2", + "postcss-clamp": "^4.1.0", + "postcss-color-functional-notation": "^4.2.4", + "postcss-color-hex-alpha": "^8.0.4", + "postcss-color-rebeccapurple": "^7.1.1", + "postcss-custom-media": "^8.0.2", + "postcss-custom-properties": "^12.1.10", + "postcss-custom-selectors": "^6.0.3", + "postcss-dir-pseudo-class": "^6.0.5", + "postcss-double-position-gradients": "^3.1.2", + "postcss-env-function": "^4.0.6", + "postcss-focus-visible": "^6.0.4", + "postcss-focus-within": "^5.0.4", + "postcss-font-variant": "^5.0.0", + "postcss-gap-properties": "^3.0.5", + "postcss-image-set-function": "^4.0.7", + "postcss-initial": "^4.0.1", + "postcss-lab-function": "^4.2.1", + "postcss-logical": "^5.0.4", + "postcss-media-minmax": "^5.0.0", + "postcss-nesting": "^10.2.0", + "postcss-opacity-percentage": "^1.1.2", + "postcss-overflow-shorthand": "^3.0.4", + "postcss-page-break": "^3.0.4", + "postcss-place": "^7.0.5", + "postcss-pseudo-class-any-link": "^7.1.6", + "postcss-replace-overflow-wrap": "^4.0.0", + "postcss-selector-not": "^6.0.1", + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/postcss-pseudo-class-any-link": { + "version": "7.1.6", + "resolved": "https://registry.npmmirror.com/postcss-pseudo-class-any-link/-/postcss-pseudo-class-any-link-7.1.6.tgz", + "integrity": "sha512-9sCtZkO6f/5ML9WcTLcIyV1yz9D1rf0tWc+ulKcvV30s0iZKS/ONyETvoWsr6vnrmW+X+KmuK3gV/w5EWnT37w==", + "dev": true, + "dependencies": { + "postcss-selector-parser": "^6.0.10" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/postcss-replace-overflow-wrap": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/postcss-replace-overflow-wrap/-/postcss-replace-overflow-wrap-4.0.0.tgz", + "integrity": "sha512-KmF7SBPphT4gPPcKZc7aDkweHiKEEO8cla/GjcBK+ckKxiZslIu3C4GCRW3DNfL0o7yW7kMQu9xlZ1kXRXLXtw==", + "dev": true, + "peerDependencies": { + "postcss": "^8.0.3" + } + }, + "node_modules/postcss-safe-parser": { + "version": "6.0.0", + "resolved": "https://registry.npmmirror.com/postcss-safe-parser/-/postcss-safe-parser-6.0.0.tgz", + "integrity": "sha512-FARHN8pwH+WiS2OPCxJI8FuRJpTVnn6ZNFiqAM2aeW2LwTHWWmWgIyKC6cUo0L8aeKiF/14MNvnpls6R2PBeMQ==", + "dev": true, + "engines": { + "node": ">=12.0" + }, + "peerDependencies": { + "postcss": "^8.3.3" + } + }, + "node_modules/postcss-scss": { + "version": "4.0.6", + "resolved": "https://registry.npmmirror.com/postcss-scss/-/postcss-scss-4.0.6.tgz", + "integrity": "sha512-rLDPhJY4z/i4nVFZ27j9GqLxj1pwxE80eAzUNRMXtcpipFYIeowerzBgG3yJhMtObGEXidtIgbUpQ3eLDsf5OQ==", + "dev": true, + "engines": { + "node": ">=12.0" + }, + "peerDependencies": { + "postcss": "^8.4.19" + } + }, + "node_modules/postcss-selector-not": { + "version": "6.0.1", + "resolved": "https://registry.npmmirror.com/postcss-selector-not/-/postcss-selector-not-6.0.1.tgz", + "integrity": "sha512-1i9affjAe9xu/y9uqWH+tD4r6/hDaXJruk8xn2x1vzxC2U3J3LKO3zJW4CyxlNhA56pADJ/djpEwpH1RClI2rQ==", + "dev": true, + "dependencies": { + "postcss-selector-parser": "^6.0.10" + }, + "engines": { + "node": "^12 || ^14 || >=16" + }, + "peerDependencies": { + "postcss": "^8.2" + } + }, + "node_modules/postcss-selector-parser": { + "version": "6.0.11", + "resolved": "https://registry.npmmirror.com/postcss-selector-parser/-/postcss-selector-parser-6.0.11.tgz", + "integrity": "sha512-zbARubNdogI9j7WY4nQJBiNqQf3sLS3wCP4WfOidu+p28LofJqDH1tcXypGrcmMHhDk2t9wGhCsYe/+szLTy1g==", + "dev": true, + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/postcss-value-parser": { + "version": "4.2.0", + "resolved": "https://registry.npmmirror.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", + "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", + "dev": true + }, + "node_modules/preact": { + "version": "10.19.3", + "resolved": "https://registry.npmmirror.com/preact/-/preact-10.19.3.tgz", + "integrity": "sha512-nHHTeFVBTHRGxJXKkKu5hT8C/YWBkPso4/Gad6xuj5dbptt9iF9NZr9pHbPhBrnT2klheu7mHTxTZ/LjwJiEiQ==" + }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmmirror.com/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/prettier": { + "version": "2.8.1", + "resolved": "https://registry.npmmirror.com/prettier/-/prettier-2.8.1.tgz", + "integrity": "sha512-lqGoSJBQNJidqCHE80vqZJHWHRFoNYsSpP9AjFhlhi9ODCJA541svILes/+/1GM3VaL/abZi7cpFzOpdR9UPKg==", + "dev": true, + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "dependencies": { + "fast-diff": "^1.1.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/prismjs": { + "version": "1.29.0", + "resolved": "https://registry.npmmirror.com/prismjs/-/prismjs-1.29.0.tgz", + "integrity": "sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==", + "engines": { + "node": ">=6" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, + "node_modules/punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmmirror.com/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/qrcode": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.0.tgz", + "integrity": "sha512-9MgRpgVc+/+47dFvQeD6U2s0Z92EsKzcHogtum4QB+UNd025WOJSHvn/hjk9xmzj7Stj95CyUAs31mrjxliEsQ==", + "dependencies": { + "dijkstrajs": "^1.0.1", + "encode-utf8": "^1.0.3", + "pngjs": "^5.0.0", + "yargs": "^15.3.1" + }, + "bin": { + "qrcode": "bin/qrcode" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmmirror.com/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true + }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmmirror.com/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/regenerator-runtime": { + "version": "0.14.1", + "resolved": "https://registry.npmmirror.com/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==" + }, + "node_modules/regexp.prototype.flags": { + "version": "1.5.1", + "resolved": "https://registry.npmmirror.com/regexp.prototype.flags/-/regexp.prototype.flags-1.5.1.tgz", + "integrity": "sha512-sy6TXMN+hnP/wMy+ISxg3krXx7BAtWVO4UouuCN/ziM9UEne0euamVNafDfvC83bRNr95y0V5iijeDQFUNpvrg==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "set-function-name": "^2.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/regexpp": { + "version": "3.2.0", + "resolved": "https://registry.npmmirror.com/regexpp/-/regexpp-3.2.0.tgz", + "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==" + }, + "node_modules/resolve": { + "version": "1.22.8", + "resolved": "https://registry.npmmirror.com/resolve/-/resolve-1.22.8.tgz", + "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", + "dev": true, + "dependencies": { + "is-core-module": "^2.13.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + } + }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true + }, + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmmirror.com/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true, + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmmirror.com/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + } + }, + "node_modules/rollup": { + "version": "3.7.5", + "resolved": "https://registry.npmmirror.com/rollup/-/rollup-3.7.5.tgz", + "integrity": "sha512-z0ZbqHBtS/et2EEUKMrAl2CoSdwN7ZPzL17UMiKN9RjjqHShTlv7F9J6ZJZJNREYjBh3TvBrdfjkFDIXFNeuiQ==", + "devOptional": true, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=14.18.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/safe-array-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/safe-array-concat/-/safe-array-concat-1.0.1.tgz", + "integrity": "sha512-6XbUAseYE2KtOuGueyeobCySj9L4+66Tn6KQMOPQJrAJEowYKW/YR/MGJZl7FdydUdaFu4LYyDZjxf4/Nmo23Q==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.2.1", + "has-symbols": "^1.0.3", + "isarray": "^2.0.5" + }, + "engines": { + "node": ">=0.4" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safe-regex-test": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/safe-regex-test/-/safe-regex-test-1.0.0.tgz", + "integrity": "sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.1.3", + "is-regex": "^1.1.4" + } + }, + "node_modules/sass": { + "version": "1.57.1", + "resolved": "https://registry.npmmirror.com/sass/-/sass-1.57.1.tgz", + "integrity": "sha512-O2+LwLS79op7GI0xZ8fqzF7X2m/m8WFfI02dHOdsK5R2ECeS5F62zrwg/relM1rjSLy7Vd/DiMNIvPrQGsA0jw==", + "dev": true, + "dependencies": { + "chokidar": ">=3.0.0 <4.0.0", + "immutable": "^4.0.0", + "source-map-js": ">=0.6.2 <2.0.0" + }, + "bin": { + "sass": "sass.js" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/sax": { + "version": "1.3.0", + "resolved": "https://registry.npmmirror.com/sax/-/sax-1.3.0.tgz", + "integrity": "sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA==" + }, + "node_modules/saxen": { + "version": "8.1.2", + "resolved": "https://registry.npmmirror.com/saxen/-/saxen-8.1.2.tgz", + "integrity": "sha512-xUOiiFbc3Ow7p8KMxwsGICPx46ZQvy3+qfNVhrkwfz3Vvq45eGt98Ft5IQaA1R/7Tb5B5MKh9fUR9x3c3nDTxw==", + "dev": true + }, + "node_modules/scroll-into-view-if-needed": { + "version": "2.2.31", + "resolved": "https://registry.npmmirror.com/scroll-into-view-if-needed/-/scroll-into-view-if-needed-2.2.31.tgz", + "integrity": "sha512-dGCXy99wZQivjmjIqihaBQNjryrz5rueJY7eHfTdyWEiR4ttYpsajb14rn9s5d4DY4EcY6+4+U/maARBXJedkA==", + "dependencies": { + "compute-scroll-into-view": "^1.0.20" + } + }, + "node_modules/scroll-tabs": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/scroll-tabs/-/scroll-tabs-1.0.1.tgz", + "integrity": "sha512-W4xjEwNS4QAyQnaJ450vQTcKpbnalBAfsTDV926WrxEMOqjyj2To8uv2d0Cp0oxMdk5TkygtzXmctPNc2zgBcg==", + "dev": true, + "dependencies": { + "min-dash": "^3.1.0", + "min-dom": "^3.1.0", + "mitt": "^1.1.3" + } + }, + "node_modules/scule": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/scule/-/scule-1.0.0.tgz", + "integrity": "sha512-4AsO/FrViE/iDNEPaAQlb77tf0csuq27EsVpy6ett584EcRTp6pTDLoGWVxCD77y5iU5FauOvhsI4o1APwPoSQ==", + "dev": true + }, + "node_modules/select": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz", + "integrity": "sha512-OwpTSOfy6xSs1+pwcNrv0RBMOzI39Lp3qQKUTPVVPRjCdNa5JH/oPRiqsesIskK8TVgmRiHwO4KXlV2Li9dANA==" + }, + "node_modules/selection-update": { + "version": "0.1.2", + "resolved": "https://registry.npmmirror.com/selection-update/-/selection-update-0.1.2.tgz", + "integrity": "sha512-4jzoJNh7VT2s2tvm/kUSskSw7pD0BVcrrGccbfOMK+3AXLBPz6nIy1yo+pbXgvNoTNII96Pq92+sAY+rF0LUAA==", + "dev": true + }, + "node_modules/semver": { + "version": "7.3.8", + "resolved": "https://registry.npmmirror.com/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/serialize-javascript": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.1.tgz", + "integrity": "sha512-owoXEFjWRllis8/M1Q+Cw5k8ZH40e3zhp/ovX+Xr/vi1qj6QesbyXXViFbpNvWvPNAD62SutwEXavefrLJWj7w==", + "dependencies": { + "randombytes": "^2.1.0" + } + }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==" + }, + "node_modules/set-function-length": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/set-function-length/-/set-function-length-1.1.1.tgz", + "integrity": "sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ==", + "dev": true, + "dependencies": { + "define-data-property": "^1.1.1", + "get-intrinsic": "^1.2.1", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/set-function-name": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/set-function-name/-/set-function-name-2.0.1.tgz", + "integrity": "sha512-tMNCiqYVkXIZgc2Hnoy2IvC/f8ezc5koaRFkCjrpWzGpCd3qbZXPzVy9MAZzK1ch/X0jvSkojys3oqJN0qCmdA==", + "dev": true, + "dependencies": { + "define-data-property": "^1.0.1", + "functions-have-names": "^1.2.3", + "has-property-descriptors": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/side-channel": { + "version": "1.0.4", + "resolved": "https://registry.npmmirror.com/side-channel/-/side-channel-1.0.4.tgz", + "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.0", + "get-intrinsic": "^1.0.2", + "object-inspect": "^1.9.0" + } + }, + "node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/slate": { + "version": "0.72.8", + "resolved": "https://registry.npmmirror.com/slate/-/slate-0.72.8.tgz", + "integrity": "sha512-/nJwTswQgnRurpK+bGJFH1oM7naD5qDmHd89JyiKNT2oOKD8marW0QSBtuFnwEbL5aGCS8AmrhXQgNOsn4osAw==", + "dependencies": { + "immer": "^9.0.6", + "is-plain-object": "^5.0.0", + "tiny-warning": "^1.0.3" + } + }, + "node_modules/slate-history": { + "version": "0.66.0", + "resolved": "https://registry.npmmirror.com/slate-history/-/slate-history-0.66.0.tgz", + "integrity": "sha512-6MWpxGQZiMvSINlCbMW43E2YBSVMCMCIwQfBzGssjWw4kb0qfvj0pIdblWNRQZD0hR6WHP+dHHgGSeVdMWzfng==", + "dependencies": { + "is-plain-object": "^5.0.0" + }, + "peerDependencies": { + "slate": ">=0.65.3" + } + }, + "node_modules/smob": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/smob/-/smob-1.4.1.tgz", + "integrity": "sha512-9LK+E7Hv5R9u4g4C3p+jjLstaLe11MDsL21UpYaCNmapvMkYhqCV4A/f/3gyH8QjMyh6l68q9xC85vihY9ahMQ==" + }, + "node_modules/snabbdom": { + "version": "3.5.1", + "resolved": "https://registry.npmmirror.com/snabbdom/-/snabbdom-3.5.1.tgz", + "integrity": "sha512-wHMNIOjkm/YNE5EM3RCbr/+DVgPg6AqQAX1eOxO46zYNvCXjKP5Y865tqQj3EXnaMBjkxmQA5jFuDpDK/dbfiA==", + "engines": { + "node": ">=8.3.0" + } + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/ssr-window": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/ssr-window/-/ssr-window-3.0.0.tgz", + "integrity": "sha512-q+8UfWDg9Itrg0yWK7oe5p/XRCJpJF9OBtXfOPgSJl+u3Xd5KI328RUEvUqSMVM9CiQUEf1QdBzJMkYGErj9QA==" + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string.prototype.trim": { + "version": "1.2.8", + "resolved": "https://registry.npmmirror.com/string.prototype.trim/-/string.prototype.trim-1.2.8.tgz", + "integrity": "sha512-lfjY4HcixfQXOfaqCvcBuOIapyaroTXhbkfJN3gcB1OtyupngWK4sEET9Knd0cXd28kTUqu/kHoV4HKSJdnjiQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/string.prototype.trimend": { + "version": "1.0.7", + "resolved": "https://registry.npmmirror.com/string.prototype.trimend/-/string.prototype.trimend-1.0.7.tgz", + "integrity": "sha512-Ni79DqeB72ZFq1uH/L6zJ+DKZTkOtPIHovb3YZHQViE+HDouuU4mBrLOLDn5Dde3RF8qw5qVETEjhu9locMLvA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1" + } + }, + "node_modules/string.prototype.trimstart": { + "version": "1.0.7", + "resolved": "https://registry.npmmirror.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.7.tgz", + "integrity": "sha512-NGhtDFu3jCEm7B4Fy0DpLewdJQOZcQ0rGbwQ/+stjnrp2i+rlKeCvos9hOIeCmqwratM47OBxY7uFZzjxHXmrg==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmmirror.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-literal": { + "version": "1.3.0", + "resolved": "https://registry.npmmirror.com/strip-literal/-/strip-literal-1.3.0.tgz", + "integrity": "sha512-PugKzOsyXpArk0yWmUwqOZecSO0GH0bPoctLcqNDH9J04pVW3lflYE0ujElBGTloevcxF5MofAOZ7C5l2b+wLg==", + "dev": true, + "dependencies": { + "acorn": "^8.10.0" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmmirror.com/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/svg.js": { + "version": "2.7.1", + "resolved": "https://registry.npmmirror.com/svg.js/-/svg.js-2.7.1.tgz", + "integrity": "sha512-ycbxpizEQktk3FYvn/8BH+6/EuWXg7ZpQREJvgacqn46gIddG24tNNe4Son6omdXCnSOaApnpZw6MPCBA1dODA==" + }, + "node_modules/tapable": { + "version": "2.2.1", + "resolved": "https://registry.npmmirror.com/tapable/-/tapable-2.2.1.tgz", + "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/terser": { + "version": "5.24.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.24.0.tgz", + "integrity": "sha512-ZpGR4Hy3+wBEzVEnHvstMvqpD/nABNelQn/z2r0fjVWGQsN3bpOLzQlqDxmb4CDZnXq5lpjnQ+mHQLAOpfM5iw==", + "dependencies": { + "@jridgewell/source-map": "^0.3.3", + "acorn": "^8.8.2", + "commander": "^2.20.0", + "source-map-support": "~0.5.20" + }, + "bin": { + "terser": "bin/terser" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmmirror.com/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", + "dev": true + }, + "node_modules/tiny-emitter": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz", + "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==" + }, + "node_modules/tiny-svg": { + "version": "2.2.4", + "resolved": "https://registry.npmmirror.com/tiny-svg/-/tiny-svg-2.2.4.tgz", + "integrity": "sha512-NOi39lBknf4UdDEahNkbEAJnzhu1ZcN2j75IS2vLRmIhsfxdZpTChfLKBcN1ShplVmPIXJAIafk6YY5/Aa80lQ==", + "dev": true + }, + "node_modules/tiny-warning": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/tiny-warning/-/tiny-warning-1.0.3.tgz", + "integrity": "sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==" + }, + "node_modules/to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", + "engines": { + "node": ">=4" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmmirror.com/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/tsconfig-paths": { + "version": "3.14.2", + "resolved": "https://registry.npmmirror.com/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz", + "integrity": "sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==", + "dev": true, + "dependencies": { + "@types/json5": "^0.0.29", + "json5": "^1.0.2", + "minimist": "^1.2.6", + "strip-bom": "^3.0.0" + } + }, + "node_modules/tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmmirror.com/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + }, + "node_modules/tsutils": { + "version": "3.21.0", + "resolved": "https://registry.npmmirror.com/tsutils/-/tsutils-3.21.0.tgz", + "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", + "dev": true, + "dependencies": { + "tslib": "^1.8.1" + }, + "engines": { + "node": ">= 6" + }, + "peerDependencies": { + "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" + } + }, + "node_modules/type": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/type/-/type-1.2.0.tgz", + "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" + }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmmirror.com/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmmirror.com/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/typed-array-buffer": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/typed-array-buffer/-/typed-array-buffer-1.0.0.tgz", + "integrity": "sha512-Y8KTSIglk9OZEr8zywiIHG/kmQ7KWyjseXs1CbSo8vC42w7hg2HgYTxSWwP0+is7bWDc1H+Fo026CpHFwm8tkw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.2.1", + "is-typed-array": "^1.1.10" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/typed-array-byte-length": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/typed-array-byte-length/-/typed-array-byte-length-1.0.0.tgz", + "integrity": "sha512-Or/+kvLxNpeQ9DtSydonMxCx+9ZXOswtwJn17SNLvhptaXYDJvkFFP5zbfU/uLmvnBJlI4yrnXRxpdWH/M5tNA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "for-each": "^0.3.3", + "has-proto": "^1.0.1", + "is-typed-array": "^1.1.10" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/typed-array-byte-offset": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/typed-array-byte-offset/-/typed-array-byte-offset-1.0.0.tgz", + "integrity": "sha512-RD97prjEt9EL8YgAgpOkf3O4IF9lhJFr9g0htQkm0rchFp/Vx7LW5Q8fSXXub7BXAODyUQohRMyOc3faCPd0hg==", + "dev": true, + "dependencies": { + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.2", + "for-each": "^0.3.3", + "has-proto": "^1.0.1", + "is-typed-array": "^1.1.10" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/typed-array-length": { + "version": "1.0.4", + "resolved": "https://registry.npmmirror.com/typed-array-length/-/typed-array-length-1.0.4.tgz", + "integrity": "sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "for-each": "^0.3.3", + "is-typed-array": "^1.1.9" + } + }, + "node_modules/typescript": { + "version": "4.9.4", + "resolved": "https://registry.npmmirror.com/typescript/-/typescript-4.9.4.tgz", + "integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==", + "devOptional": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/ufo": { + "version": "1.3.1", + "resolved": "https://registry.npmmirror.com/ufo/-/ufo-1.3.1.tgz", + "integrity": "sha512-uY/99gMLIOlJPwATcMVYfqDSxUR9//AUcgZMzwfSTJPDKzA1S8mX4VLqa+fiAtveraQUBCz4FFcwVZBGbwBXIw==", + "dev": true + }, + "node_modules/unbox-primitive": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/unbox-primitive/-/unbox-primitive-1.0.2.tgz", + "integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "has-bigints": "^1.0.2", + "has-symbols": "^1.0.3", + "which-boxed-primitive": "^1.0.2" + } + }, + "node_modules/unimport": { + "version": "3.4.0", + "resolved": "https://registry.npmmirror.com/unimport/-/unimport-3.4.0.tgz", + "integrity": "sha512-M/lfFEgufIT156QAr/jWHLUn55kEmxBBiQsMxvRSIbquwmeJEyQYgshHDEvQDWlSJrVOOTAgnJ3FvlsrpGkanA==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.0.4", + "escape-string-regexp": "^5.0.0", + "fast-glob": "^3.3.1", + "local-pkg": "^0.4.3", + "magic-string": "^0.30.3", + "mlly": "^1.4.2", + "pathe": "^1.1.1", + "pkg-types": "^1.0.3", + "scule": "^1.0.0", + "strip-literal": "^1.3.0", + "unplugin": "^1.5.0" + } + }, + "node_modules/unimport/node_modules/@rollup/pluginutils": { + "version": "5.0.5", + "resolved": "https://registry.npmmirror.com/@rollup/pluginutils/-/pluginutils-5.0.5.tgz", + "integrity": "sha512-6aEYR910NyP73oHiJglti74iRyOwgFU4x3meH/H8OJx6Ry0j6cOVZ5X/wTvub7G7Ao6qaHBEaNsV3GLJkSsF+Q==", + "dev": true, + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/unimport/node_modules/escape-string-regexp": { + "version": "5.0.0", + "resolved": "https://registry.npmmirror.com/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", + "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/unplugin": { + "version": "1.5.0", + "resolved": "https://registry.npmmirror.com/unplugin/-/unplugin-1.5.0.tgz", + "integrity": "sha512-9ZdRwbh/4gcm1JTOkp9lAkIDrtOyOxgHmY7cjuwI8L/2RTikMcVG25GsZwNAgRuap3iDw2jeq7eoqtAsz5rW3A==", + "dev": true, + "dependencies": { + "acorn": "^8.10.0", + "chokidar": "^3.5.3", + "webpack-sources": "^3.2.3", + "webpack-virtual-modules": "^0.5.0" + } + }, + "node_modules/unplugin-auto-import": { + "version": "0.16.7", + "resolved": "https://registry.npmmirror.com/unplugin-auto-import/-/unplugin-auto-import-0.16.7.tgz", + "integrity": "sha512-w7XmnRlchq6YUFJVFGSvG1T/6j8GrdYN6Em9Wf0Ye+HXgD/22kont+WnuCAA0UaUoxtuvRR1u/mXKy63g/hfqQ==", + "dev": true, + "dependencies": { + "@antfu/utils": "^0.7.6", + "@rollup/pluginutils": "^5.0.5", + "fast-glob": "^3.3.1", + "local-pkg": "^0.5.0", + "magic-string": "^0.30.5", + "minimatch": "^9.0.3", + "unimport": "^3.4.0", + "unplugin": "^1.5.0" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@nuxt/kit": "^3.2.2", + "@vueuse/core": "*" + }, + "peerDependenciesMeta": { + "@nuxt/kit": { + "optional": true + }, + "@vueuse/core": { + "optional": true + } + } + }, + "node_modules/unplugin-auto-import/node_modules/@rollup/pluginutils": { + "version": "5.0.5", + "resolved": "https://registry.npmmirror.com/@rollup/pluginutils/-/pluginutils-5.0.5.tgz", + "integrity": "sha512-6aEYR910NyP73oHiJglti74iRyOwgFU4x3meH/H8OJx6Ry0j6cOVZ5X/wTvub7G7Ao6qaHBEaNsV3GLJkSsF+Q==", + "dev": true, + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/unplugin-auto-import/node_modules/local-pkg": { + "version": "0.5.0", + "resolved": "https://registry.npmmirror.com/local-pkg/-/local-pkg-0.5.0.tgz", + "integrity": "sha512-ok6z3qlYyCDS4ZEU27HaU6x/xZa9Whf8jD4ptH5UZTQYZVYeb9bnZ3ojVhiJNLiXK1Hfc0GNbLXcmZ5plLDDBg==", + "dev": true, + "dependencies": { + "mlly": "^1.4.2", + "pkg-types": "^1.0.3" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/unplugin-auto-import/node_modules/minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/unplugin-vue-components": { + "version": "0.25.2", + "resolved": "https://registry.npmmirror.com/unplugin-vue-components/-/unplugin-vue-components-0.25.2.tgz", + "integrity": "sha512-OVmLFqILH6w+eM8fyt/d/eoJT9A6WO51NZLf1vC5c1FZ4rmq2bbGxTy8WP2Jm7xwFdukaIdv819+UI7RClPyCA==", + "dev": true, + "dependencies": { + "@antfu/utils": "^0.7.5", + "@rollup/pluginutils": "^5.0.2", + "chokidar": "^3.5.3", + "debug": "^4.3.4", + "fast-glob": "^3.3.0", + "local-pkg": "^0.4.3", + "magic-string": "^0.30.1", + "minimatch": "^9.0.3", + "resolve": "^1.22.2", + "unplugin": "^1.4.0" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@babel/parser": "^7.15.8", + "@nuxt/kit": "^3.2.2", + "vue": "2 || 3" + }, + "peerDependenciesMeta": { + "@babel/parser": { + "optional": true + }, + "@nuxt/kit": { + "optional": true + } + } + }, + "node_modules/unplugin-vue-components/node_modules/@rollup/pluginutils": { + "version": "5.0.5", + "resolved": "https://registry.npmmirror.com/@rollup/pluginutils/-/pluginutils-5.0.5.tgz", + "integrity": "sha512-6aEYR910NyP73oHiJglti74iRyOwgFU4x3meH/H8OJx6Ry0j6cOVZ5X/wTvub7G7Ao6qaHBEaNsV3GLJkSsF+Q==", + "dev": true, + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/unplugin-vue-components/node_modules/minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.0.13", + "resolved": "https://registry.npmmirror.com/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", + "integrity": "sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==", + "dev": true, + "dependencies": { + "escalade": "^3.1.1", + "picocolors": "^1.0.0" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmmirror.com/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true + }, + "node_modules/vant": { + "version": "4.7.3", + "resolved": "https://registry.npmmirror.com/vant/-/vant-4.7.3.tgz", + "integrity": "sha512-nb0pXxKSOaE9CvH//KozKDivqhjE4ZRvx1b/RCWFL4H3tZ5l+HhWtwK1yJx5AkO1Pm/IYQY86yZa1tums8DfsQ==", + "dependencies": { + "@vant/popperjs": "^1.3.0", + "@vant/use": "^1.6.0", + "@vue/shared": "^3.0.0" + }, + "peerDependencies": { + "vue": "^3.0.0" + } + }, + "node_modules/vite": { + "version": "4.0.2", + "resolved": "https://registry.npmmirror.com/vite/-/vite-4.0.2.tgz", + "integrity": "sha512-QJaY3R+tFlTagH0exVqbgkkw45B+/bXVBzF2ZD1KB5Z8RiAoiKo60vSUf6/r4c2Vh9jfGBKM4oBI9b4/1ZJYng==", + "dev": true, + "dependencies": { + "esbuild": "^0.16.3", + "postcss": "^8.4.20", + "resolve": "^1.22.1", + "rollup": "^3.7.0" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + }, + "peerDependencies": { + "@types/node": ">= 14", + "less": "*", + "sass": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + } + } + }, + "node_modules/vite-plugin-eslint": { + "version": "1.8.1", + "resolved": "https://registry.npmmirror.com/vite-plugin-eslint/-/vite-plugin-eslint-1.8.1.tgz", + "integrity": "sha512-PqdMf3Y2fLO9FsNPmMX+//2BF5SF8nEWspZdgl4kSt7UvHDRHVVfHvxsD7ULYzZrJDGRxR81Nq7TOFgwMnUang==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^4.2.1", + "@types/eslint": "^8.4.5", + "rollup": "^2.77.2" + }, + "peerDependencies": { + "eslint": ">=7", + "vite": ">=2" + } + }, + "node_modules/vite-plugin-eslint/node_modules/rollup": { + "version": "2.79.1", + "resolved": "https://registry.npmmirror.com/rollup/-/rollup-2.79.1.tgz", + "integrity": "sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==", + "dev": true, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=10.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/vue": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/vue/-/vue-3.3.8.tgz", + "integrity": "sha512-5VSX/3DabBikOXMsxzlW8JyfeLKlG9mzqnWgLQLty88vdZL7ZJgrdgBOmrArwxiLtmS+lNNpPcBYqrhE6TQW5w==", + "dependencies": { + "@vue/compiler-dom": "3.3.8", + "@vue/compiler-sfc": "3.3.8", + "@vue/runtime-dom": "3.3.8", + "@vue/server-renderer": "3.3.8", + "@vue/shared": "3.3.8" + }, + "peerDependencies": { + "typescript": "*" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/vue-draggable-plus": { + "version": "0.3.1", + "resolved": "https://registry.npmmirror.com/vue-draggable-plus/-/vue-draggable-plus-0.3.1.tgz", + "integrity": "sha512-Ubo0O8/D+hZPHb1bcDTjOE42a//OjLQwj+bQwfxa1WnEKTJdS7MU0A4auUcNjyIkhTN1xuETOR4mT+BGZCPL2g==", + "peerDependencies": { + "@types/sortablejs": "^1.15.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + } + } + }, + "node_modules/vue-eslint-parser": { + "version": "9.1.0", + "resolved": "https://registry.npmmirror.com/vue-eslint-parser/-/vue-eslint-parser-9.1.0.tgz", + "integrity": "sha512-NGn/iQy8/Wb7RrRa4aRkokyCZfOUWk19OP5HP6JEozQFX5AoS/t+Z0ZN7FY4LlmWc4FNI922V7cvX28zctN8dQ==", + "dev": true, + "dependencies": { + "debug": "^4.3.4", + "eslint-scope": "^7.1.1", + "eslint-visitor-keys": "^3.3.0", + "espree": "^9.3.1", + "esquery": "^1.4.0", + "lodash": "^4.17.21", + "semver": "^7.3.6" + }, + "engines": { + "node": "^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": ">=6.0.0" + } + }, + "node_modules/vue-i18n": { + "version": "9.1.10", + "resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-9.1.10.tgz", + "integrity": "sha512-jpr7gV5KPk4n+sSPdpZT8Qx3XzTcNDWffRlHV/cT2NUyEf+sEgTTmLvnBAibjOFJ0zsUyZlVTAWH5DDnYep+1g==", + "dependencies": { + "@intlify/core-base": "9.1.10", + "@intlify/shared": "9.1.10", + "@intlify/vue-devtools": "9.1.10", + "@vue/devtools-api": "^6.0.0-beta.7" + }, + "engines": { + "node": ">= 10" + }, + "peerDependencies": { + "vue": "^3.0.0" + } + }, + "node_modules/vue-json-viewer": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/vue-json-viewer/-/vue-json-viewer-3.0.4.tgz", + "integrity": "sha512-pnC080rTub6YjccthVSNQod2z9Sl5IUUq46srXtn6rxwhW8QM4rlYn+CTSLFKXWfw+N3xv77Cioxw7B4XUKIbQ==", + "dependencies": { + "clipboard": "^2.0.4" + }, + "peerDependencies": { + "vue": "^3.2.2" + } + }, + "node_modules/vue-router": { + "version": "4.2.5", + "resolved": "https://registry.npmmirror.com/vue-router/-/vue-router-4.2.5.tgz", + "integrity": "sha512-DIUpKcyg4+PTQKfFPX88UWhlagBEBEfJ5A8XDXRJLUnZOvcpMF8o/dnL90vpVkGaPbjvXazV/rC1qBKrZlFugw==", + "dependencies": { + "@vue/devtools-api": "^6.5.0" + }, + "peerDependencies": { + "vue": "^3.2.0" + } + }, + "node_modules/vue-template-compiler": { + "version": "2.7.14", + "resolved": "https://registry.npmmirror.com/vue-template-compiler/-/vue-template-compiler-2.7.14.tgz", + "integrity": "sha512-zyA5Y3ArvVG0NacJDkkzJuPQDF8RFeRlzV2vLeSnhSpieO6LK2OVbdLPi5MPPs09Ii+gMO8nY4S3iKQxBxDmWQ==", + "dev": true, + "dependencies": { + "de-indent": "^1.0.2", + "he": "^1.2.0" + } + }, + "node_modules/vue-tsc": { + "version": "1.0.14", + "resolved": "https://registry.npmmirror.com/vue-tsc/-/vue-tsc-1.0.14.tgz", + "integrity": "sha512-HeqtyxMrSRUCnU5nxB0lQc3o7zirMppZ/V6HLL3l4FsObGepH3A3beNmNehpLQs0Gt7DkSWVi3CpVCFgrf+/sQ==", + "dev": true, + "dependencies": { + "@volar/vue-language-core": "1.0.14", + "@volar/vue-typescript": "1.0.14" + }, + "bin": { + "vue-tsc": "bin/vue-tsc.js" + }, + "peerDependencies": { + "typescript": "*" + } + }, + "node_modules/vxe-table": { + "version": "4.5.13", + "resolved": "https://registry.npmjs.org/vxe-table/-/vxe-table-4.5.13.tgz", + "integrity": "sha512-CKsyUhDYIcO4TSXoO0I2YVkKEWjQLUq24PN6MhmFmvyFRdfj80cgLZ4iEjihLieW4aRqPcLHqkw83hCAyzvO8w==", + "dependencies": { + "dom-zindex": "^1.0.1", + "xe-utils": "^3.5.13" + }, + "peerDependencies": { + "vue": "^3.2.28", + "xe-utils": "^3.5.0" + } + }, + "node_modules/webpack-sources": { + "version": "3.2.3", + "resolved": "https://registry.npmmirror.com/webpack-sources/-/webpack-sources-3.2.3.tgz", + "integrity": "sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==", + "dev": true, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/webpack-virtual-modules": { + "version": "0.5.0", + "resolved": "https://registry.npmmirror.com/webpack-virtual-modules/-/webpack-virtual-modules-0.5.0.tgz", + "integrity": "sha512-kyDivFZ7ZM0BVOUteVbDFhlRt7Ah/CSPwJdi8hBpkK7QLumUqdLtVfm/PX/hkcnrvr0i77fO5+TjZ94Pe+C9iw==", + "dev": true + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/which-boxed-primitive": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz", + "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", + "dev": true, + "dependencies": { + "is-bigint": "^1.0.1", + "is-boolean-object": "^1.1.0", + "is-number-object": "^1.0.4", + "is-string": "^1.0.5", + "is-symbol": "^1.0.3" + } + }, + "node_modules/which-module": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", + "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==" + }, + "node_modules/which-typed-array": { + "version": "1.1.13", + "resolved": "https://registry.npmmirror.com/which-typed-array/-/which-typed-array-1.1.13.tgz", + "integrity": "sha512-P5Nra0qjSncduVPEAr7xhoF5guty49ArDTwzJ/yNuPIbZppyRxFQsRCWrocxIY+CnMVG+qfbU2FmDKyvSGClow==", + "dev": true, + "dependencies": { + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.4", + "for-each": "^0.3.3", + "gopd": "^1.0.1", + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/wildcard": { + "version": "1.1.2", + "resolved": "https://registry.npmmirror.com/wildcard/-/wildcard-1.1.2.tgz", + "integrity": "sha512-DXukZJxpHA8LuotRwL0pP1+rS6CS7FF2qStDDE1C7DDg2rLud2PXRMuEDYIPhgEezwnlHNL4c+N6MfMTjCGTng==" + }, + "node_modules/word-wrap": { + "version": "1.2.3", + "resolved": "https://registry.npmmirror.com/word-wrap/-/word-wrap-1.2.3.tgz", + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "node_modules/xe-utils": { + "version": "3.5.14", + "resolved": "https://registry.npmjs.org/xe-utils/-/xe-utils-3.5.14.tgz", + "integrity": "sha512-Xq6mS8dWwHBQsQUEBXcZYSaBV0KnNLoVWd0vRRDI3nKpbNxfs/LSCK0W21g1edLFnXYfKqg7hh5dakr3RtYY0A==" + }, + "node_modules/xml-js": { + "version": "1.6.11", + "resolved": "https://registry.npmmirror.com/xml-js/-/xml-js-1.6.11.tgz", + "integrity": "sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==", + "dependencies": { + "sax": "^1.2.4" + }, + "bin": { + "xml-js": "bin/cli.js" + } + }, + "node_modules/xml-name-validator": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/xml-name-validator/-/xml-name-validator-4.0.0.tgz", + "integrity": "sha512-ICP2e+jsHvAj2E2lIHxa5tjXRlKDJo4IdvPvCXbXQGdzSfmSpNVyIKMvoZHjDY9DP0zV17iI85o90vRFXNccRw==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/y18n": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==" + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/yargs": { + "version": "15.4.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "dependencies": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/yargs/node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "dependencies": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmmirror.com/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/zrender": { + "version": "5.5.0", + "resolved": "https://registry.npmmirror.com/zrender/-/zrender-5.5.0.tgz", + "integrity": "sha512-O3MilSi/9mwoovx77m6ROZM7sXShR/O/JIanvzTwjN3FORfLSr81PsUGd7jlaYOeds9d8tw82oP44+3YucVo+w==", + "dependencies": { + "tslib": "2.3.0" + } + }, + "node_modules/zrender/node_modules/tslib": { + "version": "2.3.0", + "resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.3.0.tgz", + "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==" + } + }, + "dependencies": { + "@antfu/utils": { + "version": "0.7.6", + "resolved": "https://registry.npmmirror.com/@antfu/utils/-/utils-0.7.6.tgz", + "integrity": "sha512-pvFiLP2BeOKA/ZOS6jxx4XhKzdVLHDhGlFEaZ2flWWYf2xOqVniqpk38I04DFRyz+L0ASggl7SkItTc+ZLju4w==", + "dev": true + }, + "@babel/helper-string-parser": { + "version": "7.23.4", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.23.4.tgz", + "integrity": "sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ==" + }, + "@babel/helper-validator-identifier": { + "version": "7.19.1", + "resolved": "https://registry.npmmirror.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", + "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==" + }, + "@babel/parser": { + "version": "7.23.0", + "resolved": "https://registry.npmmirror.com/@babel/parser/-/parser-7.23.0.tgz", + "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==" + }, + "@babel/runtime": { + "version": "7.23.8", + "resolved": "https://registry.npmmirror.com/@babel/runtime/-/runtime-7.23.8.tgz", + "integrity": "sha512-Y7KbAP984rn1VGMbGqKmBLio9V7y5Je9GvU4rQPCPinCyNfUcToxIXl06d59URp/F3LwinvODxab5N/G6qggkw==", + "requires": { + "regenerator-runtime": "^0.14.0" + } + }, + "@babel/types": { + "version": "7.21.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.21.0.tgz", + "integrity": "sha512-uR7NWq2VNFnDi7EYqiRz2Jv/VQIu38tu64Zy8TX2nQFQ6etJ9V/Rr2msW8BS132mum2rL645qpDrLtAJtVpuow==", + "requires": { + "@babel/helper-string-parser": "^7.19.4", + "@babel/helper-validator-identifier": "^7.19.1", + "to-fast-properties": "^2.0.0" + } + }, + "@bpmn-io/extract-process-variables": { + "version": "0.3.0", + "resolved": "https://registry.npmmirror.com/@bpmn-io/extract-process-variables/-/extract-process-variables-0.3.0.tgz", + "integrity": "sha512-cZMPBvVUXBn7++ZaOVQQGvhrMnFVcOP218yfYBKUv0EMYjo775ust/ZmfIgWd8llT4myXA6dPz12wcYXUBR1Bg==", + "dev": true, + "requires": { + "min-dash": "^3.5.2" + } + }, + "@csstools/postcss-cascade-layers": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-cascade-layers/-/postcss-cascade-layers-1.1.1.tgz", + "integrity": "sha512-+KdYrpKC5TgomQr2DlZF4lDEpHcoxnj5IGddYYfBWJAKfj1JtuHUIqMa+E1pJJ+z3kvDViWMqyqPlG4Ja7amQA==", + "dev": true, + "requires": { + "@csstools/selector-specificity": "^2.0.2", + "postcss-selector-parser": "^6.0.10" + } + }, + "@csstools/postcss-color-function": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-color-function/-/postcss-color-function-1.1.1.tgz", + "integrity": "sha512-Bc0f62WmHdtRDjf5f3e2STwRAl89N2CLb+9iAwzrv4L2hncrbDwnQD9PCq0gtAt7pOI2leIV08HIBUd4jxD8cw==", + "dev": true, + "requires": { + "@csstools/postcss-progressive-custom-properties": "^1.1.0", + "postcss-value-parser": "^4.2.0" + } + }, + "@csstools/postcss-font-format-keywords": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-font-format-keywords/-/postcss-font-format-keywords-1.0.1.tgz", + "integrity": "sha512-ZgrlzuUAjXIOc2JueK0X5sZDjCtgimVp/O5CEqTcs5ShWBa6smhWYbS0x5cVc/+rycTDbjjzoP0KTDnUneZGOg==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "@csstools/postcss-hwb-function": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-hwb-function/-/postcss-hwb-function-1.0.2.tgz", + "integrity": "sha512-YHdEru4o3Rsbjmu6vHy4UKOXZD+Rn2zmkAmLRfPet6+Jz4Ojw8cbWxe1n42VaXQhD3CQUXXTooIy8OkVbUcL+w==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "@csstools/postcss-ic-unit": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-ic-unit/-/postcss-ic-unit-1.0.1.tgz", + "integrity": "sha512-Ot1rcwRAaRHNKC9tAqoqNZhjdYBzKk1POgWfhN4uCOE47ebGcLRqXjKkApVDpjifL6u2/55ekkpnFcp+s/OZUw==", + "dev": true, + "requires": { + "@csstools/postcss-progressive-custom-properties": "^1.1.0", + "postcss-value-parser": "^4.2.0" + } + }, + "@csstools/postcss-is-pseudo-class": { + "version": "2.0.7", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-is-pseudo-class/-/postcss-is-pseudo-class-2.0.7.tgz", + "integrity": "sha512-7JPeVVZHd+jxYdULl87lvjgvWldYu+Bc62s9vD/ED6/QTGjy0jy0US/f6BG53sVMTBJ1lzKZFpYmofBN9eaRiA==", + "dev": true, + "requires": { + "@csstools/selector-specificity": "^2.0.0", + "postcss-selector-parser": "^6.0.10" + } + }, + "@csstools/postcss-nested-calc": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-nested-calc/-/postcss-nested-calc-1.0.0.tgz", + "integrity": "sha512-JCsQsw1wjYwv1bJmgjKSoZNvf7R6+wuHDAbi5f/7MbFhl2d/+v+TvBTU4BJH3G1X1H87dHl0mh6TfYogbT/dJQ==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "@csstools/postcss-normalize-display-values": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-normalize-display-values/-/postcss-normalize-display-values-1.0.1.tgz", + "integrity": "sha512-jcOanIbv55OFKQ3sYeFD/T0Ti7AMXc9nM1hZWu8m/2722gOTxFg7xYu4RDLJLeZmPUVQlGzo4jhzvTUq3x4ZUw==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "@csstools/postcss-oklab-function": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-oklab-function/-/postcss-oklab-function-1.1.1.tgz", + "integrity": "sha512-nJpJgsdA3dA9y5pgyb/UfEzE7W5Ka7u0CX0/HIMVBNWzWemdcTH3XwANECU6anWv/ao4vVNLTMxhiPNZsTK6iA==", + "dev": true, + "requires": { + "@csstools/postcss-progressive-custom-properties": "^1.1.0", + "postcss-value-parser": "^4.2.0" + } + }, + "@csstools/postcss-progressive-custom-properties": { + "version": "1.3.0", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-progressive-custom-properties/-/postcss-progressive-custom-properties-1.3.0.tgz", + "integrity": "sha512-ASA9W1aIy5ygskZYuWams4BzafD12ULvSypmaLJT2jvQ8G0M3I8PRQhC0h7mG0Z3LI05+agZjqSR9+K9yaQQjA==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "@csstools/postcss-stepped-value-functions": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-stepped-value-functions/-/postcss-stepped-value-functions-1.0.1.tgz", + "integrity": "sha512-dz0LNoo3ijpTOQqEJLY8nyaapl6umbmDcgj4AD0lgVQ572b2eqA1iGZYTTWhrcrHztWDDRAX2DGYyw2VBjvCvQ==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "@csstools/postcss-text-decoration-shorthand": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-text-decoration-shorthand/-/postcss-text-decoration-shorthand-1.0.0.tgz", + "integrity": "sha512-c1XwKJ2eMIWrzQenN0XbcfzckOLLJiczqy+YvfGmzoVXd7pT9FfObiSEfzs84bpE/VqfpEuAZ9tCRbZkZxxbdw==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "@csstools/postcss-trigonometric-functions": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-trigonometric-functions/-/postcss-trigonometric-functions-1.0.2.tgz", + "integrity": "sha512-woKaLO///4bb+zZC2s80l+7cm07M7268MsyG3M0ActXXEFi6SuhvriQYcb58iiKGbjwwIU7n45iRLEHypB47Og==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "@csstools/postcss-unset-value": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/@csstools/postcss-unset-value/-/postcss-unset-value-1.0.2.tgz", + "integrity": "sha512-c8J4roPBILnelAsdLr4XOAR/GsTm0GJi4XpcfvoWk3U6KiTCqiFYc63KhRMQQX35jYMp4Ao8Ij9+IZRgMfJp1g==", + "dev": true, + "requires": {} + }, + "@csstools/selector-specificity": { + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/@csstools/selector-specificity/-/selector-specificity-2.0.2.tgz", + "integrity": "sha512-IkpVW/ehM1hWKln4fCA3NzJU8KwD+kIOvPZA4cqxoJHtE21CCzjyp+Kxbu0i5I4tBNOlXPL9mjwnWlL0VEG4Fg==", + "dev": true, + "requires": {} + }, + "@ctrl/tinycolor": { + "version": "3.6.1", + "resolved": "https://registry.npmmirror.com/@ctrl/tinycolor/-/tinycolor-3.6.1.tgz", + "integrity": "sha512-SITSV6aIXsuVNV3f3O0f2n/cgyEDWoSqtZMYiAmcsYHydcKrOz3gUxB/iXd/Qf08+IZX4KpgNbvUdMBmWz+kcA==" + }, + "@element-plus/icons-vue": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@element-plus/icons-vue/-/icons-vue-2.3.1.tgz", + "integrity": "sha512-XxVUZv48RZAd87ucGS48jPf6pKu0yV5UCg9f4FFwtrYxXOwWuVJo6wOvSLKEoMQKjv8GsX/mhP6UsC1lRwbUWg==", + "requires": {} + }, + "@esbuild/android-arm": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/android-arm/-/android-arm-0.16.9.tgz", + "integrity": "sha512-kW5ccqWHVOOTGUkkJbtfoImtqu3kA1PFkivM+9QPFSHphPfPBlBalX9eDRqPK+wHCqKhU48/78T791qPgC9e9A==", + "dev": true, + "optional": true + }, + "@esbuild/android-arm64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/android-arm64/-/android-arm64-0.16.9.tgz", + "integrity": "sha512-ndIAZJUeLx4O+4AJbFQCurQW4VRUXjDsUvt1L+nP8bVELOWdmdCEOtlIweCUE6P+hU0uxYbEK2AEP0n5IVQvhg==", + "dev": true, + "optional": true + }, + "@esbuild/android-x64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/android-x64/-/android-x64-0.16.9.tgz", + "integrity": "sha512-UbMcJB4EHrAVOnknQklREPgclNU2CPet2h+sCBCXmF2mfoYWopBn/CfTfeyOkb/JglOcdEADqAljFndMKnFtOw==", + "dev": true, + "optional": true + }, + "@esbuild/darwin-arm64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/darwin-arm64/-/darwin-arm64-0.16.9.tgz", + "integrity": "sha512-d7D7/nrt4CxPul98lx4PXhyNZwTYtbdaHhOSdXlZuu5zZIznjqtMqLac8Bv+IuT6SVHiHUwrkL6ywD7mOgLW+A==", + "dev": true, + "optional": true + }, + "@esbuild/darwin-x64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/darwin-x64/-/darwin-x64-0.16.9.tgz", + "integrity": "sha512-LZc+Wlz06AkJYtwWsBM3x2rSqTG8lntDuftsUNQ3fCx9ZttYtvlDcVtgb+NQ6t9s6K5No5zutN3pcjZEC2a4iQ==", + "dev": true, + "optional": true + }, + "@esbuild/freebsd-arm64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.16.9.tgz", + "integrity": "sha512-gIj0UQZlQo93CHYouHKkpzP7AuruSaMIm1etcWIxccFEVqCN1xDr6BWlN9bM+ol/f0W9w3hx3HDuEwcJVtGneQ==", + "dev": true, + "optional": true + }, + "@esbuild/freebsd-x64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/freebsd-x64/-/freebsd-x64-0.16.9.tgz", + "integrity": "sha512-GNors4vaMJ7lzGOuhzNc7jvgsQZqErGA8rsW+nck8N1nYu86CvsJW2seigVrQQWOV4QzEP8Zf3gm+QCjA2hnBQ==", + "dev": true, + "optional": true + }, + "@esbuild/linux-arm": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-arm/-/linux-arm-0.16.9.tgz", + "integrity": "sha512-cNx1EF99c2t1Ztn0lk9N+MuwBijGF8mH6nx9GFsB3e0lpUpPkCE/yt5d+7NP9EwJf5uzqdjutgVYoH1SNqzudA==", + "dev": true, + "optional": true + }, + "@esbuild/linux-arm64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-arm64/-/linux-arm64-0.16.9.tgz", + "integrity": "sha512-YPxQunReYp8RQ1FvexFrOEqqf+nLbS3bKVZF5FRT2uKM7Wio7BeATqAwO02AyrdSEntt3I5fhFsujUChIa8CZg==", + "dev": true, + "optional": true + }, + "@esbuild/linux-ia32": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-ia32/-/linux-ia32-0.16.9.tgz", + "integrity": "sha512-zb12ixDIKNwFpIqR00J88FFitVwOEwO78EiUi8wi8FXlmSc3GtUuKV/BSO+730Kglt0B47+ZrJN1BhhOxZaVrw==", + "dev": true, + "optional": true + }, + "@esbuild/linux-loong64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-loong64/-/linux-loong64-0.16.9.tgz", + "integrity": "sha512-X8te4NLxtHiNT6H+4Pfm5RklzItA1Qy4nfyttihGGX+Koc53Ar20ViC+myY70QJ8PDEOehinXZj/F7QK3A+MKQ==", + "dev": true, + "optional": true + }, + "@esbuild/linux-mips64el": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-mips64el/-/linux-mips64el-0.16.9.tgz", + "integrity": "sha512-ZqyMDLt02c5smoS3enlF54ndK5zK4IpClLTxF0hHfzHJlfm4y8IAkIF8LUW0W7zxcKy7oAwI7BRDqeVvC120SA==", + "dev": true, + "optional": true + }, + "@esbuild/linux-ppc64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-ppc64/-/linux-ppc64-0.16.9.tgz", + "integrity": "sha512-k+ca5W5LDBEF3lfDwMV6YNXwm4wEpw9krMnNvvlNz3MrKSD2Eb2c861O0MaKrZkG/buTQAP4vkavbLwgIe6xjg==", + "dev": true, + "optional": true + }, + "@esbuild/linux-riscv64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-riscv64/-/linux-riscv64-0.16.9.tgz", + "integrity": "sha512-GuInVdogjmg9DhgkEmNipHkC+3tzkanPJzgzTC2ihsvrruLyFoR1YrTGixblNSMPudQLpiqkcwGwwe0oqfrvfA==", + "dev": true, + "optional": true + }, + "@esbuild/linux-s390x": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-s390x/-/linux-s390x-0.16.9.tgz", + "integrity": "sha512-49wQ0aYkvwXonGsxc7LuuLNICMX8XtO92Iqmug5Qau0kpnV6SP34jk+jIeu4suHwAbSbRhVFtDv75yRmyfQcHw==", + "dev": true, + "optional": true + }, + "@esbuild/linux-x64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-x64/-/linux-x64-0.16.9.tgz", + "integrity": "sha512-Nx4oKEAJ6EcQlt4dK7qJyuZUoXZG7CAeY22R7rqZijFzwFfMOD+gLP56uV7RrV86jGf8PeRY8TBsRmOcZoG42w==", + "dev": true, + "optional": true + }, + "@esbuild/netbsd-x64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/netbsd-x64/-/netbsd-x64-0.16.9.tgz", + "integrity": "sha512-d0WnpgJ+FTiMZXEQ1NOv9+0gvEhttbgKEvVqWWAtl1u9AvlspKXbodKHzQ5MLP6YV1y52Xp+p8FMYqj8ykTahg==", + "dev": true, + "optional": true + }, + "@esbuild/openbsd-x64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/openbsd-x64/-/openbsd-x64-0.16.9.tgz", + "integrity": "sha512-jccK11278dvEscHFfMk5EIPjF4wv1qGD0vps7mBV1a6TspdR36O28fgPem/SA/0pcsCPHjww5ouCLwP+JNAFlw==", + "dev": true, + "optional": true + }, + "@esbuild/sunos-x64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/sunos-x64/-/sunos-x64-0.16.9.tgz", + "integrity": "sha512-OetwTSsv6mIDLqN7I7I2oX9MmHGwG+AP+wKIHvq+6sIHwcPPJqRx+DJB55jy9JG13CWcdcQno/7V5MTJ5a0xfQ==", + "dev": true, + "optional": true + }, + "@esbuild/win32-arm64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/win32-arm64/-/win32-arm64-0.16.9.tgz", + "integrity": "sha512-tKSSSK6unhxbGbHg+Cc+JhRzemkcsX0tPBvG0m5qsWbkShDK9c+/LSb13L18LWVdOQZwuA55Vbakxmt6OjBDOQ==", + "dev": true, + "optional": true + }, + "@esbuild/win32-ia32": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/win32-ia32/-/win32-ia32-0.16.9.tgz", + "integrity": "sha512-ZTQ5vhNS5gli0KK8I6/s6+LwXmNEfq1ftjnSVyyNm33dBw8zDpstqhGXYUbZSWWLvkqiRRjgxgmoncmi6Yy7Ng==", + "dev": true, + "optional": true + }, + "@esbuild/win32-x64": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/@esbuild/win32-x64/-/win32-x64-0.16.9.tgz", + "integrity": "sha512-C4ZX+YFIp6+lPrru3tpH6Gaapy8IBRHw/e7l63fzGDhn/EaiGpQgbIlT5paByyy+oMvRFQoxxyvC4LE0AjJMqQ==", + "dev": true, + "optional": true + }, + "@eslint/eslintrc": { + "version": "1.4.0", + "resolved": "https://registry.npmmirror.com/@eslint/eslintrc/-/eslintrc-1.4.0.tgz", + "integrity": "sha512-7yfvXy6MWLgWSFsLhz5yH3iQ52St8cdUY6FoGieKkRDVxuxmrNuUetIuu6cmjNWwniUHiWXjxCr5tTXDrbYS5A==", + "dev": true, + "requires": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.4.0", + "globals": "^13.19.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "dependencies": { + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + } + } + }, + "@floating-ui/core": { + "version": "1.5.0", + "resolved": "https://registry.npmmirror.com/@floating-ui/core/-/core-1.5.0.tgz", + "integrity": "sha512-kK1h4m36DQ0UHGj5Ah4db7R0rHemTqqO0QLvUqi1/mUUp3LuAWbWxdxSIf/XsnH9VS6rRVPLJCncjRzUvyCLXg==", + "requires": { + "@floating-ui/utils": "^0.1.3" + } + }, + "@floating-ui/dom": { + "version": "1.5.3", + "resolved": "https://registry.npmmirror.com/@floating-ui/dom/-/dom-1.5.3.tgz", + "integrity": "sha512-ClAbQnEqJAKCJOEbbLo5IUlZHkNszqhuxS4fHAVxRPXPya6Ysf2G8KypnYcOTpx6I8xcgF9bbHb6g/2KpbV8qA==", + "requires": { + "@floating-ui/core": "^1.4.2", + "@floating-ui/utils": "^0.1.3" + } + }, + "@floating-ui/utils": { + "version": "0.1.6", + "resolved": "https://registry.npmmirror.com/@floating-ui/utils/-/utils-0.1.6.tgz", + "integrity": "sha512-OfX7E2oUDYxtBvsuS4e/jSn4Q9Qb6DzgeYtsAdkPZ47znpoNsMgZw0+tVijiv3uGNR6dgNlty6r9rzIzHjtd/A==" + }, + "@highlightjs/vue-plugin": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/@highlightjs/vue-plugin/-/vue-plugin-2.1.0.tgz", + "integrity": "sha512-E+bmk4ncca+hBEYRV2a+1aIzIV0VSY/e5ArjpuSN9IO7wBJrzUE2u4ESCwrbQD7sAy+jWQjkV5qCCWgc+pu7CQ==", + "requires": {} + }, + "@humanwhocodes/config-array": { + "version": "0.11.8", + "resolved": "https://registry.npmmirror.com/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", + "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", + "dev": true, + "requires": { + "@humanwhocodes/object-schema": "^1.2.1", + "debug": "^4.1.1", + "minimatch": "^3.0.5" + }, + "dependencies": { + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + } + } + }, + "@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true + }, + "@humanwhocodes/object-schema": { + "version": "1.2.1", + "resolved": "https://registry.npmmirror.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", + "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", + "dev": true + }, + "@intlify/core-base": { + "version": "9.1.10", + "resolved": "https://registry.npmjs.org/@intlify/core-base/-/core-base-9.1.10.tgz", + "integrity": "sha512-So9CNUavB/IsZ+zBmk2Cv6McQp6vc2wbGi1S0XQmJ8Vz+UFcNn9MFXAe9gY67PreIHrbLsLxDD0cwo1qsxM1Nw==", + "requires": { + "@intlify/devtools-if": "9.1.10", + "@intlify/message-compiler": "9.1.10", + "@intlify/message-resolver": "9.1.10", + "@intlify/runtime": "9.1.10", + "@intlify/shared": "9.1.10", + "@intlify/vue-devtools": "9.1.10" + } + }, + "@intlify/devtools-if": { + "version": "9.1.10", + "resolved": "https://registry.npmjs.org/@intlify/devtools-if/-/devtools-if-9.1.10.tgz", + "integrity": "sha512-SHaKoYu6sog3+Q8js1y3oXLywuogbH1sKuc7NSYkN3GElvXSBaMoCzW+we0ZSFqj/6c7vTNLg9nQ6rxhKqYwnQ==", + "requires": { + "@intlify/shared": "9.1.10" + } + }, + "@intlify/message-compiler": { + "version": "9.1.10", + "resolved": "https://registry.npmjs.org/@intlify/message-compiler/-/message-compiler-9.1.10.tgz", + "integrity": "sha512-+JiJpXff/XTb0EadYwdxOyRTB0hXNd4n1HaJ/a4yuV960uRmPXaklJsedW0LNdcptd/hYUZtCkI7Lc9J5C1gxg==", + "requires": { + "@intlify/message-resolver": "9.1.10", + "@intlify/shared": "9.1.10", + "source-map": "0.6.1" + } + }, + "@intlify/message-resolver": { + "version": "9.1.10", + "resolved": "https://registry.npmjs.org/@intlify/message-resolver/-/message-resolver-9.1.10.tgz", + "integrity": "sha512-5YixMG/M05m0cn9+gOzd4EZQTFRUu8RGhzxJbR1DWN21x/Z3bJ8QpDYj6hC4FwBj5uKsRfKpJQ3Xqg98KWoA+w==" + }, + "@intlify/runtime": { + "version": "9.1.10", + "resolved": "https://registry.npmjs.org/@intlify/runtime/-/runtime-9.1.10.tgz", + "integrity": "sha512-7QsuByNzpe3Gfmhwq6hzgXcMPpxz8Zxb/XFI6s9lQdPLPe5Lgw4U1ovRPZTOs6Y2hwitR3j/HD8BJNGWpJnOFA==", + "requires": { + "@intlify/message-compiler": "9.1.10", + "@intlify/message-resolver": "9.1.10", + "@intlify/shared": "9.1.10" + } + }, + "@intlify/shared": { + "version": "9.1.10", + "resolved": "https://registry.npmjs.org/@intlify/shared/-/shared-9.1.10.tgz", + "integrity": "sha512-Om54xJeo1Vw+K1+wHYyXngE8cAbrxZHpWjYzMR9wCkqbhGtRV5VLhVc214Ze2YatPrWlS2WSMOWXR8JktX/IgA==" + }, + "@intlify/vue-devtools": { + "version": "9.1.10", + "resolved": "https://registry.npmjs.org/@intlify/vue-devtools/-/vue-devtools-9.1.10.tgz", + "integrity": "sha512-5l3qYARVbkWAkagLu1XbDUWRJSL8br1Dj60wgMaKB0+HswVsrR6LloYZTg7ozyvM621V6+zsmwzbQxbVQyrytQ==", + "requires": { + "@intlify/message-resolver": "9.1.10", + "@intlify/runtime": "9.1.10", + "@intlify/shared": "9.1.10" + } + }, + "@jridgewell/gen-mapping": { + "version": "0.3.3", + "resolved": "https://registry.npmmirror.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", + "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", + "requires": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + } + }, + "@jridgewell/resolve-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmmirror.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==" + }, + "@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmmirror.com/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==" + }, + "@jridgewell/source-map": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.5.tgz", + "integrity": "sha512-UTYAUj/wviwdsMfzoSJspJxbkH5o1snzwX0//0ENX1u/55kkZZkcTZP6u9bwKGkv+dkk9at4m1Cpt0uY80kcpQ==", + "requires": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + } + }, + "@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmmirror.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==" + }, + "@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmmirror.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "requires": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "@layui/icons-vue": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@layui/icons-vue/-/icons-vue-1.1.0.tgz", + "integrity": "sha512-ndc53qyUZSslUkO8ZHeBMh6i4gSTtAUqsPpKQZWML0JH6E/X3LIySe6LATeqEMmD7wWSnHJ+WBVGO4ij85Dk1g==" + }, + "@layui/layer-vue": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@layui/layer-vue/-/layer-vue-2.1.1.tgz", + "integrity": "sha512-lk9UoDQmLvtqrgdK+zeizp8KZy8pQfzX7dzHhAv+Qc74L1WC2jipb2hpYmaksiKX1lihy0D9eWWycMbnRn7V9A==", + "requires": { + "@layui/icons-vue": "1.1.0" + } + }, + "@layui/layui-vue": { + "version": "2.11.5", + "resolved": "https://registry.npmjs.org/@layui/layui-vue/-/layui-vue-2.11.5.tgz", + "integrity": "sha512-KZ5xrOm+B27yrEMWSuIGPLgLxUjISWuq0ecU4BcwrasCjEklfLS9UZBQp3peRWRsD6PGXP/cet1qQiD0AnUCJg==", + "requires": { + "@babel/types": "7.21.0", + "@ctrl/tinycolor": "^3.4.1", + "@layui/icons-vue": "1.1.0", + "@layui/layer-vue": "2.1.1", + "@rollup/plugin-terser": "0.4.3", + "@types/qrcode": "1.5.0", + "@umijs/ssr-darkreader": "^4.9.45", + "@vueuse/core": "8.7.3", + "async-validator": "^4.1.1", + "cropperjs": "^1.5.12", + "dayjs": "^1.11.7", + "evtd": "^0.2.3", + "jsbarcode": "3.11.5", + "qrcode": "1.5.0", + "vue-i18n": "9.1.10" + }, + "dependencies": { + "@vueuse/core": { + "version": "8.7.3", + "resolved": "https://registry.npmjs.org/@vueuse/core/-/core-8.7.3.tgz", + "integrity": "sha512-jpBnyG9b4wXgk0Dz3I71lfhD0o53t1tZR+NoAQ+17zJy7MP/VDfGIkq8GcqpDwmptLCmGiGVipkPbWmDGMic8Q==", + "requires": { + "@vueuse/metadata": "8.7.3", + "@vueuse/shared": "8.7.3", + "vue-demi": "*" + } + }, + "@vueuse/metadata": { + "version": "8.7.3", + "resolved": "https://registry.npmjs.org/@vueuse/metadata/-/metadata-8.7.3.tgz", + "integrity": "sha512-spf9kgCsBEFbQb90I6SIqAWh1yP5T1JoJGj+/04+VTMIHXKzn3iecmHUalg8QEOCPNtnFQGNEw5OLg0L39eizg==" + }, + "@vueuse/shared": { + "version": "8.7.3", + "resolved": "https://registry.npmjs.org/@vueuse/shared/-/shared-8.7.3.tgz", + "integrity": "sha512-PMc/h6cEakJ4+5VuNUGi7RnbA6CkLvtG2230x8w3zYJpW1P6Qphh9+dFFvHn7TX+RlaicF5ND0RX1NxWmAoW7w==", + "requires": { + "vue-demi": "*" + } + }, + "vue-demi": { + "version": "0.14.6", + "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.14.6.tgz", + "integrity": "sha512-8QA7wrYSHKaYgUxDA5ZC24w+eHm3sYCbp0EzcDwKqN3p6HqtTCGR/GVsPyZW92unff4UlcSh++lmqDWN3ZIq4w==", + "requires": {} + } + } + }, + "@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmmirror.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "requires": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + } + }, + "@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmmirror.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true + }, + "@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmmirror.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "requires": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + } + }, + "@popperjs/core": { + "version": "npm:@sxzz/popperjs-es@2.11.7", + "resolved": "https://registry.npmmirror.com/@sxzz/popperjs-es/-/popperjs-es-2.11.7.tgz", + "integrity": "sha512-Ccy0NlLkzr0Ex2FKvh2X+OyERHXJ88XJ1MXtsI9y9fGexlaXaVTPzBCRBwIxFkORuOb+uBqeu+RqnpgYTEZRUQ==" + }, + "@rollup/plugin-terser": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.4.3.tgz", + "integrity": "sha512-EF0oejTMtkyhrkwCdg0HJ0IpkcaVg1MMSf2olHb2Jp+1mnLM04OhjpJWGma4HobiDTF0WCyViWuvadyE9ch2XA==", + "requires": { + "serialize-javascript": "^6.0.1", + "smob": "^1.0.0", + "terser": "^5.17.4" + } + }, + "@rollup/pluginutils": { + "version": "4.2.1", + "resolved": "https://registry.npmmirror.com/@rollup/pluginutils/-/pluginutils-4.2.1.tgz", + "integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==", + "dev": true, + "requires": { + "estree-walker": "^2.0.1", + "picomatch": "^2.2.2" + } + }, + "@transloadit/prettier-bytes": { + "version": "0.0.7", + "resolved": "https://registry.npmmirror.com/@transloadit/prettier-bytes/-/prettier-bytes-0.0.7.tgz", + "integrity": "sha512-VeJbUb0wEKbcwaSlj5n+LscBl9IPgLPkHVGBkh00cztv6X4L/TJXK58LzFuBKX7/GAfiGhIwH67YTLTlzvIzBA==" + }, + "@types/ejs": { + "version": "3.1.5", + "resolved": "https://registry.npmmirror.com/@types/ejs/-/ejs-3.1.5.tgz", + "integrity": "sha512-nv+GSx77ZtXiJzwKdsASqi+YQ5Z7vwHsTP0JY2SiQgjGckkBRKZnk8nIM+7oUZ1VCtuTz0+By4qVR7fqzp/Dfg==", + "dev": true + }, + "@types/eslint": { + "version": "8.4.10", + "resolved": "https://registry.npmmirror.com/@types/eslint/-/eslint-8.4.10.tgz", + "integrity": "sha512-Sl/HOqN8NKPmhWo2VBEPm0nvHnu2LL3v9vKo8MEq0EtbJ4eVzGPl41VNPvn5E1i5poMk4/XD8UriLHpJvEP/Nw==", + "dev": true, + "requires": { + "@types/estree": "*", + "@types/json-schema": "*" + } + }, + "@types/estree": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/@types/estree/-/estree-1.0.0.tgz", + "integrity": "sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ==", + "dev": true + }, + "@types/event-emitter": { + "version": "0.3.5", + "resolved": "https://registry.npmmirror.com/@types/event-emitter/-/event-emitter-0.3.5.tgz", + "integrity": "sha512-zx2/Gg0Eg7gwEiOIIh5w9TrhKKTeQh7CPCOPNc0el4pLSwzebA8SmnHwZs2dWlLONvyulykSwGSQxQHLhjGLvQ==" + }, + "@types/json-bigint": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@types/json-bigint/-/json-bigint-1.0.4.tgz", + "integrity": "sha512-ydHooXLbOmxBbubnA7Eh+RpBzuaIiQjh8WGJYQB50JFGFrdxW7JzVlyEV7fAXw0T2sqJ1ysTneJbiyNLqZRAag==", + "dev": true + }, + "@types/json-schema": { + "version": "7.0.11", + "resolved": "https://registry.npmmirror.com/@types/json-schema/-/json-schema-7.0.11.tgz", + "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", + "dev": true + }, + "@types/json5": { + "version": "0.0.29", + "resolved": "https://registry.npmmirror.com/@types/json5/-/json5-0.0.29.tgz", + "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", + "dev": true + }, + "@types/lodash": { + "version": "4.14.201", + "resolved": "https://registry.npmmirror.com/@types/lodash/-/lodash-4.14.201.tgz", + "integrity": "sha512-y9euML0cim1JrykNxADLfaG0FgD1g/yTHwUs/Jg9ZIU7WKj2/4IW9Lbb1WZbvck78W/lfGXFfe+u2EGfIJXdLQ==" + }, + "@types/lodash-es": { + "version": "4.17.11", + "resolved": "https://registry.npmmirror.com/@types/lodash-es/-/lodash-es-4.17.11.tgz", + "integrity": "sha512-eCw8FYAWHt2DDl77s+AMLLzPn310LKohruumpucZI4oOFJkIgnlaJcy23OKMJxx4r9PeTF13Gv6w+jqjWQaYUg==", + "requires": { + "@types/lodash": "*" + } + }, + "@types/node": { + "version": "18.11.17", + "resolved": "https://registry.npmmirror.com/@types/node/-/node-18.11.17.tgz", + "integrity": "sha512-HJSUJmni4BeDHhfzn6nF0sVmd1SMezP7/4F0Lq+aXzmp2xm9O7WXrUtHW/CHlYVtZUbByEvWidHqRtcJXGF2Ng==" + }, + "@types/qrcode": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.5.0.tgz", + "integrity": "sha512-x5ilHXRxUPIMfjtM+1vf/GPTRWZ81nqscursm5gMznJeK9M0YnZ1c3bEvRLQ0zSSgedLx1J6MGL231ObQGGhaA==", + "requires": { + "@types/node": "*" + } + }, + "@types/semver": { + "version": "7.3.13", + "resolved": "https://registry.npmmirror.com/@types/semver/-/semver-7.3.13.tgz", + "integrity": "sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==", + "dev": true + }, + "@types/sortablejs": { + "version": "1.15.7", + "resolved": "https://registry.npmmirror.com/@types/sortablejs/-/sortablejs-1.15.7.tgz", + "integrity": "sha512-PvgWCx1Lbgm88FdQ6S7OGvLIjWS66mudKPlfdrWil0TjsO5zmoZmzoKiiwRShs1dwPgrlkr0N4ewuy0/+QUXYQ==", + "peer": true + }, + "@types/web-bluetooth": { + "version": "0.0.16", + "resolved": "https://registry.npmmirror.com/@types/web-bluetooth/-/web-bluetooth-0.0.16.tgz", + "integrity": "sha512-oh8q2Zc32S6gd/j50GowEjKLoOVOwHP/bWVjKJInBwQqdOYMdPrf1oVlelTlyfFK3CKxL1uahMDAr+vy8T7yMQ==" + }, + "@typescript-eslint/eslint-plugin": { + "version": "5.46.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.46.1.tgz", + "integrity": "sha512-YpzNv3aayRBwjs4J3oz65eVLXc9xx0PDbIRisHj+dYhvBn02MjYOD96P8YGiWEIFBrojaUjxvkaUpakD82phsA==", + "dev": true, + "requires": { + "@typescript-eslint/scope-manager": "5.46.1", + "@typescript-eslint/type-utils": "5.46.1", + "@typescript-eslint/utils": "5.46.1", + "debug": "^4.3.4", + "ignore": "^5.2.0", + "natural-compare-lite": "^1.4.0", + "regexpp": "^3.2.0", + "semver": "^7.3.7", + "tsutils": "^3.21.0" + } + }, + "@typescript-eslint/parser": { + "version": "5.46.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/parser/-/parser-5.46.1.tgz", + "integrity": "sha512-RelQ5cGypPh4ySAtfIMBzBGyrNerQcmfA1oJvPj5f+H4jI59rl9xxpn4bonC0tQvUKOEN7eGBFWxFLK3Xepneg==", + "dev": true, + "requires": { + "@typescript-eslint/scope-manager": "5.46.1", + "@typescript-eslint/types": "5.46.1", + "@typescript-eslint/typescript-estree": "5.46.1", + "debug": "^4.3.4" + } + }, + "@typescript-eslint/scope-manager": { + "version": "5.46.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/scope-manager/-/scope-manager-5.46.1.tgz", + "integrity": "sha512-iOChVivo4jpwUdrJZyXSMrEIM/PvsbbDOX1y3UCKjSgWn+W89skxWaYXACQfxmIGhPVpRWK/VWPYc+bad6smIA==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.46.1", + "@typescript-eslint/visitor-keys": "5.46.1" + } + }, + "@typescript-eslint/type-utils": { + "version": "5.46.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/type-utils/-/type-utils-5.46.1.tgz", + "integrity": "sha512-V/zMyfI+jDmL1ADxfDxjZ0EMbtiVqj8LUGPAGyBkXXStWmCUErMpW873zEHsyguWCuq2iN4BrlWUkmuVj84yng==", + "dev": true, + "requires": { + "@typescript-eslint/typescript-estree": "5.46.1", + "@typescript-eslint/utils": "5.46.1", + "debug": "^4.3.4", + "tsutils": "^3.21.0" + } + }, + "@typescript-eslint/types": { + "version": "5.46.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/types/-/types-5.46.1.tgz", + "integrity": "sha512-Z5pvlCaZgU+93ryiYUwGwLl9AQVB/PQ1TsJ9NZ/gHzZjN7g9IAn6RSDkpCV8hqTwAiaj6fmCcKSQeBPlIpW28w==", + "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "5.46.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.46.1.tgz", + "integrity": "sha512-j9W4t67QiNp90kh5Nbr1w92wzt+toiIsaVPnEblB2Ih2U9fqBTyqV9T3pYWZBRt6QoMh/zVWP59EpuCjc4VRBg==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.46.1", + "@typescript-eslint/visitor-keys": "5.46.1", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "semver": "^7.3.7", + "tsutils": "^3.21.0" + } + }, + "@typescript-eslint/utils": { + "version": "5.46.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/utils/-/utils-5.46.1.tgz", + "integrity": "sha512-RBdBAGv3oEpFojaCYT4Ghn4775pdjvwfDOfQ2P6qzNVgQOVrnSPe5/Pb88kv7xzYQjoio0eKHKB9GJ16ieSxvA==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.9", + "@types/semver": "^7.3.12", + "@typescript-eslint/scope-manager": "5.46.1", + "@typescript-eslint/types": "5.46.1", + "@typescript-eslint/typescript-estree": "5.46.1", + "eslint-scope": "^5.1.1", + "eslint-utils": "^3.0.0", + "semver": "^7.3.7" + }, + "dependencies": { + "eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmmirror.com/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "requires": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + } + }, + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmmirror.com/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true + } + } + }, + "@typescript-eslint/visitor-keys": { + "version": "5.46.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.46.1.tgz", + "integrity": "sha512-jczZ9noovXwy59KjRTk1OftT78pwygdcmCuBf8yMoWt/8O8l+6x2LSEze0E4TeepXK4MezW3zGSyoDRZK7Y9cg==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.46.1", + "eslint-visitor-keys": "^3.3.0" + } + }, + "@umijs/ssr-darkreader": { + "version": "4.9.45", + "resolved": "https://registry.npmjs.org/@umijs/ssr-darkreader/-/ssr-darkreader-4.9.45.tgz", + "integrity": "sha512-XlcwzSYQ/SRZpHdwIyMDS4FOGX5kP4U/2g2mykyn/iPQTK4xTiQAyBu6UnnDnn7d5P8s7Atzh1C7H0ETNOypJg==" + }, + "@uppy/companion-client": { + "version": "2.2.2", + "resolved": "https://registry.npmmirror.com/@uppy/companion-client/-/companion-client-2.2.2.tgz", + "integrity": "sha512-5mTp2iq97/mYSisMaBtFRry6PTgZA6SIL7LePteOV5x0/DxKfrZW3DEiQERJmYpHzy7k8johpm2gHnEKto56Og==", + "requires": { + "@uppy/utils": "^4.1.2", + "namespace-emitter": "^2.0.1" + } + }, + "@uppy/core": { + "version": "2.3.4", + "resolved": "https://registry.npmmirror.com/@uppy/core/-/core-2.3.4.tgz", + "integrity": "sha512-iWAqppC8FD8mMVqewavCz+TNaet6HPXitmGXpGGREGrakZ4FeuWytVdrelydzTdXx6vVKkOmI2FLztGg73sENQ==", + "requires": { + "@transloadit/prettier-bytes": "0.0.7", + "@uppy/store-default": "^2.1.1", + "@uppy/utils": "^4.1.3", + "lodash.throttle": "^4.1.1", + "mime-match": "^1.0.2", + "namespace-emitter": "^2.0.1", + "nanoid": "^3.1.25", + "preact": "^10.5.13" + } + }, + "@uppy/store-default": { + "version": "2.1.1", + "resolved": "https://registry.npmmirror.com/@uppy/store-default/-/store-default-2.1.1.tgz", + "integrity": "sha512-xnpTxvot2SeAwGwbvmJ899ASk5tYXhmZzD/aCFsXePh/v8rNvR2pKlcQUH7cF/y4baUGq3FHO/daKCok/mpKqQ==" + }, + "@uppy/utils": { + "version": "4.1.3", + "resolved": "https://registry.npmmirror.com/@uppy/utils/-/utils-4.1.3.tgz", + "integrity": "sha512-nTuMvwWYobnJcytDO3t+D6IkVq/Qs4Xv3vyoEZ+Iaf8gegZP+rEyoaFT2CK5XLRMienPyqRqNbIfRuFaOWSIFw==", + "requires": { + "lodash.throttle": "^4.1.1" + } + }, + "@uppy/xhr-upload": { + "version": "2.1.3", + "resolved": "https://registry.npmmirror.com/@uppy/xhr-upload/-/xhr-upload-2.1.3.tgz", + "integrity": "sha512-YWOQ6myBVPs+mhNjfdWsQyMRWUlrDLMoaG7nvf/G6Y3GKZf8AyjFDjvvJ49XWQ+DaZOftGkHmF1uh/DBeGivJQ==", + "requires": { + "@uppy/companion-client": "^2.2.2", + "@uppy/utils": "^4.1.2", + "nanoid": "^3.1.25" + } + }, + "@vant/auto-import-resolver": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/@vant/auto-import-resolver/-/auto-import-resolver-1.0.2.tgz", + "integrity": "sha512-5SYC1izl36KID+3F4pqFtYD8VFK6m1pdulft99sjSkUN4GBX9OslRnsJA0g7xS+0YrytjDuxxBk04YLYIxaYMg==", + "dev": true + }, + "@vant/popperjs": { + "version": "1.3.0", + "resolved": "https://registry.npmmirror.com/@vant/popperjs/-/popperjs-1.3.0.tgz", + "integrity": "sha512-hB+czUG+aHtjhaEmCJDuXOep0YTZjdlRR+4MSmIFnkCQIxJaXLQdSsR90XWvAI2yvKUI7TCGqR8pQg2RtvkMHw==" + }, + "@vant/use": { + "version": "1.6.0", + "resolved": "https://registry.npmmirror.com/@vant/use/-/use-1.6.0.tgz", + "integrity": "sha512-PHHxeAASgiOpSmMjceweIrv2AxDZIkWXyaczksMoWvKV2YAYEhoizRuk/xFnKF+emUIi46TsQ+rvlm/t2BBCfA==", + "requires": {} + }, + "@vitejs/plugin-vue": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/@vitejs/plugin-vue/-/plugin-vue-4.0.0.tgz", + "integrity": "sha512-e0X4jErIxAB5oLtDqbHvHpJe/uWNkdpYV83AOG2xo2tEVSzCzewgJMtREZM30wXnM5ls90hxiOtAuVU6H5JgbA==", + "dev": true, + "requires": {} + }, + "@volar/language-core": { + "version": "1.0.14", + "resolved": "https://registry.npmmirror.com/@volar/language-core/-/language-core-1.0.14.tgz", + "integrity": "sha512-j1tMQgw0qCV2amM4qDJNG/zc0yj3ay8HoWNt05IaiCPsULtSSpF/9+F6Izvn0DF7nWOd6MUHTxaQAeZwLfr56Q==", + "dev": true, + "requires": { + "@volar/source-map": "1.0.14", + "@vue/reactivity": "^3.2.45", + "muggle-string": "^0.1.0" + } + }, + "@volar/source-map": { + "version": "1.0.14", + "resolved": "https://registry.npmmirror.com/@volar/source-map/-/source-map-1.0.14.tgz", + "integrity": "sha512-8pHCbEWHWaSDGb/FM9zRIW1lY1OAo16MENVSQGCgTwz7PWf3Gw6WW3TFVKCtzaFhLjPH0i5e9hALy7vBPbSHoA==", + "dev": true, + "requires": { + "muggle-string": "^0.1.0" + } + }, + "@volar/typescript": { + "version": "1.0.14", + "resolved": "https://registry.npmmirror.com/@volar/typescript/-/typescript-1.0.14.tgz", + "integrity": "sha512-67qcjjz7KGFhMCG9EKMA9qJK3BRGQecO4dGyAKfMfClZ/PaVoKfDvJvYo89McGTQ8SeczD48I9TPnaJM0zK8JQ==", + "dev": true, + "requires": { + "@volar/language-core": "1.0.14" + } + }, + "@volar/vue-language-core": { + "version": "1.0.14", + "resolved": "https://registry.npmmirror.com/@volar/vue-language-core/-/vue-language-core-1.0.14.tgz", + "integrity": "sha512-grJ4dQ7c/suZmBBmZtw2O2XeDX+rtgpdBtHxMug1NMPRDxj5EZ9WGphWtGnMQj8RyVgpz9ByvV5GbQjk4/wfBw==", + "dev": true, + "requires": { + "@volar/language-core": "1.0.14", + "@volar/source-map": "1.0.14", + "@vue/compiler-dom": "^3.2.45", + "@vue/compiler-sfc": "^3.2.45", + "@vue/reactivity": "^3.2.45", + "@vue/shared": "^3.2.45", + "minimatch": "^5.1.0", + "vue-template-compiler": "^2.7.14" + } + }, + "@volar/vue-typescript": { + "version": "1.0.14", + "resolved": "https://registry.npmmirror.com/@volar/vue-typescript/-/vue-typescript-1.0.14.tgz", + "integrity": "sha512-2P0QeGLLY05fDTu8GqY8SR2+jldXRTrkQdD2Nc0sVOjMJ7j3RYYY0wJyZ9hCBDuxV4Micc6jdB8nKS0yxQgNvA==", + "dev": true, + "requires": { + "@volar/typescript": "1.0.14", + "@volar/vue-language-core": "1.0.14" + } + }, + "@vue/compiler-core": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.3.8.tgz", + "integrity": "sha512-hN/NNBUECw8SusQvDSqqcVv6gWq8L6iAktUR0UF3vGu2OhzRqcOiAno0FmBJWwxhYEXRlQJT5XnoKsVq1WZx4g==", + "requires": { + "@babel/parser": "^7.23.0", + "@vue/shared": "3.3.8", + "estree-walker": "^2.0.2", + "source-map-js": "^1.0.2" + } + }, + "@vue/compiler-dom": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.3.8.tgz", + "integrity": "sha512-+PPtv+p/nWDd0AvJu3w8HS0RIm/C6VGBIRe24b9hSyNWOAPEUosFZ5diwawwP8ip5sJ8n0Pe87TNNNHnvjs0FQ==", + "requires": { + "@vue/compiler-core": "3.3.8", + "@vue/shared": "3.3.8" + } + }, + "@vue/compiler-sfc": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.3.8.tgz", + "integrity": "sha512-WMzbUrlTjfYF8joyT84HfwwXo+8WPALuPxhy+BZ6R4Aafls+jDBnSz8PDz60uFhuqFbl3HxRfxvDzrUf3THwpA==", + "requires": { + "@babel/parser": "^7.23.0", + "@vue/compiler-core": "3.3.8", + "@vue/compiler-dom": "3.3.8", + "@vue/compiler-ssr": "3.3.8", + "@vue/reactivity-transform": "3.3.8", + "@vue/shared": "3.3.8", + "estree-walker": "^2.0.2", + "magic-string": "^0.30.5", + "postcss": "^8.4.31", + "source-map-js": "^1.0.2" + } + }, + "@vue/compiler-ssr": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.3.8.tgz", + "integrity": "sha512-hXCqQL/15kMVDBuoBYpUnSYT8doDNwsjvm3jTefnXr+ytn294ySnT8NlsFHmTgKNjwpuFy7XVV8yTeLtNl/P6w==", + "requires": { + "@vue/compiler-dom": "3.3.8", + "@vue/shared": "3.3.8" + } + }, + "@vue/devtools-api": { + "version": "6.5.0", + "resolved": "https://registry.npmmirror.com/@vue/devtools-api/-/devtools-api-6.5.0.tgz", + "integrity": "sha512-o9KfBeaBmCKl10usN4crU53fYtC1r7jJwdGKjPT24t348rHxgfpZ0xL3Xm/gLUYnc0oTp8LAmrxOeLyu6tbk2Q==" + }, + "@vue/reactivity": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.3.8.tgz", + "integrity": "sha512-ctLWitmFBu6mtddPyOKpHg8+5ahouoTCRtmAHZAXmolDtuZXfjL2T3OJ6DL6ezBPQB1SmMnpzjiWjCiMYmpIuw==", + "requires": { + "@vue/shared": "3.3.8" + } + }, + "@vue/reactivity-transform": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/@vue/reactivity-transform/-/reactivity-transform-3.3.8.tgz", + "integrity": "sha512-49CvBzmZNtcHua0XJ7GdGifM8GOXoUMOX4dD40Y5DxI3R8OUhMlvf2nvgUAcPxaXiV5MQQ1Nwy09ADpnLQUqRw==", + "requires": { + "@babel/parser": "^7.23.0", + "@vue/compiler-core": "3.3.8", + "@vue/shared": "3.3.8", + "estree-walker": "^2.0.2", + "magic-string": "^0.30.5" + } + }, + "@vue/runtime-core": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.3.8.tgz", + "integrity": "sha512-qurzOlb6q26KWQ/8IShHkMDOuJkQnQcTIp1sdP4I9MbCf9FJeGVRXJFr2mF+6bXh/3Zjr9TDgURXrsCr9bfjUw==", + "requires": { + "@vue/reactivity": "3.3.8", + "@vue/shared": "3.3.8" + } + }, + "@vue/runtime-dom": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.3.8.tgz", + "integrity": "sha512-Noy5yM5UIf9UeFoowBVgghyGGPIDPy1Qlqt0yVsUdAVbqI8eeMSsTqBtauaEoT2UFXUk5S64aWVNJN4MJ2vRdA==", + "requires": { + "@vue/runtime-core": "3.3.8", + "@vue/shared": "3.3.8", + "csstype": "^3.1.2" + } + }, + "@vue/server-renderer": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.3.8.tgz", + "integrity": "sha512-zVCUw7RFskvPuNlPn/8xISbrf0zTWsTSdYTsUTN1ERGGZGVnRxM2QZ3x1OR32+vwkkCm0IW6HmJ49IsPm7ilLg==", + "requires": { + "@vue/compiler-ssr": "3.3.8", + "@vue/shared": "3.3.8" + } + }, + "@vue/shared": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.3.8.tgz", + "integrity": "sha512-8PGwybFwM4x8pcfgqEQFy70NaQxASvOC5DJwLQfpArw1UDfUXrJkdxD3BhVTMS+0Lef/TU7YO0Jvr0jJY8T+mw==" + }, + "@vueuse/core": { + "version": "9.13.0", + "resolved": "https://registry.npmmirror.com/@vueuse/core/-/core-9.13.0.tgz", + "integrity": "sha512-pujnclbeHWxxPRqXWmdkKV5OX4Wk4YeK7wusHqRwU0Q7EFusHoqNA/aPhB6KCh9hEqJkLAJo7bb0Lh9b+OIVzw==", + "requires": { + "@types/web-bluetooth": "^0.0.16", + "@vueuse/metadata": "9.13.0", + "@vueuse/shared": "9.13.0", + "vue-demi": "*" + }, + "dependencies": { + "vue-demi": { + "version": "0.14.6", + "resolved": "https://registry.npmmirror.com/vue-demi/-/vue-demi-0.14.6.tgz", + "integrity": "sha512-8QA7wrYSHKaYgUxDA5ZC24w+eHm3sYCbp0EzcDwKqN3p6HqtTCGR/GVsPyZW92unff4UlcSh++lmqDWN3ZIq4w==", + "requires": {} + } + } + }, + "@vueuse/metadata": { + "version": "9.13.0", + "resolved": "https://registry.npmmirror.com/@vueuse/metadata/-/metadata-9.13.0.tgz", + "integrity": "sha512-gdU7TKNAUVlXXLbaF+ZCfte8BjRJQWPCa2J55+7/h+yDtzw3vOoGQDRXzI6pyKyo6bXFT5/QoPE4hAknExjRLQ==" + }, + "@vueuse/shared": { + "version": "9.13.0", + "resolved": "https://registry.npmmirror.com/@vueuse/shared/-/shared-9.13.0.tgz", + "integrity": "sha512-UrnhU+Cnufu4S6JLCPZnkWh0WwZGUp72ktOF2DFptMlOs3TOdVv8xJN53zhHGARmVOsz5KqOls09+J1NR6sBKw==", + "requires": { + "vue-demi": "*" + }, + "dependencies": { + "vue-demi": { + "version": "0.14.6", + "resolved": "https://registry.npmmirror.com/vue-demi/-/vue-demi-0.14.6.tgz", + "integrity": "sha512-8QA7wrYSHKaYgUxDA5ZC24w+eHm3sYCbp0EzcDwKqN3p6HqtTCGR/GVsPyZW92unff4UlcSh++lmqDWN3ZIq4w==", + "requires": {} + } + } + }, + "@wangeditor/basic-modules": { + "version": "1.1.7", + "resolved": "https://registry.npmmirror.com/@wangeditor/basic-modules/-/basic-modules-1.1.7.tgz", + "integrity": "sha512-cY9CPkLJaqF05STqfpZKWG4LpxTMeGSIIF1fHvfm/mz+JXatCagjdkbxdikOuKYlxDdeqvOeBmsUBItufDLXZg==", + "requires": { + "is-url": "^1.2.4" + } + }, + "@wangeditor/code-highlight": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/@wangeditor/code-highlight/-/code-highlight-1.0.3.tgz", + "integrity": "sha512-iazHwO14XpCuIWJNTQTikqUhGKyqj+dUNWJ9288Oym9M2xMVHvnsOmDU2sgUDWVy+pOLojReMPgXCsvvNlOOhw==", + "requires": { + "prismjs": "^1.23.0" + } + }, + "@wangeditor/core": { + "version": "1.1.19", + "resolved": "https://registry.npmmirror.com/@wangeditor/core/-/core-1.1.19.tgz", + "integrity": "sha512-KevkB47+7GhVszyYF2pKGKtCSj/YzmClsD03C3zTt+9SR2XWT5T0e3yQqg8baZpcMvkjs1D8Dv4fk8ok/UaS2Q==", + "requires": { + "@types/event-emitter": "^0.3.3", + "event-emitter": "^0.3.5", + "html-void-elements": "^2.0.0", + "i18next": "^20.4.0", + "scroll-into-view-if-needed": "^2.2.28", + "slate-history": "^0.66.0" + } + }, + "@wangeditor/editor": { + "version": "5.1.23", + "resolved": "https://registry.npmmirror.com/@wangeditor/editor/-/editor-5.1.23.tgz", + "integrity": "sha512-0RxfeVTuK1tktUaPROnCoFfaHVJpRAIE2zdS0mpP+vq1axVQpLjM8+fCvKzqYIkH0Pg+C+44hJpe3VVroSkEuQ==", + "requires": { + "@uppy/core": "^2.1.1", + "@uppy/xhr-upload": "^2.0.3", + "@wangeditor/basic-modules": "^1.1.7", + "@wangeditor/code-highlight": "^1.0.3", + "@wangeditor/core": "^1.1.19", + "@wangeditor/list-module": "^1.0.5", + "@wangeditor/table-module": "^1.1.4", + "@wangeditor/upload-image-module": "^1.0.2", + "@wangeditor/video-module": "^1.1.4", + "dom7": "^3.0.0", + "is-hotkey": "^0.2.0", + "lodash.camelcase": "^4.3.0", + "lodash.clonedeep": "^4.5.0", + "lodash.debounce": "^4.0.8", + "lodash.foreach": "^4.5.0", + "lodash.isequal": "^4.5.0", + "lodash.throttle": "^4.1.1", + "lodash.toarray": "^4.4.0", + "nanoid": "^3.2.0", + "slate": "^0.72.0", + "snabbdom": "^3.1.0" + } + }, + "@wangeditor/editor-for-vue": { + "version": "5.1.12", + "resolved": "https://registry.npmmirror.com/@wangeditor/editor-for-vue/-/editor-for-vue-5.1.12.tgz", + "integrity": "sha512-0Ds3D8I+xnpNWezAeO7HmPRgTfUxHLMd9JKcIw+QzvSmhC5xUHbpCcLU+KLmeBKTR/zffnS5GQo6qi3GhTMJWQ==", + "requires": {} + }, + "@wangeditor/list-module": { + "version": "1.0.5", + "resolved": "https://registry.npmmirror.com/@wangeditor/list-module/-/list-module-1.0.5.tgz", + "integrity": "sha512-uDuYTP6DVhcYf7mF1pTlmNn5jOb4QtcVhYwSSAkyg09zqxI1qBqsfUnveeDeDqIuptSJhkh81cyxi+MF8sEPOQ==", + "requires": {} + }, + "@wangeditor/table-module": { + "version": "1.1.4", + "resolved": "https://registry.npmmirror.com/@wangeditor/table-module/-/table-module-1.1.4.tgz", + "integrity": "sha512-5saanU9xuEocxaemGdNi9t8MCDSucnykEC6jtuiT72kt+/Hhh4nERYx1J20OPsTCCdVr7hIyQenFD1iSRkIQ6w==", + "requires": {} + }, + "@wangeditor/upload-image-module": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/@wangeditor/upload-image-module/-/upload-image-module-1.0.2.tgz", + "integrity": "sha512-z81lk/v71OwPDYeQDxj6cVr81aDP90aFuywb8nPD6eQeECtOymrqRODjpO6VGvCVxVck8nUxBHtbxKtjgcwyiA==", + "requires": {} + }, + "@wangeditor/video-module": { + "version": "1.1.4", + "resolved": "https://registry.npmmirror.com/@wangeditor/video-module/-/video-module-1.1.4.tgz", + "integrity": "sha512-ZdodDPqKQrgx3IwWu4ZiQmXI8EXZ3hm2/fM6E3t5dB8tCaIGWQZhmqd6P5knfkRAd3z2+YRSRbxOGfoRSp/rLg==", + "requires": {} + }, + "ace-builds": { + "version": "1.32.2", + "resolved": "https://registry.npmmirror.com/ace-builds/-/ace-builds-1.32.2.tgz", + "integrity": "sha512-mnJAc803p+7eeDt07r6XI7ufV7VdkpPq4gJZT8Jb3QsowkaBTVy4tdBgPrVT0WbXLm0toyEQXURKSVNj/7dfJQ==" + }, + "acorn": { + "version": "8.10.0", + "resolved": "https://registry.npmmirror.com/acorn/-/acorn-8.10.0.tgz", + "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==" + }, + "acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmmirror.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "requires": {} + }, + "ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmmirror.com/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmmirror.com/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "requires": { + "color-convert": "^2.0.1" + } + }, + "anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmmirror.com/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, + "array-buffer-byte-length": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/array-buffer-byte-length/-/array-buffer-byte-length-1.0.0.tgz", + "integrity": "sha512-LPuwb2P+NrQw3XhxGc36+XSvuBPopovXYTR9Ew++Du9Yb/bx5AzBfrIsBoj0EZUifjQU+sHL21sseZ3jerWO/A==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "is-array-buffer": "^3.0.1" + } + }, + "array-includes": { + "version": "3.1.7", + "resolved": "https://registry.npmmirror.com/array-includes/-/array-includes-3.1.7.tgz", + "integrity": "sha512-dlcsNBIiWhPkHdOEEKnehA+RNUWDc4UqFtnIXU4uuYDPtA4LDkr7qip2p0VvFAEXNDr0yWZ9PJyIRiGjRLQzwQ==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "get-intrinsic": "^1.2.1", + "is-string": "^1.0.7" + } + }, + "array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true + }, + "array.prototype.findlastindex": { + "version": "1.2.3", + "resolved": "https://registry.npmmirror.com/array.prototype.findlastindex/-/array.prototype.findlastindex-1.2.3.tgz", + "integrity": "sha512-LzLoiOMAxvy+Gd3BAq3B7VeIgPdo+Q8hthvKtXybMvRV0jrXfJM/t8mw7nNlpEcVlVUnCnM2KSX4XU5HmpodOA==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "es-shim-unscopables": "^1.0.0", + "get-intrinsic": "^1.2.1" + } + }, + "array.prototype.flat": { + "version": "1.3.2", + "resolved": "https://registry.npmmirror.com/array.prototype.flat/-/array.prototype.flat-1.3.2.tgz", + "integrity": "sha512-djYB+Zx2vLewY8RWlNCUdHjDXs2XOgm602S9E7P/UpHgfeHL00cRiIF+IN/G/aUJ7kGPb6yO/ErDI5V2s8iycA==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "es-shim-unscopables": "^1.0.0" + } + }, + "array.prototype.flatmap": { + "version": "1.3.2", + "resolved": "https://registry.npmmirror.com/array.prototype.flatmap/-/array.prototype.flatmap-1.3.2.tgz", + "integrity": "sha512-Ewyx0c9PmpcsByhSW4r+9zDU7sGjFc86qf/kKtuSCRdhfbk0SNLLkaT5qvcHnRGgc5NP/ly/y+qkXkqONX54CQ==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "es-shim-unscopables": "^1.0.0" + } + }, + "arraybuffer.prototype.slice": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/arraybuffer.prototype.slice/-/arraybuffer.prototype.slice-1.0.2.tgz", + "integrity": "sha512-yMBKppFur/fbHu9/6USUe03bZ4knMYiwFBcyiaXB8Go0qNehwX6inYPzK9U0NeQvGxKthcmHcaR8P5MStSRBAw==", + "dev": true, + "requires": { + "array-buffer-byte-length": "^1.0.0", + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "get-intrinsic": "^1.2.1", + "is-array-buffer": "^3.0.2", + "is-shared-array-buffer": "^1.0.2" + } + }, + "async": { + "version": "3.2.5", + "resolved": "https://registry.npmmirror.com/async/-/async-3.2.5.tgz", + "integrity": "sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==" + }, + "async-validator": { + "version": "4.2.5", + "resolved": "https://registry.npmmirror.com/async-validator/-/async-validator-4.2.5.tgz", + "integrity": "sha512-7HhHjtERjqlNbZtqNqy2rckN/SpOOlmDliet+lP7k+eKZEjPk3DgyeU9lIXLdeLz0uBbbVp+9Qdow9wJWgwwfg==" + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmmirror.com/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "autoprefixer": { + "version": "10.4.16", + "resolved": "https://registry.npmmirror.com/autoprefixer/-/autoprefixer-10.4.16.tgz", + "integrity": "sha512-7vd3UC6xKp0HLfua5IjZlcXvGAGy7cBAXTg2lyQ/8WpNhd6SiZ8Be+xm3FyBSYJx5GKcpRCzBh7RH4/0dnY+uQ==", + "dev": true, + "requires": { + "browserslist": "^4.21.10", + "caniuse-lite": "^1.0.30001538", + "fraction.js": "^4.3.6", + "normalize-range": "^0.1.2", + "picocolors": "^1.0.0", + "postcss-value-parser": "^4.2.0" + } + }, + "available-typed-arrays": { + "version": "1.0.5", + "resolved": "https://registry.npmmirror.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz", + "integrity": "sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==", + "dev": true + }, + "axios": { + "version": "1.5.1", + "resolved": "https://registry.npmmirror.com/axios/-/axios-1.5.1.tgz", + "integrity": "sha512-Q28iYCWzNHjAm+yEAot5QaAMxhMghWLFVf7rRdwhUI+c2jix2DUXjAHXVi+s1ibs3mjPO/cCgbA++3BjD0vP/A==", + "requires": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "bignumber.js": { + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.2.tgz", + "integrity": "sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==" + }, + "binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmmirror.com/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "dev": true + }, + "boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", + "dev": true + }, + "bpmn-js": { + "version": "7.5.0", + "resolved": "https://registry.npmmirror.com/bpmn-js/-/bpmn-js-7.5.0.tgz", + "integrity": "sha512-0ANaE6Bikg1GmkcvO7RK0MQPX+EKYKBc+q7OWk39/16NcCdNZ/4UiRcCr9n0u1VUCIDsSU/jJ79TIZFnV5CNjw==", + "dev": true, + "requires": { + "bpmn-moddle": "^7.0.4", + "css.escape": "^1.5.1", + "diagram-js": "^6.8.2", + "diagram-js-direct-editing": "^1.6.1", + "ids": "^1.0.0", + "inherits": "^2.0.4", + "min-dash": "^3.5.2", + "min-dom": "^3.1.3", + "object-refs": "^0.3.0", + "tiny-svg": "^2.2.2" + } + }, + "bpmn-js-properties-panel": { + "version": "0.37.6", + "resolved": "https://registry.npmmirror.com/bpmn-js-properties-panel/-/bpmn-js-properties-panel-0.37.6.tgz", + "integrity": "sha512-1rP9r6ItL1gKqXezXnpr9eVsQtdufH6TNqxUs11Q68CtxeBAs0l1wEHw2f01i9ceHHxItmrZUTndqnASi89EYA==", + "dev": true, + "requires": { + "@bpmn-io/extract-process-variables": "^0.3.0", + "ids": "^1.0.0", + "inherits": "^2.0.1", + "lodash": "^4.17.20", + "min-dom": "^3.1.3", + "scroll-tabs": "^1.0.1", + "selection-update": "^0.1.2" + } + }, + "bpmn-js-token-simulation": { + "version": "0.10.0", + "resolved": "https://registry.npmmirror.com/bpmn-js-token-simulation/-/bpmn-js-token-simulation-0.10.0.tgz", + "integrity": "sha512-QuZQ/KVXKt9Vl+XENyOBoTW2Aw+uKjuBlKdCJL6El7AyM7DkJ5bZkSYURshId1SkBDdYg2mJ1flSmsrhGuSfwg==", + "requires": { + "min-dash": "^3.3.0", + "min-dom": "^0.2.0", + "svg.js": "^2.6.3" + }, + "dependencies": { + "min-dom": { + "version": "0.2.0", + "resolved": "https://registry.npmmirror.com/min-dom/-/min-dom-0.2.0.tgz", + "integrity": "sha512-VmxugbnAcVZGqvepjhOA4d4apmrpX8mMaRS+/jo0dI5Yorzrr4Ru9zc9KVALlY/+XakVCb8iQ+PYXljihQcsNw==", + "requires": { + "component-classes": "^1.2.3", + "component-closest": "^0.1.4", + "component-delegate": "^0.2.3", + "component-event": "^0.1.4", + "component-matches-selector": "^0.1.5", + "component-query": "^0.0.3", + "domify": "^1.3.1" + } + } + } + }, + "bpmn-moddle": { + "version": "7.1.3", + "resolved": "https://registry.npmmirror.com/bpmn-moddle/-/bpmn-moddle-7.1.3.tgz", + "integrity": "sha512-ZcBfw0NSOdYTSXFKEn7MOXHItz7VfLZTrFYKO8cK6V8ZzGjCcdiLIOiw7Lctw1PJsihhLiZQS8Htj2xKf+NwCg==", + "dev": true, + "requires": { + "min-dash": "^3.5.2", + "moddle": "^5.0.2", + "moddle-xml": "^9.0.6" + } + }, + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "requires": { + "balanced-match": "^1.0.0" + } + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmmirror.com/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "browserslist": { + "version": "4.22.1", + "resolved": "https://registry.npmmirror.com/browserslist/-/browserslist-4.22.1.tgz", + "integrity": "sha512-FEVc202+2iuClEhZhrWy6ZiAcRLvNMyYcxZ8raemul1DYVOVdFsbqckWLdsixQZCpJlwe77Z3UTalE7jsjnKfQ==", + "dev": true, + "requires": { + "caniuse-lite": "^1.0.30001541", + "electron-to-chromium": "^1.4.535", + "node-releases": "^2.0.13", + "update-browserslist-db": "^1.0.13" + } + }, + "buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" + }, + "call-bind": { + "version": "1.0.5", + "resolved": "https://registry.npmmirror.com/call-bind/-/call-bind-1.0.5.tgz", + "integrity": "sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==", + "dev": true, + "requires": { + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.1", + "set-function-length": "^1.1.1" + } + }, + "callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmmirror.com/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmmirror.com/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" + }, + "camunda-bpmn-moddle": { + "version": "4.5.0", + "resolved": "https://registry.npmmirror.com/camunda-bpmn-moddle/-/camunda-bpmn-moddle-4.5.0.tgz", + "integrity": "sha512-g3d2ZaCac52WIXP3kwmYrBEkhm0nnXcWYNj5STDkmiWpDTKUzTj4ZIt38IRpci1Uj3a/rZACvXLnQj8xKFyp/w==", + "dev": true, + "peer": true, + "requires": { + "min-dash": "^3.0.0" + } + }, + "caniuse-lite": { + "version": "1.0.30001550", + "resolved": "https://registry.npmmirror.com/caniuse-lite/-/caniuse-lite-1.0.30001550.tgz", + "integrity": "sha512-p82WjBYIypO0ukTsd/FG3Xxs+4tFeaY9pfT4amQL8KWtYH7H9nYwReGAbMTJ0hsmRO8IfDtsS6p3ZWj8+1c2RQ==", + "dev": true + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmmirror.com/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmmirror.com/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "dev": true, + "requires": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "fsevents": "~2.3.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "dependencies": { + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmmirror.com/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + } + } + }, + "clipboard": { + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.11.tgz", + "integrity": "sha512-C+0bbOqkezLIsmWSvlsXS0Q0bmkugu7jcfMIACB+RDEntIzQIkdr148we28AfSloQLRdZlYL/QYyrq05j/3Faw==", + "requires": { + "good-listener": "^1.2.2", + "select": "^1.1.2", + "tiny-emitter": "^2.0.0" + } + }, + "cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmmirror.com/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmmirror.com/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, + "component-classes": { + "version": "1.2.6", + "resolved": "https://registry.npmmirror.com/component-classes/-/component-classes-1.2.6.tgz", + "integrity": "sha512-hPFGULxdwugu1QWW3SvVOCUHLzO34+a2J6Wqy0c5ASQkfi9/8nZcBB0ZohaEbXOQlCflMAEMmEWk7u7BVs4koA==", + "requires": { + "component-indexof": "0.0.3" + } + }, + "component-closest": { + "version": "0.1.4", + "resolved": "https://registry.npmmirror.com/component-closest/-/component-closest-0.1.4.tgz", + "integrity": "sha512-NF9hMj6JKGM5sb6wP/dg7GdJOttaIH9PcTsUNdWcrvu7Kw/5R5swQAFpgaYEHlARrNMyn4Wf7O1PlRej+pt76Q==", + "requires": { + "component-matches-selector": "~0.1.5" + } + }, + "component-delegate": { + "version": "0.2.4", + "resolved": "https://registry.npmmirror.com/component-delegate/-/component-delegate-0.2.4.tgz", + "integrity": "sha512-OlpcB/6Fi+kXQPh/TfXnSvvmrU04ghz7vcJh/jgLF0Ni+I+E3WGlKJQbBGDa5X+kVUG8WxOgjP+8iWbz902fPg==", + "requires": { + "component-closest": "*", + "component-event": "*" + } + }, + "component-event": { + "version": "0.1.4", + "resolved": "https://registry.npmmirror.com/component-event/-/component-event-0.1.4.tgz", + "integrity": "sha512-GMwOG8MnUHP1l8DZx1ztFO0SJTFnIzZnBDkXAj8RM2ntV2A6ALlDxgbMY1Fvxlg6WPQ+5IM/a6vg4PEYbjg/Rw==" + }, + "component-indexof": { + "version": "0.0.3", + "resolved": "https://registry.npmmirror.com/component-indexof/-/component-indexof-0.0.3.tgz", + "integrity": "sha512-puDQKvx/64HZXb4hBwIcvQLaLgux8o1CbWl39s41hrIIZDl1lJiD5jc22gj3RBeGK0ovxALDYpIbyjqDUUl0rw==" + }, + "component-matches-selector": { + "version": "0.1.7", + "resolved": "https://registry.npmmirror.com/component-matches-selector/-/component-matches-selector-0.1.7.tgz", + "integrity": "sha512-Yb2+pVBvrqkQVpPaDBF0DYXRreBveXJNrpJs9FnFu8PF6/5IIcz5oDZqiH9nB5hbD2/TmFVN5ZCxBzqu7yFFYQ==", + "requires": { + "component-query": "*", + "global-object": "^1.0.0" + } + }, + "component-query": { + "version": "0.0.3", + "resolved": "https://registry.npmmirror.com/component-query/-/component-query-0.0.3.tgz", + "integrity": "sha512-VgebQseT1hz1Ps7vVp2uaSg+N/gsI5ts3AZUSnN6GMA2M82JH7o+qYifWhmVE/e8w/H48SJuA3nA9uX8zRe95Q==" + }, + "compute-scroll-into-view": { + "version": "1.0.20", + "resolved": "https://registry.npmmirror.com/compute-scroll-into-view/-/compute-scroll-into-view-1.0.20.tgz", + "integrity": "sha512-UCB0ioiyj8CRjtrvaceBLqqhZCVP+1B8+NWQhmdsm0VXOJtobBCf1dBQmebCCo34qZmUwZfIH2MZLqNHazrfjg==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmmirror.com/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + }, + "cropperjs": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/cropperjs/-/cropperjs-1.6.1.tgz", + "integrity": "sha512-F4wsi+XkDHCOMrHMYjrTEE4QBOrsHHN5/2VsVAaRq8P7E5z7xQpT75S+f/9WikmBEailas3+yo+6zPIomW+NOA==" + }, + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmmirror.com/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "crypto-js": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz", + "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==" + }, + "css-blank-pseudo": { + "version": "3.0.3", + "resolved": "https://registry.npmmirror.com/css-blank-pseudo/-/css-blank-pseudo-3.0.3.tgz", + "integrity": "sha512-VS90XWtsHGqoM0t4KpH053c4ehxZ2E6HtGI7x68YFV0pTo/QmkV/YFA+NnlvK8guxZVNWGQhVNJGC39Q8XF4OQ==", + "dev": true, + "requires": { + "postcss-selector-parser": "^6.0.9" + } + }, + "css-has-pseudo": { + "version": "3.0.4", + "resolved": "https://registry.npmmirror.com/css-has-pseudo/-/css-has-pseudo-3.0.4.tgz", + "integrity": "sha512-Vse0xpR1K9MNlp2j5w1pgWIJtm1a8qS0JwS9goFYcImjlHEmywP9VUF05aGBXzGpDJF86QXk4L0ypBmwPhGArw==", + "dev": true, + "requires": { + "postcss-selector-parser": "^6.0.9" + } + }, + "css-prefers-color-scheme": { + "version": "6.0.3", + "resolved": "https://registry.npmmirror.com/css-prefers-color-scheme/-/css-prefers-color-scheme-6.0.3.tgz", + "integrity": "sha512-4BqMbZksRkJQx2zAjrokiGMd07RqOa2IxIrrN10lyBe9xhn9DEvjUK79J6jkeiv9D9hQFXKb6g1jwU62jziJZA==", + "dev": true, + "requires": {} + }, + "css.escape": { + "version": "1.5.1", + "resolved": "https://registry.npmmirror.com/css.escape/-/css.escape-1.5.1.tgz", + "integrity": "sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==", + "dev": true + }, + "cssdb": { + "version": "7.2.0", + "resolved": "https://registry.npmmirror.com/cssdb/-/cssdb-7.2.0.tgz", + "integrity": "sha512-JYlIsE7eKHSi0UNuCyo96YuIDFqvhGgHw4Ck6lsN+DP0Tp8M64UTDT2trGbkMDqnCoEjks7CkS0XcjU0rkvBdg==", + "dev": true + }, + "cssesc": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/cssesc/-/cssesc-3.0.0.tgz", + "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", + "dev": true + }, + "csstype": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", + "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==" + }, + "d": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/d/-/d-1.0.1.tgz", + "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", + "requires": { + "es5-ext": "^0.10.50", + "type": "^1.0.1" + } + }, + "dayjs": { + "version": "1.11.10", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz", + "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==" + }, + "de-indent": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/de-indent/-/de-indent-1.0.2.tgz", + "integrity": "sha512-e/1zu3xH5MQryN2zdVaF0OrdNLUbvWxzMbi+iNA6Bky7l1RoP8a2fIbRocyHclXt/arDrrR6lL3TqFD9pMQTsg==", + "dev": true + }, + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmmirror.com/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==" + }, + "deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmmirror.com/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true + }, + "define-data-property": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/define-data-property/-/define-data-property-1.1.1.tgz", + "integrity": "sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==", + "dev": true, + "requires": { + "get-intrinsic": "^1.2.1", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.0" + } + }, + "define-properties": { + "version": "1.2.1", + "resolved": "https://registry.npmmirror.com/define-properties/-/define-properties-1.2.1.tgz", + "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", + "dev": true, + "requires": { + "define-data-property": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==" + }, + "delegate": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz", + "integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==" + }, + "diagram-js": { + "version": "6.8.2", + "resolved": "https://registry.npmmirror.com/diagram-js/-/diagram-js-6.8.2.tgz", + "integrity": "sha512-5EKYHjW2mmGsn9/jSenSkm8cScK5sO9eETBRQNIIzgZjxBDJn6eX964L2d7/vrAW9SeuijGUsztL9+NUinSsNg==", + "dev": true, + "requires": { + "css.escape": "^1.5.1", + "didi": "^4.0.0", + "hammerjs": "^2.0.1", + "inherits": "^2.0.1", + "min-dash": "^3.5.0", + "min-dom": "^3.1.2", + "object-refs": "^0.3.0", + "path-intersection": "^2.2.0", + "tiny-svg": "^2.2.1" + } + }, + "diagram-js-direct-editing": { + "version": "1.8.0", + "resolved": "https://registry.npmmirror.com/diagram-js-direct-editing/-/diagram-js-direct-editing-1.8.0.tgz", + "integrity": "sha512-B4Xj+PJfgBjbPEzT3uZQEkZI5xHFB0Izc+7BhDFuHidzrEMzQKZrFGdA3PqfWhReHf3dp+iB6Tt11G9eGNjKMw==", + "dev": true, + "requires": { + "min-dash": "^3.5.2", + "min-dom": "^3.1.3" + } + }, + "didi": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/didi/-/didi-4.0.0.tgz", + "integrity": "sha512-AzMElh8mCHOPWPCWfGjoJRla31fMXUT6+287W5ef3IPmtuBcyG9+MkFS7uPP6v3t2Cl086KwWfRB9mESa0OsHQ==", + "dev": true + }, + "dijkstrajs": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.3.tgz", + "integrity": "sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA==" + }, + "dir-glob": { + "version": "3.0.1", + "resolved": "https://registry.npmmirror.com/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dev": true, + "requires": { + "path-type": "^4.0.0" + } + }, + "doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + }, + "dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "dev": true, + "requires": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + } + }, + "dom-zindex": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dom-zindex/-/dom-zindex-1.0.1.tgz", + "integrity": "sha512-M/MERVDZ8hguvjl6MAlLWSLYLS7PzEyXaTb5gEeJ+SF+e9iUC0sdvlzqe91MMDHBoy+nqw7wKcUOrDSyvMCrRg==" + }, + "dom7": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/dom7/-/dom7-3.0.0.tgz", + "integrity": "sha512-oNlcUdHsC4zb7Msx7JN3K0Nro1dzJ48knvBOnDPKJ2GV9wl1i5vydJZUSyOfrkKFDZEud/jBsTk92S/VGSAe/g==", + "requires": { + "ssr-window": "^3.0.0-alpha.1" + } + }, + "domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmmirror.com/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "dev": true + }, + "domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmmirror.com/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "dev": true, + "requires": { + "domelementtype": "^2.3.0" + } + }, + "domify": { + "version": "1.4.2", + "resolved": "https://registry.npmmirror.com/domify/-/domify-1.4.2.tgz", + "integrity": "sha512-m4yreHcUWHBncGVV7U+yQzc12vIlq0jMrtHZ5mW6dQMiL/7skSYNVX9wqKwOtyO9SGCgevrAFEgOCAHmamHTUA==" + }, + "domutils": { + "version": "3.0.1", + "resolved": "https://registry.npmmirror.com/domutils/-/domutils-3.0.1.tgz", + "integrity": "sha512-z08c1l761iKhDFtfXO04C7kTdPBLi41zwOZl00WS8b5eiaebNpY00HKbztwBq+e3vyqWNwWF3mP9YLUeqIrF+Q==", + "dev": true, + "requires": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.1" + } + }, + "echarts": { + "version": "5.5.0", + "resolved": "https://registry.npmmirror.com/echarts/-/echarts-5.5.0.tgz", + "integrity": "sha512-rNYnNCzqDAPCr4m/fqyUFv7fD9qIsd50S6GDFgO1DxZhncCsNsG7IfUlAlvZe5oSEQxtsjnHiUuppzccry93Xw==", + "requires": { + "tslib": "2.3.0", + "zrender": "5.5.0" + }, + "dependencies": { + "tslib": { + "version": "2.3.0", + "resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.3.0.tgz", + "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==" + } + } + }, + "ejs": { + "version": "3.1.9", + "resolved": "https://registry.npmmirror.com/ejs/-/ejs-3.1.9.tgz", + "integrity": "sha512-rC+QVNMJWv+MtPgkt0y+0rVEIdbtxVADApW9JXrUVlzHetgcyczP/E7DJmWJ4fJCZF2cPcBk0laWO9ZHMG3DmQ==", + "requires": { + "jake": "^10.8.5" + } + }, + "electron-to-chromium": { + "version": "1.4.559", + "resolved": "https://registry.npmmirror.com/electron-to-chromium/-/electron-to-chromium-1.4.559.tgz", + "integrity": "sha512-iS7KhLYCSJbdo3rUSkhDTVuFNCV34RKs2UaB9Ecr7VlqzjjWW//0nfsFF5dtDmyXlZQaDYYtID5fjtC/6lpRug==", + "dev": true + }, + "element-plus": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/element-plus/-/element-plus-2.7.3.tgz", + "integrity": "sha512-OaqY1kQ2xzNyRFyge3fzM7jqMwux+464RBEqd+ybRV9xPiGxtgnj/sVK4iEbnKnzQIa9XK03DOIFzoToUhu1DA==", + "requires": { + "@ctrl/tinycolor": "^3.4.1", + "@element-plus/icons-vue": "^2.3.1", + "@floating-ui/dom": "^1.0.1", + "@popperjs/core": "npm:@sxzz/popperjs-es@^2.11.7", + "@types/lodash": "^4.14.182", + "@types/lodash-es": "^4.17.6", + "@vueuse/core": "^9.1.0", + "async-validator": "^4.2.5", + "dayjs": "^1.11.3", + "escape-html": "^1.0.3", + "lodash": "^4.17.21", + "lodash-es": "^4.17.21", + "lodash-unified": "^1.0.2", + "memoize-one": "^6.0.0", + "normalize-wheel-es": "^1.2.0" + } + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "encode-utf8": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/encode-utf8/-/encode-utf8-1.0.3.tgz", + "integrity": "sha512-ucAnuBEhUK4boH2HjVYG5Q2mQyPorvv0u/ocS+zhdw0S8AlHYY+GOFhP1Gio5z4icpP2ivFSvhtFjQi8+T9ppw==" + }, + "enhanced-resolve": { + "version": "5.15.0", + "resolved": "https://registry.npmmirror.com/enhanced-resolve/-/enhanced-resolve-5.15.0.tgz", + "integrity": "sha512-LXYT42KJ7lpIKECr2mAXIaMldcNCh/7E0KBKOu4KSfkHmP+mZmSs+8V5gBAqisWBy0OO4W5Oyys0GO1Y8KtdKg==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.4", + "tapable": "^2.2.0" + } + }, + "entities": { + "version": "4.4.0", + "resolved": "https://registry.npmmirror.com/entities/-/entities-4.4.0.tgz", + "integrity": "sha512-oYp7156SP8LkeGD0GF85ad1X9Ai79WtRsZ2gxJqtBuzH+98YUV6jkHEKlZkMbcrjJjIVJNIDP/3WL9wQkoPbWA==", + "dev": true + }, + "es-abstract": { + "version": "1.22.3", + "resolved": "https://registry.npmmirror.com/es-abstract/-/es-abstract-1.22.3.tgz", + "integrity": "sha512-eiiY8HQeYfYH2Con2berK+To6GrK2RxbPawDkGq4UiCQQfZHb6wX9qQqkbpPqaxQFcl8d9QzZqo0tGE0VcrdwA==", + "dev": true, + "requires": { + "array-buffer-byte-length": "^1.0.0", + "arraybuffer.prototype.slice": "^1.0.2", + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.5", + "es-set-tostringtag": "^2.0.1", + "es-to-primitive": "^1.2.1", + "function.prototype.name": "^1.1.6", + "get-intrinsic": "^1.2.2", + "get-symbol-description": "^1.0.0", + "globalthis": "^1.0.3", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0", + "internal-slot": "^1.0.5", + "is-array-buffer": "^3.0.2", + "is-callable": "^1.2.7", + "is-negative-zero": "^2.0.2", + "is-regex": "^1.1.4", + "is-shared-array-buffer": "^1.0.2", + "is-string": "^1.0.7", + "is-typed-array": "^1.1.12", + "is-weakref": "^1.0.2", + "object-inspect": "^1.13.1", + "object-keys": "^1.1.1", + "object.assign": "^4.1.4", + "regexp.prototype.flags": "^1.5.1", + "safe-array-concat": "^1.0.1", + "safe-regex-test": "^1.0.0", + "string.prototype.trim": "^1.2.8", + "string.prototype.trimend": "^1.0.7", + "string.prototype.trimstart": "^1.0.7", + "typed-array-buffer": "^1.0.0", + "typed-array-byte-length": "^1.0.0", + "typed-array-byte-offset": "^1.0.0", + "typed-array-length": "^1.0.4", + "unbox-primitive": "^1.0.2", + "which-typed-array": "^1.1.13" + } + }, + "es-set-tostringtag": { + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/es-set-tostringtag/-/es-set-tostringtag-2.0.2.tgz", + "integrity": "sha512-BuDyupZt65P9D2D2vA/zqcI3G5xRsklm5N3xCwuiy+/vKy8i0ifdsQP1sLgO4tZDSCaQUSnmC48khknGMV3D2Q==", + "dev": true, + "requires": { + "get-intrinsic": "^1.2.2", + "has-tostringtag": "^1.0.0", + "hasown": "^2.0.0" + } + }, + "es-shim-unscopables": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/es-shim-unscopables/-/es-shim-unscopables-1.0.2.tgz", + "integrity": "sha512-J3yBRXCzDu4ULnQwxyToo/OjdMx6akgVC7K6few0a7F/0wLtmKKN7I73AH5T2836UuXRqN7Qg+IIUw/+YJksRw==", + "dev": true, + "requires": { + "hasown": "^2.0.0" + } + }, + "es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmmirror.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "es5-ext": { + "version": "0.10.62", + "resolved": "https://registry.npmmirror.com/es5-ext/-/es5-ext-0.10.62.tgz", + "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", + "requires": { + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.3", + "next-tick": "^1.1.0" + } + }, + "es6-iterator": { + "version": "2.0.3", + "resolved": "https://registry.npmmirror.com/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==", + "requires": { + "d": "1", + "es5-ext": "^0.10.35", + "es6-symbol": "^3.1.1" + } + }, + "es6-symbol": { + "version": "3.1.3", + "resolved": "https://registry.npmmirror.com/es6-symbol/-/es6-symbol-3.1.3.tgz", + "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", + "requires": { + "d": "^1.0.1", + "ext": "^1.1.2" + } + }, + "esbuild": { + "version": "0.16.9", + "resolved": "https://registry.npmmirror.com/esbuild/-/esbuild-0.16.9.tgz", + "integrity": "sha512-gkH83yHyijMSZcZFs1IWew342eMdFuWXmQo3zkDPTre25LIPBJsXryg02M3u8OpTwCJdBkdaQwqKkDLnAsAeLQ==", + "dev": true, + "requires": { + "@esbuild/android-arm": "0.16.9", + "@esbuild/android-arm64": "0.16.9", + "@esbuild/android-x64": "0.16.9", + "@esbuild/darwin-arm64": "0.16.9", + "@esbuild/darwin-x64": "0.16.9", + "@esbuild/freebsd-arm64": "0.16.9", + "@esbuild/freebsd-x64": "0.16.9", + "@esbuild/linux-arm": "0.16.9", + "@esbuild/linux-arm64": "0.16.9", + "@esbuild/linux-ia32": "0.16.9", + "@esbuild/linux-loong64": "0.16.9", + "@esbuild/linux-mips64el": "0.16.9", + "@esbuild/linux-ppc64": "0.16.9", + "@esbuild/linux-riscv64": "0.16.9", + "@esbuild/linux-s390x": "0.16.9", + "@esbuild/linux-x64": "0.16.9", + "@esbuild/netbsd-x64": "0.16.9", + "@esbuild/openbsd-x64": "0.16.9", + "@esbuild/sunos-x64": "0.16.9", + "@esbuild/win32-arm64": "0.16.9", + "@esbuild/win32-ia32": "0.16.9", + "@esbuild/win32-x64": "0.16.9" + } + }, + "escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmmirror.com/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "dev": true + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" + }, + "escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true + }, + "eslint": { + "version": "8.30.0", + "resolved": "https://registry.npmmirror.com/eslint/-/eslint-8.30.0.tgz", + "integrity": "sha512-MGADB39QqYuzEGov+F/qb18r4i7DohCDOfatHaxI2iGlPuC65bwG2gxgO+7DkyL38dRFaRH7RaRAgU6JKL9rMQ==", + "dev": true, + "requires": { + "@eslint/eslintrc": "^1.4.0", + "@humanwhocodes/config-array": "^0.11.8", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", + "ajv": "^6.10.0", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "doctrine": "^3.0.0", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^7.1.1", + "eslint-utils": "^3.0.0", + "eslint-visitor-keys": "^3.3.0", + "espree": "^9.4.0", + "esquery": "^1.4.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "grapheme-splitter": "^1.0.4", + "ignore": "^5.2.0", + "import-fresh": "^3.0.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-sdsl": "^4.1.4", + "js-yaml": "^4.1.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.1", + "regexpp": "^3.2.0", + "strip-ansi": "^6.0.1", + "strip-json-comments": "^3.1.0", + "text-table": "^0.2.0" + }, + "dependencies": { + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + } + } + }, + "eslint-config-prettier": { + "version": "8.5.0", + "resolved": "https://registry.npmmirror.com/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz", + "integrity": "sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==", + "dev": true, + "requires": {} + }, + "eslint-import-resolver-node": { + "version": "0.3.9", + "resolved": "https://registry.npmmirror.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz", + "integrity": "sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==", + "dev": true, + "requires": { + "debug": "^3.2.7", + "is-core-module": "^2.13.0", + "resolve": "^1.22.4" + }, + "dependencies": { + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmmirror.com/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + } + } + }, + "eslint-import-resolver-typescript": { + "version": "3.6.1", + "resolved": "https://registry.npmmirror.com/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.6.1.tgz", + "integrity": "sha512-xgdptdoi5W3niYeuQxKmzVDTATvLYqhpwmykwsh7f6HIOStGWEIL9iqZgQDF9u9OEzrRwR8no5q2VT+bjAujTg==", + "dev": true, + "requires": { + "debug": "^4.3.4", + "enhanced-resolve": "^5.12.0", + "eslint-module-utils": "^2.7.4", + "fast-glob": "^3.3.1", + "get-tsconfig": "^4.5.0", + "is-core-module": "^2.11.0", + "is-glob": "^4.0.3" + } + }, + "eslint-module-utils": { + "version": "2.8.0", + "resolved": "https://registry.npmmirror.com/eslint-module-utils/-/eslint-module-utils-2.8.0.tgz", + "integrity": "sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw==", + "dev": true, + "requires": { + "debug": "^3.2.7" + }, + "dependencies": { + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmmirror.com/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + } + } + }, + "eslint-plugin-import": { + "version": "2.29.0", + "resolved": "https://registry.npmmirror.com/eslint-plugin-import/-/eslint-plugin-import-2.29.0.tgz", + "integrity": "sha512-QPOO5NO6Odv5lpoTkddtutccQjysJuFxoPS7fAHO+9m9udNHvTCPSAMW9zGAYj8lAIdr40I8yPCdUYrncXtrwg==", + "dev": true, + "requires": { + "array-includes": "^3.1.7", + "array.prototype.findlastindex": "^1.2.3", + "array.prototype.flat": "^1.3.2", + "array.prototype.flatmap": "^1.3.2", + "debug": "^3.2.7", + "doctrine": "^2.1.0", + "eslint-import-resolver-node": "^0.3.9", + "eslint-module-utils": "^2.8.0", + "hasown": "^2.0.0", + "is-core-module": "^2.13.1", + "is-glob": "^4.0.3", + "minimatch": "^3.1.2", + "object.fromentries": "^2.0.7", + "object.groupby": "^1.0.1", + "object.values": "^1.1.7", + "semver": "^6.3.1", + "tsconfig-paths": "^3.14.2" + }, + "dependencies": { + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmmirror.com/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "semver": { + "version": "6.3.1", + "resolved": "https://registry.npmmirror.com/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true + } + } + }, + "eslint-plugin-prettier": { + "version": "4.2.1", + "resolved": "https://registry.npmmirror.com/eslint-plugin-prettier/-/eslint-plugin-prettier-4.2.1.tgz", + "integrity": "sha512-f/0rXLXUt0oFYs8ra4w49wYZBG5GKZpAYsJSm6rnYL5uVDjd+zowwMwVZHnAjf4edNrKpCDYfXDgmRE/Ak7QyQ==", + "dev": true, + "requires": { + "prettier-linter-helpers": "^1.0.0" + } + }, + "eslint-plugin-vue": { + "version": "9.8.0", + "resolved": "https://registry.npmmirror.com/eslint-plugin-vue/-/eslint-plugin-vue-9.8.0.tgz", + "integrity": "sha512-E/AXwcTzunyzM83C2QqDHxepMzvI2y6x+mmeYHbVDQlKFqmKYvRrhaVixEeeG27uI44p9oKDFiyCRw4XxgtfHA==", + "dev": true, + "requires": { + "eslint-utils": "^3.0.0", + "natural-compare": "^1.4.0", + "nth-check": "^2.0.1", + "postcss-selector-parser": "^6.0.9", + "semver": "^7.3.5", + "vue-eslint-parser": "^9.0.1", + "xml-name-validator": "^4.0.0" + } + }, + "eslint-scope": { + "version": "7.1.1", + "resolved": "https://registry.npmmirror.com/eslint-scope/-/eslint-scope-7.1.1.tgz", + "integrity": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==", + "dev": true, + "requires": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + } + }, + "eslint-utils": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/eslint-utils/-/eslint-utils-3.0.0.tgz", + "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^2.0.0" + }, + "dependencies": { + "eslint-visitor-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", + "dev": true + } + } + }, + "eslint-visitor-keys": { + "version": "3.3.0", + "resolved": "https://registry.npmmirror.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", + "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", + "dev": true + }, + "espree": { + "version": "9.4.1", + "resolved": "https://registry.npmmirror.com/espree/-/espree-9.4.1.tgz", + "integrity": "sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg==", + "dev": true, + "requires": { + "acorn": "^8.8.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.3.0" + } + }, + "esquery": { + "version": "1.4.0", + "resolved": "https://registry.npmmirror.com/esquery/-/esquery-1.4.0.tgz", + "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", + "dev": true, + "requires": { + "estraverse": "^5.1.0" + } + }, + "esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmmirror.com/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "requires": { + "estraverse": "^5.2.0" + } + }, + "estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmmirror.com/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true + }, + "estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==" + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmmirror.com/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true + }, + "event-emitter": { + "version": "0.3.5", + "resolved": "https://registry.npmmirror.com/event-emitter/-/event-emitter-0.3.5.tgz", + "integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==", + "requires": { + "d": "1", + "es5-ext": "~0.10.14" + } + }, + "evtd": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/evtd/-/evtd-0.2.4.tgz", + "integrity": "sha512-qaeGN5bx63s/AXgQo8gj6fBkxge+OoLddLniox5qtLAEY5HSnuSlISXVPxnSae1dWblvTh4/HoMIB+mbMsvZzw==" + }, + "ext": { + "version": "1.7.0", + "resolved": "https://registry.npmmirror.com/ext/-/ext-1.7.0.tgz", + "integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==", + "requires": { + "type": "^2.7.2" + }, + "dependencies": { + "type": { + "version": "2.7.2", + "resolved": "https://registry.npmmirror.com/type/-/type-2.7.2.tgz", + "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==" + } + } + }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmmirror.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "fast-diff": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/fast-diff/-/fast-diff-1.2.0.tgz", + "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==", + "dev": true + }, + "fast-glob": { + "version": "3.3.1", + "resolved": "https://registry.npmmirror.com/fast-glob/-/fast-glob-3.3.1.tgz", + "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", + "dev": true, + "requires": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "dependencies": { + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmmirror.com/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + } + } + }, + "fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmmirror.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true + }, + "fastq": { + "version": "1.14.0", + "resolved": "https://registry.npmmirror.com/fastq/-/fastq-1.14.0.tgz", + "integrity": "sha512-eR2D+V9/ExcbF9ls441yIuN6TI2ED1Y2ZcA5BmMtJsOkWOFRJQ0Jt0g1UwqXJJVAb+V+umH5Dfr8oh4EVP7VVg==", + "dev": true, + "requires": { + "reusify": "^1.0.4" + } + }, + "file-entry-cache": { + "version": "6.0.1", + "resolved": "https://registry.npmmirror.com/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", + "dev": true, + "requires": { + "flat-cache": "^3.0.4" + } + }, + "filelist": { + "version": "1.0.4", + "resolved": "https://registry.npmmirror.com/filelist/-/filelist-1.0.4.tgz", + "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==", + "requires": { + "minimatch": "^5.0.1" + } + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmmirror.com/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmmirror.com/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "requires": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + } + }, + "flat-cache": { + "version": "3.0.4", + "resolved": "https://registry.npmmirror.com/flat-cache/-/flat-cache-3.0.4.tgz", + "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", + "dev": true, + "requires": { + "flatted": "^3.1.0", + "rimraf": "^3.0.2" + } + }, + "flatted": { + "version": "3.2.7", + "resolved": "https://registry.npmmirror.com/flatted/-/flatted-3.2.7.tgz", + "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", + "dev": true + }, + "follow-redirects": { + "version": "1.15.3", + "resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.3.tgz", + "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==" + }, + "for-each": { + "version": "0.3.3", + "resolved": "https://registry.npmmirror.com/for-each/-/for-each-0.3.3.tgz", + "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", + "dev": true, + "requires": { + "is-callable": "^1.1.3" + } + }, + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + }, + "fraction.js": { + "version": "4.3.7", + "resolved": "https://registry.npmmirror.com/fraction.js/-/fraction.js-4.3.7.tgz", + "integrity": "sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==", + "dev": true + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmmirror.com/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "optional": true + }, + "function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmmirror.com/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true + }, + "function.prototype.name": { + "version": "1.1.6", + "resolved": "https://registry.npmmirror.com/function.prototype.name/-/function.prototype.name-1.1.6.tgz", + "integrity": "sha512-Z5kx79swU5P27WEayXM1tBi5Ze/lbIyiNgU3qyXUOf9b2rgXYyF9Dy9Cx+IQv/Lc8WCG6L82zwUPpSS9hGehIg==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "functions-have-names": "^1.2.3" + } + }, + "functions-have-names": { + "version": "1.2.3", + "resolved": "https://registry.npmmirror.com/functions-have-names/-/functions-have-names-1.2.3.tgz", + "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", + "dev": true + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==" + }, + "get-intrinsic": { + "version": "1.2.2", + "resolved": "https://registry.npmmirror.com/get-intrinsic/-/get-intrinsic-1.2.2.tgz", + "integrity": "sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==", + "dev": true, + "requires": { + "function-bind": "^1.1.2", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0" + } + }, + "get-symbol-description": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/get-symbol-description/-/get-symbol-description-1.0.0.tgz", + "integrity": "sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.1.1" + } + }, + "get-tsconfig": { + "version": "4.7.2", + "resolved": "https://registry.npmmirror.com/get-tsconfig/-/get-tsconfig-4.7.2.tgz", + "integrity": "sha512-wuMsz4leaj5hbGgg4IvDU0bqJagpftG5l5cXIAvo8uZrqn0NJqwtfupTN00VnkQJPcIRrxYrm1Ue24btpCha2A==", + "dev": true, + "requires": { + "resolve-pkg-maps": "^1.0.0" + } + }, + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmmirror.com/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "dependencies": { + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + } + } + }, + "glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmmirror.com/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "requires": { + "is-glob": "^4.0.3" + } + }, + "global-object": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/global-object/-/global-object-1.0.0.tgz", + "integrity": "sha512-mSPSkY6UsHv6hgW0V2dfWBWTS8TnPnLx3ECVNoWp6rBI2Bg66VYoqGoTFlH/l7XhAZ/l+StYlntXlt87BEeCcg==" + }, + "globals": { + "version": "13.19.0", + "resolved": "https://registry.npmmirror.com/globals/-/globals-13.19.0.tgz", + "integrity": "sha512-dkQ957uSRWHw7CFXLUtUHQI3g3aWApYhfNR2O6jn/907riyTYKVBmxYVROkBcY614FSSeSJh7Xm7SrUWCxvJMQ==", + "dev": true, + "requires": { + "type-fest": "^0.20.2" + } + }, + "globalthis": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/globalthis/-/globalthis-1.0.3.tgz", + "integrity": "sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA==", + "dev": true, + "requires": { + "define-properties": "^1.1.3" + } + }, + "globby": { + "version": "11.1.0", + "resolved": "https://registry.npmmirror.com/globby/-/globby-11.1.0.tgz", + "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", + "dev": true, + "requires": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.9", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^3.0.0" + } + }, + "good-listener": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz", + "integrity": "sha512-goW1b+d9q/HIwbVYZzZ6SsTr4IgE+WA44A0GmPIQstuOrgsFcT7VEJ48nmr9GaRtNu0XTKacFLGnBPAM6Afouw==", + "requires": { + "delegate": "^3.1.2" + } + }, + "gopd": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/gopd/-/gopd-1.0.1.tgz", + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "dev": true, + "requires": { + "get-intrinsic": "^1.1.3" + } + }, + "graceful-fs": { + "version": "4.2.10", + "resolved": "https://registry.npmmirror.com/graceful-fs/-/graceful-fs-4.2.10.tgz", + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", + "dev": true + }, + "grapheme-splitter": { + "version": "1.0.4", + "resolved": "https://registry.npmmirror.com/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", + "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", + "dev": true + }, + "hammerjs": { + "version": "2.0.8", + "resolved": "https://registry.npmmirror.com/hammerjs/-/hammerjs-2.0.8.tgz", + "integrity": "sha512-tSQXBXS/MWQOn/RKckawJ61vvsDpCom87JgxiYdGwHdOa0ht0vzUWDlfioofFCRU0L+6NGDt6XzbgoJvZkMeRQ==", + "dev": true + }, + "has-bigints": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/has-bigints/-/has-bigints-1.0.2.tgz", + "integrity": "sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" + }, + "has-property-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz", + "integrity": "sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==", + "dev": true, + "requires": { + "get-intrinsic": "^1.2.2" + } + }, + "has-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/has-proto/-/has-proto-1.0.1.tgz", + "integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==", + "dev": true + }, + "has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "dev": true + }, + "has-tostringtag": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/has-tostringtag/-/has-tostringtag-1.0.0.tgz", + "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", + "dev": true, + "requires": { + "has-symbols": "^1.0.2" + } + }, + "hasown": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/hasown/-/hasown-2.0.0.tgz", + "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==", + "dev": true, + "requires": { + "function-bind": "^1.1.2" + } + }, + "he": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true + }, + "highlight.js": { + "version": "11.9.0", + "resolved": "https://registry.npmmirror.com/highlight.js/-/highlight.js-11.9.0.tgz", + "integrity": "sha512-fJ7cW7fQGCYAkgv4CPfwFHrfd/cLS4Hau96JuJ+ZTOWhjnhoeN1ub1tFmALm/+lW5z4WCAuAV9bm05AP0mS6Gw==" + }, + "html-void-elements": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/html-void-elements/-/html-void-elements-2.0.1.tgz", + "integrity": "sha512-0quDb7s97CfemeJAnW9wC0hw78MtW7NU3hqtCD75g2vFlDLt36llsYD7uB7SUzojLMP24N5IatXf7ylGXiGG9A==" + }, + "htmlparser2": { + "version": "8.0.1", + "resolved": "https://registry.npmmirror.com/htmlparser2/-/htmlparser2-8.0.1.tgz", + "integrity": "sha512-4lVbmc1diZC7GUJQtRQ5yBAeUCL1exyMwmForWkRLnwyzWBFxN633SALPMGYaWZvKe9j1pRZJpauvmxENSp/EA==", + "dev": true, + "requires": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "domutils": "^3.0.1", + "entities": "^4.3.0" + } + }, + "i18next": { + "version": "20.6.1", + "resolved": "https://registry.npmmirror.com/i18next/-/i18next-20.6.1.tgz", + "integrity": "sha512-yCMYTMEJ9ihCwEQQ3phLo7I/Pwycf8uAx+sRHwwk5U9Aui/IZYgQRyMqXafQOw5QQ7DM1Z+WyEXWIqSuJHhG2A==", + "requires": { + "@babel/runtime": "^7.12.0" + } + }, + "ids": { + "version": "1.0.5", + "resolved": "https://registry.npmmirror.com/ids/-/ids-1.0.5.tgz", + "integrity": "sha512-XQ0yom/4KWTL29sLG+tyuycy7UmeaM/79GRtSJq6IG9cJGIPeBz5kwDCguie3TwxaMNIc3WtPi0cTa1XYHicpw==", + "dev": true + }, + "ignore": { + "version": "5.2.2", + "resolved": "https://registry.npmmirror.com/ignore/-/ignore-5.2.2.tgz", + "integrity": "sha512-m1MJSy4Z2NAcyhoYpxQeBsc1ZdNQwYjN0wGbLBlnVArdJ90Gtr8IhNSfZZcCoR0fM/0E0BJ0mf1KnLNDOCJP4w==", + "dev": true + }, + "immer": { + "version": "9.0.21", + "resolved": "https://registry.npmmirror.com/immer/-/immer-9.0.21.tgz", + "integrity": "sha512-bc4NBHqOqSfRW7POMkHd51LvClaeMXpm8dx0e8oE2GORbq5aRK7Bxl4FyzVLdGtLmvLKL7BTDBG5ACQm4HWjTA==" + }, + "immutable": { + "version": "4.1.0", + "resolved": "https://registry.npmmirror.com/immutable/-/immutable-4.1.0.tgz", + "integrity": "sha512-oNkuqVTA8jqG1Q6c+UglTOD1xhC1BtjKI7XkCXRkZHrN5m18/XsnUp8Q89GkQO/z+0WjonSvl0FLhDYftp46nQ==", + "dev": true + }, + "import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmmirror.com/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + } + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmmirror.com/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true + }, + "indexof": { + "version": "0.0.1", + "resolved": "https://registry.npmmirror.com/indexof/-/indexof-0.0.1.tgz", + "integrity": "sha512-i0G7hLJ1z0DE8dsqJa2rycj9dBmNKgXBvotXtZYXakU9oivfB9Uj2ZBC27qqef2U58/ZLwalxa1X/RDCdkHtVg==", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmmirror.com/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmmirror.com/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "internal-slot": { + "version": "1.0.6", + "resolved": "https://registry.npmmirror.com/internal-slot/-/internal-slot-1.0.6.tgz", + "integrity": "sha512-Xj6dv+PsbtwyPpEflsejS+oIZxmMlV44zAhG479uYu89MsjcYOhCFnNyKrkJrihbsiasQyY0afoCl/9BLR65bg==", + "dev": true, + "requires": { + "get-intrinsic": "^1.2.2", + "hasown": "^2.0.0", + "side-channel": "^1.0.4" + } + }, + "is-array-buffer": { + "version": "3.0.2", + "resolved": "https://registry.npmmirror.com/is-array-buffer/-/is-array-buffer-3.0.2.tgz", + "integrity": "sha512-y+FyyR/w8vfIRq4eQcM1EYgSTnmHXPqaF+IgzgraytCFq5Xh8lllDVmAZolPJiZttZLeFSINPYMaEJ7/vWUa1w==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.2.0", + "is-typed-array": "^1.1.10" + } + }, + "is-bigint": { + "version": "1.0.4", + "resolved": "https://registry.npmmirror.com/is-bigint/-/is-bigint-1.0.4.tgz", + "integrity": "sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==", + "dev": true, + "requires": { + "has-bigints": "^1.0.1" + } + }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "requires": { + "binary-extensions": "^2.0.0" + } + }, + "is-boolean-object": { + "version": "1.1.2", + "resolved": "https://registry.npmmirror.com/is-boolean-object/-/is-boolean-object-1.1.2.tgz", + "integrity": "sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + } + }, + "is-callable": { + "version": "1.2.7", + "resolved": "https://registry.npmmirror.com/is-callable/-/is-callable-1.2.7.tgz", + "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", + "dev": true + }, + "is-core-module": { + "version": "2.13.1", + "resolved": "https://registry.npmmirror.com/is-core-module/-/is-core-module-2.13.1.tgz", + "integrity": "sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==", + "dev": true, + "requires": { + "hasown": "^2.0.0" + } + }, + "is-date-object": { + "version": "1.0.5", + "resolved": "https://registry.npmmirror.com/is-date-object/-/is-date-object-1.0.5.tgz", + "integrity": "sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==", + "dev": true, + "requires": { + "has-tostringtag": "^1.0.0" + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmmirror.com/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" + }, + "is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmmirror.com/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-hotkey": { + "version": "0.2.0", + "resolved": "https://registry.npmmirror.com/is-hotkey/-/is-hotkey-0.2.0.tgz", + "integrity": "sha512-UknnZK4RakDmTgz4PI1wIph5yxSs/mvChWs9ifnlXsKuXgWmOkY/hAE0H/k2MIqH0RlRye0i1oC07MCRSD28Mw==" + }, + "is-negative-zero": { + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/is-negative-zero/-/is-negative-zero-2.0.2.tgz", + "integrity": "sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA==", + "dev": true + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmmirror.com/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "is-number-object": { + "version": "1.0.7", + "resolved": "https://registry.npmmirror.com/is-number-object/-/is-number-object-1.0.7.tgz", + "integrity": "sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==", + "dev": true, + "requires": { + "has-tostringtag": "^1.0.0" + } + }, + "is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmmirror.com/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true + }, + "is-plain-object": { + "version": "5.0.0", + "resolved": "https://registry.npmmirror.com/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==" + }, + "is-regex": { + "version": "1.1.4", + "resolved": "https://registry.npmmirror.com/is-regex/-/is-regex-1.1.4.tgz", + "integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + } + }, + "is-shared-array-buffer": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz", + "integrity": "sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==", + "dev": true, + "requires": { + "call-bind": "^1.0.2" + } + }, + "is-string": { + "version": "1.0.7", + "resolved": "https://registry.npmmirror.com/is-string/-/is-string-1.0.7.tgz", + "integrity": "sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==", + "dev": true, + "requires": { + "has-tostringtag": "^1.0.0" + } + }, + "is-symbol": { + "version": "1.0.4", + "resolved": "https://registry.npmmirror.com/is-symbol/-/is-symbol-1.0.4.tgz", + "integrity": "sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==", + "dev": true, + "requires": { + "has-symbols": "^1.0.2" + } + }, + "is-typed-array": { + "version": "1.1.12", + "resolved": "https://registry.npmmirror.com/is-typed-array/-/is-typed-array-1.1.12.tgz", + "integrity": "sha512-Z14TF2JNG8Lss5/HMqt0//T9JeHXttXy5pH/DBU4vi98ozO2btxzq9MwYDZYnKwU8nRsz/+GVFVRDq3DkVuSPg==", + "dev": true, + "requires": { + "which-typed-array": "^1.1.11" + } + }, + "is-url": { + "version": "1.2.4", + "resolved": "https://registry.npmmirror.com/is-url/-/is-url-1.2.4.tgz", + "integrity": "sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww==" + }, + "is-weakref": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/is-weakref/-/is-weakref-1.0.2.tgz", + "integrity": "sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==", + "dev": true, + "requires": { + "call-bind": "^1.0.2" + } + }, + "isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmmirror.com/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, + "jake": { + "version": "10.8.7", + "resolved": "https://registry.npmmirror.com/jake/-/jake-10.8.7.tgz", + "integrity": "sha512-ZDi3aP+fG/LchyBzUM804VjddnwfSfsdeYkwt8NcbKRvo4rFkjhs456iLFn3k2ZUWvNe4i48WACDbza8fhq2+w==", + "requires": { + "async": "^3.2.3", + "chalk": "^4.0.2", + "filelist": "^1.0.4", + "minimatch": "^3.1.2" + }, + "dependencies": { + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "requires": { + "brace-expansion": "^1.1.7" + } + } + } + }, + "js-sdsl": { + "version": "4.2.0", + "resolved": "https://registry.npmmirror.com/js-sdsl/-/js-sdsl-4.2.0.tgz", + "integrity": "sha512-dyBIzQBDkCqCu+0upx25Y2jGdbTGxE9fshMsCdK0ViOongpV+n5tXRcZY9v7CaVQ79AGS9KA1KHtojxiM7aXSQ==", + "dev": true + }, + "js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmmirror.com/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "requires": { + "argparse": "^2.0.1" + } + }, + "jsbarcode": { + "version": "3.11.5", + "resolved": "https://registry.npmjs.org/jsbarcode/-/jsbarcode-3.11.5.tgz", + "integrity": "sha512-zv3KsH51zD00I/LrFzFSM6dst7rDn0vIMzaiZFL7qusTjPZiPtxg3zxetp0RR7obmjTw4f6NyGgbdkBCgZUIrA==" + }, + "jsencrypt": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/jsencrypt/-/jsencrypt-3.3.2.tgz", + "integrity": "sha512-arQR1R1ESGdAxY7ZheWr12wCaF2yF47v5qpB76TtV64H1pyGudk9Hvw8Y9tb/FiTIaaTRUyaSnm5T/Y53Ghm/A==" + }, + "json-bigint": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz", + "integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==", + "requires": { + "bignumber.js": "^9.0.0" + } + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmmirror.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true + }, + "json5": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", + "dev": true, + "requires": { + "minimist": "^1.2.0" + } + }, + "jsonc-parser": { + "version": "3.2.0", + "resolved": "https://registry.npmmirror.com/jsonc-parser/-/jsonc-parser-3.2.0.tgz", + "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==", + "dev": true + }, + "levn": { + "version": "0.4.1", + "resolved": "https://registry.npmmirror.com/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "requires": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + } + }, + "local-pkg": { + "version": "0.4.3", + "resolved": "https://registry.npmmirror.com/local-pkg/-/local-pkg-0.4.3.tgz", + "integrity": "sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==", + "dev": true + }, + "locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmmirror.com/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "requires": { + "p-locate": "^5.0.0" + } + }, + "lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmmirror.com/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmmirror.com/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==" + }, + "lodash-unified": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/lodash-unified/-/lodash-unified-1.0.3.tgz", + "integrity": "sha512-WK9qSozxXOD7ZJQlpSqOT+om2ZfcT4yO+03FuzAHD0wF6S0l0090LRPDx3vhTTLZ8cFKpBn+IOcVXK6qOcIlfQ==", + "requires": {} + }, + "lodash.camelcase": { + "version": "4.3.0", + "resolved": "https://registry.npmmirror.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", + "integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==" + }, + "lodash.clonedeep": { + "version": "4.5.0", + "resolved": "https://registry.npmmirror.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==" + }, + "lodash.debounce": { + "version": "4.0.8", + "resolved": "https://registry.npmmirror.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz", + "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==" + }, + "lodash.foreach": { + "version": "4.5.0", + "resolved": "https://registry.npmmirror.com/lodash.foreach/-/lodash.foreach-4.5.0.tgz", + "integrity": "sha512-aEXTF4d+m05rVOAUG3z4vZZ4xVexLKZGF0lIxuHZ1Hplpk/3B6Z1+/ICICYRLm7c41Z2xiejbkCkJoTlypoXhQ==" + }, + "lodash.isequal": { + "version": "4.5.0", + "resolved": "https://registry.npmmirror.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz", + "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==" + }, + "lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmmirror.com/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true + }, + "lodash.throttle": { + "version": "4.1.1", + "resolved": "https://registry.npmmirror.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz", + "integrity": "sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ==" + }, + "lodash.toarray": { + "version": "4.4.0", + "resolved": "https://registry.npmmirror.com/lodash.toarray/-/lodash.toarray-4.4.0.tgz", + "integrity": "sha512-QyffEA3i5dma5q2490+SgCvDN0pXLmRGSyAANuVi0HQ01Pkfr9fuoKQW8wm1wGBnJITs/mS7wQvS6VshUEBFCw==" + }, + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmmirror.com/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + }, + "magic-string": { + "version": "0.30.5", + "resolved": "https://registry.npmmirror.com/magic-string/-/magic-string-0.30.5.tgz", + "integrity": "sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==", + "requires": { + "@jridgewell/sourcemap-codec": "^1.4.15" + } + }, + "matches-selector": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/matches-selector/-/matches-selector-1.2.0.tgz", + "integrity": "sha512-c4vLwYWyl+Ji+U43eU/G5FwxWd4ZH0ePUsFs5y0uwD9HUEFBXUQ1zUUan+78IpRD+y4pUfG0nAzNM292K7ItvA==", + "dev": true + }, + "memoize-one": { + "version": "6.0.0", + "resolved": "https://registry.npmmirror.com/memoize-one/-/memoize-one-6.0.0.tgz", + "integrity": "sha512-rkpe71W0N0c0Xz6QD0eJETuWAJGnJ9afsl1srmwPrI+yBCkge5EycXXbYRyvL29zZVUWQCY7InPRCv3GDXuZNw==" + }, + "merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmmirror.com/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true + }, + "micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmmirror.com/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dev": true, + "requires": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + } + }, + "mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==" + }, + "mime-match": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/mime-match/-/mime-match-1.0.2.tgz", + "integrity": "sha512-VXp/ugGDVh3eCLOBCiHZMYWQaTNUHv2IJrut+yXA6+JbLPXHglHwfS/5A5L0ll+jkCY7fIzRJcH6OIunF+c6Cg==", + "requires": { + "wildcard": "^1.1.0" + } + }, + "mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmmirror.com/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "requires": { + "mime-db": "1.52.0" + } + }, + "min-dash": { + "version": "3.8.1", + "resolved": "https://registry.npmmirror.com/min-dash/-/min-dash-3.8.1.tgz", + "integrity": "sha512-evumdlmIlg9mbRVPbC4F5FuRhNmcMS5pvuBUbqb1G9v09Ro0ImPEgz5n3khir83lFok1inKqVDjnKEg3GpDxQg==" + }, + "min-dom": { + "version": "3.2.1", + "resolved": "https://registry.npmmirror.com/min-dom/-/min-dom-3.2.1.tgz", + "integrity": "sha512-v6YCmnDzxk4rRJntWTUiwggLupPw/8ZSRqUq0PDaBwVZEO/wYzCH4SKVBV+KkEvf3u0XaWHly5JEosPtqRATZA==", + "dev": true, + "requires": { + "component-event": "^0.1.4", + "domify": "^1.3.1", + "indexof": "0.0.1", + "matches-selector": "^1.2.0", + "min-dash": "^3.8.1" + } + }, + "minimatch": { + "version": "5.1.1", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-5.1.1.tgz", + "integrity": "sha512-362NP+zlprccbEt/SkxKfRMHnNY85V74mVnpUpNyr3F35covl09Kec7/sEFLt3RA4oXmewtoaanoIf67SE5Y5g==", + "requires": { + "brace-expansion": "^2.0.1" + } + }, + "minimist": { + "version": "1.2.7", + "resolved": "https://registry.npmmirror.com/minimist/-/minimist-1.2.7.tgz", + "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==", + "dev": true + }, + "mitt": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/mitt/-/mitt-1.2.0.tgz", + "integrity": "sha512-r6lj77KlwqLhIUku9UWYes7KJtsczvolZkzp8hbaDPPaE24OmWl5s539Mytlj22siEQKosZ26qCBgda2PKwoJw==", + "dev": true + }, + "mlly": { + "version": "1.4.2", + "resolved": "https://registry.npmmirror.com/mlly/-/mlly-1.4.2.tgz", + "integrity": "sha512-i/Ykufi2t1EZ6NaPLdfnZk2AX8cs0d+mTzVKuPfqPKPatxLApaBoxJQ9x1/uckXtrS/U5oisPMDkNs0yQTaBRg==", + "dev": true, + "requires": { + "acorn": "^8.10.0", + "pathe": "^1.1.1", + "pkg-types": "^1.0.3", + "ufo": "^1.3.0" + } + }, + "moddle": { + "version": "5.0.4", + "resolved": "https://registry.npmmirror.com/moddle/-/moddle-5.0.4.tgz", + "integrity": "sha512-Kjb+hjuzO+YlojNGxEUXvdhLYTHTtAABDlDcJTtTcn5MbJF9Zkv4I1Fyvp3Ypmfgg1EfHDZ3PsCQTuML9JD6wg==", + "dev": true, + "requires": { + "min-dash": "^3.0.0" + } + }, + "moddle-xml": { + "version": "9.0.6", + "resolved": "https://registry.npmmirror.com/moddle-xml/-/moddle-xml-9.0.6.tgz", + "integrity": "sha512-tl0reHpsY/aKlLGhXeFlQWlYAQHFxTkFqC8tq8jXRYpQSnLVw13T6swMaourLd7EXqHdWsc+5ggsB+fEep6xZQ==", + "dev": true, + "requires": { + "min-dash": "^3.5.2", + "moddle": "^5.0.2", + "saxen": "^8.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmmirror.com/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "muggle-string": { + "version": "0.1.0", + "resolved": "https://registry.npmmirror.com/muggle-string/-/muggle-string-0.1.0.tgz", + "integrity": "sha512-Tr1knR3d2mKvvWthlk7202rywKbiOm4rVFLsfAaSIhJ6dt9o47W4S+JMtWhd/PW9Wrdew2/S2fSvhz3E2gkfEg==", + "dev": true + }, + "namespace-emitter": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/namespace-emitter/-/namespace-emitter-2.0.1.tgz", + "integrity": "sha512-N/sMKHniSDJBjfrkbS/tpkPj4RAbvW3mr8UAzvlMHyun93XEm83IAvhWtJVHo+RHn/oO8Job5YN4b+wRjSVp5g==" + }, + "nanoid": { + "version": "3.3.6", + "resolved": "https://registry.npmmirror.com/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==" + }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmmirror.com/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true + }, + "natural-compare-lite": { + "version": "1.4.0", + "resolved": "https://registry.npmmirror.com/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", + "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", + "dev": true + }, + "next-tick": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/next-tick/-/next-tick-1.1.0.tgz", + "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" + }, + "node-releases": { + "version": "2.0.13", + "resolved": "https://registry.npmmirror.com/node-releases/-/node-releases-2.0.13.tgz", + "integrity": "sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==", + "dev": true + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true + }, + "normalize-range": { + "version": "0.1.2", + "resolved": "https://registry.npmmirror.com/normalize-range/-/normalize-range-0.1.2.tgz", + "integrity": "sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA==", + "dev": true + }, + "normalize-wheel-es": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/normalize-wheel-es/-/normalize-wheel-es-1.2.0.tgz", + "integrity": "sha512-Wj7+EJQ8mSuXr2iWfnujrimU35R2W4FAErEyTmJoJ7ucwTn2hOUSsRehMb5RSYkxXGTM7Y9QpvPmp++w5ftoJw==" + }, + "nth-check": { + "version": "2.1.1", + "resolved": "https://registry.npmmirror.com/nth-check/-/nth-check-2.1.1.tgz", + "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", + "dev": true, + "requires": { + "boolbase": "^1.0.0" + } + }, + "object-inspect": { + "version": "1.13.1", + "resolved": "https://registry.npmmirror.com/object-inspect/-/object-inspect-1.13.1.tgz", + "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==", + "dev": true + }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true + }, + "object-refs": { + "version": "0.3.0", + "resolved": "https://registry.npmmirror.com/object-refs/-/object-refs-0.3.0.tgz", + "integrity": "sha512-eP0ywuoWOaDoiake/6kTJlPJhs+k0qNm4nYRzXLNHj6vh+5M3i9R1epJTdxIPGlhWc4fNRQ7a6XJNCX+/L4FOQ==", + "dev": true + }, + "object.assign": { + "version": "4.1.4", + "resolved": "https://registry.npmmirror.com/object.assign/-/object.assign-4.1.4.tgz", + "integrity": "sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "has-symbols": "^1.0.3", + "object-keys": "^1.1.1" + } + }, + "object.fromentries": { + "version": "2.0.7", + "resolved": "https://registry.npmmirror.com/object.fromentries/-/object.fromentries-2.0.7.tgz", + "integrity": "sha512-UPbPHML6sL8PI/mOqPwsH4G6iyXcCGzLin8KvEPenOZN5lpCNBZZQ+V62vdjB1mQHrmqGQt5/OJzemUA+KJmEA==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1" + } + }, + "object.groupby": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/object.groupby/-/object.groupby-1.0.1.tgz", + "integrity": "sha512-HqaQtqLnp/8Bn4GL16cj+CUYbnpe1bh0TtEaWvybszDG4tgxCJuRpV8VGuvNaI1fAnI4lUJzDG55MXcOH4JZcQ==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "get-intrinsic": "^1.2.1" + } + }, + "object.values": { + "version": "1.1.7", + "resolved": "https://registry.npmmirror.com/object.values/-/object.values-1.1.7.tgz", + "integrity": "sha512-aU6xnDFYT3x17e/f0IiiwlGPTy2jzMySGfUB4fq6z7CV8l85CWHDk5ErhyhpfDHhrOMwGFhSQkhMGHaIotA6Ng==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmmirror.com/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "optionator": { + "version": "0.9.1", + "resolved": "https://registry.npmmirror.com/optionator/-/optionator-0.9.1.tgz", + "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "dev": true, + "requires": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.3" + } + }, + "p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmmirror.com/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "requires": { + "yocto-queue": "^0.1.0" + } + }, + "p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmmirror.com/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "requires": { + "p-limit": "^3.0.2" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmmirror.com/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==" + }, + "parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "requires": { + "callsites": "^3.0.0" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==" + }, + "path-intersection": { + "version": "2.2.1", + "resolved": "https://registry.npmmirror.com/path-intersection/-/path-intersection-2.2.1.tgz", + "integrity": "sha512-9u8xvMcSfuOiStv9bPdnRJQhGQXLKurew94n4GPQCdH1nj9QKC9ObbNoIpiRq8skiOBxKkt277PgOoFgAt3/rA==", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmmirror.com/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmmirror.com/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true + }, + "pathe": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/pathe/-/pathe-1.1.1.tgz", + "integrity": "sha512-d+RQGp0MAYTIaDBIMmOfMwz3E+LOZnxx1HZd5R18mmCZY0QBlK0LDZfPc8FW8Ed2DlvsuE6PRjroDY+wg4+j/Q==", + "dev": true + }, + "picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" + }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + }, + "pinia": { + "version": "2.1.6", + "resolved": "https://registry.npmmirror.com/pinia/-/pinia-2.1.6.tgz", + "integrity": "sha512-bIU6QuE5qZviMmct5XwCesXelb5VavdOWKWaB17ggk++NUwQWWbP5YnsONTk3b752QkW9sACiR81rorpeOMSvQ==", + "requires": { + "@vue/devtools-api": "^6.5.0", + "vue-demi": ">=0.14.5" + }, + "dependencies": { + "vue-demi": { + "version": "0.14.6", + "resolved": "https://registry.npmmirror.com/vue-demi/-/vue-demi-0.14.6.tgz", + "integrity": "sha512-8QA7wrYSHKaYgUxDA5ZC24w+eHm3sYCbp0EzcDwKqN3p6HqtTCGR/GVsPyZW92unff4UlcSh++lmqDWN3ZIq4w==", + "requires": {} + } + } + }, + "pinia-plugin-persist": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/pinia-plugin-persist/-/pinia-plugin-persist-1.0.0.tgz", + "integrity": "sha512-M4hBBd8fz/GgNmUPaaUsC29y1M09lqbXrMAHcusVoU8xlQi1TqgkWnnhvMikZwr7Le/hVyMx8KUcumGGrR6GVw==", + "requires": { + "vue-demi": "^0.12.1" + }, + "dependencies": { + "vue-demi": { + "version": "0.12.5", + "resolved": "https://registry.npmmirror.com/vue-demi/-/vue-demi-0.12.5.tgz", + "integrity": "sha512-BREuTgTYlUr0zw0EZn3hnhC3I6gPWv+Kwh4MCih6QcAeaTlaIX0DwOVN0wHej7hSvDPecz4jygy/idsgKfW58Q==", + "requires": {} + } + } + }, + "pkg-types": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/pkg-types/-/pkg-types-1.0.3.tgz", + "integrity": "sha512-nN7pYi0AQqJnoLPC9eHFQ8AcyaixBUOwvqc5TDnIKCMEE6I0y8P7OKA7fPexsXGCGxQDl/cmrLAp26LhcwxZ4A==", + "dev": true, + "requires": { + "jsonc-parser": "^3.2.0", + "mlly": "^1.2.0", + "pathe": "^1.1.0" + } + }, + "pngjs": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz", + "integrity": "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==" + }, + "postcss": { + "version": "8.4.31", + "resolved": "https://registry.npmmirror.com/postcss/-/postcss-8.4.31.tgz", + "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", + "requires": { + "nanoid": "^3.3.6", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" + } + }, + "postcss-attribute-case-insensitive": { + "version": "5.0.2", + "resolved": "https://registry.npmmirror.com/postcss-attribute-case-insensitive/-/postcss-attribute-case-insensitive-5.0.2.tgz", + "integrity": "sha512-XIidXV8fDr0kKt28vqki84fRK8VW8eTuIa4PChv2MqKuT6C9UjmSKzen6KaWhWEoYvwxFCa7n/tC1SZ3tyq4SQ==", + "dev": true, + "requires": { + "postcss-selector-parser": "^6.0.10" + } + }, + "postcss-clamp": { + "version": "4.1.0", + "resolved": "https://registry.npmmirror.com/postcss-clamp/-/postcss-clamp-4.1.0.tgz", + "integrity": "sha512-ry4b1Llo/9zz+PKC+030KUnPITTJAHeOwjfAyyB60eT0AorGLdzp52s31OsPRHRf8NchkgFoG2y6fCfn1IV1Ow==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-color-functional-notation": { + "version": "4.2.4", + "resolved": "https://registry.npmmirror.com/postcss-color-functional-notation/-/postcss-color-functional-notation-4.2.4.tgz", + "integrity": "sha512-2yrTAUZUab9s6CpxkxC4rVgFEVaR6/2Pipvi6qcgvnYiVqZcbDHEoBDhrXzyb7Efh2CCfHQNtcqWcIruDTIUeg==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-color-hex-alpha": { + "version": "8.0.4", + "resolved": "https://registry.npmmirror.com/postcss-color-hex-alpha/-/postcss-color-hex-alpha-8.0.4.tgz", + "integrity": "sha512-nLo2DCRC9eE4w2JmuKgVA3fGL3d01kGq752pVALF68qpGLmx2Qrk91QTKkdUqqp45T1K1XV8IhQpcu1hoAQflQ==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-color-rebeccapurple": { + "version": "7.1.1", + "resolved": "https://registry.npmmirror.com/postcss-color-rebeccapurple/-/postcss-color-rebeccapurple-7.1.1.tgz", + "integrity": "sha512-pGxkuVEInwLHgkNxUc4sdg4g3py7zUeCQ9sMfwyHAT+Ezk8a4OaaVZ8lIY5+oNqA/BXXgLyXv0+5wHP68R79hg==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-custom-media": { + "version": "8.0.2", + "resolved": "https://registry.npmmirror.com/postcss-custom-media/-/postcss-custom-media-8.0.2.tgz", + "integrity": "sha512-7yi25vDAoHAkbhAzX9dHx2yc6ntS4jQvejrNcC+csQJAXjj15e7VcWfMgLqBNAbOvqi5uIa9huOVwdHbf+sKqg==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-custom-properties": { + "version": "12.1.11", + "resolved": "https://registry.npmmirror.com/postcss-custom-properties/-/postcss-custom-properties-12.1.11.tgz", + "integrity": "sha512-0IDJYhgU8xDv1KY6+VgUwuQkVtmYzRwu+dMjnmdMafXYv86SWqfxkc7qdDvWS38vsjaEtv8e0vGOUQrAiMBLpQ==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-custom-selectors": { + "version": "6.0.3", + "resolved": "https://registry.npmmirror.com/postcss-custom-selectors/-/postcss-custom-selectors-6.0.3.tgz", + "integrity": "sha512-fgVkmyiWDwmD3JbpCmB45SvvlCD6z9CG6Ie6Iere22W5aHea6oWa7EM2bpnv2Fj3I94L3VbtvX9KqwSi5aFzSg==", + "dev": true, + "requires": { + "postcss-selector-parser": "^6.0.4" + } + }, + "postcss-dir-pseudo-class": { + "version": "6.0.5", + "resolved": "https://registry.npmmirror.com/postcss-dir-pseudo-class/-/postcss-dir-pseudo-class-6.0.5.tgz", + "integrity": "sha512-eqn4m70P031PF7ZQIvSgy9RSJ5uI2171O/OO/zcRNYpJbvaeKFUlar1aJ7rmgiQtbm0FSPsRewjpdS0Oew7MPA==", + "dev": true, + "requires": { + "postcss-selector-parser": "^6.0.10" + } + }, + "postcss-double-position-gradients": { + "version": "3.1.2", + "resolved": "https://registry.npmmirror.com/postcss-double-position-gradients/-/postcss-double-position-gradients-3.1.2.tgz", + "integrity": "sha512-GX+FuE/uBR6eskOK+4vkXgT6pDkexLokPaz/AbJna9s5Kzp/yl488pKPjhy0obB475ovfT1Wv8ho7U/cHNaRgQ==", + "dev": true, + "requires": { + "@csstools/postcss-progressive-custom-properties": "^1.1.0", + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-env-function": { + "version": "4.0.6", + "resolved": "https://registry.npmmirror.com/postcss-env-function/-/postcss-env-function-4.0.6.tgz", + "integrity": "sha512-kpA6FsLra+NqcFnL81TnsU+Z7orGtDTxcOhl6pwXeEq1yFPpRMkCDpHhrz8CFQDr/Wfm0jLiNQ1OsGGPjlqPwA==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-focus-visible": { + "version": "6.0.4", + "resolved": "https://registry.npmmirror.com/postcss-focus-visible/-/postcss-focus-visible-6.0.4.tgz", + "integrity": "sha512-QcKuUU/dgNsstIK6HELFRT5Y3lbrMLEOwG+A4s5cA+fx3A3y/JTq3X9LaOj3OC3ALH0XqyrgQIgey/MIZ8Wczw==", + "dev": true, + "requires": { + "postcss-selector-parser": "^6.0.9" + } + }, + "postcss-focus-within": { + "version": "5.0.4", + "resolved": "https://registry.npmmirror.com/postcss-focus-within/-/postcss-focus-within-5.0.4.tgz", + "integrity": "sha512-vvjDN++C0mu8jz4af5d52CB184ogg/sSxAFS+oUJQq2SuCe7T5U2iIsVJtsCp2d6R4j0jr5+q3rPkBVZkXD9fQ==", + "dev": true, + "requires": { + "postcss-selector-parser": "^6.0.9" + } + }, + "postcss-font-variant": { + "version": "5.0.0", + "resolved": "https://registry.npmmirror.com/postcss-font-variant/-/postcss-font-variant-5.0.0.tgz", + "integrity": "sha512-1fmkBaCALD72CK2a9i468mA/+tr9/1cBxRRMXOUaZqO43oWPR5imcyPjXwuv7PXbCid4ndlP5zWhidQVVa3hmA==", + "dev": true, + "requires": {} + }, + "postcss-gap-properties": { + "version": "3.0.5", + "resolved": "https://registry.npmmirror.com/postcss-gap-properties/-/postcss-gap-properties-3.0.5.tgz", + "integrity": "sha512-IuE6gKSdoUNcvkGIqdtjtcMtZIFyXZhmFd5RUlg97iVEvp1BZKV5ngsAjCjrVy+14uhGBQl9tzmi1Qwq4kqVOg==", + "dev": true, + "requires": {} + }, + "postcss-html": { + "version": "1.5.0", + "resolved": "https://registry.npmmirror.com/postcss-html/-/postcss-html-1.5.0.tgz", + "integrity": "sha512-kCMRWJRHKicpA166kc2lAVUGxDZL324bkj/pVOb6RhjB0Z5Krl7mN0AsVkBhVIRZZirY0lyQXG38HCVaoKVNoA==", + "dev": true, + "requires": { + "htmlparser2": "^8.0.0", + "js-tokens": "^8.0.0", + "postcss": "^8.4.0", + "postcss-safe-parser": "^6.0.0" + }, + "dependencies": { + "js-tokens": { + "version": "8.0.0", + "resolved": "https://registry.npmmirror.com/js-tokens/-/js-tokens-8.0.0.tgz", + "integrity": "sha512-PC7MzqInq9OqKyTXfIvQNcjMkODJYC8A17kAaQgeW79yfhqTWSOfjHYQ2mDDcwJ96Iibtwkfh0C7R/OvqPlgVA==", + "dev": true + } + } + }, + "postcss-image-set-function": { + "version": "4.0.7", + "resolved": "https://registry.npmmirror.com/postcss-image-set-function/-/postcss-image-set-function-4.0.7.tgz", + "integrity": "sha512-9T2r9rsvYzm5ndsBE8WgtrMlIT7VbtTfE7b3BQnudUqnBcBo7L758oc+o+pdj/dUV0l5wjwSdjeOH2DZtfv8qw==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-initial": { + "version": "4.0.1", + "resolved": "https://registry.npmmirror.com/postcss-initial/-/postcss-initial-4.0.1.tgz", + "integrity": "sha512-0ueD7rPqX8Pn1xJIjay0AZeIuDoF+V+VvMt/uOnn+4ezUKhZM/NokDeP6DwMNyIoYByuN/94IQnt5FEkaN59xQ==", + "dev": true, + "requires": {} + }, + "postcss-lab-function": { + "version": "4.2.1", + "resolved": "https://registry.npmmirror.com/postcss-lab-function/-/postcss-lab-function-4.2.1.tgz", + "integrity": "sha512-xuXll4isR03CrQsmxyz92LJB2xX9n+pZJ5jE9JgcnmsCammLyKdlzrBin+25dy6wIjfhJpKBAN80gsTlCgRk2w==", + "dev": true, + "requires": { + "@csstools/postcss-progressive-custom-properties": "^1.1.0", + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-logical": { + "version": "5.0.4", + "resolved": "https://registry.npmmirror.com/postcss-logical/-/postcss-logical-5.0.4.tgz", + "integrity": "sha512-RHXxplCeLh9VjinvMrZONq7im4wjWGlRJAqmAVLXyZaXwfDWP73/oq4NdIp+OZwhQUMj0zjqDfM5Fj7qby+B4g==", + "dev": true, + "requires": {} + }, + "postcss-media-minmax": { + "version": "5.0.0", + "resolved": "https://registry.npmmirror.com/postcss-media-minmax/-/postcss-media-minmax-5.0.0.tgz", + "integrity": "sha512-yDUvFf9QdFZTuCUg0g0uNSHVlJ5X1lSzDZjPSFaiCWvjgsvu8vEVxtahPrLMinIDEEGnx6cBe6iqdx5YWz08wQ==", + "dev": true, + "requires": {} + }, + "postcss-nesting": { + "version": "10.2.0", + "resolved": "https://registry.npmmirror.com/postcss-nesting/-/postcss-nesting-10.2.0.tgz", + "integrity": "sha512-EwMkYchxiDiKUhlJGzWsD9b2zvq/r2SSubcRrgP+jujMXFzqvANLt16lJANC+5uZ6hjI7lpRmI6O8JIl+8l1KA==", + "dev": true, + "requires": { + "@csstools/selector-specificity": "^2.0.0", + "postcss-selector-parser": "^6.0.10" + } + }, + "postcss-opacity-percentage": { + "version": "1.1.3", + "resolved": "https://registry.npmmirror.com/postcss-opacity-percentage/-/postcss-opacity-percentage-1.1.3.tgz", + "integrity": "sha512-An6Ba4pHBiDtyVpSLymUUERMo2cU7s+Obz6BTrS+gxkbnSBNKSuD0AVUc+CpBMrpVPKKfoVz0WQCX+Tnst0i4A==", + "dev": true, + "requires": {} + }, + "postcss-overflow-shorthand": { + "version": "3.0.4", + "resolved": "https://registry.npmmirror.com/postcss-overflow-shorthand/-/postcss-overflow-shorthand-3.0.4.tgz", + "integrity": "sha512-otYl/ylHK8Y9bcBnPLo3foYFLL6a6Ak+3EQBPOTR7luMYCOsiVTUk1iLvNf6tVPNGXcoL9Hoz37kpfriRIFb4A==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-page-break": { + "version": "3.0.4", + "resolved": "https://registry.npmmirror.com/postcss-page-break/-/postcss-page-break-3.0.4.tgz", + "integrity": "sha512-1JGu8oCjVXLa9q9rFTo4MbeeA5FMe00/9C7lN4va606Rdb+HkxXtXsmEDrIraQ11fGz/WvKWa8gMuCKkrXpTsQ==", + "dev": true, + "requires": {} + }, + "postcss-place": { + "version": "7.0.5", + "resolved": "https://registry.npmmirror.com/postcss-place/-/postcss-place-7.0.5.tgz", + "integrity": "sha512-wR8igaZROA6Z4pv0d+bvVrvGY4GVHihBCBQieXFY3kuSuMyOmEnnfFzHl/tQuqHZkfkIVBEbDvYcFfHmpSet9g==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-preset-env": { + "version": "7.8.3", + "resolved": "https://registry.npmmirror.com/postcss-preset-env/-/postcss-preset-env-7.8.3.tgz", + "integrity": "sha512-T1LgRm5uEVFSEF83vHZJV2z19lHg4yJuZ6gXZZkqVsqv63nlr6zabMH3l4Pc01FQCyfWVrh2GaUeCVy9Po+Aag==", + "dev": true, + "requires": { + "@csstools/postcss-cascade-layers": "^1.1.1", + "@csstools/postcss-color-function": "^1.1.1", + "@csstools/postcss-font-format-keywords": "^1.0.1", + "@csstools/postcss-hwb-function": "^1.0.2", + "@csstools/postcss-ic-unit": "^1.0.1", + "@csstools/postcss-is-pseudo-class": "^2.0.7", + "@csstools/postcss-nested-calc": "^1.0.0", + "@csstools/postcss-normalize-display-values": "^1.0.1", + "@csstools/postcss-oklab-function": "^1.1.1", + "@csstools/postcss-progressive-custom-properties": "^1.3.0", + "@csstools/postcss-stepped-value-functions": "^1.0.1", + "@csstools/postcss-text-decoration-shorthand": "^1.0.0", + "@csstools/postcss-trigonometric-functions": "^1.0.2", + "@csstools/postcss-unset-value": "^1.0.2", + "autoprefixer": "^10.4.13", + "browserslist": "^4.21.4", + "css-blank-pseudo": "^3.0.3", + "css-has-pseudo": "^3.0.4", + "css-prefers-color-scheme": "^6.0.3", + "cssdb": "^7.1.0", + "postcss-attribute-case-insensitive": "^5.0.2", + "postcss-clamp": "^4.1.0", + "postcss-color-functional-notation": "^4.2.4", + "postcss-color-hex-alpha": "^8.0.4", + "postcss-color-rebeccapurple": "^7.1.1", + "postcss-custom-media": "^8.0.2", + "postcss-custom-properties": "^12.1.10", + "postcss-custom-selectors": "^6.0.3", + "postcss-dir-pseudo-class": "^6.0.5", + "postcss-double-position-gradients": "^3.1.2", + "postcss-env-function": "^4.0.6", + "postcss-focus-visible": "^6.0.4", + "postcss-focus-within": "^5.0.4", + "postcss-font-variant": "^5.0.0", + "postcss-gap-properties": "^3.0.5", + "postcss-image-set-function": "^4.0.7", + "postcss-initial": "^4.0.1", + "postcss-lab-function": "^4.2.1", + "postcss-logical": "^5.0.4", + "postcss-media-minmax": "^5.0.0", + "postcss-nesting": "^10.2.0", + "postcss-opacity-percentage": "^1.1.2", + "postcss-overflow-shorthand": "^3.0.4", + "postcss-page-break": "^3.0.4", + "postcss-place": "^7.0.5", + "postcss-pseudo-class-any-link": "^7.1.6", + "postcss-replace-overflow-wrap": "^4.0.0", + "postcss-selector-not": "^6.0.1", + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-pseudo-class-any-link": { + "version": "7.1.6", + "resolved": "https://registry.npmmirror.com/postcss-pseudo-class-any-link/-/postcss-pseudo-class-any-link-7.1.6.tgz", + "integrity": "sha512-9sCtZkO6f/5ML9WcTLcIyV1yz9D1rf0tWc+ulKcvV30s0iZKS/ONyETvoWsr6vnrmW+X+KmuK3gV/w5EWnT37w==", + "dev": true, + "requires": { + "postcss-selector-parser": "^6.0.10" + } + }, + "postcss-replace-overflow-wrap": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/postcss-replace-overflow-wrap/-/postcss-replace-overflow-wrap-4.0.0.tgz", + "integrity": "sha512-KmF7SBPphT4gPPcKZc7aDkweHiKEEO8cla/GjcBK+ckKxiZslIu3C4GCRW3DNfL0o7yW7kMQu9xlZ1kXRXLXtw==", + "dev": true, + "requires": {} + }, + "postcss-safe-parser": { + "version": "6.0.0", + "resolved": "https://registry.npmmirror.com/postcss-safe-parser/-/postcss-safe-parser-6.0.0.tgz", + "integrity": "sha512-FARHN8pwH+WiS2OPCxJI8FuRJpTVnn6ZNFiqAM2aeW2LwTHWWmWgIyKC6cUo0L8aeKiF/14MNvnpls6R2PBeMQ==", + "dev": true, + "requires": {} + }, + "postcss-scss": { + "version": "4.0.6", + "resolved": "https://registry.npmmirror.com/postcss-scss/-/postcss-scss-4.0.6.tgz", + "integrity": "sha512-rLDPhJY4z/i4nVFZ27j9GqLxj1pwxE80eAzUNRMXtcpipFYIeowerzBgG3yJhMtObGEXidtIgbUpQ3eLDsf5OQ==", + "dev": true, + "requires": {} + }, + "postcss-selector-not": { + "version": "6.0.1", + "resolved": "https://registry.npmmirror.com/postcss-selector-not/-/postcss-selector-not-6.0.1.tgz", + "integrity": "sha512-1i9affjAe9xu/y9uqWH+tD4r6/hDaXJruk8xn2x1vzxC2U3J3LKO3zJW4CyxlNhA56pADJ/djpEwpH1RClI2rQ==", + "dev": true, + "requires": { + "postcss-selector-parser": "^6.0.10" + } + }, + "postcss-selector-parser": { + "version": "6.0.11", + "resolved": "https://registry.npmmirror.com/postcss-selector-parser/-/postcss-selector-parser-6.0.11.tgz", + "integrity": "sha512-zbARubNdogI9j7WY4nQJBiNqQf3sLS3wCP4WfOidu+p28LofJqDH1tcXypGrcmMHhDk2t9wGhCsYe/+szLTy1g==", + "dev": true, + "requires": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + } + }, + "postcss-value-parser": { + "version": "4.2.0", + "resolved": "https://registry.npmmirror.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", + "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", + "dev": true + }, + "preact": { + "version": "10.19.3", + "resolved": "https://registry.npmmirror.com/preact/-/preact-10.19.3.tgz", + "integrity": "sha512-nHHTeFVBTHRGxJXKkKu5hT8C/YWBkPso4/Gad6xuj5dbptt9iF9NZr9pHbPhBrnT2klheu7mHTxTZ/LjwJiEiQ==" + }, + "prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmmirror.com/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true + }, + "prettier": { + "version": "2.8.1", + "resolved": "https://registry.npmmirror.com/prettier/-/prettier-2.8.1.tgz", + "integrity": "sha512-lqGoSJBQNJidqCHE80vqZJHWHRFoNYsSpP9AjFhlhi9ODCJA541svILes/+/1GM3VaL/abZi7cpFzOpdR9UPKg==", + "dev": true + }, + "prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "requires": { + "fast-diff": "^1.1.2" + } + }, + "prismjs": { + "version": "1.29.0", + "resolved": "https://registry.npmmirror.com/prismjs/-/prismjs-1.29.0.tgz", + "integrity": "sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==" + }, + "proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmmirror.com/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true + }, + "qrcode": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.0.tgz", + "integrity": "sha512-9MgRpgVc+/+47dFvQeD6U2s0Z92EsKzcHogtum4QB+UNd025WOJSHvn/hjk9xmzj7Stj95CyUAs31mrjxliEsQ==", + "requires": { + "dijkstrajs": "^1.0.1", + "encode-utf8": "^1.0.3", + "pngjs": "^5.0.0", + "yargs": "^15.3.1" + } + }, + "queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmmirror.com/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true + }, + "randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "requires": { + "safe-buffer": "^5.1.0" + } + }, + "readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmmirror.com/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "requires": { + "picomatch": "^2.2.1" + } + }, + "regenerator-runtime": { + "version": "0.14.1", + "resolved": "https://registry.npmmirror.com/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==" + }, + "regexp.prototype.flags": { + "version": "1.5.1", + "resolved": "https://registry.npmmirror.com/regexp.prototype.flags/-/regexp.prototype.flags-1.5.1.tgz", + "integrity": "sha512-sy6TXMN+hnP/wMy+ISxg3krXx7BAtWVO4UouuCN/ziM9UEne0euamVNafDfvC83bRNr95y0V5iijeDQFUNpvrg==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "set-function-name": "^2.0.0" + } + }, + "regexpp": { + "version": "3.2.0", + "resolved": "https://registry.npmmirror.com/regexpp/-/regexpp-3.2.0.tgz", + "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", + "dev": true + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==" + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==" + }, + "resolve": { + "version": "1.22.8", + "resolved": "https://registry.npmmirror.com/resolve/-/resolve-1.22.8.tgz", + "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", + "dev": true, + "requires": { + "is-core-module": "^2.13.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + } + }, + "resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true + }, + "resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true + }, + "reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmmirror.com/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true + }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmmirror.com/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "rollup": { + "version": "3.7.5", + "resolved": "https://registry.npmmirror.com/rollup/-/rollup-3.7.5.tgz", + "integrity": "sha512-z0ZbqHBtS/et2EEUKMrAl2CoSdwN7ZPzL17UMiKN9RjjqHShTlv7F9J6ZJZJNREYjBh3TvBrdfjkFDIXFNeuiQ==", + "devOptional": true, + "requires": { + "fsevents": "~2.3.2" + } + }, + "run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "requires": { + "queue-microtask": "^1.2.2" + } + }, + "safe-array-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/safe-array-concat/-/safe-array-concat-1.0.1.tgz", + "integrity": "sha512-6XbUAseYE2KtOuGueyeobCySj9L4+66Tn6KQMOPQJrAJEowYKW/YR/MGJZl7FdydUdaFu4LYyDZjxf4/Nmo23Q==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.2.1", + "has-symbols": "^1.0.3", + "isarray": "^2.0.5" + } + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + }, + "safe-regex-test": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/safe-regex-test/-/safe-regex-test-1.0.0.tgz", + "integrity": "sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.1.3", + "is-regex": "^1.1.4" + } + }, + "sass": { + "version": "1.57.1", + "resolved": "https://registry.npmmirror.com/sass/-/sass-1.57.1.tgz", + "integrity": "sha512-O2+LwLS79op7GI0xZ8fqzF7X2m/m8WFfI02dHOdsK5R2ECeS5F62zrwg/relM1rjSLy7Vd/DiMNIvPrQGsA0jw==", + "dev": true, + "requires": { + "chokidar": ">=3.0.0 <4.0.0", + "immutable": "^4.0.0", + "source-map-js": ">=0.6.2 <2.0.0" + } + }, + "sax": { + "version": "1.3.0", + "resolved": "https://registry.npmmirror.com/sax/-/sax-1.3.0.tgz", + "integrity": "sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA==" + }, + "saxen": { + "version": "8.1.2", + "resolved": "https://registry.npmmirror.com/saxen/-/saxen-8.1.2.tgz", + "integrity": "sha512-xUOiiFbc3Ow7p8KMxwsGICPx46ZQvy3+qfNVhrkwfz3Vvq45eGt98Ft5IQaA1R/7Tb5B5MKh9fUR9x3c3nDTxw==", + "dev": true + }, + "scroll-into-view-if-needed": { + "version": "2.2.31", + "resolved": "https://registry.npmmirror.com/scroll-into-view-if-needed/-/scroll-into-view-if-needed-2.2.31.tgz", + "integrity": "sha512-dGCXy99wZQivjmjIqihaBQNjryrz5rueJY7eHfTdyWEiR4ttYpsajb14rn9s5d4DY4EcY6+4+U/maARBXJedkA==", + "requires": { + "compute-scroll-into-view": "^1.0.20" + } + }, + "scroll-tabs": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/scroll-tabs/-/scroll-tabs-1.0.1.tgz", + "integrity": "sha512-W4xjEwNS4QAyQnaJ450vQTcKpbnalBAfsTDV926WrxEMOqjyj2To8uv2d0Cp0oxMdk5TkygtzXmctPNc2zgBcg==", + "dev": true, + "requires": { + "min-dash": "^3.1.0", + "min-dom": "^3.1.0", + "mitt": "^1.1.3" + } + }, + "scule": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/scule/-/scule-1.0.0.tgz", + "integrity": "sha512-4AsO/FrViE/iDNEPaAQlb77tf0csuq27EsVpy6ett584EcRTp6pTDLoGWVxCD77y5iU5FauOvhsI4o1APwPoSQ==", + "dev": true + }, + "select": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz", + "integrity": "sha512-OwpTSOfy6xSs1+pwcNrv0RBMOzI39Lp3qQKUTPVVPRjCdNa5JH/oPRiqsesIskK8TVgmRiHwO4KXlV2Li9dANA==" + }, + "selection-update": { + "version": "0.1.2", + "resolved": "https://registry.npmmirror.com/selection-update/-/selection-update-0.1.2.tgz", + "integrity": "sha512-4jzoJNh7VT2s2tvm/kUSskSw7pD0BVcrrGccbfOMK+3AXLBPz6nIy1yo+pbXgvNoTNII96Pq92+sAY+rF0LUAA==", + "dev": true + }, + "semver": { + "version": "7.3.8", + "resolved": "https://registry.npmmirror.com/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + }, + "serialize-javascript": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.1.tgz", + "integrity": "sha512-owoXEFjWRllis8/M1Q+Cw5k8ZH40e3zhp/ovX+Xr/vi1qj6QesbyXXViFbpNvWvPNAD62SutwEXavefrLJWj7w==", + "requires": { + "randombytes": "^2.1.0" + } + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==" + }, + "set-function-length": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/set-function-length/-/set-function-length-1.1.1.tgz", + "integrity": "sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ==", + "dev": true, + "requires": { + "define-data-property": "^1.1.1", + "get-intrinsic": "^1.2.1", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.0" + } + }, + "set-function-name": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/set-function-name/-/set-function-name-2.0.1.tgz", + "integrity": "sha512-tMNCiqYVkXIZgc2Hnoy2IvC/f8ezc5koaRFkCjrpWzGpCd3qbZXPzVy9MAZzK1ch/X0jvSkojys3oqJN0qCmdA==", + "dev": true, + "requires": { + "define-data-property": "^1.0.1", + "functions-have-names": "^1.2.3", + "has-property-descriptors": "^1.0.0" + } + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + }, + "side-channel": { + "version": "1.0.4", + "resolved": "https://registry.npmmirror.com/side-channel/-/side-channel-1.0.4.tgz", + "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "dev": true, + "requires": { + "call-bind": "^1.0.0", + "get-intrinsic": "^1.0.2", + "object-inspect": "^1.9.0" + } + }, + "slash": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true + }, + "slate": { + "version": "0.72.8", + "resolved": "https://registry.npmmirror.com/slate/-/slate-0.72.8.tgz", + "integrity": "sha512-/nJwTswQgnRurpK+bGJFH1oM7naD5qDmHd89JyiKNT2oOKD8marW0QSBtuFnwEbL5aGCS8AmrhXQgNOsn4osAw==", + "requires": { + "immer": "^9.0.6", + "is-plain-object": "^5.0.0", + "tiny-warning": "^1.0.3" + } + }, + "slate-history": { + "version": "0.66.0", + "resolved": "https://registry.npmmirror.com/slate-history/-/slate-history-0.66.0.tgz", + "integrity": "sha512-6MWpxGQZiMvSINlCbMW43E2YBSVMCMCIwQfBzGssjWw4kb0qfvj0pIdblWNRQZD0hR6WHP+dHHgGSeVdMWzfng==", + "requires": { + "is-plain-object": "^5.0.0" + } + }, + "smob": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/smob/-/smob-1.4.1.tgz", + "integrity": "sha512-9LK+E7Hv5R9u4g4C3p+jjLstaLe11MDsL21UpYaCNmapvMkYhqCV4A/f/3gyH8QjMyh6l68q9xC85vihY9ahMQ==" + }, + "snabbdom": { + "version": "3.5.1", + "resolved": "https://registry.npmmirror.com/snabbdom/-/snabbdom-3.5.1.tgz", + "integrity": "sha512-wHMNIOjkm/YNE5EM3RCbr/+DVgPg6AqQAX1eOxO46zYNvCXjKP5Y865tqQj3EXnaMBjkxmQA5jFuDpDK/dbfiA==" + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + }, + "source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==" + }, + "source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "ssr-window": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/ssr-window/-/ssr-window-3.0.0.tgz", + "integrity": "sha512-q+8UfWDg9Itrg0yWK7oe5p/XRCJpJF9OBtXfOPgSJl+u3Xd5KI328RUEvUqSMVM9CiQUEf1QdBzJMkYGErj9QA==" + }, + "string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + } + }, + "string.prototype.trim": { + "version": "1.2.8", + "resolved": "https://registry.npmmirror.com/string.prototype.trim/-/string.prototype.trim-1.2.8.tgz", + "integrity": "sha512-lfjY4HcixfQXOfaqCvcBuOIapyaroTXhbkfJN3gcB1OtyupngWK4sEET9Knd0cXd28kTUqu/kHoV4HKSJdnjiQ==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1" + } + }, + "string.prototype.trimend": { + "version": "1.0.7", + "resolved": "https://registry.npmmirror.com/string.prototype.trimend/-/string.prototype.trimend-1.0.7.tgz", + "integrity": "sha512-Ni79DqeB72ZFq1uH/L6zJ+DKZTkOtPIHovb3YZHQViE+HDouuU4mBrLOLDn5Dde3RF8qw5qVETEjhu9locMLvA==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1" + } + }, + "string.prototype.trimstart": { + "version": "1.0.7", + "resolved": "https://registry.npmmirror.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.7.tgz", + "integrity": "sha512-NGhtDFu3jCEm7B4Fy0DpLewdJQOZcQ0rGbwQ/+stjnrp2i+rlKeCvos9hOIeCmqwratM47OBxY7uFZzjxHXmrg==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1" + } + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "requires": { + "ansi-regex": "^5.0.1" + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "dev": true + }, + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmmirror.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true + }, + "strip-literal": { + "version": "1.3.0", + "resolved": "https://registry.npmmirror.com/strip-literal/-/strip-literal-1.3.0.tgz", + "integrity": "sha512-PugKzOsyXpArk0yWmUwqOZecSO0GH0bPoctLcqNDH9J04pVW3lflYE0ujElBGTloevcxF5MofAOZ7C5l2b+wLg==", + "dev": true, + "requires": { + "acorn": "^8.10.0" + } + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmmirror.com/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "requires": { + "has-flag": "^4.0.0" + } + }, + "supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true + }, + "svg.js": { + "version": "2.7.1", + "resolved": "https://registry.npmmirror.com/svg.js/-/svg.js-2.7.1.tgz", + "integrity": "sha512-ycbxpizEQktk3FYvn/8BH+6/EuWXg7ZpQREJvgacqn46gIddG24tNNe4Son6omdXCnSOaApnpZw6MPCBA1dODA==" + }, + "tapable": { + "version": "2.2.1", + "resolved": "https://registry.npmmirror.com/tapable/-/tapable-2.2.1.tgz", + "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", + "dev": true + }, + "terser": { + "version": "5.24.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.24.0.tgz", + "integrity": "sha512-ZpGR4Hy3+wBEzVEnHvstMvqpD/nABNelQn/z2r0fjVWGQsN3bpOLzQlqDxmb4CDZnXq5lpjnQ+mHQLAOpfM5iw==", + "requires": { + "@jridgewell/source-map": "^0.3.3", + "acorn": "^8.8.2", + "commander": "^2.20.0", + "source-map-support": "~0.5.20" + } + }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmmirror.com/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", + "dev": true + }, + "tiny-emitter": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz", + "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==" + }, + "tiny-svg": { + "version": "2.2.4", + "resolved": "https://registry.npmmirror.com/tiny-svg/-/tiny-svg-2.2.4.tgz", + "integrity": "sha512-NOi39lBknf4UdDEahNkbEAJnzhu1ZcN2j75IS2vLRmIhsfxdZpTChfLKBcN1ShplVmPIXJAIafk6YY5/Aa80lQ==", + "dev": true + }, + "tiny-warning": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/tiny-warning/-/tiny-warning-1.0.3.tgz", + "integrity": "sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==" + }, + "to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==" + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmmirror.com/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + }, + "tsconfig-paths": { + "version": "3.14.2", + "resolved": "https://registry.npmmirror.com/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz", + "integrity": "sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==", + "dev": true, + "requires": { + "@types/json5": "^0.0.29", + "json5": "^1.0.2", + "minimist": "^1.2.6", + "strip-bom": "^3.0.0" + } + }, + "tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmmirror.com/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + }, + "tsutils": { + "version": "3.21.0", + "resolved": "https://registry.npmmirror.com/tsutils/-/tsutils-3.21.0.tgz", + "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + }, + "type": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/type/-/type-1.2.0.tgz", + "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" + }, + "type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmmirror.com/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "requires": { + "prelude-ls": "^1.2.1" + } + }, + "type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmmirror.com/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true + }, + "typed-array-buffer": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/typed-array-buffer/-/typed-array-buffer-1.0.0.tgz", + "integrity": "sha512-Y8KTSIglk9OZEr8zywiIHG/kmQ7KWyjseXs1CbSo8vC42w7hg2HgYTxSWwP0+is7bWDc1H+Fo026CpHFwm8tkw==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.2.1", + "is-typed-array": "^1.1.10" + } + }, + "typed-array-byte-length": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/typed-array-byte-length/-/typed-array-byte-length-1.0.0.tgz", + "integrity": "sha512-Or/+kvLxNpeQ9DtSydonMxCx+9ZXOswtwJn17SNLvhptaXYDJvkFFP5zbfU/uLmvnBJlI4yrnXRxpdWH/M5tNA==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "for-each": "^0.3.3", + "has-proto": "^1.0.1", + "is-typed-array": "^1.1.10" + } + }, + "typed-array-byte-offset": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/typed-array-byte-offset/-/typed-array-byte-offset-1.0.0.tgz", + "integrity": "sha512-RD97prjEt9EL8YgAgpOkf3O4IF9lhJFr9g0htQkm0rchFp/Vx7LW5Q8fSXXub7BXAODyUQohRMyOc3faCPd0hg==", + "dev": true, + "requires": { + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.2", + "for-each": "^0.3.3", + "has-proto": "^1.0.1", + "is-typed-array": "^1.1.10" + } + }, + "typed-array-length": { + "version": "1.0.4", + "resolved": "https://registry.npmmirror.com/typed-array-length/-/typed-array-length-1.0.4.tgz", + "integrity": "sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "for-each": "^0.3.3", + "is-typed-array": "^1.1.9" + } + }, + "typescript": { + "version": "4.9.4", + "resolved": "https://registry.npmmirror.com/typescript/-/typescript-4.9.4.tgz", + "integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==", + "devOptional": true + }, + "ufo": { + "version": "1.3.1", + "resolved": "https://registry.npmmirror.com/ufo/-/ufo-1.3.1.tgz", + "integrity": "sha512-uY/99gMLIOlJPwATcMVYfqDSxUR9//AUcgZMzwfSTJPDKzA1S8mX4VLqa+fiAtveraQUBCz4FFcwVZBGbwBXIw==", + "dev": true + }, + "unbox-primitive": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/unbox-primitive/-/unbox-primitive-1.0.2.tgz", + "integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "has-bigints": "^1.0.2", + "has-symbols": "^1.0.3", + "which-boxed-primitive": "^1.0.2" + } + }, + "unimport": { + "version": "3.4.0", + "resolved": "https://registry.npmmirror.com/unimport/-/unimport-3.4.0.tgz", + "integrity": "sha512-M/lfFEgufIT156QAr/jWHLUn55kEmxBBiQsMxvRSIbquwmeJEyQYgshHDEvQDWlSJrVOOTAgnJ3FvlsrpGkanA==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^5.0.4", + "escape-string-regexp": "^5.0.0", + "fast-glob": "^3.3.1", + "local-pkg": "^0.4.3", + "magic-string": "^0.30.3", + "mlly": "^1.4.2", + "pathe": "^1.1.1", + "pkg-types": "^1.0.3", + "scule": "^1.0.0", + "strip-literal": "^1.3.0", + "unplugin": "^1.5.0" + }, + "dependencies": { + "@rollup/pluginutils": { + "version": "5.0.5", + "resolved": "https://registry.npmmirror.com/@rollup/pluginutils/-/pluginutils-5.0.5.tgz", + "integrity": "sha512-6aEYR910NyP73oHiJglti74iRyOwgFU4x3meH/H8OJx6Ry0j6cOVZ5X/wTvub7G7Ao6qaHBEaNsV3GLJkSsF+Q==", + "dev": true, + "requires": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + } + }, + "escape-string-regexp": { + "version": "5.0.0", + "resolved": "https://registry.npmmirror.com/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", + "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==", + "dev": true + } + } + }, + "unplugin": { + "version": "1.5.0", + "resolved": "https://registry.npmmirror.com/unplugin/-/unplugin-1.5.0.tgz", + "integrity": "sha512-9ZdRwbh/4gcm1JTOkp9lAkIDrtOyOxgHmY7cjuwI8L/2RTikMcVG25GsZwNAgRuap3iDw2jeq7eoqtAsz5rW3A==", + "dev": true, + "requires": { + "acorn": "^8.10.0", + "chokidar": "^3.5.3", + "webpack-sources": "^3.2.3", + "webpack-virtual-modules": "^0.5.0" + } + }, + "unplugin-auto-import": { + "version": "0.16.7", + "resolved": "https://registry.npmmirror.com/unplugin-auto-import/-/unplugin-auto-import-0.16.7.tgz", + "integrity": "sha512-w7XmnRlchq6YUFJVFGSvG1T/6j8GrdYN6Em9Wf0Ye+HXgD/22kont+WnuCAA0UaUoxtuvRR1u/mXKy63g/hfqQ==", + "dev": true, + "requires": { + "@antfu/utils": "^0.7.6", + "@rollup/pluginutils": "^5.0.5", + "fast-glob": "^3.3.1", + "local-pkg": "^0.5.0", + "magic-string": "^0.30.5", + "minimatch": "^9.0.3", + "unimport": "^3.4.0", + "unplugin": "^1.5.0" + }, + "dependencies": { + "@rollup/pluginutils": { + "version": "5.0.5", + "resolved": "https://registry.npmmirror.com/@rollup/pluginutils/-/pluginutils-5.0.5.tgz", + "integrity": "sha512-6aEYR910NyP73oHiJglti74iRyOwgFU4x3meH/H8OJx6Ry0j6cOVZ5X/wTvub7G7Ao6qaHBEaNsV3GLJkSsF+Q==", + "dev": true, + "requires": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + } + }, + "local-pkg": { + "version": "0.5.0", + "resolved": "https://registry.npmmirror.com/local-pkg/-/local-pkg-0.5.0.tgz", + "integrity": "sha512-ok6z3qlYyCDS4ZEU27HaU6x/xZa9Whf8jD4ptH5UZTQYZVYeb9bnZ3ojVhiJNLiXK1Hfc0GNbLXcmZ5plLDDBg==", + "dev": true, + "requires": { + "mlly": "^1.4.2", + "pkg-types": "^1.0.3" + } + }, + "minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + } + } + }, + "unplugin-vue-components": { + "version": "0.25.2", + "resolved": "https://registry.npmmirror.com/unplugin-vue-components/-/unplugin-vue-components-0.25.2.tgz", + "integrity": "sha512-OVmLFqILH6w+eM8fyt/d/eoJT9A6WO51NZLf1vC5c1FZ4rmq2bbGxTy8WP2Jm7xwFdukaIdv819+UI7RClPyCA==", + "dev": true, + "requires": { + "@antfu/utils": "^0.7.5", + "@rollup/pluginutils": "^5.0.2", + "chokidar": "^3.5.3", + "debug": "^4.3.4", + "fast-glob": "^3.3.0", + "local-pkg": "^0.4.3", + "magic-string": "^0.30.1", + "minimatch": "^9.0.3", + "resolve": "^1.22.2", + "unplugin": "^1.4.0" + }, + "dependencies": { + "@rollup/pluginutils": { + "version": "5.0.5", + "resolved": "https://registry.npmmirror.com/@rollup/pluginutils/-/pluginutils-5.0.5.tgz", + "integrity": "sha512-6aEYR910NyP73oHiJglti74iRyOwgFU4x3meH/H8OJx6Ry0j6cOVZ5X/wTvub7G7Ao6qaHBEaNsV3GLJkSsF+Q==", + "dev": true, + "requires": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + } + }, + "minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + } + } + }, + "update-browserslist-db": { + "version": "1.0.13", + "resolved": "https://registry.npmmirror.com/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", + "integrity": "sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==", + "dev": true, + "requires": { + "escalade": "^3.1.1", + "picocolors": "^1.0.0" + } + }, + "uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmmirror.com/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true + }, + "vant": { + "version": "4.7.3", + "resolved": "https://registry.npmmirror.com/vant/-/vant-4.7.3.tgz", + "integrity": "sha512-nb0pXxKSOaE9CvH//KozKDivqhjE4ZRvx1b/RCWFL4H3tZ5l+HhWtwK1yJx5AkO1Pm/IYQY86yZa1tums8DfsQ==", + "requires": { + "@vant/popperjs": "^1.3.0", + "@vant/use": "^1.6.0", + "@vue/shared": "^3.0.0" + } + }, + "vite": { + "version": "4.0.2", + "resolved": "https://registry.npmmirror.com/vite/-/vite-4.0.2.tgz", + "integrity": "sha512-QJaY3R+tFlTagH0exVqbgkkw45B+/bXVBzF2ZD1KB5Z8RiAoiKo60vSUf6/r4c2Vh9jfGBKM4oBI9b4/1ZJYng==", + "dev": true, + "requires": { + "esbuild": "^0.16.3", + "fsevents": "~2.3.2", + "postcss": "^8.4.20", + "resolve": "^1.22.1", + "rollup": "^3.7.0" + } + }, + "vite-plugin-eslint": { + "version": "1.8.1", + "resolved": "https://registry.npmmirror.com/vite-plugin-eslint/-/vite-plugin-eslint-1.8.1.tgz", + "integrity": "sha512-PqdMf3Y2fLO9FsNPmMX+//2BF5SF8nEWspZdgl4kSt7UvHDRHVVfHvxsD7ULYzZrJDGRxR81Nq7TOFgwMnUang==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^4.2.1", + "@types/eslint": "^8.4.5", + "rollup": "^2.77.2" + }, + "dependencies": { + "rollup": { + "version": "2.79.1", + "resolved": "https://registry.npmmirror.com/rollup/-/rollup-2.79.1.tgz", + "integrity": "sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==", + "dev": true, + "requires": { + "fsevents": "~2.3.2" + } + } + } + }, + "vue": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/vue/-/vue-3.3.8.tgz", + "integrity": "sha512-5VSX/3DabBikOXMsxzlW8JyfeLKlG9mzqnWgLQLty88vdZL7ZJgrdgBOmrArwxiLtmS+lNNpPcBYqrhE6TQW5w==", + "requires": { + "@vue/compiler-dom": "3.3.8", + "@vue/compiler-sfc": "3.3.8", + "@vue/runtime-dom": "3.3.8", + "@vue/server-renderer": "3.3.8", + "@vue/shared": "3.3.8" + } + }, + "vue-draggable-plus": { + "version": "0.3.1", + "resolved": "https://registry.npmmirror.com/vue-draggable-plus/-/vue-draggable-plus-0.3.1.tgz", + "integrity": "sha512-Ubo0O8/D+hZPHb1bcDTjOE42a//OjLQwj+bQwfxa1WnEKTJdS7MU0A4auUcNjyIkhTN1xuETOR4mT+BGZCPL2g==", + "requires": {} + }, + "vue-eslint-parser": { + "version": "9.1.0", + "resolved": "https://registry.npmmirror.com/vue-eslint-parser/-/vue-eslint-parser-9.1.0.tgz", + "integrity": "sha512-NGn/iQy8/Wb7RrRa4aRkokyCZfOUWk19OP5HP6JEozQFX5AoS/t+Z0ZN7FY4LlmWc4FNI922V7cvX28zctN8dQ==", + "dev": true, + "requires": { + "debug": "^4.3.4", + "eslint-scope": "^7.1.1", + "eslint-visitor-keys": "^3.3.0", + "espree": "^9.3.1", + "esquery": "^1.4.0", + "lodash": "^4.17.21", + "semver": "^7.3.6" + } + }, + "vue-i18n": { + "version": "9.1.10", + "resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-9.1.10.tgz", + "integrity": "sha512-jpr7gV5KPk4n+sSPdpZT8Qx3XzTcNDWffRlHV/cT2NUyEf+sEgTTmLvnBAibjOFJ0zsUyZlVTAWH5DDnYep+1g==", + "requires": { + "@intlify/core-base": "9.1.10", + "@intlify/shared": "9.1.10", + "@intlify/vue-devtools": "9.1.10", + "@vue/devtools-api": "^6.0.0-beta.7" + } + }, + "vue-json-viewer": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/vue-json-viewer/-/vue-json-viewer-3.0.4.tgz", + "integrity": "sha512-pnC080rTub6YjccthVSNQod2z9Sl5IUUq46srXtn6rxwhW8QM4rlYn+CTSLFKXWfw+N3xv77Cioxw7B4XUKIbQ==", + "requires": { + "clipboard": "^2.0.4" + } + }, + "vue-router": { + "version": "4.2.5", + "resolved": "https://registry.npmmirror.com/vue-router/-/vue-router-4.2.5.tgz", + "integrity": "sha512-DIUpKcyg4+PTQKfFPX88UWhlagBEBEfJ5A8XDXRJLUnZOvcpMF8o/dnL90vpVkGaPbjvXazV/rC1qBKrZlFugw==", + "requires": { + "@vue/devtools-api": "^6.5.0" + } + }, + "vue-template-compiler": { + "version": "2.7.14", + "resolved": "https://registry.npmmirror.com/vue-template-compiler/-/vue-template-compiler-2.7.14.tgz", + "integrity": "sha512-zyA5Y3ArvVG0NacJDkkzJuPQDF8RFeRlzV2vLeSnhSpieO6LK2OVbdLPi5MPPs09Ii+gMO8nY4S3iKQxBxDmWQ==", + "dev": true, + "requires": { + "de-indent": "^1.0.2", + "he": "^1.2.0" + } + }, + "vue-tsc": { + "version": "1.0.14", + "resolved": "https://registry.npmmirror.com/vue-tsc/-/vue-tsc-1.0.14.tgz", + "integrity": "sha512-HeqtyxMrSRUCnU5nxB0lQc3o7zirMppZ/V6HLL3l4FsObGepH3A3beNmNehpLQs0Gt7DkSWVi3CpVCFgrf+/sQ==", + "dev": true, + "requires": { + "@volar/vue-language-core": "1.0.14", + "@volar/vue-typescript": "1.0.14" + } + }, + "vxe-table": { + "version": "4.5.13", + "resolved": "https://registry.npmjs.org/vxe-table/-/vxe-table-4.5.13.tgz", + "integrity": "sha512-CKsyUhDYIcO4TSXoO0I2YVkKEWjQLUq24PN6MhmFmvyFRdfj80cgLZ4iEjihLieW4aRqPcLHqkw83hCAyzvO8w==", + "requires": { + "dom-zindex": "^1.0.1", + "xe-utils": "^3.5.13" + } + }, + "webpack-sources": { + "version": "3.2.3", + "resolved": "https://registry.npmmirror.com/webpack-sources/-/webpack-sources-3.2.3.tgz", + "integrity": "sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==", + "dev": true + }, + "webpack-virtual-modules": { + "version": "0.5.0", + "resolved": "https://registry.npmmirror.com/webpack-virtual-modules/-/webpack-virtual-modules-0.5.0.tgz", + "integrity": "sha512-kyDivFZ7ZM0BVOUteVbDFhlRt7Ah/CSPwJdi8hBpkK7QLumUqdLtVfm/PX/hkcnrvr0i77fO5+TjZ94Pe+C9iw==", + "dev": true + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "which-boxed-primitive": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz", + "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", + "dev": true, + "requires": { + "is-bigint": "^1.0.1", + "is-boolean-object": "^1.1.0", + "is-number-object": "^1.0.4", + "is-string": "^1.0.5", + "is-symbol": "^1.0.3" + } + }, + "which-module": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", + "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==" + }, + "which-typed-array": { + "version": "1.1.13", + "resolved": "https://registry.npmmirror.com/which-typed-array/-/which-typed-array-1.1.13.tgz", + "integrity": "sha512-P5Nra0qjSncduVPEAr7xhoF5guty49ArDTwzJ/yNuPIbZppyRxFQsRCWrocxIY+CnMVG+qfbU2FmDKyvSGClow==", + "dev": true, + "requires": { + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.4", + "for-each": "^0.3.3", + "gopd": "^1.0.1", + "has-tostringtag": "^1.0.0" + } + }, + "wildcard": { + "version": "1.1.2", + "resolved": "https://registry.npmmirror.com/wildcard/-/wildcard-1.1.2.tgz", + "integrity": "sha512-DXukZJxpHA8LuotRwL0pP1+rS6CS7FF2qStDDE1C7DDg2rLud2PXRMuEDYIPhgEezwnlHNL4c+N6MfMTjCGTng==" + }, + "word-wrap": { + "version": "1.2.3", + "resolved": "https://registry.npmmirror.com/word-wrap/-/word-wrap-1.2.3.tgz", + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "dev": true + }, + "wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "xe-utils": { + "version": "3.5.14", + "resolved": "https://registry.npmjs.org/xe-utils/-/xe-utils-3.5.14.tgz", + "integrity": "sha512-Xq6mS8dWwHBQsQUEBXcZYSaBV0KnNLoVWd0vRRDI3nKpbNxfs/LSCK0W21g1edLFnXYfKqg7hh5dakr3RtYY0A==" + }, + "xml-js": { + "version": "1.6.11", + "resolved": "https://registry.npmmirror.com/xml-js/-/xml-js-1.6.11.tgz", + "integrity": "sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==", + "requires": { + "sax": "^1.2.4" + } + }, + "xml-name-validator": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/xml-name-validator/-/xml-name-validator-4.0.0.tgz", + "integrity": "sha512-ICP2e+jsHvAj2E2lIHxa5tjXRlKDJo4IdvPvCXbXQGdzSfmSpNVyIKMvoZHjDY9DP0zV17iI85o90vRFXNccRw==", + "dev": true + }, + "y18n": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==" + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "yargs": { + "version": "15.4.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "requires": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + }, + "dependencies": { + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "requires": { + "p-limit": "^2.2.0" + } + }, + "yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + } + } + }, + "yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmmirror.com/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true + }, + "zrender": { + "version": "5.5.0", + "resolved": "https://registry.npmmirror.com/zrender/-/zrender-5.5.0.tgz", + "integrity": "sha512-O3MilSi/9mwoovx77m6ROZM7sXShR/O/JIanvzTwjN3FORfLSr81PsUGd7jlaYOeds9d8tw82oP44+3YucVo+w==", + "requires": { + "tslib": "2.3.0" + }, + "dependencies": { + "tslib": { + "version": "2.3.0", + "resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.3.0.tgz", + "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==" + } + } + } + } +} diff --git a/OrangeFormsOpen-VUE3/package.json b/OrangeFormsOpen-VUE3/package.json new file mode 100644 index 00000000..265e7294 --- /dev/null +++ b/OrangeFormsOpen-VUE3/package.json @@ -0,0 +1,71 @@ +{ + "name": "vite", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vue-tsc && vite build", + "preview": "vite preview", + "lint": "eslint --fix \"src/**/*.{ts,vue}\" && prettier --write \"src/**/*.{ts,vue}\"" + }, + "dependencies": { + "@highlightjs/vue-plugin": "^2.1.0", + "@layui/layui-vue": "^2.11.5", + "@wangeditor/editor": "^5.1.23", + "@wangeditor/editor-for-vue": "^5.1.12", + "ace-builds": "^1.32.2", + "axios": "^1.5.1", + "bpmn-js-token-simulation": "^0.10.0", + "crypto-js": "^4.2.0", + "dayjs": "^1.11.10", + "echarts": "^5.5.0", + "ejs": "^3.1.9", + "highlight.js": "^11.9.0", + "jsencrypt": "^3.3.2", + "json-bigint": "^1.0.0", + "clipboard": "^2.0.11", + "pinia": "^2.1.6", + "pinia-plugin-persist": "^1.0.0", + "vant": "^4.7.3", + "vue": "^3.3.8", + "element-plus": "^2.7.3", + "vue-draggable-plus": "^0.3.1", + "vue-json-viewer": "^3.0.4", + "vue-router": "^4.2.5", + "vxe-table": "^4.5.13", + "xe-utils": "^3.5.14", + "xml-js": "^1.6.11" + }, + "devDependencies": { + "@types/ejs": "^3.1.5", + "@types/json-bigint": "^1.0.4", + "@types/node": "^18.11.17", + "@typescript-eslint/eslint-plugin": "^5.46.1", + "@typescript-eslint/parser": "^5.46.1", + "@vant/auto-import-resolver": "^1.0.2", + "@vitejs/plugin-vue": "^4.0.0", + "autoprefixer": "^10.4.16", + "bpmn-js": "^7.4.0", + "bpmn-js-properties-panel": "^0.37.2", + "eslint": "^8.30.0", + "eslint-config-prettier": "^8.5.0", + "eslint-import-resolver-typescript": "^3.6.1", + "eslint-plugin-import": "^2.29.0", + "eslint-plugin-prettier": "^4.2.1", + "eslint-plugin-vue": "^9.8.0", + "postcss": "^8.4.20", + "postcss-html": "^1.5.0", + "postcss-preset-env": "^7.8.3", + "postcss-scss": "^4.0.6", + "prettier": "2.8.1", + "sass": "^1.57.1", + "typescript": "^4.9.3", + "unplugin-auto-import": "^0.16.7", + "unplugin-vue-components": "^0.25.2", + "vite": "^4.0.0", + "vite-plugin-eslint": "^1.8.1", + "vue-eslint-parser": "^9.1.0", + "vue-tsc": "^1.0.11" + } +} diff --git a/OrangeFormsOpen-VUE3/public/favicon.ico b/OrangeFormsOpen-VUE3/public/favicon.ico new file mode 100644 index 00000000..eb9d6cdb Binary files /dev/null and b/OrangeFormsOpen-VUE3/public/favicon.ico differ diff --git a/OrangeFormsOpen-VUE3/src/App.vue b/OrangeFormsOpen-VUE3/src/App.vue new file mode 100644 index 00000000..dd6b4300 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/App.vue @@ -0,0 +1,26 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/api/BaseController.ts b/OrangeFormsOpen-VUE3/src/api/BaseController.ts new file mode 100644 index 00000000..c84566a7 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/BaseController.ts @@ -0,0 +1,43 @@ +import { AxiosRequestConfig } from 'axios'; +import { commonRequest, download, downloadBlob, upload } from '@/common/http/request'; +import { RequestOption, RequestMethods } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; + +export class BaseController { + static async get( + url: string, + params: ANY_OBJECT, + options?: RequestOption, + axiosOption?: AxiosRequestConfig, + ) { + return await commonRequest(url, params, 'get', options, axiosOption); + } + static async post( + url: string, + params: ANY_OBJECT, + options?: RequestOption, + axiosOption?: AxiosRequestConfig, + ) { + return await commonRequest(url, params, 'post', options, axiosOption); + } + static download( + url: string, + params: ANY_OBJECT, + filename: string, + method?: RequestMethods, + options?: RequestOption, + ) { + return download(url, params, filename, method, options); + } + static downloadBlob( + url: string, + params: ANY_OBJECT, + method: RequestMethods = 'post', + options?: RequestOption, + ) { + return downloadBlob(url, params, method, options); + } + static upload(url: string, params: ANY_OBJECT, options?: RequestOption) { + return upload(url, params, options); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/config.ts b/OrangeFormsOpen-VUE3/src/api/config.ts new file mode 100644 index 00000000..9aa251a8 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/config.ts @@ -0,0 +1,2 @@ +// 服务前缀 admin or tenantadmin +export const API_CONTEXT = 'admin'; diff --git a/OrangeFormsOpen-VUE3/src/api/flow/FlowCategoryController.ts b/OrangeFormsOpen-VUE3/src/api/flow/FlowCategoryController.ts new file mode 100644 index 00000000..39556427 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/flow/FlowCategoryController.ts @@ -0,0 +1,31 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { TableData } from '@/common/types/table'; +import { API_CONTEXT } from '../config'; + +export default class FlowCategoryController extends BaseController { + static list(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/flow/flowCategory/list', + params, + httpOptions, + ); + } + + static view(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/flow/flowCategory/view', params, httpOptions); + } + + static add(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/flow/flowCategory/add', params, httpOptions); + } + + static update(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/flow/flowCategory/update', params, httpOptions); + } + + static delete(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/flow/flowCategory/delete', params, httpOptions); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/flow/FlowDictionaryController.ts b/OrangeFormsOpen-VUE3/src/api/flow/FlowDictionaryController.ts new file mode 100644 index 00000000..6e9afd67 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/flow/FlowDictionaryController.ts @@ -0,0 +1,23 @@ +import { DictData, DictionaryBase } from '@/common/staticDict/types'; +import { BaseController } from '@/api/BaseController'; +import { RequestOption } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { API_CONTEXT } from '../config'; + +export default class FlowDictionaryController extends BaseController { + static dictFlowCategory( + params: ANY_OBJECT, + httpOptions?: RequestOption, + ): Promise { + return new Promise((resolve, reject) => { + this.get(API_CONTEXT + '/flow/flowCategory/listDict', params, httpOptions) + .then(res => { + const dictData = new DictionaryBase('', res.data); + resolve(dictData); + }) + .catch(err => { + reject(err); + }); + }); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/flow/FlowEntryController.ts b/OrangeFormsOpen-VUE3/src/api/flow/FlowEntryController.ts new file mode 100644 index 00000000..ba4b13f2 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/flow/FlowEntryController.ts @@ -0,0 +1,71 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { TableData } from '@/common/types/table'; +import { API_CONTEXT } from '../config'; + +export default class FlowEntryController extends BaseController { + static list(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/flow/flowEntry/list', + params, + httpOptions, + ); + } + + static view(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/flow/flowEntry/view', params, httpOptions); + } + + static add(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/flow/flowEntry/add', params, httpOptions); + } + + static update(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/flow/flowEntry/update', params, httpOptions); + } + + static delete(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/flow/flowEntry/delete', params, httpOptions); + } + + static publish(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/flow/flowEntry/publish', params, httpOptions); + } + + static listFlowEntryPublish(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get>( + API_CONTEXT + '/flow/flowEntry/listFlowEntryPublish', + params, + httpOptions, + ); + } + + static updateMainVersion(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/flow/flowEntry/updateMainVersion', params, httpOptions); + } + + static suspendFlowEntryPublish(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/flow/flowEntry/suspendFlowEntryPublish', params, httpOptions); + } + + static activateFlowEntryPublish(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/flow/flowEntry/activateFlowEntryPublish', params, httpOptions); + } + + static viewDict(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/flow/flowEntry/viewDict', params, httpOptions); + } + + static listDict(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get>( + API_CONTEXT + '/flow/flowEntry/listDict', + params, + httpOptions, + ); + } + + static listAll(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get('/admin/flow/flowEntry/listAll', params, httpOptions); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/flow/FlowEntryVariableController.ts b/OrangeFormsOpen-VUE3/src/api/flow/FlowEntryVariableController.ts new file mode 100644 index 00000000..9214fd80 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/flow/FlowEntryVariableController.ts @@ -0,0 +1,31 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { TableData } from '@/common/types/table'; +import { API_CONTEXT } from '../config'; + +export default class FlowEntryVariableController extends BaseController { + static list(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/flow/flowEntryVariable/list', + params, + httpOptions, + ); + } + + static add(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/flow/flowEntryVariable/add', params, httpOptions); + } + + static update(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/flow/flowEntryVariable/update', params, httpOptions); + } + + static delete(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/flow/flowEntryVariable/delete', params, httpOptions); + } + + static view(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/flow/flowEntryVariable/view', params, httpOptions); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/flow/FlowOperationController.ts b/OrangeFormsOpen-VUE3/src/api/flow/FlowOperationController.ts new file mode 100644 index 00000000..9c512339 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/flow/FlowOperationController.ts @@ -0,0 +1,277 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { TableData } from '@/common/types/table'; +import { API_CONTEXT } from '../config'; + +export default class FlowOperationController extends BaseController { + // 保存草稿 + static startAndSaveDraft(params: ANY_OBJECT, httpOptions?: RequestOption) { + let url = API_CONTEXT + '/flow/flowOnlineOperation/startAndSaveDraft'; + if (httpOptions && httpOptions.processDefinitionKey) { + url += '/' + httpOptions.processDefinitionKey; + } + return this.post(url, params, httpOptions); + } + // 获取在线表单工作流草稿数据 + static viewOnlineDraftData(params: ANY_OBJECT, httpOptions?: RequestOption) { + const url = API_CONTEXT + '/flow/flowOnlineOperation/viewDraftData'; + return this.get(url, params, httpOptions); + } + // 启动流程实例并且提交表单信息 + static startAndTakeUserTask(params: ANY_OBJECT, httpOptions?: RequestOption) { + let url = API_CONTEXT + '/flow/flowOnlineOperation/startAndTakeUserTask'; + if (httpOptions && httpOptions.processDefinitionKey) { + url += '/' + httpOptions.processDefinitionKey; + } else { + // 从流程设计里启动 + url = API_CONTEXT + '/flow/flowOnlineOperation/startPreview'; + } + return this.post(url, params, httpOptions); + } + // 获得流程以及工单信息 + static listWorkOrder(params: ANY_OBJECT, httpOptions?: RequestOption) { + let url = API_CONTEXT + '/flow/flowOnlineOperation/listWorkOrder'; + if (httpOptions && httpOptions.processDefinitionKey) { + url += '/' + httpOptions.processDefinitionKey; + } + return this.post>(url, params, httpOptions); + } + // 提交用户任务数据 + static submitUserTask(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/flow/flowOnlineOperation/submitUserTask', params, httpOptions); + } + // 获取历史流程数据 + static viewHistoricProcessInstance(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/flow/flowOnlineOperation/viewHistoricProcessInstance', + params, + httpOptions, + ); + } + // 获取用户任务数据 + static viewUserTask(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/flow/flowOnlineOperation/viewUserTask', + params, + httpOptions, + ); + } + // 获取在线表单工作流以及工作流下表单列表 + static listFlowEntryForm(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/flow/flowOnlineOperation/listFlowEntryForm', + params, + httpOptions, + ); + } + // 获得草稿信息 + static viewDraftData(params: ANY_OBJECT, httpOptions?: RequestOption) { + const url = API_CONTEXT + '/flow/flowOperation/viewDraftData'; + return this.get(url, params, httpOptions); + } + // 撤销工单 + static cancelWorkOrder(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/flow/flowOperation/cancelWorkOrder', params, httpOptions); + } + // 多实例加签 + static submitConsign(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/flow/flowOperation/submitConsign', params, httpOptions); + } + // 已办任务列表 + static listHistoricTask(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/flow/flowOperation/listHistoricTask', + params, + httpOptions, + ); + } + // 获取已办任务信息 + static viewHistoricTaskInfo(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/flow/flowOperation/viewHistoricTaskInfo', + params, + httpOptions, + ); + } + // 仅启动流程实例 + static startOnly(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/flow/flowOperation/startOnly', params, httpOptions); + } + // 获得流程定义初始化用户任务信息 + static viewInitialTaskInfo(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/flow/flowOperation/viewInitialTaskInfo', + params, + httpOptions, + ); + } + // 获取待办任务信息 + static viewRuntimeTaskInfo(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/flow/flowOperation/viewRuntimeTaskInfo', + params, + httpOptions, + ); + } + // 获取流程实例审批历史 + static listFlowTaskComment(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/flow/flowOperation/listFlowTaskComment', + params, + httpOptions, + ); + } + // 获取历史任务信息 + static viewInitialHistoricTaskInfo(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/flow/flowOperation/viewInitialHistoricTaskInfo', + params, + httpOptions, + ); + } + // 获取所有待办任务 + static listRuntimeTask(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/flow/flowOperation/listRuntimeTask', + params, + httpOptions, + ); + } + // 获得流程实例审批路径 + static viewHighlightFlowData(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/flow/flowOperation/viewHighlightFlowData', + params, + httpOptions, + ); + } + // 获得流程实例的配置XML + static viewProcessBpmn(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/flow/flowOperation/viewProcessBpmn', + params, + httpOptions, + ); + } + // 获得所有历史流程实例 + static listAllHistoricProcessInstance(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/flow/flowOperation/listAllHistoricProcessInstance', + params, + httpOptions, + ); + } + // 获得当前用户历史流程实例 + static listHistoricProcessInstance(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/flow/flowOperation/listHistoricProcessInstance', + params, + httpOptions, + ); + } + // 终止流程 + static stopProcessInstance(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/flow/flowOperation/stopProcessInstance', params, httpOptions); + } + // 删除流程实例 + static deleteProcessInstance(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post( + API_CONTEXT + '/flow/flowOperation/deleteProcessInstance', + params, + httpOptions, + ); + } + // 催办 + static remindRuntimeTask(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/flow/flowOperation/remindRuntimeTask', params, httpOptions); + } + // 催办消息列表 + static listRemindingTask(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/flow/flowMessage/listRemindingTask', + params, + httpOptions, + ); + } + // 驳回 + static rejectRuntimeTask(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/flow/flowOperation/rejectRuntimeTask', params, httpOptions); + } + // 驳回到起点 + static rejectToStartUserTask(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post( + API_CONTEXT + '/flow/flowOperation/rejectToStartUserTask', + params, + httpOptions, + ); + } + // 撤销 + static revokeHistoricTask(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/flow/flowOperation/revokeHistoricTask', params, httpOptions); + } + // 抄送消息列表 + static listCopyMessage(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/flow/flowMessage/listCopyMessage', + params, + httpOptions, + ); + } + // 消息个数 + static getMessageCount(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/flow/flowMessage/getMessageCount', + params, + httpOptions, + ); + } + // 在线表单流程抄送消息数据 + static viewOnlineCopyBusinessData(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/flow/flowOnlineOperation/viewCopyBusinessData', + params, + httpOptions, + ); + } + // 静态表单流程抄送消息数据 + static viewCopyBusinessData(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/flow/flowOperation/viewCopyBusinessData', + params, + httpOptions, + ); + } + // 获取指定任务处理人列表 + static viewTaskUserInfo(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/flow/flowOperation/viewTaskUserInfo', + params, + httpOptions, + ); + } + // 获取驳回历史任务列表 + static listRejectCandidateUserTask(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get>( + API_CONTEXT + '/flow/flowOperation/listRejectCandidateUserTask', + params, + httpOptions, + ); + } + // 获取多实例任务中会签人员列表 + static listMultiSignAssignees(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get>( + API_CONTEXT + '/flow/flowOperation/listMultiSignAssignees', + params, + httpOptions, + ); + } + // 获取所有任务列表 + static listAllUserTask(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/flow/flowOperation/listAllUserTask', + params, + httpOptions, + ); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/flow/index.ts b/OrangeFormsOpen-VUE3/src/api/flow/index.ts new file mode 100644 index 00000000..632dfd35 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/flow/index.ts @@ -0,0 +1,11 @@ +import FlowOperationController from './FlowOperationController'; +import FlowDictionaryController from './FlowDictionaryController'; +import FlowEntryController from './FlowEntryController'; +import FlowEntryVariableController from './FlowEntryVariableController'; + +export { + FlowOperationController, + FlowEntryController, + FlowDictionaryController, + FlowEntryVariableController, +}; diff --git a/OrangeFormsOpen-VUE3/src/api/online/OnlineColumnController.ts b/OrangeFormsOpen-VUE3/src/api/online/OnlineColumnController.ts new file mode 100644 index 00000000..6117e809 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/online/OnlineColumnController.ts @@ -0,0 +1,84 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { TableData } from '@/common/types/table'; +import { ColumnInfo } from '@/types/online/column'; +import { API_CONTEXT } from '../config'; + +export default class OnlineColumnController extends BaseController { + static list(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/online/onlineColumn/list', + params, + httpOptions, + ); + } + + static view(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/online/onlineColumn/view', params, httpOptions); + } + + // static export(sender, params, fileName) { + // return sender.download(API_CONTEXT + '/online/onlineColumn/export', params, fileName); + // } + + static add(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineColumn/add', params, httpOptions); + } + + static update(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineColumn/update', params, httpOptions); + } + + static refreshColumn(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineColumn/refresh', params, httpOptions); + } + + static delete(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineColumn/delete', params, httpOptions); + } + + static listOnlineColumnRule(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/online/onlineColumn/listOnlineColumnRule', + params, + httpOptions, + ); + } + + static listNotInOnlineColumnRule(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/online/onlineColumn/listNotInOnlineColumnRule', + params, + httpOptions, + ); + } + + static addOnlineColumnRule(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineColumn/addOnlineColumnRule', params, httpOptions); + } + + static deleteOnlineColumnRule(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post( + API_CONTEXT + '/online/onlineColumn/deleteOnlineColumnRule', + params, + httpOptions, + ); + } + + static updateOnlineColumnRule(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post( + API_CONTEXT + '/online/onlineColumn/updateOnlineColumnRule', + params, + httpOptions, + ); + } + + static viewOnlineColumnRule(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post( + API_CONTEXT + '/online/onlineColumn/viewOnlineColumnRule', + params, + httpOptions, + ); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/online/OnlineDatasourceController.ts b/OrangeFormsOpen-VUE3/src/api/online/OnlineDatasourceController.ts new file mode 100644 index 00000000..82b8b66c --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/online/OnlineDatasourceController.ts @@ -0,0 +1,35 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { TableData } from '@/common/types/table'; +import { API_CONTEXT } from '../config'; + +export default class OnlineDatasourceController extends BaseController { + static list(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/online/onlineDatasource/list', + params, + httpOptions, + ); + } + + static view(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/online/onlineDatasource/view', params, httpOptions); + } + + // static export(sender, params, fileName) { + // return sender.download(API_CONTEXT + '/online/onlineDatasource/export', params, fileName); + // } + + static add(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineDatasource/add', params, httpOptions); + } + + static update(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineDatasource/update', params, httpOptions); + } + + static delete(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineDatasource/delete', params, httpOptions); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/online/OnlineDatasourceRelationController.ts b/OrangeFormsOpen-VUE3/src/api/online/OnlineDatasourceRelationController.ts new file mode 100644 index 00000000..02ab3aa7 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/online/OnlineDatasourceRelationController.ts @@ -0,0 +1,39 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { TableData } from '@/common/types/table'; +import { API_CONTEXT } from '../config'; + +export default class OnlineDatasourceRelationController extends BaseController { + static list(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/online/onlineDatasourceRelation/list', + params, + httpOptions, + ); + } + + static view(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/online/onlineDatasourceRelation/view', + params, + httpOptions, + ); + } + + // static export(sender, params, fileName) { + // return sender.download(API_CONTEXT + '/online/onlineDatasourceRelation/export', params, fileName); + // } + + static add(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineDatasourceRelation/add', params, httpOptions); + } + + static update(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineDatasourceRelation/update', params, httpOptions); + } + + static delete(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineDatasourceRelation/delete', params, httpOptions); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/online/OnlineDblinkController.ts b/OrangeFormsOpen-VUE3/src/api/online/OnlineDblinkController.ts new file mode 100644 index 00000000..3178fb72 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/online/OnlineDblinkController.ts @@ -0,0 +1,53 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { TableData } from '@/common/types/table'; +import { DBLink } from '@/types/online/dblink'; +import { TableInfo } from '@/types/online/table'; +import { API_CONTEXT } from '../config'; + +export default class OnlineDblinkController extends BaseController { + static list(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/online/onlineDblink/list', + params, + httpOptions, + ); + } + + static listDblinkTables(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/online/onlineDblink/listDblinkTables', + params, + httpOptions, + ); + } + + static listDblinkTableColumns(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/online/onlineDblink/listDblinkTableColumns', + params, + httpOptions, + ); + } + + static view(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/online/onlineDblink/view', params, httpOptions); + } + + static add(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineDblink/add', params, httpOptions); + } + + static update(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineDblink/update', params, httpOptions); + } + + static delete(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineDblink/delete', params, httpOptions); + } + + static testConnection(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/online/onlineDblink/testConnection', params, httpOptions); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/online/OnlineDictController.ts b/OrangeFormsOpen-VUE3/src/api/online/OnlineDictController.ts new file mode 100644 index 00000000..997d48e5 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/online/OnlineDictController.ts @@ -0,0 +1,40 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { TableData } from '@/common/types/table'; +import { Dict } from '@/types/online/dict'; +import { API_CONTEXT } from '../config'; + +export default class OnlineDictController extends BaseController { + static list(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>(API_CONTEXT + '/online/onlineDict/list', params, httpOptions); + } + + static view(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/online/onlineDict/view', params, httpOptions); + } + + // static export(sender, params, fileName) { + // return sender.download(API_CONTEXT + '/online/onlineDict/export', params, fileName); + // } + + static add(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineDict/add', params, httpOptions); + } + + static update(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineDict/update', params, httpOptions); + } + + static delete(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineDict/delete', params, httpOptions); + } + + static listAllGlobalDict(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/online/onlineDict/listAllGlobalDict', + params, + httpOptions, + ); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/online/OnlineFormController.ts b/OrangeFormsOpen-VUE3/src/api/online/OnlineFormController.ts new file mode 100644 index 00000000..b4ac568d --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/online/OnlineFormController.ts @@ -0,0 +1,43 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { TableData } from '@/common/types/table'; +import { API_CONTEXT } from '../config'; + +export default class OnlineFormController extends BaseController { + static list(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/online/onlineForm/list', + params, + httpOptions, + ); + } + + static view(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/online/onlineForm/view', params, httpOptions); + } + + static render(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/online/onlineForm/render', params, httpOptions); + } + + // static export(sender, params, fileName) { + // return sender.download(API_CONTEXT + '/online/onlineForm/export', params, fileName); + // } + + static add(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineForm/add', params, httpOptions); + } + + static update(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineForm/update', params, httpOptions); + } + + static delete(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineForm/delete', params, httpOptions); + } + + static clone(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineForm/clone', params, httpOptions); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/online/OnlineOperationController.ts b/OrangeFormsOpen-VUE3/src/api/online/OnlineOperationController.ts new file mode 100644 index 00000000..d8937a5f --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/online/OnlineOperationController.ts @@ -0,0 +1,91 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { TableData } from '@/common/types/table'; +import { API_CONTEXT } from '../config'; + +export default class OnlineOperationController extends BaseController { + static listDict(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post( + API_CONTEXT + '/online/onlineOperation/listDict', + params, + httpOptions, + ); + } + + static listByDatasourceId(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/online/onlineOperation/listByDatasourceId', + params, + httpOptions, + ); + } + + static listByOneToManyRelationId(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/online/onlineOperation/listByOneToManyRelationId', + params, + httpOptions, + ); + } + + static addDatasource(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineOperation/addDatasource', params, httpOptions); + } + + static addOneToManyRelation(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post( + API_CONTEXT + '/online/onlineOperation/addOneToManyRelation', + params, + httpOptions, + ); + } + + static updateDatasource(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineOperation/updateDatasource', params, httpOptions); + } + + static updateOneToManyRelation(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post( + API_CONTEXT + '/online/onlineOperation/updateOneToManyRelation', + params, + httpOptions, + ); + } + + static viewByDatasourceId(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/online/onlineOperation/viewByDatasourceId', + params, + httpOptions, + ); + } + + static viewByOneToManyRelationId(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/online/onlineOperation/viewByOneToManyRelationId', + params, + httpOptions, + ); + } + + static deleteDatasource(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineOperation/deleteDatasource', params, httpOptions); + } + + static deleteOneToManyRelation(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post( + API_CONTEXT + '/online/onlineOperation/deleteOneToManyRelation', + params, + httpOptions, + ); + } + + static getColumnRuleCode(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/online/onlineOperation/getColumnRuleCode', params, httpOptions); + } + + static getPrintTemplate(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/report/reportPrint/listAll', params, httpOptions); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/online/OnlinePageController.ts b/OrangeFormsOpen-VUE3/src/api/online/OnlinePageController.ts new file mode 100644 index 00000000..623c1ff6 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/online/OnlinePageController.ts @@ -0,0 +1,100 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { TableData } from '@/common/types/table'; +import { FormPage } from '@/types/online/page'; +import { API_CONTEXT } from '../config'; + +export default class OnlinePageController extends BaseController { + static list(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/online/onlinePage/list', + params, + httpOptions, + ); + } + + static listAllPageAndForm(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post( + API_CONTEXT + '/online/onlinePage/listAllPageAndForm', + params, + httpOptions, + ); + } + + static view(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/online/onlinePage/view', params, httpOptions); + } + + // static export(sender, params, fileName) { + // return sender.download(API_CONTEXT + '/online/onlinePage/export', params, fileName); + // } + + static add(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlinePage/add', params, httpOptions); + } + + static update(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlinePage/update', params, httpOptions); + } + + static updatePublished(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlinePage/updatePublished', params, httpOptions); + } + + static delete(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlinePage/delete', params, httpOptions); + } + + static updateStatus(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlinePage/updateStatus', params, httpOptions); + } + + static listOnlinePageDatasource(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/online/onlinePage/listOnlinePageDatasource', + params, + httpOptions, + ); + } + + static listNotInOnlinePageDatasource(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post( + API_CONTEXT + '/online/onlinePage/listNotInOnlinePageDatasource', + params, + httpOptions, + ); + } + + static addOnlinePageDatasource(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post( + API_CONTEXT + '/online/onlinePage/addOnlinePageDatasource', + params, + httpOptions, + ); + } + + static deleteOnlinePageDatasource(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post( + API_CONTEXT + '/online/onlinePage/deleteOnlinePageDatasource', + params, + httpOptions, + ); + } + + static updateOnlinePageDatasource(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post( + API_CONTEXT + '/online/onlinePage/updateOnlinePageDatasource', + params, + httpOptions, + ); + } + + static viewOnlinePageDatasource(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/online/onlinePage/viewOnlinePageDatasource', + params, + httpOptions, + ); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/online/OnlineRuleController.ts b/OrangeFormsOpen-VUE3/src/api/online/OnlineRuleController.ts new file mode 100644 index 00000000..bd753b2e --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/online/OnlineRuleController.ts @@ -0,0 +1,35 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption } from '@/common/http/types'; +import { TableData } from '@/common/types/table'; +import { ANY_OBJECT } from '@/types/generic'; +import { API_CONTEXT } from '../config'; + +export default class OnlineRuleController extends BaseController { + static list(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/online/onlineRule/list', + params, + httpOptions, + ); + } + + static view(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/online/onlineRule/view', params, httpOptions); + } + + // static export(sender, params, fileName) { + // return sender.download(API_CONTEXT + '/online/onlineRule/export', params, fileName); + // } + + static add(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineRule/add', params, httpOptions); + } + + static update(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineRule/update', params, httpOptions); + } + + static delete(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineRule/delete', params, httpOptions); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/online/OnlineVirtualColumnController.ts b/OrangeFormsOpen-VUE3/src/api/online/OnlineVirtualColumnController.ts new file mode 100644 index 00000000..74ae18fd --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/online/OnlineVirtualColumnController.ts @@ -0,0 +1,35 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption } from '@/common/http/types'; +import { TableData } from '@/common/types/table'; +import { ANY_OBJECT } from '@/types/generic'; +import { API_CONTEXT } from '../config'; + +export default class OnlineVirtualColumnController extends BaseController { + static list(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/online/onlineVirtualColumn/list', + params, + httpOptions, + ); + } + + static view(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/online/onlineVirtualColumn/view', + params, + httpOptions, + ); + } + + static add(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineVirtualColumn/add', params, httpOptions); + } + + static update(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineVirtualColumn/update', params, httpOptions); + } + + static delete(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/online/onlineVirtualColumn/delete', params, httpOptions); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/online/index.ts b/OrangeFormsOpen-VUE3/src/api/online/index.ts new file mode 100644 index 00000000..1979f238 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/online/index.ts @@ -0,0 +1,23 @@ +import OnlineDblinkController from './OnlineDblinkController'; +import OnlineDictController from './OnlineDictController'; +import OnlinePageController from './OnlinePageController'; +import OnlineDatasourceRelationController from './OnlineDatasourceRelationController'; +import OnlineDatasourceController from './OnlineDatasourceController'; +import OnlineColumnController from './OnlineColumnController'; +import OnlineRuleController from './OnlineRuleController'; +import OnlineVirtualColumnController from './OnlineVirtualColumnController'; +import OnlineOperationController from './OnlineOperationController'; +import OnlineFormController from './OnlineFormController'; + +export { + OnlineDblinkController, + OnlineDictController, + OnlinePageController, + OnlineDatasourceRelationController, + OnlineDatasourceController, + OnlineColumnController, + OnlineRuleController, + OnlineVirtualColumnController, + OnlineOperationController, + OnlineFormController, +}; diff --git a/OrangeFormsOpen-VUE3/src/api/system/DictionaryController.ts b/OrangeFormsOpen-VUE3/src/api/system/DictionaryController.ts new file mode 100644 index 00000000..9477a3ce --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/system/DictionaryController.ts @@ -0,0 +1,217 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption } from '@/common/http/types'; +import { DictData, DictionaryBase } from '@/common/staticDict/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { API_CONTEXT } from '../config'; + +export default class DictionaryController extends BaseController { + static dictSysRole(params: ANY_OBJECT, httpOptions?: RequestOption) { + return new Promise((resolve, reject) => { + this.get(API_CONTEXT + '/upms/sysRole/listDict', params, httpOptions) + .then(res => { + const dictData = new DictionaryBase('角色字典', res.data); + resolve(dictData); + }) + .catch(err => { + reject(err); + }); + }); + } + // 全局编码字典 + static dictGlobalDict(params: ANY_OBJECT, httpOptions?: RequestOption) { + return new Promise((resolve, reject) => { + this.get(API_CONTEXT + '/upms/globalDict/listDict', params, httpOptions) + .then(res => { + const dictData = new DictionaryBase( + '编码字典', + (res.data || []).map(item => { + return { + ...item, + // 设置已禁用编码字典数据项 + disabled: item.status === 1, + }; + }), + ); + resolve(dictData); + }) + .catch(err => { + reject(err); + }); + }); + } + + static dictGlobalDictByIds(params: ANY_OBJECT, httpOptions?: RequestOption) { + return new Promise((resolve, reject) => { + this.get(API_CONTEXT + '/upms/globalDict/listDictByIds', params, httpOptions) + .then(res => { + const dictData = new DictionaryBase('编码字典', res.data); + resolve(dictData); + }) + .catch(err => { + reject(err); + }); + }); + } + + static dictSysDept(params: ANY_OBJECT, httpOptions?: RequestOption) { + return new Promise((resolve, reject) => { + this.get(API_CONTEXT + '/upms/sysDept/listDict', params, httpOptions) + .then(res => { + const dictData = new DictionaryBase('部门字典', res.data); + resolve(dictData); + }) + .catch(err => { + reject(err); + }); + }); + } + + static dictSysDeptByParentId( + params: ANY_OBJECT, + httpOptions?: RequestOption, + ): Promise { + return new Promise((resolve, reject) => { + this.get(API_CONTEXT + '/upms/sysDept/listDictByParentId', params, httpOptions) + .then(res => { + const dictData = new DictionaryBase('部门字典', res.data); + resolve(dictData); + }) + .catch(err => { + reject(err); + }); + }); + } + + static dictSysMenu(params: ANY_OBJECT, httpOptions?: RequestOption): Promise { + return new Promise((resolve, reject) => { + this.get(API_CONTEXT + '/upms/sysMenu/listMenuDict', params, httpOptions) + .then(res => { + const dictData = new DictionaryBase('菜单字典', res.data); + resolve(dictData); + }) + .catch(err => { + reject(err); + }); + }); + } + + static dictDeptPost(params: ANY_OBJECT, httpOptions?: RequestOption): Promise { + return new Promise((resolve, reject) => { + this.get( + API_CONTEXT + '/upms/sysDept/listSysDeptPostWithRelation', + params, + httpOptions, + ) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + static dictSysPost(params: ANY_OBJECT, httpOptions?: RequestOption) { + return new Promise((resolve, reject) => { + this.get(API_CONTEXT + '/upms/sysPost/listDict', params, httpOptions) + .then(res => { + const dictData = new DictionaryBase('岗位字典', res.data); + resolve(dictData); + }) + .catch(err => { + reject(err); + }); + }); + } + + static dictReportDblink(params: ANY_OBJECT, httpOptions?: RequestOption) { + return new Promise((resolve, reject) => { + this.get(API_CONTEXT + '/report/reportDblink/listDict', params, httpOptions) + .then(res => { + const dictData = new DictionaryBase('数据库链接', res.data); + resolve(dictData); + }) + .catch(err => { + reject(err); + }); + }); + } + + static dictReportDict(params: ANY_OBJECT, httpOptions?: RequestOption) { + return new Promise((resolve, reject) => { + this.get(API_CONTEXT + '/report/reportDict/listDict', params, httpOptions) + .then(res => { + const dictData = new DictionaryBase('报表字典', res.data); + resolve(dictData); + }) + .catch(err => { + reject(err); + }); + }); + } + static dictAreaCode(params: ANY_OBJECT, httpOptions?: RequestOption) { + return new Promise((resolve, reject) => { + this.get(API_CONTEXT + '/app/areaCode/listDict', params, httpOptions) + .then(res => { + const dictData = new DictionaryBase('行政区划', res.data); + resolve(dictData); + }) + .catch(err => { + reject(err); + }); + }); + } + + static dictAreaCodeByParentId(params: ANY_OBJECT, httpOptions?: RequestOption) { + return new Promise((resolve, reject) => { + this.get(API_CONTEXT + '/app/areaCode/listDictByParentId', params, httpOptions) + .then(res => { + const dictData = new DictionaryBase('行政区划', res.data); + resolve(dictData); + }) + .catch(err => { + reject(err); + }); + }); + } + + // 业务相关的接口 + static dictKnowledge(params: ANY_OBJECT, httpOptions?: RequestOption) { + return new Promise((resolve, reject) => { + this.get('/admin/app/knowledge/listDict', params, httpOptions) + .then(res => { + const dictData = new DictionaryBase('知识点字典', res.data); + resolve(dictData); + }) + .catch(err => { + reject(err); + }); + }); + } + + static dictStudent(params: ANY_OBJECT, httpOptions?: RequestOption) { + return new Promise((resolve, reject) => { + this.get(API_CONTEXT + '/app/student/listDict', params, httpOptions) + .then(res => { + const dictData = new DictionaryBase('学生字典', res.data); + dictData.setList(res.data); + resolve(dictData); + }) + .catch(err => { + reject(err); + }); + }); + } + + static dictTeacher(params: ANY_OBJECT, httpOptions?: RequestOption) { + return new Promise((resolve, reject) => { + this.get('/admin/app/teacher/listDict', params, httpOptions) + .then(res => { + const dictData = new DictionaryBase('老师字典', res.data); + resolve(dictData); + }) + .catch(err => { + reject(err); + }); + }); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/system/LoginController.ts b/OrangeFormsOpen-VUE3/src/api/system/LoginController.ts new file mode 100644 index 00000000..80c44ee3 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/system/LoginController.ts @@ -0,0 +1,14 @@ +import { loginParam, LoginUserInfo } from '@/types/upms/login'; +import { UserInfo } from '@/types/upms/user'; +import { BaseController } from '@/api/BaseController'; +import { API_CONTEXT } from '../config'; + +export default class LoginController extends BaseController { + static login(params: loginParam) { + return this.post(API_CONTEXT + '/upms/login/doLogin', params); + } + + static logout() { + return this.post(API_CONTEXT + '/upms/login/doLogout', {}); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/system/LoginUserController.ts b/OrangeFormsOpen-VUE3/src/api/system/LoginUserController.ts new file mode 100644 index 00000000..c6176108 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/system/LoginUserController.ts @@ -0,0 +1,21 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { OnlineUser } from '@/types/upms/user'; +import { TableData } from '@/common/types/table'; +import { API_CONTEXT } from '../config'; + +export default class LoginUserController extends BaseController { + // 在线用户查询 + static listSysLoginUser(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/upms/loginUser/list', + params, + httpOptions, + ); + } + // 强退 + static deleteSysLoginUser(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/loginUser/delete', params, httpOptions); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/system/MenuController.ts b/OrangeFormsOpen-VUE3/src/api/system/MenuController.ts new file mode 100644 index 00000000..cb9ddb2f --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/system/MenuController.ts @@ -0,0 +1,47 @@ +import { MenuItem } from '@/types/upms/menu'; +import { BaseController } from '@/api/BaseController'; +import { RequestOption } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { API_CONTEXT } from '../config'; + +export default class SystemMenuController extends BaseController { + static getMenuPermList(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysMenu/list', params, httpOptions); + } + + static addMenu(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysMenu/add', params, httpOptions); + } + + static updateMenu(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysMenu/update', params, httpOptions); + } + + static deleteMenu(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysMenu/delete', params, httpOptions); + } + + static viewMenu(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/upms/sysMenu/view', params, httpOptions); + } + + static listMenuPermCode(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/upms/sysMenu/listMenuPerm', params, httpOptions); + } + + static listSysPermByMenuIdWithDetail(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/upms/sysMenu/listSysPermWithDetail', + params, + httpOptions, + ); + } + + static listSysUserByMenuIdWithDetail(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/upms/sysMenu/listSysUserWithDetail', + params, + httpOptions, + ); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/system/MobileEntryController.ts b/OrangeFormsOpen-VUE3/src/api/system/MobileEntryController.ts new file mode 100644 index 00000000..5066bac2 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/system/MobileEntryController.ts @@ -0,0 +1,42 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption, TableData } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { API_CONTEXT } from '../config'; + +export default class MobileEntryController extends BaseController { + static list(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/mobile/mobileEntry/list', + params, + httpOptions, + ); + } + + static view(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/mobile/mobileEntry/view', params, httpOptions); + } + + // static export(sender, params, fileName) { + // return sender.download(API_CONTEXT + '/mobile/mobileEntry/export', params, fileName); + // } + + static add(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/mobile/mobileEntry/add', params, httpOptions); + } + + static update(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/mobile/mobileEntry/update', params, httpOptions); + } + + static delete(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/mobile/mobileEntry/delete', params, httpOptions); + } + + static uploadImage(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/mobile/mobileEntry/uploadImage', params, httpOptions); + } + + static downloadImage(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/mobile/mobileEntry/downloadImage', params, httpOptions); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/system/OperationLogController.ts b/OrangeFormsOpen-VUE3/src/api/system/OperationLogController.ts new file mode 100644 index 00000000..d63f12ed --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/system/OperationLogController.ts @@ -0,0 +1,15 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption } from '@/common/http/types'; +import { TableData } from '@/common/types/table'; +import { ANY_OBJECT } from '@/types/generic'; +import { API_CONTEXT } from '../config'; + +export default class OperationLogController extends BaseController { + static listSysOperationLog(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/upms/sysOperationLog/list', + params, + httpOptions, + ); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/system/PermCodeController.ts b/OrangeFormsOpen-VUE3/src/api/system/PermCodeController.ts new file mode 100644 index 00000000..50cbe25a --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/system/PermCodeController.ts @@ -0,0 +1,13 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption, TableData } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { PermCode } from '@/types/upms/permcode'; +import { Role } from '@/types/upms/role'; +import { User } from '@/types/upms/user'; +import { API_CONTEXT } from '../config'; + +export default class PermCodeController extends BaseController { + static getPermCodeList(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/upms/login/getAllPermCodes', params, httpOptions); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/system/PermController.ts b/OrangeFormsOpen-VUE3/src/api/system/PermController.ts new file mode 100644 index 00000000..54afc0fc --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/system/PermController.ts @@ -0,0 +1,86 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption, TableData } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { MenuItem } from '@/types/upms/menu'; +import { Perm, PermModule } from '@/types/upms/perm'; +import { Role } from '@/types/upms/role'; +import { User } from '@/types/upms/user'; +import { API_CONTEXT } from '../config'; + +export default class PermController extends BaseController { + static getPermList(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>(API_CONTEXT + '/upms/sysPerm/list', params, httpOptions); + } + + static viewPerm(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/upms/sysPerm/view', params, httpOptions); + } + + static addPerm(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysPerm/add', params, httpOptions); + } + + static updatePerm(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysPerm/update', params, httpOptions); + } + + static deletePerm(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysPerm/delete', params, httpOptions); + } + + static getAllPermList(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post( + API_CONTEXT + '/upms/sysPermModule/listAll', + params, + httpOptions, + ); + } + + static getPermGroupList(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysPermModule/list', params, httpOptions); + } + + static addPermGroup(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysPermModule/add', params, httpOptions); + } + + static updatePermGroup(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysPermModule/update', params, httpOptions); + } + + static deletePermGroup(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysPermModule/delete', params, httpOptions); + } + + static listSysUserByPermIdWithDetail(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/upms/sysPerm/listSysUserWithDetail', + params, + httpOptions, + ); + } + + static listSysRoleByPermIdWithDetail(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/upms/sysPerm/listSysRoleWithDetail', + params, + httpOptions, + ); + } + + static listSysMenuByPermIdWithDetail(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get( + API_CONTEXT + '/upms/sysPerm/listSysMenuWithDetail', + params, + httpOptions, + ); + } + + static listSysPermByRoleIdWithDetail(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get>( + API_CONTEXT + '/upms/sysRole/listSysPermWithDetail', + params, + httpOptions, + ); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/system/SysCommonBizController.ts b/OrangeFormsOpen-VUE3/src/api/system/SysCommonBizController.ts new file mode 100644 index 00000000..592ac936 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/system/SysCommonBizController.ts @@ -0,0 +1,18 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { TableData } from '@/common/types/table'; +import { API_CONTEXT } from '../config'; + +export default class SysCommonBizController extends BaseController { + static list(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/commonext/bizwidget/list', + params, + httpOptions, + ); + } + static viewByIds(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/commonext/bizwidget/view', params, httpOptions); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/system/SysDataPermController.ts b/OrangeFormsOpen-VUE3/src/api/system/SysDataPermController.ts new file mode 100644 index 00000000..d0dc1d74 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/system/SysDataPermController.ts @@ -0,0 +1,80 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption, TableData } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { PermData } from '@/types/upms/permdata'; +import { User } from '@/types/upms/user'; +import { API_CONTEXT } from '../config'; + +export default class SysDataPermController extends BaseController { + /** + * @param params {dataPermId, dataPermName, deptIdListString} + */ + static add(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysDataPerm/add', params, httpOptions); + } + + /** + * @param params {dataPermId, dataPermName, deptIdListString} + */ + static update(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysDataPerm/update', params, httpOptions); + } + + /** + * @param params {dataPermId} + */ + static delete(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysDataPerm/delete', params, httpOptions); + } + + /** + * @param params {dataPermName} + */ + static list(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/upms/sysDataPerm/list', + params, + httpOptions, + ); + } + + /** + * @param params {dataPermId} + */ + static view(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/upms/sysDataPerm/view', params, httpOptions); + } + + /** + * @param params {dataPermId, searchString} + */ + static listDataPermUser(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/upms/sysDataPerm/listDataPermUser', + params, + httpOptions, + ); + } + + /** + * @param params {dataPermId, userIdListString} + */ + static addDataPermUser(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysDataPerm/addDataPermUser', params, httpOptions); + } + + /** + * @param params {dataPermId, userId} + */ + static deleteDataPermUser(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysDataPerm/deleteDataPermUser', params, httpOptions); + } + + static listNotInDataPermUser(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/upms/sysDataPerm/listNotInDataPermUser', + params, + httpOptions, + ); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/system/SysDeptController.ts b/OrangeFormsOpen-VUE3/src/api/system/SysDeptController.ts new file mode 100644 index 00000000..5c303c40 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/system/SysDeptController.ts @@ -0,0 +1,63 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption, TableData } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { SysDept, SysDeptPost } from '@/types/upms/department'; +import { API_CONTEXT } from '../config'; + +export default class SysDeptController extends BaseController { + static list(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>(API_CONTEXT + '/upms/sysDept/list', params, httpOptions); + } + + static view(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/upms/sysDept/view', params, httpOptions); + } + + static export(params: ANY_OBJECT, fileName: string) { + return this.download(API_CONTEXT + '/upms/sysDept/export', params, fileName); + } + + static add(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysDept/add', params, httpOptions); + } + + static update(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysDept/update', params, httpOptions); + } + + static delete(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysDept/delete', params, httpOptions); + } + + static listNotInSysDeptPost(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/upms/sysDept/listNotInSysDeptPost', + params, + httpOptions, + ); + } + + static listSysDeptPost(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/upms/sysDept/listSysDeptPost', + params, + httpOptions, + ); + } + + static addSysDeptPost(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysDept/addSysDeptPost', params, httpOptions); + } + + static updateSysDeptPost(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysDept/updateSysDeptPost', params, httpOptions); + } + + static deleteSysDeptPost(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysDept/deleteSysDeptPost', params, httpOptions); + } + + static viewSysDeptPost(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/upms/sysDept/viewSysDeptPost', params, httpOptions); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/system/SysGlobalDictController.ts b/OrangeFormsOpen-VUE3/src/api/system/SysGlobalDictController.ts new file mode 100644 index 00000000..0b5800e9 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/system/SysGlobalDictController.ts @@ -0,0 +1,53 @@ +import { post, get } from '@/common/http/request'; +import { RequestOption, TableData } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { DictCode, DictCodeItem } from '@/types/upms/dict'; +import { API_CONTEXT } from '../config'; + +type listAllItemType = { + cachedResultList: DictCodeItem[]; + fullResultList: DictCodeItem[]; +}; + +export default class SysGlobalDictController { + static list(params: ANY_OBJECT, httpOptions?: RequestOption) { + return post>(API_CONTEXT + '/upms/globalDict/list', params, httpOptions); + } + + static listAll(params: ANY_OBJECT, httpOptions?: RequestOption) { + console.log(this); + return get(API_CONTEXT + '/upms/globalDict/listAll', params, httpOptions); + } + + static add(params: ANY_OBJECT, httpOptions?: RequestOption) { + return post(API_CONTEXT + '/upms/globalDict/add', params, httpOptions); + } + + static update(params: ANY_OBJECT, httpOptions?: RequestOption) { + return post(API_CONTEXT + '/upms/globalDict/update', params, httpOptions); + } + + static delete(params: ANY_OBJECT, httpOptions?: RequestOption) { + return post(API_CONTEXT + '/upms/globalDict/delete', params, httpOptions); + } + + static addItem(params: ANY_OBJECT, httpOptions?: RequestOption) { + return post(API_CONTEXT + '/upms/globalDict/addItem', params, httpOptions); + } + + static updateItem(params: ANY_OBJECT, httpOptions?: RequestOption) { + return post(API_CONTEXT + '/upms/globalDict/updateItem', params, httpOptions); + } + + static updateItemStatus(params: ANY_OBJECT, httpOptions?: RequestOption) { + return post(API_CONTEXT + '/upms/globalDict/updateItemStatus', params, httpOptions); + } + + static deleteItem(params: ANY_OBJECT, httpOptions?: RequestOption) { + return post(API_CONTEXT + '/upms/globalDict/deleteItem', params, httpOptions); + } + + static reloadCachedData(params: ANY_OBJECT, httpOptions?: RequestOption) { + return get(API_CONTEXT + '/upms/globalDict/reloadCachedData', params, httpOptions); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/system/SysPostController.ts b/OrangeFormsOpen-VUE3/src/api/system/SysPostController.ts new file mode 100644 index 00000000..1ccdb02a --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/system/SysPostController.ts @@ -0,0 +1,27 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption, TableData } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { Post } from '@/types/upms/post'; +import { API_CONTEXT } from '../config'; + +export default class SysPostController extends BaseController { + static list(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>(API_CONTEXT + '/upms/sysPost/list', params, httpOptions); + } + + static view(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/upms/sysPost/view', params, httpOptions); + } + + static add(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysPost/add', params, httpOptions); + } + + static update(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysPost/update', params, httpOptions); + } + + static delete(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysPost/delete', params, httpOptions); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/system/SystemRoleController.ts b/OrangeFormsOpen-VUE3/src/api/system/SystemRoleController.ts new file mode 100644 index 00000000..1fe72ba3 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/system/SystemRoleController.ts @@ -0,0 +1,61 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption, TableData } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { Role } from '@/types/upms/role'; +import { User } from '@/types/upms/user'; +import { API_CONTEXT } from '../config'; + +export default class SystemRoleController extends BaseController { + static getRoleList(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>(API_CONTEXT + '/upms/sysRole/list', params, httpOptions); + } + + static getRole(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/upms/sysRole/view', params, httpOptions); + } + + static deleteRole(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysRole/delete', params, httpOptions); + } + + static addRole(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysRole/add', params, httpOptions); + } + + static updateRole(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysRole/update', params, httpOptions); + } + + /** + * @param params {roleId, searchString} + */ + static listRoleUser(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/upms/sysRole/listUserRole', + params, + httpOptions, + ); + } + + static listNotInUserRole(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>( + API_CONTEXT + '/upms/sysRole/listNotInUserRole', + params, + httpOptions, + ); + } + + /** + * @param params {roleId, userIdListString} + */ + static addRoleUser(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysRole/addUserRole', params, httpOptions); + } + + /** + * @param params {roleId, userId} + */ + static deleteRoleUser(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysRole/deleteUserRole', params, httpOptions); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/system/UserController.ts b/OrangeFormsOpen-VUE3/src/api/system/UserController.ts new file mode 100644 index 00000000..12f06ccd --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/system/UserController.ts @@ -0,0 +1,62 @@ +import { BaseController } from '@/api/BaseController'; +import { RequestOption, TableData } from '@/common/http/types'; +import { ANY_OBJECT } from '@/types/generic'; +import { MenuItem } from '@/types/upms/menu'; +import { Perm } from '@/types/upms/perm'; +import { PermCode } from '@/types/upms/permcode'; +import { User, UserInfo } from '@/types/upms/user'; +import { API_CONTEXT } from '../config'; + +export default class SystemUserController extends BaseController { + static getUserList(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post>(API_CONTEXT + '/upms/sysUser/list', params, httpOptions); + } + + static addUser(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysUser/add', params, httpOptions); + } + + static updateUser(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysUser/update', params, httpOptions); + } + + static deleteUser(params: User, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysUser/delete', params, httpOptions); + } + + static viewMenu(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysMenu/view', params, httpOptions); + } + + static getUser(params: User, httpOptions?: RequestOption) { + return this.get(API_CONTEXT + '/upms/sysUser/view', params, httpOptions); + } + + static resetUserPassword(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.post(API_CONTEXT + '/upms/sysUser/resetPassword', params, httpOptions); + } + + static listSysPermWithDetail(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get>( + API_CONTEXT + '/upms/sysUser/listSysPermWithDetail', + params, + httpOptions, + ); + } + + static listSysPermCodeWithDetail(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get>( + API_CONTEXT + '/upms/sysUser/listSysPermCodeWithDetail', + params, + httpOptions, + ); + } + + static listSysMenuWithDetail(params: ANY_OBJECT, httpOptions?: RequestOption) { + return this.get>( + API_CONTEXT + '/upms/sysUser/listSysMenuWithDetail', + params, + httpOptions, + ); + } +} diff --git a/OrangeFormsOpen-VUE3/src/api/system/index.ts b/OrangeFormsOpen-VUE3/src/api/system/index.ts new file mode 100644 index 00000000..586dcbc3 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/api/system/index.ts @@ -0,0 +1,31 @@ +import DictionaryController from './DictionaryController'; +import LoginUserController from './LoginUserController'; +import SystemMenuController from './MenuController'; +import PermController from './PermController'; +import PermCodeController from './PermCodeController'; +import SysDataPermController from './SysDataPermController'; +import SysDeptController from './SysDeptController'; +import SystemRoleController from './SystemRoleController'; +import SystemUserController from './UserController'; +import SysPostController from './SysPostController'; +import MobileEntryController from './MobileEntryController'; +import SysGlobalDictController from './SysGlobalDictController'; +import OperationLogController from './OperationLogController'; +import SysCommonBizController from './SysCommonBizController'; + +export { + SystemMenuController, + PermController, + PermCodeController, + SystemUserController, + DictionaryController, + SysDeptController, + SysDataPermController, + SystemRoleController, + LoginUserController, + SysPostController, + MobileEntryController, + SysGlobalDictController, + OperationLogController, + SysCommonBizController, +}; diff --git a/OrangeFormsOpen-VUE3/src/assets/img/add.png b/OrangeFormsOpen-VUE3/src/assets/img/add.png new file mode 100644 index 00000000..42e1f361 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/add.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/advance-add-active.png b/OrangeFormsOpen-VUE3/src/assets/img/advance-add-active.png new file mode 100644 index 00000000..cd033825 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/advance-add-active.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/advance-add.png b/OrangeFormsOpen-VUE3/src/assets/img/advance-add.png new file mode 100644 index 00000000..bb7d5fc1 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/advance-add.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/advance-del-active.png b/OrangeFormsOpen-VUE3/src/assets/img/advance-del-active.png new file mode 100644 index 00000000..3a98209c Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/advance-del-active.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/advance-del.png b/OrangeFormsOpen-VUE3/src/assets/img/advance-del.png new file mode 100644 index 00000000..8c8dc485 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/advance-del.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/advance-edit-active.png b/OrangeFormsOpen-VUE3/src/assets/img/advance-edit-active.png new file mode 100644 index 00000000..911929ea Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/advance-edit-active.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/advance-edit.png b/OrangeFormsOpen-VUE3/src/assets/img/advance-edit.png new file mode 100644 index 00000000..6de05dc8 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/advance-edit.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/back.png b/OrangeFormsOpen-VUE3/src/assets/img/back.png new file mode 100644 index 00000000..9e60639e Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/back.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/back2.png b/OrangeFormsOpen-VUE3/src/assets/img/back2.png new file mode 100644 index 00000000..cca83a32 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/back2.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/collapse.png b/OrangeFormsOpen-VUE3/src/assets/img/collapse.png new file mode 100644 index 00000000..ce4aeaf9 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/collapse.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/datasource-active.png b/OrangeFormsOpen-VUE3/src/assets/img/datasource-active.png new file mode 100644 index 00000000..b8b1afd9 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/datasource-active.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/datasource.png b/OrangeFormsOpen-VUE3/src/assets/img/datasource.png new file mode 100644 index 00000000..37f99e71 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/datasource.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/default-header.jpg b/OrangeFormsOpen-VUE3/src/assets/img/default-header.jpg new file mode 100644 index 00000000..222d18da Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/default-header.jpg differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/default.jpg b/OrangeFormsOpen-VUE3/src/assets/img/default.jpg new file mode 100644 index 00000000..aa0237bb Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/default.jpg differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/demo-h5-qrcode.png b/OrangeFormsOpen-VUE3/src/assets/img/demo-h5-qrcode.png new file mode 100644 index 00000000..b47443b7 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/demo-h5-qrcode.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/density.png b/OrangeFormsOpen-VUE3/src/assets/img/density.png new file mode 100644 index 00000000..c2c4ff56 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/density.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/document-active.png b/OrangeFormsOpen-VUE3/src/assets/img/document-active.png new file mode 100644 index 00000000..032ffc11 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/document-active.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/document.png b/OrangeFormsOpen-VUE3/src/assets/img/document.png new file mode 100644 index 00000000..a804b661 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/document.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/down.png b/OrangeFormsOpen-VUE3/src/assets/img/down.png new file mode 100644 index 00000000..ea1633eb Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/down.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/empty.png b/OrangeFormsOpen-VUE3/src/assets/img/empty.png new file mode 100644 index 00000000..2ccc001b Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/empty.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/eye_close.png b/OrangeFormsOpen-VUE3/src/assets/img/eye_close.png new file mode 100644 index 00000000..f44bbf2c Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/eye_close.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/eye_open.png b/OrangeFormsOpen-VUE3/src/assets/img/eye_open.png new file mode 100644 index 00000000..a7027a62 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/eye_open.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/filter.png b/OrangeFormsOpen-VUE3/src/assets/img/filter.png new file mode 100644 index 00000000..2a8f0b93 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/filter.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/import.png b/OrangeFormsOpen-VUE3/src/assets/img/import.png new file mode 100644 index 00000000..dfe69967 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/import.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/login.png b/OrangeFormsOpen-VUE3/src/assets/img/login.png new file mode 100644 index 00000000..87130950 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/login.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/login_bg.jpg b/OrangeFormsOpen-VUE3/src/assets/img/login_bg.jpg new file mode 100644 index 00000000..efc558de Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/login_bg.jpg differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/login_bg.png b/OrangeFormsOpen-VUE3/src/assets/img/login_bg.png new file mode 100644 index 00000000..d6e2577f Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/login_bg.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/login_bg2.png b/OrangeFormsOpen-VUE3/src/assets/img/login_bg2.png new file mode 100644 index 00000000..2bde2ca8 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/login_bg2.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/login_icon.png b/OrangeFormsOpen-VUE3/src/assets/img/login_icon.png new file mode 100644 index 00000000..82668af8 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/login_icon.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/login_icon2.png b/OrangeFormsOpen-VUE3/src/assets/img/login_icon2.png new file mode 100644 index 00000000..3eece7f3 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/login_icon2.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/login_logo.png b/OrangeFormsOpen-VUE3/src/assets/img/login_logo.png new file mode 100644 index 00000000..42130c0b Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/login_logo.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/login_logo2.png b/OrangeFormsOpen-VUE3/src/assets/img/login_logo2.png new file mode 100644 index 00000000..b102924d Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/login_logo2.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/login_password.png b/OrangeFormsOpen-VUE3/src/assets/img/login_password.png new file mode 100644 index 00000000..7295fcbc Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/login_password.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/login_title.png b/OrangeFormsOpen-VUE3/src/assets/img/login_title.png new file mode 100644 index 00000000..3d666881 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/login_title.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/login_username.png b/OrangeFormsOpen-VUE3/src/assets/img/login_username.png new file mode 100644 index 00000000..6370d0e4 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/login_username.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/logo.jpg b/OrangeFormsOpen-VUE3/src/assets/img/logo.jpg new file mode 100644 index 00000000..a88fc0d0 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/logo.jpg differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/logo.png b/OrangeFormsOpen-VUE3/src/assets/img/logo.png new file mode 100644 index 00000000..f2df5bb8 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/logo.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/logo_white.png b/OrangeFormsOpen-VUE3/src/assets/img/logo_white.png new file mode 100644 index 00000000..a0377587 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/logo_white.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/more.png b/OrangeFormsOpen-VUE3/src/assets/img/more.png new file mode 100644 index 00000000..02855cc2 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/more.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/orange-group1.png b/OrangeFormsOpen-VUE3/src/assets/img/orange-group1.png new file mode 100644 index 00000000..efd59f26 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/orange-group1.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/orange-group2.png b/OrangeFormsOpen-VUE3/src/assets/img/orange-group2.png new file mode 100644 index 00000000..218e76ec Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/orange-group2.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/orange-group3.png b/OrangeFormsOpen-VUE3/src/assets/img/orange-group3.png new file mode 100644 index 00000000..b411a1b2 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/orange-group3.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/orange-group4.png b/OrangeFormsOpen-VUE3/src/assets/img/orange-group4.png new file mode 100644 index 00000000..3dc4b574 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/orange-group4.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/orange.png b/OrangeFormsOpen-VUE3/src/assets/img/orange.png new file mode 100644 index 00000000..ba94624e Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/orange.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/preview.png b/OrangeFormsOpen-VUE3/src/assets/img/preview.png new file mode 100644 index 00000000..371e0e73 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/preview.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/reduce.png b/OrangeFormsOpen-VUE3/src/assets/img/reduce.png new file mode 100644 index 00000000..05db73ed Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/reduce.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/refresh.png b/OrangeFormsOpen-VUE3/src/assets/img/refresh.png new file mode 100644 index 00000000..00d32a5c Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/refresh.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/refresh2.png b/OrangeFormsOpen-VUE3/src/assets/img/refresh2.png new file mode 100644 index 00000000..6ad4a63b Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/refresh2.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/remind.png b/OrangeFormsOpen-VUE3/src/assets/img/remind.png new file mode 100644 index 00000000..286f3dfc Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/remind.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/resume_icon_add.png b/OrangeFormsOpen-VUE3/src/assets/img/resume_icon_add.png new file mode 100644 index 00000000..9ebf2c92 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/resume_icon_add.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/right-icon.png b/OrangeFormsOpen-VUE3/src/assets/img/right-icon.png new file mode 100644 index 00000000..4454401d Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/right-icon.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/s-home.png b/OrangeFormsOpen-VUE3/src/assets/img/s-home.png new file mode 100644 index 00000000..8468cebf Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/s-home.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/setting.png b/OrangeFormsOpen-VUE3/src/assets/img/setting.png new file mode 100644 index 00000000..b196bef7 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/setting.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/sp1.png b/OrangeFormsOpen-VUE3/src/assets/img/sp1.png new file mode 100644 index 00000000..7e3320a8 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/sp1.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/spjd.png b/OrangeFormsOpen-VUE3/src/assets/img/spjd.png new file mode 100644 index 00000000..2c9fe121 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/spjd.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/spjd2.png b/OrangeFormsOpen-VUE3/src/assets/img/spjd2.png new file mode 100644 index 00000000..200b7deb Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/spjd2.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/tj.png b/OrangeFormsOpen-VUE3/src/assets/img/tj.png new file mode 100644 index 00000000..7a42a3f5 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/tj.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/tj2.png b/OrangeFormsOpen-VUE3/src/assets/img/tj2.png new file mode 100644 index 00000000..d92ea55b Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/tj2.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/vant.png b/OrangeFormsOpen-VUE3/src/assets/img/vant.png new file mode 100644 index 00000000..76b6cdb4 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/vant.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/wg.png b/OrangeFormsOpen-VUE3/src/assets/img/wg.png new file mode 100644 index 00000000..e828b78b Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/wg.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/img/wg2.png b/OrangeFormsOpen-VUE3/src/assets/img/wg2.png new file mode 100644 index 00000000..42947839 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/img/wg2.png differ diff --git a/OrangeFormsOpen-VUE3/src/assets/online-icon/iconfont.css b/OrangeFormsOpen-VUE3/src/assets/online-icon/iconfont.css new file mode 100644 index 00000000..41ee14fc --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/assets/online-icon/iconfont.css @@ -0,0 +1,331 @@ +@font-face { + font-family: "online-icon"; /* Project id 3701349 */ + src: url('iconfont.woff2?t=1706613476403') format('woff2'), + url('iconfont.woff?t=1706613476403') format('woff'), + url('iconfont.ttf?t=1706613476403') format('truetype'); +} + +.online-icon { + font-family: "online-icon" !important; + font-style: normal; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} +/* Tabs */ +.icon-tabs2:before { + content: "\e6c6"; +} +/* card */ +.icon-card3:before { + content: "\e6c7"; +} +/* 消息 */ +.icon-message:before { + content: "\e6c5"; +} +/* 刷新 */ +.icon-custom-refresh:before { + content: "\e6b3"; +} +/* 行高设置 */ +.icon-table-row-height:before { + content: "\e6bd"; +} +/* 展开 */ +.icon-expand:before { + content: "\e6b9"; +} +/* 收缩 */ +.icon-unexpand:before { + content: "\e6af"; +} +/* 表格容器 */ +.icon-table-container:before { + content: "\e6aa"; +} +/* 关联选择 */ +.icon-data-select:before { + content: "\e6ab"; +} + +/* 普通进度条 */ +.icon-progress:before { + content: "\e6a6"; +} +/* 环形进度条 */ +.icon-circle-progress:before { + content: "\e6a1"; +} +/* 进度条卡片 */ +.icon-progress-card:before { + content: "\e6a2"; +} +/* 通用列表 */ +.icon-common-list:before { + content: "\e6a3"; +} +/* 通用卡片 */ +.icon-common-card:before { + content: "\e6a5"; +} +/* 漏斗图 */ +.icon-funnel:before { + content: "\e69a"; +} +/* 报表表格 */ +.icon-dataview:before { + content: "\e69b"; +} +/* 雷达图 */ +.icon-radar:before { + content: "\e69c"; +} +/* 轮播图 */ +.icon-carousel:before { + content: "\e69d"; +}/* 报表富文本展示 */ +.icon-richtext:before { + content: "\e69e"; +} + +.icon-user:before { + content: "\e677"; +} + +.icon-card:before { + content: "\e678"; +} + +.icon-orange-icon:before { + content: "\e679"; +} + +/* 部门选择 */ +.icon-dept:before { + content: "\e668"; +} +/* 分隔线 */ +.icon-divider:before { + content: "\e66f"; +} +/* 文本显示框 */ +.icon-text:before { + content: "\e670"; +} +/* 表格 */ +.icon-table:before { + content: "\e671"; +} +/* 基础块 */ +.icon-block:before { + content: "\e672"; +} +/* 超链接 */ +.icon-link:before { + content: "\e673"; +} +/* 图片 */ +.icon-image:before { + content: "\e674"; +} +/* 上传组件 */ +.icon-upload:before { + content: "\e675"; +} +/* 富文本 */ +.icon-richeditor:before { + content: "\e676"; +} +/* 更多 */ +.icon-more:before { + content: "\e65f"; +} +/* 复选框 */ +.icon-checkbox:before { + content: "\e66c"; +} +/* 文字输入框 */ +.icon-input:before { + content: "\e66d"; +} +/* 数字输入框 */ +.icon-input-number:before { + content: "\e66e"; +} +/* 属性 */ +.icon-props:before { + content: "\e66b"; +} +/* 数据 */ +.icon-data:before { + content: "\e661"; +} +/* 单选框 */ +.icon-radio:before { + content: "\e64b"; +} +/* 关联 */ +.icon-relation:before { + content: "\e64c"; +} +/* 卡片 */ +.icon-card2:before { + content: "\e64d"; +} +/* PC */ +.icon-pc:before { + content: "\e64e"; +} +/* 复制 */ +.icon-copy:before { + content: "\e64f"; +} +/* 操作 */ +.icon-operator:before { + content: "\e650"; +} +/* 表单设计 */ +.icon-form-design:before { + content: "\e651"; +} +/* 基础信息 */ +.icon-basic-info:before { + content: "\e653"; +} + +.icon-shouqi-01:before { + content: "\e654"; +} +/* PAD */ +.icon-pad:before { + content: "\e655"; +} +/* 组件 */ +.icon-component:before { + content: "\e656"; +} +/* 日期范围选择 */ +.icon-date-range:before { + content: "\e657"; +} +/* close */ +.icon-close:before { + content: "\e658"; +} +/* 日期选择框 */ +.icon-date:before { + content: "\e659"; +} +/* 级联选择框 */ +.icon-cascader:before { + content: "\e65a"; +} +/* 筛选 */ +.icon-filter:before { + content: "\e65b"; +} +/* PHONE */ +.icon-phone:before { + content: "\e65c"; +} +/* 删除 */ +.icon-delete:before { + content: "\e65d"; +} +/* 脚本 */ +.icon-script:before { + content: "\e65e"; +} + +.icon-shujushi-01:before { + content: "\e660"; +} + +.icon-shujubiaodanshi-01:before { + content: "\e662"; +} + +.icon-zhongzhi-01:before { + content: "\e663"; +} + +.icon-sousuo-01:before { + content: "\e664"; +} +/* 下拉选择 */ +.icon-select:before { + content: "\e665"; +} +/* 数字范围选择 */ +.icon-number-range:before { + content: "\e666"; +} + +.icon-datasource:before { + content: "\e667"; +} +/* 开关组件 */ +.icon-switch:before { + content: "\e669"; +} + +.icon-xiala-01:before { + content: "\e66a"; +} + +/* 折线图 */ +.icon-linechart:before { + content: "\e68f"; +} + +.icon-scatterchart:before { + content: "\e690"; +} + +.icon-pivottable:before { + content: "\e691"; +} + +.icon-barchart:before { + content: "\e692"; +} + +.icon-piechart:before { + content: "\e68e"; +} + +.icon-tabs:before { + content: "\e67a"; +} + +.icon-align-top:before { + content: "\e695"; +} + +.icon-align-bottom:before { + content: "\e696"; +} + +.icon-align-middle:before { + content: "\e697"; +} + +.icon-align-center:before { + content: "\e68d"; +} + +.icon-align-left:before { + content: "\e693"; +} + +.icon-align-right:before { + content: "\e694"; +} + +.icon-flow-stauts:before { + content: "\e69f"; +} + +.icon-flow-design:before { + content: "\e6a0"; +} diff --git a/OrangeFormsOpen-VUE3/src/assets/online-icon/iconfont.ttf b/OrangeFormsOpen-VUE3/src/assets/online-icon/iconfont.ttf new file mode 100644 index 00000000..3a2006a8 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/online-icon/iconfont.ttf differ diff --git a/OrangeFormsOpen-VUE3/src/assets/online-icon/iconfont.woff b/OrangeFormsOpen-VUE3/src/assets/online-icon/iconfont.woff new file mode 100644 index 00000000..18a27fb0 Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/online-icon/iconfont.woff differ diff --git a/OrangeFormsOpen-VUE3/src/assets/online-icon/iconfont.woff2 b/OrangeFormsOpen-VUE3/src/assets/online-icon/iconfont.woff2 new file mode 100644 index 00000000..1162f39a Binary files /dev/null and b/OrangeFormsOpen-VUE3/src/assets/online-icon/iconfont.woff2 differ diff --git a/OrangeFormsOpen-VUE3/src/assets/skin/orange/index.scss b/OrangeFormsOpen-VUE3/src/assets/skin/orange/index.scss new file mode 100644 index 00000000..39d462f4 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/assets/skin/orange/index.scss @@ -0,0 +1,87 @@ +@use 'sass:map'; + +$color-primary: #f70; +$color-white: #fff; +$color-primary-light-9: color-mix(in srgb, $color-white 90%, $color-primary 10%) !default; +$color-text-secondary: #909399 !default; +@forward 'element-plus/theme-chalk/src/common/var.scss' with ( + // do not use same name, it will override. + $colors: ( + 'primary': ( + 'base': $color-primary, + ), + ), + $common-component-size: ( + 'large': 36px, + 'default': 32px, + 'small': 32px, + ), + $tag: ( + 'font-size': 14px, + ), + $tag-height: ( + 'large': 28px, + 'default': 28px, + ), + $radio-bordered-input-height: ( + 'large': 14px, + 'default': 14px, + 'small': 14px, + ), + $radio-bordered-input-width: ( + 'large': 14px, + 'default': 14px, + 'small': 14px, + ), + $button-padding-vertical: ( + 'large': 11px, + 'default': 9px, + 'small': 6px, + ), + $button-padding-horizontal: ( + 'large': 18px, + 'default': 16px, + 'small': 12px, + ) +); + +$form-item-margin-bottom: () !default; +$form-item-margin-bottom: map.merge( + ( + 'large': 18px, + 'default': 18px, + 'small': 18px, + ), + $form-item-margin-bottom +); + +$form-item-line-height: () !default; +$form-item-line-height: map.merge( + ( + 'large': 36px, + 'default': 32px, + 'small': 24px, + ), + $form-item-line-height +); +$radio-font-size: () !default; +$radio-font-size: map.merge( + ( + 'large': 14px, + 'small': 14px, + ), + $radio-font-size +); +@use '@/assets/style/base.scss'; + +// 覆盖原样式,否则它会遮盖弹出对话框 +:deep(.vxe-table--empty-placeholder) { + z-index: 0; +} +// messagebox会被layer遮盖,因为下面这个样式对应的元素没有设置z-index,尽管其父元素设置了 +.el-overlay-message-box { + z-index: 2000; +} +.rich-input .el-form-item__content { + z-index: 1; +} diff --git a/OrangeFormsOpen-VUE3/src/assets/style/base.scss b/OrangeFormsOpen-VUE3/src/assets/style/base.scss new file mode 100644 index 00000000..d3b28b73 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/assets/style/base.scss @@ -0,0 +1,1110 @@ +// @import url('element-variables'); +// @import url('transition'); + +html, body { + padding: 0; + margin: 0; + font-size: 14px; + font-family: Arial,'Helvetica Neue',Helvetica,'PingFang SC','Hiragino Sans GB','Microsoft YaHei','微软雅黑',sans-serif; + background-color: rgb(228 240 255); + //background-color: white; +} + +*, +*::before, +*::after { + box-sizing: border-box; +} + +$header-height: 60px; + +/** 过滤组件长度 */ +$filter-item-width: 250px; + +/** 范围选择过滤组件长度 */ +$filter-item-range-width: 400px; + +/** 左侧过滤树组件每一项高度 */ +$tree-node-height: 40px; + +/** 高级管理表单标题高度 */ +$advanced-title-height: 50px; +$border-color: rgb(216 220 229); +$menuHover: rgb(255 255 255 / 30%); +$menu-background-color: transparent; +$tabs-header-margin-bottom: 25px; +$tab-header-background-color: #F6F7F9; +$image-item-width: 65px; +$box-padding-size: 25px; +$table-header-row-height: 44px; +$table-row-height: 50px; + + +$--color-white: #FFF !default; +$--border-color-base: #DCDFE6; +$--color-primary: #F70 !default; +$--color-sidebar-title-text: #FFF; +$--color-menu-background: #2D3039; +$--color-text-secondary: #909399 !default; +$--color-text-primary: #303133 !default; +$--color-primary-light-1: color-mix(in srgb, $--color-white 10%, $--color-primary 90%) !default; +$--color-primary-light-2: color-mix(in srgb, $--color-white 20%, $--color-primary 80%) !default; +$--color-primary-light-3: color-mix(in srgb, $--color-white 30%, $--color-primary 70%) !default; +$--color-primary-light-4: color-mix(in srgb, $--color-white 40%, $--color-primary 60%) !default; +$--color-primary-light-5: color-mix(in srgb, $--color-white 50%, $--color-primary 50%) !default; +$--color-primary-light-6: color-mix(in srgb, $--color-white 60%, $--color-primary 40%) !default; +$--color-primary-light-7: color-mix(in srgb, $--color-white 70%, $--color-primary 30%) !default; +$--color-primary-light-8: color-mix(in srgb, $--color-white 80%, $--color-primary 20%) !default; +$--color-primary-light-9: color-mix(in srgb, $--color-white 90%, $--color-primary 10%) !default; + + +/** + * 弹窗样式,封装的layer的弹窗 + **/ +body .layer-dialog .layui-layer-title{ + border:1px solid #01000000; + border-radius: 4px 4px 0 0; + background-color: #f8f8f8; +} + +body .layer-dialog .slot-fragment { + height: 100%; +} + +body .layer-dialog .layui-layer-setwin {color: #fff} + +body .layer-dialog { + border:1px solid #01000000; + border-radius: 4px; +} + +body .layer-dialog .layui-layer-content { + padding: $box-padding-size; +} + +body .layer-dialog.one_to_one_query .layui-layer-content { + padding: 0; +} + +body .layer-dialog.layui-layer-iframe .layui-layer-content { + padding: 0!important; +} + +/** + * 左树右表弹窗样式 + */ +body .layer-advance-dialog { + background-color: #F8F8F8; + border:1px solid #01000000; + border-radius: 4px; +} + +body .layer-advance-dialog .layui-layer-title{ + border:1px solid #01000000; + border-radius: 4px 4px 0 0; +} + +body .layer-advance-dialog .layui-layer-content { + padding: 5px 15px; +} + +/** + * 全屏弹窗样式 + */ +body .fullscreen-dialog { + background-color: #F8F8F8; + border: none; + border-radius: 0; +} + +body .fullscreen-dialog .layui-layer-title { + display: none; +} + +body .fullscreen-dialog .layui-layer-setwin { + display: none; +} + +body .fullscreen-dialog .layui-layer-content { + height: 100vh!important; + padding: 0; +} + +.orange-project { + .el-main { + padding: 0; + } + .flex-box { + flex-wrap: wrap; + } + .scrollbar_dropdown__wrap { + overflow-x: hidden!important; + } + + .icon-btn.el-button { + padding: 5px 0; + font-size: 18px; + } + + .default-padding-box { + padding: $box-padding-size; + } + + .padding-no-top { + padding: 0 $box-padding-size $box-padding-size $box-padding-size; + } + + .default-border { + border: 1px solid $--border-color-base; + } + + .default-border-left { + border-left: 1px solid $--border-color-base; + } + + .default-border-right { + border-right: 1px solid $--border-color-base; + } + + .default-border-top { + border-top: 1px solid $--border-color-base; + } + + .default-border-bottom { + border-bottom: 1px solid $--border-color-base; + } + + .page-table { + padding: 16px 24px; + } + + .page-close-box { + position: absolute; + top:-0; + right: -0; + width: 42px; + + /** background: $--color-primary; */ + height: 42px; + text-align: center; + cursor: pointer; + img { + position: absolute; + top: 4px; + right: 4px; + } + &::before{ + position: absolute; + top: 0; + right: 0; + width: 0; + height: 0; + border: 20px solid $--color-primary; + border-color: $--color-primary $--color-primary transparent transparent; + content: ''; + } + } + + .el-button + .btn-import, .btn-import + .el-button { + margin-left: 10px!important; + } + + /** + * 过滤组件样式 + **/ + .mask-box { + position: absolute; + top: 0; + z-index: 10; + width: 100%; + height: 100%; + background-color: rgb(0 0 0 / 50%); + } + + .filter-box { + position: relative; + z-index: 20; + padding: $box-padding-size $box-padding-size 0 $box-padding-size; + background-color: white; + } + + .advance-filter-box { + padding-bottom: 25px; + } + + .filter-item { + width: $filter-item-width; + } + + .cascader-item { + width: 160px!important; + } + + .is-range, .is-search { + width: $filter-item-range-width; + } + + .table-operation-box { + overflow: hidden; + margin-bottom: 10px; + align-self: flex-end; + } + + .table-check-box { + margin-right: 7px; + } + + /** + * 左侧树状组件的样式,用户高级管理表单以及用户管理表单 + **/ + .advanced-left-box { + border-right: 1px solid $border-color; + .el-tree-node__content { + height: $tree-node-height; + } + + .tree-node-item { + width: 100%; + height: $tree-node-height; + line-height: $tree-node-height; + + .tree-node-menu { + display: none; + float: right; + padding-right: 10px; + color: red!important; + } + + &:hover .tree-node-menu { + display: block; + } + } + + .el-tree-node .el-button+.el-button { + margin-left: 5px; + } + } + + /** + * form表单输入组件宽度 + **/ + .full-width-input, .attribute-collapse { + .el-select { + width: 100%; + } + + .el-input { + width: 100%; + } + + .el-cascader { + width: 100%; + } + + .el-date-editor { + width: 100%; + } + + .el-input-number { + width: 100%; + } + } + +/* 与element-plus样式冲突 + .el-form-item.el-form-item--mini { + min-height: 29px; + } + + .el-form-item.el-form-item--small { + min-height: 33px; + } + + .el-form-item.el-form-item--medium { + min-height: 37px; + } + + .el-form-item.el-form-item--default { + min-height: 41px; + } +*/ + + .el-aside { + overflow: visible; + } + + .el-menu { + border-right-width: 0; + } + + .sidebar-bg { + box-shadow: 0 1px 4px rgb(0 21 41 / 8%)!important; + } + + .sidebar-title { + display: flex; + align-items: center; + height: 60px; + padding: 0 20px; + } + + .sidebar-title-text { + padding-left: 15px; + font-size: 18px; + color: $--color-sidebar-title-text; + } + + @if global-variable-exists(--color-menu-item-active-text-color) { + .el-menu:not(.el-menu--horizontal) .el-menu-item.is-active { + color: $--color-menu-item-active-text-color!important; + } + + .el-menu:not(.el-menu--horizontal) .el-submenu__title i { + color: $--color-menu-item-active-text-color; + } + } + + @if global-variable-exists(--color-menu-item-active-background) { + .el-menu:not(.el-menu--horizontal) .el-menu-item.is-active { + @if global-variable-exists(--color-menu-item-active-background-to) { + background: linear-gradient(to left, $--color-menu-item-active-background, $--color-menu-item-active-background-to); + } @else { + background: $--color-menu-item-active-background; + } + } + .el-menu:not(.el-menu--horizontal) .el-menu-item:hover { + @if global-variable-exists(--color-menu-item-active-background-to) { + background: linear-gradient(to left, $--color-menu-item-active-background, $--color-menu-item-active-background-to); + } @else { + background: $--color-menu-item-active-background; + } + } + } + + @if global-variable-exists(--color-submenu-background) { + .left-menu .el-submenu .el-menu { + background-color: $--color-submenu-background; + } + } + + /** + * 多tab页表单,tab样式 + **/ + .el-tabs__header { + margin: 0 0 20px; + } + + /** + * 表格表头背景色 + **/ + .el-container .table-header-gray, .has-gutter .gutter, .layui-layer .table-header-gray { + background-color: $tab-header-background-color; + } + + /** + * 操作按钮颜色 + **/ + .table-btn.delete { + color: #F56C6C; + } + + .table-btn.delete:hover { + color: #F78989; + } + + .table-btn.delete:disabled { + color: #DCDFE6; + } + + .table-btn.success { + color: #67C23A; + } + + .table-btn.success:hover { + color: #85CE61; + } + + .table-btn.success:disabled { + color: #DCDFE6; + } + + .table-btn.warning { + color: #E6A23C; + } + + .table-btn.warning:hover { + color: #EBB563; + } + + .table-btn.warning:disabled { + color: #DCDFE6; + } + + .table-btn.primary { + color: $--color-primary; + } + + .table-btn.primary:hover { + color: $--color-primary-light-2; + } + + .table-btn.primary:disabled { + color: #DCDFE6; + } + + /** + * 图片上传以及显示样式 + **/ + .upload-image-item { + display: block; + width: $image-item-width; + height: $image-item-width; + font-size: 28px; + text-align: center; + color: #8c939d; + + .el-upload i { + line-height: $image-item-width; + } + } + + .upload-image-multi { + display: inline; + } + + .upload-image-item .el-upload { + position: relative; + overflow: hidden; + border: 1px dashed #d9d9d9; + border-radius: 6px; + cursor: pointer; + } + .upload-image-item .el-upload:hover { + border-color: #409eff; + } + + .upload-image-show { + display: inline; + width: $image-item-width; + height: $image-item-width; + } + + .table-cell-image { + width: $image-item-width; + height: $image-item-width; + margin: 0 5px; + font-size: $image-item-width; + text-align: center; + color: #606266; + line-height: $image-item-width; + } + + .upload-image-list .el-upload-list__item { + width: $image-item-width; + height: $image-item-width; + line-height: $image-item-width; + } + + .upload-image-item .el-upload-list--picture-card .el-upload-list__item { + width: $image-item-width; + height: $image-item-width; + } + + .upload-image-item .el-upload.el-upload--text { + width: $image-item-width; + height: $image-item-width; + } + + .upload-image-item .el-upload--picture-card { + width: $image-item-width; + height: $image-item-width; + line-height: $image-item-width; + } + + /** + * + **/ + $header-menu-height: 32px; + + .sidebar { + height: 100%; + background-color: $--color-menu-background; + + /* overflow: hidden; */ + box-shadow: 0 1px 4px rgb(0 21 41 / 8%); + } + + .header { + position: relative; + display: flex; + align-items: center; + height: $header-height; + background-color: white; + } + + .header .menu-column { + margin-right: 20px; + .el-menu-item.is-active { + border-left: 0 solid #47ba5a; + } + } + + .header-menu { + display: flex; + justify-content: flex-end; + float: right; + height: $header-menu-height; + line-height: $header-menu-height; + flex-grow: 1 + } + + .header-img { + float: right; + width: $header-menu-height; + height: $header-menu-height; + margin-left: 14px; + border-radius: 50%; + } + + .el-menu--horizontal.el-menu { + background-color: white; + } + + .el-menu--horizontal > .el-menu-item { + height: 40px; + line-height: 40px; + } + + .el-menu.el-menu--horizontal { + border-bottom: none; + } + + .user-dropdown { + font-size: 12px; + color: $--color-text-secondary; + cursor: pointer; + } + .user-dropdown-item { + font-size: 12px; + color: $--color-text-primary; + + .el-badge { + height: 20px; + margin-top: 0; + margin-left: 10px; + } + } + + .hamburger-container { + float: left; + height: $header-height; + padding: 0 10px; + line-height: 70px; + } + + .el-submenu__title { + background: #0000; + } + + .tree-select { + .el-tree-node__content { + height: 34px; + line-height: 34px; + padding-right: 10px; + } + } + + .tree-select.single-select-tree { + .el-tree-node.is-current > .el-tree-node__content > .el-tree-node__label { + color: $--color-primary; + font-weight: 700; + } + } + + .operation-cell { + text-decoration: underline; + color: #006CDC; + cursor: pointer; + } + + .single-select-tree { + min-width: 200px!important; + } + + .base-card-header { + display: flex; + align-items: center; + height: 50px; + line-height: 50px; + + .header-title { + font-size: 14px; + font-weight: 500; + color: #282828; + } + } + + .base-card-operation { + flex-grow: 1; + display: flex; + justify-content: flex-end; + } + + .el-card__header { + padding: 0 16px; + } + .el-card__body { + padding: 16px; + } + + .custom-cascader { + width: 200px!important; + } + + .no-scroll { + overflow: hidden; + } + + .custom-scroll .el-scrollbar__view { + overflow: hidden!important; + } + + .upload-img-del { + position: absolute; + top: 2px; + right: 2px; + width: 20px; + height: 20px; + font-size: 16px; + color: #C0C4CC; + line-height: 20px; + } + + .upload-img-del:hover { + color: #EF5E1C; + } + + .input-label { + display: inline-block; + height: 29px; + line-height: 28px; + } + + .input-progress { + display: flex; + align-items: center; + height: 29px; + } + + .input-item { + width: 100%!important; + } + + .table-header-gray { + background: rgb(237 237 237 / 100%); + } + + .card-header { + display: flex; + justify-content: space-between; + padding: 10px 0; + line-height: 28px; + } + + .el-select--mini .el-input__inner { + min-height: 28px; + } + + .step-header { + .title { + flex-shrink: 0; + height: 60px; + font-size: 18px; + background: white; + line-height: 60px; + flex-grow: 1; + div { + display: inline-block; + } + .header-logo { + width: 40px; + height: 40px; + margin-right: 8px; + font-size: 28px; + text-align: center; + background: rgb(255 119 0 / 10%); + border-radius: 8px; + line-height: 40px; + } + .logo {; + display: inline-block; + padding-left: 0; + margin-right: 8px; + font-size: 20px; + color: #FDA834; + } + } + .step { + flex-grow: 0; + flex-shrink: 0; + padding: 0 50px; + background: white; + } + .operation { + flex-grow: 1; + flex-shrink: 0; + background: white; + } + } + + .widget-item { + position: relative; + border: 1px dashed rgb(0 0 0 / 0%); + } + .widget-item.active { + background: $--color-primary-light-9; + border: 1px dashed $--color-primary-light-4; + } +} + +.vxe-table--render-default.border--full .vxe-body--column { + background-size: 1px 100%,100% 0!important; + border-bottom: 1px solid #e8eaec; +} + +.vxe-table--render-default.border--inner .vxe-body--column { + background-size: 0 100%,100% 0!important; + border-bottom: 1px solid #e8eaec; +} + +.third-party-dlg { + display: flex; + flex-wrap: nowrap; + flex-direction: column; + background-color: #fff; +} + +.third-party-dlg .form-box { + flex-grow: 1; + flex-shrink: 1; + min-height: 50px; +} +.third-party-dlg .menu-box { + flex-grow: 0; + flex-shrink: 0; +} + +::-webkit-scrollbar { + width: 7px; + height: 7px; + background: none; +} + +::-webkit-scrollbar-thumb { + background: #DDDEE0; + border-radius: 7px; +} + +::-webkit-scrollbar-thumb:hover { + background: #A8A8A8; +} + +.el-popper.preview-popper { + display: none; +} + +.ml20 { + margin-left: 20px; +} + +.mr20 { + margin-right: 20px; +} + +.mt20 { + margin-top: 20px; +} + +.mb20 { + margin-bottom: 20px; +} + +.pl20 { + padding-left: 20px; +} + +.pr20 { + padding-right: 20px; +} + +.pt20 { + padding-top: 20px; +} + +.pb20 { + padding-bottom: 20px; +} + +.gutter-left { + padding-left: 20px; +} + +.gutter-right { + padding-right: 20px; +} + +.gutter-top { + padding-top: 20px; +} + +.gutter-bottom { + padding-bottom: 20px; +} + +.advance-box { + display: flex; + flex-direction: row !important; + .header-title{ + font-weight: bold !important; + } + .module-node-item:hover{ + .module-node-menu{ + opacity: 1 !important; + } + } + .module-node-menu{ + opacity: 0; + transition: 0.3s; + &>.el-button{ + margin-left: 4px; + } + img:nth-child(2){display: none;} + } + .el-tree-node__content{ + border-radius: 4px; + } + .is-current>.el-tree-node__content .module-node-menu{ + img:nth-child(1){display: none;} + img:nth-child(2){display: inline;} + i{ + color: $--color-primary; + } + } + .el-card__header{ + position: relative; + padding-top: 16px; + padding-bottom: 16px; + + /* border-bottom: 1px solid #e8e8e8; */ + border: 0; + } + .el-aside{ + .el-card__header::after{ + position: absolute; + right: 16px; + bottom: -1px; + left: 16px; + display: block; + height: 1px; + background-color: #e8e8e8; + content: ''; + } + } + .base-card-header { + height: auto !important; + line-height: 1; + } + + .is-current>.el-tree-node__content .tree-node-item,.is-current>.el-tree-node__content .text{ + color: $--color-primary; + } + .el-tree-node__expand-icon{ + color: #333; + } + .el-tree-node__expand-icon.is-leaf{ + color: transparent; + } +} + +.el-tree-node__expand-icon{ + color: #333; +} + +.el-tabs__content { + overflow: initial; +} +.el-radio-group{ + display: flex; + align-items: center; + flex-wrap: wrap; + width: 100%; +} +.el-radio{ + vertical-align: middle; + .el-radio__inner{ + width: 16px; + height: 16px; + vertical-align: middle; + } + &.is-checked .el-radio__label{ + color: $--color-primary; + } + .el-radio__inner::after{ + width: 8px; + height: 8px; + } +} +.el-form-item{ + margin-bottom: 16px; +} + +.base-card-operation{ + .el-button.advance-icon-btn:hover, .el-button.advance-icon-btn:focus{ + background-color: white; + border-color: #DCDFE6; + } +} +.vxe-table--render-default .vxe-tree--node-btn{ + color: #333 !important; +} +.vxe-table .vxe-body--row, .vxe-table .vxe-table .vxe-body--row td, .el-table td{ + color: #333; +} +.vxe-table:not(.online-table) .vxe-header--row, .vxe-table:not(.online-table) th, .el-table th{ + height: $table-header-row-height; + padding: 0 !important; + color: #333 !important; + .cell{ + color: #333 !important; + font-weight: bold !important; + } +} +.vxe-table th .vxe-checkbox--icon{ + position: relative; + top: -1px; +} +.vxe-table.vxe-table--render-default .vxe-table--border-line{ + border-width: 0 0 1px; +} +.border-bottom-0 .vxe-table--border-line{ + border-bottom: 0 !important; +} +.vxe-table .vxe-cell--sort{ + top: -1px; + height: 1.1em !important; +} +.vxe-table .vxe-cell--sort i{ + font-size: 12px; + cursor: pointer; +} +.vxe-table .col--seq .vxe-cell--tree-node{ + padding-left: 0 !important; +} +.el-input-number.is-controls-right input.el-input__inner{ + text-align: left; +} +.vxe-table.vxe-table--render-default{ + .is--indeterminate.vxe-cell--checkbox, .is--checked, .vxe-cell--checkbox:not(.is--disabled):hover{ + .vxe-checkbox--icon{ + color: $--color-primary !important; + } + } +} +.table-empty{ + position: relative; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + img{ + width: 120px; + } + span{ + position: relative; + top: -12px; + display: block; + color: #999; + line-height: 1; + } +} +.el-tabs .el-tabs__item.is-active{ + font-weight: bold !important; +} + +// element-plus尺寸去除了medium,small变的更小了 +//.container-small, [class^='el-'][class*='small']{ +.container-default, [class^='el-'][class*='default']{ + font-weight: normal; + .el-tree,.el-input input,.el-radio__label,.el-checkbox__label,.el-switch__label *,.el-upload-list__item,.el-upload__tip,.vxe-cell--label,.vxe-cell--title,.el-tabs__item,.el-breadcrumb,.el-pager li,.el-pagination__total,label,.el-form-item__label,.el-table .cell,.user-dropdown,.el-select-dropdown__item,.el-cascader-node__label,.vxe-table--render-default.size--small,.el-tree-node__label,.el-dropdown-menu__item,.table-btn,.unified-font,.custom-label,.el-link span,.group-title,.el-radio-button__inner,.el-collapse-item__header{ + font-weight: normal; + } + .vxe-cell--title{ + font-weight: bold; + } + .base-card-header .header-title,.base-card-header .el-dropdown span{ + font-size: 14px; + } + .el-radio__label{ + padding-left: 4px; + vertical-align: middle; + } + .el-radio-group{ + min-height: 32px; + } +} + +// element-plus尺寸去除了medium +//.container-medium, [class^='el-'][class*='medium']{ +.container-large, [class^='el-'][class*='large']{ + .vxe-cell--title{ + font-weight: bold; + } + .base-card-header .header-title,.base-card-header .el-dropdown span{ + font-size: 16px; + } + .el-radio__label{ + padding-left: 4px; + vertical-align: middle; + } + .el-radio-group{ + min-height: 36px; + } +} + +.radio-table { + display: block; +} + +.dialog-box { + display: flex !important; + flex-direction: column; + height: 100%; + + .filter-box, .filter-box .flex-box { + padding: 0!important; + } + .content-box { + flex-shrink: 1; + min-height: 1px; + padding: 0!important; + flex-grow: 1; + } + .footer-box { + flex-shrink: 0; + min-height: 1px; + padding: 0!important; + margin-top: 16px; + flex-grow: 0; + } +} + +.el-button + .el-button { + margin-left: 10px; +} + +.mt-16 { + margin-top: 16px; +} + +.mb-16 { + margin-bottom: 16px; +} diff --git a/OrangeFormsOpen-VUE3/src/assets/style/chart.scss b/OrangeFormsOpen-VUE3/src/assets/style/chart.scss new file mode 100644 index 00000000..6b33fd22 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/assets/style/chart.scss @@ -0,0 +1,60 @@ +$chart-form-item-width: 150px; +$chart-form-item-textarea-width: 200px; + +.axis-item { + .el-collapse-item__content { + padding-bottom: 0 !important; + } +} + +.chart-attribute { + .el-divider--horizontal { + margin: 6px 0 !important; + } + + .el-table__empty-text { + line-height: 30px !important; + } +} + +.chart-attribute.el-form--label-top, +.chart-attribute.el-form--label-left { + .el-form-item__label { + width: 100%; + padding-bottom: 0 !important; + font-size: 12px; + color: #303133; + font-weight: 600; + } +} + +.view-attribute-item { + margin-bottom: 6px !important; + + .el-form-item__content { + min-height: 28px !important; + } + + .el-slider, + .el-select { + width: $chart-form-item-width; + } + .el-textarea { + width: $chart-form-item-textarea-width; + } +} + +.view-attribute-item.slider-item { + .el-form-item__label { + line-height: 38px !important; + } +} + +.view-attribute-item .el-form-item__label { + font-size: 12px; + color: #303133; +} + +.luckysheet { + border-radius: 5px; +} diff --git a/OrangeFormsOpen-VUE3/src/assets/style/form-style.scss b/OrangeFormsOpen-VUE3/src/assets/style/form-style.scss new file mode 100644 index 00000000..439fec6b --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/assets/style/form-style.scss @@ -0,0 +1,104 @@ +.form-advanced-manager { + .advance-filter-box { + position: absolute; + top: 100%; + left: 0; + width: 100%; + padding: 10px $box-padding-size 15px $box-padding-size; + background-color: white; + } + + .title-box { + z-index: 20; + height: $advanced-title-height; + padding: 0 20px; + background-color: white; + border-bottom: 1px solid $border-color; + + .title { + line-height: $advanced-title-height; + color: #606266; + } + + .menu-box { + position: absolute; + top: 0; + right: 10px; + height: $advanced-title-height; + + .el-row { + height: $advanced-title-height - 20; + margin: 10px 0; + } + } + } + + .advanced-right-box { + padding: 0; + .gutter-box { + float: left; + width: 3px; + height: 16px; + margin: (($advanced-title-height - 16)/2) 0; + background-color: $--color-primary; + } + } +} + +.form-dict-manager { + .dict-title { + height: 50px; + font-size: 14px; + color: $--color-text-primary; + line-height: 50px; + border-bottom: 1px solid $--border-color-base; + + span { + margin-left: 20px; + } + } + + .dict-item { + width: 100%; + height: 40px; + padding-left: 20px; + color: #606266; + line-height: 40px; + cursor: pointer; + + &:hover { + background-color: $--color-primary-light-9; + } + } + + .active-dict-item { + border-left: 3px solid $--color-primary; + color: $--color-primary; + background-color: $--color-primary-light-9 !important; + } + + .el-scrollbar__bar.is-horizontal { + display: none !important; + } +} + +.form-table-manager { + .advance-filter-box { + position: absolute; + top: 100%; + left: 0; + width: 100%; + padding: 20px; + padding: 10px $box-padding-size 15px $box-padding-size; + background-color: white; + } +} + +.form-config { + padding: $box-padding-size; +} + +.advance-query-form { + padding: 0 !important; + background-color: transparent !important; +} diff --git a/OrangeFormsOpen-VUE3/src/assets/style/index.scss b/OrangeFormsOpen-VUE3/src/assets/style/index.scss new file mode 100644 index 00000000..0bdac0d0 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/assets/style/index.scss @@ -0,0 +1,4 @@ +@charset "UTF-8"; + +@import url('./form-style.scss'); +@import url('./transition.scss'); diff --git a/OrangeFormsOpen-VUE3/src/assets/style/transition.scss b/OrangeFormsOpen-VUE3/src/assets/style/transition.scss new file mode 100644 index 00000000..5fba3930 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/assets/style/transition.scss @@ -0,0 +1,30 @@ +/* fade */ +.fade-enter-active, +.fade-leave-active { + transition: opacity 0.28s; +} + +.fade-enter, +.fade-leave-active { + opacity: 0; +} + +/* fade */ +.breadcrumb-enter-active, +.breadcrumb-leave-active { + transition: all 0.5s; +} + +.breadcrumb-enter, +.breadcrumb-leave-active { + opacity: 0; + transform: translateX(20px); +} + +.breadcrumb-move { + transition: all 0.5s; +} + +.breadcrumb-leave-active { + position: absolute; +} diff --git a/OrangeFormsOpen-VUE3/src/assets/vue.svg b/OrangeFormsOpen-VUE3/src/assets/vue.svg new file mode 100644 index 00000000..770e9d33 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/assets/vue.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/OrangeFormsOpen-VUE3/src/common/hooks/useCommon.ts b/OrangeFormsOpen-VUE3/src/common/hooks/useCommon.ts new file mode 100644 index 00000000..ba27c94e --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/hooks/useCommon.ts @@ -0,0 +1,73 @@ +import { Delete, Search, Edit, Plus, Refresh, Picture } from '@element-plus/icons-vue'; +import { EpPropMergeType } from 'element-plus/es/utils'; +import { useDate } from '@/common/hooks/useDate'; +import { usePermissions } from '@/common/hooks/usePermission'; +import { Dialog } from '@/components/Dialog'; +import { useDropdown } from '@/common/hooks/useDropdown'; +import { useTable } from '@/common/hooks/useTable'; + +/** + * 大部分管理页面需要的组件及公共属性和方法 + * + * @returns 图标(Plus、Delete、Edit、Search)、对话框组件(Dialog)、defaultFormItemSize、mainContextHeight、checkPermCodeExist、下拉数据勾子(useDropdown)、表格数据勾子(useTable) + */ +export const useCommon = () => { + const mainContextHeight = inject('mainContextHeight', ref(200)); + const clientHeight = inject('documentClientHeight', ref(200)); + + const { checkPermCodeExist } = usePermissions(); + const { formatDateByStatsType, getDateRangeFilter } = useDate(); + + /** + * 将输入的值转换成指定的类型 + * @param {Any} value + * @param {String} type 要转换的类型(integer、float、boolean、string) + */ + function parseParams(value: number | string | boolean | undefined, type = 'string') { + if (value == null) return value; + switch (type) { + case 'integer': + return Number.parseInt(value as string); + case 'float': + return Number.parseFloat(value as string); + case 'boolean': + return value === 'true' || value; + default: + return String(value); + } + } + + /** + * 将输入值转换为执行的类型数组 + * @param {Array} value 输入数组 + * @param {String} type 要转换的类型(integer、float、boolean、string) + */ + function parseArrayParams(value: Array, type = 'string') { + if (Array.isArray(value)) { + return value.map(item => { + return parseParams(item, type); + }); + } else { + return []; + } + } + + return { + Delete, + Search, + Edit, + Plus, + Refresh, + Picture, + Dialog, + mainContextHeight, + clientHeight, + checkPermCodeExist, + formatDateByStatsType, + getDateRangeFilter, + useDropdown, + useTable, + parseParams, + parseArrayParams, + }; +}; diff --git a/OrangeFormsOpen-VUE3/src/common/hooks/useDate.ts b/OrangeFormsOpen-VUE3/src/common/hooks/useDate.ts new file mode 100644 index 00000000..8cb31257 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/hooks/useDate.ts @@ -0,0 +1,92 @@ +import { formatDate, parseDate } from '../utils'; + +const allowStatsType = ['time', 'datetime', 'day', 'month', 'year']; + +export const useDate = () => { + /** + * 格式化日期 + * @param {Date|String} date 要格式化的日期 + * @param {String} statsType 输出日期类型 + * @param {String} format 输入日期的格式 + */ + const formatDateByStatsType = ( + date: string | number | Date, + statsType = 'day', + format = 'YYYY-MM-DD', + ) => { + if (date == null) return undefined; + if (statsType == null) return date; + statsType = allowStatsType.indexOf(statsType) === -1 ? 'day' : statsType; + if (statsType === 'datetime') format = 'YYYY-MM-DD HH:mm:ss'; + + //console.log('date', statsType, format, date); + + const tempDate = date instanceof Date ? date : parseDate(date, format); + //console.log('tempDate', tempDate); + if (!tempDate) return undefined; + switch (statsType) { + case 'time': + return formatDate(tempDate, 'HH:mm:ss'); + case 'datetime': + return formatDate(tempDate, 'YYYY-MM-DD HH:mm:ss'); + case 'day': + return formatDate(tempDate, 'YYYY-MM-DD'); + case 'month': + return formatDate(tempDate, 'YYYY-MM'); + case 'year': + return formatDate(tempDate, 'YYYY'); + default: + return formatDate(tempDate, 'YYYY-MM-DD'); + } + }; + + /** + * 根据输入的日期获得日期范围(例如:输入2019-12-12,输出['2019-12-12 00:00:00', '2019-12-12 23:59:59']) + * @param {Date|String} date 要转换的日期 + * @param {String} statsType 转换类型(day, month, year) + * @param {String} format 输出格式 + */ + const getDateRangeFilter = (date: string, statsType = 'day', format = 'YYYY-MM-dd HH:mm:ss') => { + if (date == null) return []; + + statsType = allowStatsType.indexOf(statsType) === -1 ? 'day' : statsType; + date = date.substring(0, date.indexOf(' ')); + const tempList = date.split('-'); + const year = Number.parseInt(tempList[0]); + const month = Number.parseInt(tempList[1]); + const day = Number.parseInt(tempList[2]); + if (isNaN(year) || isNaN(month) || isNaN(day)) { + return []; + } + const tempDate = new Date(year, month - 1, day); + // 判断是否正确的日期 + if (isNaN(tempDate.getTime())) return []; + + tempDate.setHours(0, 0, 0, 0); + let retDate: Date[] = []; + // TODO 如果类型为'time', 'datetime'会出错 + switch (statsType) { + case 'day': + retDate = [new Date(tempDate), new Date(tempDate.setDate(tempDate.getDate() + 1))]; + break; + case 'month': + tempDate.setDate(1); + retDate = [new Date(tempDate), new Date(tempDate.setMonth(tempDate.getMonth() + 1))]; + break; + case 'year': + tempDate.setDate(1); + tempDate.setMonth(0); + retDate = [new Date(tempDate), new Date(tempDate.setFullYear(tempDate.getFullYear() + 1))]; + break; + } + + retDate[1] = new Date(retDate[1].getTime() - 1); + + return [formatDate(retDate[0], format), formatDate(retDate[1], format)]; + }; + + return { + formatDateByStatsType, + getDateRangeFilter, + }; +}; diff --git a/OrangeFormsOpen-VUE3/src/common/hooks/useDownload.ts b/OrangeFormsOpen-VUE3/src/common/hooks/useDownload.ts new file mode 100644 index 00000000..e9a562fd --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/hooks/useDownload.ts @@ -0,0 +1,60 @@ +import { ElMessage } from 'element-plus'; +import { get } from '../http/request'; + +/** + * 文件下载Hooks + * + * @returns downloadFile + */ +export const useDownload = () => { + /** + * 下载上传的文件 + * @param {*} url 下载文件的url + * @param {*} fileName 下载文件名 + */ + const downloadFile = (url: string, fileName: string) => { + get( + url, + {}, + {}, + { + responseType: 'blob', + transformResponse: function (data) { + return data; + }, + }, + ) + .then(res => { + console.log('============= download', res); + const data = res instanceof Blob ? res : res.data; + if (data instanceof Blob) { + const url = window.URL.createObjectURL(data); + const link = document.createElement('a'); + link.style.display = 'none'; + link.href = url; + link.setAttribute('download', fileName); + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + } else { + ElMessage.error('下载文件失败'); + } + }) + .catch(e => { + console.error('============= download', e); + if (e instanceof Blob) { + const reader = new FileReader(); + reader.onload = function () { + ElMessage.error( + reader.result ? JSON.parse(reader.result.toString()).errorMessage : '下载文件失败', + ); + }; + reader.readAsText(e); + } else { + ElMessage.error('下载文件失败'); + } + }); + }; + + return { downloadFile }; +}; diff --git a/OrangeFormsOpen-VUE3/src/common/hooks/useDropdown.ts b/OrangeFormsOpen-VUE3/src/common/hooks/useDropdown.ts new file mode 100644 index 00000000..5df9aff9 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/hooks/useDropdown.ts @@ -0,0 +1,85 @@ +import { DropdownOptions } from '../types/list'; +import { treeDataTranslate } from '../utils'; + +const defaultOptions = { + isTree: false, + idKey: 'id', + parentIdKey: 'parentId', +}; + +export const useDropdown = (options: DropdownOptions) => { + const loading = ref(false); + let loaded = false; + const dropdownList: Ref = ref([]); + + const finalOptions = { ...defaultOptions, ...options }; + + const { loadData, isTree, idKey, parentIdKey } = finalOptions; + + //console.log('dropdown', loadData, isTree, idKey, parentIdKey); + + const loadDropdownData = (): Promise => { + return new Promise((resolve, reject) => { + if (!loaded && !loading.value) { + loadData() + .then(res => { + console.log(`loadDropdownData 加载了${res.dataList.length}条数据`); + loaded = true; + dropdownList.value = isTree + ? treeDataTranslate(res.dataList, idKey, parentIdKey) + : res.dataList; + resolve(dropdownList.value); + }) + .catch(e => { + reject(e); + }) + .finally(() => { + loading.value = false; + }); + } else { + resolve(dropdownList.value); + } + }); + }; + + /** + * 下拉框显示或隐藏时调用 + * @param {Boolean} isShow 正在显示或者隐藏 + */ + const onVisibleChange = (isShow: boolean): Promise => { + return new Promise((resolve, reject) => { + if (isShow && !loaded && !loading.value) { + loadDropdownData() + .then(res => { + resolve(res); + }) + .catch(e => { + reject(e); + }); + } else { + resolve(dropdownList.value); + } + }); + }; + + /** + * 刷新列表 + * @param immediate 是否立即刷新,默认为true + * @return Promise 立即执行时返回最新数据 + */ + const refresh = (immediate = true): Promise => { + loaded = false; + if (immediate) { + return loadDropdownData(); + } + dropdownList.value = []; + return Promise.resolve(); + }; + + return { + loading, + dropdownList, + onVisibleChange, + refresh, + }; +}; diff --git a/OrangeFormsOpen-VUE3/src/common/hooks/usePermission.ts b/OrangeFormsOpen-VUE3/src/common/hooks/usePermission.ts new file mode 100644 index 00000000..27a84930 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/hooks/usePermission.ts @@ -0,0 +1,25 @@ +import { useLoginStore } from '@/store'; +import { getAppId } from '../utils'; + +export const usePermissions = () => { + const loginStorage = useLoginStore(); + + const checkPermCodeExist = (permCode: string) => { + //console.log(permCode); + if (getAppId() != null && getAppId() !== '') return true; + + if (loginStorage.userInfo == null) { + return false; + } + + if (loginStorage.userInfo.permCodeList != null) { + return loginStorage.userInfo.permCodeList.indexOf(permCode) != -1; + } else { + return loginStorage.userInfo.isAdmin; + } + }; + + return { + checkPermCodeExist, + }; +}; diff --git a/OrangeFormsOpen-VUE3/src/common/hooks/useTable.ts b/OrangeFormsOpen-VUE3/src/common/hooks/useTable.ts new file mode 100644 index 00000000..b026b44b --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/hooks/useTable.ts @@ -0,0 +1,197 @@ +/* + * 表格数据(分页)钩子 + * 提供表格数据查询、分页基础数据和回调方法 + */ +import { ElMessage } from 'element-plus'; +import { OrderInfo, RequestParam, TableOptions } from '../types/pagination'; +import { SortInfo } from '../types/sortinfo'; + +// 默认分页大小 +const DEFAULT_PAGE_SIZE = 10; + +export const useTable = (options: TableOptions) => { + const orderInfo: OrderInfo = { + fieldName: options.orderFieldName, + asc: options.ascending || false, + dateAggregateBy: options.dateAggregateBy, + }; + const loading = ref(false); + const currentPage = ref(1); + const totalCount = ref(0); + const dataList: Ref = ref([]); + const pageSize: Ref = ref(options.pageSize || DEFAULT_PAGE_SIZE); + if (!options.verifyTableParameter) { + options.verifyTableParameter = () => true; + } + const { loadTableData, paged, verifyTableParameter } = options; + + let oldPage = 0; + let oldPageSize: number = options.pageSize || DEFAULT_PAGE_SIZE; + + if (pageSize.value <= 0) { + console.warn(`pagesize的值不能小于等于0,被设置为默认值:${DEFAULT_PAGE_SIZE}`); + pageSize.value = DEFAULT_PAGE_SIZE; + } + + // 监听pageSize变化 + watch(pageSize, (newVal, oldVal) => { + //console.log('pageSize change', newVal, oldVal); + if (newVal != oldVal) { + loadData(1, newVal) + .then(() => { + oldPage = 1; + oldPageSize = newVal; + currentPage.value = 1; + }) + .catch(() => { + currentPage.value = oldPage; + pageSize.value = oldVal; + }); + } + }); + // 监听currentPage变化 + watch(currentPage, (newVal, oldVal) => { + if (newVal != oldVal) { + loadData(newVal, pageSize.value) + .then(() => { + oldPage = newVal; + }) + .catch(() => { + currentPage.value = oldVal; + }); + } + }); + + /** + * 获取表格数据 + * @param pageNum 当前分页 + * @param pageSize 每页数量 + * @param reload 是否重新获取数据 + */ + const loadData = (pageNum: number, pageSize: number, reload = false): Promise => { + if (paged && !reload && oldPage == pageNum && oldPageSize == pageSize) { + console.log('数据已加载,无须重复执行'); + return Promise.resolve(); + } + if (paged) { + console.log(`开始加载数据, 第${pageNum}页,每页${pageSize}, 强制加载:${reload}`); + } else { + console.log(`开始加载数据, 无分页, 强制加载:${reload}`); + } + + const params = {} as RequestParam; + if (orderInfo.fieldName != null) params.orderParam = [orderInfo]; + if (paged) { + params.pageParam = { + pageNum, + pageSize, + }; + } + return new Promise((resolve, reject) => { + loading.value = true; + loadTableData(params) + .then(res => { + //console.log(res.dataList, res.totalCount); + // vxetable需要用到对象的hasOwnerProperty方法,因此需要重新构造对象 + dataList.value = res.dataList.map((item: T) => { + return { ...item }; + }); + totalCount.value = res.totalCount; + console.log(`本次加载${res.dataList.length}条数据,共有${res.totalCount}条数据`); + resolve(); + }) + .catch(e => { + reject(e); + }) + .finally(() => { + loading.value = false; + //console.log('加载数据完毕'); + }); + }); + }; + + const onPageSizeChange = (size: number) => { + pageSize.value = size; + }; + + const onCurrentPageChange = (newVal: number) => { + currentPage.value = newVal; + }; + + /** + * 表格排序字段变化 + * @param {String} prop 排序字段的字段名 + * @param {string} field 排序字段的字段名 + * @param {String} order 正序还是倒序 + */ + const onSortChange = ({ prop, field, order }: SortInfo) => { + //console.log(prop, field, order); + orderInfo.fieldName = prop || field; + orderInfo.asc = order == 'ascending' || order == 'asc'; + refreshTable(); + }; + /** + * 刷新表格数据 + * @param {Boolean} research 是否按照新的查询条件重新查询(调用verify函数) + * @param {Integer} pageNum 当前页面 + * @param showMsg 是否显示查询结果成功与否消息 + */ + const refreshTable = (research = false, pageNum = 0, showMsg = false) => { + //console.log(research, pageNum, showMsg); + let reload = false; + if (research) { + if (!verifyTableParameter()) return; + reload = true; + } + + if (pageNum && pageNum != currentPage.value) { + loadData(pageNum, pageSize.value, reload) + .then(() => { + oldPage = currentPage.value = pageNum; + if (showMsg) ElMessage.success('查询成功'); + }) + .catch((e: Error) => { + console.warn('获取表格数据出错了', e); + currentPage.value = oldPage; + if (showMsg) ElMessage.error('查询失败' + e.message); + }); + } else { + loadData(currentPage.value, pageSize.value, true) + .then(() => { + if (showMsg) ElMessage.success('查询成功'); + }) + .catch((e: Error) => { + console.warn('获取表格数据出错了', e); + if (showMsg) ElMessage.error('查询失败' + e.message); + }); + } + }; + /** + * 获取每一行的index信息 + * @param {Integer} index 表格在本页位置 + */ + const getTableIndex = (index: number) => { + return paged ? (currentPage.value - 1) * pageSize.value + (index + 1) : index + 1; + }; + + const clearTable = () => { + oldPage = 0; + currentPage.value = 1; + totalCount.value = 0; + dataList.value = []; + }; + + return { + loading, + currentPage, + totalCount, + pageSize, + dataList, + clearTable, + getTableIndex, + onPageSizeChange, + onCurrentPageChange, + onSortChange, + refreshTable, + }; +}; diff --git a/OrangeFormsOpen-VUE3/src/common/hooks/useUpload.ts b/OrangeFormsOpen-VUE3/src/common/hooks/useUpload.ts new file mode 100644 index 00000000..19829fc9 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/hooks/useUpload.ts @@ -0,0 +1,160 @@ +import { useLayoutStore } from '@/store'; +import { ANY_OBJECT } from '@/types/generic'; +import { getAppId, getToken } from '../utils'; +import { post } from '../http/request'; +import { useUrlBuilder } from './useUrl'; + +export const useUpload = () => { + const { buildGetUrl, requestUrl } = useUrlBuilder(); + /** + * 解析返回的上传文件数据 + * @param {String} jsonData 上传文件数据,[{name, downloadUri, filename}] + * @param {Object} params 上传文件的参数 + * @returns {Array} 上传文件信息,[{name, downloadUri, filename, url}] + */ + const parseUploadData = (jsonData: string, params: ANY_OBJECT) => { + let pathList = []; + if (jsonData != null) { + try { + pathList = JSON.parse(jsonData); + } catch (e) { + console.error(e); + } + } + + return Array.isArray(pathList) + ? pathList.map(item => { + const downloadParams = { ...params }; + downloadParams.filename = item.filename; + return { + ...item, + url: getUploadFileUrl(item, downloadParams), + }; + }) + : []; + }; + + /** + * 获得上传文件url + * @param {*} item 上传文件 + * @param {*} params 上传文件的参数 + */ + const getUploadFileUrl = (item: { downloadUri: string }, params?: ANY_OBJECT) => { + if (item == null || item.downloadUri == null) { + return null; + } else { + const currentMenuId = useLayoutStore().currentMenuId; + const query = { ...params }; + query.Authorization = getToken(); + query.MenuId = currentMenuId; + query.AppCode = getAppId(); + return buildGetUrl(item.downloadUri, query); + } + }; + + const getUploadHeaders = computed(() => { + const token = getToken(); + const appId = getAppId(); + const currentMenuId = useLayoutStore().currentMenuId; + const header: ANY_OBJECT = { + Authorization: token, + MenuId: currentMenuId, + }; + if (appId) header.AppCode = appId; + + return header; + }); + + /** + * 获得上传接口 + * @param {*} url 上传路径 + */ + const getUploadActionUrl = (url: string) => { + return buildGetUrl(url, null); + }; + + /** + * 上传文件 + * @param {*} url 请求的url + * @param {*} params 请求参数 + */ + const fetchUpload = (url: string, params: ANY_OBJECT) => { + return new Promise((resolve, reject) => { + post( + requestUrl(url), + {}, + { showError: true }, + { + data: params, + headers: { + 'Content-Type': 'multipart/form-data', + }, + transformRequest: [ + function (data: ANY_OBJECT) { + const formData = new FormData(); + Object.keys(data).map(key => { + formData.append(key, data[key]); + }); + return formData; + }, + ], + }, + ) + .then((res: ANY_OBJECT) => { + console.log('uploaded file fetchUpload', res); + if (res.data && res.success) { + resolve(res.data); + } + }) + .catch(e => { + reject(e); + }); + }); + }; + + /** + * 获得上传文件url列表 + * @param {*} jsonData 上传文件数据,[{name, downloadUri, filename}] + * @param {*} params 上传文件的参数 + * @returns {Array} 文件url列表 + */ + const getPictureList = (jsonData: string, params: ANY_OBJECT) => { + const tempList = parseUploadData(jsonData, params); + if (Array.isArray(tempList)) { + return tempList.map(item => item.url); + } else { + return []; + } + }; + + /** + * 将选中文件信息格式化成json信息 + * @param {Array} fileList 上传文件列表,[{name, fileUrl, data}] + */ + const fileListToJson = (fileList: ANY_OBJECT[]) => { + if (Array.isArray(fileList)) { + return JSON.stringify( + fileList.map(item => { + return { + name: item.name, + downloadUri: item.downloadUri || item.response.data.downloadUri, + filename: item.filename || item.response.data.filename, + uploadPath: item.uploadPath || item.response.data.uploadPath, + }; + }), + ); + } else { + return undefined; + } + }; + + return { + getUploadFileUrl, + parseUploadData, + getUploadHeaders, + getUploadActionUrl, + fetchUpload, + getPictureList, + fileListToJson, + }; +}; diff --git a/OrangeFormsOpen-VUE3/src/common/hooks/useUploadWidget.ts b/OrangeFormsOpen-VUE3/src/common/hooks/useUploadWidget.ts new file mode 100644 index 00000000..5ae27ec8 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/hooks/useUploadWidget.ts @@ -0,0 +1,25 @@ +import { UploadFile } from 'element-plus'; + +export const useUploadWidget = (maxFileCount = 1) => { + const fileList = ref([]); + const maxCount = ref(maxFileCount); + + /** + * 上传文件列表改变 + * @param {Object} uploadFile 改变的文件 + * @param {Array} uploadFiles 改变后的文件列表 + */ + const onFileChange = (uploadFile: UploadFile | null, uploadFiles: UploadFile[] | null) => { + if (uploadFiles && uploadFiles.length > 0) { + if (maxFileCount == 1) { + fileList.value = [uploadFiles[uploadFiles.length - 1]]; + } else { + fileList.value = uploadFiles; + } + } else { + fileList.value = []; + } + }; + + return { fileList, onFileChange, maxCount }; +}; diff --git a/OrangeFormsOpen-VUE3/src/common/hooks/useUrl.ts b/OrangeFormsOpen-VUE3/src/common/hooks/useUrl.ts new file mode 100644 index 00000000..b7cfcf91 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/hooks/useUrl.ts @@ -0,0 +1,40 @@ +import { ANY_OBJECT } from '@/types/generic'; +import { objectToQueryString } from '../utils'; + +export const useUrlBuilder = () => { + /** + * 请求地址统一处理/组装 + * @param actionName 方法名称 + * @param params 请求参数 + * @returns 请求全路径(含参数) + */ + const buildGetUrl = (actionName: string, params: ANY_OBJECT | null = null) => { + console.log('getUrl', actionName); + const queryString = objectToQueryString(params); + if (actionName != null && actionName !== '') { + if (actionName.substring(0, 1) === '/') actionName = actionName.substring(1); + } + + return ( + import.meta.env.VITE_SERVER_HOST + actionName + (queryString == null ? '' : '?' + queryString) + ); + }; + + /** + * 请求地址统一处理/组装 + * @param actionName action方法名称 + */ + const requestUrl = (actionName: string) => { + console.log('requestUrl', actionName); + if (actionName) { + if (actionName.substring(0, 1) === '/') actionName = actionName.substring(1); + } + if (actionName.indexOf('http://') === 0 || actionName.indexOf('https://') === 0) { + return actionName; + } else { + return import.meta.env.VITE_SERVER_HOST + actionName; + } + }; + + return { buildGetUrl, requestUrl }; +}; diff --git a/OrangeFormsOpen-VUE3/src/common/hooks/useWindowResize.ts b/OrangeFormsOpen-VUE3/src/common/hooks/useWindowResize.ts new file mode 100644 index 00000000..4343db94 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/hooks/useWindowResize.ts @@ -0,0 +1,50 @@ +import { onMounted, onUnmounted, provide, ref } from 'vue'; +import { useLayoutStore } from '@/store'; +import { getAppId } from '../utils'; + +// 屏幕宽度分界值,影响整体样式 +const WIDTH = 1900; + +const documentClientHeight = ref(0); + +/** + * 在最顶层使用该hook,一方面监听窗口大小变化,同时向下面提供一个计算属性 + */ +export const useWindowResize = () => { + const windowResize = () => { + //console.log('窗口尺寸发生变化'); + documentClientHeight.value = document.documentElement.clientHeight; + if (window.innerWidth <= WIDTH) { + layoutStore.defaultFormItemSize = 'default'; + document.body.className = 'orange-project container-default'; + } else { + layoutStore.defaultFormItemSize = 'large'; + document.body.className = 'orange-project container-large'; + } + + layoutStore.documentClientHeight = document.documentElement.clientHeight; + layoutStore.mainContextHeight = mainContextHeight.value; + }; + + const layoutStore = useLayoutStore(); + const mainContextHeight = computed(() => { + const appId = getAppId(); + if (appId == null) { + return documentClientHeight.value - (layoutStore.supportTags ? 110 : 60); + } else { + return documentClientHeight.value; + } + }); + + provide('documentClientHeight', documentClientHeight); + provide('mainContextHeight', mainContextHeight); + + onMounted(() => { + windowResize(); + window.addEventListener('resize', windowResize); + }); + + onUnmounted(() => { + window.removeEventListener('resize', windowResize); + }); +}; diff --git a/OrangeFormsOpen-VUE3/src/common/http/axios.ts b/OrangeFormsOpen-VUE3/src/common/http/axios.ts new file mode 100644 index 00000000..1846d7da --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/http/axios.ts @@ -0,0 +1,147 @@ +import axios, { AxiosInstance, AxiosPromise, AxiosResponse } from 'axios'; +import JSONbig from 'json-bigint'; +import { router } from '@/router'; +import { getToken, setToken, getAppId } from '@/common/utils/index'; +import { useLayoutStore } from '@/store'; +import { Dialog } from '@/components/Dialog'; +import { serverDefaultCfg } from './config'; +import { ResponseDataType } from './types'; + +// 创建 axios 请求实例 +const axiosInstance: AxiosInstance = axios.create({ + baseURL: serverDefaultCfg.baseURL, // 基础请求地址 + timeout: 30000, // 请求超时设置 + withCredentials: true, // 跨域请求是否需要携带 cookie + headers: { + //Accept: 'application/json, text/plain, */*', + //'X-Requested-With': 'XMLHttpRequest', + 'Content-Type': 'application/json; charset=utf-8', + deviceType: '4', + }, + validateStatus: status => { + return status === 200 || status === 401; // 放行哪些状态的请求 + }, + transformResponse: [ + function (data) { + //console.log('transformResponse', data); + if (typeof data === 'string') { + return JSONbig({ storeAsString: true }).parse(data); + } else { + return data; + } + }, + ], +}); + +// 创建请求拦截 +axiosInstance.interceptors.request.use( + config => { + const token = getToken(); + const appId = getAppId(); + const currentMenuId = useLayoutStore().currentMenuId; + if (token != null) config.headers['Authorization'] = token; + if (appId != null && appId !== '') config.headers['AppCode'] = appId; + if (currentMenuId != null) config.headers['MenuId'] = currentMenuId; + return config; + }, + error => { + Promise.reject(error); + }, +); + +const loginInvalid = () => { + setToken(null); + Dialog.closeAll(); + router.push({ name: 'login' }); +}; + +// 创建响应拦截 +axiosInstance.interceptors.response.use( + (response: AxiosResponse): AxiosPromise> => { + //console.log('axios response => ', response); + const { data, status } = response; + // 如果401响应放行至此,执行此逻辑 + if (status === 401) { + const appId = getAppId(); + if (appId == null) { + loginInvalid(); + } + return Promise.reject(new Error('您未登录,或者登录已经超时,请先登录!')); + } + if (response.data && response.data.errorCode === 'UNAUTHORIZED_LOGIN') { + // 401, token失效 + const appId = getAppId(); + if (appId == null) { + loginInvalid(); + } else { + return Promise.reject(new Error(response.data.errorMessage)); + } + } else { + if (response.headers['refreshedtoken'] != null) { + setToken(response.headers['refreshedtoken']); + } + //console.log('response', response, 'blob', response.data instanceof Blob); + // 判断请求是否成功 + if (!(response.data instanceof Blob) && !response.data.success) { + return Promise.reject(new Error(response.data.errorMessage || 'error')); + } + } + return data; + }, + error => { + //console.warn(error); + let message = ''; + if (error && error.response) { + switch (error.response.status) { + case 302: + message = '接口重定向了!'; + break; + case 400: + message = '参数不正确!'; + break; + case 401: + message = '您未登录,或者登录已经超时,请先登录!'; + break; + case 403: + message = '您没有权限操作!'; + break; + case 404: + message = `请求地址出错: ${error.response.config.url}`; + break; + case 408: + message = '请求超时!'; + break; + case 409: + message = '系统已存在相同数据!'; + break; + case 500: + message = '服务器内部错误!'; + break; + case 501: + message = '服务未实现!'; + break; + case 502: + message = '网关错误!'; + break; + case 503: + message = '服务不可用!'; + break; + case 504: + message = '服务暂时无法访问,请稍后再试!'; + break; + case 505: + message = 'HTTP 版本不受支持!'; + break; + default: + message = '异常问题,请联系管理员!'; + break; + } + console.log('请求异常 ==>', message); + return Promise.reject(new Error(message)); + } else { + return Promise.reject(new Error(error.message)); + } + }, +); + +export default axiosInstance; diff --git a/OrangeFormsOpen-VUE3/src/common/http/config.ts b/OrangeFormsOpen-VUE3/src/common/http/config.ts new file mode 100644 index 00000000..2984c957 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/http/config.ts @@ -0,0 +1,4 @@ +export const serverDefaultCfg = { + baseURL: import.meta.env.VITE_SERVER_HOST, // 请求基础地址,可根据环境自定义 + mockURL: '', +}; diff --git a/OrangeFormsOpen-VUE3/src/common/http/request.ts b/OrangeFormsOpen-VUE3/src/common/http/request.ts new file mode 100644 index 00000000..bb685102 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/http/request.ts @@ -0,0 +1,384 @@ +import { ElMessage, ElLoading } from 'element-plus'; +import { AxiosRequestConfig } from 'axios'; +import { getAppId } from '@/common/utils/index'; +import { ANY_OBJECT } from '@/types/generic'; +import { useUrlBuilder } from '../hooks/useUrl'; +import axiosInstance from './axios'; +import { serverDefaultCfg } from './config'; +import { RequestMethods, RequestOption, ResponseDataType } from './types'; + +const { requestUrl } = useUrlBuilder(); +const globalConfig = { + requestOption: { + mock: false, + // 调用的时候是否显示蒙版 + showMask: true, + // 是否显示公共的错误提示 + showError: true, + // 是否开启节流功能,同一个url不能频繁重复调用 + throttleFlag: false, + // 节流间隔 + throttleTimeout: 50, + } as RequestOption, + axiosOption: { + responseType: 'json', + } as AxiosRequestConfig, +}; + +function showErrorMessage(message: string | { showClose: boolean; message: string }) { + const appId = getAppId(); + if (appId != null && appId !== '') { + if (window.parent) { + window.parent.postMessage( + { + type: 'message', + data: { + type: 'error', + text: message, + }, + }, + '*', + ); + } + } else { + ElMessage.error(message); + } +} + +/** + * 遮罩管理,多次调用支持引用计数 + */ +class LoadingManager { + private options: ANY_OBJECT; + private refCount: number; + private loading: ReturnType | null; + + constructor(options: ANY_OBJECT) { + this.options = options; + this.refCount = 0; + this.loading = null; + } + + showMask() { + this.refCount++; + //console.log('loading >>>', this.refCount); + if (this.refCount <= 1 && this.loading == null) { + //console.log('loading do create serice'); + this.loading = ElLoading.service(this.options); + } + } + + hideMask() { + //console.log('loading hideMask', this.refCount); + if (this.refCount <= 1 && this.loading != null) { + this.loading.close(); + this.loading = null; + //console.log('loading hideMask do close'); + } + this.refCount--; + this.refCount = Math.max(0, this.refCount); + } +} + +//console.log('new LoadingManager'); +const loadingManager = new LoadingManager({ + fullscreen: true, + background: 'rgba(0, 0, 0, 0.1)', +}); + +// url调用节流Set +const ajaxThrottleSet = new Set(); + +/** + * 核心函数,可通过它处理一切请求数据,并做横向扩展 + * @param url 请求地址 + * @param params 请求参数 + * @param method 请求方法,只接受"get" | "delete" | "head" | "post" | "put" | "patch" + * @param requestOption 请求配置(针对当前本次请求) + * @param axiosOption axios配置(针对当前本次请求) + */ +export async function commonRequest( + url: string, + params: ANY_OBJECT, + method: RequestMethods, + requestOption?: RequestOption, + axiosOption?: AxiosRequestConfig, +): Promise> { + const finalOption = { + ...globalConfig.requestOption, + ...requestOption, + }; + const { showMask, showError, throttleFlag, throttleTimeout } = finalOption; + + let finalUrl = url; + // 通过mock平台可对局部接口进行mock设置 + if (finalOption.mock) finalUrl = serverDefaultCfg.mockURL; + + if (ajaxThrottleSet.has(finalUrl) && throttleFlag) { + return Promise.reject(); + } else { + if (throttleFlag) { + ajaxThrottleSet.add(url); + setTimeout(() => { + ajaxThrottleSet.delete(url); + }, throttleTimeout || 50); + } + + const finalAxiosOption = { + ...globalConfig.axiosOption, + ...axiosOption, + }; + + // get请求使用params字段 + let data: ANY_OBJECT = { params }; + // 非get请求使用data字段 + if (method !== 'get') data = { data: params }; + + if (showMask) loadingManager.showMask(); + try { + const result: ResponseDataType = await axiosInstance({ + url: finalUrl, + method, + ...data, + ...finalAxiosOption, + }); + //console.log('result:', result); + if (result instanceof Blob || result.success) { + return Promise.resolve(result); + } else { + if (showError) { + showErrorMessage({ + showClose: true, + message: result.errorMessage ? result.errorMessage : '数据请求失败', + }); + } + return Promise.reject(result); + } + } catch (error) { + console.warn('请求异常', error); + if (showError) { + const err = error as Error; + showErrorMessage({ + showClose: true, + message: err ? err.message : '网络请求错误', + }); + } + return Promise.reject(error); + } finally { + loadingManager.hideMask(); + } + } +} + +/*** + * @param url 请求地址 + * @param params 请求参数 + * @param options 请求设置(showMask-是否显示Loading层,默认为true;showError-是否显示错误信息,默认为true;throttleFlag-是否开户节流,默认为false;throttleTimeout-节流时效,默认为50毫秒) + * @param axiosOption + */ +export const get = async ( + url: string, + params: ANY_OBJECT, + options?: RequestOption, + axiosOption?: AxiosRequestConfig, +) => { + return await commonRequest(url, params, 'get', options, axiosOption); +}; +/*** + * @param url 请求地址 + * @param params 请求参数 + * @param options 请求设置(showMask-是否显示Loading层,默认为true;showError-是否显示错误信息,默认为true;throttleFlag-是否开户节流,默认为false;throttleTimeout-节流时效,默认为50毫秒) + * @param axiosOption + */ +export const post = async ( + url: string, + params: ANY_OBJECT, + options?: RequestOption, + axiosOption?: AxiosRequestConfig, +) => { + return await commonRequest(url, params, 'post', options, axiosOption); +}; +/*** + * @param url 请求地址 + * @param params 请求参数 + * @param options 请求设置(showMask-是否显示Loading层,默认为true;showError-是否显示错误信息,默认为true;throttleFlag-是否开户节流,默认为false;throttleTimeout-节流时效,默认为50毫秒) + * @param axiosOption + */ +export const put = async ( + url: string, + params: ANY_OBJECT, + options?: RequestOption, + axiosOption?: AxiosRequestConfig, +) => { + return await commonRequest(url, params, 'put', options, axiosOption); +}; +/*** + * @param url 请求地址 + * @param params 请求参数 + * @param options 请求设置(showMask-是否显示Loading层,默认为true;showError-是否显示错误信息,默认为true;throttleFlag-是否开户节流,默认为false;throttleTimeout-节流时效,默认为50毫秒) + * @param axiosOption + */ +export const patch = async ( + url: string, + params: ANY_OBJECT, + options?: RequestOption, + axiosOption?: AxiosRequestConfig, +) => { + return await commonRequest(url, params, 'patch', options, axiosOption); +}; +/*** + * @param url 请求地址 + * @param params 请求参数 + * @param options 请求设置(showMask-是否显示Loading层,默认为true;showError-是否显示错误信息,默认为true;throttleFlag-是否开户节流,默认为false;throttleTimeout-节流时效,默认为50毫秒) + * @param axiosOption + */ +export const del = async ( + url: string, + params: ANY_OBJECT, + options?: RequestOption, + axiosOption?: AxiosRequestConfig, +) => { + return await commonRequest(url, params, 'delete', options, axiosOption); +}; +/** + * + * @param url 请求地址 + * @param params 请求参数 + * @param filename 文件名 + * @param options 请求设置(showMask-是否显示Loading层,默认为true;showError-是否显示错误信息,默认为true;throttleFlag-是否开户节流,默认为false;throttleTimeout-节流时效,默认为50毫秒) + */ +export const download = async ( + url: string, + params: ANY_OBJECT, + filename: string, + method?: RequestMethods, + options?: RequestOption, +) => { + // console.log( + // 'download file url=%s, params:%s, filename:%s, options:%s', + // url, + // params, + // filename, + // options, + // ); + return new Promise((resolve, reject) => { + downloadBlob(url, params, method, options) + .then(blobData => { + const blobUrl = window.URL.createObjectURL(blobData); + const linkDom = document.createElement('a'); + linkDom.style.display = 'none'; + linkDom.href = blobUrl; + linkDom.setAttribute('download', filename); + if (typeof linkDom.download === 'undefined') { + linkDom.setAttribute('target', '_blank'); + } + document.body.appendChild(linkDom); + linkDom.click(); + document.body.removeChild(linkDom); + window.URL.revokeObjectURL(blobUrl); + resolve(true); + }) + .catch(e => { + reject(e); + }); + }); +}; +/** + * 下载文件,返回blob + * @param {String} url 请求的url + * @param {Object} params 请求参数 + * @param {RequestMethods} method 请求方法 + * @returns {Promise} + */ +export const downloadBlob = ( + url: string, + params: ANY_OBJECT, + method: RequestMethods = 'post', + options?: RequestOption, +) => { + return new Promise((resolve, reject) => { + const axiosOption: AxiosRequestConfig = { + responseType: 'blob', + transformResponse: function (data) { + //console.log(data); + return data instanceof Blob && data.size > 0 ? data : undefined; + }, + }; + commonRequest(requestUrl(url), params, method, options, axiosOption) + .then(res => { + //console.log('download blob response >>>', res); + if (res instanceof Blob) { + const blobData = new Blob([res.data], { type: 'application/octet-stream' }); + resolve(blobData); + } else { + console.warn('下载文件失败', res); + reject(new Error('下载文件失败')); + } + }) + .catch(e => { + if (e instanceof Blob) { + const reader = new FileReader(); + reader.onload = () => { + reject( + reader.result ? JSON.parse(reader.result.toString()).errorMessage : '下载文件失败', + ); + }; + reader.readAsText(e); + } else { + reject('下载文件失败'); + } + }); + }); +}; +/** + * 上传 + * @param url 请求地址 + * @param params 请求参数 + * @param options 请求设置(showMask-是否显示Loading层,默认为true;showError-是否显示错误信息,默认为true;throttleFlag-是否开户节流,默认为false;throttleTimeout-节流时效,默认为50毫秒) + */ +export const upload = async (url: string, params: ANY_OBJECT, options?: RequestOption) => { + //console.log('upload file url=%s, params:%s, options:%s', url, params, options); + const axiosOption: AxiosRequestConfig = { + headers: { + 'Content-Type': 'multipart/form-data', + }, + transformRequest: [ + function (data) { + const formData = new FormData(); + Object.keys(data).forEach(key => { + formData.append(key, data[key]); + }); + return formData; + }, + ], + }; + + const finalOption = { + ...globalConfig.requestOption, + ...options, + }; + const { showError } = finalOption; + return new Promise((resolve, reject) => { + commonRequest(requestUrl(url), params, 'post', options, axiosOption) + .then(res => { + if (res?.success) { + resolve(res); + } else { + if (showError) + showErrorMessage({ + showClose: true, + message: res.data.errorMessage ? res.data.errorMessage : '数据请求失败', + }); + reject('数据请求失败'); + } + }) + .catch(e => { + if (showError) + showErrorMessage({ + showClose: true, + message: e.errorMessage ? e.errorMessage : '网络请求错误', + }); + reject(e); + }); + }); +}; diff --git a/OrangeFormsOpen-VUE3/src/common/http/types.d.ts b/OrangeFormsOpen-VUE3/src/common/http/types.d.ts new file mode 100644 index 00000000..5920357c --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/http/types.d.ts @@ -0,0 +1,39 @@ +import { Method } from 'axios'; +import { ANY_OBJECT } from '@/types/generic'; + +export type RequestMethods = Extract< + Method, + 'get' | 'post' | 'put' | 'delete' | 'patch' | 'option' | 'head' +>; + +/** + * @param showMask 是否显示Loading层 + * @param showError 是否显示错误消息 + * @param throttleFlag 是否节流 + * @param throttleTimeout 节流限制时长 + */ +export type RequestOption = { + /** 是否使用Mock请求 */ + mock?: boolean; + showMask?: boolean; + showError?: boolean; + throttleFlag?: boolean; + throttleTimeout?: number; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [key: string]: any; +}; + +// 定义返回数据的类型 +export type ResponseDataType = { + errorCode: string | null; + data: T; + errorMessage: string | null; + success: boolean; +}; + +export type TableData = { + dataList: T[]; + totalCount: number; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [key: string]: any; +}; diff --git a/OrangeFormsOpen-VUE3/src/common/staticDict/combined.ts b/OrangeFormsOpen-VUE3/src/common/staticDict/combined.ts new file mode 100644 index 00000000..db1c5c18 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/staticDict/combined.ts @@ -0,0 +1,5 @@ +import * as baseDict from './index'; + +export default { + ...baseDict, +}; diff --git a/OrangeFormsOpen-VUE3/src/common/staticDict/flow.ts b/OrangeFormsOpen-VUE3/src/common/staticDict/flow.ts new file mode 100644 index 00000000..21a8d6fc --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/staticDict/flow.ts @@ -0,0 +1,331 @@ +/** + * 流程表单常量字典 + */ +import { DictionaryBase } from './types'; + +const SysFlowEntryBindFormType = new DictionaryBase('流程绑定表单类型', [ + { + id: 0, + name: '动态表单', + symbol: 'ONLINE_FORM', + }, + { + id: 1, + name: '路由表单', + symbol: 'ROUTER_FORM', + }, +]); + +const SysFlowEntryPublishedStatus = new DictionaryBase('流程设计发布状态', [ + { + id: 0, + name: '未发布', + symbol: 'UNPUBLISHED', + }, + { + id: 1, + name: '已发布', + symbol: 'PUBLISHED', + }, +]); + +const SysFlowEntryStep = new DictionaryBase('流程设计步骤', [ + { + id: 0, + name: '编辑基础信息', + symbol: 'BASIC', + }, + { + id: 1, + name: '流程变量设置', + symbol: 'PROCESS_VARIABLE', + }, + { + id: 2, + name: '设计流程', + symbol: 'PROCESS_DESIGN', + }, + { + id: 3, + name: '流程状态设置', + symbol: 'PROCESS_STATUS', + }, +]); + +const SysFlowTaskOperationType = new DictionaryBase('任务操作类型', [ + { + id: 'agree', + name: '同意', + symbol: 'AGREE', + }, + { + id: 'refuse', + name: '拒绝', + symbol: 'REFUSE', + }, + { + id: 'reject', + name: '驳回', + symbol: 'REJECT', + }, + { + id: 'rejectToStart', + name: '驳回到起点', + symbol: 'REJECT_TO_START', + }, + { + id: 'revoke', + name: '撤销', + symbol: 'REVOKE', + }, + { + id: 'transfer', + name: '转办', + symbol: 'TRANSFER', + }, + { + id: 'multi_consign', + name: '加签', + symbol: 'CO_SIGN', + }, + { + id: 'multi_minus_sign', + name: '减签', + symbol: 'SIGN_REDUCTION', + }, + { + id: 'save', + name: '保存', + symbol: 'SAVE', + }, + { + id: 'stop', + name: '终止', + symbol: 'STOP', + }, + { + id: 'multi_sign', + name: '会签', + symbol: 'MULTI_SIGN', + }, + { + id: 'multi_agree', + name: '同意(会签)', + symbol: 'MULTI_AGREE', + }, + { + id: 'multi_refuse', + name: '拒绝(会签)', + symbol: 'MULTI_REFUSE', + }, + { + id: 'multi_abstain', + name: '弃权(会签)', + symbol: 'MULTI_ABSTAIN', + }, + { + id: 'set_assignee', + name: '指定审批人', + symbol: 'SET_ASSIGNEE', + }, +]); + +const SysFlowTaskType = new DictionaryBase('工作流任务类型', [ + { + id: 0, + name: '其他任务', + symbol: 'OTHER_TASK', + }, + { + id: 1, + name: '用户任务', + symbol: 'USER_TASK', + }, +]); + +const SysFlowVariableType = new DictionaryBase('工作流变量类型', [ + { + id: 0, + name: '流程变量', + symbol: 'INSTANCE', + }, + { + id: 1, + name: '任务变量', + symbol: 'TASK', + }, +]); + +const SysFlowWorkOrderStatus = new DictionaryBase('工单状态', [ + { + id: 0, + name: '已提交', + symbol: 'SUBMITED', + }, + { + id: 1, + name: '审批中', + symbol: 'APPROVING', + }, + { + id: 2, + name: '已拒绝', + symbol: 'REFUSED', + }, + { + id: 3, + name: '已完成', + symbol: 'FINISHED', + }, + { + id: 4, + name: '终止', + symbol: 'STOPPED', + }, + { + id: 5, + name: '撤销', + symbol: 'CANCEL', + }, + { + id: 6, + name: '草稿', + symbol: 'DRAFT', + }, +]); + +const SysFlowCopyForType = new DictionaryBase('抄送类型', [ + { + id: 'user', + name: '抄送人', + symbol: 'USER', + }, + { + id: 'dept', + name: '抄送部门', + symbol: 'DEPT', + }, + { + id: 'role', + name: '抄送角色', + symbol: 'ROLE', + }, + { + id: 'deptPostLeader', + name: '审批人部门领导', + symbol: 'SELF_DEPT_LEADER', + }, + { + id: 'upDeptPostLeader', + name: '审批人上级部门领导', + symbol: 'UP_DEPT_LEADER', + }, + { + id: 'allDeptPost', + name: '抄送岗位', + symbol: 'POST', + }, + { + id: 'selfDeptPost', + name: '审批人部门岗位', + symbol: 'SELF_DEPT_POST', + }, + { + id: 'siblingDeptPost', + name: '审批人同级部门岗位', + symbol: 'SLIBING_DEPT_POST', + }, + { + id: 'upDeptPost', + name: '审批人上级部门岗位', + symbol: 'UP_DEPT_POST', + }, + { + id: 'deptPost', + name: '指定部门岗位', + symbol: 'DEPT_POST', + }, +]); + +const FlowNodeType = new DictionaryBase('钉钉节点类型', [ + { + id: 0, + name: '发起人', + symbol: 'ORIGINATOR', + }, + { + id: 1, + name: '审批人', + symbol: 'APPROVED_BY', + }, + { + id: 2, + name: '抄送人', + symbol: 'CC_TO', + }, + { + id: 3, + name: '连接线', + symbol: 'CONNECTING_LINE', + }, + { + id: 4, + name: '条件分支', + symbol: 'CONDITIONAL_BRANCH', + }, + { + id: 5, + name: '并行分支', + symbol: 'PARALLEL_BRANCH', + }, +]); + +const DiagramType = new DictionaryBase('', [ + { + id: 0, + name: '普通流程图', + symbol: 'ORDINARY', + }, + { + id: 1, + name: '钉钉风格流程图', + symbol: 'DINGDING', + }, +]); + +const SysAutoCodeType = new DictionaryBase('自动编码类型', [ + { + id: 'DAYS', + name: '精确到日', + symbol: 'DAYS', + }, + { + id: 'HOURS', + name: '精确到时', + symbol: 'HOURS', + }, + { + id: 'MINUTES', + name: '精确到分', + symbol: 'MINUTES', + }, + { + id: 'SECONDS', + name: '精确到秒', + symbol: 'SECONDS', + }, +]); + +export { + SysFlowEntryPublishedStatus, + SysFlowEntryBindFormType, + SysFlowEntryStep, + SysFlowTaskOperationType, + SysFlowTaskType, + SysFlowVariableType, + SysFlowWorkOrderStatus, + SysFlowCopyForType, + DiagramType, + FlowNodeType, + SysAutoCodeType, +}; diff --git a/OrangeFormsOpen-VUE3/src/common/staticDict/index.ts b/OrangeFormsOpen-VUE3/src/common/staticDict/index.ts new file mode 100644 index 00000000..fa4692eb --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/staticDict/index.ts @@ -0,0 +1,946 @@ +import { DictionaryBase } from './types'; + +const SysUserStatus = new DictionaryBase('用户状态', [ + { + id: 0, + name: '正常状态', + symbol: 'NORMAL', + }, + { + id: 1, + name: '锁定状态', + symbol: 'LOCKED', + }, +]); + +const SysUserType = new DictionaryBase('用户类型', [ + { + id: 0, + name: '管理员', + symbol: 'ADMIN', + }, + { + id: 1, + name: '系统操作员', + symbol: 'SYSTEM', + }, + { + id: 2, + name: '普通操作员', + symbol: 'OPERATOR', + }, +]); + +const SysOperationType = new DictionaryBase('操作日志操作类型', [ + { + id: 0, + name: '登录', + symbol: 'LOGIN', + }, + { + id: 1, + name: '手机登录', + symbol: 'MOBILE_LOGIN', + }, + { + id: 5, + name: '登出', + symbol: 'LOGOUT', + }, + { + id: 10, + name: '新增', + symbol: 'ADD', + }, + { + id: 15, + name: '修改', + symbol: 'UPDATE', + }, + { + id: 20, + name: '删除', + symbol: 'DELETE', + }, + { + id: 35, + name: '查询', + symbol: 'LIST', + }, + { + id: 40, + name: '分组查询', + symbol: 'LIST_WITH_GROUP', + }, + { + id: 45, + name: '导出', + symbol: 'EXPORT', + }, + { + id: 25, + name: '新增多对多关联', + symbol: 'ADD_M2M', + }, + { + id: 30, + name: '移除多对多关联', + symbol: 'DELETE_M2M', + }, + { + id: 50, + name: '上传', + symbol: 'UPLOAD', + }, + { + id: 55, + name: '下载', + symbol: 'DOWNLOAD', + }, + { + id: 60, + name: '重置缓存', + symbol: 'RELOAD_CACHE', + }, + { + id: 65, + name: '发布', + symbol: 'PUBLISH', + }, + { + id: 70, + name: '取消发布', + symbol: 'UNPUBLISH', + }, + { + id: 75, + name: '流程挂起', + symbol: 'SUSPEND', + }, + { + id: 80, + name: '流程恢复', + symbol: 'RESUME', + }, + { + id: 100, + name: '启动流程', + symbol: 'START_FLOW', + }, + { + id: 105, + name: '终止流程', + symbol: 'STOP_FLOW', + }, + { + id: 110, + name: '删除流程', + symbol: 'DELETE_FLOW', + }, + { + id: 115, + name: '撤销流程', + symbol: 'CANCEL_FLOW', + }, + { + id: 120, + name: '提交流程任务', + symbol: 'SUBMIT_TASK', + }, + { + id: 125, + name: '催办流程', + symbol: 'REMIND_TASK', + }, + { + id: 126, + name: '流程干预', + symbol: 'INTERVENE_FLOW', + }, + { + id: 127, + name: '流程数据补偿', + symbol: 'FIX_FLOW_BUSINESS_DATA', + }, +]); + +const SysPermModuleType = new DictionaryBase('权限分组类型', [ + { + id: 0, + name: '分组模块', + symbol: 'GROUP', + }, + { + id: 1, + name: '接口模块', + symbol: 'CONTROLLER', + }, +]); + +const SysPermCodeType = new DictionaryBase('权限字类型', [ + { + id: 0, + name: '表单', + symbol: 'FORM', + }, + { + id: 1, + name: '片段', + symbol: 'FRAGMENT', + }, + { + id: 2, + name: '操作', + symbol: 'OPERATION', + }, +]); + +/** + * 菜单类型 + * + * DIRECTORY(0: 目录) + * MENU(1: 表单) + * FRAGMENT(2: 片段) + * BUTTON(3: 按钮) + */ +const SysMenuType = new DictionaryBase('菜单类型', [ + { + id: 0, + name: '目录', + symbol: 'DIRECTORY', + }, + { + id: 1, + name: '表单', + symbol: 'MENU', + }, + { + id: 2, + name: '片段', + symbol: 'FRAGMENT', + }, + { + id: 3, + name: '按钮', + symbol: 'BUTTON', + }, +]); + +const MobileEntryType = new DictionaryBase('移动端首页配置项类型', [ + { + id: 0, + name: '轮播图', + symbol: 'BANNER', + }, + { + id: 1, + name: '九宫格', + symbol: 'SUDOKU', + }, + { + id: 2, + name: '分组', + symbol: 'GROUP', + }, +]); + +/** + * 菜单绑定类型 + * + * ROUTER(0: 路由菜单) + * ONLINE_FORM(1: 在线表单) + * WORK_ORDER(2: 工单列表) + * REPORT(3: 报表页面) + * THRID_URL(4: 外部链接) + */ +const SysMenuBindType = new DictionaryBase('菜单绑定类型', [ + { + id: 0, + name: '路由菜单', + symbol: 'ROUTER', + }, + { + id: 1, + name: '在线表单', + symbol: 'ONLINE_FORM', + }, + { + id: 2, + name: '工单列表', + symbol: 'WORK_ORDER', + }, + { + id: 3, + name: '报表页面', + symbol: 'REPORT', + }, + { + id: 4, + name: '外部链接', + symbol: 'THRID_URL', + }, +]); + +const SysDataPermType = new DictionaryBase('数据权限类型', [ + { + id: 0, + name: '查看全部', + symbol: 'ALL', + }, + { + id: 1, + name: '仅看自己', + symbol: 'ONLY_USER', + }, + { + id: 2, + name: '仅看所在部门', + symbol: 'ONLY_DEPT', + }, + { + id: 3, + name: '仅看所在部门及子部门', + symbol: 'ONLY_DEPT_AND_CHILD', + }, + { + id: 4, + name: '自选部门及子部门', + symbol: 'CUSTOM_DEPT_AND_CHILD', + }, + { + id: 5, + name: '仅自选部门', + symbol: 'CUSTOM_DEPT', + }, + { + id: 6, + name: '本部门用户', + symbol: 'DEPT_USER', + }, + { + id: 7, + name: '本部门及子部门用户', + symbol: 'DEPT_AND_CHILD_USER', + }, +]); + +const ScatterSymbolType = new DictionaryBase('纵轴位置', [ + { + id: 0, + name: '固定大小', + symbol: 'FIXED', + }, + { + id: 1, + name: '值大小', + symbol: 'VALUE', + }, +]); + +const SysCustomWidgetType = new DictionaryBase('组件类型', [ + { + id: 0, + name: '文本显示', + symbol: 'Label', + }, + { + id: 1, + name: '文本输入框', + symbol: 'Input', + }, + { + id: 3, + name: '数字输入框', + symbol: 'NumberInput', + }, + { + id: 4, + name: '数字范围输入框', + symbol: 'NumberRange', + }, + { + id: 5, + name: '开关组件', + symbol: 'Switch', + }, + { + id: 6, + name: '滑块组件', + symbol: 'Slider', + }, + { + id: 7, + name: '单选组件', + symbol: 'Radio', + }, + { + id: 8, + name: '复选框', + symbol: 'CheckBox', + }, + { + id: 10, + name: '下拉选择框', + symbol: 'Select', + }, + { + id: 12, + name: '级联选择框', + symbol: 'Cascader', + }, + { + id: 13, + name: '树形选择组件', + symbol: 'Tree', + }, + { + id: 14, + name: '评分组件', + symbol: 'Rate', + }, + { + id: 15, + name: '进步器', + symbol: 'Stepper', + }, + { + id: 16, + name: '日历组件', + symbol: 'Calendar', + }, + { + id: 20, + name: '日期选择框', + symbol: 'Date', + }, + { + id: 21, + name: '日期范围选择框', + symbol: 'DateRange', + }, + { + id: 30, + name: '颜色选择框', + symbol: 'ColorPicker', + }, + { + id: 31, + name: '上传组件', + symbol: 'Upload', + }, + { + id: 32, + name: '富文本编辑', + symbol: 'RichEditor', + }, + { + id: 40, + name: '分割线', + symbol: 'Divider', + }, + { + id: 41, + name: '文本', + symbol: 'Text', + }, + { + id: 42, + name: '图片', + symbol: 'Image', + }, + { + id: 43, + name: '超链接', + symbol: 'Link', + }, + { + id: 100, + name: '表格组件', + symbol: 'Table', + }, + { + id: 101, + name: '透视表', + symbol: 'PivotTable', + }, + { + id: 102, + name: '数据列表', + symbol: 'List', + }, + { + id: 103, + name: '查询列表', + symbol: 'QueryList', + }, + { + id: 104, + name: '工单列表', + symbol: 'WorkOrderList', + }, + { + id: 200, + name: '折线图', + symbol: 'LineChart', + }, + { + id: 201, + name: '柱状图', + symbol: 'BarChart', + }, + { + id: 202, + name: '饼图', + symbol: 'PieChart', + }, + { + id: 203, + name: '散点图', + symbol: 'ScatterChart', + }, + { + id: 204, + name: '普通表格', + symbol: 'DataViewTable', + }, + { + id: 205, + name: '轮播图', + symbol: 'Carousel', + }, + { + id: 206, + name: '富文本', + symbol: 'RichText', + }, + { + id: 207, + name: '仪表盘', + symbol: 'GaugeChart', + }, + { + id: 208, + name: '漏斗图', + symbol: 'FunnelChart', + }, + { + id: 209, + name: '雷达图', + symbol: 'RadarChart', + }, + { + id: 210, + name: '普通进度条', + symbol: 'ProgressBar', + }, + { + id: 211, + name: '环形进度条', + symbol: 'ProgressCircle', + }, + { + id: 212, + name: '通用卡片', + symbol: 'DataCard', + }, + { + id: 213, + name: '通用列表', + symbol: 'CommonList', + }, + { + id: 214, + name: '进度条卡片', + symbol: 'DataProgressCard', + }, + { + id: 300, + name: '基础块', + symbol: 'Block', + }, + { + id: 301, + name: '卡片组件', + symbol: 'Card', + }, + { + id: 302, + name: 'Tabs 组件', + symbol: 'Tabs', + }, + { + id: 303, + name: '图片卡片', + symbol: 'ImageCard', + }, + { + id: 304, + name: '分组容器', + symbol: 'CellGroup', + }, + { + id: 400, + name: '用户选择', + symbol: 'UserSelect', + }, + { + id: 401, + name: '部门选择', + symbol: 'DeptSelect', + }, + { + id: 402, + name: '关联选择', + symbol: 'DataSelect', + }, + { + id: 403, + name: '表格容器', + symbol: 'TableContainer', + }, + { + id: 500, + name: '单选过滤', + symbol: 'MobileRadioFilter', + }, + { + id: 501, + name: '多选过滤', + symbol: 'MobileCheckBoxFilter', + }, + { + id: 502, + name: '文本过滤', + symbol: 'MobileInputFilter', + }, + { + id: 503, + name: '开关过滤', + symbol: 'MobileSwitchFilter', + }, + { + id: 504, + name: '日期过滤', + symbol: 'MobileDateRangeFilter', + }, + { + id: 505, + name: '数字范围过滤', + symbol: 'MobileNumberRangeFilter', + }, +]); + +const OnlineFormEventType = new DictionaryBase('在线表单事件类型', [ + { + id: 'change', + name: '数据改变', + symbol: 'CHANGE', + }, + { + id: 'disable', + name: '是否禁用', + symbol: 'DISABLE', + }, + { + id: 'visible', + name: '是否可见', + symbol: 'VISIBLE', + }, + { + id: 'dropdownChange', + name: '下拉数据改变', + symbol: 'DROPDOWN_CHANGE', + }, + { + id: 'linkHerf', + name: '链接地址', + symbol: 'LINK_HERF', + }, + { + id: 'disabledDate', + name: '日期是否可用', + symbol: 'DISABLED_DATE', + }, + { + id: 'afterLoadTableData', + name: '表格加载数据后', + symbol: 'AFTER_LOAD_TABLE_DATA', + }, + { + id: 'beforeLoadTableData', + name: '表格加载数据前', + symbol: 'BEFORE_LOAD_TABLE_DATA', + }, + { + id: 'afterLoadFormData', + name: '页面加载数据后', + symbol: 'AFTER_LOAD_FORM_DATA', + }, + { + id: 'beforeLoadFormData', + name: '页面加载数据前', + symbol: 'BEFORE_LOAD_FORM_DATA', + }, + { + id: 'beforeCommitFormData', + name: '页面数据提交前', + symbol: 'BEFORE_COMMIT_FORM_DATA', + }, + { + id: 'formCreated', + name: '页面创建完毕', + symbol: 'AFTER_CREATE_FORM', + }, + { + id: 'tableOperationVisible', + name: '操作是否可见', + symbol: 'OPERATION_VISIBLE', + }, + { + id: 'tableOperationDisbled', + name: '操作是否禁用', + symbol: 'OPERATION_DISABLED', + }, +]); + +/** + * 表单类型 + * + * QUERY(1: 查询表单) + * ADVANCE_QUERY(2: 左树右表查询) + * ONE_TO_ONE_QUERY(3: 一对一查询) + * FORM(5: 编辑表单) + * FLOW(10: 流程表单) + * WORK_ORDER(11: 工单列表) + * REPORT(50: 报表页面) + */ +const SysOnlineFormType = new DictionaryBase('表单类型', [ + { + id: 1, + name: '查询表单', + symbol: 'QUERY', + }, + { + id: 2, + name: '左树右表查询', + symbol: 'ADVANCE_QUERY', + }, + { + id: 3, + name: '一对一查询', + symbol: 'ONE_TO_ONE_QUERY', + }, + { + id: 5, + name: '编辑表单', + symbol: 'FORM', + }, + { + id: 10, + name: '流程表单', + symbol: 'FLOW', + }, + { + id: 11, + name: '工单列表', + symbol: 'WORK_ORDER', + }, + { + id: 50, + name: '报表页面', + symbol: 'REPORT', + }, +]); + +const SysCustomWidgetOperationType = new DictionaryBase('操作类型', [ + { + id: 0, + name: '新建', + symbol: 'ADD', + }, + { + id: 1, + name: '编辑', + symbol: 'EDIT', + }, + { + id: 2, + name: '删除', + symbol: 'DELETE', + }, + { + id: 3, + name: '导出', + symbol: 'EXPORT', + }, + { + id: 10, + name: '批量删除', + symbol: 'BATCH_DELETE', + }, + { + id: 20, + name: '表单操作', + symbol: 'FORM', + }, + { + id: 22, + name: '复制', + symbol: 'COPY', + }, + { + id: 30, + name: '保存', + symbol: 'SAVE', + }, + { + id: 31, + name: '取消', + symbol: 'CANCEL', + }, + { + id: 50, + name: '脚本操作', + symbol: 'SCRIPT', + }, + { + id: 51, + name: '下钻事件', + symbol: 'DRILL', + }, + { + id: 52, + name: '路由跳转', + symbol: 'ROUTE', + }, +]); + +const OnlineSystemVariableType = new DictionaryBase('系统变量类型', [ + { + id: 0, + name: '登录用户', + symbol: 'CURRENT_USER', + }, + { + id: 1, + name: '所属部门', + symbol: 'CURRENT_DEPT', + }, + { + id: 10, + name: '当前日期', + symbol: 'CURRENT_DATE', + }, + { + id: 11, + name: '当前时间', + symbol: 'CURRENT_TIME', + }, + { + id: 20, + name: '流程发起人', + symbol: 'FLOW_CREATE_USER', + }, +]); + +const SysCustomWidgetBindDataType = new DictionaryBase('组件绑定数据类型', [ + { + id: 0, + name: '字段', + symbol: 'Column', + }, + { + id: 5, + name: '系统变量', + symbol: 'SYSTEM_VARIABLE', + }, + { + id: 10, + name: '自定义字段', + symbol: 'Custom', + }, + { + id: 20, + name: '固定值', + symbol: 'Fixed', + }, +]); + +const DirectionType = new DictionaryBase('方向', [ + { + id: 0, + name: '横轴', + symbol: 'HORIZONTAL', + }, + { + id: 1, + name: '纵轴', + symbol: 'VERTICAL', + }, +]); + +const DblinkType = new DictionaryBase('数据库连接类型', [ + { + id: 0, + name: 'MySQL', + symbol: 'MYSQL', + }, + /* + { + id: 1, + name: 'PostgreSQL', + symbol: 'POSTGRESQL', + }, + { + id: 2, + name: 'Oracle', + symbol: 'ORACLE', + }, + { + id: 3, + name: '达梦数据库', + symbol: 'DM_DB', + }, + { + id: 4, + name: '人大金仓', + symbol: 'KINGBASE', + }, + { + id: 5, + name: '华为高斯', + symbol: 'OPENGAUSS', + }, + { + id: 10, + name: 'ClickHouse', + symbol: 'CLICK_HOUSE', + }, + { + id: 11, + name: 'Doris', + symbol: 'DORIS', + }, + */ +]); + +export { + SysUserStatus, + SysUserType, + SysDataPermType, + SysOperationType, + SysPermModuleType, + SysPermCodeType, + SysMenuBindType, + MobileEntryType, + SysMenuType, + ScatterSymbolType, + SysCustomWidgetType, + OnlineFormEventType, + SysOnlineFormType, + SysCustomWidgetOperationType, + OnlineSystemVariableType, + SysCustomWidgetBindDataType, + DirectionType, + DblinkType, +}; diff --git a/OrangeFormsOpen-VUE3/src/common/staticDict/online.ts b/OrangeFormsOpen-VUE3/src/common/staticDict/online.ts new file mode 100644 index 00000000..7dda34c2 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/staticDict/online.ts @@ -0,0 +1,411 @@ +/** + * 在线表单常量字典 + */ +import { DictionaryBase } from './types'; + +const SysOnlineFieldKind = new DictionaryBase('字段类型', [ + { + id: 1, + name: '文件上传字段', + symbol: 'UPLOAD', + }, + { + id: 2, + name: '图片上传字段', + symbol: 'UPLOAD_IMAGE', + }, + { + id: 3, + name: '富文本字段', + symbol: 'RICH_TEXT', + }, + { + id: 4, + name: '多选字段', + symbol: 'MULTI_SELECT', + }, + { + id: 19, + name: '创建人部门', + symbol: 'CREATE_USER_DEPT_ID', + }, + { + id: 20, + name: '创建时间字段', + symbol: 'CREATE_TIME', + }, + { + id: 21, + name: '创建人字段', + symbol: 'CREATE_USER_ID', + }, + { + id: 22, + name: '更新时间字段', + symbol: 'UPDATE_TIME', + }, + { + id: 23, + name: '更新人字段', + symbol: 'UPDATE_USER_ID', + }, + { + id: 25, + name: '流程审批状态', + symbol: 'FLOW_APPROVAL_STATUS', + }, + { + id: 26, + name: '流程状态', + symbol: 'FLOW_FINISHED_STATUS', + }, + { + id: 31, + name: '逻辑删除字段', + symbol: 'LOGIC_DELETE', + }, +]); + +const SysOnlineDataPermFilterType = new DictionaryBase('数据权限过滤类型', [ + { + id: 1, + name: '用户过滤字段', + symbol: 'USER_FILTER', + }, + { + id: 2, + name: '部门过滤字段', + symbol: 'DEPT_FILTER', + }, +]); + +const SysOnlineRelationType = new DictionaryBase('关联类型', [ + { + id: 0, + name: '一对一关联', + symbol: 'ONE_TO_ONE', + }, + { + id: 1, + name: '一对多关联', + symbol: 'ONE_TO_MANY', + }, +]); + +const SysOnlineFormKind = new DictionaryBase('表单类别', [ + { + id: 1, + name: '弹出窗口', + symbol: 'DIALOG', + }, + { + id: 5, + name: '跳转页面', + symbol: 'PAGE', + }, +]); + +const SysOnlinePageType = new DictionaryBase('页面类型', [ + { + id: 1, + name: '业务页面', + symbol: 'BIZ', + }, + { + id: 10, + name: '流程页面', + symbol: 'FLOW', + }, +]); + +const SysOnlinePageStatus = new DictionaryBase('页面状态', [ + { + id: 0, + name: '基础信息录入', + symbol: 'BASIC', + }, + { + id: 1, + name: '数据模型录入', + symbol: 'DATASOURCE', + }, + { + id: 2, + name: '表单设计', + symbol: 'DESIGNING', + }, +]); + +const SysOnlineDictType = new DictionaryBase('字典类型', [ + { + id: 1, + name: '数据表字典', + symbol: 'TABLE', + }, + { + id: 5, + name: 'URL字典', + symbol: 'URL', + }, + { + id: 10, + name: '静态字典', + symbol: 'STATIC', + }, + { + id: 20, + name: '编码字典', + symbol: 'CODE', + }, + { + id: 15, + name: '自定义字典', + symbol: 'CUSTOM', + }, +]); + +const SysOnlineRuleType = new DictionaryBase('验证规则类型', [ + { + id: 1, + name: '只允许整数', + symbol: 'INTEGER_ONLY', + }, + { + id: 2, + name: '只允许数字', + symbol: 'DIGITAL_ONLY', + }, + { + id: 3, + name: '只允许英文字符', + symbol: 'LETTER_ONLY', + }, + { + id: 4, + name: '范围验证', + symbol: 'RANGE', + }, + { + id: 5, + name: '邮箱格式验证', + symbol: 'EMAIL', + }, + { + id: 6, + name: '手机格式验证', + symbol: 'MOBILE', + }, + { + id: 100, + name: '自定义验证', + symbol: 'CUSTOM', + }, +]); + +const SysCustomWidgetBindValueType = new DictionaryBase('组件绑定值类型', [ + { + id: 1, + name: '字典数据', + symbol: 'DICT_DATA', + }, + { + id: 10, + name: '系统变量', + symbol: 'SYSTEM_VARIABLE', + }, + { + id: 20, + name: '自定义', + symbol: 'INPUT_DATA', + }, +]); + +const SysOnlineColumnFilterType = new DictionaryBase('过滤类型', [ + { + id: 0, + name: '无过滤', + symbol: 'NONE', + }, + { + id: 1, + name: '普通过滤', + symbol: 'EQUAL_FILTER', + }, + { + id: 2, + name: '范围过滤', + symbol: 'RANFGE_FILTER', + }, + { + id: 3, + name: '模糊过滤', + symbol: 'LIKE_FILTER', + }, + { + id: 4, + name: '多选过滤', + symbol: 'MULTI_SELECT_FILTER', + }, +]); + +const SysOnlinePageDatasourceFieldStatus = new DictionaryBase('数据表状态', [ + { + id: 0, + name: '已删除', + symbol: 'DELETED', + }, + { + id: 1, + name: '已使用', + symbol: 'USED', + }, + { + id: 0, + name: '未使用', + symbol: 'UNUSED', + }, +]); + +const SysOnlinePageSettingStep = new DictionaryBase('在线表单编辑步骤', [ + { + id: 0, + name: '编辑基础信息', + symbol: 'BASIC', + }, + { + id: 1, + name: '编辑数据模型', + symbol: 'DATASOURCE', + }, + { + id: 2, + name: '设计表单', + symbol: 'FORM_DESIGN', + }, +]); + +const SysOnlineParamValueType = new DictionaryBase('参数值类型', [ + { + id: 1, + name: '数据字段', + symbol: 'TABLE_COLUMN', + }, + { + id: 2, + name: '静态字典', + symbol: 'STATIC_DICT', + }, + { + id: 3, + name: '直接输入', + symbol: 'INPUT_VALUE', + }, +]); + +const SysOnlineAggregationType = new DictionaryBase('字段聚合类型', [ + { + id: 0, + name: '总数', + symbol: 'SUM', + }, + { + id: 1, + name: '个数', + symbol: 'COUNT', + }, + { + id: 2, + name: '平均数', + symbol: 'AVG', + }, + { + id: 3, + name: '最小值', + symbol: 'MIN', + }, + { + id: 4, + name: '最大值', + symbol: 'MAX', + }, +]); + +const SysOnlineFilterOperationType = new DictionaryBase('过滤条件操作类型', [ + { + id: 0, + name: ' = ', + symbol: 'EQUAL', + }, + { + id: 1, + name: ' != ', + symbol: 'NOT_EQUAL', + }, + { + id: 2, + name: ' >= ', + symbol: 'GREATER_THAN_OR_EQUAL', + }, + { + id: 3, + name: ' > ', + symbol: 'GREATER_THAN', + }, + { + id: 4, + name: ' <= ', + symbol: 'LESS_THAN_OR_EQUAL', + }, + { + id: 5, + name: ' < ', + symbol: 'LESS_THAN', + }, + { + id: 6, + name: ' like ', + symbol: 'LIKE', + }, + { + id: 7, + name: ' not null ', + symbol: 'NOT_NULL', + }, + { + id: 8, + name: ' is null ', + symbol: 'IS_NULL', + }, +]); + +const SysOnlineVirtualColumnFilterValueType = new DictionaryBase('虚拟字段过滤值类型', [ + { + id: 0, + name: '输入值', + symbol: 'CUSTOM_INPUT', + }, + { + id: 1, + name: '静态字典', + symbol: 'STATIC_DICT', + }, +]); + +export { + SysOnlineFieldKind, + SysOnlineDataPermFilterType, + SysOnlineRelationType, + SysOnlineFormKind, + SysOnlinePageType, + SysOnlinePageStatus, + SysOnlineDictType, + SysOnlineRuleType, + SysCustomWidgetBindValueType, + SysOnlineColumnFilterType, + SysOnlinePageSettingStep, + SysOnlinePageDatasourceFieldStatus, + SysOnlineParamValueType, + SysOnlineAggregationType, + SysOnlineFilterOperationType, + SysOnlineVirtualColumnFilterValueType, +}; diff --git a/OrangeFormsOpen-VUE3/src/common/staticDict/types.ts b/OrangeFormsOpen-VUE3/src/common/staticDict/types.ts new file mode 100644 index 00000000..30035f6b --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/staticDict/types.ts @@ -0,0 +1,78 @@ +/** + * 字典数据类型 + */ +export type DictDataIdType = string | number; +export type DictDataPropertyType = string | number | undefined | boolean; + +export type DictData = { + id: DictDataIdType; + name: string; + symbol?: string; + [key: string]: DictDataPropertyType; +}; +/** + * 常量字典数据 + */ +export class DictionaryBase extends Map { + public showName: string; + // 动态属性 + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [name: string]: any; + + constructor(name: string, dataList: DictData[], keyId = 'id', symbolId = 'symbol') { + super(); + this.showName = name; + this.setList(dataList, keyId, symbolId); + } + + setList(dataList: DictData[], keyId = 'id', symbolId = 'symbol') { + this.clear(); + if (Array.isArray(dataList)) { + dataList.forEach(item => { + this.set(item[keyId] as DictDataIdType, item); + if (item[symbolId] != null) { + Object.defineProperty(this, item[symbolId] as PropertyKey, { + get: function () { + return item[keyId]; + }, + }); + } + }); + } + } + + getList( + valueId = 'name', + parentIdKey = 'parentId', + filter?: (o: DictData) => DictData, + ): DictData[] { + const temp: DictData[] = []; + this.forEach((value, key: DictDataPropertyType) => { + let obj: DictData = { + id: key as string | number, + name: typeof value === 'string' ? value : String(value[valueId]), + parentId: value[parentIdKey], + }; + if (typeof value !== 'string') { + obj = { + ...value, + ...obj, + }; + } + if (typeof filter !== 'function' || filter(obj)) { + temp.push(obj); + } + }); + + return temp; + } + + getValue(id: DictDataIdType, valueId = 'name'): string { + // 如果id为boolean类型,则自动转换为0和1 + if (typeof id === 'boolean') { + id = id ? 1 : 0; + } + const obj = this.get(id); + return obj == null ? '' : (obj[valueId] as string); + } +} diff --git a/OrangeFormsOpen-VUE3/src/common/types/list.d.ts b/OrangeFormsOpen-VUE3/src/common/types/list.d.ts new file mode 100644 index 00000000..51623e14 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/types/list.d.ts @@ -0,0 +1,21 @@ +/** + * 列表数据 + * + * @param dataList 数据集合 + */ +export interface ListData { + dataList: T[]; +} +/** + * 下拉列表初始化参数 + * @param loadData 加载数据函数 + * @param isTree 是否树型数据 + * @param idKey ID字段名,默认:id + * @param parentIdKey 父ID字段名,默认:parentId + */ +export interface DropdownOptions { + loadData: () => Promise>; + isTree?: boolean; + idKey?: string; + parentIdKey?: string; +} diff --git a/OrangeFormsOpen-VUE3/src/common/types/pagination.d.ts b/OrangeFormsOpen-VUE3/src/common/types/pagination.d.ts new file mode 100644 index 00000000..dd8daabf --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/types/pagination.d.ts @@ -0,0 +1,53 @@ +/** + * 分页参数 + * @param pageNum 查询页 + * @param pagesize 分页大小 + */ +export interface PageParam { + pageNum: number; + pageSize: number; +} +/** + * 排序参数 + * @param fieldName 排序字段名 + * @param asc 是否正序 + * @param dateAggregateBy 默认排序字段的日期统计类型 + */ +export interface OrderInfo { + fieldName?: string; + asc?: boolean; + dateAggregateBy?: string; +} + +/** + * 分页查询请求参数 + * @param pageParam 分页参数 + * @param orderParam 排序参数 + */ +export interface RequestParam { + pageParam?: PageParam; + orderParam?: OrderInfo[]; +} + +/** + * 表格初始化参数 + * + * @param loadTableData 表数据获取函数,返回Promise + * @param verifyTableParameter 表数据获取检验函数 + * @param paged 是否支持分页 + * @param rowSelection 是否支持行选择 + * @param orderFieldName 默认排序字段 + * @param ascending 默认排序方式(true为正序,false为倒序),默认值:true + * @param dateAggregateBy 默认排序字段的日期统计类型 + * @param pageSize 分页大小,默认值:10 + */ +export type TableOptions = { + loadTableData: (params: RequestParam) => Promise>; + verifyTableParameter?: () => boolean; + paged?: boolean; + rowSelection?: boolean; + orderFieldName?: string; + ascending?: boolean; + dateAggregateBy?: string; + pageSize?: number; +}; diff --git a/OrangeFormsOpen-VUE3/src/common/types/sortinfo.d.ts b/OrangeFormsOpen-VUE3/src/common/types/sortinfo.d.ts new file mode 100644 index 00000000..357d19a9 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/types/sortinfo.d.ts @@ -0,0 +1,5 @@ +export interface SortInfo { + prop?: string; + field?: string; + order: string; +} diff --git a/OrangeFormsOpen-VUE3/src/common/types/table.d.ts b/OrangeFormsOpen-VUE3/src/common/types/table.d.ts new file mode 100644 index 00000000..6973d219 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/types/table.d.ts @@ -0,0 +1,11 @@ +import { ListData } from './list'; + +/** + * 表格数据 + * + * @param dataList 数据集合 + * @param totalCount 数据集合总数 + */ +export interface TableData extends ListData { + totalCount: number; +} diff --git a/OrangeFormsOpen-VUE3/src/common/utils/index.ts b/OrangeFormsOpen-VUE3/src/common/utils/index.ts new file mode 100644 index 00000000..d5fd7408 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/utils/index.ts @@ -0,0 +1,664 @@ +import { JSEncrypt } from 'jsencrypt'; +import dayjs from 'dayjs'; +import { ANY_OBJECT } from '@/types/generic'; + +/** + * 列表数据转换树形数据 + * @param {Array} data 要转换的列表 + * @param {String} id 主键字段字段名 + * @param {String} pid 父字段字段名 + * @returns {Array} 转换后的树数据 + */ +export function treeDataTranslate(data: Array, id = 'id', pid = 'parentId'): D[] { + const res: D[] = []; + const temp: ANY_OBJECT = {}; + const dataList: ANY_OBJECT[] = data.map(item => { + return { ...item } as ANY_OBJECT; + }); + for (let i = 0; i < dataList.length; i++) { + const d = dataList[i]; + if (d) { + temp[d[id]] = dataList[i]; + } + } + for (let k = 0; k < dataList.length; k++) { + const d = dataList[k]; + if (d) { + if (temp[d[pid]] && d[id] !== d[pid]) { + if (!temp[d[pid]]['children']) { + temp[d[pid]]['children'] = []; + } + if (!temp[d[pid]]['_level']) { + temp[d[pid]]['_level'] = 1; + } + d['_level'] = temp[d[pid]]._level + 1; + d['_parent'] = d[pid]; + temp[d[pid]]['children'].push(d); + } else { + res.push(d as D); + } + } + } + + return res; +} +/** + * 获取字符串字节长度(中文算2个字符) + * @param {String} str 要获取长度的字符串 + */ +export function getStringLength(str: string) { + return str.replace(/[\u4e00-\u9fa5\uff00-\uffff]/g, '**').length; +} +/** + * 获取uuid + */ +export function getUUID(): string { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => { + const random: number = Math.random() * 16; + return (c === 'x' ? random : (random & 0x3) | 0x8).toString(16); + }); +} + +export function stringCase(str: string, type: number) { + if (str == null || str === '') return str; + if (type === 0) { + // 首字母小写 + return str.slice(0, 1).toLowerCase() + str.slice(1); + } else { + // 首字母大写 + return str.slice(0, 1).toUpperCase() + str.slice(1); + } +} + +/** + * 大小驼峰变换函数 + * @param name 要转换的字符串 + * @param type 转换的类型0:转换成小驼峰,1:转换成大驼峰 + */ +export function nameTranslate(name: string, type: 0 | 1) { + name = name.toLowerCase(); + let nameArray = name.split('_'); + nameArray.forEach((item, index) => { + if (index === 0) { + name = type === 1 ? item.slice(0, 1).toUpperCase() + item.slice(1) : item; + } else { + name = name + item.slice(0, 1).toUpperCase() + item.slice(1); + } + }); + + nameArray = name.split('-'); + nameArray.forEach((item, index) => { + if (index === 0) { + name = type === 1 ? item.slice(0, 1).toUpperCase() + item.slice(1) : item; + } else { + name = name + item.slice(0, 1).toUpperCase() + item.slice(1); + } + }); + return name; +} +/** + * 通过id从树中获取指定的节点 + * @param {Object} node 根节点 + * @param {String|Nubmer} id 键值 + * @param {Array} list 保存查询路径 + * @param {String} idKey 主键字段名 + * @param {String} childKey 子节点字段名 + */ +function findNode( + node: ANY_OBJECT, + id: string | number | undefined, + list?: Array | undefined, + idKey = 'id', + childKey = 'children', +): ANY_OBJECT | undefined { + if (Array.isArray(list)) list.push(node); + if (node[idKey] === id) { + return node; + } + + if (node[childKey] != null && Array.isArray(node[childKey])) { + for (let i = 0; i < node[childKey].length; i++) { + const tempNode: ANY_OBJECT | undefined = findNode( + node[childKey][i], + id, + list, + idKey, + childKey, + ); + if (tempNode) return tempNode; + } + } + + if (Array.isArray(list)) list.pop(); +} +/** + * 通过id返回从根节点到指定节点的路径 + * @param {Array} treeRoot 树根节点数组 + * @param {*} id 要查询的节点的id + * @param {*} idKey 主键字段名 + * @param {*} childKey 子节点字段名 + */ +export function findTreeNodeObjectPath( + treeRoot: ANY_OBJECT, + id: string | number | undefined, + idKey = 'id', + childKey = 'children', +) { + const tempList: ANY_OBJECT[] = []; + for (let i = 0; i < treeRoot.length; i++) { + if (findNode(treeRoot[i], id, tempList, idKey, childKey)) { + return tempList; + } + } + + return []; +} + +export function findTreeNodePath( + treeRoot: Array, + id: string | number | undefined, + idKey = 'id', + childKey = 'children', +): Array { + return (findTreeNodeObjectPath(treeRoot, id, idKey, childKey) || []).map(item => item[idKey]); +} + +/** + * 通过id从树中查找节点 + * @param {Array} treeRoot 根节点数组 + * @param {*} id 要查找的节点的id + * @param {*} idKey 主键字段名 + * @param {*} childKey 子节点字段名 + */ +export function findTreeNode( + treeRoot: ANY_OBJECT, + id: string, + idKey = 'id', + childKey = 'children', +) { + for (let i = 0; i < treeRoot.length; i++) { + const tempNode = findNode(treeRoot[i], id, undefined, idKey, childKey); + if (tempNode) return tempNode; + } +} + +export function traverseTree( + root: ANY_OBJECT, + callback: (node: ANY_OBJECT) => void, + childKey = 'children', +) { + function traverseNode(node: ANY_OBJECT) { + if (typeof callback === 'function') callback(node); + if (Array.isArray(node[childKey])) { + node[childKey].forEach((suNode: ANY_OBJECT) => { + traverseNode(suNode); + }); + } + } + if (Array.isArray(root)) { + root.forEach(node => { + traverseNode(node); + }); + } +} + +/** + * 把Object转换成query字符串 + * @param {Object} params 要转换的Object + */ +export function objectToQueryString(params: ANY_OBJECT | null) { + if (params == null) { + return null; + } else { + return Object.keys(params) + .map(key => { + if (params[key] !== undefined) { + return `${key}=${params[key]}`; + } else { + return undefined; + } + }) + .filter(item => item != null) + .join('&'); + } +} +/** + * 从数组中查找某一项 + * @param {Array} list 要查找的数组 + * @param {String} id 要查找的节点id + * @param {String} idKey 主键字段名(如果为null则直接比较) + * @param {Boolean} removeItem 是否从数组中移除查找到的节点 + * @returns {Object} 找到返回节点,没找到返回undefined + */ +export function findItemFromList( + list: ANY_OBJECT[], + id: string | number | undefined | null, + idKey: string | null = null, + removeItem = false, +) { + if (Array.isArray(list) && list.length > 0 && id != null) { + for (let i = 0; i < list.length; i++) { + const item = list[i]; + if ( + ((idKey == null || idKey === '') && item.toString() === id) || + (idKey != null && item[idKey] === id) + ) { + if (removeItem) list.splice(i, 1); + return item; + } + } + } + return null; +} +/** + * 将数据保存到sessionStorage + * @param {*} key sessionStorage的键值 + * @param {*} value 要保存的数据 + */ +export function setObjectToSessionStorage(key: string, value: ANY_OBJECT) { + if (key == null || key === '') return false; + if (value == null) { + window.sessionStorage.removeItem(key); + return true; + } else { + const jsonObj = { + data: value, + }; + window.sessionStorage.setItem(key, JSON.stringify(jsonObj)); + return true; + } +} +/** + * 从sessionStorage里面获取数据 + * @param {String} key 键值 + * @param {*} defaultValue 默认值 + */ +export function getObjectFromSessionStorage(key: string, defaultValue: ANY_OBJECT): ANY_OBJECT { + let jsonObj = null; + try { + const val: string | null = sessionStorage.getItem(key); + if (val == null) return defaultValue; + jsonObj = JSON.parse(val); + jsonObj = (jsonObj || {}).data; + } catch (e) { + jsonObj = defaultValue; + } + return jsonObj != null ? jsonObj : defaultValue; +} +/** + * 判读字符串是否一个数字 + * @param {String} str 要判断的字符串 + */ +export function isNumber(str: string) { + const num = Number.parseFloat(str); + if (Number.isNaN(num)) return false; + return num.toString() === str; +} +/** + * 生成随机数 + * @param {Integer} min 随机数最小值 + * @param {Integer} max 随机数最大值 + */ +export function random(min: number, max: number) { + const base = Math.random(); + return min + base * (max - min); +} +/** + * 加密 + * @param {*} value 要加密的字符串 + */ +const publicKey = + 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCpC4QMnbTrQOFriJJCCFFWhlruBJThAEBfRk7pRx1jsAhyNVL3CqJb0tRvpnbCnJhrRAEPdgFHXv5A0RrvFp+5Cw7QoFH6O9rKB8+0H7+aVQeKITMUHf/XMXioymw6Iq4QfWd8RhdtM1KM6eGTy8aU7SO2s69Mc1LXefg/x3yw6wIDAQAB'; +export function encrypt(value: string): string | null { + if (value == null || value === '') return null; + const encrypt = new JSEncrypt(); + encrypt.setPublicKey(publicKey); + return encodeURIComponent(encrypt.encrypt(value)); +} + +export function getToken() { + return sessionStorage.getItem('token'); +} + +export function setToken(token: string | null | undefined) { + if (token == null || token === '') { + sessionStorage.removeItem('token'); + } else { + sessionStorage.setItem('token', token); + } +} + +export function getAppId() { + const appId = sessionStorage.getItem('appId'); + return appId != null ? appId : undefined; +} + +export function setAppId(appId: string | null | undefined) { + if (appId == null || appId === '') { + sessionStorage.removeItem('appId'); + } else { + sessionStorage.setItem('appId', appId); + } +} + +export function traversalTree( + treeNode: ANY_OBJECT, + callback: (treeNode: ANY_OBJECT) => void, + childrenKey = 'children', +) { + if ( + treeNode != null && + Array.isArray(treeNode[childrenKey]) && + treeNode[childrenKey].length > 0 + ) { + treeNode[childrenKey].forEach((childNode: ANY_OBJECT) => { + traversalTree(childNode, callback, childrenKey); + }); + } + return typeof callback === 'function' ? callback(treeNode) : undefined; +} + +export class TreeTableImpl { + private options; + private dataList; + private dataMap; + private checkedRows: Map | undefined; + + constructor( + dataList: Array, + options: { + idKey: string; + nameKey: string; + parentIdKey: string; + isLefeCallback: (item: ANY_OBJECT) => boolean | undefined; + checkStrictly: boolean; + }, + ) { + this.options = { + idKey: options ? options.idKey : 'id', + nameKey: options ? options.nameKey : 'name', + parentIdKey: options ? options.parentIdKey : 'parentId', + isLefeCallback: options ? options.isLefeCallback : undefined, + checkStrictly: options ? options.checkStrictly : false, + }; + + this.dataList = Array.isArray(dataList) ? dataList : []; + this.dataMap = new Map(); + this.dataList.forEach(item => { + this.dataMap.set(item[this.options.idKey], item); + }); + // 表格选中行 + this.checkedRows = undefined; + this.onCheckedRowChange = this.onCheckedRowChange.bind(this); + } + + /** + * 过滤表格数据 + * @param {string} filterString 过滤条件字符串 + * @param {boolean} onlyChecked 是否只显示选中节点 + * @returns {array} 过滤后的表格数据列表 + */ + getFilterTableData(filterString: string | null, onlyChecked = false) { + const { idKey, nameKey, parentIdKey, isLefeCallback } = this.options; + const tempMap = new Map(); + const parentIdList: ANY_OBJECT[] = []; + this.dataList.forEach(item => { + if ( + (filterString == null || + filterString === '' || + item[nameKey].indexOf(filterString) !== -1) && + (!onlyChecked || (this.checkedRows != null && this.checkedRows.get(item[idKey]))) + ) { + if (!isLefeCallback || !isLefeCallback(item)) { + parentIdList.push(item[idKey]); + } + // 将命中节点以及它的父节点都设置为命中 + let tempItem = item; + do { + tempMap.set(tempItem[idKey], tempItem); + tempItem = this.dataMap.get(tempItem[parentIdKey]); + } while (tempItem != null); + } + }); + + return this.dataList.map(item => { + let disabled = true; + + if (parentIdList.indexOf(item[parentIdKey]) !== -1 || tempMap.get(item[idKey]) != null) { + if ( + parentIdList.indexOf(item[parentIdKey]) !== -1 && + (isLefeCallback == null || !isLefeCallback(item)) + ) { + parentIdList.push(item[idKey]); + } + disabled = false; + } + + return { + ...item, + __disabled: disabled, + }; + }); + } + + /** + * 获取表格树数据,计算选中状态 + * @param {array} dataList 表格列表数据 + */ + getTableTreeData(dataList: ANY_OBJECT[], checkedRows: Map) { + const { idKey, parentIdKey, checkStrictly } = this.options; + let treeData: ANY_OBJECT[] = []; + function calcPermCodeTreeAttribute(treeNode: ANY_OBJECT, checkedRows: Map) { + const checkedItem = checkedRows == null ? null : checkedRows.get(treeNode[idKey]); + treeNode.__checked = checkedItem != null; + // 是否所有子权限字都被选中 + let allChildChecked = true; + // 是否任意子权限字被选中 + let hasChildChecked = false; + // 如果存在子权限字 + if (Array.isArray(treeNode.children) && treeNode.children.length > 0) { + treeNode.children.forEach((item: ANY_OBJECT) => { + const isChecked = calcPermCodeTreeAttribute(item, checkedRows); + hasChildChecked = hasChildChecked || isChecked; + allChildChecked = allChildChecked && isChecked; + }); + } else { + allChildChecked = false; + } + treeNode.__indeterminate = !checkStrictly && hasChildChecked && !allChildChecked; + treeNode.__checked = treeNode.__checked || (allChildChecked && !checkStrictly); + return treeNode.__checked || treeNode.__indeterminate; + } + + if (Array.isArray(dataList)) { + treeData = treeDataTranslate( + dataList.map(item => { + return { ...item }; + }), + idKey, + parentIdKey, + ); + treeData.forEach(item => { + calcPermCodeTreeAttribute(item, checkedRows); + }); + } + + return treeData; + } + + /** + * 树表格行选中状态改变 + * @param {object} row 选中状态改变行数据 + */ + onCheckedRowChange(row: ANY_OBJECT) { + if (this.checkedRows == null) { + this.checkedRows = new Map(); + } else { + const temp = new Map(); + this.checkedRows.forEach((item, key) => { + temp.set(key, item); + }); + this.checkedRows = temp; + } + const { idKey } = this.options; + if (!row.__checked || row.__indeterminate) { + // 节点之前未被选中或者之前为半选状态,修改当前节点以及子节点为选中状态 + this.checkedRows.set(row[idKey], row); + if (Array.isArray(row.children) && !this.options.checkStrictly) { + row.children.forEach((childNode: ANY_OBJECT) => { + traversalTree(childNode, node => { + this.checkedRows?.set(node[idKey], node); + }); + }); + } + } else { + // 节点之前为选中状态,修改节点以及子节点为未选中状态 + this.checkedRows.delete(row[idKey]); + if (Array.isArray(row.children) && !this.options.checkStrictly) { + row.children.forEach((childNode: ANY_OBJECT) => { + traversalTree(childNode, node => { + this.checkedRows?.delete(node[idKey]); + }); + }); + } + } + } + + /** + * 获取所有选中的权限字节点 + * @param {array} treeData 树数据 + * @param {boolean} includeHalfChecked 是否包含半选节点,默认为false + * @returns {array} 选中节点列表 + */ + getCheckedRows(treeData: ANY_OBJECT, includeHalfChecked = false) { + const checkedRows: ANY_OBJECT[] = []; + + function traversalCallback(node: ANY_OBJECT) { + if (node == null) return; + if (node.__checked || (includeHalfChecked && node.__indeterminate)) { + checkedRows.push(node); + } + } + + if (Array.isArray(treeData) && treeData.length > 0) { + treeData.forEach(permCode => { + traversalTree(permCode, traversalCallback, 'children'); + }); + } + + return checkedRows; + } + + /** + * 设置选中节点 + * @param {array} checkedRows + */ + setCheckedRows(checkedRows: ANY_OBJECT[]) { + this.checkedRows = new Map(); + if (Array.isArray(checkedRows)) { + checkedRows.forEach(item => { + const node = this.dataMap.get(item[this.options.idKey]); + if (node != null) { + this.checkedRows?.set(node[this.options.idKey], node); + } + }); + } + } + /** + * 根据id获取表格行 + * @param {*} id + */ + getTableRow(id: string) { + return this.dataMap.get(id); + } +} + +export function formatDate( + date: string | number | Date | dayjs.Dayjs | null | undefined, + formatString: string | undefined, +) { + return dayjs(date).format(formatString); +} + +export function parseDate(date: string | number | Date, formatString: string | undefined) { + return dayjs(date, formatString); +} + +export function fileToBase64(file: File) { + return new Promise((resolve, reject) => { + if (file == null) return reject(); + const reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = e => { + console.log('file loaded', e); + resolve(e.target?.result as string); + }; + reader.onerror = e => { + console.warn('file load', e); + reject(e); + }; + }); +} + +export function getObjectValue(data: ANY_OBJECT, fieldName: string) { + if (data == null) return undefined; + if (fieldName == null || fieldName === '') return data; + const fieldPath = fieldName.split('.'); + let tempValue = data; + if (Array.isArray(fieldPath)) { + fieldPath.forEach(key => { + if (tempValue != null) { + tempValue = tempValue[key]; + } + }); + } + + return tempValue; +} + +// 判断输入值是否一个Object +export function isObject(obj: ANY_OBJECT) { + return obj != null && typeof obj === 'object' && obj.toString() === '[object Object]'; +} + +function copyObject(obj: ANY_OBJECT): ANY_OBJECT { + if (obj == null) return obj; + return JSON.parse(JSON.stringify(obj)); +} + +export function deepMerge(obj1: ANY_OBJECT, obj2: ANY_OBJECT) { + const tempObj = copyObject(obj1); + if (obj2 != null) { + Object.keys(obj2).forEach(key => { + const val2 = obj2[key]; + const val1 = tempObj[key]; + if (isObject(val2)) { + // 如果两个值都是对象,则递归合并 + if (isObject(val1)) { + tempObj[key] = deepMerge(val1, val2); + } else { + tempObj[key] = copyObject(val2); + } + } else if (Array.isArray(val2)) { + //console.log('......deepMerge.......', val1, val2, obj1, obj2); + // 如果两个值都是数组,则合并数组 + if (Array.isArray(val1)) { + tempObj[key] = val2.map((arrVal2, index) => { + const arrVal1 = val1[index]; + if (isObject(arrVal1)) { + return deepMerge(arrVal1, arrVal2); + } else { + return arrVal2; + } + }); + } else { + tempObj[key] = copyObject(val2); + } + } else { + // 直接覆盖 + tempObj[key] = val2; + } + }); + } + return tempObj; +} diff --git a/OrangeFormsOpen-VUE3/src/common/utils/validate.ts b/OrangeFormsOpen-VUE3/src/common/utils/validate.ts new file mode 100644 index 00000000..1578f39c --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/common/utils/validate.ts @@ -0,0 +1,30 @@ +export const pattern = { + mobie: + /^((\+?86)|(\(\+86\)))?(13[012356789][0-9]{8}|15[012356789][0-9]{8}|17[012356789][0-9]{8}|19[012356789][0-9]{8}|18[02356789][0-9]{8}|147[0-9]{8}|1349[0-9]{7})$/, + english: /^[a-zA-Z]+$/, + englishAndNumber: /^[a-zA-Z0-9]+$/, +}; + +/** + * 邮箱 + * @param str + */ +export function isEmail(str: string) { + return /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/.test(str); +} + +/** + * 手机号码 + * @param str + */ +export function isMobile(str: string) { + return pattern.mobie.test(str); +} + +/** + * 电话号码 + * @param str + */ +export function isPhone(str: string) { + return /^([0-9]{3,4}-)?[0-9]{7,8}$/.test(str); +} diff --git a/OrangeFormsOpen-VUE3/src/components/AdvanceQuery/index.vue b/OrangeFormsOpen-VUE3/src/components/AdvanceQuery/index.vue new file mode 100644 index 00000000..835caad4 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/AdvanceQuery/index.vue @@ -0,0 +1,240 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/components/Btns/RightAddBtn.vue b/OrangeFormsOpen-VUE3/src/components/Btns/RightAddBtn.vue new file mode 100644 index 00000000..16858b89 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/Btns/RightAddBtn.vue @@ -0,0 +1,44 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/components/DateRange/index.vue b/OrangeFormsOpen-VUE3/src/components/DateRange/index.vue new file mode 100644 index 00000000..29187c78 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/DateRange/index.vue @@ -0,0 +1,271 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/components/DeptSelect/DeptSelectDlg.vue b/OrangeFormsOpen-VUE3/src/components/DeptSelect/DeptSelectDlg.vue new file mode 100644 index 00000000..d15c38c1 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/DeptSelect/DeptSelectDlg.vue @@ -0,0 +1,240 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/components/DeptSelect/index.vue b/OrangeFormsOpen-VUE3/src/components/DeptSelect/index.vue new file mode 100644 index 00000000..0504fc74 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/DeptSelect/index.vue @@ -0,0 +1,211 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/components/Dialog/index.ts b/OrangeFormsOpen-VUE3/src/components/Dialog/index.ts new file mode 100644 index 00000000..dd1482be --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/Dialog/index.ts @@ -0,0 +1,164 @@ +import { layer } from '@layui/layui-vue'; +import { Component } from 'vue'; +import { ANY_OBJECT } from '@/types/generic'; +import { getAppId, getToken, getUUID } from '@/common/utils'; +import { DialogProp } from './types'; +import Layout from './layout.vue'; + +const LAYER_Z_INDEX = 500; + +export class Dialog { + private static index = 0; + + static closeAll = () => { + layer.closeAll(); + Dialog.index = 0; + }; + + // 未提供单独关闭某个对话框的方法,涉及到z-index的变化规则,若需提供,须考虑z-index的变化规则 + // options可参考:http://www.layui-vue.com/zh-CN/components/layer 和 https://layui.dev/docs/2/layer/#options + + /** + * 打开弹窗 + * @param {*} title 弹窗标题 + * @param {*} component 弹窗内容的组件 + * @param {*} options 弹窗设置(详情请见layui官网 http://www.layui-vue.com/zh-CN/components/layer 和 https://layui.dev/docs/2/layer/#options) + * @param {*} params 弹窗组件参数 + * @param {*} thirdPartyOptions 第三方接入参数 + * @param {*} thirdPartyOptions.pathName 接入路由name + * @param {*} thirdPartyOptions.width 弹窗宽度 + * @param {*} thirdPartyOptions.height 弹窗高度 + */ + static show = ( + title: string, + component: Component | string, + options?: ANY_OBJECT, + params?: ANY_OBJECT, + thirdPartyOptions?: ANY_OBJECT, + ) => { + // 调用第三方弹窗方法 + if (getAppId() != null && getAppId() !== '') { + if (thirdPartyOptions && window.parent) { + showDialog(title, params, thirdPartyOptions); + return new Promise((resolve, reject) => { + const eventListener = (e: ANY_OBJECT) => { + if (e.data.type === 'refreshData') { + console.log('第三方弹窗关闭后,回传的数据', e); + window.removeEventListener('message', eventListener); + resolve(e.data.data?.data as D); + } + }; + window.addEventListener('message', eventListener, false); + }); + } else { + console.warn('错误的第三方调用!'); + return Promise.reject('错误的第三方调用!'); + } + } + + return new Promise((resolve, reject) => { + const observer: DialogProp = { + index: '', + cancel: () => { + layer.close(observer.index); + reject({ message: 'canceled' }); + }, + submit: (data: D) => { + //console.log('dialog index', observer.index); + layer.close(observer.index); + resolve(data); + }, + }; + + let layerOptions = { + title: title, + type: 1, + skin: + 'layer-dialog ' + (window.innerWidth <= 1900 ? 'container-default' : 'container-large'), + resize: false, + offset: 'auto', + shadeClose: false, + content: '' as string | Component, + zIndex: LAYER_Z_INDEX + Dialog.index, + end: () => { + //console.log('layer end'); + Dialog.index--; + }, + }; + // end之后,要执行index-- + if (options && options.end) { + const end = options.end; + layerOptions.end = () => { + Dialog.index--; + if (typeof end == 'function') { + end(); + } + }; + } + + layerOptions = { ...layerOptions, ...options }; + + params = { ...params }; + params.dialog = observer; + + console.log('dialog params', params); + //layerOptions.content = h(component, params); + layerOptions.content = h(Layout, () => h(component, params)); + + const id = layer.open(layerOptions); + observer.index = id; + Dialog.index++; + }); + }; +} + +function showDialog(title: string, params?: ANY_OBJECT, options?: ANY_OBJECT) { + console.log('第三方弹窗', title, params, options); + // 调用第三方弹窗方法 + if (options && window.parent) { + const paramsCopy: ANY_OBJECT = {}; + if (params) { + for (const key in params) { + if (Object.prototype.hasOwnProperty.call(params, key)) { + const element = params[key]; + paramsCopy[key] = unref(element); + } + } + } + + const dialogKey = getUUID(); + const location = window.location; + let dlgUrl = + location.origin + + location.pathname + + '#' + + options.pathName + + '?appId=' + + getAppId() + + '&token=' + + getToken() + + '&dlgFullScreen=' + + (options.fullscreen ? '1' : '0') + + '&dialogKey=' + + dialogKey; + + dlgUrl += '&thirdParamsString=' + encodeURIComponent(JSON.stringify(paramsCopy)); + + const data = { + title: title, + dlgFullScreen: options.fullscreen, + width: options.width, + height: options.height, + top: options.top, + params: paramsCopy, + url: dlgUrl, + dialogKey: dialogKey, + }; + + const dlgOption = { + type: 'openDialog', + data: JSON.parse(JSON.stringify(data)), + }; + window.parent.postMessage(dlgOption, '*'); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/Dialog/layout.vue b/OrangeFormsOpen-VUE3/src/components/Dialog/layout.vue new file mode 100644 index 00000000..fdfac929 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/Dialog/layout.vue @@ -0,0 +1,7 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/components/Dialog/types.d.ts b/OrangeFormsOpen-VUE3/src/components/Dialog/types.d.ts new file mode 100644 index 00000000..70272132 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/Dialog/types.d.ts @@ -0,0 +1,5 @@ +export interface DialogProp { + index: string; + cancel: () => void; + submit: (data: T) => void; +} diff --git a/OrangeFormsOpen-VUE3/src/components/Dialog/useDialog.ts b/OrangeFormsOpen-VUE3/src/components/Dialog/useDialog.ts new file mode 100644 index 00000000..955876ee --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/Dialog/useDialog.ts @@ -0,0 +1,28 @@ +import { EpPropMergeType } from 'element-plus/es/utils/vue/props'; +import { Dialog } from '@/components/Dialog'; +import { ANY_OBJECT } from '@/types/generic'; + +export const useDialog = () => { + const defaultFormItemSize = inject< + EpPropMergeType | undefined + >('defaultFormItemSize', 'default'); + + const show = ( + title: string, + component: Component | string, + options?: ANY_OBJECT, + params?: ANY_OBJECT, + thirdPartyOptions?: ANY_OBJECT, + ) => { + if (!params) { + params = {}; + } + params.defaultFormItemSize = defaultFormItemSize; + + return Dialog.show(title, component, options, params, thirdPartyOptions); + }; + + return { + show, + }; +}; diff --git a/OrangeFormsOpen-VUE3/src/components/FilterBox/index.vue b/OrangeFormsOpen-VUE3/src/components/FilterBox/index.vue new file mode 100644 index 00000000..2f5fd0f5 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/FilterBox/index.vue @@ -0,0 +1,77 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/components/IconSelect/icon.json b/OrangeFormsOpen-VUE3/src/components/IconSelect/icon.json new file mode 100644 index 00000000..86cbda3f --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/IconSelect/icon.json @@ -0,0 +1,280 @@ +[ + "el-icon-delete-solid", + "el-icon-delete", + "el-icon-s-tools", + "el-icon-setting", + "el-icon-user-solid", + "el-icon-user", + "el-icon-phone", + "el-icon-phone-outline", + "el-icon-more", + "el-icon-more-outline", + "el-icon-star-on", + "el-icon-star-off", + "el-icon-s-goods", + "el-icon-goods", + "el-icon-warning", + "el-icon-warning-outline", + "el-icon-question", + "el-icon-info", + "el-icon-remove", + "el-icon-circle-plus", + "el-icon-success", + "el-icon-error", + "el-icon-zoom-in", + "el-icon-zoom-out", + "el-icon-remove-outline", + "el-icon-circle-plus-outline", + "el-icon-circle-check", + "el-icon-circle-close", + "el-icon-s-help", + "el-icon-help", + "el-icon-minus", + "el-icon-plus", + "el-icon-check", + "el-icon-close", + "el-icon-picture", + "el-icon-picture-outline", + "el-icon-picture-outline-round", + "el-icon-upload", + "el-icon-upload2", + "el-icon-download", + "el-icon-camera-solid", + "el-icon-camera", + "el-icon-video-camera-solid", + "el-icon-video-camera", + "el-icon-message-solid", + "el-icon-bell", + "el-icon-s-cooperation", + "el-icon-s-order", + "el-icon-s-platform", + "el-icon-s-fold", + "el-icon-s-unfold", + "el-icon-s-operation", + "el-icon-s-promotion", + "el-icon-s-home", + "el-icon-s-release", + "el-icon-s-ticket", + "el-icon-s-management", + "el-icon-s-open", + "el-icon-s-shop", + "el-icon-s-marketing", + "el-icon-s-flag", + "el-icon-s-comment", + "el-icon-s-finance", + "el-icon-s-claim", + "el-icon-s-custom", + "el-icon-s-opportunity", + "el-icon-s-data", + "el-icon-s-check", + "el-icon-s-grid", + "el-icon-menu", + "el-icon-share", + "el-icon-d-caret", + "el-icon-caret-left", + "el-icon-caret-right", + "el-icon-caret-bottom", + "el-icon-caret-top", + "el-icon-bottom-left", + "el-icon-bottom-right", + "el-icon-back", + "el-icon-right", + "el-icon-bottom", + "el-icon-top", + "el-icon-top-left", + "el-icon-top-right", + "el-icon-arrow-left", + "el-icon-arrow-right", + "el-icon-arrow-down", + "el-icon-arrow-up", + "el-icon-d-arrow-left", + "el-icon-d-arrow-right", + "el-icon-video-pause", + "el-icon-video-play", + "el-icon-refresh", + "el-icon-refresh-right", + "el-icon-refresh-left", + "el-icon-finished", + "el-icon-sort", + "el-icon-sort-up", + "el-icon-sort-down", + "el-icon-rank", + "el-icon-loading", + "el-icon-view", + "el-icon-c-scale-to-original", + "el-icon-date", + "el-icon-edit", + "el-icon-edit-outline", + "el-icon-folder", + "el-icon-folder-opened", + "el-icon-folder-add", + "el-icon-folder-remove", + "el-icon-folder-delete", + "el-icon-folder-checked", + "el-icon-tickets", + "el-icon-document-remove", + "el-icon-document-delete", + "el-icon-document-copy", + "el-icon-document-checked", + "el-icon-document", + "el-icon-document-add", + "el-icon-printer", + "el-icon-paperclip", + "el-icon-takeaway-box", + "el-icon-search", + "el-icon-monitor", + "el-icon-attract", + "el-icon-mobile", + "el-icon-scissors", + "el-icon-umbrella", + "el-icon-headset", + "el-icon-brush", + "el-icon-mouse", + "el-icon-coordinate", + "el-icon-magic-stick", + "el-icon-reading", + "el-icon-data-line", + "el-icon-data-board", + "el-icon-pie-chart", + "el-icon-data-analysis", + "el-icon-collection-tag", + "el-icon-film", + "el-icon-suitcase", + "el-icon-suitcase-1", + "el-icon-receiving", + "el-icon-collection", + "el-icon-files", + "el-icon-notebook-1", + "el-icon-notebook-2", + "el-icon-toilet-paper", + "el-icon-office-building", + "el-icon-school", + "el-icon-table-lamp", + "el-icon-house", + "el-icon-no-smoking", + "el-icon-smoking", + "el-icon-shopping-cart-full", + "el-icon-shopping-cart-1", + "el-icon-shopping-cart-2", + "el-icon-shopping-bag-1", + "el-icon-shopping-bag-2", + "el-icon-sold-out", + "el-icon-sell", + "el-icon-present", + "el-icon-box", + "el-icon-bank-card", + "el-icon-money", + "el-icon-coin", + "el-icon-wallet", + "el-icon-discount", + "el-icon-price-tag", + "el-icon-news", + "el-icon-guide", + "el-icon-male", + "el-icon-female", + "el-icon-thumb", + "el-icon-cpu", + "el-icon-link", + "el-icon-connection", + "el-icon-open", + "el-icon-turn-off", + "el-icon-set-up", + "el-icon-chat-round", + "el-icon-chat-line-round", + "el-icon-chat-square", + "el-icon-chat-dot-round", + "el-icon-chat-dot-square", + "el-icon-chat-line-square", + "el-icon-message", + "el-icon-postcard", + "el-icon-position", + "el-icon-turn-off-microphone", + "el-icon-microphone", + "el-icon-close-notification", + "el-icon-bangzhu", + "el-icon-time", + "el-icon-odometer", + "el-icon-crop", + "el-icon-aim", + "el-icon-switch-button", + "el-icon-full-screen", + "el-icon-copy-document", + "el-icon-mic", + "el-icon-stopwatch", + "el-icon-medal-1", + "el-icon-medal", + "el-icon-trophy", + "el-icon-trophy-1", + "el-icon-first-aid-kit", + "el-icon-discover", + "el-icon-place", + "el-icon-location", + "el-icon-location-outline", + "el-icon-location-information", + "el-icon-add-location", + "el-icon-delete-location", + "el-icon-map-location", + "el-icon-alarm-clock", + "el-icon-timer", + "el-icon-watch-1", + "el-icon-watch", + "el-icon-lock", + "el-icon-unlock", + "el-icon-key", + "el-icon-service", + "el-icon-mobile-phone", + "el-icon-bicycle", + "el-icon-truck", + "el-icon-ship", + "el-icon-basketball", + "el-icon-football", + "el-icon-soccer", + "el-icon-baseball", + "el-icon-wind-power", + "el-icon-light-rain", + "el-icon-lightning", + "el-icon-heavy-rain", + "el-icon-sunrise", + "el-icon-sunrise-1", + "el-icon-sunset", + "el-icon-sunny", + "el-icon-cloudy", + "el-icon-partly-cloudy", + "el-icon-cloudy-and-sunny", + "el-icon-moon", + "el-icon-moon-night", + "el-icon-dish", + "el-icon-dish-1", + "el-icon-food", + "el-icon-chicken", + "el-icon-fork-spoon", + "el-icon-knife-fork", + "el-icon-burger", + "el-icon-tableware", + "el-icon-sugar", + "el-icon-dessert", + "el-icon-ice-cream", + "el-icon-hot-water", + "el-icon-water-cup", + "el-icon-coffee-cup", + "el-icon-cold-drink", + "el-icon-goblet", + "el-icon-goblet-full", + "el-icon-goblet-square", + "el-icon-goblet-square-full", + "el-icon-refrigerator", + "el-icon-grape", + "el-icon-watermelon", + "el-icon-cherry", + "el-icon-apple", + "el-icon-pear", + "el-icon-orange", + "el-icon-coffee", + "el-icon-ice-tea", + "el-icon-ice-drink", + "el-icon-milk-tea", + "el-icon-potato-strips", + "el-icon-lollipop", + "el-icon-ice-cream-square", + "el-icon-ice-cream-round" +] diff --git a/OrangeFormsOpen-VUE3/src/components/IconSelect/index.vue b/OrangeFormsOpen-VUE3/src/components/IconSelect/index.vue new file mode 100644 index 00000000..a5afd369 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/IconSelect/index.vue @@ -0,0 +1,126 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/components/InputNumberRange/index.vue b/OrangeFormsOpen-VUE3/src/components/InputNumberRange/index.vue new file mode 100644 index 00000000..99fee02d --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/InputNumberRange/index.vue @@ -0,0 +1,236 @@ + + + + + + + + + diff --git a/OrangeFormsOpen-VUE3/src/components/MultiItemBox/index.vue b/OrangeFormsOpen-VUE3/src/components/MultiItemBox/index.vue new file mode 100644 index 00000000..20179a73 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/MultiItemBox/index.vue @@ -0,0 +1,175 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/components/MultiItemList/index.vue b/OrangeFormsOpen-VUE3/src/components/MultiItemList/index.vue new file mode 100644 index 00000000..58be52a4 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/MultiItemList/index.vue @@ -0,0 +1,213 @@ + + + + + + + diff --git a/OrangeFormsOpen-VUE3/src/components/PageCloseButton/index.vue b/OrangeFormsOpen-VUE3/src/components/PageCloseButton/index.vue new file mode 100644 index 00000000..3f81b7b8 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/PageCloseButton/index.vue @@ -0,0 +1,19 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/components/Progress/index.vue b/OrangeFormsOpen-VUE3/src/components/Progress/index.vue new file mode 100644 index 00000000..73d05be9 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/Progress/index.vue @@ -0,0 +1,36 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/components/RichEditor/index.vue b/OrangeFormsOpen-VUE3/src/components/RichEditor/index.vue new file mode 100644 index 00000000..1c2479dd --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/RichEditor/index.vue @@ -0,0 +1,171 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/algorithm/bitmap.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/algorithm/bitmap.js new file mode 100644 index 00000000..ba38da07 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/algorithm/bitmap.js @@ -0,0 +1,11 @@ +/* eslint no-bitwise: "off" */ +/* + v: int value + digit: bit len of v + flag: true or false +*/ +const bitmap = (v, digit, flag) => { + const b = 1 << digit; + return flag ? v | b : v ^ b; +}; +export default bitmap; diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/algorithm/expression.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/algorithm/expression.js new file mode 100644 index 00000000..e3cf8ae1 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/algorithm/expression.js @@ -0,0 +1,39 @@ +// src: include chars: [0-9], +, -, *, / +// // 9+(3-1)*3+10/2 => 9 3 1-3*+ 10 2/+ +const infix2suffix = src => { + const operatorStack = []; + const stack = []; + for (let i = 0; i < src.length; i += 1) { + const c = src.charAt(i); + if (c !== ' ') { + if (c >= '0' && c <= '9') { + stack.push(c); + } else if (c === ')') { + let c1 = operatorStack.pop(); + while (c1 !== '(') { + stack.push(c1); + c1 = operatorStack.pop(); + } + } else { + // priority: */ > +- + if (operatorStack.length > 0 && (c === '+' || c === '-')) { + const last = operatorStack[operatorStack.length - 1]; + if (last === '*' || last === '/') { + while (operatorStack.length > 0) { + stack.push(operatorStack.pop()); + } + } + } + operatorStack.push(c); + } + } + } + while (operatorStack.length > 0) { + stack.push(operatorStack.pop()); + } + return stack; +}; + +export default { + infix2suffix, +}; diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/assets/material_common_sprite82.svg b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/assets/material_common_sprite82.svg new file mode 100644 index 00000000..276826dd --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/assets/material_common_sprite82.svg @@ -0,0 +1,742 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diagram_icon_18dp + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Artboard 2 + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + + +slide_18_18 + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/assets/sprite.svg b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/assets/sprite.svg new file mode 100644 index 00000000..bb0a8f2c --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/assets/sprite.svg @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/canvas/draw.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/canvas/draw.js new file mode 100644 index 00000000..c743e52a --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/canvas/draw.js @@ -0,0 +1,507 @@ +const imageMap = new Map(); + +function dpr() { + return window.devicePixelRatio || 1; +} + +function thinLineWidth() { + return dpr() - 0.5; +} + +function npx(px) { + return parseInt(px * dpr(), 10); +} + +function npxLine(px) { + const n = npx(px); + return n > 0 ? n - 0.5 : 0.5; +} + +class DrawBox { + constructor(x, y, w, h, padding = 0) { + this.x = x; + this.y = y; + this.width = w; + this.height = h; + this.padding = padding; + this.bgcolor = '#ffffff'; + // border: [width, style, color] + this.borderTop = null; + this.borderRight = null; + this.borderBottom = null; + this.borderLeft = null; + } + + setBorders({ top, bottom, left, right }) { + if (top) this.borderTop = top; + if (right) this.borderRight = right; + if (bottom) this.borderBottom = bottom; + if (left) this.borderLeft = left; + } + + innerWidth() { + return this.width - this.padding * 2 - 2; + } + + innerHeight() { + return this.height - this.padding * 2 - 2; + } + + textx(align) { + const { width, padding } = this; + let { x } = this; + if (align === 'left') { + x += padding; + } else if (align === 'center') { + x += width / 2; + } else if (align === 'right') { + x += width - padding; + } + return x; + } + + texty(align, h) { + const { height, padding } = this; + let { y } = this; + if (align === 'top') { + y += padding; + } else if (align === 'middle') { + y += height / 2 - h / 2; + } else if (align === 'bottom') { + y += height - padding - h; + } + return y; + } + + topxys() { + const { x, y, width } = this; + return [ + [x, y], + [x + width, y], + ]; + } + + rightxys() { + const { x, y, width, height } = this; + return [ + [x + width, y], + [x + width, y + height], + ]; + } + + bottomxys() { + const { x, y, width, height } = this; + return [ + [x, y + height], + [x + width, y + height], + ]; + } + + leftxys() { + const { x, y, height } = this; + return [ + [x, y], + [x, y + height], + ]; + } +} + +function drawFontLine(type, tx, ty, align, valign, blheight, blwidth) { + const floffset = { x: 0, y: 0 }; + if (type === 'underline') { + if (valign === 'bottom') { + floffset.y = 0; + } else if (valign === 'top') { + floffset.y = -(blheight + 2); + } else { + floffset.y = -blheight / 2; + } + } else if (type === 'strike') { + if (valign === 'bottom') { + floffset.y = blheight / 2; + } else if (valign === 'top') { + floffset.y = -(blheight / 2 + 2); + } + } + + if (align === 'center') { + floffset.x = blwidth / 2; + } else if (align === 'right') { + floffset.x = blwidth; + } + this.line([tx - floffset.x, ty - floffset.y], [tx - floffset.x + blwidth, ty - floffset.y]); +} + +class Draw { + constructor(el, width, height) { + this.el = el; + this.ctx = el.getContext('2d'); + this.resize(width, height); + this.ctx.scale(dpr(), dpr()); + } + + resize(width, height) { + // console.log('dpr:', dpr); + this.el.style.width = `${width}px`; + this.el.style.height = `${height}px`; + this.el.width = npx(width); + this.el.height = npx(height); + } + + clear() { + const { width, height } = this.el; + this.ctx.clearRect(0, 0, width, height); + return this; + } + + attr(options) { + Object.assign(this.ctx, options); + return this; + } + + save() { + this.ctx.save(); + this.ctx.beginPath(); + return this; + } + + restore() { + this.ctx.restore(); + return this; + } + + beginPath() { + this.ctx.beginPath(); + return this; + } + + translate(x, y) { + this.ctx.translate(npx(x), npx(y)); + return this; + } + + scale(x, y) { + this.ctx.scale(x, y); + return this; + } + + clearRect(x, y, w, h) { + this.ctx.clearRect(x, y, w, h); + return this; + } + + fillRect(x, y, w, h) { + this.ctx.fillRect(npx(x) - 0.5, npx(y) - 0.5, npx(w), npx(h)); + return this; + } + + fillText(text, x, y) { + this.ctx.fillText(text, npx(x), npx(y)); + return this; + } + + /** + * ��ͼƬ�� + * @param {*} box - һ�� DrawBox ���� + * @param {string} src - ͼƬ��·�� + * @param {Object} fixedIndexWidth - ��������� + * @param {Object} fixedIndexHeight - ������߶� + */ + fillImage(box, { value: src }, { fixedIndexWidth, fixedIndexHeight }, scroll, celldata) { + if (!celldata.imagewidth) { + return; + } + if (celldata.value == '' || celldata.value == undefined) { + imageMap.forEach((value, key) => { + if (value[0] === celldata.scaledWidth && value[1] === celldata.scaledHeight) { + imageMap.delete(key); + } + }); + } + const imageTop = celldata.top; + const imageLeft = celldata.left; + const { x, y, width, height } = box; + // if(!((imageTop ==y && imageLeft == x) || (imageTop ==y-scroll.scroll.y && imageLeft == x-scroll.scroll.x))) + // {return} + const img = new Image(); + img.src = src; + img.onload = () => { + this.ctx.save(); + // �������Ͻ�λ�ã�Ϊʲôtranslateû����Ч�أ���Ϊ�첽���� + let sx = x + fixedIndexWidth; + let sy = y + fixedIndexHeight; + if (scroll) { + sx = sx - scroll.scroll.x + 0; + sy = sy - scroll.scroll.y + 0; + } + //���㳤���� + const imageWidth = celldata.imagewidth; + const imageHeight = celldata.imageheight; + const imageH = height - 2; // ������ʵ�ʿ��߱ȣ�ֱ��������Ԫ�� + const gridCellWidth = width; + const gridCellHeight = height; + let widthRatio = gridCellWidth / imageWidth; + let heightRatio = gridCellHeight / imageHeight; + let scaleRatio = Math.min(widthRatio, heightRatio); + let scaledWidth = imageWidth * scaleRatio; + let scaledHeight = imageHeight * scaleRatio; + if (imageMap.has(img.src)) { + // scaledWidth = imageMap.get(img.src)[0] + // scaledHeight = imageMap.get(img.src)[1] + // celldata.scaledWidth = scaledWidth + // celldata.scaledHeight = scaledHeight + // celldata.scaleRatio = scaleRatio + + //����ͼƬʱ�Ѵ���ƫ�� + if (imageMap.get(img.src)[2] != 0 || imageMap.get(img.src)[3] != 0) { + //���¼����ʼλ�� + // if (scroll.scroll.x > imageMap.get(img.src)[2]) { + // sx = sx + (scroll.scroll.x - imageMap.get(img.src)[2]) + // } else { + // sx = sx - (imageMap.get(img.src)[2] - scroll.scroll.x) + // } + // if (scroll.scroll.y > imageMap.get(img.src)[3]) { + // sy = sy + (scroll.scroll.y - imageMap.get(img.src)[3]) + // } else { + // sy = sy - (imageMap.get(img.src)[3] - scroll.scroll.y) + // } + // sx = sx - (scroll.scroll.x - imageMap.get(img.src)[2]) - 5 + // sy = sy - (scroll.scroll.y - imageMap.get(img.src)[3]) - 5 + // ��ֹ�ظ���Ⱦ + if (imageTop == y - scroll.scroll.y && imageLeft == x - scroll.scroll.x) { + this.ctx.drawImage(img, npx(sx), npx(sy), npx(imageWidth), npx(imageH)); + this.ctx.restore(); + } + } else { + // if (imageTop == y && imageLeft == x) { + this.ctx.drawImage(img, npx(sx), npx(sy), npx(imageWidth), npx(imageH)); + this.ctx.restore(); + // } + } + } else { + // imageMap.set(img.src, [scaledWidth, scaledHeight, scroll.scroll.x, scroll.scroll.y]) + // celldata.scaledWidth = scaledWidth + // celldata.scaledHeight = scaledHeight + // celldata.scaleRatio = scaleRatio + // if (imageTop == y - scroll.scroll.y && imageLeft == x - scroll.scroll.x) { + this.ctx.drawImage(img, npx(sx), npx(sy), npx(imageWidth), npx(imageH)); + this.ctx.restore(); + // } + } + }; + return this; + } + + /** + * ����ͼ�Ρ� + * �����ﱾ�����ο�text�������߼�������Ԫ��Ϊ radio, checkbox, date ʱ��������ǰ������Ӧ��ͼ�Ρ� + * @param {Object} cell - ��Ԫ�� + * @param {Object} box - DrawBox + * @param {Object} fixedIndexWidth - ��������� + * @param {Object} fixedIndexHeight - ������߶� + * @returns {Draw} CanvasRenderingContext2D ʵ�� + */ + async geometry(cell, box, { fixedIndexWidth, fixedIndexHeight }, style, scroll, celldata) { + const { type } = cell; + switch (type) { + case 'image': + await this.fillImage(box, cell, { fixedIndexWidth, fixedIndexHeight }, scroll, celldata); + break; + default: + } + + return this; + } + + /* + txt: render text + box: DrawBox + attr: { + align: left | center | right + valign: top | middle | bottom + color: '#333333', + strike: false, + font: { + name: 'Arial', + size: 14, + bold: false, + italic: false, + } + } + textWrap: text wrapping + */ + text(mtxt, box, attr = {}, textWrap = true) { + const { ctx } = this; + const { align, valign, font, color, strike, underline } = attr; + const tx = box.textx(align); + ctx.save(); + ctx.beginPath(); + this.attr({ + textAlign: align, + textBaseline: valign, + font: `${font.italic ? 'italic' : ''} ${font.bold ? 'bold' : ''} ${npx(font.size)}px ${ + font.name + }`, + fillStyle: color, + strokeStyle: color, + }); + const txts = `${mtxt}`.split('\n'); + const biw = box.innerWidth(); + const ntxts = []; + txts.forEach(it => { + const txtWidth = ctx.measureText(it).width; + if (textWrap && txtWidth > npx(biw)) { + let textLine = { w: 0, len: 0, start: 0 }; + for (let i = 0; i < it.length; i += 1) { + if (textLine.w >= npx(biw)) { + ntxts.push(it.substr(textLine.start, textLine.len)); + textLine = { w: 0, len: 0, start: i }; + } + textLine.len += 1; + textLine.w += ctx.measureText(it[i]).width + 1; + } + if (textLine.len > 0) { + ntxts.push(it.substr(textLine.start, textLine.len)); + } + } else { + ntxts.push(it); + } + }); + const txtHeight = (ntxts.length - 1) * (font.size + 2); + let ty = box.texty(valign, txtHeight); + ntxts.forEach(txt => { + const txtWidth = ctx.measureText(txt).width; + this.fillText(txt, tx, ty); + if (strike) { + drawFontLine.call(this, 'strike', tx, ty, align, valign, font.size, txtWidth); + } + if (underline) { + drawFontLine.call(this, 'underline', tx, ty, align, valign, font.size, txtWidth); + } + ty += font.size + 2; + }); + ctx.restore(); + return this; + } + + border(style, color) { + const { ctx } = this; + ctx.lineWidth = thinLineWidth; + ctx.strokeStyle = color; + // console.log('style:', style); + if (style === 'medium') { + ctx.lineWidth = npx(2) - 0.5; + } else if (style === 'thick') { + ctx.lineWidth = npx(3); + } else if (style === 'dashed') { + ctx.setLineDash([npx(3), npx(2)]); + } else if (style === 'dotted') { + ctx.setLineDash([npx(1), npx(1)]); + } else if (style === 'double') { + ctx.setLineDash([npx(2), 0]); + } + return this; + } + + line(...xys) { + const { ctx } = this; + if (xys.length > 1) { + ctx.beginPath(); + const [x, y] = xys[0]; + ctx.moveTo(npxLine(x), npxLine(y)); + for (let i = 1; i < xys.length; i += 1) { + const [x1, y1] = xys[i]; + ctx.lineTo(npxLine(x1), npxLine(y1)); + } + ctx.stroke(); + } + return this; + } + + strokeBorders(box) { + const { ctx } = this; + ctx.save(); + // border + const { borderTop, borderRight, borderBottom, borderLeft } = box; + if (borderTop) { + this.border(...borderTop); + // console.log('box.topxys:', box.topxys()); + this.line(...box.topxys()); + } + if (borderRight) { + this.border(...borderRight); + this.line(...box.rightxys()); + } + if (borderBottom) { + this.border(...borderBottom); + this.line(...box.bottomxys()); + } + if (borderLeft) { + this.border(...borderLeft); + this.line(...box.leftxys()); + } + ctx.restore(); + } + + dropdown(box) { + const { ctx } = this; + const { x, y, width, height } = box; + const sx = x + width - 15; + const sy = y + height - 15; + ctx.save(); + ctx.beginPath(); + ctx.moveTo(npx(sx), npx(sy)); + ctx.lineTo(npx(sx + 8), npx(sy)); + ctx.lineTo(npx(sx + 4), npx(sy + 6)); + ctx.closePath(); + ctx.fillStyle = 'rgba(0, 0, 0, .45)'; + ctx.fill(); + ctx.restore(); + } + + error(box) { + const { ctx } = this; + const { x, y, width } = box; + const sx = x + width - 1; + ctx.save(); + ctx.beginPath(); + ctx.moveTo(npx(sx - 8), npx(y - 1)); + ctx.lineTo(npx(sx), npx(y - 1)); + ctx.lineTo(npx(sx), npx(y + 8)); + ctx.closePath(); + ctx.fillStyle = 'rgba(255, 0, 0, .65)'; + ctx.fill(); + ctx.restore(); + } + + frozen(box) { + const { ctx } = this; + const { x, y, width } = box; + const sx = x + width - 1; + ctx.save(); + ctx.beginPath(); + ctx.moveTo(npx(sx - 8), npx(y - 1)); + ctx.lineTo(npx(sx), npx(y - 1)); + ctx.lineTo(npx(sx), npx(y + 8)); + ctx.closePath(); + ctx.fillStyle = 'rgba(0, 255, 0, .85)'; + ctx.fill(); + ctx.restore(); + } + + rect(box, dtextcb) { + const { ctx } = this; + const { x, y, width, height, bgcolor } = box; + ctx.save(); + ctx.beginPath(); + ctx.fillStyle = bgcolor || '#fff'; + ctx.rect(npxLine(x + 1), npxLine(y + 1), npx(width - 2), npx(height - 2)); + ctx.clip(); + ctx.fill(); + dtextcb(); + ctx.restore(); + } +} + +export default {}; +export { Draw, DrawBox, thinLineWidth, npx }; diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/canvas/draw2.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/canvas/draw2.js new file mode 100644 index 00000000..d58a177e --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/canvas/draw2.js @@ -0,0 +1,90 @@ +class Draw { + constructor(el) { + this.el = el; + this.ctx = el.getContext('2d'); + } + + clear() { + const { width, height } = this.el; + this.ctx.clearRect(0, 0, width, height); + return this; + } + + attr(m) { + Object.assign(this.ctx, m); + return this; + } + + save() { + this.ctx.save(); + this.ctx.beginPath(); + return this; + } + + restore() { + this.ctx.restore(); + return this; + } + + beginPath() { + this.ctx.beginPath(); + return this; + } + + closePath() { + this.ctx.closePath(); + return this; + } + + measureText(text) { + return this.ctx.measureText(text); + } + + rect(x, y, width, height) { + this.ctx.rect(x, y, width, height); + return this; + } + + scale(x, y) { + this.ctx.scale(x, y); + return this; + } + + rotate(angle) { + this.ctx.rotate(angle); + return this; + } + + translate(x, y) { + this.ctx.translate(x, y); + return this; + } + + transform(a, b, c, d, e) { + this.ctx.transform(a, b, c, d, e); + return this; + } + + fillRect(x, y, w, h) { + this.ctx.fillRect(x, y, w, h); + return this; + } + + strokeRect(x, y, w, h) { + this.ctx.strokeRect(x, y, w, h); + return this; + } + + fillText(text, x, y, maxWidth) { + this.ctx.fillText(text, x, y, maxWidth); + return this; + } + + strokeText(text, x, y, maxWidth) { + this.ctx.strokeText(text, x, y, maxWidth); + return this; + } +} + +export default {}; +export { Draw }; diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/border_palette.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/border_palette.js new file mode 100644 index 00000000..d927bc36 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/border_palette.js @@ -0,0 +1,62 @@ +import { cssPrefix } from '../config.js'; +import { h } from './element.js'; +import Icon from './icon.js'; +import DropdownColor from './dropdown_color.js'; +import DropdownLineType from './dropdown_linetype.js'; + +function buildTable(...trs) { + return h('table', '').child(h('tbody', '').children(...trs)); +} + +function buildTd(iconName) { + return h('td', '').child( + h('div', `${cssPrefix}-border-palette-cell`) + .child(new Icon(`border-${iconName}`)) + .on('click', () => { + this.mode = iconName; + const { mode, style, color } = this; + this.change({ mode, style, color }); + }), + ); +} + +export default class BorderPalette { + constructor() { + this.color = '#000'; + this.style = 'thin'; + this.mode = 'all'; + this.change = () => { + console.log('empty function'); + }; + this.ddColor = new DropdownColor('line-color', this.color); + this.ddColor.change = color => { + this.color = color; + }; + this.ddType = new DropdownLineType(this.style); + this.ddType.change = ([s]) => { + this.style = s; + }; + this.el = h('div', `${cssPrefix}-border-palette`); + const table = buildTable( + h('tr', '').children( + h('td', `${cssPrefix}-border-palette-left`).child( + buildTable( + h('tr', '').children( + ...['all', 'inside', 'horizontal', 'vertical', 'outside'].map(it => + buildTd.call(this, it), + ), + ), + h('tr', '').children( + ...['left', 'top', 'right', 'bottom', 'none'].map(it => buildTd.call(this, it)), + ), + ), + ), + h('td', `${cssPrefix}-border-palette-right`).children( + h('div', `${cssPrefix}-toolbar-btn`).child(this.ddColor.el), + h('div', `${cssPrefix}-toolbar-btn`).child(this.ddType.el), + ), + ), + ); + this.el.child(table); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/bottombar.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/bottombar.js new file mode 100644 index 00000000..b2533999 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/bottombar.js @@ -0,0 +1,204 @@ +import { cssPrefix } from '../config.js'; +import { tf } from '../locale/locale.js'; +import { h } from './element.js'; +import { bindClickoutside, unbindClickoutside } from './event.js'; +import Icon from './icon.js'; +import FormInput from './form_input.js'; +import Dropdown from './dropdown.js'; +// Record: temp not used +// import { xtoast } from './message.js'; + +class DropdownMore extends Dropdown { + constructor(click) { + const icon = new Icon('ellipsis'); + super(icon, 'auto', false, 'top-left'); + this.contentClick = click; + } + + reset(items) { + const eles = items.map((it, i) => + h('div', `${cssPrefix}-item`) + .css('width', '150px') + .css('font-weight', 'normal') + .on('click', () => { + this.contentClick(i); + this.hide(); + }) + .child(it), + ); + this.setContentChildren(...eles); + } + + setTitle() { + console.log('empty function'); + } +} + +const menuItems = [{ key: 'delete', title: tf('contextmenu.deleteSheet') }]; + +function buildMenuItem(item) { + return h('div', `${cssPrefix}-item`) + .child(item.title()) + .on('click', () => { + this.itemClick(item.key); + this.hide(); + }); +} + +function buildMenu() { + return menuItems.map(it => buildMenuItem.call(this, it)); +} + +class ContextMenu { + constructor() { + this.el = h('div', `${cssPrefix}-contextmenu`) + .css('width', '160px') + .children(...buildMenu.call(this)) + .hide(); + this.itemClick = () => { + console.log('empty function'); + }; + } + + hide() { + const { el } = this; + el.hide(); + unbindClickoutside(el); + } + + setOffset(offset) { + const { el } = this; + el.offset(offset); + el.show(); + bindClickoutside(el); + } +} + +export default class Bottombar { + constructor( + addFunc = () => { + console.log('empty function'); + }, + swapFunc = () => { + console.log('empty function'); + }, + deleteFunc = () => { + console.log('empty function'); + }, + updateFunc = () => { + console.log('empty function'); + }, + ) { + this.swapFunc = swapFunc; + this.updateFunc = updateFunc; + this.dataNames = []; + this.activeEl = null; + this.deleteEl = null; + this.items = []; + this.moreEl = new DropdownMore(i => { + this.clickSwap2(this.items[i]); + }); + this.contextMenu = new ContextMenu(); + this.contextMenu.itemClick = deleteFunc; + this.el = h('div', `${cssPrefix}-bottombar`).children( + this.contextMenu.el, + (this.menuEl = h('ul', `${cssPrefix}-menu`).child( + h('li', '').children( + new Icon('add').on('click', () => { + addFunc(); + }), + h('span', '').child(this.moreEl), + ), + )), + ); + } + + addItem(name, active, options) { + this.dataNames.push(name); + const item = h('li', active ? 'active' : '').child(name); + item + .on('click', () => { + this.clickSwap2(item); + }) + .on('contextmenu', evt => { + if (options.mode === 'read') return; + const { offsetLeft, offsetHeight } = evt.target; + this.contextMenu.setOffset({ left: offsetLeft, bottom: offsetHeight + 1 }); + this.deleteEl = item; + }) + .on('dblclick', () => { + if (options.mode === 'read') return; + const v = item.html(); + const input = new FormInput('auto', ''); + input.val(v); + input.input.on('blur', ({ target }) => { + const { value } = target; + const nindex = this.dataNames.findIndex(it => it === v); + this.renameItem(nindex, value); + /* + this.dataNames.splice(nindex, 1, value); + this.moreEl.reset(this.dataNames); + item.html('').child(value); + this.updateFunc(nindex, value); + */ + }); + item.html('').child(input.el); + input.focus(); + }); + if (active) { + this.clickSwap(item); + } + this.items.push(item); + this.menuEl.child(item); + this.moreEl.reset(this.dataNames); + } + + renameItem(index, value) { + this.dataNames.splice(index, 1, value); + this.moreEl.reset(this.dataNames); + this.items[index].html('').child(value); + this.updateFunc(index, value); + } + + clear() { + this.items.forEach(it => { + this.menuEl.removeChild(it.el); + }); + this.items = []; + this.dataNames = []; + this.moreEl.reset(this.dataNames); + } + + deleteItem() { + const { activeEl, deleteEl } = this; + if (this.items.length > 1) { + const index = this.items.findIndex(it => it === deleteEl); + this.items.splice(index, 1); + this.dataNames.splice(index, 1); + this.menuEl.removeChild(deleteEl.el); + this.moreEl.reset(this.dataNames); + if (activeEl === deleteEl) { + const [f] = this.items; + this.activeEl = f; + this.activeEl.toggle(); + return [index, 0]; + } + return [index, -1]; + } + return [-1]; + } + + clickSwap2(item) { + const index = this.items.findIndex(it => it === item); + this.clickSwap(item); + this.activeEl.toggle(); + this.swapFunc(index); + } + + clickSwap(item) { + if (this.activeEl !== null) { + this.activeEl.toggle(); + } + this.activeEl = item; + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/button.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/button.js new file mode 100644 index 00000000..21fcf2aa --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/button.js @@ -0,0 +1,11 @@ +import { cssPrefix } from '../config.js'; +import { t } from '../locale/locale.js'; +import { Element } from './element.js'; + +export default class Button extends Element { + // type: primary + constructor(title, type = '') { + super('div', `${cssPrefix}-button ${type}`); + this.child(t(`button.${title}`)); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/calendar.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/calendar.js new file mode 100644 index 00000000..a73f9e9a --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/calendar.js @@ -0,0 +1,112 @@ +import { t } from '../locale/locale.js'; +import { h } from './element.js'; +import Icon from './icon.js'; + +function addMonth(date, step) { + date.setMonth(date.getMonth() + step); +} + +function weekday(date, index) { + const d = new Date(date); + d.setDate(index - date.getDay() + 1); + return d; +} + +function monthDays(year, month, cdate) { + // the first day of month + const startDate = new Date(year, month, 1, 23, 59, 59); + const datess = [[], [], [], [], [], []]; + for (let i = 0; i < 6; i += 1) { + for (let j = 0; j < 7; j += 1) { + const index = i * 7 + j; + const d = weekday(startDate, index); + const disabled = d.getMonth() !== month; + // console.log('d:', d, ', cdate:', cdate); + const active = d.getMonth() === cdate.getMonth() && d.getDate() === cdate.getDate(); + datess[i][j] = { d, disabled, active }; + } + } + return datess; +} + +export default class Calendar { + constructor(value) { + this.value = value; + this.cvalue = new Date(value); + + this.headerLeftEl = h('div', 'calendar-header-left'); + this.bodyEl = h('tbody', ''); + this.buildAll(); + this.el = h('div', 'x-spreadsheet-calendar').children( + h('div', 'calendar-header').children( + this.headerLeftEl, + h('div', 'calendar-header-right').children( + h('a', 'calendar-prev') + .on('click.stop', () => this.prev()) + .child(new Icon('chevron-left')), + h('a', 'calendar-next') + .on('click.stop', () => this.next()) + .child(new Icon('chevron-right')), + ), + ), + h('table', 'calendar-body').children( + h('thead', '').child( + h('tr', '').children(...t('calendar.weeks').map(week => h('th', 'cell').child(week))), + ), + this.bodyEl, + ), + ); + this.selectChange = () => { + console.log('empty function'); + }; + } + + setValue(value) { + this.value = value; + this.cvalue = new Date(value); + this.buildAll(); + } + + prev() { + const { value } = this; + addMonth(value, -1); + this.buildAll(); + } + + next() { + const { value } = this; + addMonth(value, 1); + this.buildAll(); + } + + buildAll() { + this.buildHeaderLeft(); + this.buildBody(); + } + + buildHeaderLeft() { + const { value } = this; + this.headerLeftEl.html(`${t('calendar.months')[value.getMonth()]} ${value.getFullYear()}`); + } + + buildBody() { + const { value, cvalue, bodyEl } = this; + const mDays = monthDays(value.getFullYear(), value.getMonth(), cvalue); + const trs = mDays.map(it => { + const tds = it.map(it1 => { + let cls = 'cell'; + if (it1.disabled) cls += ' disabled'; + if (it1.active) cls += ' active'; + return h('td', '').child( + h('div', cls) + .on('click.stop', () => { + this.selectChange(it1.d); + }) + .child(it1.d.getDate().toString()), + ); + }); + return h('tr', '').children(...tds); + }); + bodyEl.html('').children(...trs); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/color_palette.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/color_palette.js new file mode 100644 index 00000000..aac0f9af --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/color_palette.js @@ -0,0 +1,124 @@ +import { cssPrefix } from '../config.js'; +import { h } from './element.js'; + +const themeColorPlaceHolders = [ + '#ffffff', + '#000100', + '#e7e5e6', + '#445569', + '#5b9cd6', + '#ed7d31', + '#a5a5a5', + '#ffc001', + '#4371c6', + '#71ae47', +]; + +const themeColors = [ + [ + '#f2f2f2', + '#7f7f7f', + '#d0cecf', + '#d5dce4', + '#deeaf6', + '#fce5d5', + '#ededed', + '#fff2cd', + '#d9e2f3', + '#e3efd9', + ], + [ + '#d8d8d8', + '#595959', + '#afabac', + '#adb8ca', + '#bdd7ee', + '#f7ccac', + '#dbdbdb', + '#ffe59a', + '#b3c6e7', + '#c5e0b3', + ], + [ + '#bfbfbf', + '#3f3f3f', + '#756f6f', + '#8596b0', + '#9cc2e6', + '#f4b184', + '#c9c9c9', + '#fed964', + '#8eaada', + '#a7d08c', + ], + [ + '#a5a5a5', + '#262626', + '#3a3839', + '#333f4f', + '#2e75b5', + '#c45a10', + '#7b7b7b', + '#bf8e01', + '#2f5596', + '#538136', + ], + [ + '#7f7f7f', + '#0c0c0c', + '#171516', + '#222a35', + '#1f4e7a', + '#843c0a', + '#525252', + '#7e6000', + '#203864', + '#365624', + ], +]; + +const standardColors = [ + '#c00000', + '#fe0000', + '#fdc101', + '#ffff01', + '#93d051', + '#00b04e', + '#01b0f1', + '#0170c1', + '#012060', + '#7030a0', +]; + +function buildTd(bgcolor) { + return h('td', '').child( + h('div', `${cssPrefix}-color-palette-cell`) + .on('click.stop', () => this.change(bgcolor)) + .css('background-color', bgcolor), + ); +} + +export default class ColorPalette { + constructor() { + this.el = h('div', `${cssPrefix}-color-palette`); + this.change = () => { + console.log('empty function'); + }; + const table = h('table', '').children( + h('tbody', '').children( + h('tr', `${cssPrefix}-theme-color-placeholders`).children( + ...themeColorPlaceHolders.map(color => buildTd.call(this, color)), + ), + ...themeColors.map(it => + h('tr', `${cssPrefix}-theme-colors`).children( + ...it.map(color => buildTd.call(this, color)), + ), + ), + h('tr', `${cssPrefix}-standard-colors`).children( + ...standardColors.map(color => buildTd.call(this, color)), + ), + ), + ); + this.el.child(table); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/contextmenu.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/contextmenu.js new file mode 100644 index 00000000..873b81db --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/contextmenu.js @@ -0,0 +1,99 @@ +import { cssPrefix } from '../config.js'; +import { tf } from '../locale/locale.js'; +import { h } from './element.js'; +import { bindClickoutside, unbindClickoutside } from './event.js'; + +const menuItems = [ + { key: 'copy', title: tf('contextmenu.copy'), label: 'Ctrl+C' }, + { key: 'cut', title: tf('contextmenu.cut'), label: 'Ctrl+X' }, + { key: 'paste', title: tf('contextmenu.paste'), label: 'Ctrl+V' }, + { key: 'paste-value', title: tf('contextmenu.pasteValue'), label: 'Ctrl+Shift+V' }, + { key: 'paste-format', title: tf('contextmenu.pasteFormat'), label: 'Ctrl+Alt+V' }, + { key: 'divider' }, + { key: 'insert-row', title: tf('contextmenu.insertRow') }, + { key: 'insert-column', title: tf('contextmenu.insertColumn') }, + { key: 'divider' }, + { key: 'delete-row', title: tf('contextmenu.deleteRow') }, + { key: 'delete-column', title: tf('contextmenu.deleteColumn') }, + { key: 'delete-cell-text', title: tf('contextmenu.deleteCellText') }, + { key: 'hide', title: tf('contextmenu.hide') }, + { key: 'divider' }, + { key: 'validation', title: tf('contextmenu.validation') }, + { key: 'divider' }, + { key: 'cell-printable', title: tf('contextmenu.cellprintable') }, + { key: 'cell-non-printable', title: tf('contextmenu.cellnonprintable') }, + { key: 'divider' }, + { key: 'cell-editable', title: tf('contextmenu.celleditable') }, + { key: 'cell-non-editable', title: tf('contextmenu.cellnoneditable') }, +]; + +function buildMenuItem(item) { + if (item.key === 'divider') { + return h('div', `${cssPrefix}-item divider`); + } + return h('div', `${cssPrefix}-item`) + .on('click', () => { + this.itemClick(item.key); + this.hide(); + }) + .children(item.title(), h('div', 'label').child(item.label || '')); +} + +function buildMenu() { + return menuItems.map(it => buildMenuItem.call(this, it)); +} + +export default class ContextMenu { + constructor(viewFn, isHide = false) { + this.menuItems = buildMenu.call(this); + this.el = h('div', `${cssPrefix}-contextmenu`) + .children(...this.menuItems) + .hide(); + this.viewFn = viewFn; + this.itemClick = () => { + console.log('empty function'); + }; + this.isHide = isHide; + this.setMode('range'); + } + + // row-col: the whole rows or the whole cols + // range: select range + setMode(mode) { + const hideEl = this.menuItems[12]; + if (mode === 'row-col') { + hideEl.show(); + } else { + hideEl.hide(); + } + } + + hide() { + const { el } = this; + el.hide(); + unbindClickoutside(el); + } + + setPosition(x, y) { + if (this.isHide) return; + const { el } = this; + const { width } = el.show().offset(); + const view = this.viewFn(); + const vhf = view.height / 2; + let left = x; + if (view.width - x <= width) { + left -= width; + } + el.css('left', `${left}px`); + if (y > vhf) { + el.css('bottom', `${view.height - y}px`) + .css('max-height', `${y}px`) + .css('top', 'auto'); + } else { + el.css('top', `${y}px`) + .css('max-height', `${view.height - y}px`) + .css('bottom', 'auto'); + } + bindClickoutside(el); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/datepicker.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/datepicker.js new file mode 100644 index 00000000..7ef86416 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/datepicker.js @@ -0,0 +1,39 @@ +import { cssPrefix } from '../config.js'; +import Calendar from './calendar.js'; +import { h } from './element.js'; + +export default class Datepicker { + constructor() { + this.calendar = new Calendar(new Date()); + this.el = h('div', `${cssPrefix}-datepicker`).child(this.calendar.el).hide(); + } + + setValue(date) { + // console.log(':::::::', date, typeof date, date instanceof string); + const { calendar } = this; + if (typeof date === 'string') { + // console.log(/^\d{4}-\d{1,2}-\d{1,2}$/.test(date)); + if (/^\d{4}-\d{1,2}-\d{1,2}$/.test(date)) { + calendar.setValue(new Date(date.replace(new RegExp('-', 'g'), '/'))); + } + } else if (date instanceof Date) { + calendar.setValue(date); + } + return this; + } + + change(cb) { + this.calendar.selectChange = d => { + cb(d); + this.hide(); + }; + } + + show() { + this.el.show(); + } + + hide() { + this.el.hide(); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown.js new file mode 100644 index 00000000..ad48dc7e --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown.js @@ -0,0 +1,70 @@ +import { cssPrefix } from '../config.js'; +import { Element, h } from './element.js'; +import { bindClickoutside, unbindClickoutside } from './event.js'; + +export default class Dropdown extends Element { + constructor(title, width, showArrow, placement, ...children) { + super('div', `${cssPrefix}-dropdown ${placement}`); + this.title = title; + this.change = () => { + console.log('empty function'); + }; + this.headerClick = () => { + console.log('empty function'); + }; + if (typeof title === 'string') { + this.title = h('div', `${cssPrefix}-dropdown-title`).child(title); + } else if (showArrow) { + this.title.addClass('arrow-left'); + } + this.contentEl = h('div', `${cssPrefix}-dropdown-content`).css('width', width).hide(); + + this.setContentChildren(...children); + + this.headerEl = h('div', `${cssPrefix}-dropdown-header`); + this.headerEl + .on('click', () => { + if (this.contentEl.css('display') !== 'block') { + this.show(); + } else { + this.hide(); + } + }) + .children( + this.title, + showArrow + ? h('div', `${cssPrefix}-icon arrow-right`).child( + h('div', `${cssPrefix}-icon-img arrow-down`), + ) + : '', + ); + this.children(this.headerEl, this.contentEl); + } + + setContentChildren(...children) { + this.contentEl.html(''); + if (children.length > 0) { + this.contentEl.children(...children); + } + } + + setTitle(title) { + this.title.html(title); + this.hide(); + } + + show() { + const { contentEl } = this; + contentEl.show(); + this.parent().active(); + bindClickoutside(this.parent(), () => { + this.hide(); + }); + } + + hide() { + this.parent().active(false); + this.contentEl.hide(); + unbindClickoutside(this.parent()); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_align.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_align.js new file mode 100644 index 00000000..0bc6fdb8 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_align.js @@ -0,0 +1,26 @@ +import { cssPrefix } from '../config.js'; +import Dropdown from './dropdown.js'; +import { h } from './element.js'; +import Icon from './icon.js'; + +function buildItemWithIcon(iconName) { + return h('div', `${cssPrefix}-item`).child(new Icon(iconName)); +} + +export default class DropdownAlign extends Dropdown { + constructor(aligns, align) { + const icon = new Icon(`align-${align}`); + const naligns = aligns.map(it => + buildItemWithIcon(`align-${it}`).on('click', () => { + this.setTitle(it); + this.change(it); + }), + ); + super(icon, 'auto', true, 'bottom-left', ...naligns); + } + + setTitle(align) { + this.title.setName(`align-${align}`); + this.hide(); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_border.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_border.js new file mode 100644 index 00000000..c38ac9c5 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_border.js @@ -0,0 +1,15 @@ +import Dropdown from './dropdown.js'; +import Icon from './icon.js'; +import BorderPalette from './border_palette.js'; + +export default class DropdownBorder extends Dropdown { + constructor() { + const icon = new Icon('border-all'); + const borderPalette = new BorderPalette(); + borderPalette.change = v => { + this.change(v); + this.hide(); + }; + super(icon, 'auto', false, 'bottom-left', borderPalette.el); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_color.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_color.js new file mode 100644 index 00000000..29e0aba8 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_color.js @@ -0,0 +1,22 @@ +import Dropdown from './dropdown.js'; +import Icon from './icon.js'; +import ColorPalette from './color_palette.js'; + +export default class DropdownColor extends Dropdown { + constructor(iconName, color) { + const icon = new Icon(iconName) + .css('height', '16px') + .css('border-bottom', `3px solid ${color}`); + const colorPalette = new ColorPalette(); + colorPalette.change = v => { + this.setTitle(v); + this.change(v); + }; + super(icon, 'auto', false, 'bottom-left', colorPalette.el); + } + + setTitle(color) { + this.title.css('border-color', color); + this.hide(); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_font.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_font.js new file mode 100644 index 00000000..a85ffa45 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_font.js @@ -0,0 +1,18 @@ +import { baseFonts } from '../core/font.js'; +import { cssPrefix } from '../config.js'; +import Dropdown from './dropdown.js'; +import { h } from './element.js'; + +export default class DropdownFont extends Dropdown { + constructor() { + const nfonts = baseFonts.map(it => + h('div', `${cssPrefix}-item`) + .on('click', () => { + this.setTitle(it.title); + this.change(it); + }) + .child(it.title), + ); + super(baseFonts[0].title, '160px', true, 'bottom-left', ...nfonts); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_fontsize.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_fontsize.js new file mode 100644 index 00000000..7b6f2da1 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_fontsize.js @@ -0,0 +1,18 @@ +import { fontSizes } from '../core/font.js'; +import { cssPrefix } from '../config.js'; +import Dropdown from './dropdown.js'; +import { h } from './element.js'; + +export default class DropdownFontSize extends Dropdown { + constructor() { + const nfontSizes = fontSizes.map(it => + h('div', `${cssPrefix}-item`) + .on('click', () => { + this.setTitle(`${it.pt}`); + this.change(it); + }) + .child(`${it.pt}`), + ); + super('10', '60px', true, 'bottom-left', ...nfontSizes); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_format.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_format.js new file mode 100644 index 00000000..ca7487c1 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_format.js @@ -0,0 +1,35 @@ +import { baseFormats } from '../core/format.js'; +import { cssPrefix } from '../config.js'; +import Dropdown from './dropdown.js'; +import { h } from './element.js'; + +export default class DropdownFormat extends Dropdown { + constructor() { + let nformats = baseFormats.slice(0); + nformats.splice(2, 0, { key: 'divider' }); + nformats.splice(8, 0, { key: 'divider' }); + nformats = nformats.map(it => { + const item = h('div', `${cssPrefix}-item`); + if (it.key === 'divider') { + item.addClass('divider'); + } else { + item.child(it.title()).on('click', () => { + this.setTitle(it.title()); + this.change(it); + }); + if (it.label) item.child(h('div', 'label').html(it.label)); + } + return item; + }); + super('Normal', '220px', true, 'bottom-left', ...nformats); + } + + setTitle(key) { + for (let i = 0; i < baseFormats.length; i += 1) { + if (baseFormats[i].key === key) { + this.title.html(baseFormats[i].title()); + } + } + this.hide(); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_formula.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_formula.js new file mode 100644 index 00000000..6f68880f --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_formula.js @@ -0,0 +1,19 @@ +import { baseFormulas } from '../core/formula.js'; +import { cssPrefix } from '../config.js'; +import Dropdown from './dropdown.js'; +import Icon from './icon.js'; +import { h } from './element.js'; + +export default class DropdownFormula extends Dropdown { + constructor() { + const nformulas = baseFormulas.map(it => + h('div', `${cssPrefix}-item`) + .on('click', () => { + this.hide(); + this.change(it); + }) + .child(it.key), + ); + super(new Icon('formula'), '180px', true, 'bottom-left', ...nformulas); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_linetype.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_linetype.js new file mode 100644 index 00000000..b81aa0f0 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/dropdown_linetype.js @@ -0,0 +1,48 @@ +import { cssPrefix } from '../config.js'; +import Dropdown from './dropdown.js'; +import { h } from './element.js'; +import Icon from './icon.js'; + +const lineTypes = [ + [ + 'thin', + '', + ], + [ + 'medium', + '', + ], + [ + 'thick', + '', + ], + [ + 'dashed', + '', + ], + [ + 'dotted', + '', + ], + // ['double', ''], +]; + +export default class DropdownLineType extends Dropdown { + constructor(type) { + const icon = new Icon('line-type'); + let beforei = 0; + const lineTypeEls = lineTypes.map((it, iti) => + h('div', `${cssPrefix}-item state ${type === it[0] ? 'checked' : ''}`) + .on('click', () => { + lineTypeEls[beforei].toggle('checked'); + lineTypeEls[iti].toggle('checked'); + beforei = iti; + this.hide(); + this.change(it); + }) + .child(h('div', `${cssPrefix}-line-type`).html(it[1])), + ); + + super(icon, 'auto', false, 'bottom-left', ...lineTypeEls); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/editor.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/editor.js new file mode 100644 index 00000000..9c815c95 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/editor.js @@ -0,0 +1,284 @@ +import { cssPrefix } from '../config.js'; +import { h } from './element.js'; +import Suggest from './suggest.js'; +// TODO datepicker 暂不支持,后续放开datepicker解决报错后使用 +// import Datepicker from './datepicker'; +// import { mouseMoveUp } from '../event.js'; + +function resetTextareaSize() { + const { inputText } = this; + if (!/^\s*$/.test(inputText)) { + const { textlineEl, textEl, areaOffset } = this; + const txts = inputText.split('\n'); + const maxTxtSize = Math.max(...txts.map(it => it.length)); + const tlOffset = textlineEl.offset(); + const fontWidth = tlOffset.width / inputText.length; + const tlineWidth = (maxTxtSize + 1) * fontWidth + 5; + const maxWidth = this.viewFn().width - areaOffset.left - fontWidth; + let h1 = txts.length; + if (tlineWidth > areaOffset.width) { + let twidth = tlineWidth; + if (tlineWidth > maxWidth) { + twidth = maxWidth; + h1 += parseInt(tlineWidth / maxWidth, 10); + h1 += tlineWidth % maxWidth > 0 ? 1 : 0; + } + textEl.css('width', `${twidth}px`); + } + h1 *= this.rowHeight; + if (h1 > areaOffset.height) { + textEl.css('height', `${h1}px`); + } + } +} + +function insertText({ target }, itxt) { + const { value, selectionEnd } = target; + const ntxt = `${value.slice(0, selectionEnd)}${itxt}${value.slice(selectionEnd)}`; + target.value = ntxt; + target.setSelectionRange(selectionEnd + 1, selectionEnd + 1); + + this.inputText = ntxt; + this.textlineEl.html(ntxt); + resetTextareaSize.call(this); +} + +function keydownEventHandler(evt) { + const { keyCode, altKey } = evt; + if (keyCode !== 13 && keyCode !== 9) evt.stopPropagation(); + if (keyCode === 13 && altKey) { + insertText.call(this, evt, '\n'); + evt.stopPropagation(); + } + if (keyCode === 13 && !altKey) evt.preventDefault(); +} + +function inputEventHandler(evt) { + const v = evt.target.value; + // console.log(evt, 'v:', v); + const { suggest, textlineEl, validator } = this; + const { cell } = this; + if (cell !== null) { + if (('editable' in cell && cell.editable === true) || cell.editable === undefined) { + this.inputText = v; + if (validator) { + if (validator.type === 'list') { + suggest.search(v); + } else { + suggest.hide(); + } + } else { + const start = v.lastIndexOf('='); + if (start !== -1) { + suggest.search(v.substring(start + 1)); + } else { + suggest.hide(); + } + } + textlineEl.html(v); + resetTextareaSize.call(this); + this.change('input', v); + } else { + evt.target.value = cell.text || ''; + } + } else { + this.inputText = v; + if (validator) { + if (validator.type === 'list') { + suggest.search(v); + } else { + suggest.hide(); + } + } else { + const start = v.lastIndexOf('='); + if (start !== -1) { + suggest.search(v.substring(start + 1)); + } else { + suggest.hide(); + } + } + textlineEl.html(v); + resetTextareaSize.call(this); + this.change('input', v); + } +} + +function setTextareaRange(position) { + const { el } = this.textEl; + setTimeout(() => { + el.focus(); + el.setSelectionRange(position, position); + }, 0); +} + +function setText(text, position) { + const { textEl, textlineEl } = this; + // firefox bug + textEl.el.blur(); + + textEl.val(text); + textlineEl.html(text); + setTextareaRange.call(this, position); +} + +function suggestItemClick(it) { + const { inputText, validator } = this; + let position = 0; + if (validator && validator.type === 'list') { + this.inputText = it; + position = this.inputText.length; + } else { + const start = inputText.lastIndexOf('='); + const sit = inputText.substring(0, start + 1); + let eit = inputText.substring(start + 1); + if (eit.indexOf(')') !== -1) { + eit = eit.substring(eit.indexOf(')')); + } else { + eit = ''; + } + this.inputText = `${sit + it.key}(`; + // console.log('inputText:', this.inputText); + position = this.inputText.length; + this.inputText += `)${eit}`; + } + setText.call(this, this.inputText, position); +} + +function resetSuggestItems() { + this.suggest.setItems(this.formulas); +} + +function dateFormat(d) { + let month = d.getMonth() + 1; + let date = d.getDate(); + if (month < 10) month = `0${month}`; + if (date < 10) date = `0${date}`; + return `${d.getFullYear()}-${month}-${date}`; +} + +export default class Editor { + constructor(formulas, viewFn, rowHeight) { + this.viewFn = viewFn; + this.rowHeight = rowHeight; + this.formulas = formulas; + this.suggest = new Suggest(formulas, it => { + suggestItemClick.call(this, it); + }); + // this.datepicker = new Datepicker(); + // this.datepicker.change((d) => { + // // console.log('d:', d); + // this.setText(dateFormat(d)); + // this.clear(); + // }); + this.areaEl = h('div', `${cssPrefix}-editor-area`) + .children( + (this.textEl = h('textarea', '') + .on('input', evt => inputEventHandler.call(this, evt)) + .on('paste.stop', () => { + console.log('empty function'); + }) + .on('keydown', evt => keydownEventHandler.call(this, evt))), + (this.textlineEl = h('div', 'textline')), + this.suggest.el, + // this.datepicker.el, + ) + .on('mousemove.stop', () => { + console.log('empty function'); + }) + .on('mousedown.stop', () => { + console.log('empty function'); + }); + this.el = h('div', `${cssPrefix}-editor`).child(this.areaEl).hide(); + this.suggest.bindInputEvents(this.textEl); + + this.areaOffset = null; + this.freeze = { w: 0, h: 0 }; + this.cell = null; + this.inputText = ''; + this.change = () => { + console.log('empty function'); + }; + } + + setFreezeLengths(width, height) { + this.freeze.w = width; + this.freeze.h = height; + } + + clear() { + // const { cell } = this; + // const cellText = (cell && cell.text) || ''; + if (this.inputText !== '') { + this.change('finished', this.inputText); + } + this.cell = null; + this.areaOffset = null; + this.inputText = ''; + this.el.hide(); + this.textEl.val(''); + this.textlineEl.html(''); + resetSuggestItems.call(this); + // this.datepicker.hide(); + } + + setOffset(offset, suggestPosition = 'top') { + const { textEl, areaEl, suggest, freeze, el } = this; + if (offset) { + this.areaOffset = offset; + const { left, top, width, height, l, t } = offset; + // console.log('left:', left, ',top:', top, ', freeze:', freeze); + const elOffset = { left: 0, top: 0 }; + // top left + if (freeze.w > l && freeze.h > t) { + // + } else if (freeze.w < l && freeze.h < t) { + elOffset.left = freeze.w; + elOffset.top = freeze.h; + } else if (freeze.w > l) { + elOffset.top = freeze.h; + } else if (freeze.h > t) { + elOffset.left = freeze.w; + } + el.offset(elOffset); + areaEl.offset({ left: left - elOffset.left - 0.8, top: top - elOffset.top - 0.8 }); + textEl.offset({ width: width - 9 + 0.8, height: height - 3 + 0.8 }); + const sOffset = { left: 0 }; + sOffset[suggestPosition] = height; + suggest.setOffset(sOffset); + suggest.hide(); + } + } + + setCell(cell, validator) { + if (cell && cell.editable === false) return; + + // console.log('::', validator); + const { el, datepicker, suggest } = this; + el.show(); + this.cell = cell; + const text = (cell && cell.text) || ''; + this.setText(text); + + this.validator = validator; + if (validator) { + const { type } = validator; + if (type === 'date') { + // datepicker.show(); + if (!/^\s*$/.test(text)) { + datepicker.setValue(text); + } + } + if (type === 'list') { + suggest.setItems(validator.values()); + suggest.search(''); + } + } + } + + setText(text) { + this.inputText = text; + // console.log('text>>:', text); + setText.call(this, text, text.length); + resetTextareaSize.call(this); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/element.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/element.js new file mode 100644 index 00000000..1d1ff92d --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/element.js @@ -0,0 +1,268 @@ +class Element { + constructor(tag, className = '') { + if (typeof tag === 'string') { + this.el = document.createElement(tag); + this.el.className = className; + } else { + this.el = tag; + } + this.data = {}; + } + + data(key, value) { + if (value !== undefined) { + this.data[key] = value; + return this; + } + return this.data[key]; + } + + on(eventNames, handler) { + const [fen, ...oen] = eventNames.split('.'); + let eventName = fen; + if (eventName === 'mousewheel' && /Firefox/i.test(window.navigator.userAgent)) { + eventName = 'DOMMouseScroll'; + } + this.el.addEventListener(eventName, evt => { + handler(evt); + for (let i = 0; i < oen.length; i += 1) { + const k = oen[i]; + if (k === 'left' && evt.button !== 0) { + return; + } + if (k === 'right' && evt.button !== 2) { + return; + } + if (k === 'stop') { + evt.stopPropagation(); + } + } + }); + return this; + } + + offset(value) { + if (value !== undefined) { + Object.keys(value).forEach(k => { + this.css(k, `${value[k]}px`); + }); + return this; + } + const { offsetTop, offsetLeft, offsetHeight, offsetWidth } = this.el; + return { + top: offsetTop, + left: offsetLeft, + height: offsetHeight, + width: offsetWidth, + }; + } + + scroll(v) { + const { el } = this; + if (v !== undefined) { + if (v.left !== undefined) { + el.scrollLeft = v.left; + } + if (v.top !== undefined) { + el.scrollTop = v.top; + } + } + return { left: el.scrollLeft, top: el.scrollTop }; + } + + box() { + return this.el.getBoundingClientRect(); + } + + parent() { + return new Element(this.el.parentNode); + } + + children(...eles) { + if (arguments.length === 0) { + return this.el.childNodes; + } + eles.forEach(ele => this.child(ele)); + return this; + } + + removeChild(el) { + this.el.removeChild(el); + } + + /* + first() { + return this.el.firstChild; + } + + last() { + return this.el.lastChild; + } + + remove(ele) { + return this.el.removeChild(ele); + } + + prepend(ele) { + const { el } = this; + if (el.children.length > 0) { + el.insertBefore(ele, el.firstChild); + } else { + el.appendChild(ele); + } + return this; + } + + prev() { + return this.el.previousSibling; + } + + next() { + return this.el.nextSibling; + } + */ + + child(arg) { + let ele = arg; + if (typeof arg === 'string') { + ele = document.createTextNode(arg); + } else if (arg instanceof Element) { + ele = arg.el; + } + this.el.appendChild(ele); + return this; + } + + contains(ele) { + return this.el.contains(ele); + } + + className(v) { + if (v !== undefined) { + this.el.className = v; + return this; + } + return this.el.className; + } + + addClass(name) { + this.el.classList.add(name); + return this; + } + + hasClass(name) { + return this.el.classList.contains(name); + } + + removeClass(name) { + this.el.classList.remove(name); + return this; + } + + toggle(cls = 'active') { + return this.toggleClass(cls); + } + + toggleClass(name) { + return this.el.classList.toggle(name); + } + + active(flag = true, cls = 'active') { + if (flag) this.addClass(cls); + else this.removeClass(cls); + return this; + } + + checked(flag = true) { + this.active(flag, 'checked'); + return this; + } + + disabled(flag = true) { + if (flag) this.addClass('disabled'); + else this.removeClass('disabled'); + return this; + } + + // key, value + // key + // {k, v}... + attr(key, value) { + if (value !== undefined) { + this.el.setAttribute(key, value); + } else { + if (typeof key === 'string') { + return this.el.getAttribute(key); + } + Object.keys(key).forEach(k => { + this.el.setAttribute(k, key[k]); + }); + } + return this; + } + + removeAttr(key) { + this.el.removeAttribute(key); + return this; + } + + html(content) { + if (content !== undefined) { + this.el.innerHTML = content; + return this; + } + return this.el.innerHTML; + } + + val(v) { + if (v !== undefined) { + this.el.value = v; + return this; + } + return this.el.value; + } + + focus() { + this.el.focus(); + } + + cssRemoveKeys(...keys) { + keys.forEach(k => this.el.style.removeProperty(k)); + return this; + } + + // css( propertyName ) + // css( propertyName, value ) + // css( properties ) + css(name, value) { + if (value === undefined && typeof name !== 'string') { + Object.keys(name).forEach(k => { + this.el.style[k] = name[k]; + }); + return this; + } + if (value !== undefined) { + this.el.style[name] = value; + return this; + } + return this.el.style[name]; + } + + computedStyle() { + return window.getComputedStyle(this.el, null); + } + + show() { + this.css('display', 'block'); + return this; + } + + hide() { + this.css('display', 'none'); + return this; + } +} + +const h = (tag, className = '') => new Element(tag, className); + +export { Element, h }; diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/event.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/event.js new file mode 100644 index 00000000..9a847868 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/event.js @@ -0,0 +1,148 @@ +export function bind(target, name, fn) { + target.addEventListener(name, fn); +} +export function unbind(target, name, fn) { + target.removeEventListener(name, fn); +} +export function unbindClickoutside(el) { + if (el.xclickoutside) { + unbind(window.document.body, 'click', el.xclickoutside); + delete el.xclickoutside; + } +} + +// the left mouse button: mousedown → mouseup → click +// the right mouse button: mousedown → contenxtmenu → mouseup +// the right mouse button in firefox(>65.0): mousedown → contenxtmenu → mouseup → click on window +export function bindClickoutside(el, cb) { + el.xclickoutside = evt => { + // ignore double click + // console.log('evt:', evt); + if (evt.detail === 2 || el.contains(evt.target)) return; + if (cb) cb(el); + else { + el.hide(); + unbindClickoutside(el); + } + }; + bind(window.document.body, 'click', el.xclickoutside); +} +export function mouseMoveUp(target, movefunc, upfunc) { + bind(target, 'mousemove', movefunc); + const t = target; + t.xEvtUp = evt => { + // console.log('mouseup>>>'); + unbind(target, 'mousemove', movefunc); + unbind(target, 'mouseup', target.xEvtUp); + upfunc(evt); + }; + bind(target, 'mouseup', target.xEvtUp); +} + +function calTouchDirection(spanx, spany, evt, cb) { + let direction = ''; + // console.log('spanx:', spanx, ', spany:', spany); + if (Math.abs(spanx) > Math.abs(spany)) { + // horizontal + direction = spanx > 0 ? 'right' : 'left'; + cb(direction, spanx, evt); + } else { + // vertical + direction = spany > 0 ? 'down' : 'up'; + cb(direction, spany, evt); + } +} +// cb = (direction, distance) => {} +export function bindTouch(target, { move, end }) { + let startx = 0; + let starty = 0; + bind(target, 'touchstart', evt => { + const { pageX, pageY } = evt.touches[0]; + startx = pageX; + starty = pageY; + }); + bind(target, 'touchmove', evt => { + if (!move) return; + const { pageX, pageY } = evt.changedTouches[0]; + const spanx = pageX - startx; + const spany = pageY - starty; + if (Math.abs(spanx) > 10 || Math.abs(spany) > 10) { + // console.log('spanx:', spanx, ', spany:', spany); + calTouchDirection(spanx, spany, evt, move); + startx = pageX; + starty = pageY; + } + evt.preventDefault(); + }); + bind(target, 'touchend', evt => { + if (!end) return; + const { pageX, pageY } = evt.changedTouches[0]; + const spanx = pageX - startx; + const spany = pageY - starty; + calTouchDirection(spanx, spany, evt, end); + }); +} + +// eventemiter +export function createEventEmitter() { + const listeners = new Map(); + + function on(eventName, callback) { + const push = () => { + const currentListener = listeners.get(eventName); + return (Array.isArray(currentListener) && currentListener.push(callback)) || false; + }; + + const create = () => listeners.set(eventName, [].concat(callback)); + + return (listeners.has(eventName) && push()) || create(); + } + + function fire(eventName, args) { + const exec = () => { + const currentListener = listeners.get(eventName); + for (const callback of currentListener) callback.call(null, ...args); + }; + + return listeners.has(eventName) && exec(); + } + + function removeListener(eventName, callback) { + const remove = () => { + const currentListener = listeners.get(eventName); + const idx = currentListener.indexOf(callback); + return ( + idx >= 0 && + currentListener.splice(idx, 1) && + listeners.get(eventName).length === 0 && + listeners.delete(eventName) + ); + }; + + return listeners.has(eventName) && remove(); + } + + function once(eventName, callback) { + const execCalllback = (...args) => { + callback.call(null, ...args); + removeListener(eventName, execCalllback); + }; + + return on(eventName, execCalllback); + } + + function removeAllListeners() { + listeners.clear(); + } + + return { + get current() { + return listeners; + }, + on, + once, + fire, + removeListener, + removeAllListeners, + }; +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/form_field.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/form_field.js new file mode 100644 index 00000000..764dc185 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/form_field.js @@ -0,0 +1,66 @@ +import { cssPrefix } from '../config.js'; +import { t } from '../locale/locale.js'; +import { h } from './element.js'; + +const patterns = { + number: /(^\d+$)|(^\d+(\.\d{0,4})?$)/, + date: /^\d{4}-\d{1,2}-\d{1,2}$/, +}; + +// rule: { required: false, type, pattern: // } +export default class FormField { + constructor(input, rule, label, labelWidth) { + this.label = ''; + this.rule = rule; + if (label) { + this.label = h('label', 'label').css('width', `${labelWidth}px`).html(label); + } + this.tip = h('div', 'tip').child('tip').hide(); + this.input = input; + this.input.vchange = () => this.validate(); + this.el = h('div', `${cssPrefix}-form-field`).children(this.label, input.el, this.tip); + } + + isShow() { + return this.el.css('display') !== 'none'; + } + + show() { + this.el.show(); + } + + hide() { + this.el.hide(); + return this; + } + + val(v) { + return this.input.val(v); + } + + hint(hint) { + this.input.hint(hint); + } + + validate() { + const { input, rule, tip, el } = this; + const v = input.val(); + if (rule.required) { + if (/^\s*$/.test(v)) { + tip.html(t('validation.required')); + el.addClass('error'); + return false; + } + } + if (rule.type || rule.pattern) { + const pattern = rule.pattern || patterns[rule.type]; + if (!pattern.test(v)) { + tip.html(t('validation.notMatch')); + el.addClass('error'); + return false; + } + } + el.removeClass('error'); + return true; + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/form_input.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/form_input.js new file mode 100644 index 00000000..ca29e490 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/form_input.js @@ -0,0 +1,30 @@ +import { cssPrefix } from '../config.js'; +import { h } from './element.js'; + +export default class FormInput { + constructor(width, hint) { + this.vchange = () => { + console.log('empty function'); + }; + this.el = h('div', `${cssPrefix}-form-input`); + this.input = h('input', '') + .css('width', width) + .on('input', evt => this.vchange(evt)) + .attr('placeholder', hint); + this.el.child(this.input); + } + + focus() { + setTimeout(() => { + this.input.el.focus(); + }, 10); + } + + hint(v) { + this.input.attr('placeholder', v); + } + + val(v) { + return this.input.val(v); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/form_select.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/form_select.js new file mode 100644 index 00000000..410a2cc5 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/form_select.js @@ -0,0 +1,53 @@ +import { cssPrefix } from '../config.js'; +import { h } from './element.js'; +import Suggest from './suggest.js'; + +export default class FormSelect { + constructor( + key, + items, + width, + getTitle = it => it, + change = () => { + console.log('empty function'); + }, + ) { + this.key = key; + this.getTitle = getTitle; + this.vchange = () => { + console.log('empty function'); + }; + this.el = h('div', `${cssPrefix}-form-select`); + this.suggest = new Suggest( + items.map(it => ({ key: it, title: this.getTitle(it) })), + it => { + this.itemClick(it.key); + change(it.key); + this.vchange(it.key); + }, + width, + this.el, + ); + this.el + .children((this.itemEl = h('div', 'input-text').html(this.getTitle(key))), this.suggest.el) + .on('click', () => this.show()); + } + + show() { + this.suggest.search(''); + } + + itemClick(it) { + this.key = it; + this.itemEl.html(this.getTitle(it)); + } + + val(v) { + if (v !== undefined) { + this.key = v; + this.itemEl.html(this.getTitle(v)); + return this; + } + return this.key; + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/icon.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/icon.js new file mode 100644 index 00000000..421d05ff --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/icon.js @@ -0,0 +1,14 @@ +import { cssPrefix } from '../config.js'; +import { Element, h } from './element.js'; + +export default class Icon extends Element { + constructor(name) { + super('div', `${cssPrefix}-icon`); + this.iconNameEl = h('div', `${cssPrefix}-icon-img ${name}`); + this.child(this.iconNameEl); + } + + setName(name) { + this.iconNameEl.className(`${cssPrefix}-icon-img ${name}`); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/message.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/message.js new file mode 100644 index 00000000..59ba33af --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/message.js @@ -0,0 +1,31 @@ +import { cssPrefix } from '../config.js'; +import { h } from './element.js'; +import Icon from './icon.js'; + +export function xtoast(title, content) { + const el = h('div', `${cssPrefix}-toast`); + const dimmer = h('div', `${cssPrefix}-dimmer active`); + const remove = () => { + document.body.removeChild(el.el); + document.body.removeChild(dimmer.el); + }; + + el.children( + h('div', `${cssPrefix}-toast-header`).children( + new Icon('close').on('click.stop', () => remove()), + title, + ), + h('div', `${cssPrefix}-toast-content`).html(content), + ); + document.body.appendChild(el.el); + document.body.appendChild(dimmer.el); + // set offset + const { width, height } = el.box(); + const { clientHeight, clientWidth } = document.documentElement; + el.offset({ + left: (clientWidth - width) / 2, + top: (clientHeight - height) / 3, + }); +} + +export default {}; diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/modal.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/modal.js new file mode 100644 index 00000000..ac554572 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/modal.js @@ -0,0 +1,45 @@ +import { cssPrefix } from '../config.js'; +import { h } from './element.js'; +import Icon from './icon.js'; +import { bind, unbind } from './event.js'; + +export default class Modal { + constructor(title, content, width = '600px') { + this.title = title; + this.el = h('div', `${cssPrefix}-modal`) + .css('width', width) + .children( + h('div', `${cssPrefix}-modal-header`).children( + new Icon('close').on('click.stop', () => this.hide()), + this.title, + ), + h('div', `${cssPrefix}-modal-content`).children(...content), + ) + .hide(); + } + + show() { + // dimmer + this.dimmer = h('div', `${cssPrefix}-dimmer active`); + document.body.appendChild(this.dimmer.el); + const { width, height } = this.el.show().box(); + const { clientHeight, clientWidth } = document.documentElement; + this.el.offset({ + left: (clientWidth - width) / 2, + top: (clientHeight - height) / 3, + }); + window.xkeydownEsc = evt => { + if (evt.keyCode === 27) { + this.hide(); + } + }; + bind(window, 'keydown', window.xkeydownEsc); + } + + hide() { + this.el.hide(); + document.body.removeChild(this.dimmer.el); + unbind(window, 'keydown', window.xkeydownEsc); + delete window.xkeydownEsc; + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/modal_validation.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/modal_validation.js new file mode 100644 index 00000000..366590df --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/modal_validation.js @@ -0,0 +1,214 @@ +import { t } from '../locale/locale.js'; +import { cssPrefix } from '../config.js'; +import Modal from './modal.js'; +import FormInput from './form_input.js'; +import FormSelect from './form_select.js'; +import FormField from './form_field.js'; +import Button from './button.js'; +import { h } from './element.js'; + +const fieldLabelWidth = 100; + +export default class ModalValidation extends Modal { + constructor() { + const mf = new FormField( + new FormSelect( + 'cell', + ['cell'], // cell|row|column + '100%', + it => t(`dataValidation.modeType.${it}`), + ), + { required: true }, + `${t('dataValidation.range')}:`, + fieldLabelWidth, + ); + const rf = new FormField(new FormInput('120px', 'E3 or E3:F12'), { + required: true, + pattern: /^([A-Z]{1,2}[1-9]\d*)(:[A-Z]{1,2}[1-9]\d*)?$/, + }); + const cf = new FormField( + new FormSelect( + 'list', + ['list', 'number', 'date', 'phone', 'email'], + '100%', + it => t(`dataValidation.type.${it}`), + it => this.criteriaSelected(it), + ), + { required: true }, + `${t('dataValidation.criteria')}:`, + fieldLabelWidth, + ); + + // operator + const of = new FormField( + new FormSelect( + 'be', + ['be', 'nbe', 'eq', 'neq', 'lt', 'lte', 'gt', 'gte'], + '160px', + it => t(`dataValidation.operator.${it}`), + it => this.criteriaOperatorSelected(it), + ), + { required: true }, + ).hide(); + // min, max + const minvf = new FormField(new FormInput('70px', '10'), { required: true }).hide(); + const maxvf = new FormField(new FormInput('70px', '100'), { + required: true, + type: 'number', + }).hide(); + // value + const svf = new FormField(new FormInput('120px', 'a,b,c'), { required: true }); + const vf = new FormField(new FormInput('70px', '10'), { + required: true, + type: 'number', + }).hide(); + + super(t('contextmenu.validation'), [ + h('div', `${cssPrefix}-form-fields`).children(mf.el, rf.el), + h('div', `${cssPrefix}-form-fields`).children( + cf.el, + of.el, + minvf.el, + maxvf.el, + vf.el, + svf.el, + ), + h('div', `${cssPrefix}-buttons`).children( + new Button('cancel').on('click', () => this.btnClick('cancel')), + new Button('remove').on('click', () => this.btnClick('remove')), + new Button('save', 'primary').on('click', () => this.btnClick('save')), + ), + ]); + this.mf = mf; + this.rf = rf; + this.cf = cf; + this.of = of; + this.minvf = minvf; + this.maxvf = maxvf; + this.vf = vf; + this.svf = svf; + this.change = () => { + console.log('empty function'); + }; + } + + showVf(it) { + const hint = it === 'date' ? '2018-11-12' : '10'; + const { vf } = this; + vf.input.hint(hint); + vf.show(); + } + + criteriaSelected(it) { + const { of, minvf, maxvf, vf, svf } = this; + if (it === 'date' || it === 'number') { + of.show(); + minvf.rule.type = it; + maxvf.rule.type = it; + if (it === 'date') { + minvf.hint('2018-11-12'); + maxvf.hint('2019-11-12'); + } else { + minvf.hint('10'); + maxvf.hint('100'); + } + minvf.show(); + maxvf.show(); + vf.hide(); + svf.hide(); + } else { + if (it === 'list') { + svf.show(); + } else { + svf.hide(); + } + vf.hide(); + of.hide(); + minvf.hide(); + maxvf.hide(); + } + } + + criteriaOperatorSelected(it) { + if (!it) return; + const { minvf, maxvf, vf } = this; + if (it === 'be' || it === 'nbe') { + minvf.show(); + maxvf.show(); + vf.hide(); + } else { + const type = this.cf.val(); + vf.rule.type = type; + if (type === 'date') { + vf.hint('2018-11-12'); + } else { + vf.hint('10'); + } + vf.show(); + minvf.hide(); + maxvf.hide(); + } + } + + btnClick(action) { + if (action === 'cancel') { + this.hide(); + } else if (action === 'remove') { + this.change('remove'); + this.hide(); + } else if (action === 'save') { + // validate + const attrs = ['mf', 'rf', 'cf', 'of', 'svf', 'vf', 'minvf', 'maxvf']; + for (let i = 0; i < attrs.length; i += 1) { + const field = this[attrs[i]]; + // console.log('field:', field); + if (field.isShow()) { + // console.log('it:', it); + if (!field.validate()) return; + } + } + + const mode = this.mf.val(); + const ref = this.rf.val(); + const type = this.cf.val(); + const operator = this.of.val(); + let value = this.svf.val(); + if (type === 'number' || type === 'date') { + if (operator === 'be' || operator === 'nbe') { + value = [this.minvf.val(), this.maxvf.val()]; + } else { + value = this.vf.val(); + } + } + // console.log(mode, ref, type, operator, value); + this.change('save', mode, ref, type, operator, { + required: false, + value, + }); + this.hide(); + } + } + + // validation: { mode, ref, validator } + setValue(v) { + if (v) { + const { mf, rf, cf, of, svf, vf, minvf, maxvf } = this; + const { mode, ref, validator } = v; + const { type, operator, value } = validator || { type: 'list' }; + mf.val(mode || 'cell'); + rf.val(ref); + cf.val(type); + of.val(operator); + if (Array.isArray(value)) { + minvf.val(value[0]); + maxvf.val(value[1]); + } else { + svf.val(value || ''); + vf.val(value || ''); + } + this.criteriaSelected(type); + this.criteriaOperatorSelected(operator); + } + this.show(); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/print.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/print.js new file mode 100644 index 00000000..41282326 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/print.js @@ -0,0 +1,213 @@ +import { cssPrefix } from '../config.js'; +import { Draw } from '../canvas/draw.js'; +import { t } from '../locale/locale.js'; +import { h } from './element.js'; +import Button from './button.js'; +import { renderCell } from './table.js'; + +// resolution: 72 => 595 x 842 +// 150 => 1240 x 1754 +// 200 => 1654 x 2339 +// 300 => 2479 x 3508 +// 96 * cm / 2.54 , 96 * cm / 2.54 + +const PAGER_SIZES = [ + ['A3', 11.69, 16.54], + ['A4', 8.27, 11.69], + ['A5', 5.83, 8.27], + ['B4', 9.84, 13.9], + ['B5', 6.93, 9.84], +]; + +const PAGER_ORIENTATIONS = ['landscape', 'portrait']; + +function inches2px(inc) { + return parseInt(96 * inc, 10); +} + +function btnClick(type) { + if (type === 'cancel') { + this.el.hide(); + } else { + this.toPrint(); + } +} + +function pagerSizeChange(evt) { + const { paper } = this; + const { value } = evt.target; + const ps = PAGER_SIZES[value]; + paper.w = inches2px(ps[1]); + paper.h = inches2px(ps[2]); + // console.log('paper:', ps, paper); + this.preview(); +} +function pagerOrientationChange(evt) { + const { paper } = this; + const { value } = evt.target; + const v = PAGER_ORIENTATIONS[value]; + paper.orientation = v; + this.preview(); +} + +export default class Print { + constructor(data) { + this.paper = { + w: inches2px(PAGER_SIZES[0][1]), + h: inches2px(PAGER_SIZES[0][2]), + padding: 50, + orientation: PAGER_ORIENTATIONS[0], + get width() { + return this.orientation === 'landscape' ? this.h : this.w; + }, + get height() { + return this.orientation === 'landscape' ? this.w : this.h; + }, + }; + this.data = data; + this.el = h('div', `${cssPrefix}-print`) + .children( + h('div', `${cssPrefix}-print-bar`).children( + h('div', '-title').child('Print settings'), + h('div', '-right').children( + h('div', `${cssPrefix}-buttons`).children( + new Button('cancel').on('click', btnClick.bind(this, 'cancel')), + new Button('next', 'primary').on('click', btnClick.bind(this, 'next')), + ), + ), + ), + h('div', `${cssPrefix}-print-content`).children( + (this.contentEl = h('div', '-content')), + h('div', '-sider').child( + h('form', '').children( + h('fieldset', '').children( + h('label', '').child(`${t('print.size')}`), + h('select', '') + .children( + ...PAGER_SIZES.map((it, index) => + h('option', '') + .attr('value', index) + .child(`${it[0]} ( ${it[1]}''x${it[2]}'' )`), + ), + ) + .on('change', pagerSizeChange.bind(this)), + ), + h('fieldset', '').children( + h('label', '').child(`${t('print.orientation')}`), + h('select', '') + .children( + ...PAGER_ORIENTATIONS.map((it, index) => + h('option', '') + .attr('value', index) + .child(`${t('print.orientations')[index]}`), + ), + ) + .on('change', pagerOrientationChange.bind(this)), + ), + ), + ), + ), + ) + .hide(); + } + + resetData(data) { + this.data = data; + } + + preview() { + const { data, paper } = this; + const { width, height, padding } = paper; + const iwidth = width - padding * 2; + const iheight = height - padding * 2; + const cr = data.contentRange(); + const pages = parseInt(cr.h / iheight, 10) + 1; + const scale = iwidth / cr.w; + let left = padding; + const top = padding; + if (scale > 1) { + left += (iwidth - cr.w) / 2; + } + let ri = 0; + let yoffset = 0; + this.contentEl.html(''); + this.canvases = []; + const mViewRange = { + sri: 0, + sci: 0, + eri: 0, + eci: 0, + }; + for (let i = 0; i < pages; i += 1) { + let th = 0; + let yo = 0; + const wrap = h('div', `${cssPrefix}-canvas-card`); + const canvas = h('canvas', `${cssPrefix}-canvas`); + this.canvases.push(canvas.el); + const draw = new Draw(canvas.el, width, height); + // cell-content + draw.save(); + draw.translate(left, top); + if (scale < 1) draw.scale(scale, scale); + // console.log('ri:', ri, cr.eri, yoffset); + for (; ri <= cr.eri; ri += 1) { + const rh = data.rows.getHeight(ri); + th += rh; + if (th < iheight) { + for (let ci = 0; ci <= cr.eci; ci += 1) { + renderCell(draw, data, ri, ci, yoffset); + mViewRange.eci = ci; + } + } else { + yo = -(th - rh); + break; + } + } + mViewRange.eri = ri; + draw.restore(); + // merge-cell + draw.save(); + draw.translate(left, top); + if (scale < 1) draw.scale(scale, scale); + const yof = yoffset; + data.eachMergesInView(mViewRange, ({ sri, sci }) => { + renderCell(draw, data, sri, sci, yof); + }); + draw.restore(); + + mViewRange.sri = mViewRange.eri; + mViewRange.sci = mViewRange.eci; + yoffset += yo; + this.contentEl.child(h('div', `${cssPrefix}-canvas-card-wraper`).child(wrap.child(canvas))); + } + this.el.show(); + } + + toPrint() { + this.el.hide(); + const { paper } = this; + const iframe = h('iframe', '').hide(); + const { el } = iframe; + window.document.body.appendChild(el); + const { contentWindow } = el; + const idoc = contentWindow.document; + const style = document.createElement('style'); + style.innerHTML = ` + @page { size: ${paper.width}px ${paper.height}px; }; + canvas { + page-break-before: auto; + page-break-after: always; + image-rendering: pixelated; + }; + `; + idoc.head.appendChild(style); + this.canvases.forEach(it => { + const cn = it.cloneNode(false); + const ctx = cn.getContext('2d'); + // ctx.imageSmoothingEnabled = true; + ctx.drawImage(it, 0, 0); + idoc.body.appendChild(cn); + }); + contentWindow.print(); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/resizer.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/resizer.js new file mode 100644 index 00000000..035fa1c4 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/resizer.js @@ -0,0 +1,118 @@ +import { cssPrefix } from '../config.js'; +import { h } from './element.js'; +import { mouseMoveUp } from './event.js'; + +export default class Resizer { + constructor(vertical = false, minDistance) { + this.moving = false; + this.vertical = vertical; + this.el = h('div', `${cssPrefix}-resizer ${vertical ? 'vertical' : 'horizontal'}`) + .children( + (this.unhideHoverEl = h('div', `${cssPrefix}-resizer-hover`) + .on('dblclick.stop', evt => this.mousedblclickHandler(evt)) + .css('position', 'absolute') + .hide()), + (this.hoverEl = h('div', `${cssPrefix}-resizer-hover`).on('mousedown.stop', evt => + this.mousedownHandler(evt), + )), + (this.lineEl = h('div', `${cssPrefix}-resizer-line`).hide()), + ) + .hide(); + // cell rect + this.cRect = null; + this.finishedFn = null; + this.minDistance = minDistance; + this.unhideFn = () => { + console.log('empty function'); + }; + } + + showUnhide(index) { + this.unhideIndex = index; + this.unhideHoverEl.show(); + } + + hideUnhide() { + this.unhideHoverEl.hide(); + } + + // rect : {top, left, width, height} + // line : {width, height} + show(rect, line) { + const { moving, vertical, hoverEl, lineEl, el, unhideHoverEl } = this; + if (moving) return; + this.cRect = rect; + const { left, top, width, height } = rect; + el.offset({ + left: vertical ? left + width - 5 : left, + top: vertical ? top : top + height - 5, + }).show(); + hoverEl.offset({ + width: vertical ? 5 : width, + height: vertical ? height : 5, + }); + lineEl.offset({ + width: vertical ? 0 : line.width, + height: vertical ? line.height : 0, + }); + unhideHoverEl.offset({ + left: vertical ? 5 - width : left, + top: vertical ? top : 5 - height, + width: vertical ? 5 : width, + height: vertical ? height : 5, + }); + } + + hide() { + this.el + .offset({ + left: 0, + top: 0, + }) + .hide(); + this.hideUnhide(); + } + + mousedblclickHandler() { + if (this.unhideIndex) this.unhideFn(this.unhideIndex); + } + + mousedownHandler(evt) { + let startEvt = evt; + const { el, lineEl, cRect, vertical, minDistance } = this; + let distance = vertical ? cRect.width : cRect.height; + // console.log('distance:', distance); + lineEl.show(); + mouseMoveUp( + window, + e => { + this.moving = true; + if (startEvt !== null && e.buttons === 1) { + // console.log('top:', top, ', left:', top, ', cRect:', cRect); + if (vertical) { + distance += e.movementX; + if (distance > minDistance) { + el.css('left', `${cRect.left + distance}px`); + } + } else { + distance += e.movementY; + if (distance > minDistance) { + el.css('top', `${cRect.top + distance}px`); + } + } + startEvt = e; + } + }, + () => { + startEvt = null; + lineEl.hide(); + this.moving = false; + this.hide(); + if (this.finishedFn) { + if (distance < minDistance) distance = minDistance; + this.finishedFn(cRect, distance); + } + }, + ); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/scrollbar.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/scrollbar.js new file mode 100644 index 00000000..6f38146b --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/scrollbar.js @@ -0,0 +1,47 @@ +import { cssPrefix } from '../config.js'; +import { h } from './element.js'; + +export default class Scrollbar { + constructor(vertical) { + this.vertical = vertical; + this.moveFn = null; + this.el = h('div', `${cssPrefix}-scrollbar ${vertical ? 'vertical' : 'horizontal'}`) + .child((this.contentEl = h('div', ''))) + .on('mousemove.stop', () => { + console.log('mousemove.stop'); + }) + .on('scroll.stop', evt => { + const { scrollTop, scrollLeft } = evt.target; + // console.log('scrollTop:', scrollTop); + if (this.moveFn) { + this.moveFn(this.vertical ? scrollTop : scrollLeft, evt); + } + // console.log('evt:::', evt); + }); + } + + move(v) { + this.el.scroll(v); + return this; + } + + scroll() { + return this.el.scroll(); + } + + set(distance, contentDistance) { + const d = distance - 1; + // console.log('distance:', distance, ', contentDistance:', contentDistance); + if (contentDistance > d) { + const cssKey = this.vertical ? 'height' : 'width'; + // console.log('d:', d); + this.el.css(cssKey, `${d - 15}px`).show(); + this.contentEl + .css(this.vertical ? 'width' : 'height', '1px') + .css(cssKey, `${contentDistance}px`); + } else { + this.el.hide(); + } + return this; + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/selector.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/selector.js new file mode 100644 index 00000000..9afde85e --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/selector.js @@ -0,0 +1,401 @@ +import { cssPrefix } from '../config.js'; +import { CellRange } from '../core/cell_range.js'; +import { h } from './element.js'; + +const selectorHeightBorderWidth = 2 * 2 - 1; +let startZIndex = 10; + +class SelectorElement { + constructor(useHideInput = false, autoFocus = true) { + this.useHideInput = useHideInput; + this.autoFocus = autoFocus; + this.inputChange = () => { + console.log('empty function'); + }; + this.cornerEl = h('div', `${cssPrefix}-selector-corner`); + this.areaEl = h('div', `${cssPrefix}-selector-area`).child(this.cornerEl).hide(); + this.clipboardEl = h('div', `${cssPrefix}-selector-clipboard`).hide(); + this.autofillEl = h('div', `${cssPrefix}-selector-autofill`).hide(); + this.el = h('div', `${cssPrefix}-selector`) + .css('z-index', `${startZIndex}`) + .children(this.areaEl, this.clipboardEl, this.autofillEl) + .hide(); + if (useHideInput) { + this.hideInput = h('input', '').on('compositionend', evt => { + this.inputChange(evt.target.value); + }); + this.el.child((this.hideInputDiv = h('div', 'hide-input').child(this.hideInput))); + this.el.child((this.hideInputDiv = h('div', 'hide-input').child(this.hideInput))); + } + startZIndex += 1; + } + + setOffset(v) { + this.el.offset(v).show(); + return this; + } + + hide() { + this.el.hide(); + return this; + } + + setAreaOffset(v) { + const { left, top, width, height } = v; + const of = { + width: width - selectorHeightBorderWidth + 0.8, + height: height - selectorHeightBorderWidth + 0.8, + left: left - 0.8, + top: top - 0.8, + }; + this.areaEl.offset(of).show(); + if (this.useHideInput) { + this.hideInputDiv.offset(of); + if (this.autoFocus) { + this.hideInput.val('').focus(); + } else { + this.hideInput.val(''); + } + } + } + + setClipboardOffset(v) { + const { left, top, width, height } = v; + this.clipboardEl.offset({ + left, + top, + width: width - 5, + height: height - 5, + }); + } + + showAutofill(v) { + const { left, top, width, height } = v; + this.autofillEl + .offset({ + width: width - selectorHeightBorderWidth, + height: height - selectorHeightBorderWidth, + left, + top, + }) + .show(); + } + + hideAutofill() { + this.autofillEl.hide(); + } + + showClipboard() { + this.clipboardEl.show(); + } + + hideClipboard() { + this.clipboardEl.hide(); + } +} + +function calBRAreaOffset(offset) { + const { data } = this; + const { left, top, width, height, scroll, l, t } = offset; + const ftwidth = data.freezeTotalWidth(); + const ftheight = data.freezeTotalHeight(); + let left0 = left - ftwidth; + if (ftwidth > l) left0 -= scroll.x; + let top0 = top - ftheight; + if (ftheight > t) top0 -= scroll.y; + return { + left: left0, + top: top0, + width, + height, + }; +} + +function calTAreaOffset(offset) { + const { data } = this; + const { left, width, height, l, t, scroll } = offset; + const ftwidth = data.freezeTotalWidth(); + let left0 = left - ftwidth; + if (ftwidth > l) left0 -= scroll.x; + return { + left: left0, + top: t, + width, + height, + }; +} + +function calLAreaOffset(offset) { + const { data } = this; + const { top, width, height, l, t, scroll } = offset; + const ftheight = data.freezeTotalHeight(); + let top0 = top - ftheight; + // console.log('ftheight:', ftheight, ', t:', t); + if (ftheight > t) top0 -= scroll.y; + return { + left: l, + top: top0, + width, + height, + }; +} + +function setBRAreaOffset(offset) { + const { br } = this; + br.setAreaOffset(calBRAreaOffset.call(this, offset)); +} + +function setTLAreaOffset(offset) { + const { tl } = this; + tl.setAreaOffset(offset); +} + +function setTAreaOffset(offset) { + const { t } = this; + t.setAreaOffset(calTAreaOffset.call(this, offset)); +} + +function setLAreaOffset(offset) { + const { l } = this; + l.setAreaOffset(calLAreaOffset.call(this, offset)); +} + +function setLClipboardOffset(offset) { + const { l } = this; + l.setClipboardOffset(calLAreaOffset.call(this, offset)); +} + +function setBRClipboardOffset(offset) { + const { br } = this; + br.setClipboardOffset(calBRAreaOffset.call(this, offset)); +} + +function setTLClipboardOffset(offset) { + const { tl } = this; + tl.setClipboardOffset(offset); +} + +function setTClipboardOffset(offset) { + const { t } = this; + t.setClipboardOffset(calTAreaOffset.call(this, offset)); +} + +function setAllAreaOffset(offset) { + setBRAreaOffset.call(this, offset); + setTLAreaOffset.call(this, offset); + setTAreaOffset.call(this, offset); + setLAreaOffset.call(this, offset); +} + +function setAllClipboardOffset(offset) { + setBRClipboardOffset.call(this, offset); + setTLClipboardOffset.call(this, offset); + setTClipboardOffset.call(this, offset); + setLClipboardOffset.call(this, offset); +} + +export default class Selector { + constructor(data) { + const { autoFocus } = data.settings; + this.inputChange = () => { + console.log('empty function'); + }; + this.data = data; + this.br = new SelectorElement(true, autoFocus); + this.t = new SelectorElement(); + this.l = new SelectorElement(); + this.tl = new SelectorElement(); + this.br.inputChange = v => { + this.inputChange(v); + }; + this.br.el.show(); + this.offset = null; + this.areaOffset = null; + this.indexes = null; + this.range = null; + this.arange = null; + this.el = h('div', `${cssPrefix}-selectors`) + .children(this.tl.el, this.t.el, this.l.el, this.br.el) + .hide(); + + // for performance + this.lastri = -1; + this.lastci = -1; + + startZIndex += 1; + } + + resetData(data) { + this.data = data; + this.range = data.selector.range; + this.resetAreaOffset(); + } + + hide() { + this.el.hide(); + } + + resetOffset() { + const { data, tl, t, l, br } = this; + const freezeHeight = data.freezeTotalHeight(); + const freezeWidth = data.freezeTotalWidth(); + if (freezeHeight > 0 || freezeWidth > 0) { + tl.setOffset({ width: freezeWidth, height: freezeHeight }); + t.setOffset({ left: freezeWidth, height: freezeHeight }); + l.setOffset({ top: freezeHeight, width: freezeWidth }); + br.setOffset({ left: freezeWidth, top: freezeHeight }); + } else { + tl.hide(); + t.hide(); + l.hide(); + br.setOffset({ left: 0, top: 0 }); + } + } + + resetAreaOffset() { + // console.log('offset:', offset); + const offset = this.data.getSelectedRect(); + const coffset = this.data.getClipboardRect(); + setAllAreaOffset.call(this, offset); + setAllClipboardOffset.call(this, coffset); + this.resetOffset(); + } + + resetBRTAreaOffset() { + const offset = this.data.getSelectedRect(); + const coffset = this.data.getClipboardRect(); + setBRAreaOffset.call(this, offset); + setTAreaOffset.call(this, offset); + setBRClipboardOffset.call(this, coffset); + setTClipboardOffset.call(this, coffset); + this.resetOffset(); + } + + resetBRLAreaOffset() { + const offset = this.data.getSelectedRect(); + const coffset = this.data.getClipboardRect(); + setBRAreaOffset.call(this, offset); + setLAreaOffset.call(this, offset); + setBRClipboardOffset.call(this, coffset); + setLClipboardOffset.call(this, coffset); + this.resetOffset(); + } + + set(ri, ci, indexesUpdated = true) { + const { data } = this; + const cellRange = data.calSelectedRangeByStart(ri, ci); + const { sri, sci } = cellRange; + if (indexesUpdated) { + let [cri, cci] = [ri, ci]; + if (ri < 0) cri = 0; + if (ci < 0) cci = 0; + data.selector.setIndexes(cri, cci); + this.indexes = [cri, cci]; + } + + this.moveIndexes = [sri, sci]; + // this.sIndexes = sIndexes; + // this.eIndexes = eIndexes; + this.range = cellRange; + this.resetAreaOffset(); + this.el.show(); + } + + setEnd(ri, ci, moving = true) { + const { data, lastri, lastci } = this; + if (moving) { + if (ri === lastri && ci === lastci) return; + this.lastri = ri; + this.lastci = ci; + } + this.range = data.calSelectedRangeByEnd(ri, ci); + setAllAreaOffset.call(this, this.data.getSelectedRect()); + } + + reset() { + // console.log('::::', this.data); + const { eri, eci } = this.data.selector.range; + this.setEnd(eri, eci); + } + + showAutofill(ri, ci) { + if (ri === -1 && ci === -1) return; + // console.log('ri:', ri, ', ci:', ci); + // const [sri, sci] = this.sIndexes; + // const [eri, eci] = this.eIndexes; + const { sri, sci, eri, eci } = this.range; + const [nri, nci] = [ri, ci]; + // const rn = eri - sri; + // const cn = eci - sci; + const srn = sri - ri; + const scn = sci - ci; + const ern = eri - ri; + const ecn = eci - ci; + if (scn > 0) { + // left + // console.log('left'); + this.arange = new CellRange(sri, nci, eri, sci - 1); + // this.saIndexes = [sri, nci]; + // this.eaIndexes = [eri, sci - 1]; + // data.calRangeIndexes2( + } else if (srn > 0) { + // top + // console.log('top'); + // nri = sri; + this.arange = new CellRange(nri, sci, sri - 1, eci); + // this.saIndexes = [nri, sci]; + // this.eaIndexes = [sri - 1, eci]; + } else if (ecn < 0) { + // right + // console.log('right'); + // nci = eci; + this.arange = new CellRange(sri, eci + 1, eri, nci); + // this.saIndexes = [sri, eci + 1]; + // this.eaIndexes = [eri, nci]; + } else if (ern < 0) { + // bottom + // console.log('bottom'); + // nri = eri; + this.arange = new CellRange(eri + 1, sci, nri, eci); + // this.saIndexes = [eri + 1, sci]; + // this.eaIndexes = [nri, eci]; + } else { + // console.log('else:'); + this.arange = null; + // this.saIndexes = null; + // this.eaIndexes = null; + return; + } + if (this.arange !== null) { + // console.log(this.saIndexes, ':', this.eaIndexes); + const offset = this.data.getRect(this.arange); + offset.width += 2; + offset.height += 2; + const { br, l, t, tl } = this; + br.showAutofill(calBRAreaOffset.call(this, offset)); + l.showAutofill(calLAreaOffset.call(this, offset)); + t.showAutofill(calTAreaOffset.call(this, offset)); + tl.showAutofill(offset); + } + } + + hideAutofill() { + ['br', 'l', 't', 'tl'].forEach(property => { + this[property].hideAutofill(); + }); + } + + showClipboard() { + const coffset = this.data.getClipboardRect(); + setAllClipboardOffset.call(this, coffset); + ['br', 'l', 't', 'tl'].forEach(property => { + this[property].showClipboard(); + }); + } + + hideClipboard() { + ['br', 'l', 't', 'tl'].forEach(property => { + this[property].hideClipboard(); + }); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/sheet.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/sheet.js new file mode 100644 index 00000000..adfee1f4 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/sheet.js @@ -0,0 +1,1089 @@ +import { cssPrefix } from '../config.js'; +import { formulas } from '../core/formula.js'; +import { h } from './element.js'; +import { bind, mouseMoveUp, bindTouch, createEventEmitter } from './event.js'; +import Resizer from './resizer.js'; +import Scrollbar from './scrollbar.js'; +import Selector from './selector.js'; +import Editor from './editor.js'; +import Print from './print.js'; +import ContextMenu from './contextmenu.js'; +import Table from './table.js'; +import Toolbar from './toolbar/index.js'; +import ModalValidation from './modal_validation.js'; +import SortFilter from './sort_filter.js'; +import { xtoast } from './message.js'; + +/** + * @desc throttle fn + * @param func function + * @param wait Delay in milliseconds + */ +function throttle(func, wait) { + let timeout; + return (...arg) => { + const args = arg; + if (!timeout) { + timeout = setTimeout(() => { + timeout = null; + func.apply(this, args); + }, wait); + } + }; +} + +function scrollbarMove() { + const { data, verticalScrollbar, horizontalScrollbar } = this; + const { l, t, left, top, width, height } = data.getSelectedRect(); + const tableOffset = this.getTableOffset(); + // console.log(',l:', l, ', left:', left, ', tOffset.left:', tableOffset.width); + if (Math.abs(left) + width > tableOffset.width) { + horizontalScrollbar.move({ left: l + width - tableOffset.width }); + } else { + const fsw = data.freezeTotalWidth(); + if (left < fsw) { + horizontalScrollbar.move({ left: l - 1 - fsw }); + } + } + // console.log('top:', top, ', height:', height, ', tof.height:', tableOffset.height); + if (Math.abs(top) + height > tableOffset.height) { + verticalScrollbar.move({ top: t + height - tableOffset.height - 1 }); + } else { + const fsh = data.freezeTotalHeight(); + if (top < fsh) { + verticalScrollbar.move({ top: t - 1 - fsh }); + } + } +} + +function selectorSet(multiple, ri, ci, indexesUpdated = true, moving = false) { + if (ri === -1 && ci === -1) return; + const { table, selector, toolbar, data, contextMenu } = this; + const cell = data.getCell(ri, ci); + if (multiple) { + selector.setEnd(ri, ci, moving); + this.trigger('cells-selected', cell, selector.range); + } else { + // trigger click event + selector.set(ri, ci, indexesUpdated); + this.trigger('cell-selected', cell, ri, ci); + } + contextMenu.setMode(ri === -1 || ci === -1 ? 'row-col' : 'range'); + toolbar.reset(); + table.render(); +} + +// multiple: boolean +// direction: left | right | up | down | row-first | row-last | col-first | col-last +function selectorMove(multiple, direction) { + const { selector, data } = this; + const { rows, cols } = data; + let [ri, ci] = selector.indexes; + const { eri, eci } = selector.range; + if (multiple) { + [ri, ci] = selector.moveIndexes; + } + // console.log('selector.move:', ri, ci); + if (direction === 'left') { + if (ci > 0) ci -= 1; + } else if (direction === 'right') { + if (eci !== ci) ci = eci; + if (ci < cols.len - 1) ci += 1; + } else if (direction === 'up') { + if (ri > 0) ri -= 1; + } else if (direction === 'down') { + if (eri !== ri) ri = eri; + if (ri < rows.len - 1) ri += 1; + } else if (direction === 'row-first') { + ci = 0; + } else if (direction === 'row-last') { + ci = cols.len - 1; + } else if (direction === 'col-first') { + ri = 0; + } else if (direction === 'col-last') { + ri = rows.len - 1; + } + if (multiple) { + selector.moveIndexes = [ri, ci]; + } + selectorSet.call(this, multiple, ri, ci); + scrollbarMove.call(this); +} + +// private methods +function overlayerMousemove(evt) { + // console.log('x:', evt.offsetX, ', y:', evt.offsetY); + if (evt.buttons !== 0) return; + if (evt.target.className === `${cssPrefix}-resizer-hover`) return; + const { offsetX, offsetY } = evt; + const { rowResizer, colResizer, tableEl, data } = this; + const { rows, cols } = data; + if (offsetX > cols.indexWidth && offsetY > rows.height) { + rowResizer.hide(); + colResizer.hide(); + return; + } + const tRect = tableEl.box(); + const cRect = data.getCellRectByXY(evt.offsetX, evt.offsetY); + if (cRect.ri >= 0 && cRect.ci === -1) { + cRect.width = cols.indexWidth; + rowResizer.show(cRect, { + width: tRect.width, + }); + if (rows.isHide(cRect.ri - 1)) { + rowResizer.showUnhide(cRect.ri); + } else { + rowResizer.hideUnhide(); + } + } else { + rowResizer.hide(); + } + if (cRect.ri === -1 && cRect.ci >= 0) { + cRect.height = rows.height; + colResizer.show(cRect, { + height: tRect.height, + }); + if (cols.isHide(cRect.ci - 1)) { + colResizer.showUnhide(cRect.ci); + } else { + colResizer.hideUnhide(); + } + } else { + colResizer.hide(); + } +} + +// let scrollThreshold = 15; +function overlayerMousescroll(evt) { + // scrollThreshold -= 1; + // if (scrollThreshold > 0) return; + // scrollThreshold = 15; + + const { verticalScrollbar, horizontalScrollbar, data } = this; + const { top } = verticalScrollbar.scroll(); + const { left } = horizontalScrollbar.scroll(); + // console.log('evt:::', evt.wheelDelta, evt.detail * 40); + + const { rows, cols } = data; + + // deltaY for vertical delta + const { deltaY, deltaX } = evt; + const loopValue = (ii, vFunc) => { + let i = ii; + let v = 0; + do { + v = vFunc(i); + i += 1; + } while (v <= 0); + return v; + }; + // console.log('deltaX', deltaX, 'evt.detail', evt.detail); + // if (evt.detail) deltaY = evt.detail * 40; + const moveY = vertical => { + if (vertical > 0) { + // up + const ri = data.scroll.ri + 1; + if (ri < rows.len) { + const rh = loopValue(ri, i => rows.getHeight(i)); + verticalScrollbar.move({ top: top + rh - 1 }); + } + } else { + // down + const ri = data.scroll.ri - 1; + if (ri >= 0) { + const rh = loopValue(ri, i => rows.getHeight(i)); + verticalScrollbar.move({ top: ri === 0 ? 0 : top - rh }); + } + } + }; + + // deltaX for Mac horizontal scroll + const moveX = horizontal => { + if (horizontal > 0) { + // left + const ci = data.scroll.ci + 1; + if (ci < cols.len) { + const cw = loopValue(ci, i => cols.getWidth(i)); + horizontalScrollbar.move({ left: left + cw - 1 }); + } + } else { + // right + const ci = data.scroll.ci - 1; + if (ci >= 0) { + const cw = loopValue(ci, i => cols.getWidth(i)); + horizontalScrollbar.move({ left: ci === 0 ? 0 : left - cw }); + } + } + }; + const tempY = Math.abs(deltaY); + const tempX = Math.abs(deltaX); + const temp = Math.max(tempY, tempX); + // console.log('event:', evt); + // detail for windows/mac firefox vertical scroll + if (/Firefox/i.test(window.navigator.userAgent)) throttle(moveY(evt.detail), 50); + if (temp === tempX) throttle(moveX(deltaX), 50); + if (temp === tempY) throttle(moveY(deltaY), 50); +} +/** + * 表格覆盖层拖动结束事件 + * @ignore + * @param evt + */ +function overlayerMouseDrop(evt) { + const { selector, data, toolbar } = this; + if (data.settings.mode === 'read') return; + const { offsetX, offsetY } = evt; + const cellRect = data.getCellRectByXY(offsetX, offsetY); + const { ri, ci } = cellRect; + // 触发拖动结束事件 + const cell = data.getCell(ri, ci); + selector.set(ri, ci, true); + this.trigger('cell-drop', cell, ri, ci, evt); + toolbar.reset(); + // selectorSet.call(this, false, ri, ci); + this.trigger('cell-selected', data.getCell(ri, ci), ri, ci); +} +function overlayerTouch(direction, distance) { + const { verticalScrollbar, horizontalScrollbar } = this; + const { top } = verticalScrollbar.scroll(); + const { left } = horizontalScrollbar.scroll(); + + if (direction === 'left' || direction === 'right') { + horizontalScrollbar.move({ left: left - distance }); + } else if (direction === 'up' || direction === 'down') { + verticalScrollbar.move({ top: top - distance }); + } +} + +function verticalScrollbarSet() { + const { data, verticalScrollbar } = this; + const { height } = this.getTableOffset(); + const erth = data.exceptRowTotalHeight(0, -1); + // console.log('erth:', erth); + verticalScrollbar.set(height, data.rows.totalHeight() - erth); +} + +function horizontalScrollbarSet() { + const { data, horizontalScrollbar } = this; + const { width } = this.getTableOffset(); + if (data) { + horizontalScrollbar.set(width, data.cols.totalWidth()); + } +} + +function sheetFreeze() { + const { selector, data, editor } = this; + const [ri, ci] = data.freeze; + if (ri > 0 || ci > 0) { + const fwidth = data.freezeTotalWidth(); + const fheight = data.freezeTotalHeight(); + editor.setFreezeLengths(fwidth, fheight); + } + selector.resetAreaOffset(); +} + +function sheetReset() { + const { tableEl, overlayerEl, overlayerCEl, table, toolbar, selector, el } = this; + const tOffset = this.getTableOffset(); + const vRect = this.getRect(); + tableEl.attr(vRect); + overlayerEl.offset(vRect); + overlayerCEl.offset(tOffset); + el.css('width', `${vRect.width}px`); + verticalScrollbarSet.call(this); + horizontalScrollbarSet.call(this); + sheetFreeze.call(this); + table.render(); + toolbar.reset(); + selector.reset(); +} + +function clearClipboard() { + const { data, selector } = this; + data.clearClipboard(); + selector.hideClipboard(); +} + +function copy(evt) { + const { data, selector } = this; + if (data.settings.mode === 'read') return; + data.copy(); + data.copyToSystemClipboard(evt); + selector.showClipboard(); +} + +function cut() { + const { data, selector } = this; + if (data.settings.mode === 'read') return; + data.cut(); + selector.showClipboard(); +} + +function paste(what, evt) { + const { data } = this; + if (data.settings.mode === 'read') return; + if (data.clipboard.isClear()) { + const resetSheet = () => sheetReset.call(this); + const eventTrigger = rows => { + this.trigger('pasted-clipboard', rows); + }; + // pastFromSystemClipboard is async operation, need to tell it how to reset sheet and trigger event after it finishes + // pasting content from system clipboard + data.pasteFromSystemClipboard(resetSheet, eventTrigger); + } else if (data.paste(what, msg => xtoast('Tip', msg))) { + sheetReset.call(this); + } else if (evt) { + const cdata = evt.clipboardData.getData('text/plain'); + this.data.pasteFromText(cdata); + sheetReset.call(this); + } +} + +function hideRowsOrCols() { + this.data.hideRowsOrCols(); + sheetReset.call(this); +} + +function unhideRowsOrCols(type, index) { + this.data.unhideRowsOrCols(type, index); + sheetReset.call(this); +} + +function autofilter() { + const { data } = this; + data.autofilter(); + sheetReset.call(this); +} + +function toolbarChangePaintformatPaste() { + const { toolbar } = this; + if (toolbar.paintformatActive()) { + paste.call(this, 'format'); + clearClipboard.call(this); + toolbar.paintformatToggle(); + } +} + +function overlayerMousedown(evt) { + // console.log(':::::overlayer.mousedown:', evt.detail, evt.button, evt.buttons, evt.shiftKey); + // console.log('evt.target.className:', evt.target.className); + const { selector, data, table, sortFilter } = this; + if (data.settings.mode === 'read') return; + const { offsetX, offsetY } = evt; + const isAutofillEl = evt.target.className === `${cssPrefix}-selector-corner`; + const cellRect = data.getCellRectByXY(offsetX, offsetY); + const { left, top, width, height } = cellRect; + let { ri, ci } = cellRect; + // sort or filter + const { autoFilter } = data; + if (autoFilter.includes(ri, ci)) { + if (left + width - 20 < offsetX && top + height - 20 < offsetY) { + const items = autoFilter.items(ci, (r, c) => data.rows.getCell(r, c)); + sortFilter.hide(); + sortFilter.set(ci, items, autoFilter.getFilter(ci), autoFilter.getSort(ci)); + sortFilter.setOffset({ left, top: top + height + 2 }); + return; + } + } + + // console.log('ri:', ri, ', ci:', ci); + if (!evt.shiftKey) { + // console.log('selectorSetStart:::'); + if (isAutofillEl) { + selector.showAutofill(ri, ci); + } else { + selectorSet.call(this, false, ri, ci); + } + + // mouse move up + mouseMoveUp( + window, + e => { + // console.log('mouseMoveUp::::'); + ({ ri, ci } = data.getCellRectByXY(e.offsetX, e.offsetY)); + if (isAutofillEl) { + selector.showAutofill(ri, ci); + } else if (e.buttons === 1 && !e.shiftKey) { + // if(ri < 1 || ci < 1) { + // return + // } + selectorSet.call(this, true, ri, ci, true, true); + } + }, + () => { + if (isAutofillEl && selector.arange && data.settings.mode !== 'read') { + if (data.autofill(selector.arange, 'all', msg => xtoast('Tip', msg))) { + table.render(); + } + } + selector.hideAutofill(); + toolbarChangePaintformatPaste.call(this); + }, + ); + } + + if (!isAutofillEl && evt.buttons === 1) { + if (evt.shiftKey) { + // console.log('shiftKey::::'); + selectorSet.call(this, true, ri, ci); + } + } +} + +function editorSetOffset() { + const { editor, data } = this; + const sOffset = data.getSelectedRect(); + const tOffset = this.getTableOffset(); + let sPosition = 'top'; + // console.log('sOffset:', sOffset, ':', tOffset); + if (sOffset.top > tOffset.height / 2) { + sPosition = 'bottom'; + } + editor.setOffset(sOffset, sPosition); +} + +function editorSet() { + const { editor, data } = this; + if (data.settings.mode === 'read') return; + // 隐藏内容的单元格禁止编辑 + const selectedCell = data.getSelectedCell(); + if (selectedCell && selectedCell.hidden) { + return; + } + if (data.settings.mode === 'edit') { + editorSetOffset.call(this); + editor.setCell(selectedCell, data.getSelectedValidator()); + clearClipboard.call(this); + } +} + +function verticalScrollbarMove(distance) { + const { data, table, selector } = this; + data.scrolly(distance, () => { + selector.resetBRLAreaOffset(); + editorSetOffset.call(this); + table.render(); + }); +} + +function horizontalScrollbarMove(distance) { + const { data, table, selector } = this; + data.scrollx(distance, () => { + selector.resetBRTAreaOffset(); + editorSetOffset.call(this); + table.render(); + }); +} + +function rowResizerFinished(cRect, distance) { + const { ri } = cRect; + const { table, selector, data } = this; + const { sri, eri } = selector.range; + if (ri >= sri && ri <= eri) { + for (let row = sri; row <= eri; row += 1) { + data.rows.setHeight(row, distance); + } + } else { + data.rows.setHeight(ri, distance); + } + + table.render(); + selector.resetAreaOffset(); + verticalScrollbarSet.call(this); + editorSetOffset.call(this); +} + +function colResizerFinished(cRect, distance) { + const { ci } = cRect; + const { table, selector, data } = this; + const { sci, eci } = selector.range; + if (ci >= sci && ci <= eci) { + for (let col = sci; col <= eci; col += 1) { + data.cols.setWidth(col, distance); + } + } else { + data.cols.setWidth(ci, distance); + } + + table.render(); + selector.resetAreaOffset(); + horizontalScrollbarSet.call(this); + editorSetOffset.call(this); +} + +function dataSetCellText(text, state = 'finished') { + const { data, table } = this; + // const [ri, ci] = selector.indexes; + if (data.settings.mode === 'read') return; + data.setSelectedCellText(text, state); + const { ri, ci } = data.selector; + if (state === 'finished') { + table.render(); + } else { + this.trigger('cell-edited', text, ri, ci); + } +} + +function insertDeleteRowColumn(type) { + const { data } = this; + if (data.settings.mode === 'read') return; + if (type === 'insert-row') { + data.insert('row'); + } else if (type === 'delete-row') { + data.delete('row'); + } else if (type === 'insert-column') { + data.insert('column'); + } else if (type === 'delete-column') { + data.delete('column'); + } else if (type === 'delete-cell') { + data.deleteCell(); + } else if (type === 'delete-cell-format') { + data.deleteCell('format'); + } else if (type === 'delete-cell-text') { + data.deleteCell('text'); + const { ri, ci } = data.selector; + this.trigger('cell-edited', '', ri, ci); + } else if (type === 'cell-printable') { + data.setSelectedCellAttr('printable', true); + } else if (type === 'cell-non-printable') { + data.setSelectedCellAttr('printable', false); + } else if (type === 'cell-editable') { + data.setSelectedCellAttr('editable', true); + } else if (type === 'cell-non-editable') { + data.setSelectedCellAttr('editable', false); + } + clearClipboard.call(this); + sheetReset.call(this); +} + +function toolbarChange(type, value) { + const { data } = this; + if (type === 'undo') { + this.undo(); + } else if (type === 'redo') { + this.redo(); + } else if (type === 'print') { + this.print.preview(); + } else if (type === 'paintformat') { + if (value === true) copy.call(this); + else clearClipboard.call(this); + } else if (type === 'clearformat') { + insertDeleteRowColumn.call(this, 'delete-cell-format'); + } else if (type === 'link') { + // link + } else if (type === 'chart') { + uploadImage.call(this, type); + // chart + } else if (type === 'autofilter') { + // filter + autofilter.call(this); + } else if (type === 'freeze') { + if (value) { + const { ri, ci } = data.selector; + this.freeze(ri, ci); + } else { + this.freeze(0, 0); + } + } else { + data.setSelectedCellAttr(type, value); + if (type === 'formula' && !data.selector.multiple()) { + editorSet.call(this); + } + sheetReset.call(this); + } +} + +function sortFilterChange(ci, order, operator, value) { + // console.log('sort:', sortDesc, operator, value); + this.data.setAutoFilter(ci, order, operator, value); + sheetReset.call(this); +} + +function sheetInitEvents() { + const { + selector, + overlayerEl, + rowResizer, + colResizer, + verticalScrollbar, + horizontalScrollbar, + editor, + contextMenu, + toolbar, + modalValidation, + sortFilter, + } = this; + // overlayer + overlayerEl + .on('mousemove', evt => { + overlayerMousemove.call(this, evt); + }) + .on('mousedown', evt => { + editor.clear(); + contextMenu.hide(); + // the left mouse button: mousedown → mouseup → click + // the right mouse button: mousedown → contenxtmenu → mouseup + if (evt.buttons === 2) { + if (this.data.xyInSelectedRect(evt.offsetX, evt.offsetY)) { + contextMenu.setPosition(evt.offsetX, evt.offsetY); + } else { + overlayerMousedown.call(this, evt); + contextMenu.setPosition(evt.offsetX, evt.offsetY); + } + evt.stopPropagation(); + } else if (evt.detail === 2) { + editorSet.call(this); + } else { + overlayerMousedown.call(this, evt); + } + }) + .on('mousewheel.stop', evt => { + overlayerMousescroll.call(this, evt); + }) + .on('mouseout', evt => { + const { offsetX, offsetY } = evt; + if (offsetY <= 0) colResizer.hide(); + if (offsetX <= 0) rowResizer.hide(); + }) + .on('drop', evt => { + evt.preventDefault(); + overlayerMouseDrop.call(this, evt); + }); + + selector.inputChange = v => { + dataSetCellText.call(this, v, 'input'); + editorSet.call(this); + }; + + // slide on mobile + bindTouch(overlayerEl.el, { + move: (direction, d) => { + overlayerTouch.call(this, direction, d); + }, + }); + + // toolbar change + toolbar.change = (type, value) => toolbarChange.call(this, type, value); + + // sort filter ok + sortFilter.ok = (ci, order, o, v) => sortFilterChange.call(this, ci, order, o, v); + + // resizer finished callback + rowResizer.finishedFn = (cRect, distance) => { + // if (mode !== 'edit') return + rowResizerFinished.call(this, cRect, distance); + }; + colResizer.finishedFn = (cRect, distance) => { + // if (mode !== 'edit') return + colResizerFinished.call(this, cRect, distance); + }; + // resizer unhide callback + rowResizer.unhideFn = index => { + unhideRowsOrCols.call(this, 'row', index); + }; + colResizer.unhideFn = index => { + unhideRowsOrCols.call(this, 'col', index); + }; + // scrollbar move callback + verticalScrollbar.moveFn = (distance, evt) => { + verticalScrollbarMove.call(this, distance, evt); + }; + horizontalScrollbar.moveFn = (distance, evt) => { + horizontalScrollbarMove.call(this, distance, evt); + }; + // editor + editor.change = (state, itext) => { + dataSetCellText.call(this, itext, state); + }; + // modal validation + modalValidation.change = (action, ...args) => { + if (action === 'save') { + this.data.addValidation(...args); + } else { + this.data.removeValidation(); + } + }; + // contextmenu + contextMenu.itemClick = type => { + // console.log('type:', type); + if (type === 'validation') { + modalValidation.setValue(this.data.getSelectedValidation()); + } else if (type === 'copy') { + copy.call(this); + } else if (type === 'cut') { + cut.call(this); + } else if (type === 'paste') { + paste.call(this, 'all'); + } else if (type === 'paste-value') { + paste.call(this, 'text'); + } else if (type === 'paste-format') { + paste.call(this, 'format'); + } else if (type === 'hide') { + hideRowsOrCols.call(this); + } else { + insertDeleteRowColumn.call(this, type); + } + }; + + bind(window, 'resize', () => { + this.reload(); + }); + + bind(window, 'click', evt => { + this.focusing = overlayerEl.contains(evt.target); + }); + + bind(window, 'paste', evt => { + if (!this.focusing) return; + paste.call(this, 'all', evt); + evt.preventDefault(); + }); + + bind(window, 'copy', evt => { + if (!this.focusing) return; + copy.call(this, evt); + evt.preventDefault(); + }); + + // for selector + bind(window, 'keydown', evt => { + if (!this.focusing) return; + const keyCode = evt.keyCode || evt.which; + const { key, ctrlKey, shiftKey, metaKey } = evt; + // console.log('keydown.evt: ', keyCode); + if (ctrlKey || metaKey) { + // const { sIndexes, eIndexes } = selector; + // let what = 'all'; + // if (shiftKey) what = 'text'; + // if (altKey) what = 'format'; + switch (keyCode) { + case 90: + // undo: ctrl + z + this.undo(); + evt.preventDefault(); + break; + case 89: + // redo: ctrl + y + this.redo(); + evt.preventDefault(); + break; + case 67: + // ctrl + c + // => copy + // copy.call(this); + // evt.preventDefault(); + break; + case 88: + // ctrl + x + cut.call(this); + evt.preventDefault(); + break; + case 85: + // ctrl + u + toolbar.trigger('underline'); + evt.preventDefault(); + break; + case 86: + // ctrl + v + // => paste + // evt.preventDefault(); + break; + case 37: + // ctrl + left + selectorMove.call(this, shiftKey, 'row-first'); + evt.preventDefault(); + break; + case 38: + // ctrl + up + selectorMove.call(this, shiftKey, 'col-first'); + evt.preventDefault(); + break; + case 39: + // ctrl + right + selectorMove.call(this, shiftKey, 'row-last'); + evt.preventDefault(); + break; + case 40: + // ctrl + down + selectorMove.call(this, shiftKey, 'col-last'); + evt.preventDefault(); + break; + case 32: + // ctrl + space, all cells in col + selectorSet.call(this, false, -1, this.data.selector.ci, false); + evt.preventDefault(); + break; + case 66: + // ctrl + B + toolbar.trigger('bold'); + break; + case 73: + // ctrl + I + toolbar.trigger('italic'); + break; + default: + break; + } + } else { + // console.log('evt.keyCode:', evt.keyCode); + switch (keyCode) { + case 32: + if (shiftKey) { + // shift + space, all cells in row + selectorSet.call(this, false, this.data.selector.ri, -1, false); + } + break; + case 27: // esc + contextMenu.hide(); + clearClipboard.call(this); + break; + case 37: // left + selectorMove.call(this, shiftKey, 'left'); + evt.preventDefault(); + break; + case 38: // up + selectorMove.call(this, shiftKey, 'up'); + evt.preventDefault(); + break; + case 39: // right + selectorMove.call(this, shiftKey, 'right'); + evt.preventDefault(); + break; + case 40: // down + selectorMove.call(this, shiftKey, 'down'); + evt.preventDefault(); + break; + case 9: // tab + editor.clear(); + // shift + tab => move left + // tab => move right + selectorMove.call(this, false, shiftKey ? 'left' : 'right'); + evt.preventDefault(); + break; + case 13: // enter + editor.clear(); + // shift + enter => move up + // enter => move down + selectorMove.call(this, false, shiftKey ? 'up' : 'down'); + evt.preventDefault(); + break; + case 8: // backspace + insertDeleteRowColumn.call(this, 'delete-cell-text'); + evt.preventDefault(); + break; + default: + break; + } + + if (key === 'Delete') { + insertDeleteRowColumn.call(this, 'delete-cell-text'); + evt.preventDefault(); + } else if ( + (keyCode >= 65 && keyCode <= 90) || + (keyCode >= 48 && keyCode <= 57) || + (keyCode >= 96 && keyCode <= 105) || + evt.key === '=' + ) { + dataSetCellText.call(this, evt.key, 'input'); + editorSet.call(this); + } else if (keyCode === 113) { + // F2 + editorSet.call(this); + } + } + }); +} + +function fileOpen() { + console.warn('fileOpen not implemented'); +} + +async function uploadImage(type) { + try { + const blob = await fileOpen({ + description: 'Image files', + mimeTypes: ['image/jpg', 'image/png', 'image/gif', 'image/webp'], + extensions: ['.jpg', '.jpeg', '.png', '.gif', '.webp'], + }); + // 将图片上传到指定的服务器。 + const { data } = this; + const reader = new FileReader(); + let imgUrlBase64; + reader.readAsDataURL(blob); + reader.onload = evt => { + imgUrlBase64 = evt.target.result; + // cancelIdleCallback(evt.target.result); + data.setSelectedCellAttr('type', 'image' || type); // 设置类型,方便后面的渲染。 + // data.setSelectedCellAttr('value', imgUrlBase64); // 设置图片地址。方面后面使用地址渲染。 + // data.setSelectedCellAttr('left', data.getSelectedRect().left); + // data.setSelectedCellAttr('top', data.getSelectedRect().top); + data.rows._[data.selector.ri].cells[data.selector.ci].value = imgUrlBase64; + data.rows._[data.selector.ri].cells[data.selector.ci].left = data.getSelectedRect().left; + data.rows._[data.selector.ri].cells[data.selector.ci].top = data.getSelectedRect().top; + const image = new Image(); + image.src = imgUrlBase64; + image.onload = function () { + const width = this.width; + const height = this.height; + // data.setSelectedCellAttr('imagewidth', width); + // data.setSelectedCellAttr('imageheight', height); + data.rows._[data.selector.ri].cells[data.selector.ci].imagewidth = width; + data.rows._[data.selector.ri].cells[data.selector.ci].imageheight = height; + }; + + sheetReset.call(this); + }; + + // console.log('64',imgUrlBase64) + + // const response = await fetch(url, { + // method, + // body: formData, + // }); + // if (success && typeof success === 'function') { + // success(response); + // } + // const json = await response.json(); + // 具体结构要后台接口提供。 + // const { code, message, data: imageUrl } = json; + // if (code !== 0) { + // throw new Error(message); + // } + // const { thumbUrl: imageUrl } = json; + // 其实是设置该单元格 type: 'image', value: imageUrl,在后面进行渲染。 + // 因为 setSelectedCellAttr 只能设置一个值,所以这里需要先设置 type,再设置 value。 + // 因为原渲染内容使用 text,我们既需要地址,又不像渲染 text,所以使用 value。 + // const imageUrl = 'C:\Users\shm\Pictures\29-20040Q60Z70-L.jpg' + // data.setSelectedCellAttr('type', 'image' || type); // 设置类型,方便后面的渲染。 + // data.setSelectedCellAttr('value', imgUrlBase64); // 设置图片地址。方面后面使用地址渲染。 + // sheetReset.call(this); + } catch (e) { + console.error(e); + } +} +const getWidth = () => { + return '100%'; +}; +export default class Sheet { + constructor(targetEl, data) { + this.eventMap = createEventEmitter(); + const { showToolbar, showContextmenu, mode } = data.settings; + this.el = h('div', `${cssPrefix}-sheet`); + + this.toolbar = new Toolbar(data, getWidth, !showToolbar); + this.print = new Print(data); + targetEl.children(this.toolbar.el, this.el, this.print.el); + this.data = data; + // table + this.tableEl = h('canvas', `${cssPrefix}-table`); + // resizer + this.rowResizer = new Resizer(false, data.rows.height); + this.colResizer = new Resizer(true, data.cols.minWidth); + // scrollbar + this.verticalScrollbar = new Scrollbar(true); + this.horizontalScrollbar = new Scrollbar(false); + // editor + this.editor = new Editor(formulas, () => this.getTableOffset(), data.rows.height); + // data validation + this.modalValidation = new ModalValidation(); + // contextMenu + this.contextMenu = new ContextMenu(() => this.getRect(), !showContextmenu); + // selector + this.selector = new Selector(data); + this.overlayerCEl = h('div', `${cssPrefix}-overlayer-content`).children( + this.editor.el, + this.selector.el, + ); + this.overlayerEl = h('div', `${cssPrefix}-overlayer`).child(this.overlayerCEl); + // sortFilter + this.sortFilter = new SortFilter(); + // root element + this.el.children( + this.tableEl, + this.overlayerEl.el, + this.rowResizer.el, + this.colResizer.el, + this.verticalScrollbar.el, + this.horizontalScrollbar.el, + this.contextMenu.el, + this.modalValidation.el, + this.sortFilter.el, + ); + // table + this.table = new Table(this.tableEl.el, data); + sheetInitEvents.call(this); + sheetReset.call(this); + // init selector [0, 0] + if (mode !== 'read') { + selectorSet.call(this, false, 0, 0); + } + } + + on(eventName, func) { + this.eventMap.on(eventName, func); + return this; + } + + trigger(eventName, ...args) { + const { eventMap } = this; + eventMap.fire(eventName, args); + } + + resetData(data) { + // before + this.editor.clear(); + // after + this.data = data; + verticalScrollbarSet.call(this); + horizontalScrollbarSet.call(this); + this.toolbar.resetData(data); + this.print.resetData(data); + this.selector.resetData(data); + this.table.resetData(data); + } + + loadData(data) { + this.data.setData(data); + sheetReset.call(this); + return this; + } + + // freeze rows or cols + freeze(ri, ci) { + const { data } = this; + data.setFreeze(ri, ci); + sheetReset.call(this); + return this; + } + + undo() { + this.data.undo(); + sheetReset.call(this); + } + + redo() { + this.data.redo(); + sheetReset.call(this); + } + + reload() { + sheetReset.call(this); + return this; + } + + getRect() { + const { data } = this; + return { width: data.viewWidth(), height: data.viewHeight() }; + } + + getTableOffset() { + const { rows, cols } = this.data; + const { width, height } = this.getRect(); + return { + width: width - cols.indexWidth, + height: height - rows.height, + left: cols.indexWidth, + top: rows.height, + }; + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/sort_filter.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/sort_filter.js new file mode 100644 index 00000000..b678726f --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/sort_filter.js @@ -0,0 +1,148 @@ +import { cssPrefix } from '../config.js'; +import { t } from '../locale/locale.js'; +import { h } from './element.js'; +import Button from './button.js'; +import { bindClickoutside, unbindClickoutside } from './event.js'; + +function buildMenu(clsName) { + return h('div', `${cssPrefix}-item ${clsName}`); +} + +function buildSortItem(it) { + return buildMenu('state') + .child(t(`sort.${it}`)) + .on('click.stop', () => this.itemClick(it)); +} + +function buildFilterBody(items) { + const { filterbEl, filterValues } = this; + filterbEl.html(''); + const itemKeys = Object.keys(items); + itemKeys.forEach((it, index) => { + const cnt = items[it]; + const active = filterValues.includes(it) ? 'checked' : ''; + filterbEl.child( + h('div', `${cssPrefix}-item state ${active}`) + .on('click.stop', () => this.filterClick(index, it)) + .children(it === '' ? t('filter.empty') : it, h('div', 'label').html(`(${cnt})`)), + ); + }); +} + +function resetFilterHeader() { + const { filterhEl, filterValues, values } = this; + filterhEl.html(`${filterValues.length} / ${values.length}`); + filterhEl.checked(filterValues.length === values.length); +} + +export default class SortFilter { + constructor() { + this.filterbEl = h('div', `${cssPrefix}-body`); + this.filterhEl = h('div', `${cssPrefix}-header state`).on('click.stop', () => + this.filterClick(0, 'all'), + ); + this.el = h('div', `${cssPrefix}-sort-filter`) + .children( + (this.sortAscEl = buildSortItem.call(this, 'asc')), + (this.sortDescEl = buildSortItem.call(this, 'desc')), + buildMenu('divider'), + h('div', `${cssPrefix}-filter`).children(this.filterhEl, this.filterbEl), + h('div', `${cssPrefix}-buttons`).children( + new Button('cancel').on('click', () => this.btnClick('cancel')), + new Button('ok', 'primary').on('click', () => this.btnClick('ok')), + ), + ) + .hide(); + // this.setFilters(['test1', 'test2', 'text3']); + this.ci = null; + this.sortDesc = null; + this.values = null; + this.filterValues = []; + } + + btnClick(it) { + if (it === 'ok') { + const { ci, sort, filterValues } = this; + if (this.ok) { + this.ok(ci, sort, 'in', filterValues); + } + } + this.hide(); + } + + itemClick(it) { + // console.log('it:', it); + this.sort = it; + const { sortAscEl, sortDescEl } = this; + sortAscEl.checked(it === 'asc'); + sortDescEl.checked(it === 'desc'); + } + + filterClick(index, it) { + // console.log('index:', index, it); + const { filterbEl, filterValues, values } = this; + const children = filterbEl.children(); + if (it === 'all') { + if (children.length === filterValues.length) { + this.filterValues = []; + children.forEach(i => h(i).checked(false)); + } else { + this.filterValues = Array.from(values); + children.forEach(i => h(i).checked(true)); + } + } else { + const checked = h(children[index]).toggle('checked'); + if (checked) { + filterValues.push(it); + } else { + filterValues.splice( + filterValues.findIndex(i => i === it), + 1, + ); + } + } + resetFilterHeader.call(this); + } + + // v: autoFilter + // items: {value: cnt} + // sort { ci, order } + set(ci, items, filter, sort) { + this.ci = ci; + const { sortAscEl, sortDescEl } = this; + if (sort !== null) { + this.sort = sort.order; + sortAscEl.checked(sort.asc()); + sortDescEl.checked(sort.desc()); + } else { + this.sortDesc = null; + sortAscEl.checked(false); + sortDescEl.checked(false); + } + // this.setFilters(items, filter); + this.values = Object.keys(items); + this.filterValues = filter ? Array.from(filter.value) : Object.keys(items); + buildFilterBody.call(this, items, filter); + resetFilterHeader.call(this); + } + + setOffset(v) { + this.el.offset(v).show(); + let tindex = 1; + bindClickoutside(this.el, () => { + if (tindex <= 0) { + this.hide(); + } + tindex -= 1; + }); + } + + show() { + this.el.show(); + } + + hide() { + this.el.hide(); + unbindClickoutside(this.el); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/suggest.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/suggest.js new file mode 100644 index 00000000..123b5002 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/suggest.js @@ -0,0 +1,138 @@ +import { cssPrefix } from '../config.js'; +import { h } from './element.js'; +import { bindClickoutside, unbindClickoutside } from './event.js'; + +function inputMovePrev(evt) { + evt.preventDefault(); + evt.stopPropagation(); + const { filterItems } = this; + if (filterItems.length <= 0) return; + if (this.itemIndex >= 0) filterItems[this.itemIndex].toggle(); + this.itemIndex -= 1; + if (this.itemIndex < 0) { + this.itemIndex = filterItems.length - 1; + } + filterItems[this.itemIndex].toggle(); +} + +function inputMoveNext(evt) { + evt.stopPropagation(); + const { filterItems } = this; + if (filterItems.length <= 0) return; + if (this.itemIndex >= 0) filterItems[this.itemIndex].toggle(); + this.itemIndex += 1; + if (this.itemIndex > filterItems.length - 1) { + this.itemIndex = 0; + } + filterItems[this.itemIndex].toggle(); +} + +function inputEnter(evt) { + evt.preventDefault(); + const { filterItems } = this; + if (filterItems.length <= 0) return; + evt.stopPropagation(); + if (this.itemIndex < 0) this.itemIndex = 0; + filterItems[this.itemIndex].el.click(); + this.hide(); +} + +function inputKeydownHandler(evt) { + const { keyCode } = evt; + if (evt.ctrlKey) { + evt.stopPropagation(); + } + switch (keyCode) { + case 37: // left + evt.stopPropagation(); + break; + case 38: // up + inputMovePrev.call(this, evt); + break; + case 39: // right + evt.stopPropagation(); + break; + case 40: // down + inputMoveNext.call(this, evt); + break; + case 13: // enter + inputEnter.call(this, evt); + break; + case 9: + inputEnter.call(this, evt); + break; + default: + evt.stopPropagation(); + break; + } +} + +export default class Suggest { + constructor(items, itemClick, width = '200px') { + this.filterItems = []; + this.items = items; + this.el = h('div', `${cssPrefix}-suggest`).css('width', width).hide(); + this.itemClick = itemClick; + this.itemIndex = -1; + } + + setOffset(v) { + this.el.cssRemoveKeys('top', 'bottom').offset(v); + } + + hide() { + const { el } = this; + this.filterItems = []; + this.itemIndex = -1; + el.hide(); + unbindClickoutside(this.el.parent()); + } + + setItems(items) { + this.items = items; + // this.search(''); + } + + search(word) { + let { items } = this; + if (!/^\s*$/.test(word)) { + items = items.filter(it => (it.key || it).startsWith(word.toUpperCase())); + } + items = items.map(it => { + let { title } = it; + if (title) { + if (typeof title === 'function') { + title = title(); + } + } else { + title = it; + } + const item = h('div', `${cssPrefix}-item`) + .child(title) + .on('click.stop', () => { + this.itemClick(it); + this.hide(); + }); + if (it.label) { + item.child(h('div', 'label').html(it.label)); + } + return item; + }); + this.filterItems = items; + if (items.length <= 0) { + return; + } + const { el } = this; + // items[0].toggle(); + el.html('') + .children(...items) + .show(); + bindClickoutside(el.parent(), () => { + this.hide(); + }); + } + + bindInputEvents(input) { + input.on('keydown', evt => inputKeydownHandler.call(this, evt)); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/table.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/table.js new file mode 100644 index 00000000..fe1c76a6 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/table.js @@ -0,0 +1,395 @@ +import { stringAt } from '../core/alphabet.js'; +import { getFontSizePxByPt } from '../core/font.js'; +import _cell from '../core/cell.js'; +import { formulam } from '../core/formula.js'; +import { formatm } from '../core/format.js'; + +import { Draw, DrawBox, thinLineWidth, npx } from '../canvas/draw.js'; +// gobal var +const cellPaddingWidth = 5; +const tableFixedHeaderCleanStyle = { fillStyle: '#fff' }; +const tableGridStyle = { + fillStyle: '#fff', + lineWidth: thinLineWidth, + strokeStyle: '#e6e6e6', +}; +function tableFixedHeaderStyle() { + return { + textAlign: 'center', + textBaseline: 'middle', + font: `500 ${npx(12)}px Source Sans Pro`, + fillStyle: '#585757', + lineWidth: thinLineWidth(), + strokeStyle: '#e6e6e6', + }; +} + +function getDrawBox(data, rindex, cindex, yoffset = 0) { + const { left, top, width, height } = data.cellRect(rindex, cindex); + return new DrawBox(left, top + yoffset, width, height, cellPaddingWidth); +} +/* +function renderCellBorders(bboxes, translateFunc) { + const { draw } = this; + if (bboxes) { + const rset = new Set(); + // console.log('bboxes:', bboxes); + bboxes.forEach(({ ri, ci, box }) => { + if (!rset.has(ri)) { + rset.add(ri); + translateFunc(ri); + } + draw.strokeBorders(box); + }); + } +} +*/ + +export function renderCell(draw, data, rindex, cindex, yoffset = 0, scroll) { + const { sortedRowMap, rows, cols } = data; + if (rows.isHide(rindex) || cols.isHide(cindex)) return; + let nrindex = rindex; + if (sortedRowMap.has(rindex)) { + nrindex = sortedRowMap.get(rindex); + } + + const cell = data.getCell(nrindex, cindex); + if (cell === null) return; + let frozen = false; + if ('editable' in cell && cell.editable === false) { + frozen = true; + } + + const style = data.getCellStyleOrDefault(nrindex, cindex); + const dbox = getDrawBox(data, rindex, cindex, yoffset); + dbox.bgcolor = style.bgcolor; + if (style.border !== undefined) { + dbox.setBorders(style.border); + // bboxes.push({ ri: rindex, ci: cindex, box: dbox }); + draw.strokeBorders(dbox); + } + draw.rect(dbox, () => { + if (['image'].includes(cell.type) && !cell.hidden) { + let celldata = data.rows.getCell(rindex, cindex); + // 如果单元格类型是单选框,则添加前缀的圆弧画法 + // 在这里传递一下行坐标与列坐标的宽度,方便异步加载图片时使用 + const fixedIndexWidth = cols.indexWidth; + const fixedIndexHeight = rows.indexHeight; + draw.geometry(cell, dbox, { fixedIndexWidth, fixedIndexHeight }, style, scroll, celldata); + } + // render text + let cellText = ''; + if (!data.settings.evalPaused) { + cellText = _cell.render(cell.text || '', formulam, (y, x) => data.getCellTextOrDefault(x, y)); + } else { + cellText = cell.text || ''; + } + if (style.format) { + // console.log(data.formatm, '>>', cell.format); + cellText = formatm[style.format].render(cellText); + } + const font = Object.assign({}, style.font); + font.size = getFontSizePxByPt(font.size); + // console.log('style:', style); + draw.text( + cellText, + dbox, + { + align: style.align, + valign: style.valign, + font, + color: style.color, + strike: style.strike, + underline: style.underline, + }, + style.textwrap, + ); + // error + const error = data.validations.getError(rindex, cindex); + if (error) { + // console.log('error:', rindex, cindex, error); + draw.error(dbox); + } + if (frozen) { + draw.frozen(dbox); + } + }); +} + +function renderAutofilter(viewRange) { + const { data, draw } = this; + if (viewRange) { + const { autoFilter } = data; + if (!autoFilter.active()) return; + const afRange = autoFilter.hrange(); + if (viewRange.intersects(afRange)) { + afRange.each((ri, ci) => { + const dbox = getDrawBox(data, ri, ci); + draw.dropdown(dbox); + }); + } + } +} + +function renderContent(viewRange, fw, fh, tx, ty, scroll) { + const { draw, data } = this; + draw.save(); + draw.translate(fw, fh).translate(tx, ty); + + const { exceptRowSet } = data; + // const exceptRows = Array.from(exceptRowSet); + const filteredTranslateFunc = ri => { + const ret = exceptRowSet.has(ri); + if (ret) { + const height = data.rows.getHeight(ri); + draw.translate(0, -height); + } + return !ret; + }; + + const exceptRowTotalHeight = data.exceptRowTotalHeight(viewRange.sri, viewRange.eri); + // 1 render cell + draw.save(); + draw.translate(0, -exceptRowTotalHeight); + viewRange.each( + (ri, ci) => { + renderCell(draw, data, ri, ci, 0, scroll); + }, + ri => filteredTranslateFunc(ri), + ); + draw.restore(); + + // 2 render mergeCell + const rset = new Set(); + draw.save(); + draw.translate(0, -exceptRowTotalHeight); + data.eachMergesInView(viewRange, ({ sri, sci, eri }) => { + if (!exceptRowSet.has(sri)) { + renderCell(draw, data, sri, sci, 0, scroll); + } else if (!rset.has(sri)) { + rset.add(sri); + const height = data.rows.sumHeight(sri, eri + 1); + draw.translate(0, -height); + } + }); + draw.restore(); + + // 3 render autofilter + renderAutofilter.call(this, viewRange); + + draw.restore(); +} + +function renderSelectedHeaderCell(x, y, w, h) { + const { draw } = this; + draw.save(); + draw.attr({ fillStyle: 'rgba(76,76,76,.1)' }).fillRect(x, y, w, h); + draw.restore(); +} +function renderLeftHeaderCell(x, y, w, h, op) { + const { draw } = this; + op = op || {}; + draw.save(); + draw.attr({ fillStyle: 'rgba(76,76,76,.1)', ...op }).fillRect(x, y, w, h); + draw.restore(); +} +// viewRange +// type: all | left | top +// w: the fixed width of header +// h: the fixed height of header +// tx: moving distance on x-axis +// ty: moving distance on y-axis +function renderFixedHeaders(type, viewRange, w, h, tx, ty) { + const { draw, data } = this; + const sumHeight = viewRange.h; // rows.sumHeight(viewRange.sri, viewRange.eri + 1); + const sumWidth = viewRange.w; // cols.sumWidth(viewRange.sci, viewRange.eci + 1); + const nty = ty + h; + const ntx = tx + w; + + draw.save(); + // draw rect background + draw.attr(tableFixedHeaderCleanStyle); + if (type === 'all' || type === 'left') draw.fillRect(0, nty, w, sumHeight); + if (type === 'all' || type === 'top') draw.fillRect(ntx, 0, sumWidth, h); + + const { sri, sci, eri, eci } = data.selector.range; + // console.log(data.selectIndexes); + // draw text + // text font, align... + draw.attr(tableFixedHeaderStyle()); + // y-header-text + if (type === 'all' || type === 'left') { + data.rowEach(viewRange.sri, viewRange.eri, (i, y1, rowHeight) => { + const y = nty + y1; + const ii = i; + draw.line([0, y], [w, y]); + if ( + data.settings.leftFixHeaderRender && + data.settings.leftFixHeaderRender instanceof Function + ) { + let cfg = data.settings.leftFixHeaderRender(i); + if (cfg) { + renderLeftHeaderCell.call(this, 0, y, w, rowHeight, cfg); + } else { + if (sri <= ii && ii < eri + 1) { + renderSelectedHeaderCell.call(this, 0, y, w, rowHeight); + } + } + } else { + if (sri <= ii && ii < eri + 1) { + renderSelectedHeaderCell.call(this, 0, y, w, rowHeight); + } + } + draw.fillText(ii + 1, w / 2, y + rowHeight / 2); + if (i > 0 && data.rows.isHide(i - 1)) { + draw.save(); + draw.attr({ strokeStyle: '#c6c6c6' }); + draw.line([5, y + 5], [w - 5, y + 5]); + draw.restore(); + } + }); + draw.line([0, sumHeight + nty], [w, sumHeight + nty]); + draw.line([w, nty], [w, sumHeight + nty]); + } + // x-header-text + if (type === 'all' || type === 'top') { + data.colEach(viewRange.sci, viewRange.eci, (i, x1, colWidth) => { + const x = ntx + x1; + const ii = i; + draw.line([x, 0], [x, h]); + if (sci <= ii && ii < eci + 1) { + renderSelectedHeaderCell.call(this, x, 0, colWidth, h); + } + draw.fillText(stringAt(ii), x + colWidth / 2, h / 2); + if (i > 0 && data.cols.isHide(i - 1)) { + draw.save(); + draw.attr({ strokeStyle: '#c6c6c6' }); + draw.line([x + 5, 5], [x + 5, h - 5]); + draw.restore(); + } + }); + draw.line([sumWidth + ntx, 0], [sumWidth + ntx, h]); + draw.line([0, h], [sumWidth + ntx, h]); + } + draw.restore(); +} + +function renderFixedLeftTopCell(fw, fh) { + const { draw, data } = this; + if (data.settings.mode !== 'edit') return; + draw.save(); + // left-top-cell + draw.attr({ fillStyle: '#fff' }).fillRect(0, 0, fw, fh); + draw.restore(); +} + +function renderContentGrid({ sri, sci, eri, eci, w, h }, fw, fh, tx, ty) { + const { draw, data } = this; + const { settings } = data; + + draw.save(); + draw.attr(tableGridStyle).translate(fw + tx, fh + ty); + // const sumWidth = cols.sumWidth(sci, eci + 1); + // const sumHeight = rows.sumHeight(sri, eri + 1); + // console.log('sumWidth:', sumWidth); + // draw.clearRect(0, 0, w, h); + if (!settings.showGrid) { + draw.restore(); + return; + } + // console.log('rowStart:', rowStart, ', rowLen:', rowLen); + data.rowEach(sri, eri, (i, y, ch) => { + // console.log('y:', y); + if (i !== sri) draw.line([0, y], [w, y]); + if (i === eri) draw.line([0, y + ch], [w, y + ch]); + }); + data.colEach(sci, eci, (i, x, cw) => { + if (i !== sci) draw.line([x, 0], [x, h]); + if (i === eci) draw.line([x + cw, 0], [x + cw, h]); + }); + draw.restore(); +} + +function renderFreezeHighlightLine(fw, fh, ftw, fth) { + const { draw, data } = this; + const twidth = data.viewWidth() - fw; + const theight = data.viewHeight() - fh; + draw.save().translate(fw, fh).attr({ strokeStyle: 'rgba(75, 137, 255, .6)' }); + draw.line([0, fth], [twidth, fth]); + draw.line([ftw, 0], [ftw, theight]); + draw.restore(); +} + +/** end */ +class Table { + constructor(el, data) { + this.el = el; + this.draw = new Draw(el, data.viewWidth(), data.viewHeight()); + this.data = data; + } + + resetData(data) { + this.data = data; + this.render(); + } + + render() { + // resize canvas + const { data } = this; + const { rows, cols } = data; + // fixed width of header + const fw = cols.indexWidth; + // fixed height of header + const fh = rows.height; + + this.draw.resize(data.viewWidth(), data.viewHeight()); + this.clear(); + + const viewRange = data.viewRange(); + // renderAll.call(this, viewRange, data.scroll); + const tx = data.freezeTotalWidth(); + const ty = data.freezeTotalHeight(); + const { x, y } = data.scroll; + // 1 + renderContentGrid.call(this, viewRange, fw, fh, tx, ty); + renderContent.call(this, viewRange, fw, fh, -x, -y, data); + renderFixedHeaders.call(this, 'all', viewRange, fw, fh, tx, ty); + renderFixedLeftTopCell.call(this, fw, fh); + const [fri, fci] = data.freeze; + if (fri > 0 || fci > 0) { + // 2 + if (fri > 0) { + const vr = viewRange.clone(); + vr.sri = 0; + vr.eri = fri - 1; + vr.h = ty; + renderContentGrid.call(this, vr, fw, fh, tx, 0); + renderContent.call(this, vr, fw, fh, -x, 0, data); + renderFixedHeaders.call(this, 'top', vr, fw, fh, tx, 0); + } + // 3 + if (fci > 0) { + const vr = viewRange.clone(); + vr.sci = 0; + vr.eci = fci - 1; + vr.w = tx; + renderContentGrid.call(this, vr, fw, fh, 0, ty); + renderFixedHeaders.call(this, 'left', vr, fw, fh, 0, ty); + renderContent.call(this, vr, fw, fh, 0, -y, data); + } + // 4 + const freezeViewRange = data.freezeViewRange(); + renderContentGrid.call(this, freezeViewRange, fw, fh, 0, 0); + renderFixedHeaders.call(this, 'all', freezeViewRange, fw, fh, 0, 0); + renderContent.call(this, freezeViewRange, fw, fh, 0, 0, data); + // 5 + renderFreezeHighlightLine.call(this, fw, fh, tx, ty); + } + } + + clear() { + this.draw.clear(); + } +} + +export default Table; diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar.js new file mode 100644 index 00000000..dc69bda9 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar.js @@ -0,0 +1,258 @@ +import { cssPrefix } from '../config.js'; +import { t } from '../locale/locale.js'; +import { h } from './element.js'; +import { bind } from './event.js'; +import tooltip from './tooltip.js'; +import DropdownFont from './dropdown_font.js'; +import DropdownFontSize from './dropdown_fontsize.js'; +import DropdownFormat from './dropdown_format.js'; +import DropdownFormula from './dropdown_formula.js'; +import DropdownColor from './dropdown_color.js'; +import DropdownAlign from './dropdown_align.js'; +import DropdownBorder from './dropdown_border.js'; +import Dropdown from './dropdown.js'; +import Icon from './icon.js'; + +function buildIcon(name) { + return new Icon(name); +} + +function buildButton(tooltipdata) { + return h('div', `${cssPrefix}-toolbar-btn`) + .on('mouseenter', evt => { + tooltip(tooltipdata, evt.target); + }) + .attr('data-tooltip', tooltipdata); +} + +function buildDivider() { + return h('div', `${cssPrefix}-toolbar-divider`); +} + +function buildButtonWithIcon( + tooltipdata, + iconName, + change = () => { + console.log('empty function'); + }, +) { + return buildButton(tooltipdata) + .child(buildIcon(iconName)) + .on('click', () => change()); +} + +function bindDropdownChange() { + this.ddFormat.change = it => this.change('format', it.key); + this.ddFont.change = it => this.change('font-name', it.key); + this.ddFormula.change = it => this.change('formula', it.key); + this.ddFontSize.change = it => this.change('font-size', it.pt); + this.ddTextColor.change = it => this.change('color', it); + this.ddFillColor.change = it => this.change('bgcolor', it); + this.ddAlign.change = it => this.change('align', it); + this.ddVAlign.change = it => this.change('valign', it); + this.ddBorder.change = it => this.change('border', it); +} + +function toggleChange(type) { + let elName = type; + const types = type.split('-'); + if (types.length > 1) { + types.forEach((it, i) => { + if (i === 0) elName = it; + else elName += it[0].toUpperCase() + it.substring(1); + }); + } + const el = this[`${elName}El`]; + el.toggle(); + this.change(type, el.hasClass('active')); +} + +class DropdownMore extends Dropdown { + constructor() { + const icon = new Icon('ellipsis'); + const moreBtns = h('div', `${cssPrefix}-toolbar-more`); + super(icon, 'auto', false, 'bottom-right', moreBtns); + this.moreBtns = moreBtns; + this.contentEl.css('max-width', '420px'); + } +} + +function initBtns2() { + this.btns2 = this.btnChildren.map(it => { + const rect = it.box(); + const { marginLeft, marginRight } = it.computedStyle(); + return [it, rect.width + parseInt(marginLeft, 10) + parseInt(marginRight, 10)]; + }); +} + +function moreResize() { + const { el, btns, moreEl, ddMore, btns2 } = this; + const { moreBtns, contentEl } = ddMore; + el.css('width', `${this.widthFn() - 60}px`); + const elBox = el.box(); + + let sumWidth = 160; + let sumWidth2 = 12; + const list1 = []; + const list2 = []; + btns2.forEach(([it, w], index) => { + sumWidth += w; + if (index === btns2.length - 1 || sumWidth < elBox.width) { + list1.push(it); + } else { + sumWidth2 += w; + list2.push(it); + } + }); + btns.html('').children(...list1); + moreBtns.html('').children(...list2); + contentEl.css('width', `${sumWidth2}px`); + if (list2.length > 0) { + moreEl.show(); + } else { + moreEl.hide(); + } +} + +export default class Toolbar { + constructor(data, widthFn, isHide = false) { + this.data = data; + this.change = () => { + console.log('empty function'); + }; + this.widthFn = widthFn; + const style = data.defaultStyle(); + // console.log('data:', data); + this.ddFormat = new DropdownFormat(); + this.ddFont = new DropdownFont(); + this.ddFormula = new DropdownFormula(); + this.ddFontSize = new DropdownFontSize(); + this.ddTextColor = new DropdownColor('text-color', style.color); + this.ddFillColor = new DropdownColor('fill-color', style.bgcolor); + this.ddAlign = new DropdownAlign(['left', 'center', 'right'], style.align); + this.ddVAlign = new DropdownAlign(['top', 'middle', 'bottom'], style.valign); + this.ddBorder = new DropdownBorder(); + this.ddMore = new DropdownMore(); + this.btnChildren = [ + (this.undoEl = buildButtonWithIcon(`${t('toolbar.undo')} (Ctrl+Z)`, 'undo', () => + this.change('undo'), + )), + (this.redoEl = buildButtonWithIcon(`${t('toolbar.undo')} (Ctrl+Y)`, 'redo', () => + this.change('redo'), + )), + // this.printEl = buildButtonWithIcon('Print (Ctrl+P)', 'print', () => this.change('print')), + (this.paintformatEl = buildButtonWithIcon(`${t('toolbar.paintformat')}`, 'paintformat', () => + toggleChange.call(this, 'paintformat'), + )), + (this.clearformatEl = buildButtonWithIcon(`${t('toolbar.clearformat')}`, 'clearformat', () => + this.change('clearformat'), + )), + buildDivider(), + buildButton(`${t('toolbar.format')}`).child(this.ddFormat.el), + buildDivider(), + buildButton(`${t('toolbar.font')}`).child(this.ddFont.el), + buildButton(`${t('toolbar.fontSize')}`).child(this.ddFontSize.el), + buildDivider(), + (this.fontBoldEl = buildButtonWithIcon(`${t('toolbar.fontBold')} (Ctrl+B)`, 'bold', () => + toggleChange.call(this, 'font-bold'), + )), + (this.fontItalicEl = buildButtonWithIcon( + `${t('toolbar.fontItalic')} (Ctrl+I)`, + 'italic', + () => toggleChange.call(this, 'font-italic'), + )), + (this.underlineEl = buildButtonWithIcon( + `${t('toolbar.underline')} (Ctrl+U)`, + 'underline', + () => toggleChange.call(this, 'underline'), + )), + (this.strikeEl = buildButtonWithIcon(`${t('toolbar.strike')}`, 'strike', () => + toggleChange.call(this, 'strike'), + )), + buildButton(`${t('toolbar.textColor')}`).child(this.ddTextColor.el), + buildDivider(), + buildButton(`${t('toolbar.fillColor')}`).child(this.ddFillColor.el), + buildButton(`${t('toolbar.border')}`).child(this.ddBorder.el), + (this.mergeEl = buildButtonWithIcon(`${t('toolbar.merge')}`, 'merge', () => + toggleChange.call(this, 'merge'), + )), + buildDivider(), + buildButton(`${t('toolbar.align')}`).child(this.ddAlign.el), + buildButton(`${t('toolbar.valign')}`).child(this.ddVAlign.el), + (this.textwrapEl = buildButtonWithIcon(`${t('toolbar.textwrap')}`, 'textwrap', () => + toggleChange.call(this, 'textwrap'), + )), + buildDivider(), + // this.linkEl = buildButtonWithIcon('Insert link', 'link'), + // this.chartEl = buildButtonWithIcon('Insert chart', 'chart'), + (this.freezeEl = buildButtonWithIcon(`${t('toolbar.freeze')}`, 'freeze', () => + toggleChange.call(this, 'freeze'), + )), + (this.autofilterEl = buildButtonWithIcon(`${t('toolbar.autofilter')}`, 'autofilter', () => + toggleChange.call(this, 'autofilter'), + )), + buildButton(`${t('toolbar.formula')}`).child(this.ddFormula.el), + // buildDivider(), + (this.moreEl = buildButton(`${t('toolbar.more')}`) + .child(this.ddMore.el) + .hide()), + ]; + this.el = h('div', `${cssPrefix}-toolbar`); + this.btns = h('div', `${cssPrefix}-toolbar-btns`).children(...this.btnChildren); + this.el.child(this.btns); + if (isHide) this.el.hide(); + bindDropdownChange.call(this); + this.reset(); + setTimeout(() => { + initBtns2.call(this); + moreResize.call(this); + }, 0); + bind(window, 'resize', () => { + moreResize.call(this); + }); + } + + paintformatActive() { + return this.paintformatEl.hasClass('active'); + } + + paintformatToggle() { + this.paintformatEl.toggle(); + } + + trigger(type) { + toggleChange.call(this, type); + } + + reset() { + const { data } = this; + const style = data.getSelectedCellStyle(); + const cell = data.getSelectedCell(); + // console.log('canUndo:', data.canUndo()); + this.undoEl.disabled(!data.canUndo()); + this.redoEl.disabled(!data.canRedo()); + this.mergeEl.active(data.canUnmerge()).disabled(!data.selector.multiple()); + this.autofilterEl.active(!data.canAutofilter()); + // this.mergeEl.disabled(); + // console.log('selectedCell:', style, cell); + const { font } = style; + this.ddFont.setTitle(font.name); + this.ddFontSize.setTitle(font.size); + this.fontBoldEl.active(font.bold); + this.fontItalicEl.active(font.italic); + this.underlineEl.active(style.underline); + this.strikeEl.active(style.strike); + this.ddTextColor.setTitle(style.color); + this.ddFillColor.setTitle(style.bgcolor); + this.ddAlign.setTitle(style.align); + this.ddVAlign.setTitle(style.valign); + this.textwrapEl.active(style.textwrap); + // console.log('freeze is Active:', data.freezeIsActive()); + this.freezeEl.active(data.freezeIsActive()); + if (cell) { + if (cell.format) { + this.ddFormat.setTitle(cell.format); + } + } + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/align.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/align.js new file mode 100644 index 00000000..d223395f --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/align.js @@ -0,0 +1,13 @@ +import DropdownAlign from '../dropdown_align.js'; +import DropdownItem from './dropdown_item.js'; + +export default class Align extends DropdownItem { + constructor(value) { + super('align', '', value); + } + + dropdown() { + const { value } = this; + return new DropdownAlign(['left', 'center', 'right'], value); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/autofilter.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/autofilter.js new file mode 100644 index 00000000..0c573a0a --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/autofilter.js @@ -0,0 +1,11 @@ +import ToggleItem from './toggle_item.js'; + +export default class Autofilter extends ToggleItem { + constructor() { + super('autofilter'); + } + + setState() { + console.log('empty function'); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/bold.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/bold.js new file mode 100644 index 00000000..02f144ee --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/bold.js @@ -0,0 +1,7 @@ +import ToggleItem from './toggle_item.js'; + +export default class Bold extends ToggleItem { + constructor() { + super('font-bold', 'Ctrl+B'); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/border.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/border.js new file mode 100644 index 00000000..12713ac7 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/border.js @@ -0,0 +1,12 @@ +import DropdownBorder from '../dropdown_border.js'; +import DropdownItem from './dropdown_item.js'; + +export default class Border extends DropdownItem { + constructor() { + super('border'); + } + + dropdown() { + return new DropdownBorder(); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/clearformat.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/clearformat.js new file mode 100644 index 00000000..76227895 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/clearformat.js @@ -0,0 +1,7 @@ +import IconItem from './icon_item.js'; + +export default class Clearformat extends IconItem { + constructor() { + super('clearformat'); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/dropdown_item.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/dropdown_item.js new file mode 100644 index 00000000..03ad9467 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/dropdown_item.js @@ -0,0 +1,25 @@ +import Item from './item.js'; + +export default class DropdownItem extends Item { + dropdown() { + console.log('empty function'); + } + + getValue(v) { + return v; + } + + element() { + const { tag } = this; + this.dd = this.dropdown(); + this.dd.change = it => this.change(tag, this.getValue(it)); + return super.element().child(this.dd); + } + + setState(v) { + if (v) { + this.value = v; + this.dd.setTitle(v); + } + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/fill_color.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/fill_color.js new file mode 100644 index 00000000..b69eec43 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/fill_color.js @@ -0,0 +1,13 @@ +import DropdownColor from '../dropdown_color.js'; +import DropdownItem from './dropdown_item.js'; + +export default class FillColor extends DropdownItem { + constructor(color) { + super('bgcolor', undefined, color); + } + + dropdown() { + const { tag, value } = this; + return new DropdownColor(tag, value); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/font.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/font.js new file mode 100644 index 00000000..d57bfed8 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/font.js @@ -0,0 +1,16 @@ +import DropdownFont from '../dropdown_font.js'; +import DropdownItem from './dropdown_item.js'; + +export default class Font extends DropdownItem { + constructor() { + super('font-name'); + } + + getValue(it) { + return it.key; + } + + dropdown() { + return new DropdownFont(); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/font_size.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/font_size.js new file mode 100644 index 00000000..6e2d2a2a --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/font_size.js @@ -0,0 +1,16 @@ +import DropdownFontsize from '../dropdown_fontsize.js'; +import DropdownItem from './dropdown_item.js'; + +export default class Format extends DropdownItem { + constructor() { + super('font-size'); + } + + getValue(it) { + return it.pt; + } + + dropdown() { + return new DropdownFontsize(); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/format.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/format.js new file mode 100644 index 00000000..f84ffbe2 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/format.js @@ -0,0 +1,16 @@ +import DropdownFormat from '../dropdown_format.js'; +import DropdownItem from './dropdown_item.js'; + +export default class Format extends DropdownItem { + constructor() { + super('format'); + } + + getValue(it) { + return it.key; + } + + dropdown() { + return new DropdownFormat(); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/formula.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/formula.js new file mode 100644 index 00000000..8fb60ed0 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/formula.js @@ -0,0 +1,16 @@ +import DropdownFormula from '../dropdown_formula.js'; +import DropdownItem from './dropdown_item.js'; + +export default class Format extends DropdownItem { + constructor() { + super('formula'); + } + + getValue(it) { + return it.key; + } + + dropdown() { + return new DropdownFormula(); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/freeze.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/freeze.js new file mode 100644 index 00000000..26acfa81 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/freeze.js @@ -0,0 +1,7 @@ +import ToggleItem from './toggle_item.js'; + +export default class Freeze extends ToggleItem { + constructor() { + super('freeze'); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/icon_item.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/icon_item.js new file mode 100644 index 00000000..1de4337e --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/icon_item.js @@ -0,0 +1,15 @@ +import Icon from '../icon.js'; +import Item from './item.js'; + +export default class IconItem extends Item { + element() { + return super + .element() + .child(new Icon(this.tag)) + .on('click', () => this.change(this.tag)); + } + + setState(disabled) { + this.el.disabled(disabled); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/index.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/index.js new file mode 100644 index 00000000..65273422 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/index.js @@ -0,0 +1,241 @@ +import { h } from '../element.js'; +import { cssPrefix } from '../../config.js'; +import { bind } from '../event.js'; +import Align from './align.js'; +import Valign from './valign.js'; +// import Autofilter from './autofilter.js'; +import Bold from './bold.js'; +import Italic from './italic.js'; +import Strike from './strike.js'; +import Underline from './underline.js'; +import Border from './border.js'; +import Clearformat from './clearformat.js'; +import Paintformat from './paintformat.js'; +import TextColor from './text_color.js'; +import FillColor from './fill_color.js'; +import FontSize from './font_size.js'; +import Font from './font.js'; +import Format from './format.js'; +// import Formula from './formula.js'; +// import Freeze from './freeze'; +import Merge from './merge.js'; +import Redo from './redo.js'; +import Undo from './undo.js'; +// import Print from './print.js'; +// import Textwrap from './textwrap'; +import More from './more.js'; +import Item from './item.js'; + +function buildDivider() { + return h('div', `${cssPrefix}-toolbar-divider`); +} + +function initBtns2() { + this.btns2 = []; + this.items.forEach(it => { + if (Array.isArray(it)) { + it.forEach(({ el }) => { + const rect = el.box(); + const { marginLeft, marginRight } = el.computedStyle(); + this.btns2.push([el, rect.width + parseInt(marginLeft, 10) + parseInt(marginRight, 10)]); + }); + } else { + const rect = it.box(); + const { marginLeft, marginRight } = it.computedStyle(); + this.btns2.push([it, rect.width + parseInt(marginLeft, 10) + parseInt(marginRight, 10)]); + } + }); +} + +function moreResize() { + const { el, btns, moreEl, btns2 } = this; + const { moreBtns, contentEl } = moreEl.dd; + el.css('width', `${this.widthFn()}px`); + const elBox = el.box(); + + let sumWidth = 160; + let sumWidth2 = 12; + const list1 = []; + const list2 = []; + btns2.forEach(([it, w], index) => { + sumWidth += w; + if (index === btns2.length - 1 || sumWidth < elBox.width) { + list1.push(it); + } else { + sumWidth2 += w; + list2.push(it); + } + }); + btns.html('').children(...list1); + moreBtns.html('').children(...list2); + contentEl.css('width', `${sumWidth2}px`); + if (list2.length > 0) { + moreEl.show(); + } else { + moreEl.hide(); + } +} + +function genBtn(it) { + const btn = new Item(); + btn.el.on('click', () => { + if (it.onClick) it.onClick(this.data.getData(), this.data); + }); + btn.tip = it.tip || ''; + + let { el } = it; + + if (it.icon) { + el = h('img').attr('src', it.icon); + } + + if (el) { + const icon = h('div', `${cssPrefix}-icon`); + icon.child(el); + btn.el.child(icon); + } + + return btn; +} + +export default class Toolbar { + constructor(data, widthFn, isHide = false) { + this.data = data; + this.change = () => { + console.log('empty function'); + }; + this.widthFn = widthFn; + this.isHide = isHide; + const style = data.defaultStyle(); + this.items = [ + [ + (this.undoEl = new Undo()), + (this.redoEl = new Redo()), + // new Print(), + (this.paintformatEl = new Paintformat()), + (this.clearformatEl = new Clearformat()), + ], + buildDivider(), + [(this.formatEl = new Format())], + buildDivider(), + [(this.fontEl = new Font()), (this.fontSizeEl = new FontSize())], + buildDivider(), + [ + (this.boldEl = new Bold()), + (this.italicEl = new Italic()), + (this.underlineEl = new Underline()), + (this.strikeEl = new Strike()), + (this.textColorEl = new TextColor(style.color)), + ], + buildDivider(), + [ + (this.fillColorEl = new FillColor(style.bgcolor)), + (this.borderEl = new Border()), + (this.mergeEl = new Merge()), + ], + buildDivider(), + [ + (this.alignEl = new Align(style.align)), + (this.valignEl = new Valign(style.valign)), + // this.textwrapEl = new Textwrap() + ], + // buildDivider(), + // [ + // this.freezeEl = new Freeze(), + // this.autofilterEl = new Autofilter(), + // this.formulaEl = new Formula() + // ] + ]; + + const { extendToolbar = {} } = data.settings; + + if (extendToolbar.left && extendToolbar.left.length > 0) { + this.items.unshift(buildDivider()); + const btns = extendToolbar.left.map(genBtn.bind(this)); + + this.items.unshift(btns); + } + if (extendToolbar.right && extendToolbar.right.length > 0) { + this.items.push(buildDivider()); + const btns = extendToolbar.right.map(genBtn.bind(this)); + this.items.push(btns); + } + + this.items.push([(this.moreEl = new More())]); + + this.el = h('div', `${cssPrefix}-toolbar`); + this.btns = h('div', `${cssPrefix}-toolbar-btns`); + + this.items.forEach(it => { + if (Array.isArray(it)) { + it.forEach(i => { + this.btns.child(i.el); + i.change = (...args) => { + this.change(...args); + }; + }); + } else { + this.btns.child(it.el); + } + }); + + this.el.child(this.btns); + if (isHide) { + this.el.hide(); + } else { + this.reset(); + setTimeout(() => { + initBtns2.call(this); + moreResize.call(this); + }, 0); + bind(window, 'resize', () => { + moreResize.call(this); + }); + } + } + + paintformatActive() { + return this.paintformatEl.active(); + } + + paintformatToggle() { + this.paintformatEl.toggle(); + } + + trigger(type) { + this[`${type}El`].click(); + } + + resetData(data) { + this.data = data; + this.reset(); + } + + reset() { + if (this.isHide) return; + const { data } = this; + const style = data.getSelectedCellStyle(); + // console.log('canUndo:', data.canUndo()); + this.undoEl.setState(!data.canUndo()); + this.redoEl.setState(!data.canRedo()); + this.mergeEl.setState(data.canUnmerge(), !data.selector.multiple()); + // this.autofilterEl.setState(!data.canAutofilter()); + // this.mergeEl.disabled(); + // console.log('selectedCell:', style, cell); + const { font, format } = style; + this.formatEl.setState(format); + this.fontEl.setState(font.name); + this.fontSizeEl.setState(font.size); + this.boldEl.setState(font.bold); + this.italicEl.setState(font.italic); + this.underlineEl.setState(style.underline); + this.strikeEl.setState(style.strike); + this.textColorEl.setState(style.color); + this.fillColorEl.setState(style.bgcolor); + this.alignEl.setState(style.align); + this.valignEl.setState(style.valign); + // this.textwrapEl.setState(style.textwrap); + // console.log('freeze is Active:', data.freezeIsActive()); + // this.freezeEl.setState(data.freezeIsActive()); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/italic.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/italic.js new file mode 100644 index 00000000..98fcefe6 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/italic.js @@ -0,0 +1,7 @@ +import ToggleItem from './toggle_item.js'; + +export default class Italic extends ToggleItem { + constructor() { + super('font-italic', 'Ctrl+I'); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/item.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/item.js new file mode 100644 index 00000000..779ffddc --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/item.js @@ -0,0 +1,35 @@ +import { cssPrefix } from '../../config.js'; +import tooltip from '../tooltip.js'; +import { h } from '../element.js'; +import { t } from '../../locale/locale.js'; + +export default class Item { + // tooltip + // tag: the subclass type + // shortcut: shortcut key + constructor(tag, shortcut, value) { + this.tip = ''; + if (tag) this.tip = t(`toolbar.${tag.replace(/-[a-z]/g, c => c[1].toUpperCase())}`); + if (shortcut) this.tip += ` (${shortcut})`; + this.tag = tag; + this.shortcut = shortcut; + this.value = value; + this.el = this.element(); + this.change = () => { + console.log('empty function'); + }; + } + + element() { + const { tip } = this; + return h('div', `${cssPrefix}-toolbar-btn`) + .on('mouseenter', evt => { + if (this.tip) tooltip(this.tip, evt.target); + }) + .attr('data-tooltip', tip); + } + + setState() { + console.log('empty function'); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/merge.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/merge.js new file mode 100644 index 00000000..6fe0235d --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/merge.js @@ -0,0 +1,11 @@ +import ToggleItem from './toggle_item.js'; + +export default class Merge extends ToggleItem { + constructor() { + super('merge'); + } + + setState(active, disabled) { + this.el.active(active).disabled(disabled); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/more.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/more.js new file mode 100644 index 00000000..679d74c1 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/more.js @@ -0,0 +1,35 @@ +import Dropdown from '../dropdown.js'; + +import { cssPrefix } from '../../config.js'; +import { h } from '../element.js'; +import Icon from '../icon.js'; +import DropdownItem from './dropdown_item.js'; + +class DropdownMore extends Dropdown { + constructor() { + const icon = new Icon('ellipsis'); + const moreBtns = h('div', `${cssPrefix}-toolbar-more`); + super(icon, 'auto', false, 'bottom-right', moreBtns); + this.moreBtns = moreBtns; + this.contentEl.css('max-width', '420px'); + } +} + +export default class More extends DropdownItem { + constructor() { + super('more'); + this.el.hide(); + } + + dropdown() { + return new DropdownMore(); + } + + show() { + this.el.show(); + } + + hide() { + this.el.hide(); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/paintformat.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/paintformat.js new file mode 100644 index 00000000..b98d592f --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/paintformat.js @@ -0,0 +1,11 @@ +import ToggleItem from './toggle_item.js'; + +export default class Paintformat extends ToggleItem { + constructor() { + super('paintformat'); + } + + setState() { + console.log('empty function'); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/print.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/print.js new file mode 100644 index 00000000..def5d2da --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/print.js @@ -0,0 +1,7 @@ +import IconItem from './icon_item.js'; + +export default class Print extends IconItem { + constructor() { + super('print', 'Ctrl+P'); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/redo.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/redo.js new file mode 100644 index 00000000..8309a3bf --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/redo.js @@ -0,0 +1,7 @@ +import IconItem from './icon_item.js'; + +export default class Redo extends IconItem { + constructor() { + super('redo', 'Ctrl+Y'); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/strike.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/strike.js new file mode 100644 index 00000000..0aa81f6c --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/strike.js @@ -0,0 +1,7 @@ +import ToggleItem from './toggle_item.js'; + +export default class Strike extends ToggleItem { + constructor() { + super('strike', 'Ctrl+U'); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/text_color.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/text_color.js new file mode 100644 index 00000000..19fffa3f --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/text_color.js @@ -0,0 +1,13 @@ +import DropdownColor from '../dropdown_color.js'; +import DropdownItem from './dropdown_item.js'; + +export default class TextColor extends DropdownItem { + constructor(color) { + super('color', undefined, color); + } + + dropdown() { + const { tag, value } = this; + return new DropdownColor(tag, value); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/textwrap.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/textwrap.js new file mode 100644 index 00000000..1c5ea6f6 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/textwrap.js @@ -0,0 +1,7 @@ +import ToggleItem from './toggle_item.js'; + +export default class Textwrap extends ToggleItem { + constructor() { + super('textwrap'); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/toggle_item.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/toggle_item.js new file mode 100644 index 00000000..d89ace4e --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/toggle_item.js @@ -0,0 +1,28 @@ +import Icon from '../icon.js'; +import Item from './item.js'; + +export default class ToggleItem extends Item { + element() { + const { tag } = this; + return super + .element() + .child(new Icon(tag)) + .on('click', () => this.click()); + } + + click() { + this.change(this.tag, this.toggle()); + } + + setState(active) { + this.el.active(active); + } + + toggle() { + return this.el.toggle(); + } + + active() { + return this.el.hasClass('active'); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/underline.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/underline.js new file mode 100644 index 00000000..a9a2793d --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/underline.js @@ -0,0 +1,7 @@ +import ToggleItem from './toggle_item.js'; + +export default class Underline extends ToggleItem { + constructor() { + super('underline', 'Ctrl+U'); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/undo.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/undo.js new file mode 100644 index 00000000..bee38c98 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/undo.js @@ -0,0 +1,7 @@ +import IconItem from './icon_item.js'; + +export default class Undo extends IconItem { + constructor() { + super('undo', 'Ctrl+Z'); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/valign.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/valign.js new file mode 100644 index 00000000..a5748673 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/toolbar/valign.js @@ -0,0 +1,13 @@ +import DropdownAlign from '../dropdown_align.js'; +import DropdownItem from './dropdown_item.js'; + +export default class Valign extends DropdownItem { + constructor(value) { + super('valign', '', value); + } + + dropdown() { + const { value } = this; + return new DropdownAlign(['top', 'middle', 'bottom'], value); + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/tooltip.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/tooltip.js new file mode 100644 index 00000000..66ea90dd --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/component/tooltip.js @@ -0,0 +1,27 @@ +import { cssPrefix } from '../config.js'; +import { h } from './element.js'; +import { bind } from './event.js'; + +export default function tooltip(html, target) { + if (target.classList.contains('active')) { + return; + } + const { left, top, width, height } = target.getBoundingClientRect(); + const el = h('div', `${cssPrefix}-tooltip`).html(html).show(); + document.body.appendChild(el.el); + const elBox = el.box(); + // console.log('elBox:', elBox); + el.css('left', `${left + width / 2 - elBox.width / 2}px`).css('top', `${top + height + 2}px`); + + bind(target, 'mouseleave', () => { + if (document.body.contains(el.el)) { + document.body.removeChild(el.el); + } + }); + + bind(target, 'click', () => { + if (document.body.contains(el.el)) { + document.body.removeChild(el.el); + } + }); +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/config.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/config.js new file mode 100644 index 00000000..bb916b7f --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/config.js @@ -0,0 +1,6 @@ +export const cssPrefix = 'x-spreadsheet'; +export const dpr = window.devicePixelRatio || 1; +export default { + cssPrefix, + dpr, +}; diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/_.prototypes.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/_.prototypes.js new file mode 100644 index 00000000..c3a11091 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/_.prototypes.js @@ -0,0 +1,28 @@ +// font.js +/** + * @typedef {number} fontsizePX px for fontSize + */ +/** + * @typedef {number} fontsizePT pt for fontSize + */ +/** + * @typedef {object} BaseFont + * @property {string} key inner key + * @property {string} title title for display + */ + +/** + * @typedef {object} FontSize + * @property {fontsizePT} pt + * @property {fontsizePX} px + */ + +// alphabet.js +/** + * @typedef {string} tagA1 A1 tag for XY-tag (0, 0) + * @example "A1" + */ +/** + * @typedef {[number, number]} tagXY + * @example [0, 0] + */ diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/alphabet.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/alphabet.js new file mode 100644 index 00000000..5683b25d --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/alphabet.js @@ -0,0 +1,117 @@ +import './_.prototypes.js'; + +const alphabets = [ + 'A', + 'B', + 'C', + 'D', + 'E', + 'F', + 'G', + 'H', + 'I', + 'J', + 'K', + 'L', + 'M', + 'N', + 'O', + 'P', + 'Q', + 'R', + 'S', + 'T', + 'U', + 'V', + 'W', + 'X', + 'Y', + 'Z', +]; + +/** index number 2 letters + * @example stringAt(26) ==> 'AA' + * @date 2019-10-10 + * @export + * @param {number} index + * @returns {string} + */ +export function stringAt(index) { + let str = ''; + let cindex = index; + while (cindex >= alphabets.length) { + cindex /= alphabets.length; + cindex -= 1; + str += alphabets[parseInt(cindex, 10) % alphabets.length]; + } + const last = index % alphabets.length; + str += alphabets[last]; + return str; +} + +/** translate letter in A1-tag to number + * @date 2019-10-10 + * @export + * @param {string} str "AA" in A1-tag "AA1" + * @returns {number} + */ +export function indexAt(str) { + let ret = 0; + for (let i = 0; i !== str.length; ++i) ret = 26 * ret + str.charCodeAt(i) - 64; + return ret - 1; +} + +// B10 => x,y +/** translate A1-tag to XY-tag + * @date 2019-10-10 + * @export + * @param {tagA1} src + * @returns {tagXY} + */ +export function expr2xy(src) { + let x = ''; + let y = ''; + for (let i = 0; i < src.length; i += 1) { + if (src.charAt(i) >= '0' && src.charAt(i) <= '9') { + y += src.charAt(i); + } else { + x += src.charAt(i); + } + } + return [indexAt(x), parseInt(y, 10) - 1]; +} + +/** translate XY-tag to A1-tag + * @example x,y => B10 + * @date 2019-10-10 + * @export + * @param {number} x + * @param {number} y + * @returns {tagA1} + */ +export function xy2expr(x, y) { + return `${stringAt(x)}${y + 1}`; +} + +/** translate A1-tag src by (xn, yn) + * @date 2019-10-10 + * @export + * @param {tagA1} src + * @param {number} xn + * @param {number} yn + * @returns {tagA1} + */ +export function expr2expr(src, xn, yn, condition = () => true) { + if (xn === 0 && yn === 0) return src; + const [x, y] = expr2xy(src); + if (!condition(x, y)) return src; + return xy2expr(x + xn, y + yn); +} + +export default { + stringAt, + indexAt, + expr2xy, + xy2expr, + expr2expr, +}; diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/auto_filter.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/auto_filter.js new file mode 100644 index 00000000..42b2b8f9 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/auto_filter.js @@ -0,0 +1,183 @@ +import { CellRange } from './cell_range.js'; +// operator: all|eq|neq|gt|gte|lt|lte|in|be +// value: +// in => [] +// be => [min, max] +class Filter { + constructor(ci, operator, value) { + this.ci = ci; + this.operator = operator; + this.value = value; + } + + set(operator, value) { + this.operator = operator; + this.value = value; + } + + includes(v) { + const { operator, value } = this; + if (operator === 'all') { + return true; + } + if (operator === 'in') { + return value.includes(v); + } + return false; + } + + vlength() { + const { operator, value } = this; + if (operator === 'in') { + return value.length; + } + return 0; + } + + getData() { + const { ci, operator, value } = this; + return { ci, operator, value }; + } +} + +class Sort { + constructor(ci, order) { + this.ci = ci; + this.order = order; + } + + asc() { + return this.order === 'asc'; + } + + desc() { + return this.order === 'desc'; + } +} + +export default class AutoFilter { + constructor() { + this.ref = null; + this.filters = []; + this.sort = null; + } + + setData({ ref, filters, sort }) { + if (ref != null) { + this.ref = ref; + this.filters = filters.map(it => new Filter(it.ci, it.operator, it.value)); + if (sort) { + this.sort = new Sort(sort.ci, sort.order); + } + } + } + + getData() { + if (this.active()) { + const { ref, filters, sort } = this; + return { ref, filters: filters.map(it => it.getData()), sort }; + } + return {}; + } + + addFilter(ci, operator, value) { + const filter = this.getFilter(ci); + if (filter == null) { + this.filters.push(new Filter(ci, operator, value)); + } else { + filter.set(operator, value); + } + } + + setSort(ci, order) { + this.sort = order ? new Sort(ci, order) : null; + } + + includes(ri, ci) { + if (this.active()) { + return this.hrange().includes(ri, ci); + } + return false; + } + + getSort(ci) { + const { sort } = this; + if (sort && sort.ci === ci) { + return sort; + } + return null; + } + + getFilter(ci) { + const { filters } = this; + for (let i = 0; i < filters.length; i += 1) { + if (filters[i].ci === ci) { + return filters[i]; + } + } + return null; + } + + filteredRows(getCell) { + // const ary = []; + // let lastri = 0; + const rset = new Set(); + const fset = new Set(); + if (this.active()) { + const { sri, eri } = this.range(); + const { filters } = this; + for (let ri = sri + 1; ri <= eri; ri += 1) { + for (let i = 0; i < filters.length; i += 1) { + const filter = filters[i]; + const cell = getCell(ri, filter.ci); + const ctext = cell ? cell.text : ''; + if (!filter.includes(ctext)) { + rset.add(ri); + break; + } else { + fset.add(ri); + } + } + } + } + return { rset, fset }; + } + + items(ci, getCell) { + const m = {}; + if (this.active()) { + const { sri, eri } = this.range(); + for (let ri = sri + 1; ri <= eri; ri += 1) { + const cell = getCell(ri, ci); + if (cell !== null && !/^\s*$/.test(cell.text)) { + const key = cell.text; + const cnt = (m[key] || 0) + 1; + m[key] = cnt; + } else { + m[''] = (m[''] || 0) + 1; + } + } + } + return m; + } + + range() { + return CellRange.valueOf(this.ref); + } + + hrange() { + const r = this.range(); + r.eri = r.sri; + return r; + } + + clear() { + this.ref = null; + this.filters = []; + this.sort = null; + } + + active() { + return this.ref !== null; + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/cell.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/cell.js new file mode 100644 index 00000000..7006aa52 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/cell.js @@ -0,0 +1,224 @@ +import { expr2xy, xy2expr } from './alphabet.js'; +import { numberCalc } from './helper.js'; + +// Converting infix expression to a suffix expression +// src: AVERAGE(SUM(A1,A2), B1) + 50 + B20 +// return: [A1, A2], SUM[, B1],AVERAGE,50,+,B20,+ +const infixExprToSuffixExpr = src => { + const operatorStack = []; + const stack = []; + let subStrs = []; // SUM, A1, B2, 50 ... + let fnArgType = 0; // 1 => , 2 => : + let fnArgOperator = ''; + let fnArgsLen = 1; // A1,A2,A3... + let oldc = ''; + for (let i = 0; i < src.length; i += 1) { + const c = src.charAt(i); + if (c !== ' ') { + if (c >= 'a' && c <= 'z') { + subStrs.push(c.toUpperCase()); + } else if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || c === '.') { + subStrs.push(c); + } else if (c === '"') { + i += 1; + while (src.charAt(i) !== '"') { + subStrs.push(src.charAt(i)); + i += 1; + } + stack.push(`"${subStrs.join('')}`); + subStrs = []; + } else if (c === '-' && /[+\-*/,(]/.test(oldc)) { + subStrs.push(c); + } else { + // console.log('subStrs:', subStrs.join(''), stack); + if (c !== '(' && subStrs.length > 0) { + stack.push(subStrs.join('')); + } + if (c === ')') { + let c1 = operatorStack.pop(); + if (fnArgType === 2) { + // fn argument range => A1:B5 + try { + const [ex, ey] = expr2xy(stack.pop()); + const [sx, sy] = expr2xy(stack.pop()); + // console.log('::', sx, sy, ex, ey); + let rangelen = 0; + for (let x = sx; x <= ex; x += 1) { + for (let y = sy; y <= ey; y += 1) { + stack.push(xy2expr(x, y)); + rangelen += 1; + } + } + stack.push([c1, rangelen]); + } catch (e) { + // console.log(e); + } + } else if (fnArgType === 1 || fnArgType === 3) { + if (fnArgType === 3) stack.push(fnArgOperator); + // fn argument => A1,A2,B5 + stack.push([c1, fnArgsLen]); + fnArgsLen = 1; + } else { + // console.log('c1:', c1, fnArgType, stack, operatorStack); + while (c1 !== '(') { + stack.push(c1); + if (operatorStack.length <= 0) break; + c1 = operatorStack.pop(); + } + } + fnArgType = 0; + } else if (c === '=' || c === '>' || c === '<') { + const nc = src.charAt(i + 1); + fnArgOperator = c; + if (nc === '=' || nc === '-') { + fnArgOperator += nc; + i += 1; + } + fnArgType = 3; + } else if (c === ':') { + fnArgType = 2; + } else if (c === ',') { + if (fnArgType === 3) { + stack.push(fnArgOperator); + } + fnArgType = 1; + fnArgsLen += 1; + } else if (c === '(' && subStrs.length > 0) { + // function + operatorStack.push(subStrs.join('')); + } else { + // priority: */ > +- + // console.log('xxxx:', operatorStack, c, stack); + if (operatorStack.length > 0 && (c === '+' || c === '-')) { + let top = operatorStack[operatorStack.length - 1]; + if (top !== '(') stack.push(operatorStack.pop()); + if (top === '*' || top === '/') { + while (operatorStack.length > 0) { + top = operatorStack[operatorStack.length - 1]; + if (top !== '(') stack.push(operatorStack.pop()); + else break; + } + } + } else if (operatorStack.length > 0) { + const top = operatorStack[operatorStack.length - 1]; + if (top === '*' || top === '/') stack.push(operatorStack.pop()); + } + operatorStack.push(c); + } + subStrs = []; + } + oldc = c; + } + } + if (subStrs.length > 0) { + stack.push(subStrs.join('')); + } + while (operatorStack.length > 0) { + stack.push(operatorStack.pop()); + } + return stack; +}; + +const evalSubExpr = (subExpr, cellRender) => { + const [fl] = subExpr; + let expr = subExpr; + if (fl === '"') { + return subExpr.substring(1); + } + let ret = 1; + if (fl === '-') { + expr = subExpr.substring(1); + ret = -1; + } + if (expr[0] >= '0' && expr[0] <= '9') { + return ret * Number(expr); + } + const [x, y] = expr2xy(expr); + return ret * cellRender(x, y); +}; + +// evaluate the suffix expression +// srcStack: <= infixExprToSufixExpr +// formulaMap: {'SUM': {}, ...} +// cellRender: (x, y) => {} +const evalSuffixExpr = (srcStack, formulaMap, cellRender, cellList) => { + const stack = []; + // console.log(':::::formulaMap:', formulaMap); + for (let i = 0; i < srcStack.length; i += 1) { + // console.log(':::>>>', srcStack[i]); + const expr = srcStack[i]; + const fc = expr[0]; + if (expr === '+') { + const top = stack.pop(); + stack.push(numberCalc('+', stack.pop(), top)); + } else if (expr === '-') { + if (stack.length === 1) { + const top = stack.pop(); + stack.push(numberCalc('*', top, -1)); + } else { + const top = stack.pop(); + stack.push(numberCalc('-', stack.pop(), top)); + } + } else if (expr === '*') { + stack.push(numberCalc('*', stack.pop(), stack.pop())); + } else if (expr === '/') { + const top = stack.pop(); + stack.push(numberCalc('/', stack.pop(), top)); + } else if (fc === '=' || fc === '>' || fc === '<') { + let top = stack.pop(); + if (!Number.isNaN(top)) top = Number(top); + let left = stack.pop(); + if (!Number.isNaN(left)) left = Number(left); + let ret = false; + if (fc === '=') { + ret = left === top; + } else if (expr === '>') { + ret = left > top; + } else if (expr === '>=') { + ret = left >= top; + } else if (expr === '<') { + ret = left < top; + } else if (expr === '<=') { + ret = left <= top; + } + stack.push(ret); + } else if (Array.isArray(expr)) { + const [formula, len] = expr; + const params = []; + for (let j = 0; j < len; j += 1) { + params.push(stack.pop()); + } + stack.push(formulaMap[formula].render(params.reverse())); + } else { + if (cellList.includes(expr)) { + return 0; + } + if ((fc >= 'a' && fc <= 'z') || (fc >= 'A' && fc <= 'Z')) { + cellList.push(expr); + } + stack.push(evalSubExpr(expr, cellRender)); + cellList.pop(); + } + // console.log('stack:', stack); + } + return stack[0]; +}; + +const cellRender = (src, formulaMap, getCellText, cellList = []) => { + if (src[0] === '=') { + const stack = infixExprToSuffixExpr(src.substring(1)); + if (stack.length <= 0) return src; + return evalSuffixExpr( + stack, + formulaMap, + (x, y) => cellRender(getCellText(x, y), formulaMap, getCellText, cellList), + cellList, + ); + } + return src; +}; + +export default { + render: cellRender, +}; +export { infixExprToSuffixExpr }; diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/cell_range.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/cell_range.js new file mode 100644 index 00000000..e3bec0d0 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/cell_range.js @@ -0,0 +1,214 @@ +import { xy2expr, expr2xy } from './alphabet.js'; + +class CellRange { + constructor(sri, sci, eri, eci, w = 0, h = 0) { + this.sri = sri; + this.sci = sci; + this.eri = eri; + this.eci = eci; + this.w = w; + this.h = h; + } + + set(sri, sci, eri, eci) { + this.sri = sri; + this.sci = sci; + this.eri = eri; + this.eci = eci; + } + + multiple() { + return this.eri - this.sri > 0 || this.eci - this.sci > 0; + } + + // cell-index: ri, ci + // cell-ref: A10 + includes(...args) { + let [ri, ci] = [0, 0]; + if (args.length === 1) { + [ci, ri] = expr2xy(args[0]); + } else if (args.length === 2) { + [ri, ci] = args; + } + const { sri, sci, eri, eci } = this; + return sri <= ri && ri <= eri && sci <= ci && ci <= eci; + } + + each(cb, rowFilter = () => true) { + const { sri, sci, eri, eci } = this; + for (let i = sri; i <= eri; i += 1) { + if (rowFilter(i)) { + for (let j = sci; j <= eci; j += 1) { + cb(i, j); + } + } + } + } + + contains(other) { + return ( + this.sri <= other.sri && + this.sci <= other.sci && + this.eri >= other.eri && + this.eci >= other.eci + ); + } + + // within + within(other) { + return ( + this.sri >= other.sri && + this.sci >= other.sci && + this.eri <= other.eri && + this.eci <= other.eci + ); + } + + // disjoint + disjoint(other) { + return ( + this.sri > other.eri || this.sci > other.eci || other.sri > this.eri || other.sci > this.eci + ); + } + + // intersects + intersects(other) { + return ( + this.sri <= other.eri && + this.sci <= other.eci && + other.sri <= this.eri && + other.sci <= this.eci + ); + } + + // union + union(other) { + const { sri, sci, eri, eci } = this; + return new CellRange( + other.sri < sri ? other.sri : sri, + other.sci < sci ? other.sci : sci, + other.eri > eri ? other.eri : eri, + other.eci > eci ? other.eci : eci, + ); + } + + // intersection + // intersection(other) {} + + // Returns Array that represents that part of this that does not intersect with other + // difference + difference(other) { + const ret = []; + const addRet = (sri, sci, eri, eci) => { + ret.push(new CellRange(sri, sci, eri, eci)); + }; + const { sri, sci, eri, eci } = this; + const dsr = other.sri - sri; + const dsc = other.sci - sci; + const der = eri - other.eri; + const dec = eci - other.eci; + if (dsr > 0) { + addRet(sri, sci, other.sri - 1, eci); + if (der > 0) { + addRet(other.eri + 1, sci, eri, eci); + if (dsc > 0) { + addRet(other.sri, sci, other.eri, other.sci - 1); + } + if (dec > 0) { + addRet(other.sri, other.eci + 1, other.eri, eci); + } + } else { + if (dsc > 0) { + addRet(other.sri, sci, eri, other.sci - 1); + } + if (dec > 0) { + addRet(other.sri, other.eci + 1, eri, eci); + } + } + } else if (der > 0) { + addRet(other.eri + 1, sci, eri, eci); + if (dsc > 0) { + addRet(sri, sci, other.eri, other.sci - 1); + } + if (dec > 0) { + addRet(sri, other.eci + 1, other.eri, eci); + } + } + if (dsc > 0) { + addRet(sri, sci, eri, other.sci - 1); + if (dec > 0) { + addRet(sri, other.eri + 1, eri, eci); + if (dsr > 0) { + addRet(sri, other.sci, other.sri - 1, other.eci); + } + if (der > 0) { + addRet(other.sri + 1, other.sci, eri, other.eci); + } + } else { + if (dsr > 0) { + addRet(sri, other.sci, other.sri - 1, eci); + } + if (der > 0) { + addRet(other.sri + 1, other.sci, eri, eci); + } + } + } else if (dec > 0) { + addRet(eri, other.eci + 1, eri, eci); + if (dsr > 0) { + addRet(sri, sci, other.sri - 1, other.eci); + } + if (der > 0) { + addRet(other.eri + 1, sci, eri, other.eci); + } + } + return ret; + } + + size() { + return [this.eri - this.sri + 1, this.eci - this.sci + 1]; + } + + toString() { + const { sri, sci, eri, eci } = this; + let ref = xy2expr(sci, sri); + if (this.multiple()) { + ref = `${ref}:${xy2expr(eci, eri)}`; + } + return ref; + } + + clone() { + const { sri, sci, eri, eci, w, h } = this; + return new CellRange(sri, sci, eri, eci, w, h); + } + + /* + toJSON() { + return this.toString(); + } + */ + + equals(other) { + return ( + this.eri === other.eri && + this.eci === other.eci && + this.sri === other.sri && + this.sci === other.sci + ); + } + + static valueOf(ref) { + // B1:B8, B1 => 1 x 1 cell range + const refs = ref.split(':'); + const [sci, sri] = expr2xy(refs[0]); + let [eri, eci] = [sri, sci]; + if (refs.length > 1) { + [eci, eri] = expr2xy(refs[1]); + } + return new CellRange(sri, sci, eri, eci); + } +} + +export default CellRange; + +export { CellRange }; diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/clipboard.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/clipboard.js new file mode 100644 index 00000000..d85a9fc1 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/clipboard.js @@ -0,0 +1,35 @@ +export default class Clipboard { + constructor() { + this.range = null; // CellRange + this.state = 'clear'; + } + + copy(cellRange) { + this.range = cellRange; + this.state = 'copy'; + return this; + } + + cut(cellRange) { + this.range = cellRange; + this.state = 'cut'; + return this; + } + + isCopy() { + return this.state === 'copy'; + } + + isCut() { + return this.state === 'cut'; + } + + isClear() { + return this.state === 'clear'; + } + + clear() { + this.range = null; + this.state = 'clear'; + } +} diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/col.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/col.js new file mode 100644 index 00000000..c15d9f6e --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/col.js @@ -0,0 +1,80 @@ +import helper from './helper.js'; + +class Cols { + constructor({ len, width, indexWidth, minWidth }) { + this._ = {}; + this.len = len; + this.width = width; + this.indexWidth = indexWidth; + this.minWidth = minWidth; + } + + setData(d) { + if (d.len) { + this.len = d.len; + delete d.len; + } + this._ = d; + } + + getData() { + const { len } = this; + return Object.assign({ len }, this._); + } + + getWidth(i) { + if (this.isHide(i)) return 0; + const col = this._[i]; + if (col && col.width) { + return col.width; + } + return this.width; + } + + getOrNew(ci) { + this._[ci] = this._[ci] || {}; + return this._[ci]; + } + + setWidth(ci, width) { + const col = this.getOrNew(ci); + col.width = width; + } + + unhide(idx) { + let index = idx; + while (index > 0) { + index -= 1; + if (this.isHide(index)) { + this.setHide(index, false); + } else break; + } + } + + isHide(ci) { + const col = this._[ci]; + return col && col.hide; + } + + setHide(ci, v) { + const col = this.getOrNew(ci); + if (v === true) col.hide = true; + else delete col.hide; + } + + setStyle(ci, style) { + const col = this.getOrNew(ci); + col.style = style; + } + + sumWidth(min, max) { + return helper.rangeSum(min, max, i => this.getWidth(i)); + } + + totalWidth() { + return this.sumWidth(0, this.len); + } +} + +export default {}; +export { Cols }; diff --git a/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/data_proxy.js b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/data_proxy.js new file mode 100644 index 00000000..90404d48 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/SpreadSheet/core/data_proxy.js @@ -0,0 +1,1252 @@ +import { t } from '../locale/locale.js'; +import Selector from './selector.js'; +import Scroll from './scroll.js'; +import History from './history.js'; +import Clipboard from './clipboard.js'; +import AutoFilter from './auto_filter.js'; +import { Merges } from './merge.js'; +import helper from './helper.js'; +import { Rows } from './row.js'; +import { Cols } from './col.js'; +import { Validations } from './validation.js'; +import { CellRange } from './cell_range.js'; +import { expr2xy, xy2expr } from './alphabet.js'; + +// private methods +/* + * { + * name: '' + * freeze: [0, 0], + * formats: [], + * styles: [ + * { + * bgcolor: '', + * align: '', + * valign: '', + * textwrap: false, + * strike: false, + * underline: false, + * color: '', + * format: 1, + * border: { + * left: [style, color], + * right: [style, color], + * top: [style, color], + * bottom: [style, color], + * }, + * font: { + * name: 'Helvetica', + * size: 10, + * bold: false, + * italic: false, + * } + * } + * ], + * merges: [ + * 'A1:F11', + * ... + * ], + * rows: { + * 1: { + * height: 50, + * style: 1, + * cells: { + * 1: { + * style: 2, + * type: 'string', + * text: '', + * value: '', // cal result + * } + * } + * }, + * ... + * }, + * cols: { + * 2: { width: 100, style: 1 } + * } + * } + */ +const defaultSettings = { + mode: 'edit', // edit | read + view: { + height: () => document.documentElement.clientHeight, + width: () => document.documentElement.clientWidth, + }, + showGrid: true, + showToolbar: true, + showContextmenu: true, + showBottomBar: true, + row: { + len: 100, + height: 25, + }, + col: { + len: 26, + width: 100, + indexWidth: 60, + minWidth: 60, + }, + style: { + bgcolor: '#ffffff', + align: 'left', + valign: 'middle', + textwrap: false, + strike: false, + underline: false, + color: '#0a0a0a', + font: { + name: 'Arial', + size: 10, + bold: false, + italic: false, + }, + format: 'normal', + }, +}; + +const toolbarHeight = 41; +const bottombarHeight = 41; + +// src: cellRange +// dst: cellRange +function canPaste( + src, + dst, + error = () => { + console.log('empty function'); + }, +) { + const { merges } = this; + const cellRange = dst.clone(); + const [srn, scn] = src.size(); + const [drn, dcn] = dst.size(); + if (srn > drn) { + cellRange.eri = dst.sri + srn - 1; + } + if (scn > dcn) { + cellRange.eci = dst.sci + scn - 1; + } + if (merges.intersects(cellRange)) { + error(t('error.pasteForMergedCell')); + return false; + } + return true; +} +function copyPaste(srcCellRange, dstCellRange, what, autofill = false) { + const { rows, merges } = this; + // delete dest merge + if (what === 'all' || what === 'format') { + rows.deleteCells(dstCellRange, what); + merges.deleteWithin(dstCellRange); + } + rows.copyPaste(srcCellRange, dstCellRange, what, autofill, (ri, ci, cell) => { + if (cell && cell.merge) { + // console.log('cell:', ri, ci, cell); + const [rn, cn] = cell.merge; + if (rn <= 0 && cn <= 0) return; + merges.add(new CellRange(ri, ci, ri + rn, ci + cn)); + } + }); +} + +function cutPaste(srcCellRange, dstCellRange) { + const { clipboard, rows, merges } = this; + rows.cutPaste(srcCellRange, dstCellRange); + merges.move( + srcCellRange, + dstCellRange.sri - srcCellRange.sri, + dstCellRange.sci - srcCellRange.sci, + ); + clipboard.clear(); +} + +// bss: { top, bottom, left, right } +function setStyleBorder(ri, ci, bss) { + const { styles, rows } = this; + const cell = rows.getCellOrNew(ri, ci); + let cstyle = {}; + if (cell.style !== undefined) { + cstyle = helper.cloneDeep(styles[cell.style]); + } + cstyle = helper.merge(cstyle, { border: bss }); + cell.style = this.addStyle(cstyle); +} + +function setStyleBorders({ mode, style, color }) { + const { styles, selector, rows } = this; + const { sri, sci, eri, eci } = selector.range; + const multiple = !this.isSingleSelected(); + if (!multiple) { + if (mode === 'inside' || mode === 'horizontal' || mode === 'vertical') { + return; + } + } + if (mode === 'outside' && !multiple) { + setStyleBorder.call(this, sri, sci, { + top: [style, color], + bottom: [style, color], + left: [style, color], + right: [style, color], + }); + } else if (mode === 'none') { + selector.range.each((ri, ci) => { + const cell = rows.getCell(ri, ci); + if (cell && cell.style !== undefined) { + const ns = helper.cloneDeep(styles[cell.style]); + delete ns.border; + // ['bottom', 'top', 'left', 'right'].forEach((prop) => { + // if (ns[prop]) delete ns[prop]; + // }); + cell.style = this.addStyle(ns); + } + }); + } else if ( + mode === 'all' || + mode === 'inside' || + mode === 'outside' || + mode === 'horizontal' || + mode === 'vertical' + ) { + const merges = []; + for (let ri = sri; ri <= eri; ri += 1) { + for (let ci = sci; ci <= eci; ci += 1) { + // jump merges -- start + const mergeIndexes = []; + for (let ii = 0; ii < merges.length; ii += 1) { + const [mri, mci, rn, cn] = merges[ii]; + if (ri === mri + rn + 1) mergeIndexes.push(ii); + if (mri <= ri && ri <= mri + rn) { + if (ci === mci) { + ci += cn + 1; + break; + } + } + } + mergeIndexes.forEach(it => merges.splice(it, 1)); + if (ci > eci) break; + // jump merges -- end + const cell = rows.getCell(ri, ci); + let [rn, cn] = [0, 0]; + if (cell && cell.merge) { + [rn, cn] = cell.merge; + merges.push([ri, ci, rn, cn]); + } + const mrl = rn > 0 && ri + rn === eri; + const mcl = cn > 0 && ci + cn === eci; + let bss = {}; + if (mode === 'all') { + bss = { + bottom: [style, color], + top: [style, color], + left: [style, color], + right: [style, color], + }; + } else if (mode === 'inside') { + if (!mcl && ci < eci) bss.right = [style, color]; + if (!mrl && ri < eri) bss.bottom = [style, color]; + } else if (mode === 'horizontal') { + if (!mrl && ri < eri) bss.bottom = [style, color]; + } else if (mode === 'vertical') { + if (!mcl && ci < eci) bss.right = [style, color]; + } else if (mode === 'outside' && multiple) { + if (sri === ri) bss.top = [style, color]; + if (mrl || eri === ri) bss.bottom = [style, color]; + if (sci === ci) bss.left = [style, color]; + if (mcl || eci === ci) bss.right = [style, color]; + } + if (Object.keys(bss).length > 0) { + setStyleBorder.call(this, ri, ci, bss); + } + ci += cn; + } + } + } else if (mode === 'top' || mode === 'bottom') { + for (let ci = sci; ci <= eci; ci += 1) { + if (mode === 'top') { + setStyleBorder.call(this, sri, ci, { top: [style, color] }); + ci += rows.getCellMerge(sri, ci)[1]; + } + if (mode === 'bottom') { + setStyleBorder.call(this, eri, ci, { bottom: [style, color] }); + ci += rows.getCellMerge(eri, ci)[1]; + } + } + } else if (mode === 'left' || mode === 'right') { + for (let ri = sri; ri <= eri; ri += 1) { + if (mode === 'left') { + setStyleBorder.call(this, ri, sci, { left: [style, color] }); + ri += rows.getCellMerge(ri, sci)[0]; + } + if (mode === 'right') { + setStyleBorder.call(this, ri, eci, { right: [style, color] }); + ri += rows.getCellMerge(ri, eci)[0]; + } + } + } +} + +function getCellRowByY(y, scrollOffsety) { + const { rows } = this; + const fsh = this.freezeTotalHeight(); + // console.log('y:', y, ', fsh:', fsh); + let inits = rows.height; + if (fsh + rows.height < y) inits -= scrollOffsety; + + // handle ri in autofilter + const frset = this.exceptRowSet; + + let ri = 0; + let top = inits; + let { height } = rows; + for (; ri < rows.len; ri += 1) { + if (top > y) break; + if (!frset.has(ri)) { + height = rows.getHeight(ri); + top += height; + } + } + top -= height; + // console.log('ri:', ri, ', top:', top, ', height:', height); + + if (top <= 0) { + return { ri: -1, top: 0, height }; + } + + return { ri: ri - 1, top, height }; +} + +function getCellColByX(x, scrollOffsetx) { + const { cols } = this; + const fsw = this.freezeTotalWidth(); + let inits = cols.indexWidth; + if (fsw + cols.indexWidth < x) inits -= scrollOffsetx; + const [ci, left, width] = helper.rangeReduceIf(0, cols.len, inits, cols.indexWidth, x, i => + cols.getWidth(i), + ); + if (left <= 0) { + return { ci: -1, left: 0, width: cols.indexWidth }; + } + return { ci: ci - 1, left, width }; +} + +export default class DataProxy { + constructor(name, settings) { + this.settings = helper.merge(defaultSettings, settings || {}); + // save data begin + this.name = name || 'sheet'; + this.freeze = [0, 0]; + this.styles = []; // Array diff --git a/OrangeFormsOpen-VUE3/src/components/StepBar/stepItem.vue b/OrangeFormsOpen-VUE3/src/components/StepBar/stepItem.vue new file mode 100644 index 00000000..887127ac --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/StepBar/stepItem.vue @@ -0,0 +1,60 @@ + + + + + + + diff --git a/OrangeFormsOpen-VUE3/src/components/TableBox/index.vue b/OrangeFormsOpen-VUE3/src/components/TableBox/index.vue new file mode 100644 index 00000000..8570c4da --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/TableBox/index.vue @@ -0,0 +1,294 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/components/TableProgressColumn/index.vue b/OrangeFormsOpen-VUE3/src/components/TableProgressColumn/index.vue new file mode 100644 index 00000000..9e5f3daa --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/TableProgressColumn/index.vue @@ -0,0 +1,101 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/components/UserSelect/UserSelectDlg.vue b/OrangeFormsOpen-VUE3/src/components/UserSelect/UserSelectDlg.vue new file mode 100644 index 00000000..da153599 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/UserSelect/UserSelectDlg.vue @@ -0,0 +1,251 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/components/UserSelect/index.vue b/OrangeFormsOpen-VUE3/src/components/UserSelect/index.vue new file mode 100644 index 00000000..6c156134 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/UserSelect/index.vue @@ -0,0 +1,217 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/components/icons/index.vue b/OrangeFormsOpen-VUE3/src/components/icons/index.vue new file mode 100644 index 00000000..5a353b6f --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/icons/index.vue @@ -0,0 +1,46 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/components/layout/components/BreadCrumb.vue b/OrangeFormsOpen-VUE3/src/components/layout/components/BreadCrumb.vue new file mode 100644 index 00000000..cf550ad6 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/layout/components/BreadCrumb.vue @@ -0,0 +1,66 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/components/layout/components/Sidebar.vue b/OrangeFormsOpen-VUE3/src/components/layout/components/Sidebar.vue new file mode 100644 index 00000000..408af847 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/layout/components/Sidebar.vue @@ -0,0 +1,141 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/components/layout/components/SubMenu.vue b/OrangeFormsOpen-VUE3/src/components/layout/components/SubMenu.vue new file mode 100644 index 00000000..8e7d4551 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/layout/components/SubMenu.vue @@ -0,0 +1,72 @@ + + + + + +@/types/upms/menu diff --git a/OrangeFormsOpen-VUE3/src/components/layout/components/TagItem.vue b/OrangeFormsOpen-VUE3/src/components/layout/components/TagItem.vue new file mode 100644 index 00000000..4c216be2 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/layout/components/TagItem.vue @@ -0,0 +1,117 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/components/layout/components/TagPanel.vue b/OrangeFormsOpen-VUE3/src/components/layout/components/TagPanel.vue new file mode 100644 index 00000000..383c0a05 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/layout/components/TagPanel.vue @@ -0,0 +1,282 @@ + + + + + +@/types/upms/menu diff --git a/OrangeFormsOpen-VUE3/src/components/layout/components/hooks.ts b/OrangeFormsOpen-VUE3/src/components/layout/components/hooks.ts new file mode 100644 index 00000000..f78fcd7f --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/layout/components/hooks.ts @@ -0,0 +1,51 @@ +import { SysMenuBindType } from '@/common/staticDict'; +import { getToken } from '@/common/utils'; +import { useLayoutStore } from '@/store'; +import { findMenuItemById } from '@/store/utils'; +import { MenuItem } from '@/types/upms/menu'; + +export const useSelectMenu = () => { + const layoutStore = useLayoutStore(); + + /** + * 选择菜单,跳转到目标页面 + * 外链弹出新窗口 + * + * @param menuId 菜单ID + */ + const selectMenuById = (menuId: string) => { + const menuItem: MenuItem | null = findMenuItemById(menuId, layoutStore.menuList); + if (menuItem) selectMenu(menuItem); + }; + + /** + * 选择菜单,跳转到目标页面 + * 外链弹出新窗口 + * + * @param menu 菜单项 + */ + const selectMenu = (menu: MenuItem) => { + // TODO 外链暂时直接弹出新窗口,有其它规则时,可以从这里开始修改 + if ( + menu != null && + menu.bindType === SysMenuBindType.THRID_URL && + menu.targetUrl != null && + menu.targetUrl !== '' + ) { + const token = getToken(); + let targetUrl = menu.targetUrl; + if (targetUrl.indexOf('?') === -1) { + targetUrl = targetUrl + '?'; + } + targetUrl = targetUrl + 'token=' + token; + window.open(targetUrl); + return; + } + layoutStore.setCurrentMenu(menu); + }; + + return { + selectMenuById, + selectMenu, + }; +}; diff --git a/OrangeFormsOpen-VUE3/src/components/layout/components/multi-column-menu.vue b/OrangeFormsOpen-VUE3/src/components/layout/components/multi-column-menu.vue new file mode 100644 index 00000000..4b6cc9db --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/layout/components/multi-column-menu.vue @@ -0,0 +1,153 @@ + + + + + +@/types/upms/menu diff --git a/OrangeFormsOpen-VUE3/src/components/layout/components/multi-column.vue b/OrangeFormsOpen-VUE3/src/components/layout/components/multi-column.vue new file mode 100644 index 00000000..685b5313 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/layout/components/multi-column.vue @@ -0,0 +1,143 @@ + + + + + +@/types/upms/menu diff --git a/OrangeFormsOpen-VUE3/src/components/layout/index.vue b/OrangeFormsOpen-VUE3/src/components/layout/index.vue new file mode 100644 index 00000000..a791b692 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/layout/index.vue @@ -0,0 +1,495 @@ + + + + + + + diff --git a/OrangeFormsOpen-VUE3/src/components/thirdParty/hooks.ts b/OrangeFormsOpen-VUE3/src/components/thirdParty/hooks.ts new file mode 100644 index 00000000..64d58d25 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/thirdParty/hooks.ts @@ -0,0 +1,114 @@ +import { useRoute } from 'vue-router'; +import { ANY_OBJECT } from '@/types/generic'; +import { getAppId, setToken } from '@/common/utils'; +import { ThirdProps } from './types'; + +export const useThirdParty = (props: ThirdProps) => { + console.log('接收到的第三方参数', props); + + const dialogIndex = ref(0); + + const thirdParams = computed(() => { + let temp: ANY_OBJECT = {}; + try { + if (props.thirdParamsString) temp = JSON.parse(props.thirdParamsString); + } catch (e) { + console.log(e); + temp = {}; + } + return temp; + }); + + console.log('thirdParams', thirdParams); + + const onCloseThirdDialog = (isSuccess?: boolean, rowData?: T, data?: T) => { + console.log('onCloseThirdDialog', rowData, data); + if (window.parent) { + window.parent.postMessage( + { + type: 'closeDialog', + data: { + index: dialogIndex.value, + dialogKey: props.dialogKey, + path: thirdParams.value.path, + rowData: rowData ? JSON.parse(JSON.stringify(rowData)) : undefined, + data: data ? JSON.parse(JSON.stringify(data)) : undefined, + isSuccess, + }, + }, + '*', + ); + } + }; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const handlerMessage = (msgType: string, data: any) => { + //console.log('handlerMessage', msgType, data); + switch (msgType) { + case 'setToken': + if (data.token) setToken(data.token); + break; + case 'dialogIndex': + dialogIndex.value = data; + break; + case 'refreshData': + break; + case 'message': + // handlerErrorMessage(data); + break; + } + }; + + const eventListener = (e: ANY_OBJECT) => { + handlerMessage(e.data.type, e.data.data); + }; + + onMounted(() => { + console.log('onMounted message'); + window.addEventListener('message', eventListener, false); + }); + + onUnmounted(() => { + console.log('onUnmounted message'); + window.removeEventListener('message', eventListener); + }); + + return { + thirdParams, + onCloseThirdDialog, + }; +}; + +export const useThirdPartyAlive = () => { + let refreshTimer: number; + + const route = useRoute(); + + const refreshToken = () => { + if (window.parent) { + window.parent.postMessage( + { + type: 'refreshToken', + }, + '*', + ); + } + }; + + if (route.path.indexOf('/thirdParty/') !== -1) { + onMounted(() => { + if (getAppId()) { + refreshTimer = setInterval(() => { + console.log('refreshToken thirdParty'); + refreshToken(); + }, 1000 * 60 * 3); + } + }); + + onUnmounted(() => { + if (refreshTimer) { + clearInterval(refreshTimer); + } + }); + } +}; diff --git a/OrangeFormsOpen-VUE3/src/components/thirdParty/index.vue b/OrangeFormsOpen-VUE3/src/components/thirdParty/index.vue new file mode 100644 index 00000000..8d8457c9 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/thirdParty/index.vue @@ -0,0 +1,47 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/components/thirdParty/types.ts b/OrangeFormsOpen-VUE3/src/components/thirdParty/types.ts new file mode 100644 index 00000000..41748366 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/components/thirdParty/types.ts @@ -0,0 +1,4 @@ +export interface ThirdProps { + thirdParamsString?: string; + dialogKey?: string; +} diff --git a/OrangeFormsOpen-VUE3/src/index.scss b/OrangeFormsOpen-VUE3/src/index.scss new file mode 100644 index 00000000..28c359c5 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/index.scss @@ -0,0 +1,408 @@ +html,body { + height: 100%; + background: #f9f9f9; +} + + +@layer components { + .flex-center { + @apply flex; + @apply items-center; + } +} + +@layer base { + *, + ::before, + ::after { + border-style: solid; /* 2 */ + border-width: 0; /* 2 */ + border-color: theme('borderColor.DEFAULT', currentcolor); /* 2 */ + box-sizing: border-box; /* 1 */ + } + + ::before, + ::after { + --tw-content: ''; + } + + /* + 1. Use a consistent sensible line-height in all browsers. + 2. Prevent adjustments of font size after orientation changes in iOS. + 3. Use a more readable tab size. + 4. Use the user's configured `sans` font-family by default. + */ + + html { + line-height: 1.5; /* 1 */ + text-size-adjust: 100%; /* 2 */ /* 3 */ + tab-size: 4; /* 3 */ + font-family: theme( + 'fontFamily.sans', + ui-sans-serif, + system-ui, + -apple-system, + BlinkMacSystemFont, + 'Segoe UI', + Roboto, + 'Helvetica Neue', + Arial, + 'Noto Sans', + sans-serif, + 'Apple Color Emoji', + 'Segoe UI Emoji', + 'Segoe UI Symbol', + 'Noto Color Emoji' + ); /* 4 */ + } + + /* + 1. Remove the margin in all browsers. + 2. Inherit line-height from `html` so users can set them as a class directly on the `html` element. + */ + + body { + margin: 0; /* 1 */ + line-height: inherit; /* 2 */ + } + + /* + 1. Add the correct height in Firefox. + 2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655) + 3. Ensure horizontal rules are visible by default. + */ + + hr { + height: 0; /* 1 */ + color: inherit; /* 2 */ + border-top-width: 1px; /* 3 */ + } + + /* + Add the correct text decoration in Chrome, Edge, and Safari. + */ + + abbr:where([title]) { + text-decoration: underline dotted; + } + + /* + Remove the default font size and weight for headings. + */ + + h1, + h2, + h3, + h4, + h5, + h6 { + font-size: inherit; + font-weight: inherit; + } + + /* + Reset links to optimize for opt-in styling instead of opt-out. + */ + + a { + text-decoration: inherit; + color: inherit; + } + + /* + Add the correct font weight in Edge and Safari. + */ + + b, + strong { + font-weight: bolder; + } + + /* + 1. Use the user's configured `mono` font family by default. + 2. Correct the odd `em` font sizing in all browsers. + */ + + code, + kbd, + samp, + pre { + font-size: 1em; /* 2 */ + font-family: theme( + 'fontFamily.mono', + ui-monospace, + SFMono-Regular, + Menlo, + Monaco, + Consolas, + 'Liberation Mono', + 'Courier New', + monospace + ); /* 1 */ + } + + /* + Add the correct font size in all browsers. + */ + + small { + font-size: 80%; + } + + /* + Prevent `sub` and `sup` elements from affecting the line height in all browsers. + */ + + sub, + sup { + position: relative; + font-size: 75%; + line-height: 0; + vertical-align: baseline; + } + + sub { + bottom: -0.25em; + } + + sup { + top: -0.5em; + } + + table { + text-indent: 0; /* 1 */ + border-color: inherit; /* 2 */ + border-collapse: collapse; /* 3 */ + } + + /* + 1. Change the font styles in all browsers. + 2. Remove the margin in Firefox and Safari. + 3. Remove default padding in all browsers. + */ + + button, + input, + optgroup, + select, + textarea { + padding: 0; /* 3 */ + margin: 0; /* 2 */ + font-size: 100%; /* 1 */ + font-family: inherit; /* 1 */ + color: inherit; /* 1 */ + line-height: inherit; /* 1 */ + } + + /* + Remove the inheritance of text transform in Edge and Firefox. + */ + + button, + select { + text-transform: none; + } + + /* + 1. Correct the inability to style clickable types in iOS and Safari. + 2. Remove default button styles. + */ + + button, + [type='button'], + [type='reset'], + [type='submit'] { + appearance: button; /* 1 */ + background-image: none; /* 2 */ + } + + /* + Use the modern Firefox focus style for all focusable elements. + */ + + :-moz-focusring { + outline: auto; + } + + /* + Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737) + */ + + :-moz-ui-invalid { + box-shadow: none; + } + + /* + Add the correct vertical alignment in Chrome and Firefox. + */ + + progress { + vertical-align: baseline; + } + + /* + Correct the cursor style of increment and decrement buttons in Safari. + */ + + ::-webkit-inner-spin-button, + ::-webkit-outer-spin-button { + height: auto; + } + + /* + 1. Correct the odd appearance in Chrome and Safari. + 2. Correct the outline style in Safari. + */ + + [type='search'] { + appearance: textfield; /* 1 */ + outline-offset: -2px; /* 2 */ + } + + /* + Remove the inner padding in Chrome and Safari on macOS. + */ + + ::-webkit-search-decoration { + appearance: none; + } + + /* + 1. Correct the inability to style clickable types in iOS and Safari. + 2. Change font properties to `inherit` in Safari. + */ + + ::-webkit-file-upload-button { + appearance: button; /* 1 */ + font: inherit; /* 2 */ + } + + /* + Add the correct display in Chrome and Safari. + */ + + summary { + display: list-item; + } + + /* + Removes the default spacing and border for appropriate elements. + */ + + blockquote, + dl, + dd, + h1, + h2, + h3, + h4, + h5, + h6, + hr, + figure, + p, + pre { + margin: 0; + } + + fieldset { + padding: 0; + margin: 0; + } + + legend { + padding: 0; + } + + ol, + ul, + menu { + padding: 0; + margin: 0; + list-style: none; + } + + /* + Prevent resizing textareas horizontally by default. + */ + + textarea { + resize: vertical; + } + + input::placeholder, + textarea::placeholder { + color: theme('colors.gray.400', #9ca3af); /* 2 */ + opacity: 1; /* 1 */ + } + + /* + Set the default cursor for buttons. + */ + + button, + [role='button'] { + cursor: pointer; + } + + /* + Make sure disabled buttons don't get the pointer cursor. + */ + :disabled { + cursor: default; + } + + /* + 1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14) + 2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210) + This can trigger a poorly considered lint error in some tools but is included by design. + */ + + img, + svg, + video, + canvas, + audio, + iframe, + embed, + object { + display: block; /* 1 */ + vertical-align: middle; /* 2 */ + } + + /* + Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14) + */ + + img, + video { + max-width: 100%; + height: auto; + } + + /* + Ensure the default browser behavior of the `hidden` attribute. + */ + + [hidden] { + display: none; + } +} +::-webkit-scrollbar-track-piece { + background-color: #f8f8f8; +} + +::-webkit-scrollbar { + width: 7px; + height: 7px; +} + +::-webkit-scrollbar-thumb { + min-height: 28px; + background-color: #ddd; + background-clip: padding-box; +} + +::-webkit-scrollbar-thumb:hover { + background-color: #bbb; +} diff --git a/OrangeFormsOpen-VUE3/src/main.ts b/OrangeFormsOpen-VUE3/src/main.ts new file mode 100644 index 00000000..93adb2d2 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/main.ts @@ -0,0 +1,52 @@ +import { createApp } from 'vue'; +import * as ElementPlusIconsVue from '@element-plus/icons-vue'; +import '@/common/http/request'; +import { VxeTable, VxeColumn, Edit } from 'vxe-table'; +import App from '@/App.vue'; +import { router } from '@/router/index'; +import pinia from '@/store'; + +// 表格样式 +import 'vxe-table/lib/style.css'; +// layui样式 +import '@layui/layui-vue/lib/index.css'; +// vant样式 +import 'vant/lib/index.css'; +// element-plus 按需导入缺少的样式 +import 'element-plus/theme-chalk/el-loading.css'; +import 'element-plus/theme-chalk/el-message.css'; +import 'element-plus/theme-chalk/el-message-box.css'; +import 'element-plus/theme-chalk/el-notification.css'; +import 'element-plus/theme-chalk/el-cascader.css'; +import 'element-plus/theme-chalk/el-cascader-panel.css'; +import 'element-plus/theme-chalk/el-tree.css'; +import 'element-plus/theme-chalk/el-date-picker.css'; +import 'element-plus/theme-chalk/el-input-number.css'; + +// 其它样式 +import '@/assets/online-icon/iconfont.css'; +// 静态字典 +import * as staticDict from '@/common/staticDict/index'; +import * as olineDicgt from '@/common/staticDict/online'; +import * as flowDict from '@/common/staticDict/flow'; + +import { ANY_OBJECT } from '@/types/generic'; + +function useTable(app: ANY_OBJECT) { + app.use(VxeTable).use(VxeColumn).use(Edit); +} +function useStaticDict(app: ANY_OBJECT, staticDict: ANY_OBJECT) { + Object.keys(staticDict).forEach(key => { + app.config.globalProperties[key] = staticDict[key]; + }); +} + +const app = createApp(App); +for (const [key, component] of Object.entries(ElementPlusIconsVue)) { + app.component(key, component); +} +useStaticDict(app, staticDict); +useStaticDict(app, olineDicgt); +useStaticDict(app, flowDict); +app.use(pinia).use(router).use(useTable); +app.mount('#app'); diff --git a/OrangeFormsOpen-VUE3/src/online/components/ActiveWidgetMenu.vue b/OrangeFormsOpen-VUE3/src/online/components/ActiveWidgetMenu.vue new file mode 100644 index 00000000..6a78620f --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/ActiveWidgetMenu.vue @@ -0,0 +1,56 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/OnlineBaseCard.vue b/OrangeFormsOpen-VUE3/src/online/components/OnlineBaseCard.vue new file mode 100644 index 00000000..33f3426a --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/OnlineBaseCard.vue @@ -0,0 +1,262 @@ + + + + + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/OnlineCardTable.vue b/OrangeFormsOpen-VUE3/src/online/components/OnlineCardTable.vue new file mode 100644 index 00000000..98d26666 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/OnlineCardTable.vue @@ -0,0 +1,217 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomBlock.vue b/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomBlock.vue new file mode 100644 index 00000000..babe316a --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomBlock.vue @@ -0,0 +1,325 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomImage.vue b/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomImage.vue new file mode 100644 index 00000000..03c8afb8 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomImage.vue @@ -0,0 +1,142 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomLabel.vue b/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomLabel.vue new file mode 100644 index 00000000..84b49b12 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomLabel.vue @@ -0,0 +1,88 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomTable.vue b/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomTable.vue new file mode 100644 index 00000000..919b21f0 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomTable.vue @@ -0,0 +1,567 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomTabs.vue b/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomTabs.vue new file mode 100644 index 00000000..d96a27e5 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomTabs.vue @@ -0,0 +1,95 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomText.vue b/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomText.vue new file mode 100644 index 00000000..7bd15ae2 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomText.vue @@ -0,0 +1,69 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomTree.vue b/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomTree.vue new file mode 100644 index 00000000..bf99ebf8 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomTree.vue @@ -0,0 +1,167 @@ + + + + + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomUpload.vue b/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomUpload.vue new file mode 100644 index 00000000..6cb7c1c4 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomUpload.vue @@ -0,0 +1,278 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomWidget.vue b/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomWidget.vue new file mode 100644 index 00000000..010a968c --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomWidget.vue @@ -0,0 +1,579 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomWorkFlowTable.vue b/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomWorkFlowTable.vue new file mode 100644 index 00000000..84d1f160 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/OnlineCustomWorkFlowTable.vue @@ -0,0 +1,496 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/AttributeCollapse/editWidgetAttribute.vue b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/AttributeCollapse/editWidgetAttribute.vue new file mode 100644 index 00000000..330a4a4c --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/AttributeCollapse/editWidgetAttribute.vue @@ -0,0 +1,264 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/AttributeCollapse/index.vue b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/AttributeCollapse/index.vue new file mode 100644 index 00000000..085b9dd0 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/AttributeCollapse/index.vue @@ -0,0 +1,91 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/AttributeForm/editWidgetAttribute.vue b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/AttributeForm/editWidgetAttribute.vue new file mode 100644 index 00000000..f8bb03ba --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/AttributeForm/editWidgetAttribute.vue @@ -0,0 +1,270 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/AttributeForm/index.vue b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/AttributeForm/index.vue new file mode 100644 index 00000000..1034e291 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/AttributeForm/index.vue @@ -0,0 +1,86 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/CustomWidgetDictSetting/editDictParamValue.vue b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/CustomWidgetDictSetting/editDictParamValue.vue new file mode 100644 index 00000000..4e598bad --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/CustomWidgetDictSetting/editDictParamValue.vue @@ -0,0 +1,188 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/CustomWidgetDictSetting/index.vue b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/CustomWidgetDictSetting/index.vue new file mode 100644 index 00000000..97861731 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/CustomWidgetDictSetting/index.vue @@ -0,0 +1,223 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/DateViewTablePagerSetting/index.vue b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/DateViewTablePagerSetting/index.vue new file mode 100644 index 00000000..00741f3d --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/DateViewTablePagerSetting/index.vue @@ -0,0 +1,54 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineCustomListOrderSetting/editCustomListOrder.vue b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineCustomListOrderSetting/editCustomListOrder.vue new file mode 100644 index 00000000..56134d5b --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineCustomListOrderSetting/editCustomListOrder.vue @@ -0,0 +1,179 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineCustomListOrderSetting/index.vue b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineCustomListOrderSetting/index.vue new file mode 100644 index 00000000..8da39f1a --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineCustomListOrderSetting/index.vue @@ -0,0 +1,98 @@ + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineImageUrlInput.vue b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineImageUrlInput.vue new file mode 100644 index 00000000..22c9a958 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineImageUrlInput.vue @@ -0,0 +1,68 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineMobieNumberRangeQuickSelectSetting/editNumberRangeQuick.vue b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineMobieNumberRangeQuickSelectSetting/editNumberRangeQuick.vue new file mode 100644 index 00000000..75be8e5c --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineMobieNumberRangeQuickSelectSetting/editNumberRangeQuick.vue @@ -0,0 +1,98 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineMobieNumberRangeQuickSelectSetting/index.vue b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineMobieNumberRangeQuickSelectSetting/index.vue new file mode 100644 index 00000000..bf53cb25 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineMobieNumberRangeQuickSelectSetting/index.vue @@ -0,0 +1,84 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineTabPanelSetting/editOnlineTabPanel.vue b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineTabPanelSetting/editOnlineTabPanel.vue new file mode 100644 index 00000000..c48f5a22 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineTabPanelSetting/editOnlineTabPanel.vue @@ -0,0 +1,120 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineTabPanelSetting/index.vue b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineTabPanelSetting/index.vue new file mode 100644 index 00000000..2cd1b5e5 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineTabPanelSetting/index.vue @@ -0,0 +1,97 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineTableColumnSetting/editOnlineTableColumn.vue b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineTableColumnSetting/editOnlineTableColumn.vue new file mode 100644 index 00000000..efbce695 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineTableColumnSetting/editOnlineTableColumn.vue @@ -0,0 +1,227 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineTableColumnSetting/index.vue b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineTableColumnSetting/index.vue new file mode 100644 index 00000000..75f32b48 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/WidgetAttributeSetting/components/OnlineTableColumnSetting/index.vue @@ -0,0 +1,101 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/online/components/hooks/widget.ts b/OrangeFormsOpen-VUE3/src/online/components/hooks/widget.ts new file mode 100644 index 00000000..f3d64c82 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/hooks/widget.ts @@ -0,0 +1,52 @@ +import { ElMessageBox } from 'element-plus'; +import { ANY_OBJECT } from '@/types/generic'; +import { WidgetProps, WidgetEmit } from '../types/widget'; + +export const useWidget = (props: WidgetProps, emit: WidgetEmit) => { + const propsWidget = computed({ + get() { + return props.widget; + }, + set(value: ANY_OBJECT) { + console.log('widget change', value); + emit('update:widget', value); + }, + }); + const childWidgetList = computed({ + get() { + return props.widget.childWidgetList || []; + }, + set(values: ANY_OBJECT[]) { + console.log('childWidgetList change', values); + const widget = props.widget; + widget.childWidgetList = values; + emit('update:widget', widget); + }, + }); + + const onWidgetClick = (widget: ANY_OBJECT | null = null) => { + emit('widgetClick', widget); + }; + + const onDeleteWidget = (widget: ANY_OBJECT) => { + ElMessageBox.confirm('是否删除此组件?', '', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + }) + .then(() => { + childWidgetList.value = childWidgetList.value.filter((item: ANY_OBJECT) => item !== widget); + onWidgetClick(null); + }) + .catch(e => { + console.warn(e); + }); + }; + + const onCopyWidget = (widget: ANY_OBJECT) => { + const childWidgetList = props.widget.childWidgetList; + childWidgetList.push(widget); + }; + + return { propsWidget, childWidgetList, onWidgetClick, onDeleteWidget, onCopyWidget }; +}; diff --git a/OrangeFormsOpen-VUE3/src/online/components/types/widget.ts b/OrangeFormsOpen-VUE3/src/online/components/types/widget.ts new file mode 100644 index 00000000..f5bdad55 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/components/types/widget.ts @@ -0,0 +1,11 @@ +import { ANY_OBJECT } from '@/types/generic'; + +export interface WidgetProps { + widget: ANY_OBJECT; + isEdit?: boolean; +} + +export interface WidgetEmit { + (event: 'widgetClick', value: ANY_OBJECT | null): void; + (event: 'update:widget', value: ANY_OBJECT | ANY_OBJECT[]): void; +} diff --git a/OrangeFormsOpen-VUE3/src/online/config/baseCard.ts b/OrangeFormsOpen-VUE3/src/online/config/baseCard.ts new file mode 100644 index 00000000..d8c539ad --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/baseCard.ts @@ -0,0 +1,54 @@ +import { SysCustomWidgetType, OnlineFormEventType } from '@/common/staticDict/index'; + +const card = { + span: { + name: '组件宽度', + widgetType: SysCustomWidgetType.Slider, + value: 12, + min: 1, + max: 24, + }, + shadow: { + name: '阴影显示', + widgetType: SysCustomWidgetType.Select, + value: 'never', + dropdownList: [ + { + id: 'never', + name: '不显示', + }, + { + id: 'hover', + name: '悬浮显示', + }, + { + id: 'always', + name: '一直显示', + }, + ], + }, + padding: { + name: '内部边距', + widgetType: SysCustomWidgetType.NumberInput, + value: 20, + min: 0, + }, + paddingBottom: { + name: '底部距离', + widgetType: SysCustomWidgetType.NumberInput, + value: 0, + min: 0, + }, +}; + +const baseCardConfig = { + widgetType: SysCustomWidgetType.Card, + icon: 'online-icon icon-card3', + attribute: card, + allowEventList: [OnlineFormEventType.VISIBLE], + operationList: [], + supportBindTable: false, + supportBindColumn: false, +}; + +export default baseCardConfig; diff --git a/OrangeFormsOpen-VUE3/src/online/config/cascader.ts b/OrangeFormsOpen-VUE3/src/online/config/cascader.ts new file mode 100644 index 00000000..55d85e55 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/cascader.ts @@ -0,0 +1,80 @@ +import { + SysCustomWidgetType, + SysOnlineFormType, + OnlineFormEventType, +} from '@/common/staticDict/index'; +import { ANY_OBJECT } from '@/types/generic'; + +const cascader = { + span: { + name: '组件宽度', + widgetType: SysCustomWidgetType.Slider, + value: 12, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + min: 1, + max: 24, + }, + placeholder: { + name: '占位文本', + widgetType: SysCustomWidgetType.Input, + value: '', + }, + dictInfo: { + name: '下拉字典', + value: {}, + customComponent: { + component: 'CustomWidgetDictSetting', + }, + }, + required: { + name: '是否必填', + value: false, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: true, + name: '必填', + }, + { + id: false, + name: '非必填', + }, + ], + }, + disabled: { + name: '是否禁用', + value: false, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: false, + name: '启用', + }, + { + id: true, + name: '禁用', + }, + ], + }, +}; + +const cascaderConfig = { + widgetType: SysCustomWidgetType.Cascader, + icon: 'online-icon icon-cascader', + attribute: cascader, + allowEventList: [ + OnlineFormEventType.CHANGE, + OnlineFormEventType.DISABLE, + OnlineFormEventType.VISIBLE, + OnlineFormEventType.DROPDOWN_CHANGE, + ], + supportBindTable: true, + supportBindColumn: true, +}; + +export default cascaderConfig; diff --git a/OrangeFormsOpen-VUE3/src/online/config/checkbox.ts b/OrangeFormsOpen-VUE3/src/online/config/checkbox.ts new file mode 100644 index 00000000..8208fbf5 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/checkbox.ts @@ -0,0 +1,75 @@ +import { + SysCustomWidgetType, + SysOnlineFormType, + OnlineFormEventType, +} from '@/common/staticDict/index'; +import { ANY_OBJECT } from '@/types/generic'; + +const checkbox = { + span: { + name: '组件宽度', + widgetType: SysCustomWidgetType.Slider, + value: 12, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + min: 1, + max: 24, + }, + dictInfo: { + name: '下拉字典', + value: {}, + customComponent: { + component: 'CustomWidgetDictSetting', + }, + }, + required: { + name: '是否必填', + value: false, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: true, + name: '必填', + }, + { + id: false, + name: '非必填', + }, + ], + }, + disabled: { + name: '是否禁用', + value: false, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: false, + name: '启用', + }, + { + id: true, + name: '禁用', + }, + ], + }, +}; + +const checkboxConfig = { + widgetType: SysCustomWidgetType.CheckBox, + icon: 'online-icon icon-checkbox', + attribute: checkbox, + allowEventList: [ + OnlineFormEventType.CHANGE, + OnlineFormEventType.DISABLE, + OnlineFormEventType.VISIBLE, + OnlineFormEventType.DROPDOWN_CHANGE, + ], + supportBindTable: true, + supportBindColumn: true, +}; + +export default checkboxConfig; diff --git a/OrangeFormsOpen-VUE3/src/online/config/customBlock.ts b/OrangeFormsOpen-VUE3/src/online/config/customBlock.ts new file mode 100644 index 00000000..be3d9c7a --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/customBlock.ts @@ -0,0 +1,28 @@ +import { SysCustomWidgetType, OnlineFormEventType } from '@/common/staticDict/index'; + +const block = { + span: { + name: '组件宽度', + widgetType: SysCustomWidgetType.Slider, + value: 12, + min: 1, + max: 24, + }, + paddingBottom: { + name: '底部距离', + widgetType: SysCustomWidgetType.NumberInput, + value: 0, + min: 0, + }, +}; + +const customBlockConfig = { + widgetType: SysCustomWidgetType.Block, + icon: 'online-icon icon-block', + attribute: block, + allowEventList: [OnlineFormEventType.VISIBLE], + supportBindTable: false, + supportBindColumn: false, +}; + +export default customBlockConfig; diff --git a/OrangeFormsOpen-VUE3/src/online/config/date.ts b/OrangeFormsOpen-VUE3/src/online/config/date.ts new file mode 100644 index 00000000..03db333f --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/date.ts @@ -0,0 +1,100 @@ +import { + SysCustomWidgetType, + SysOnlineFormType, + OnlineFormEventType, +} from '@/common/staticDict/index'; +import { ANY_OBJECT } from '@/types/generic'; + +const date = { + span: { + name: '组件宽度', + widgetType: SysCustomWidgetType.Slider, + value: 12, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + min: 1, + max: 24, + }, + placeholder: { + name: '占位文本', + widgetType: SysCustomWidgetType.Input, + value: '', + }, + type: { + name: '显示类型', + widgetType: SysCustomWidgetType.Select, + dropdownList: [ + { + id: 'date', + name: '日', + }, + { + id: 'week', + name: '周', + }, + { + id: 'month', + name: '月', + }, + { + id: 'year', + name: '年', + }, + { + id: 'datetime', + name: '时间', + }, + ], + value: 'date', + }, + required: { + name: '是否必填', + value: false, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: true, + name: '必填', + }, + { + id: false, + name: '非必填', + }, + ], + }, + disabled: { + name: '是否禁用', + value: false, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: false, + name: '启用', + }, + { + id: true, + name: '禁用', + }, + ], + }, +}; + +const dateConfig = { + widgetType: SysCustomWidgetType.Date, + icon: 'online-icon icon-date', + attribute: date, + allowEventList: [ + OnlineFormEventType.CHANGE, + OnlineFormEventType.DISABLE, + OnlineFormEventType.VISIBLE, + OnlineFormEventType.DISABLED_DATE, + ], + supportBindTable: true, + supportBindColumn: true, +}; + +export default dateConfig; diff --git a/OrangeFormsOpen-VUE3/src/online/config/dateRange.ts b/OrangeFormsOpen-VUE3/src/online/config/dateRange.ts new file mode 100644 index 00000000..5303e200 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/dateRange.ts @@ -0,0 +1,97 @@ +import { + SysCustomWidgetType, + SysOnlineFormType, + OnlineFormEventType, +} from '@/common/staticDict/index'; +import { ANY_OBJECT } from '@/types/generic'; + +const dateRange = { + span: { + name: '组件宽度', + widgetType: SysCustomWidgetType.Slider, + value: 12, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + min: 1, + max: 24, + }, + 'start-placeholder': { + name: '开始日期提示', + widgetType: SysCustomWidgetType.Input, + value: '', + }, + 'end-placeholder': { + name: '结束日期提示', + widgetType: SysCustomWidgetType.Input, + value: '', + }, + type: { + name: '显示类型', + widgetType: SysCustomWidgetType.Select, + dropdownList: [ + { + id: 'daterange', + name: '日', + }, + { + id: 'monthrange', + name: '月', + }, + { + id: 'datetimerange', + name: '时间', + }, + ], + value: 'daterange', + }, + required: { + name: '是否必填', + value: false, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: true, + name: '必填', + }, + { + id: false, + name: '非必填', + }, + ], + }, + disabled: { + name: '是否禁用', + value: false, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: false, + name: '启用', + }, + { + id: true, + name: '禁用', + }, + ], + }, +}; + +const dateRangeConfig = { + widgetType: SysCustomWidgetType.DateRange, + icon: 'online-icon icon-date-range', + attribute: dateRange, + allowEventList: [ + OnlineFormEventType.CHANGE, + OnlineFormEventType.DISABLE, + OnlineFormEventType.VISIBLE, + OnlineFormEventType.DISABLED_DATE, + ], + supportBindTable: true, + supportBindColumn: true, +}; + +export default dateRangeConfig; diff --git a/OrangeFormsOpen-VUE3/src/online/config/deptSelect.ts b/OrangeFormsOpen-VUE3/src/online/config/deptSelect.ts new file mode 100644 index 00000000..f6c8f74c --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/deptSelect.ts @@ -0,0 +1,72 @@ +import { + SysCustomWidgetType, + SysOnlineFormType, + OnlineFormEventType, +} from '@/common/staticDict/index'; +import { ANY_OBJECT } from '@/types/generic'; + +const deptSelect = { + span: { + name: '组件宽度', + widgetType: SysCustomWidgetType.Slider, + value: 12, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + min: 1, + max: 24, + }, + placeholder: { + name: '占位文本', + widgetType: SysCustomWidgetType.Input, + value: '', + }, + required: { + name: '是否必填', + value: false, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: true, + name: '必填', + }, + { + id: false, + name: '非必填', + }, + ], + }, + disabled: { + name: '是否禁用', + value: false, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: false, + name: '启用', + }, + { + id: true, + name: '禁用', + }, + ], + }, +}; + +const deptSelectConfig = { + widgetType: SysCustomWidgetType.DeptSelect, + icon: 'online-icon icon-dept', + attribute: deptSelect, + allowEventList: [ + OnlineFormEventType.CHANGE, + OnlineFormEventType.DISABLE, + OnlineFormEventType.VISIBLE, + ], + supportBindTable: true, + supportBindColumn: true, +}; + +export default deptSelectConfig; diff --git a/OrangeFormsOpen-VUE3/src/online/config/image.ts b/OrangeFormsOpen-VUE3/src/online/config/image.ts new file mode 100644 index 00000000..286cab17 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/image.ts @@ -0,0 +1,118 @@ +import { + SysCustomWidgetType, + OnlineFormEventType, + SysCustomWidgetBindDataType, +} from '@/common/staticDict/index'; +import { ANY_OBJECT } from '@/types/generic'; + +const image = { + span: { + name: '组件宽度', + widgetType: SysCustomWidgetType.Slider, + value: 12, + min: 1, + max: 24, + }, + fit: { + name: '裁切方式', + widgetType: SysCustomWidgetType.Select, + value: 'fill', + dropdownList: [ + { + id: 'fill', + name: 'fill', + }, + { + id: 'contain', + name: 'contain', + }, + { + id: 'cover', + name: 'cover', + }, + { + id: 'none', + name: 'none', + }, + { + id: 'scale-down', + name: 'scale-down', + }, + ], + }, + align: { + name: '图片位置', + widgetType: SysCustomWidgetType.Select, + value: 'start', + dropdownList: [ + { + id: 'start', + name: '左侧', + }, + { + id: 'center', + name: '居中', + }, + { + id: 'end', + name: '右侧', + }, + ], + }, + width: { + name: '图片宽度', + value: '100px', + widgetType: SysCustomWidgetType.Input, + }, + height: { + name: '图片高度', + value: '100px', + widgetType: SysCustomWidgetType.Input, + }, + radius: { + name: '圆角宽度', + value: 3, + widgetType: SysCustomWidgetType.Slider, + min: 0, + }, + round: { + name: '圆形图片', + value: false, + widgetType: SysCustomWidgetType.Switch, + }, + src: { + name: '图片地址', + value: '', + customComponent: { + component: 'OnlineImageUrlInput', + props: { + disabled: function (formConfig: ANY_OBJECT) { + // 表单为非报表,并且绑定在字段上,那么图片不可输入 + return ( + formConfig && + formConfig.currentWidget && + formConfig.currentWidget.bindData?.dataType !== SysCustomWidgetBindDataType.Fixed && + formConfig.form?.pageCode == null + ); + }, + }, + }, + }, + paddingBottom: { + name: '底部距离', + widgetType: SysCustomWidgetType.NumberInput, + value: 0, + min: 0, + }, +}; + +const imageConfig = { + widgetType: SysCustomWidgetType.Image, + icon: 'online-icon icon-image', + attribute: image, + allowEventList: [OnlineFormEventType.VISIBLE], + supportBindTable: true, + supportBindColumn: true, +}; + +export default imageConfig; diff --git a/OrangeFormsOpen-VUE3/src/online/config/index.ts b/OrangeFormsOpen-VUE3/src/online/config/index.ts new file mode 100644 index 00000000..a9f62be3 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/index.ts @@ -0,0 +1,282 @@ +import { ANY_OBJECT } from '@/types/generic'; +import { SysCustomWidgetType } from '@/common/staticDict/index'; +import blockConfig from './customBlock'; +import baseCardConfig from './baseCard'; +import tabsConfig from './tabs'; +import textConfig from './text'; +import imageConfig from './image'; +import labelConfig from './label'; +import inputConfig from './input'; +import numberInputConfig from './numberInput'; +import numberRangeConfig from './numberRange'; +import switchConfig from './switch'; +import radioConfig from './radio'; +import checkboxConfig from './checkbox'; +import selectConfig from './select'; +import cascaderConfig from './cascader'; +import dateConfig from './date'; +import dateRangeConfig from './dateRange'; +import userSelectConfig from './userSelect'; +import deptSelectConfig from './deptSelect'; +import uploadConfig from './upload'; +import richEditorConfig from './richEditor'; +import tableConfig from './table'; +import linkConfig from './link'; +import treeConfig from './tree'; + +const formWidgetGroupList: ANY_OBJECT = { + pc: [ + { + id: 'layout', + groupName: '布局组件', + widgetList: [blockConfig, baseCardConfig, tabsConfig, textConfig, imageConfig], + }, + { + id: 'filter', + groupName: '过滤组件', + widgetList: [ + labelConfig, + inputConfig, + numberInputConfig, + numberRangeConfig, + switchConfig, + radioConfig, + checkboxConfig, + selectConfig, + cascaderConfig, + dateConfig, + dateRangeConfig, + userSelectConfig, + deptSelectConfig, + ], + }, + { + id: 'base', + groupName: '基础组件', + widgetList: [ + labelConfig, + inputConfig, + numberInputConfig, + numberRangeConfig, + switchConfig, + radioConfig, + checkboxConfig, + selectConfig, + cascaderConfig, + dateConfig, + dateRangeConfig, + uploadConfig, + richEditorConfig, + tableConfig, + linkConfig, + ], + }, + { + id: 'advance', + groupName: '高级组件', + widgetList: [userSelectConfig, deptSelectConfig], + }, + ], +}; + +function getDefaultVariableName(widgetType: number) { + const tempTime = new Date().getTime(); + switch (widgetType) { + case SysCustomWidgetType.Label: + return 'label' + tempTime; + case SysCustomWidgetType.Input: + return 'input' + tempTime; + case SysCustomWidgetType.NumberInput: + return 'numberInput' + tempTime; + case SysCustomWidgetType.NumberRange: + return 'numberRange' + tempTime; + case SysCustomWidgetType.Switch: + return 'switch' + tempTime; + case SysCustomWidgetType.Slider: + return 'slider' + tempTime; + case SysCustomWidgetType.Radio: + return 'radio' + tempTime; + case SysCustomWidgetType.CheckBox: + return 'checkBox' + tempTime; + case SysCustomWidgetType.Select: + return 'select' + tempTime; + case SysCustomWidgetType.Cascader: + return 'cascader' + tempTime; + case SysCustomWidgetType.Date: + return 'date' + tempTime; + case SysCustomWidgetType.DateRange: + return 'dateRange' + tempTime; + case SysCustomWidgetType.Upload: + return 'upload' + tempTime; + case SysCustomWidgetType.RichEditor: + return 'richEditor' + tempTime; + case SysCustomWidgetType.Divider: + return 'divider' + tempTime; + case SysCustomWidgetType.Text: + return 'text' + tempTime; + case SysCustomWidgetType.Image: + return 'image' + tempTime; + case SysCustomWidgetType.ImageCard: + return 'imageCard' + tempTime; + case SysCustomWidgetType.Table: + return 'table' + tempTime; + case SysCustomWidgetType.PivotTable: + return 'pivotTable' + tempTime; + case SysCustomWidgetType.LineChart: + return 'lineChart' + tempTime; + case SysCustomWidgetType.BarChart: + return 'barChart' + tempTime; + case SysCustomWidgetType.PieChart: + return 'pieChart' + tempTime; + case SysCustomWidgetType.ScatterChart: + return 'scatterChart' + tempTime; + case SysCustomWidgetType.Block: + return 'block' + tempTime; + case SysCustomWidgetType.Link: + return 'link' + tempTime; + case SysCustomWidgetType.UserSelect: + return 'userSelect' + tempTime; + case SysCustomWidgetType.DeptSelect: + return 'deptSelect' + tempTime; + case SysCustomWidgetType.DataSelect: + return 'dataSelect' + tempTime; + case SysCustomWidgetType.Card: + return 'baseCard' + tempTime; + case SysCustomWidgetType.Tabs: + return 'tabs' + tempTime; + case SysCustomWidgetType.Tree: + return 'tree' + tempTime; + case SysCustomWidgetType.TableContainer: + return 'tableContainer' + tempTime; + case SysCustomWidgetType.List: + return 'baseList' + tempTime; + case SysCustomWidgetType.Rate: + return 'rate' + tempTime; + case SysCustomWidgetType.Stepper: + return 'stepper' + tempTime; + case SysCustomWidgetType.Calendar: + return 'calendar' + tempTime; + case SysCustomWidgetType.CellGroup: + return 'group' + tempTime; + case SysCustomWidgetType.MobileRadioFilter: + return 'mbileRadioFilter' + tempTime; + case SysCustomWidgetType.MobileCheckBoxFilter: + return 'mobileCheckBoxFilter' + tempTime; + case SysCustomWidgetType.MobileInputFilter: + return 'mobileInputFilter' + tempTime; + case SysCustomWidgetType.MobileSwitchFilter: + return 'mobileSwitchFilter' + tempTime; + case SysCustomWidgetType.MobileDateRangeFilter: + return 'mobileDateRangeFilter' + tempTime; + case SysCustomWidgetType.MobileNumberRangeFilter: + return 'mobileNumberRangeFilter' + tempTime; + } +} + +function getWidgetAttribute(widgetType: number): ANY_OBJECT | null { + switch (widgetType) { + case SysCustomWidgetType.Label: + return labelConfig; + case SysCustomWidgetType.Text: + return textConfig; + case SysCustomWidgetType.Image: + return imageConfig; + case SysCustomWidgetType.Input: + return inputConfig; + case SysCustomWidgetType.NumberInput: + return numberInputConfig; + case SysCustomWidgetType.NumberRange: + return numberRangeConfig; + case SysCustomWidgetType.Switch: + return switchConfig; + case SysCustomWidgetType.Radio: + return radioConfig; + case SysCustomWidgetType.CheckBox: + return checkboxConfig; + case SysCustomWidgetType.Select: + return selectConfig; + case SysCustomWidgetType.Cascader: + return cascaderConfig; + case SysCustomWidgetType.Date: + return dateConfig; + case SysCustomWidgetType.DateRange: + return dateRangeConfig; + case SysCustomWidgetType.Upload: + return uploadConfig; + case SysCustomWidgetType.RichEditor: + return richEditorConfig; + case SysCustomWidgetType.Table: + return tableConfig; + case SysCustomWidgetType.Block: + return blockConfig; + case SysCustomWidgetType.Link: + return linkConfig; + case SysCustomWidgetType.UserSelect: + return userSelectConfig; + case SysCustomWidgetType.DeptSelect: + return deptSelectConfig; + case SysCustomWidgetType.Card: + return baseCardConfig; + case SysCustomWidgetType.Tabs: + return tabsConfig; + case SysCustomWidgetType.Tree: + return treeConfig; + default: + return null; + } +} + +function getWidgetObject(widget: ANY_OBJECT): ANY_OBJECT { + const temp = { + // ...widget, + widgetType: widget.widgetType, + bindData: { + //...bindDataConfig, + defaultValue: { + //...bindDataConfig.defaultValue, + }, + }, + operationList: widget.operationList + ? JSON.parse(JSON.stringify(widget.operationList)) + : undefined, + showName: SysCustomWidgetType.getValue(widget.widgetType), + variableName: getDefaultVariableName(widget.widgetType), + props: Object.keys(widget.attribute).reduce((retObj: ANY_OBJECT, key) => { + let tempValue; + if (typeof widget.attribute[key].value === 'function') { + tempValue = widget.attribute[key].value(); + } else { + tempValue = widget.attribute[key].value; + } + if (Array.isArray(tempValue) || tempValue instanceof Object) { + retObj[key] = JSON.parse(JSON.stringify(tempValue)); + } else { + retObj[key] = tempValue; + } + return retObj; + }, {}), + eventList: [], + childWidgetList: [], + style: {}, + supportOperation: widget.supportOperation == null ? false : widget.supportOperation, + }; + return temp; +} + +function supportBindTable(widget: ANY_OBJECT) { + const widgetInfo = getWidgetAttribute(widget.widgetType); + return widgetInfo ? widgetInfo.supportBindTable : false; +} + +function supportBindColumn(widget: ANY_OBJECT) { + const widgetInfo = getWidgetAttribute(widget.widgetType); + return widgetInfo ? widgetInfo.supportBindColumn : false; +} + +export default { + formWidgetGroupList, + getWidgetObject, + getWidgetAttribute, + supportBindTable, + supportBindColumn, +}; diff --git a/OrangeFormsOpen-VUE3/src/online/config/input.ts b/OrangeFormsOpen-VUE3/src/online/config/input.ts new file mode 100644 index 00000000..a9d3ffda --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/input.ts @@ -0,0 +1,129 @@ +import { + SysCustomWidgetType, + SysOnlineFormType, + OnlineFormEventType, +} from '@/common/staticDict/index'; +import { ANY_OBJECT } from '@/types/generic'; + +const input = { + span: { + name: '组件宽度', + widgetType: SysCustomWidgetType.Slider, + value: 12, + visible: function (formConfig: ANY_OBJECT) { + return ( + formConfig && + formConfig.form.formType !== SysOnlineFormType.QUERY && + formConfig.activeMode === 'pc' + ); + }, + disabled: false, + min: 1, + max: 24, + }, + type: { + name: '输入框类型', + value: 'text', + widgetType: SysCustomWidgetType.Select, + dropdownList: function (formConfig: ANY_OBJECT) { + return [ + { + id: 'text', + name: '单行文本', + }, + { + id: 'textarea', + name: '多行文本', + }, + ]; + }, + }, + placeholder: { + name: '占位文本', + widgetType: SysCustomWidgetType.Input, + value: '', + }, + 'show-password': { + name: '是否密码', + value: false, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: true, + name: '是', + }, + { + id: false, + name: '否', + }, + ], + }, + 'show-word-limit': { + name: '是否显示字数统计', + value: false, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: true, + name: '必填', + }, + { + id: false, + name: '非必填', + }, + ], + }, + maxlength: { + name: '最大字符数', + widgetType: SysCustomWidgetType.NumberInput, + value: undefined, + }, + required: { + name: '是否必填', + value: false, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: true, + name: '必填', + }, + { + id: false, + name: '非必填', + }, + ], + }, + disabled: { + name: '是否禁用', + value: false, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: false, + name: '启用', + }, + { + id: true, + name: '禁用', + }, + ], + }, +}; + +const inputConfig = { + widgetType: SysCustomWidgetType.Input, + icon: 'online-icon icon-input', + attribute: input, + allowEventList: [ + OnlineFormEventType.CHANGE, + OnlineFormEventType.DISABLE, + OnlineFormEventType.VISIBLE, + ], + supportBindTable: true, + supportBindColumn: true, +}; + +export default inputConfig; diff --git a/OrangeFormsOpen-VUE3/src/online/config/label.ts b/OrangeFormsOpen-VUE3/src/online/config/label.ts new file mode 100644 index 00000000..8756ff71 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/label.ts @@ -0,0 +1,30 @@ +import { + SysCustomWidgetType, + SysOnlineFormType, + OnlineFormEventType, +} from '@/common/staticDict/index'; +import { ANY_OBJECT } from '@/types/generic'; + +const label = { + span: { + name: '组件宽度', + widgetType: SysCustomWidgetType.Slider, + value: 12, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + min: 1, + max: 24, + }, +}; + +const labelConfig = { + widgetType: SysCustomWidgetType.Label, + icon: 'online-icon icon-text', + attribute: label, + allowEventList: [OnlineFormEventType.VISIBLE], + supportBindTable: true, + supportBindColumn: true, +}; + +export default labelConfig; diff --git a/OrangeFormsOpen-VUE3/src/online/config/link.ts b/OrangeFormsOpen-VUE3/src/online/config/link.ts new file mode 100644 index 00000000..a83e696e --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/link.ts @@ -0,0 +1,105 @@ +import { + SysCustomWidgetType, + SysOnlineFormType, + OnlineFormEventType, +} from '@/common/staticDict/index'; +import { ANY_OBJECT } from '@/types/generic'; + +const input = { + span: { + name: '组件宽度', + widgetType: SysCustomWidgetType.Slider, + value: 12, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + disabled: false, + min: 1, + max: 24, + }, + type: { + name: '显示类型', + value: 'primary', + widgetType: SysCustomWidgetType.Select, + dropdownList: [ + { + id: 'primary', + name: 'primary', + }, + { + id: 'success', + name: 'success', + }, + { + id: 'warning', + name: 'warning', + }, + { + id: 'danger', + name: 'danger', + }, + { + id: 'info', + name: 'info', + }, + ], + }, + href: { + name: '链接地址', + widgetType: SysCustomWidgetType.Input, + value: undefined, + }, + showText: { + name: '链接显示', + widgetType: SysCustomWidgetType.Input, + value: undefined, + }, + underline: { + name: '下划线', + value: false, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: true, + name: '下划线', + }, + { + id: false, + name: '无下划线', + }, + ], + }, + disabled: { + name: '是否禁用', + value: false, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: false, + name: '启用', + }, + { + id: true, + name: '禁用', + }, + ], + }, +}; + +const linkConfig = { + widgetType: SysCustomWidgetType.Link, + icon: 'online-icon icon-link', + attribute: input, + allowEventList: [ + OnlineFormEventType.LINK_HERF, + OnlineFormEventType.DISABLE, + OnlineFormEventType.VISIBLE, + ], + supportBindTable: false, + supportBindColumn: false, +}; + +export default linkConfig; diff --git a/OrangeFormsOpen-VUE3/src/online/config/numberInput.ts b/OrangeFormsOpen-VUE3/src/online/config/numberInput.ts new file mode 100644 index 00000000..58c46909 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/numberInput.ts @@ -0,0 +1,122 @@ +import { + SysCustomWidgetType, + SysOnlineFormType, + OnlineFormEventType, +} from '@/common/staticDict/index'; +import { ANY_OBJECT } from '@/types/generic'; + +const numberInput = { + span: { + name: '组件宽度', + widgetType: SysCustomWidgetType.Slider, + value: 12, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + min: 1, + max: 24, + }, + placeholder: { + name: '占位文本', + widgetType: SysCustomWidgetType.Input, + value: '', + }, + min: { + name: '最小值', + widgetType: SysCustomWidgetType.NumberInput, + value: undefined, + }, + max: { + name: '最大值', + widgetType: SysCustomWidgetType.NumberInput, + value: undefined, + }, + step: { + name: '步长', + widgetType: SysCustomWidgetType.NumberInput, + value: 1, + }, + precision: { + name: '精度', + widgetType: SysCustomWidgetType.NumberInput, + value: undefined, + }, + controls: { + name: '控制按钮', + widgetType: SysCustomWidgetType.Switch, + value: true, + dropdownList: [ + { + id: true, + name: '显示', + }, + { + id: false, + name: '隐藏', + }, + ], + }, + 'controls-position': { + name: '按钮位置', + widgetType: SysCustomWidgetType.Radio, + value: undefined, + dropdownList: [ + { + id: undefined, + name: '默认', + }, + { + id: 'right', + name: '右侧', + }, + ], + }, + required: { + name: '是否必填', + value: false, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: true, + name: '必填', + }, + { + id: false, + name: '非必填', + }, + ], + }, + disabled: { + name: '是否禁用', + value: false, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: false, + name: '启用', + }, + { + id: true, + name: '禁用', + }, + ], + }, +}; + +const numberInputConfig = { + widgetType: SysCustomWidgetType.NumberInput, + icon: 'online-icon icon-input-number', + attribute: numberInput, + allowEventList: [ + OnlineFormEventType.CHANGE, + OnlineFormEventType.DISABLE, + OnlineFormEventType.VISIBLE, + ], + supportBindTable: true, + supportBindColumn: true, +}; + +export default numberInputConfig; diff --git a/OrangeFormsOpen-VUE3/src/online/config/numberRange.ts b/OrangeFormsOpen-VUE3/src/online/config/numberRange.ts new file mode 100644 index 00000000..8c73cb35 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/numberRange.ts @@ -0,0 +1,77 @@ +import { + SysCustomWidgetType, + SysOnlineFormType, + OnlineFormEventType, +} from '@/common/staticDict/index'; +import { ANY_OBJECT } from '@/types/generic'; + +const numberRange = { + span: { + name: '组件宽度', + widgetType: SysCustomWidgetType.Slider, + value: 12, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + min: 1, + max: 24, + }, + 'start-placeholder': { + name: '最小值提示', + widgetType: SysCustomWidgetType.Input, + value: '', + }, + 'end-placeholder': { + name: '最大值提示', + widgetType: SysCustomWidgetType.Input, + value: '', + }, + required: { + name: '是否必填', + value: false, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: true, + name: '必填', + }, + { + id: false, + name: '非必填', + }, + ], + }, + disabled: { + name: '是否禁用', + value: false, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: false, + name: '启用', + }, + { + id: true, + name: '禁用', + }, + ], + }, +}; + +const numberRangeConfig = { + widgetType: SysCustomWidgetType.NumberRange, + icon: 'online-icon icon-number-range', + attribute: numberRange, + allowEventList: [ + OnlineFormEventType.CHANGE, + OnlineFormEventType.DISABLE, + OnlineFormEventType.VISIBLE, + ], + supportBindTable: true, + supportBindColumn: true, +}; + +export default numberRangeConfig; diff --git a/OrangeFormsOpen-VUE3/src/online/config/radio.ts b/OrangeFormsOpen-VUE3/src/online/config/radio.ts new file mode 100644 index 00000000..ee9da93c --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/radio.ts @@ -0,0 +1,88 @@ +import { ANY_OBJECT } from '@/types/generic'; +import { + SysCustomWidgetType, + SysOnlineFormType, + OnlineFormEventType, +} from '@/common/staticDict/index'; + +const radio = { + span: { + name: '组件宽度', + widgetType: SysCustomWidgetType.Slider, + value: 12, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + min: 1, + max: 24, + }, + dictInfo: { + name: '下拉字典', + value: {}, + customComponent: { + component: 'CustomWidgetDictSetting', + }, + }, + supportAll: { + name: '全部选项', + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: true, + name: '显示', + }, + { + id: false, + name: '隐藏', + }, + ], + }, + required: { + name: '是否必填', + value: false, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: true, + name: '必填', + }, + { + id: false, + name: '非必填', + }, + ], + }, + disabled: { + name: '是否禁用', + value: false, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: false, + name: '启用', + }, + { + id: true, + name: '禁用', + }, + ], + }, +}; + +const radioConfig = { + widgetType: SysCustomWidgetType.Radio, + icon: 'online-icon icon-radio', + attribute: radio, + allowEventList: [ + OnlineFormEventType.CHANGE, + OnlineFormEventType.DISABLE, + OnlineFormEventType.VISIBLE, + ], + supportBindTable: true, + supportBindColumn: true, +}; + +export default radioConfig; diff --git a/OrangeFormsOpen-VUE3/src/online/config/richEditor.ts b/OrangeFormsOpen-VUE3/src/online/config/richEditor.ts new file mode 100644 index 00000000..0b40da4e --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/richEditor.ts @@ -0,0 +1,45 @@ +import { + SysCustomWidgetType, + SysOnlineFormType, + OnlineFormEventType, +} from '@/common/staticDict/index'; +import { ANY_OBJECT } from '@/types/generic'; + +const richEditor = { + span: { + name: '组件宽度', + widgetType: SysCustomWidgetType.Slider, + value: 24, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + min: 1, + max: 24, + }, + required: { + name: '是否必填', + value: false, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: true, + name: '必填', + }, + { + id: false, + name: '非必填', + }, + ], + }, +}; + +const richEditorConfig = { + widgetType: SysCustomWidgetType.RichEditor, + icon: 'online-icon icon-richeditor', + attribute: richEditor, + eventList: [OnlineFormEventType.VISIBLE], + supportBindTable: true, + supportBindColumn: true, +}; + +export default richEditorConfig; diff --git a/OrangeFormsOpen-VUE3/src/online/config/select.ts b/OrangeFormsOpen-VUE3/src/online/config/select.ts new file mode 100644 index 00000000..5b5e49c7 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/select.ts @@ -0,0 +1,80 @@ +import { + SysCustomWidgetType, + SysOnlineFormType, + OnlineFormEventType, +} from '@/common/staticDict/index'; +import { ANY_OBJECT } from '@/types/generic'; + +const select = { + span: { + name: '组件宽度', + widgetType: SysCustomWidgetType.Slider, + value: 12, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + min: 1, + max: 24, + }, + placeholder: { + name: '占位文本', + widgetType: SysCustomWidgetType.Input, + value: '', + }, + dictInfo: { + name: '下拉字典', + value: {}, + customComponent: { + component: 'CustomWidgetDictSetting', + }, + }, + required: { + name: '是否必填', + value: false, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: true, + name: '必填', + }, + { + id: false, + name: '非必填', + }, + ], + }, + disabled: { + name: '是否禁用', + value: false, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: false, + name: '启用', + }, + { + id: true, + name: '禁用', + }, + ], + }, +}; + +const selectConfig = { + widgetType: SysCustomWidgetType.Select, + icon: 'online-icon icon-select', + attribute: select, + allowEventList: [ + OnlineFormEventType.CHANGE, + OnlineFormEventType.DISABLE, + OnlineFormEventType.VISIBLE, + OnlineFormEventType.DROPDOWN_CHANGE, + ], + supportBindTable: true, + supportBindColumn: true, +}; + +export default selectConfig; diff --git a/OrangeFormsOpen-VUE3/src/online/config/switch.ts b/OrangeFormsOpen-VUE3/src/online/config/switch.ts new file mode 100644 index 00000000..11c18a86 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/switch.ts @@ -0,0 +1,77 @@ +import { + SysCustomWidgetType, + SysOnlineFormType, + OnlineFormEventType, +} from '@/common/staticDict/index'; +import { ANY_OBJECT } from '@/types/generic'; + +const switchAttribute = { + span: { + name: '组件宽度', + widgetType: SysCustomWidgetType.Slider, + value: 12, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + min: 1, + max: 24, + }, + 'active-color': { + name: '打开背景色', + widgetType: SysCustomWidgetType.ColorPicker, + value: '#1989fa', + }, + 'inactive-color': { + name: '关闭背景色', + widgetType: SysCustomWidgetType.ColorPicker, + value: '#E8E8E8', + }, + required: { + name: '是否必填', + value: false, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: true, + name: '必填', + }, + { + id: false, + name: '非必填', + }, + ], + }, + disabled: { + name: '是否禁用', + value: false, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: false, + name: '启用', + }, + { + id: true, + name: '禁用', + }, + ], + }, +}; + +const switchConfig = { + widgetType: SysCustomWidgetType.Switch, + icon: 'online-icon icon-switch', + attribute: switchAttribute, + allowEventList: [ + OnlineFormEventType.CHANGE, + OnlineFormEventType.DISABLE, + OnlineFormEventType.VISIBLE, + ], + supportBindTable: true, + supportBindColumn: true, +}; + +export default switchConfig; diff --git a/OrangeFormsOpen-VUE3/src/online/config/table.ts b/OrangeFormsOpen-VUE3/src/online/config/table.ts new file mode 100644 index 00000000..59580539 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/table.ts @@ -0,0 +1,155 @@ +import { + SysCustomWidgetType, + SysOnlineFormType, + OnlineFormEventType, + SysCustomWidgetOperationType, +} from '@/common/staticDict/index'; +import { ANY_OBJECT } from '@/types/generic'; + +const table = { + span: { + name: '组件宽度', + widgetType: SysCustomWidgetType.Slider, + value: 24, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + min: 1, + max: 24, + }, + height: { + name: '表格高度', + widgetType: SysCustomWidgetType.NumberInput, + value: 300, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + min: 100, + }, + paddingBottom: { + name: '底部距离', + widgetType: SysCustomWidgetType.NumberInput, + value: 0, + min: 0, + }, + paged: { + name: '支持分页', + widgetType: SysCustomWidgetType.Switch, + value: true, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType === SysOnlineFormType.QUERY; + }, + }, + pageSize: { + name: '每页条数', + widgetType: SysCustomWidgetType.Select, + value: 10, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType === SysOnlineFormType.QUERY; + }, + dropdownList: [ + { + id: 10, + name: 10, + }, + { + id: 20, + name: 20, + }, + { + id: 50, + name: 50, + }, + { + id: 100, + name: 100, + }, + ], + }, + operationColumnWidth: { + name: '操作列宽度', + widgetType: SysCustomWidgetType.NumberInput, + value: 160, + }, + tableColumnList: { + name: '表格字段', + showLabel: false, + value: [], + customComponent: { + component: 'OnlineTableColumnSetting', + }, + }, +}; + +const tableConfig = { + widgetType: SysCustomWidgetType.Table, + icon: 'online-icon icon-table', + attribute: table, + allowEventList: [ + OnlineFormEventType.VISIBLE, + OnlineFormEventType.BEFORE_LOAD_TABLE_DATA, + OnlineFormEventType.AFTER_LOAD_TABLE_DATA, + ], + operationList: [ + { + id: 1, + type: SysCustomWidgetOperationType.BATCH_DELETE, + name: SysCustomWidgetOperationType.getValue(SysCustomWidgetOperationType.BATCH_DELETE), + enabled: false, + builtin: true, + rowOperation: false, + btnType: 'danger', + plain: true, + formId: undefined, + readOnly: false, + showOrder: 0, + eventList: [], + }, + { + id: 2, + type: SysCustomWidgetOperationType.ADD, + name: SysCustomWidgetOperationType.getValue(SysCustomWidgetOperationType.ADD), + enabled: false, + builtin: true, + rowOperation: false, + btnType: 'primary', + plain: false, + formId: undefined, + readOnly: false, + showOrder: 1, + eventList: [], + }, + { + id: 3, + type: SysCustomWidgetOperationType.EDIT, + name: SysCustomWidgetOperationType.getValue(SysCustomWidgetOperationType.EDIT), + enabled: false, + builtin: true, + rowOperation: true, + btnClass: 'table-btn success', + formId: undefined, + readOnly: false, + showOrder: 10, + eventList: [], + }, + { + id: 4, + type: SysCustomWidgetOperationType.DELETE, + name: SysCustomWidgetOperationType.getValue(SysCustomWidgetOperationType.DELETE), + enabled: false, + builtin: true, + rowOperation: true, + btnClass: 'table-btn delete', + formId: undefined, + readOnly: false, + showOrder: 15, + eventList: [], + }, + ], + supportOperate: true, + supportBindTable: true, + supportBindColumn: false, + supportOperation: true, +}; + +export default tableConfig; diff --git a/OrangeFormsOpen-VUE3/src/online/config/tabs.ts b/OrangeFormsOpen-VUE3/src/online/config/tabs.ts new file mode 100644 index 00000000..c6b73635 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/tabs.ts @@ -0,0 +1,51 @@ +import { SysCustomWidgetType, OnlineFormEventType } from '@/common/staticDict/index'; + +const tabs = { + span: { + name: '组件宽度', + widgetType: SysCustomWidgetType.Slider, + value: 24, + min: 1, + max: 24, + }, + type: { + name: '风格类型', + widgetType: SysCustomWidgetType.Radio, + value: undefined, + dropdownList: [ + { + id: undefined, + name: '默认', + }, + { + id: 'border-card', + name: '卡片', + }, + ], + }, + paddingBottom: { + name: '底部距离', + widgetType: SysCustomWidgetType.NumberInput, + value: 0, + min: 0, + }, + tabPanelList: { + name: '标签页设置', + value: [], + customComponent: { + component: 'OnlineTabPanelSetting', + }, + }, +}; + +const tabsConfig = { + widgetType: SysCustomWidgetType.Tabs, + icon: 'online-icon icon-tabs2', + attribute: tabs, + allowEventList: [OnlineFormEventType.VISIBLE], + supportOperate: false, + supportBindTable: false, + supportBindColumn: false, +}; + +export default tabsConfig; diff --git a/OrangeFormsOpen-VUE3/src/online/config/text.ts b/OrangeFormsOpen-VUE3/src/online/config/text.ts new file mode 100644 index 00000000..42c829cd --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/text.ts @@ -0,0 +1,132 @@ +import { + SysCustomWidgetType, + OnlineFormEventType, + SysCustomWidgetBindDataType, +} from '@/common/staticDict/index'; +import { ANY_OBJECT } from '@/types/generic'; + +const text = { + span: { + name: '组件宽度', + widgetType: SysCustomWidgetType.Slider, + value: 12, + min: 1, + max: 24, + }, + padding: { + name: '内部边距', + widgetType: SysCustomWidgetType.NumberInput, + value: 2, + min: 0, + }, + paddingBottom: { + name: '底部距离', + widgetType: SysCustomWidgetType.NumberInput, + value: 0, + min: 0, + }, + height: { + name: '组件高度', + widgetType: SysCustomWidgetType.NumberInput, + value: 25, + min: 0, + }, + textIndent: { + name: '首行缩进', + widgetType: SysCustomWidgetType.NumberInput, + value: 0, + min: 0, + }, + align: { + name: '水平对齐', + value: 'left', + widgetType: SysCustomWidgetType.Select, + dropdownList: [ + { + id: 'left', + name: '左对齐', + }, + { + id: 'center', + name: '居中', + }, + { + id: 'right', + name: '右对齐', + }, + ], + }, + valign: { + name: '垂直对齐', + value: 'center', + widgetType: SysCustomWidgetType.Select, + dropdownList: [ + { + id: 'flex-start', + name: '顶部', + }, + { + id: 'center', + name: '居中', + }, + { + id: 'flex-end', + name: '底部', + }, + ], + }, + fontSize: { + name: '字号', + value: 14, + widgetType: SysCustomWidgetType.Slider, + min: 10, + max: 50, + }, + fontColor: { + name: '字体颜色', + widgetType: SysCustomWidgetType.ColorPicker, + value: '#383838', + }, + bgColor: { + name: '背景色', + widgetType: SysCustomWidgetType.ColorPicker, + value: undefined, + }, + fontBold: { + name: '粗体', + widgetType: SysCustomWidgetType.Switch, + value: false, + }, + fontItalic: { + name: '斜体', + widgetType: SysCustomWidgetType.Switch, + value: false, + }, + text: { + name: '内容', + value: '文本内容', + widgetType: SysCustomWidgetType.Input, + props: { + type: 'textarea', + disabled: function (formConfig: ANY_OBJECT) { + // 表单为非报表,并且绑定在字段上,那么内容不可输入 + return ( + formConfig && + formConfig.currentWidget?.bindData?.dataType !== SysCustomWidgetBindDataType.Fixed && + formConfig.form?.pageCode == null + ); + }, + }, + }, +}; + +const textConfig = { + widgetType: SysCustomWidgetType.Text, + icon: 'online-icon icon-text', + attribute: text, + allowEventList: [OnlineFormEventType.VISIBLE], + supportBindTable: true, + supportBindColumn: true, +}; + +export default textConfig; diff --git a/OrangeFormsOpen-VUE3/src/online/config/tree.ts b/OrangeFormsOpen-VUE3/src/online/config/tree.ts new file mode 100644 index 00000000..4f4290ea --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/tree.ts @@ -0,0 +1,83 @@ +import { + SysCustomWidgetType, + SysOnlineFormType, + OnlineFormEventType, +} from '@/common/staticDict/index'; +import { ANY_OBJECT } from '@/types/generic'; + +const tree = { + span: { + name: '组件宽度', + widgetType: SysCustomWidgetType.Slider, + value: 24, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + min: 1, + max: 24, + }, + height: { + name: '组件高度', + widgetType: SysCustomWidgetType.NumberInput, + value: 300, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + min: 100, + }, + dictInfo: { + name: '下拉字典', + value: {}, + customComponent: { + component: 'CustomWidgetDictSetting', + }, + }, + required: { + name: '是否必填', + value: false, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: true, + name: '必填', + }, + { + id: false, + name: '非必填', + }, + ], + }, + disabled: { + name: '是否禁用', + value: false, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: false, + name: '启用', + }, + { + id: true, + name: '禁用', + }, + ], + }, +}; + +const treeConfig = { + widgetType: SysCustomWidgetType.Tree, + icon: 'online-icon icon-table', + attribute: tree, + allowEventList: [OnlineFormEventType.VISIBLE], + supportOperate: false, + supportBindTable: true, + supportBindColumn: true, +}; + +export default treeConfig; diff --git a/OrangeFormsOpen-VUE3/src/online/config/upload.ts b/OrangeFormsOpen-VUE3/src/online/config/upload.ts new file mode 100644 index 00000000..ea7febfa --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/upload.ts @@ -0,0 +1,134 @@ +import { + SysCustomWidgetType, + SysOnlineFormType, + OnlineFormEventType, +} from '@/common/staticDict/index'; +import { ANY_OBJECT } from '@/types/generic'; +import { API_CONTEXT } from '@/api/config'; + +const upload = { + span: { + name: '组件宽度', + widgetType: SysCustomWidgetType.Slider, + value: 12, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + min: 1, + max: 24, + }, + fileFieldName: { + name: '文件字段名', + widgetType: SysCustomWidgetType.Input, + value: 'uploadFile', + }, + actionUrl: { + name: '上传地址', + widgetType: SysCustomWidgetType.Input, + value: function (formConfig: ANY_OBJECT) { + if (formConfig == null) return; + const form = formConfig.form; + const widget = formConfig.currentWidget; + if (form == null || widget == null || widget.datasource == null) return ''; + if ( + form.formType === SysOnlineFormType.FLOW || + form.formType === SysOnlineFormType.FLOW_SLAVE_EDIT + ) { + return API_CONTEXT + '/flow/flowOnlineOperation/upload'; + } else { + return ( + API_CONTEXT + + '/online/onlineOperation/' + + (widget.relation ? 'uploadOneToManyRelation/' : 'uploadDatasource/') + + widget.datasource.variableName + ); + } + }, + }, + downloadUrl: { + name: '下载地址', + widgetType: SysCustomWidgetType.Input, + value: function (formConfig: ANY_OBJECT) { + if (formConfig == null) return; + const form = formConfig.form; + const widget = formConfig.currentWidget; + if (form == null || widget == null || widget.datasource == null) return ''; + if ( + form.formType === SysOnlineFormType.FLOW || + form.formType === SysOnlineFormType.FLOW_SLAVE_EDIT + ) { + return API_CONTEXT + '/flow/flowOnlineOperation/download'; + } else { + return ( + API_CONTEXT + + '/online/onlineOperation/' + + (widget.relation ? 'downloadOneToManyRelation/' : 'downloadDatasource/') + + widget.datasource.variableName + ); + } + }, + }, + readOnly: { + name: '是否只读', + value: false, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: true, + name: '是', + }, + { + id: false, + name: '否', + }, + ], + }, + required: { + name: '是否必填', + value: false, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: true, + name: '必填', + }, + { + id: false, + name: '非必填', + }, + ], + }, + disabled: { + name: '是否禁用', + value: false, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: false, + name: '启用', + }, + { + id: true, + name: '禁用', + }, + ], + }, +}; + +const uploadConfig = { + widgetType: SysCustomWidgetType.Upload, + icon: 'online-icon icon-upload', + attribute: upload, + allowEventList: [ + OnlineFormEventType.CHANGE, + OnlineFormEventType.DISABLE, + OnlineFormEventType.VISIBLE, + ], + supportBindTable: true, + supportBindColumn: true, +}; + +export default uploadConfig; diff --git a/OrangeFormsOpen-VUE3/src/online/config/userSelect.ts b/OrangeFormsOpen-VUE3/src/online/config/userSelect.ts new file mode 100644 index 00000000..34482e75 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/userSelect.ts @@ -0,0 +1,72 @@ +import { + SysCustomWidgetType, + SysOnlineFormType, + OnlineFormEventType, +} from '@/common/staticDict/index'; +import { ANY_OBJECT } from '@/types/generic'; + +const userSelect = { + span: { + name: '组件宽度', + widgetType: SysCustomWidgetType.Slider, + value: 12, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + min: 1, + max: 24, + }, + placeholder: { + name: '占位文本', + widgetType: SysCustomWidgetType.Input, + value: '', + }, + required: { + name: '是否必填', + value: false, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: true, + name: '必填', + }, + { + id: false, + name: '非必填', + }, + ], + }, + disabled: { + name: '是否禁用', + value: false, + visible: function (formConfig: ANY_OBJECT) { + return formConfig && formConfig.form.formType !== SysOnlineFormType.QUERY; + }, + widgetType: SysCustomWidgetType.Switch, + dropdownList: [ + { + id: false, + name: '启用', + }, + { + id: true, + name: '禁用', + }, + ], + }, +}; + +const userSelectConfig = { + widgetType: SysCustomWidgetType.UserSelect, + icon: 'online-icon icon-user', + attribute: userSelect, + allowEventList: [ + OnlineFormEventType.CHANGE, + OnlineFormEventType.DISABLE, + OnlineFormEventType.VISIBLE, + ], + supportBindTable: true, + supportBindColumn: true, +}; + +export default userSelectConfig; diff --git a/OrangeFormsOpen-VUE3/src/online/config/workOrderList.ts b/OrangeFormsOpen-VUE3/src/online/config/workOrderList.ts new file mode 100644 index 00000000..d4002a0c --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/online/config/workOrderList.ts @@ -0,0 +1,32 @@ +import { SysCustomWidgetType, OnlineFormEventType } from '@/common/staticDict/index'; + +const workOrderList = { + card: { + name: '显示组件', + widgetType: SysCustomWidgetType.Select, + value: SysCustomWidgetType.ImageCard, + dropdownList: [ + { + id: SysCustomWidgetType.ImageCard, + name: SysCustomWidgetType.getValue(SysCustomWidgetType.ImageCard), + }, + ], + props: { + clearable: false, + }, + }, +}; + +const workOrderListConfig = { + widgetType: SysCustomWidgetType.WorkOrderList, + icon: 'online-icon icon-card', + attribute: workOrderList, + allowEventList: [OnlineFormEventType.VISIBLE], + operationList: [], + supportOperate: false, + supportBindTable: true, + supportBindColumn: false, + supportOperation: false, +}; + +export default workOrderListConfig; diff --git a/OrangeFormsOpen-VUE3/src/pages/error/404.vue b/OrangeFormsOpen-VUE3/src/pages/error/404.vue new file mode 100644 index 00000000..472dec55 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/error/404.vue @@ -0,0 +1,5 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/login/index.vue b/OrangeFormsOpen-VUE3/src/pages/login/index.vue new file mode 100644 index 00000000..8b6e1e6c --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/login/index.vue @@ -0,0 +1,273 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineAdvanceQueryForm/index.vue b/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineAdvanceQueryForm/index.vue new file mode 100644 index 00000000..0983641f --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineAdvanceQueryForm/index.vue @@ -0,0 +1,868 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineEditForm/index.vue b/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineEditForm/index.vue new file mode 100644 index 00000000..78187af1 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineEditForm/index.vue @@ -0,0 +1,616 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineOneToOneForm/OnlineFilterBox.vue b/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineOneToOneForm/OnlineFilterBox.vue new file mode 100644 index 00000000..9b8f8549 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineOneToOneForm/OnlineFilterBox.vue @@ -0,0 +1,355 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineOneToOneForm/index.vue b/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineOneToOneForm/index.vue new file mode 100644 index 00000000..37fbf254 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineOneToOneForm/index.vue @@ -0,0 +1,558 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineQueryForm/OnlineFilterBox.vue b/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineQueryForm/OnlineFilterBox.vue new file mode 100644 index 00000000..3b38a35b --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineQueryForm/OnlineFilterBox.vue @@ -0,0 +1,347 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineQueryForm/index.vue b/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineQueryForm/index.vue new file mode 100644 index 00000000..3be38f44 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineQueryForm/index.vue @@ -0,0 +1,648 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineWorkFlowForm/index.vue b/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineWorkFlowForm/index.vue new file mode 100644 index 00000000..2dd81d80 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineWorkFlowForm/index.vue @@ -0,0 +1,357 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineWorkOrderForm/index.vue b/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineWorkOrderForm/index.vue new file mode 100644 index 00000000..c674ab46 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/OnlineWorkOrderForm/index.vue @@ -0,0 +1,472 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/hooks/useForm.ts b/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/hooks/useForm.ts new file mode 100644 index 00000000..6bbea226 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/hooks/useForm.ts @@ -0,0 +1,925 @@ +import { ElMessage, ElMessageBox, type FormInstance } from 'element-plus'; +import { OnlineFormController } from '@/api/online'; +import { usePermissions } from '@/common/hooks/usePermission'; +import { + OnlineFormEventType, + OnlineSystemVariableType, + SysCustomWidgetBindDataType, + SysCustomWidgetOperationType, + SysCustomWidgetType, + SysOnlineFormType, +} from '@/common/staticDict'; +import { + SysOnlineFieldKind, + SysOnlineParamValueType, + SysOnlineRelationType, + SysOnlineRuleType, +} from '@/common/staticDict/online'; +import { formatDate } from '@/common/utils'; +import { Dialog } from '@/components/Dialog'; +import { useLoginStore } from '@/store'; +import { ANY_OBJECT } from '@/types/generic'; +import OnlineQueryForm from '@/pages/online/OnlinePageRender/OnlineQueryForm/index.vue'; +import OnlineEditForm from '@/pages/online/OnlinePageRender/OnlineEditForm/index.vue'; +import { useFormConfig } from '@/pages/online/hooks/useFormConfig'; +import widgetData from '@/online/config/index'; +import combinedDict from '@/common/staticDict/combined'; +import { pattern } from '@/common/utils/validate'; +import { post } from '@/common/http/request'; +//import { API_CONTEXT } from '@/api/config'; +import { useThirdParty } from '@/components/thirdParty/hooks'; + +const StaticDict = { ...combinedDict }; + +export const useForm = (props: ANY_OBJECT, formRef: Ref | null = null) => { + const { buildFormConfig } = useFormConfig(); + const { thirdParams } = useThirdParty(props); + + const isReady = ref(false); + + const dialogParams = computed(() => { + return { + formConfig: props.formConfig || thirdParams.value.formConfig, + rowData: props.rowData || thirdParams.value.rowData, + masterTableData: props.masterTableData || thirdParams.value.masterTableData, + isEdit: props.isEdit || thirdParams.value.isEdit || false, + isCopy: props.isCopy || thirdParams.value.isCopy || false, + readOnly: props.readOnly || thirdParams.value.readOnly || false, + fullscreen: props.fullscreen || thirdParams.value.fullscreen || false, + saveData: !thirdParams.value.saveData ? props.saveData : thirdParams.value.saveData, + }; + }); + + const form = computed(() => { + const temp: ANY_OBJECT = buildFormConfig(dialogParams.value.formConfig) || {}; + return temp; + }); + + const loginStore = useLoginStore(); + + const formReadOnly = computed(() => { + //if (this.dialogParams == null || this.dialogParams.readOnly == null) + return props.readOnly || false; + //return this.dialogParams.readOnly; + }); + + const { checkPermCodeExist } = usePermissions(); + + const masterTable = computed(() => { + return form.value.tableMap.get(form.value.masterTableId); + }); + const isRelation = computed(() => { + return masterTable.value?.relation != null; + }); + const formData = reactive({ + // 数据字段会根据render信息去初始化 + // 自定义字段 + customField: {}, + }); + const operationCallback = ref<(() => void) | null>(null); + + const getSystemVariableValue = (systemVariableType: number) => { + switch (systemVariableType) { + case OnlineSystemVariableType.CURRENT_USER: + return loginStore.userInfo?.showName; + case OnlineSystemVariableType.CURRENT_DEPT: + return loginStore.userInfo?.deptName; + case OnlineSystemVariableType.CURRENT_DATE: + return formatDate(new Date(), 'YYYY-MM-DD'); + case OnlineSystemVariableType.CURRENT_TIME: + return formatDate(new Date(), 'YYYY-MM-DD HH:mm:ss'); + case OnlineSystemVariableType.FLOW_CREATE_USER: + return (props.flowInfo || {}).processInstanceInitiator || loginStore.userInfo?.showName; + } + return undefined; + }; + const getWidgetValue = (widget: ANY_OBJECT) => { + if (props.isEdit && widget.bindData.dataType !== SysCustomWidgetBindDataType.SYSTEM_VARIABLE) + return; + if (widget.bindData.dataType === SysCustomWidgetBindDataType.Column && widget.column) { + // 绑定从表字段 + if (widget.relation && formData[widget.relation.variableName]) { + if (formReadOnly.value || widget.widgetType === SysCustomWidgetType.Label) { + const dictObj = + formData[widget.relation.variableName][widget.column.columnName + 'DictMap']; + if (dictObj != null && dictObj.name) return dictObj.name; + const dictArray = + formData[widget.relation.variableName][widget.column.columnName + 'DictMapList']; + if (Array.isArray(dictArray) && dictArray.length > 0) + return dictArray.map(item => item.name).join(','); + } + return formData[widget.relation.variableName][widget.column.columnName]; + } + // 绑定主表字段 + if (widget.datasource && formData[widget.datasource.variableName]) { + if (formReadOnly.value || widget.widgetType === SysCustomWidgetType.Label) { + const dictObj = + formData[widget.datasource.variableName][widget.column.columnName + 'DictMap']; + if (dictObj != null && dictObj.name) return dictObj.name; + const dictArray = + formData[widget.datasource.variableName][widget.column.columnName + 'DictMapList']; + if (Array.isArray(dictArray) && dictArray.length > 0) { + const temp = dictArray.map(item => item.name).join(','); + return temp; + } + } + return formData[widget.datasource.variableName][widget.column.columnName]; + } + } else if ( + widget.bindData.dataType === SysCustomWidgetBindDataType.Custom && + widget.bindData.formFieldName + ) { + return formData.customField[widget.bindData.formFieldName]; + } else if ( + widget.bindData.dataType === SysCustomWidgetBindDataType.SYSTEM_VARIABLE && + widget.bindData.systemVariableType != null + ) { + // 系统内置变量 + return getSystemVariableValue(widget.bindData.systemVariableType); + } + }; + const getWidgetVisible = () => { + return true; + }; + const onValueChange = (widget: ANY_OBJECT, value: ANY_OBJECT) => { + console.log('useForm.onValueChange', widget, value); + if (props.isEdit || !isReady.value) return; + if (widget.bindData.dataType === SysCustomWidgetBindDataType.Column && widget.column) { + // 绑定从表字段 + if (widget.relation) { + formData[widget.relation.variableName][widget.column.columnName] = value; + return; + } + // 绑定主表字段 + if (widget.datasource) { + formData[widget.datasource.variableName][widget.column.columnName] = value; + } + } else if ( + widget.bindData.dataType === SysCustomWidgetBindDataType.Custom && + widget.bindData.formFieldName + ) { + formData.customField[widget.bindData.formFieldName] = value; + } + console.log('useForm.onValueChange formData', formData); + }; + const onWidgetValueChange = ( + widget: ANY_OBJECT, + value: ANY_OBJECT | undefined, + detail: ANY_OBJECT | null, + ) => { + if (props.isEdit || !isReady.value) return; + const dictData = (detail || {}).dictData; + // 更新字典数据 + if (dictData != null) { + if (widget.bindData.dataType === SysCustomWidgetBindDataType.Column && widget.column) { + // 绑定从表字段 + if (widget.relation) { + if (Array.isArray(dictData)) { + formData[widget.relation.variableName][widget.column.columnName + 'DictMapList'] = + dictData; + } else { + formData[widget.relation.variableName][widget.column.columnName + 'DictMap'] = dictData; + } + return; + } + // 绑定主表字段 + if (widget.datasource) { + if (Array.isArray(dictData)) { + formData[widget.datasource.variableName][widget.column.columnName + 'DictMapList'] = + dictData; + } else { + formData[widget.datasource.variableName][widget.column.columnName + 'DictMap'] = + dictData; + } + } + } else if ( + widget.bindData.dataType === SysCustomWidgetBindDataType.Custom && + widget.bindData.formFieldName + ) { + if (Array.isArray(dictData)) { + formData.customField[widget.bindData.formFieldName + 'DictMapList'] = dictData; + } else { + formData.customField[widget.bindData.formFieldName + 'DictMap'] = dictData; + } + } + } + // 一对一关联选择组件 + if ( + widget.widgetType === SysCustomWidgetType.DataSelect && + (form.value.formType === SysOnlineFormType.FORM || + form.value.formType === SysOnlineFormType.FLOW) + ) { + const selectRow = (detail || {}).selectRow; + const relationId = (widget.props.relativeTable || {}).relationId; + const relation = form.value.relationMap.get(relationId); + if (relation != null) { + formData[relation.variableName] = selectRow || {}; + } + } + }; + const getPrimaryData = (widget: ANY_OBJECT | null) => { + let primaryKey; + if (widget && widget.table && Array.isArray(widget.table.columnList)) { + widget.table.columnList.forEach((column: ANY_OBJECT) => { + if (column.primaryKey) primaryKey = column.columnName; + }); + } + if (widget && primaryKey != null) { + if (widget.relation != null) { + return formData[widget.relation.variableName][primaryKey]; + } else if (widget.datasource != null) { + return formData[widget.datasource.variableName][primaryKey]; + } + } + return undefined; + }; + const getWidgetValueByColumn = (column: ANY_OBJECT) => { + if (column == null) return undefined; + const table = column ? form.value.tableMap.get(column.tableId) : undefined; + if (table == null || table.datasource == null) return undefined; + return table.relation == null + ? formData[table.datasource.variableName][column.columnName] + : formData[table.relation.variableName][column.columnName]; + }; + const getParamValue = (valueType: number, valueData: string) => { + switch (valueType) { + case SysOnlineParamValueType.TABLE_COLUMN: { + const column = form.value.columnMap ? form.value.columnMap.get(valueData) : null; + return column ? getWidgetValueByColumn(column) : undefined; + } + case SysOnlineParamValueType.STATIC_DICT: + return Array.isArray(valueData) ? valueData[1] : undefined; + case SysOnlineParamValueType.INPUT_VALUE: + return valueData; + } + }; + const getDropdownParams = (widget: ANY_OBJECT) => { + if (Array.isArray(widget.props.dictInfo.paramList)) { + const params: ANY_OBJECT = {}; + for (let i = 0; i < widget.props.dictInfo.paramList.length; i++) { + const dictParam = widget.props.dictInfo.paramList[i]; + if (dictParam.dictValue == null || dictParam.dictValueType == null) continue; + params[dictParam.dictParamName] = getParamValue( + dictParam.dictValueType, + dictParam.dictValue, + ); + } + + return params; + } else { + return {}; + } + }; + const getOperationPermCode = (operation: ANY_OBJECT | null) => { + let temp = 'view'; + switch (operation?.type) { + case SysCustomWidgetOperationType.ADD: + case SysCustomWidgetOperationType.EDIT: + case SysCustomWidgetOperationType.DELETE: + case SysCustomWidgetOperationType.BATCH_DELETE: + temp = 'edit'; + break; + default: + temp = 'view'; + } + if (masterTable.value && masterTable.value.datasource) { + return 'online:' + masterTable.value.datasource.variableName + ':' + temp; + } else { + return ''; + } + }; + const checkOperationPermCode = (operation: ANY_OBJECT | null) => { + if (form.value.formType !== SysOnlineFormType.QUERY || props.isEdit) return true; + return checkPermCodeExist(getOperationPermCode(operation)); + }; + const checkOperationDisabled = ( + operation: ANY_OBJECT | null, + rowData: ANY_OBJECT | null = null, + ) => { + if (props.isEdit) return false; + if (operation == null) return true; + return false; + }; + const checkOperationVisible = ( + operation: ANY_OBJECT | null, + rowData: ANY_OBJECT | null = null, + ) => { + if (props.isEdit) return true; + if (operation == null) return false; + return true; + }; + const cloneWidget = (widget: ANY_OBJECT) => { + const attribute = widgetData.getWidgetAttribute(widget.widgetType); + if (attribute == null) { + return null; + } + const temp = widgetData.getWidgetObject(attribute); + temp.showName = widget.showName; + temp.props = { + ...widget.props, + }; + return temp; + }; + const loadOnlineFormConfig = (formId: string) => { + return new Promise((resolve, reject) => { + OnlineFormController.render({ + formId: formId, + }) + .then(res => { + console.log('<<<<<>>>>', res); + const onlineForm = res.data.onlineForm; + let formConfigData = JSON.parse(onlineForm.widgetJson); + formConfigData = formConfigData.pc; + const formConfig: ANY_OBJECT = { + rawData: res.data, + formName: onlineForm.formName, + formType: onlineForm.formType, + formKind: onlineForm.formKind, + masterTableId: onlineForm.masterTableId, + labelWidth: formConfigData.labelWidth, + labelPosition: formConfigData.labelPosition, + filterItemWidth: formConfigData.filterItemWidth, + gutter: formConfigData.gutter, + height: formConfigData.height, + width: formConfigData.width, + fullscreen: formConfigData.fullscreen, + advanceQuery: formConfigData.advanceQuery, + widgetList: formConfigData.widgetList, + operationList: (formConfigData.operationList || []).sort( + (value1: ANY_OBJECT, value2: ANY_OBJECT) => { + return (value1.showOrder || 0) - (value2.showOrder || 0); + }, + ), + tableWidget: formConfigData.tableWidget, + leftWidget: formConfigData.leftWidget, + customFieldList: formConfigData.customFieldList, + formEventList: formConfigData.formEventList, + maskFieldList: formConfigData.maskFieldList, + mode: 'pc', + }; + resolve(formConfig); + }) + .catch(e => { + reject(e); + }); + }); + }; + const getCompoment = (formConfig: ANY_OBJECT, widget: ANY_OBJECT) => { + if (widget != null && widget.widgetType === SysCustomWidgetType.Table) return OnlineEditForm; + + return formConfig.formType === SysOnlineFormType.QUERY ? OnlineQueryForm : OnlineEditForm; + }; + /** + * 执行操作 + * @param {*} operation 操作 + * @param {*} options 配置项 + * @param {*} options.isEdit 是否编辑 + * @param {*} options.saveData 是否把数据保存到数据库 + * @param {*} options.widget 触发组件 + * @param {*} options.rowData 行数据 + * @param {*} options.masterTableData 主表数据 + * @param {*} options.callback 回调 + */ + const handlerOperation = (operation: ANY_OBJECT, operationParams: ANY_OBJECT) => { + const { isEdit, saveData, widget, rowData, masterTableData, callback } = operationParams; + loadOnlineFormConfig(operation.formId) + .then((formConfig: ANY_OBJECT) => { + let dlgOptions; + if (formConfig.fullscreen) { + dlgOptions = { + area: ['100vw', '100vh'], + skin: 'fullscreen-dialog', + }; + } else { + dlgOptions = { + area: [ + (formConfig.width ? formConfig.width : 600) + 'px', + (formConfig.height ? formConfig.height : 500) + 'px', + ], + }; + } + const dlgComponent = getCompoment(formConfig, widget); + if (dlgComponent == null) { + return Promise.reject(new Error('错误的操作组件!!!')); + } else { + console.log('handlerOperation component', dlgComponent); + const thirdPath = 'thirdOnlineEditForm'; + operationCallback.value = callback; + return Dialog.show( + formConfig.formName, + dlgComponent, + dlgOptions, + { + formConfig: formConfig, + rowData: rowData, + formData: formData, + masterTableData: masterTableData, + isEdit: isEdit, + isCopy: operation.type === SysCustomWidgetOperationType.COPY, + readOnly: operation.readOnly, + fullscreen: formConfig.fullscreen, + saveData: saveData, + path: thirdPath, + }, + { + fullscreen: formConfig.fullscreen, + width: dlgOptions.area[0], + height: dlgOptions.area[1], + pathName: '/thirdParty/thirdOnlineEditForm', + }, + ); + } + }) + .then(res => { + if (callback && typeof callback === 'function') { + callback(res); + } + operationCallback.value = null; + }) + .catch((e: Error) => { + console.log(e); + }); + }; + + const getTableData = (widget: ANY_OBJECT) => { + return widget.relation ? formData[widget.relation.variableName] : []; + }; + const setTableData = (widget: ANY_OBJECT, dataList: ANY_OBJECT[]) => { + console.log('setTableData', widget, dataList); + if (widget == null) return; + if (widget.relation) { + formData[widget.relation.variableName] = dataList; + } + }; + + const initPage = () => { + form.value.tableMap.forEach((table: ANY_OBJECT) => { + if (table.relation == null) { + // 主表 + const tempObj = Array.isArray(table.columnList) + ? table.columnList.reduce((retObj, column) => { + retObj[column.columnName] = undefined; + return retObj; + }, {}) + : {}; + formData[table.datasource.variableName] = tempObj; + } else { + if (table.relation.relationType === SysOnlineRelationType.ONE_TO_ONE) { + // 一对一关联从表 + const tempObj = Array.isArray(table.columnList) + ? table.columnList.reduce((retObj, column) => { + retObj[column.columnName] = undefined; + return retObj; + }, {}) + : {}; + formData[table.relation.variableName] = tempObj; + } else if (table.relation.relationType === SysOnlineRelationType.ONE_TO_MANY) { + // 一对多关联从表 + if ( + masterTable.value.relation != null && + masterTable.value.relation.relationId === table.relation.relationId + ) { + // 表单主表是当前一对多从表 + const tempObj = Array.isArray(table.columnList) + ? table.columnList.reduce((retObj, column) => { + retObj[column.columnName] = undefined; + return retObj; + }, {}) + : {}; + formData[table.relation.variableName] = tempObj; + } else { + formData[table.relation.variableName] = []; + } + } + } + }); + // 初始化自定义字段 + if (Array.isArray(form.value.customFieldList)) { + form.value.customFieldList.forEach(field => { + formData.customField[field.fieldName] = undefined; + }); + } + console.log('initPage formData', formData); + }; + + const errorMessage = ref([]); + const richEditWidgetList = reactive([]); + const dropdownWidgetList = reactive([]); + const tableWidgetList = reactive([]); + + const getWidgetProp = (widget: ANY_OBJECT) => { + if (widget.bindData.dataType === SysCustomWidgetBindDataType.Column && widget.column) { + if (widget.relation && formData[widget.relation.variableName]) { + return widget.relation.variableName + '.' + widget.column.columnName; + } else if (widget.datasource && formData[widget.datasource.variableName]) { + return widget.datasource.variableName + '.' + widget.column.columnName; + } + } else if ( + widget.bindData.dataType === SysCustomWidgetBindDataType.Custom && + widget.bindData.formFieldName + ) { + return 'customField.' + widget.bindData.formFieldName; + } + }; + const initWidget = (widget: ANY_OBJECT) => { + if (widget != null) { + if (widget.bindData.tableId) widget.table = form.value.tableMap.get(widget.bindData.tableId); + if (widget.bindData.columnId) + widget.column = form.value.columnMap.get(widget.bindData.columnId); + if (widget.bindData.dataType === SysCustomWidgetBindDataType.Custom) { + if (widget.props.dictId != null) { + widget.dictInfo = form.value.dictMap.get(widget.props.dictId); + } else { + // TODO 这里与原代码不一致,原代码走不到这一步 + widget.dictInfo = (widget.column || {}).dictInfo; + } + } + if (widget.table) { + if (widget.table.datasource) widget.datasource = widget.table.datasource; + if (widget.table.relation) widget.relation = widget.table.relation; + } + if (widget.widgetType === SysCustomWidgetType.RichEditor) { + richEditWidgetList.push(widget); + } + widget.propString = getWidgetProp(widget); + + // 初始化组件下拉字典参数 + if (widget.props.dictInfo && Array.isArray(widget.props.dictInfo.paramList)) { + widget.props.dictInfo.paramList.forEach((param: ANY_OBJECT) => { + if (param.dictValueType === SysOnlineParamValueType.STATIC_DICT) { + let errorItem = null; + if (Array.isArray(param.dictValue) && param.dictValue.length === 2) { + const dicts = StaticDict as ANY_OBJECT; + const staticDict = dicts[param.dictValue[0]]; + if (staticDict == null) { + errorItem = { + widget: widget, + message: + '组件字典参数' + + param.dictParamName + + '绑定的静态字典 [' + + param.dictValue[0] + + '] 并不存在!', + }; + } else { + if (staticDict.getValue(param.dictValue[1]) == null) { + errorItem = { + widget: widget, + message: + '组件字典参数' + + param.dictParamName + + '绑定的静态字典值并不属于静态字段 [' + + param.dictValue[0] + + '] !', + }; + } + } + } else { + errorItem = { + widget: widget, + message: '组件字典参数' + param.dictParamName + '绑定的静态字典错误!', + }; + } + if (errorItem != null) errorMessage.value.push(errorItem); + } + }); + } + if (widget.props.dictInfo && widget.props.dictInfo.dictId) { + widget.props.dictInfo.dict = form.value.dictMap.get(widget.props.dictInfo.dictId); + } + if (widget.column && widget.column.dictInfo != null) { + dropdownWidgetList.push(widget); + } + // 初始化表格列 + if (widget.widgetType === SysCustomWidgetType.Table) { + // 寻找表格主键 + widget.primaryColumnName = undefined; + if (widget.table && Array.isArray(widget.table.columnList)) { + for (let i = 0; i < widget.table.columnList.length; i++) { + if (widget.table.columnList[i].primaryKey) { + widget.primaryColumnName = widget.table.columnList[i].columnName; + break; + } + } + } + if (Array.isArray(widget.props.tableColumnList)) { + widget.props.tableColumnList.forEach((tableColumn: ANY_OBJECT) => { + tableColumn.table = form.value.tableMap.get(tableColumn.tableId); + tableColumn.column = form.value.columnMap.get(tableColumn.columnId); + tableColumn.relation = form.value.relationMap.get(tableColumn.relationId); + if (tableColumn.table == null || tableColumn.column == null) { + errorMessage.value.push({ + widget: widget, + message: '表格列 [' + tableColumn.showName + '] 绑定的字段不存在!', + }); + } + }); + } + // 操作排序 + if (Array.isArray(widget.operationList)) { + widget.operationList = (widget.operationList || []).sort((value1, value2) => { + return (value1.showOrder || 0) - (value2.showOrder || 0); + }); + } + tableWidgetList.push(widget); + } + + if (Array.isArray(widget.childWidgetList)) { + widget.childWidgetList.forEach(subWidget => { + initWidget(subWidget); + }); + } + + if (widget.props && widget.props.dictInfo) { + if (Array.isArray(widget.props.dictInfo.paramList)) { + widget.props.dictInfo.paramList.forEach((dictParam: ANY_OBJECT) => { + if (dictParam.dictValueType === SysOnlineParamValueType.TABLE_COLUMN) { + let linkageItem = form.value.linkageMap.get(dictParam.dictValue); + if (linkageItem == null) { + linkageItem = []; + form.value.linkageMap.set(dictParam.dictValue, linkageItem); + } + linkageItem.push(widget); + } + }); + } + } + } + }; + + const initFormWidgetList = () => { + if (Array.isArray(form.value.widgetList)) { + form.value.widgetList.forEach(widget => { + initWidget(widget); + }); + } + errorMessage.value = []; + if (form.value.tableWidget) initWidget(form.value.tableWidget); + if (form.value.leftWidget) initWidget(form.value.leftWidget); + if (errorMessage.value.length > 0) { + console.error(errorMessage); + } + }; + const buildRuleItem = (column: ANY_OBJECT, rule: ANY_OBJECT, trigger = 'blur') => { + if (rule.propDataJson) rule.data = JSON.parse(rule.propDataJson); + if (column != null && rule != null) { + switch (rule.onlineRule.ruleType) { + case SysOnlineRuleType.INTEGER_ONLY: + return { + type: 'integer', + message: rule.data.message, + trigger: trigger, + transform: (value: string) => Number(value), + }; + case SysOnlineRuleType.DIGITAL_ONLY: + return { + type: 'number', + message: rule.data.message, + trigger: trigger, + transform: (value: string) => Number(value), + }; + case SysOnlineRuleType.LETTER_ONLY: + return { + type: 'string', + pattern: pattern.english, + message: rule.data.message, + trigger: trigger, + }; + case SysOnlineRuleType.EMAIL: + return { + type: 'email', + message: rule.data.message, + trigger: trigger, + }; + case SysOnlineRuleType.MOBILE: + return { + type: 'string', + pattern: pattern.mobie, + message: rule.data.message, + trigger: trigger, + }; + case SysOnlineRuleType.RANGE: + if (column) { + const isNumber = ['Boolean', 'Date', 'String'].indexOf(column.objectFieldType) === -1; + return { + type: isNumber ? 'number' : 'string', + min: rule.data.min, + max: rule.data.max, + message: rule.data.message, + trigger: trigger, + }; + } + break; + case SysOnlineRuleType.CUSTOM: + return { + type: 'string', + pattern: new RegExp(rule.onlineRule.pattern), + message: rule.data.message, + trigger: trigger, + }; + } + } + }; + const buildWidgetRule = (widget: ANY_OBJECT, rules: ANY_OBJECT) => { + if (widget != null) { + let widgetRuleKey = ''; + if (widget.bindData.dataType === SysCustomWidgetBindDataType.Custom) { + // 自定义字段 + widgetRuleKey = 'customField.' + widget.bindData.formFieldName; + } else if (widget.bindData.dataType === SysCustomWidgetBindDataType.Column && widget.column) { + // 绑定字段 + widgetRuleKey = + (widget.relation ? widget.relation.variableName : widget.datasource.variableName) + + '.' + + widget.column.columnName; + } + // 必填字段以及设置了验证规则的字段 + if ( + widgetRuleKey && + (widget.props.required || (widget.column && Array.isArray(widget.column.ruleList))) + ) { + console.log('rules >>>>>>>>>>', rules, 'widgetRuleKey', widgetRuleKey); + if (rules) { + rules[widgetRuleKey] = []; + // 必填验证 + if (widget.props.required) { + rules[widgetRuleKey].push({ + required: true, + message: widget.showName + '不能为空!', + trigger: 'change', + }); + } + // 其他验证 + if (widget.column && Array.isArray(widget.column.ruleList)) { + widget.column.ruleList.forEach((rule: ANY_OBJECT) => { + const ruleItem = buildRuleItem(widget.column, rule, 'change'); + if (ruleItem) rules[widgetRuleKey].push(ruleItem); + }); + } + } + } + if (Array.isArray(widget.childWidgetList)) { + widget.childWidgetList.forEach(subWidget => { + buildWidgetRule(subWidget, rules); + }); + } + } + }; + + const rules = ref({}); + const initWidgetRule = () => { + if (!rules.value) { + rules.value = {}; + } + form.value.widgetList.forEach((widget: ANY_OBJECT) => { + buildWidgetRule(widget, rules.value); + }); + nextTick(() => { + if (formRef) formRef.value.clearValidate(); + }); + }; + + // TODO initWidgetLinkage + const initWidgetLinkage = () => { + // form.value.linkageMap.forEach((widgetList: ANY_OBJECT[], key: string) => { + // const column = form.value.columnMap.get(key); + // const table = column ? form.value.tableMap.get(column.tableId) : undefined; + // const watchKey = + // 'formData.' + + // (table.relation == null ? table.datasource.variableName : table.relation.variableName) + + // '.'; + // watchKey += column.columnName; + // watch(watchKey, newValue => { + // if (Array.isArray(widgetList)) { + // widgetList.forEach(widget => { + // resetWidget(widget); + // }); + // } + // }); + // }); + }; + + // TODO onPrint + const onPrint = (operation: ANY_OBJECT, row: ANY_OBJECT | null, fileName: string) => { + console.log('onPrint', operation, row, fileName); + if (operation == null) return; + // let printParam + // if (row != null) { + // let temp = getPrintParamItem(row, operation.printParamList) + // printParam = temp ? [temp] : [] + // } else { + // if (this.selectRows.length <= 0) { + // ElMessage.error('请选择要打印的数据!') + // return + // } + // printParam = this.selectRows + // .map((row) => { + // return this.getPrintParamItem(row, operation.printParamList) + // }) + // .filter((item) => item != null) + // } + // let params = { + // datasourceId: masterTable.value.datasource.datasourceId, + // printId: operation.printTemplateId, + // printParams: printParam, + // } + // post( + // API_CONTEXT + '/online/onlineOperation/print/' + + // masterTable.value.datasource.variableName, + // params + // ) + // .then((res) => { + // let downloadUrl = res.data + // ajax + // .fetchDownloadBlob(downloadUrl, {}, fileName, 'get') + // .then((blobData) => { + // let pdfUrl = window.URL.createObjectURL(blobData) + // window.open('./lib/pdfjs/web/viewer.html?file=' + pdfUrl) + // }) + // .catch((e) => { + // console.log(e) + // ElMessage.error(e) + // }) + // }) + // .catch((e) => {}) + }; + + const masterTablePrimaryKey = computed(() => { + if (masterTable.value == null) return null; + if (Array.isArray(masterTable.value.columnList)) { + for (let i = 0; i < masterTable.value.columnList.length; i++) { + if (masterTable.value.columnList[i].primaryKey) { + return masterTable.value.columnList[i].columnName; + } + } + } + return null; + }); + + const onStartFlow = (operation: ANY_OBJECT | null, row: ANY_OBJECT | null) => { + ElMessageBox.confirm('是否要启动流程?', '', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'info', + }) + .then(() => { + if ( + operation == null || + operation.processDefinitionKey == null || + masterTablePrimaryKey.value == null || + row == null || + row[masterTablePrimaryKey.value] == null + ) { + ElMessage.error('启动流程失败,缺少必要参数!'); + return; + } + const params = { + id: row[masterTablePrimaryKey.value], + processDefinitionKey: operation.processDefinitionKey, + }; + post('/admin/flow/flowOnlineOperation/startWithBusinessKey', params) + .then(() => { + ElMessage.success('启动成功!'); + }) + .catch(e => { + console.error(e); + }); + }) + .catch(e => { + console.warn(e); + }); + }; + + return { + rules, + isReady, + dialogParams, + form, + formData, + masterTable, + isRelation, + tableWidgetList, + richEditWidgetList, + getWidgetValue, + getWidgetProp, + getWidgetVisible, + onValueChange, + onWidgetValueChange, + getPrimaryData, + getDropdownParams, + checkOperationPermCode, + checkOperationDisabled, + checkOperationVisible, + cloneWidget, + handlerOperation, + loadOnlineFormConfig, + getTableData, + setTableData, + initPage, + initFormWidgetList, + initWidgetRule, + initWidgetLinkage, + onPrint, + onStartFlow, + }; +}; diff --git a/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/hooks/useFormExpose.ts b/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/hooks/useFormExpose.ts new file mode 100644 index 00000000..672c6e53 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/hooks/useFormExpose.ts @@ -0,0 +1,19 @@ +import { getCurrentInstance } from 'vue'; +import { ANY_OBJECT } from '@/types/generic'; +import { useLoginStore } from '@/store'; +import { post, get } from '@/common/http/request'; + +export const useFormExpose = (formData: ANY_OBJECT) => { + const loginStore = useLoginStore(); + const _this = getCurrentInstance(); + + return { + formData, + props: _this?.props, + loginStore, + axios: { + post, + get, + }, + }; +}; diff --git a/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/index.vue b/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/index.vue new file mode 100644 index 00000000..60bfb8af --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/OnlinePageRender/index.vue @@ -0,0 +1,142 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/basic/index.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/basic/index.vue new file mode 100644 index 00000000..d30bc935 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/basic/index.vue @@ -0,0 +1,128 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/dataModel/editOnlinePageDatasource.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/dataModel/editOnlinePageDatasource.vue new file mode 100644 index 00000000..e1abecad --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/dataModel/editOnlinePageDatasource.vue @@ -0,0 +1,257 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/dataModel/editOnlinePageDatasourceRelation.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/dataModel/editOnlinePageDatasourceRelation.vue new file mode 100644 index 00000000..1efb5424 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/dataModel/editOnlinePageDatasourceRelation.vue @@ -0,0 +1,492 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/dataModel/editVirtualColumnFilter.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/dataModel/editVirtualColumnFilter.vue new file mode 100644 index 00000000..e468bbe7 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/dataModel/editVirtualColumnFilter.vue @@ -0,0 +1,286 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/dataModel/indev.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/dataModel/indev.vue new file mode 100644 index 00000000..f9df5980 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/dataModel/indev.vue @@ -0,0 +1,499 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/dataModel/onlinePageTableColumnRule.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/dataModel/onlinePageTableColumnRule.vue new file mode 100644 index 00000000..77467d70 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/dataModel/onlinePageTableColumnRule.vue @@ -0,0 +1,834 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/dataModel/onlinePageVirtualColumn.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/dataModel/onlinePageVirtualColumn.vue new file mode 100644 index 00000000..b6d7cf42 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/dataModel/onlinePageVirtualColumn.vue @@ -0,0 +1,758 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/dataModel/setOnlineTableColumnRule.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/dataModel/setOnlineTableColumnRule.vue new file mode 100644 index 00000000..4672d40b --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/dataModel/setOnlineTableColumnRule.vue @@ -0,0 +1,378 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/editOnlineForm.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/editOnlineForm.vue new file mode 100644 index 00000000..638aa238 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/editOnlineForm.vue @@ -0,0 +1,280 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/editOnlinePageDatasource.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/editOnlinePageDatasource.vue new file mode 100644 index 00000000..b61ff2a1 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/editOnlinePageDatasource.vue @@ -0,0 +1,253 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/editOnlinePageDatasourceRelation.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/editOnlinePageDatasourceRelation.vue new file mode 100644 index 00000000..e7cbcc95 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/editOnlinePageDatasourceRelation.vue @@ -0,0 +1,478 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/editVirtualColumnFilter.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/editVirtualColumnFilter.vue new file mode 100644 index 00000000..e30820d0 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/editVirtualColumnFilter.vue @@ -0,0 +1,277 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomFormOperateSetting.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomFormOperateSetting.vue new file mode 100644 index 00000000..806fa287 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomFormOperateSetting.vue @@ -0,0 +1,186 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomFormSetting.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomFormSetting.vue new file mode 100644 index 00000000..564b1cd3 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomFormSetting.vue @@ -0,0 +1,303 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomTableContainerSetting.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomTableContainerSetting.vue new file mode 100644 index 00000000..5309fc0d --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomTableContainerSetting.vue @@ -0,0 +1,187 @@ + + + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomWidgetAttributeSetting.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomWidgetAttributeSetting.vue new file mode 100644 index 00000000..8b7827b1 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomWidgetAttributeSetting.vue @@ -0,0 +1,116 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomWidgetBindData.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomWidgetBindData.vue new file mode 100644 index 00000000..b0342969 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomWidgetBindData.vue @@ -0,0 +1,346 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomWidgetDictSetting/EditDictParamValue.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomWidgetDictSetting/EditDictParamValue.vue new file mode 100644 index 00000000..35c16ef7 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomWidgetDictSetting/EditDictParamValue.vue @@ -0,0 +1,182 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomWidgetDictSetting/index.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomWidgetDictSetting/index.vue new file mode 100644 index 00000000..1f1783b7 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomWidgetDictSetting/index.vue @@ -0,0 +1,202 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomWidgetRelativeTableSetting/index.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomWidgetRelativeTableSetting/index.vue new file mode 100644 index 00000000..64123e2d --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/CustomWidgetRelativeTableSetting/index.vue @@ -0,0 +1,156 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/EditCustomFormOperate.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/EditCustomFormOperate.vue new file mode 100644 index 00000000..ff561524 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/EditCustomFormOperate.vue @@ -0,0 +1,485 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/EditFormField.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/EditFormField.vue new file mode 100644 index 00000000..baccde46 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/EditFormField.vue @@ -0,0 +1,97 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/EditWidgetAttribute.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/EditWidgetAttribute.vue new file mode 100644 index 00000000..f4d2f9c2 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/EditWidgetAttribute.vue @@ -0,0 +1,219 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/OnlineTabPanelSetting/editOnlineTabPanel.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/OnlineTabPanelSetting/editOnlineTabPanel.vue new file mode 100644 index 00000000..481a1e09 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/OnlineTabPanelSetting/editOnlineTabPanel.vue @@ -0,0 +1,117 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/OnlineTabPanelSetting/index.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/OnlineTabPanelSetting/index.vue new file mode 100644 index 00000000..41e7aa03 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/OnlineTabPanelSetting/index.vue @@ -0,0 +1,104 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/OnlineTableColumnSetting/editOnlineTableColumn.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/OnlineTableColumnSetting/editOnlineTableColumn.vue new file mode 100644 index 00000000..2b1d3713 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/OnlineTableColumnSetting/editOnlineTableColumn.vue @@ -0,0 +1,233 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/OnlineTableColumnSetting/index.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/OnlineTableColumnSetting/index.vue new file mode 100644 index 00000000..1e05decb --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/components/OnlineTableColumnSetting/index.vue @@ -0,0 +1,109 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/editTableColumn.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/editTableColumn.vue new file mode 100644 index 00000000..c3abb225 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/editTableColumn.vue @@ -0,0 +1,225 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/index.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/index.vue new file mode 100644 index 00000000..7763de2c --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/formDesign/index.vue @@ -0,0 +1,1352 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/index.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/index.vue new file mode 100644 index 00000000..ed3f29ee --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/index.vue @@ -0,0 +1,752 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/setOnlineTableColumnRule.vue b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/setOnlineTableColumnRule.vue new file mode 100644 index 00000000..e2d000dd --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/editOnlinePage/setOnlineTableColumnRule.vue @@ -0,0 +1,375 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/formOnlineDblink/EditOnlineDblink.vue b/OrangeFormsOpen-VUE3/src/pages/online/formOnlineDblink/EditOnlineDblink.vue new file mode 100644 index 00000000..089cf3fd --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/formOnlineDblink/EditOnlineDblink.vue @@ -0,0 +1,424 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/formOnlineDblink/index.vue b/OrangeFormsOpen-VUE3/src/pages/online/formOnlineDblink/index.vue new file mode 100644 index 00000000..cef70a0a --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/formOnlineDblink/index.vue @@ -0,0 +1,209 @@ + + + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/formOnlineDict/EditDictDataButton.vue b/OrangeFormsOpen-VUE3/src/pages/online/formOnlineDict/EditDictDataButton.vue new file mode 100644 index 00000000..a3ac0d74 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/formOnlineDict/EditDictDataButton.vue @@ -0,0 +1,96 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/formOnlineDict/EditOnlineDict.vue b/OrangeFormsOpen-VUE3/src/pages/online/formOnlineDict/EditOnlineDict.vue new file mode 100644 index 00000000..2397d14e --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/formOnlineDict/EditOnlineDict.vue @@ -0,0 +1,845 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/formOnlineDict/index.vue b/OrangeFormsOpen-VUE3/src/pages/online/formOnlineDict/index.vue new file mode 100644 index 00000000..e828680d --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/formOnlineDict/index.vue @@ -0,0 +1,306 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/formOnlinePage/index.vue b/OrangeFormsOpen-VUE3/src/pages/online/formOnlinePage/index.vue new file mode 100644 index 00000000..838569a4 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/formOnlinePage/index.vue @@ -0,0 +1,312 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/online/hooks/useDict.ts b/OrangeFormsOpen-VUE3/src/pages/online/hooks/useDict.ts new file mode 100644 index 00000000..e5171a5a --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/hooks/useDict.ts @@ -0,0 +1,127 @@ +import combinedDict from '@/common/staticDict/combined'; +import { SysCustomWidgetOperationType } from '@/common/staticDict'; +import { SysOnlineDictType } from '@/common/staticDict/online'; +import { OnlineOperationController } from '@/api/online'; +import { ANY_OBJECT } from '@/types/generic'; +import { post, get } from '@/common/http/request'; + +const StaticDict = { ...combinedDict }; + +export const useDict = () => { + function getTableDictData(dictId: string, dictParams: ANY_OBJECT) { + return new Promise((resolve, reject) => { + const filterDtoList = dictParams + ? Object.keys(dictParams).map(key => { + return { + columnName: key, + columnValue: dictParams[key], + }; + }) + : []; + const params = { + dictId: dictId, + filterDtoList: filterDtoList, + }; + OnlineOperationController.listDict(params) + .then(res => { + resolve(res.data); + }) + .catch(e => { + reject(e); + }); + }); + } + + function getDictDataByUrl( + url: string, + params: ANY_OBJECT, + dictInfo: ANY_OBJECT, + methods = 'get', + ) { + const request = methods == 'get' ? get : post; + return new Promise((resolve, reject) => { + request(url, params) + .then(res => { + if (Array.isArray(res.data)) { + resolve( + res.data.map(item => { + return { + id: item[dictInfo.keyColumnName], + name: item[dictInfo.valueColumnName], + parentId: item[dictInfo.parentKeyColumnName], + }; + }), + ); + } else { + reject(); + } + }) + .catch(e => { + reject(e); + }); + }); + } + + function getUrlDictData(dictInfo: ANY_OBJECT, dictParams: ANY_OBJECT) { + const url = dictInfo.dictListUrl; + if (url != null && url !== '') { + return getDictDataByUrl(url, dictParams, dictInfo, 'get'); + } else { + console.error('字典 [' + dictInfo.dictName + '] url为空'); + return Promise.reject(); + } + } + + /** + * 获取字典数据 + * @param {*} dictInfo 字典配置对象 + * @param {*} params 获取字典时传入的参数,仅对于数据表字典和URL字典有效 + * @returns 字典数据 + */ + function getDictDataList(dictInfo: ANY_OBJECT, dictParams: ANY_OBJECT): Promise { + const dicts = StaticDict as ANY_OBJECT; + const dictData = JSON.parse(dictInfo.dictDataJson); + switch (dictInfo.dictType) { + case SysOnlineDictType.TABLE: + case SysOnlineDictType.CODE: + return getTableDictData(dictInfo.dictId, dictParams); + case SysOnlineDictType.URL: + return getUrlDictData(dictInfo, dictParams || {}); + case SysOnlineDictType.CUSTOM: + if (dictData != null && Array.isArray(dictData.dictData)) { + return Promise.resolve(dictData.dictData); + } else { + return Promise.reject(new Error('获取自定义字典数据错误!')); + } + case SysOnlineDictType.STATIC: + if ( + dictData != null && + dictData.staticDictName != null && + dicts[dictData.staticDictName] != null + ) { + return Promise.resolve(dicts[dictData.staticDictName].getList()); + } else { + return Promise.reject(new Error('未知的静态字典!')); + } + default: + return Promise.reject(new Error('未知的字典类型!')); + } + } + + function getOperationPermCode(widget: ANY_OBJECT, operation: ANY_OBJECT) { + const datasourceVariableName = (widget.datasource || {}).variableName; + let temp = 'view'; + switch (operation.type) { + case SysCustomWidgetOperationType.ADD: + case SysCustomWidgetOperationType.EDIT: + case SysCustomWidgetOperationType.DELETE: + temp = 'edit'; + break; + default: + temp = 'view'; + } + return 'online:' + datasourceVariableName + ':' + temp; + } + + return { getDictDataList, getDictDataByUrl, getOperationPermCode }; +}; diff --git a/OrangeFormsOpen-VUE3/src/pages/online/hooks/useFormConfig.ts b/OrangeFormsOpen-VUE3/src/pages/online/hooks/useFormConfig.ts new file mode 100644 index 00000000..e0821346 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/hooks/useFormConfig.ts @@ -0,0 +1,343 @@ +import { + OnlineFormEventType, + SysCustomWidgetOperationType, + SysOnlineFormType, +} from '@/common/staticDict'; +import { SysOnlinePageType } from '@/common/staticDict/online'; +import { ANY_OBJECT } from '@/types/generic'; +import { findItemFromList } from '@/common/utils'; +import widgetData from '@/online/config/index'; +import tableConfig from '@/online/config/table'; +import treeConfig from '@/online/config/tree'; +import workOrderListConfig from '@/online/config/workOrderList'; + +export const useFormConfig = () => { + const baseQueryForm = { + filterItemWidth: 350, + gutter: 20, + labelWidth: 100, + labelPosition: 'right', + tableWidget: { + ...widgetData.getWidgetObject(tableConfig), + }, + leftWidget: { + ...widgetData.getWidgetObject(treeConfig), + }, + operationList: [ + { + id: 0, + type: SysCustomWidgetOperationType.EXPORT, + name: SysCustomWidgetOperationType.getValue(SysCustomWidgetOperationType.EXPORT), + enabled: false, + builtin: true, + rowOperation: false, + btnType: 'primary', + plain: true, + formId: undefined, + paramList: [], + eventList: [], + readOnly: false, + showOrder: 0, + }, + { + id: 1, + type: SysCustomWidgetOperationType.BATCH_DELETE, + name: SysCustomWidgetOperationType.getValue(SysCustomWidgetOperationType.BATCH_DELETE), + enabled: false, + builtin: true, + rowOperation: false, + btnType: 'danger', + plain: true, + formId: undefined, + eventList: [], + readOnly: false, + showOrder: 1, + }, + { + id: 2, + type: SysCustomWidgetOperationType.ADD, + name: SysCustomWidgetOperationType.getValue(SysCustomWidgetOperationType.ADD), + enabled: false, + builtin: true, + rowOperation: false, + btnType: 'primary', + plain: false, + formId: undefined, + eventList: [], + readOnly: false, + showOrder: 2, + }, + { + id: 3, + type: SysCustomWidgetOperationType.EDIT, + name: SysCustomWidgetOperationType.getValue(SysCustomWidgetOperationType.EDIT), + enabled: false, + builtin: true, + rowOperation: true, + btnClass: 'table-btn success', + formId: undefined, + eventList: [], + readOnly: false, + showOrder: 10, + }, + { + id: 4, + type: SysCustomWidgetOperationType.DELETE, + name: SysCustomWidgetOperationType.getValue(SysCustomWidgetOperationType.DELETE), + enabled: false, + builtin: true, + rowOperation: true, + btnClass: 'table-btn delete', + formId: undefined, + eventList: [], + readOnly: false, + showOrder: 15, + }, + ], + customFieldList: [], + widgetList: [], + formEventList: [], + maskFieldList: [], + allowEventList: [OnlineFormEventType.AFTER_CREATE_FORM], + fullscreen: true, + advanceQuery: false, + supportOperation: true, + width: 800, + }; + + const baseEditForm = { + gutter: 20, + labelWidth: 100, + labelPosition: 'right', + operationList: [], + customFieldList: [], + widgetList: [], + formEventList: [], + maskFieldList: [], + allowEventList: [ + OnlineFormEventType.AFTER_CREATE_FORM, + OnlineFormEventType.AFTER_LOAD_FORM_DATA, + OnlineFormEventType.BEFORE_COMMIT_FORM_DATA, + ], + fullscreen: false, + supportOperation: true, + width: 800, + }; + + const baseFlowForm = { + gutter: 20, + labelWidth: 100, + labelPosition: 'right', + customFieldList: [], + widgetList: [], + formEventList: [], + maskFieldList: [], + allowEventList: [ + OnlineFormEventType.AFTER_CREATE_FORM, + OnlineFormEventType.AFTER_LOAD_FORM_DATA, + OnlineFormEventType.BEFORE_COMMIT_FORM_DATA, + ], + fullscreen: true, + supportOperation: false, + width: 800, + }; + + const baseWorkflowForm = { + gutter: 20, + labelWidth: 100, + labelPosition: 'right', + tableWidget: { + ...widgetData.getWidgetObject(tableConfig), + }, + operationList: [], + customFieldList: [], + widgetList: [], + formEventList: [], + maskFieldList: [], + allowEventList: [OnlineFormEventType.AFTER_CREATE_FORM], + fullscreen: true, + supportOperation: true, + width: 800, + }; + + const getFormConfig = (formType: number, pageType: number | undefined) => { + switch (formType) { + case SysOnlineFormType.QUERY: + case SysOnlineFormType.ADVANCE_QUERY: + case SysOnlineFormType.ONE_TO_ONE_QUERY: + return JSON.parse( + JSON.stringify({ + pc: { + ...baseQueryForm, + advanceQuery: formType === SysOnlineFormType.ADVANCE_QUERY, + supportOperation: formType !== SysOnlineFormType.ONE_TO_ONE_QUERY, + }, + }), + ); + case SysOnlineFormType.FORM: + return JSON.parse( + JSON.stringify({ + pc: { + ...baseEditForm, + supportOperation: pageType === SysOnlinePageType.BIZ, + }, + }), + ); + case SysOnlineFormType.FLOW: + return JSON.parse( + JSON.stringify({ + pc: baseFlowForm, + }), + ); + case SysOnlineFormType.WORK_ORDER: + return JSON.parse( + JSON.stringify({ + pc: baseWorkflowForm, + }), + ); + default: + return null; + } + }; + + /** + * 合并数组,如果目标数组里的数据在原数组不存在,则加入到原数组,否则使用原数组数据 + */ + const mergeArray = (source: ANY_OBJECT[], target: ANY_OBJECT[], keyName: string) => { + const tempList: ANY_OBJECT[] = []; + if (Array.isArray(target)) { + target.forEach(item => { + const temp = findItemFromList(source, item[keyName], keyName); + tempList.push({ + ...item, + ...temp, + }); + }); + } + if (Array.isArray(source)) { + source.forEach(item => { + const temp = findItemFromList(tempList, item[keyName], keyName); + if (temp == null) { + tempList.push(item); + } + }); + } + return tempList; + }; + /** + * 合并组件操作和属性 + */ + const mergeWidget = (widget: ANY_OBJECT) => { + if (widget == null) return; + const widgetConfig: ANY_OBJECT | null = widgetData.getWidgetAttribute(widget.widgetType); + if (widgetConfig != null) { + // 合并组件操作 + widget.supportOperation = widgetConfig.supportOperation; + if (widget.supportOperation) { + widget.operationList = mergeArray(widget.operationList, widgetConfig.operationList, 'id'); + } + // 合并组件属性 + widget.props = { + ...widgetConfig.props, + ...widget.props, + }; + } + }; + + const buildFormConfig = (formData: ANY_OBJECT) => { + if (formData == null) return; + const formConfig = formData; + formConfig.datasourceMap = new Map(); + formConfig.relationMap = new Map(); + formConfig.tableMap = new Map(); + formConfig.columnMap = new Map(); + formConfig.dictMap = new Map(); + formConfig.linkageMap = new Map(); + const rawData = formData.rawData; + if (rawData == null) return formConfig; + // 字典 + if (Array.isArray(rawData.onlineDictList)) { + rawData.onlineDictList.forEach((dict: ANY_OBJECT) => { + formConfig.dictMap.set(dict.dictId, dict); + }); + } + rawData.onlineDictList = null; + // 数据表 + if (Array.isArray(rawData.onlineTableList)) { + rawData.onlineTableList.forEach((table: ANY_OBJECT) => { + formConfig.tableMap.set(table.tableId, table); + }); + } + rawData.onlineTableList = null; + // 字段 + if (Array.isArray(rawData.onlineColumnList)) { + rawData.onlineColumnList.forEach((column: ANY_OBJECT) => { + if (column.dictId != null) { + column.dictInfo = formConfig.dictMap.get(column.dictId); + } + const table = formConfig.tableMap.get(column.tableId); + if (table) { + if (!Array.isArray(table.columnList)) table.columnList = []; + table.columnList.push(column); + } + formConfig.columnMap.set(column.columnId, column); + }); + } + rawData.onlineColumnList = null; + // 虚拟字段 + if (Array.isArray(rawData.onlineVirtualColumnList)) { + rawData.onlineVirtualColumnList.forEach((column: ANY_OBJECT) => { + column.columnId = column.virtualColumnId; + column.columnComment = column.columnPrompt; + column.columnName = column.objectFieldName; + column.primaryKey = false; + column.isVirtualColumn = true; + formConfig.columnMap.set(column.columnId, column); + }); + } + rawData.onlineVirtualColumnList = null; + // 数据源 + if (Array.isArray(rawData.onlineDatasourceList)) { + rawData.onlineDatasourceList.forEach((datasource: ANY_OBJECT) => { + datasource.masterTable = formConfig.tableMap.get(datasource.masterTableId); + if (datasource.masterTable) datasource.masterTable.datasource = datasource; + formConfig.datasourceMap.set(datasource.datasourceId, datasource); + }); + } + rawData.onlineDatasourceList = null; + // 关联 + if (Array.isArray(rawData.onlineDatasourceRelationList)) { + rawData.onlineDatasourceRelationList.forEach((relation: ANY_OBJECT) => { + const datasource = formConfig.datasourceMap.get(relation.datasourceId); + if (datasource) { + if (!Array.isArray(datasource.relationList)) datasource.relationList = []; + datasource.relationList.push(relation); + } + relation.masterColumn = formConfig.columnMap.get(relation.masterColumnId); + relation.slaveTable = formConfig.tableMap.get(relation.slaveTableId); + if (relation.slaveTable) { + relation.slaveTable.relation = relation; + relation.slaveTable.datasource = datasource; + } + relation.slaveColumn = formConfig.columnMap.get(relation.slaveColumnId); + formConfig.relationMap.set(relation.relationId, relation); + }); + } + rawData.onlineDatasourceRelationList = null; + // 校验规则 + if (Array.isArray(rawData.onlineColumnRuleList)) { + rawData.onlineColumnRuleList.forEach((rule: ANY_OBJECT) => { + const column = formConfig.columnMap.get(rule.columnId); + if (column) { + if (!Array.isArray(column.ruleList)) column.ruleList = []; + column.ruleList.push(rule); + } + }); + } + rawData.onlineColumnRuleList = null; + + return formConfig; + }; + + return { getFormConfig, mergeWidget, mergeArray, buildFormConfig }; +}; diff --git a/OrangeFormsOpen-VUE3/src/pages/online/hooks/useWidgetToolkit.ts b/OrangeFormsOpen-VUE3/src/pages/online/hooks/useWidgetToolkit.ts new file mode 100644 index 00000000..401c8e9b --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/online/hooks/useWidgetToolkit.ts @@ -0,0 +1,152 @@ +import { SysCustomWidgetType, SysOnlineFormType } from '@/common/staticDict'; +import { SysOnlineFieldKind } from '@/common/staticDict/online'; +import { ANY_OBJECT } from '@/types/generic'; + +export const useWidgetToolkit = () => { + function getColumnDataType(column: ANY_OBJECT) { + switch (column.objectFieldType) { + case 'String': + return 'String'; + case 'Date': + return 'Date'; + case 'Boolean': + return 'Boolean'; + case 'Integer': + case 'Long': + case 'Float': + case 'Double': + case 'BigDecimal': + return 'Number'; + default: + return undefined; + } + } + + /** + * 字段是否可以使用组件显示 + * @param {*} column 要显示的字段 + * @param {*} widgetType 使用的组件 + * @param {*} formType 表单类型 + * @return { disabled, warningMsg } 是否可以显示和提示文字 + */ + function columnIsValidByWidgetType( + column: ANY_OBJECT | null, + widgetType: number, + formType: number, + ) { + console.log(column, widgetType, formType); + if (column == null) { + return { + disabled: true, + warningMsg: '错误的字段数据', + }; + } + const columnFieldType = getColumnDataType(column); + let disabled = false; + let warningMsg = null; + if (column.fieldKind === SysOnlineFieldKind.UPLOAD) { + disabled = widgetType !== SysCustomWidgetType.Upload; + warningMsg = SysOnlineFieldKind.getValue(column.fieldKind); + } else if (column.fieldKind === SysOnlineFieldKind.UPLOAD_IMAGE) { + disabled = + widgetType !== SysCustomWidgetType.Upload && widgetType !== SysCustomWidgetType.Image; + warningMsg = SysOnlineFieldKind.getValue(column.fieldKind); + } else if (column.fieldKind === SysOnlineFieldKind.RICH_TEXT) { + disabled = + widgetType !== SysCustomWidgetType.RichEditor && widgetType !== SysCustomWidgetType.Label; + warningMsg = SysOnlineFieldKind.getValue(column.fieldKind); + } else if ( + column.fieldKind === SysOnlineFieldKind.CREATE_TIME || + column.fieldKind === SysOnlineFieldKind.CREATE_USER_ID || + column.fieldKind === SysOnlineFieldKind.UPDATE_TIME || + column.fieldKind === SysOnlineFieldKind.UPDATE_USER_ID || + column.fieldKind === SysOnlineFieldKind.LOGIC_DELETE + ) { + disabled = + widgetType !== SysCustomWidgetType.Label && + widgetType !== SysCustomWidgetType.Text && + [ + SysOnlineFormType.QUERY, + SysOnlineFormType.ADVANCE_QUERY, + SysOnlineFormType.ONE_TO_ONE_QUERY, + ].indexOf(formType) === -1; + warningMsg = SysOnlineFieldKind.getValue(column.fieldKind); + } else { + switch (widgetType) { + case SysCustomWidgetType.Label: + case SysCustomWidgetType.MobileInputFilter: + disabled = false; + break; + case SysCustomWidgetType.Text: + disabled = column.fieldKind === SysOnlineFieldKind.UPLOAD_IMAGE; + break; + case SysCustomWidgetType.Image: + disabled = column.fieldKind !== SysOnlineFieldKind.UPLOAD_IMAGE; + break; + case SysCustomWidgetType.Input: + disabled = columnFieldType !== 'String' && columnFieldType !== 'Number'; + break; + case SysCustomWidgetType.NumberInput: + case SysCustomWidgetType.NumberRange: + case SysCustomWidgetType.MobileNumberRangeFilter: + disabled = columnFieldType !== 'Number'; + break; + case SysCustomWidgetType.Switch: + case SysCustomWidgetType.MobileSwitchFilter: + disabled = columnFieldType !== 'Boolean'; + break; + case SysCustomWidgetType.Slider: + case SysCustomWidgetType.Stepper: + case SysCustomWidgetType.Rate: + disabled = columnFieldType !== 'Number'; + break; + case SysCustomWidgetType.Radio: + case SysCustomWidgetType.Select: + case SysCustomWidgetType.Cascader: + case SysCustomWidgetType.CheckBox: + case SysCustomWidgetType.Tree: + case SysCustomWidgetType.MobileRadioFilter: + case SysCustomWidgetType.MobileCheckBoxFilter: + disabled = + (columnFieldType !== 'String' && columnFieldType !== 'Number') || column.dictId == null; + if (column.dictId == null) warningMsg = '未绑定字典'; + break; + case SysCustomWidgetType.Date: + case SysCustomWidgetType.DateRange: + case SysCustomWidgetType.Calendar: + case SysCustomWidgetType.MobileDateRangeFilter: + disabled = columnFieldType !== 'Date'; + break; + case SysCustomWidgetType.Upload: + disabled = column.fieldKind !== SysOnlineFieldKind.UPLOAD; + break; + case SysCustomWidgetType.RichEditor: + disabled = column.fieldKind !== SysOnlineFieldKind.RICH_TEXT; + break; + case SysCustomWidgetType.UserSelect: + case SysCustomWidgetType.DeptSelect: + disabled = columnFieldType !== 'String' && columnFieldType !== 'Number'; + break; + case SysCustomWidgetType.DataSelect: + disabled = !column.oneToOnyRelationColumn; + break; + default: + disabled = true; + break; + } + } + + if (disabled && warningMsg == null) { + warningMsg = + widgetType === SysCustomWidgetType.DataSelect ? '不是一对一关联字段' : '字段类型不匹配'; + } + + return { + disabled, + warningMsg, + }; + } + return { + columnIsValidByWidgetType, + }; +}; diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formEditDictData/index.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formEditDictData/index.vue new file mode 100644 index 00000000..74e2edb4 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formEditDictData/index.vue @@ -0,0 +1,160 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formEditGlobalDict/index.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formEditGlobalDict/index.vue new file mode 100644 index 00000000..f4f21ff4 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formEditGlobalDict/index.vue @@ -0,0 +1,92 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysDataPerm/index.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysDataPerm/index.vue new file mode 100644 index 00000000..48eb6909 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysDataPerm/index.vue @@ -0,0 +1,339 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysDept/index.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysDept/index.vue new file mode 100644 index 00000000..6fb2bec3 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysDept/index.vue @@ -0,0 +1,262 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysMenu/editColumn.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysMenu/editColumn.vue new file mode 100644 index 00000000..dbc5ac53 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysMenu/editColumn.vue @@ -0,0 +1,124 @@ + + + +@/types/upms/menu diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysMenu/index.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysMenu/index.vue new file mode 100644 index 00000000..fdaf9200 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysMenu/index.vue @@ -0,0 +1,562 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysPerm/index.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysPerm/index.vue new file mode 100644 index 00000000..385608de --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysPerm/index.vue @@ -0,0 +1,195 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysPermCode/index.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysPermCode/index.vue new file mode 100644 index 00000000..bf309bbd --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysPermCode/index.vue @@ -0,0 +1,292 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysPermModule/index.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysPermModule/index.vue new file mode 100644 index 00000000..9f67dfaa --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysPermModule/index.vue @@ -0,0 +1,271 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysPost/index.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysPost/index.vue new file mode 100644 index 00000000..b0397de5 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysPost/index.vue @@ -0,0 +1,153 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysRole/index.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysRole/index.vue new file mode 100644 index 00000000..0de33859 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysRole/index.vue @@ -0,0 +1,217 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysUser/index.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysUser/index.vue new file mode 100644 index 00000000..0c65f1ca --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formEditSysUser/index.vue @@ -0,0 +1,358 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysDataPerm/TabContentDataPerm.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysDataPerm/TabContentDataPerm.vue new file mode 100644 index 00000000..b28c8c41 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysDataPerm/TabContentDataPerm.vue @@ -0,0 +1,322 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysDataPerm/TabContentDataPermUser.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysDataPerm/TabContentDataPermUser.vue new file mode 100644 index 00000000..49cb33b5 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysDataPerm/TabContentDataPermUser.vue @@ -0,0 +1,305 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysDataPerm/formSetSysDataPermUser.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysDataPerm/formSetSysDataPermUser.vue new file mode 100644 index 00000000..21758064 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysDataPerm/formSetSysDataPermUser.vue @@ -0,0 +1,252 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysDataPerm/index.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysDataPerm/index.vue new file mode 100644 index 00000000..00434083 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysDataPerm/index.vue @@ -0,0 +1,129 @@ + + + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysDept/index.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysDept/index.vue new file mode 100644 index 00000000..552b17af --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysDept/index.vue @@ -0,0 +1,268 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysDeptPost/formSetDeptPost.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysDeptPost/formSetDeptPost.vue new file mode 100644 index 00000000..5cedbfec --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysDeptPost/formSetDeptPost.vue @@ -0,0 +1,257 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysDeptPost/index.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysDeptPost/index.vue new file mode 100644 index 00000000..48e49831 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysDeptPost/index.vue @@ -0,0 +1,332 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysDict/index.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysDict/index.vue new file mode 100644 index 00000000..c4b551dc --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysDict/index.vue @@ -0,0 +1,646 @@ + + + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysLoginUser/index.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysLoginUser/index.vue new file mode 100644 index 00000000..b4e119a8 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysLoginUser/index.vue @@ -0,0 +1,183 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysMenu/formSysColumnMenu.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysMenu/formSysColumnMenu.vue new file mode 100644 index 00000000..b76d2ddb --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysMenu/formSysColumnMenu.vue @@ -0,0 +1,407 @@ + + + + + + + +@/types/upms/menu diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysMenu/hooks.ts b/OrangeFormsOpen-VUE3/src/pages/upms/formSysMenu/hooks.ts new file mode 100644 index 00000000..6e47535c --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysMenu/hooks.ts @@ -0,0 +1,26 @@ +import { EpPropMergeType } from 'element-plus/es/utils/vue/props'; +import { MenuItem } from '@/types/upms/menu'; +import { SysMenuType } from '@/common/staticDict'; + +export const useMenuTools = () => { + const getMenuType = ( + row: MenuItem, + ): EpPropMergeType< + StringConstructor, + 'primary' | 'success' | 'info' | 'warning' | 'danger', + unknown + > => { + if (row.menuType === SysMenuType.DIRECTORY) { + return 'primary'; + } else if (row.menuType === SysMenuType.MENU) { + return 'info'; + } else if (row.menuType === SysMenuType.FRAGMENT) { + return 'danger'; + } else if (row.menuType === SysMenuType.BUTTON) { + return 'warning'; + } + return 'primary'; + }; + + return { getMenuType }; +}; diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysMenu/index.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysMenu/index.vue new file mode 100644 index 00000000..e5067c16 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysMenu/index.vue @@ -0,0 +1,265 @@ + + + + + +@/types/upms/menu diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysOperationLog/SysOperationLogDetail.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysOperationLog/SysOperationLogDetail.vue new file mode 100644 index 00000000..7d73c91c --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysOperationLog/SysOperationLogDetail.vue @@ -0,0 +1,219 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysOperationLog/index.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysOperationLog/index.vue new file mode 100644 index 00000000..84d37ab1 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysOperationLog/index.vue @@ -0,0 +1,324 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysPerm/PermGroupList.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysPerm/PermGroupList.vue new file mode 100644 index 00000000..2043dedd --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysPerm/PermGroupList.vue @@ -0,0 +1,241 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysPerm/PermList.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysPerm/PermList.vue new file mode 100644 index 00000000..441f27a5 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysPerm/PermList.vue @@ -0,0 +1,296 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysPerm/SysPermDetail.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysPerm/SysPermDetail.vue new file mode 100644 index 00000000..71b49807 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysPerm/SysPermDetail.vue @@ -0,0 +1,452 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysPerm/index.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysPerm/index.vue new file mode 100644 index 00000000..eeed94c2 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysPerm/index.vue @@ -0,0 +1,125 @@ + + + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysPermCode/formSysPermCodeDetail.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysPermCode/formSysPermCodeDetail.vue new file mode 100644 index 00000000..f82e765c --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysPermCode/formSysPermCodeDetail.vue @@ -0,0 +1,344 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysPermCode/index.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysPermCode/index.vue new file mode 100644 index 00000000..90e31ed4 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysPermCode/index.vue @@ -0,0 +1,450 @@ + + + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysPost/index.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysPost/index.vue new file mode 100644 index 00000000..85fe5edf --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysPost/index.vue @@ -0,0 +1,278 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysRole/TabContentRole.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysRole/TabContentRole.vue new file mode 100644 index 00000000..4bb56692 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysRole/TabContentRole.vue @@ -0,0 +1,276 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysRole/TabContentUser.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysRole/TabContentUser.vue new file mode 100644 index 00000000..197db722 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysRole/TabContentUser.vue @@ -0,0 +1,311 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysRole/formSetRoleUser.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysRole/formSetRoleUser.vue new file mode 100644 index 00000000..c0306a83 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysRole/formSetRoleUser.vue @@ -0,0 +1,252 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysRole/index.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysRole/index.vue new file mode 100644 index 00000000..f6ff0aec --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysRole/index.vue @@ -0,0 +1,130 @@ + + + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/upms/formSysUser/index.vue b/OrangeFormsOpen-VUE3/src/pages/upms/formSysUser/index.vue new file mode 100644 index 00000000..093014bf --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/upms/formSysUser/index.vue @@ -0,0 +1,389 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/welcome/index.vue b/OrangeFormsOpen-VUE3/src/pages/welcome/index.vue new file mode 100644 index 00000000..fe4ddfbe --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/welcome/index.vue @@ -0,0 +1,552 @@ + + + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/welcome/index_bak.vue b/OrangeFormsOpen-VUE3/src/pages/welcome/index_bak.vue new file mode 100644 index 00000000..aa10ccfb --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/welcome/index_bak.vue @@ -0,0 +1,208 @@ + + + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/components/CopyForSelect/addCopyForItem.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/components/CopyForSelect/addCopyForItem.vue new file mode 100644 index 00000000..94a91df8 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/components/CopyForSelect/addCopyForItem.vue @@ -0,0 +1,352 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/components/CopyForSelect/copyForSetting.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/components/CopyForSelect/copyForSetting.vue new file mode 100644 index 00000000..78968d20 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/components/CopyForSelect/copyForSetting.vue @@ -0,0 +1,435 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/components/CopyForSelect/index.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/components/CopyForSelect/index.vue new file mode 100644 index 00000000..9bfbb985 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/components/CopyForSelect/index.vue @@ -0,0 +1,438 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/components/HandlerFlowTask.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/components/HandlerFlowTask.vue new file mode 100644 index 00000000..44cacce6 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/components/HandlerFlowTask.vue @@ -0,0 +1,635 @@ + + + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/components/ProcessDesigner.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/components/ProcessDesigner.vue new file mode 100644 index 00000000..f8f9811a --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/components/ProcessDesigner.vue @@ -0,0 +1,277 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/components/ProcessViewer.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/components/ProcessViewer.vue new file mode 100644 index 00000000..cfb42186 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/components/ProcessViewer.vue @@ -0,0 +1,634 @@ + + + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/components/TagSelect.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/components/TagSelect.vue new file mode 100644 index 00000000..b9de858d --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/components/TagSelect.vue @@ -0,0 +1,86 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/components/TaskCommit.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/components/TaskCommit.vue new file mode 100644 index 00000000..076bbdd4 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/components/TaskCommit.vue @@ -0,0 +1,380 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/components/TaskGroupSelect.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/components/TaskGroupSelect.vue new file mode 100644 index 00000000..ad1fb710 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/components/TaskGroupSelect.vue @@ -0,0 +1,98 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/components/TaskMultipleSelect.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/components/TaskMultipleSelect.vue new file mode 100644 index 00000000..5643a305 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/components/TaskMultipleSelect.vue @@ -0,0 +1,103 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/components/TaskPostSelect.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/components/TaskPostSelect.vue new file mode 100644 index 00000000..f6684bb4 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/components/TaskPostSelect.vue @@ -0,0 +1,171 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/components/TaskUserSelect.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/components/TaskUserSelect.vue new file mode 100644 index 00000000..514b60f4 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/components/TaskUserSelect.vue @@ -0,0 +1,323 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/components/UserTaskSelect/index.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/components/UserTaskSelect/index.vue new file mode 100644 index 00000000..22fb4d2f --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/components/UserTaskSelect/index.vue @@ -0,0 +1,143 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/components/UserTaskSelect/userTaskSelectDlg.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/components/UserTaskSelect/userTaskSelectDlg.vue new file mode 100644 index 00000000..43955c7d --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/components/UserTaskSelect/userTaskSelectDlg.vue @@ -0,0 +1,458 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/flowCategory/formEditFlowCategory.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/flowCategory/formEditFlowCategory.vue new file mode 100644 index 00000000..a870b262 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/flowCategory/formEditFlowCategory.vue @@ -0,0 +1,261 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/flowCategory/formFlowCategory.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/flowCategory/formFlowCategory.vue new file mode 100644 index 00000000..c4a3f57c --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/flowCategory/formFlowCategory.vue @@ -0,0 +1,292 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/flowEntry/formEditFlowEntry.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/flowEntry/formEditFlowEntry.vue new file mode 100644 index 00000000..9b890b3a --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/flowEntry/formEditFlowEntry.vue @@ -0,0 +1,1250 @@ + + + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/flowEntry/formEditFlowEntryStatus.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/flowEntry/formEditFlowEntryStatus.vue new file mode 100644 index 00000000..e637aba2 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/flowEntry/formEditFlowEntryStatus.vue @@ -0,0 +1,153 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/flowEntry/formEditFlowEntryVariable.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/flowEntry/formEditFlowEntryVariable.vue new file mode 100644 index 00000000..637dc8ce --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/flowEntry/formEditFlowEntryVariable.vue @@ -0,0 +1,228 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/flowEntry/formFlowEntry.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/flowEntry/formFlowEntry.vue new file mode 100644 index 00000000..a8f8ac6c --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/flowEntry/formFlowEntry.vue @@ -0,0 +1,541 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/flowEntry/formPublishedFlowEntry.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/flowEntry/formPublishedFlowEntry.vue new file mode 100644 index 00000000..543b36f7 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/flowEntry/formPublishedFlowEntry.vue @@ -0,0 +1,258 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/formMessage/index.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/formMessage/index.vue new file mode 100644 index 00000000..9c454d9a --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/formMessage/index.vue @@ -0,0 +1,346 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/handlerFlowTask/hook.ts b/OrangeFormsOpen-VUE3/src/pages/workflow/handlerFlowTask/hook.ts new file mode 100644 index 00000000..4f14f013 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/handlerFlowTask/hook.ts @@ -0,0 +1,156 @@ +import { useRoute, useRouter } from 'vue-router'; +import { ElMessage } from 'element-plus'; +import { ANY_OBJECT } from '@/types/generic'; +import { FlowOperationController } from '@/api/flow'; +import { Dialog } from '@/components/Dialog'; +import { SysFlowTaskOperationType } from '@/common/staticDict/flow'; +import { useThirdParty } from '@/components/thirdParty/hooks'; +import { useLayoutStore } from '@/store'; +import TaskCommit from '../components/TaskCommit.vue'; +import { IProp } from './types'; + +export const useFlowAction = (props: IProp) => { + const layoutStore = useLayoutStore(); + const router = useRouter(); + const route = useRoute(); + const handlerFlowTaskRef = ref(); + const { thirdParams } = useThirdParty(props); + + const dialogParams = computed(() => { + console.log('dialogParams props', props); + return { + isRuntime: props.isRuntime === 'true' || thirdParams.value.isRuntime || false, + isDraft: props.isDraft === 'true' || thirdParams.value.isDraft || false, + isPreview: props.isPreview === 'true' || thirdParams.value.isPreview || false, + processDefinitionKey: props.processDefinitionKey || thirdParams.value.processDefinitionKey, + formId: props.formId || thirdParams.value.formId, + routerName: props.routerName || thirdParams.value.routerName, + readOnly: props.readOnly === 'true' || thirdParams.value.readOnly, + messageId: props.messageId || thirdParams.value.messageId, + processInstanceId: props.processInstanceId || thirdParams.value.processInstanceId, + processDefinitionId: props.processDefinitionId || thirdParams.value.processDefinitionId, + taskId: props.taskId || thirdParams.value.taskId, + flowEntryName: props.flowEntryName || thirdParams.value.flowEntryName, + processInstanceInitiator: + props.processInstanceInitiator || thirdParams.value.processInstanceInitiator, + taskName: props.taskName || thirdParams.value.taskName, + operationList: + typeof props.operationList == 'string' + ? JSON.parse(props.operationList) + : props.operationList, // || thirdParams.value.operationList, + variableList: + typeof props.variableList == 'string' + ? JSON.parse(props.variableList) + : props.variableList || thirdParams.value.variableList, + }; + }); + // 加签 + const submitConsign = (assignee: Array | string, isAdd = true) => { + return new Promise((resolve, reject) => { + const params = { + taskId: dialogParams.value.taskId, + processInstanceId: dialogParams.value.processInstanceId, + newAssignees: Array.isArray(assignee) ? assignee : assignee.split(','), + isAdd, + }; + + FlowOperationController.submitConsign(params) + .then(() => { + ElMessage.success(isAdd ? '加签成功!' : '减签成功!'); + resolve(true); + }) + .catch(e => { + console.warn('加签异常', e); + reject(); + }); + }); + }; + // 关闭流程处理 + const handlerClose = () => { + if (props.dialog) { + props.dialog.cancel(); + } else { + route.meta.refreshParentCachedPage = true; + router.go(-1); + } + }; + // 预处理工作流操作 + const preHandlerOperation = ( + operation: ANY_OBJECT | null, + isStart: boolean, + xml: string | undefined, + copyItemList: Array | null = null, + ) => { + return new Promise((resolve, reject) => { + if (operation == null) { + isStart ? resolve(null) : reject(); + return; + } + // 撤销操作不弹出选择窗口 + let showCommitDig = + (!isStart && operation.type !== SysFlowTaskOperationType.REVOKE) || + operation.type === SysFlowTaskOperationType.SET_ASSIGNEE; + if (operation.type === SysFlowTaskOperationType.MULTI_SIGN) { + showCommitDig = + !operation.multiSignAssignee || + !Array.isArray(operation.multiSignAssignee.assigneeList) || + operation.multiSignAssignee.assigneeList.length <= 0; + } + if (showCommitDig) { + let title = '提交'; + if (!isStart) { + switch (operation.type) { + case SysFlowTaskOperationType.CO_SIGN: + case SysFlowTaskOperationType.SIGN_REDUCTION: + title = SysFlowTaskOperationType.getValue(operation.type); + break; + default: + title = '审批'; + break; + } + } + Dialog.show( + title, + TaskCommit, + { + area: '500px', + }, + { + operation, + rowData: { + copyItemList, + operation, + }, + copyItemList, + processInstanceId: dialogParams.value.processInstanceId, + taskId: dialogParams.value.taskId, + xml: xml, + finishedInfo: (handlerFlowTaskRef.value || {}).finishedInfo, + path: 'thirdTaskCommit', + }, + { + width: '500px', + height: '380px', + pathName: '/thirdParty/thirdTaskCommit', + }, + ) + .then(res => { + resolve(res); + }) + .catch(e => { + reject(e); + }); + } else { + resolve(null); + } + }); + }; + + return { + handlerFlowTaskRef, + dialogParams, + submitConsign, + handlerClose, + preHandlerOperation, + }; +}; diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/handlerFlowTask/index.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/handlerFlowTask/index.vue new file mode 100644 index 00000000..52c444c2 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/handlerFlowTask/index.vue @@ -0,0 +1,534 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/handlerFlowTask/types.ts b/OrangeFormsOpen-VUE3/src/pages/workflow/handlerFlowTask/types.ts new file mode 100644 index 00000000..1fb3f6f9 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/handlerFlowTask/types.ts @@ -0,0 +1,37 @@ +import { DialogProp } from '@/components/Dialog/types'; +import { ThirdProps } from '@/components/thirdParty/types'; +import { ANY_OBJECT } from '@/types/generic'; + +export interface IProp extends ThirdProps { + isRuntime?: boolean | string; + isDraft?: boolean | string; + isPreview?: boolean | string; + // 流程标识 + processDefinitionKey: string; + // 在线表单formId + formId?: string; + // 路由名称 + routerName?: string; + // 只读页面 + readOnly: boolean | string; + // 消息id,用于抄送消息回显 + messageId?: string; + // 流程实例id + processInstanceId?: string; + // 流程定义id + processDefinitionId?: string; + // 当前任务节点id + taskId?: string; + // 流程名称 + flowEntryName: string; + // 发起人 + processInstanceInitiator?: string; + // 当前任务节点名称 + taskName?: string; + // 当前任务节点操作列表 + operationList?: Array | string; + // 当前任务节点变量列表 + variableList?: Array | string; + // 弹窗句柄 + dialog?: DialogProp; +} diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/ProcessDesigner.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/ProcessDesigner.vue new file mode 100644 index 00000000..c0233bd6 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/ProcessDesigner.vue @@ -0,0 +1,835 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/highlight.ts b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/highlight.ts new file mode 100644 index 00000000..8b6b88c7 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/highlight.ts @@ -0,0 +1,81 @@ +import { ref, h, computed, defineComponent, watch } from 'vue'; +import hljs from 'highlight.js/lib/core'; +import { escapeHtml } from '@highlightjs/vue-plugin/src/lib/utils'; + +const component = defineComponent({ + props: { + code: { + type: String, + required: true, + }, + language: { + type: String, + default: '', + }, + autodetect: { + type: Boolean, + default: true, + }, + ignoreIllegals: { + type: Boolean, + default: true, + }, + }, + setup(props) { + const language = ref(props.language); + watch( + () => props.language, + newLanguage => { + language.value = newLanguage; + }, + ); + + const autodetect = computed(() => props.autodetect || !language.value); + const cannotDetectLanguage = computed( + () => !autodetect.value && !hljs.getLanguage(language.value), + ); + + const className = computed((): string => { + if (cannotDetectLanguage.value) { + return ''; + } else { + return `hljs ${language.value}`; + } + }); + + const highlightedCode = computed((): string => { + // No idea what language to use, return raw code + if (cannotDetectLanguage.value) { + console.warn(`The language "${language.value}" you specified could not be found.`); + return escapeHtml(props.code); + } + + if (autodetect.value) { + const result = hljs.highlightAuto(props.code); + //language.value = result.language ?? ''; + return result.value; + } else { + const result = hljs.highlight(props.code, { + language: language.value, + ignoreIllegals: props.ignoreIllegals, + }); + return result.value; + } + }); + + return { + className, + highlightedCode, + }; + }, + render() { + return h('pre', {}, [ + h('code', { + class: this.className, + innerHTML: this.highlightedCode, + }), + ]); + }, +}); + +export default component; diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/content-pad/contentPadProvider.js b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/content-pad/contentPadProvider.js new file mode 100644 index 00000000..dcd6089b --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/content-pad/contentPadProvider.js @@ -0,0 +1,423 @@ +import { assign, forEach, isArray } from 'min-dash'; + +import { is } from 'bpmn-js/lib/util/ModelUtil'; + +import { isExpanded, isEventSubProcess } from 'bpmn-js/lib/util/DiUtil'; + +import { isAny } from 'bpmn-js/lib/features/modeling/util/ModelingUtil'; + +import { getChildLanes } from 'bpmn-js/lib/features/modeling/util/LaneUtil'; + +import { hasPrimaryModifier } from 'diagram-js/lib/util/Mouse'; + +/** + * A provider for BPMN 2.0 elements context pad + */ +export default function ContextPadProvider( + config, + injector, + eventBus, + contextPad, + modeling, + elementFactory, + connect, + create, + popupMenu, + canvas, + rules, + translate, + elementRegistry, +) { + config = config || {}; + + contextPad.registerProvider(this); + + this._contextPad = contextPad; + + this._modeling = modeling; + + this._elementFactory = elementFactory; + this._connect = connect; + this._create = create; + this._popupMenu = popupMenu; + this._canvas = canvas; + this._rules = rules; + this._translate = translate; + + if (config.autoPlace !== false) { + this._autoPlace = injector.get('autoPlace', false); + } + + eventBus.on('create.end', 250, function (event) { + var context = event.context, + shape = context.shape; + + if (!hasPrimaryModifier(event) || !contextPad.isOpen(shape)) { + return; + } + + var entries = contextPad.getEntries(shape); + + if (entries.replace) { + entries.replace.action.click(event, shape); + } + }); +} + +ContextPadProvider.$inject = [ + 'config.contextPad', + 'injector', + 'eventBus', + 'contextPad', + 'modeling', + 'elementFactory', + 'connect', + 'create', + 'popupMenu', + 'canvas', + 'rules', + 'translate', + 'elementRegistry', +]; + +ContextPadProvider.prototype.getContextPadEntries = function (element) { + var contextPad = this._contextPad, + modeling = this._modeling, + elementFactory = this._elementFactory, + connect = this._connect, + create = this._create, + popupMenu = this._popupMenu, + canvas = this._canvas, + rules = this._rules, + autoPlace = this._autoPlace, + translate = this._translate; + + var actions = {}; + + if (element.type === 'label') { + return actions; + } + + var businessObject = element.businessObject; + + function startConnect(event, element) { + connect.start(event, element); + } + + function removeElement() { + modeling.removeElements([element]); + } + + function getReplaceMenuPosition(element) { + var Y_OFFSET = 5; + + var diagramContainer = canvas.getContainer(), + pad = contextPad.getPad(element).html; + + var diagramRect = diagramContainer.getBoundingClientRect(), + padRect = pad.getBoundingClientRect(); + + var top = padRect.top - diagramRect.top; + var left = padRect.left - diagramRect.left; + + var pos = { + x: left, + y: top + padRect.height + Y_OFFSET, + }; + + return pos; + } + + /** + * Create an append action + * + * @param {string} type + * @param {string} className + * @param {string} [title] + * @param {Object} [options] + * + * @return {Object} descriptor + */ + function appendAction(type, className, title, options) { + if (typeof title !== 'string') { + options = title; + title = translate('Append {type}', { type: type.replace(/^bpmn:/, '') }); + } + + function appendStart(event, element) { + var shape = elementFactory.createShape(assign({ type: type }, options)); + create.start(event, shape, { + source: element, + }); + } + + var append = autoPlace + ? function (event, element) { + var shape = elementFactory.createShape(assign({ type: type }, options)); + autoPlace.append(element, shape); + } + : appendStart; + + return { + group: 'model', + className: className, + title: title, + action: { + dragstart: appendStart, + click: append, + }, + }; + } + + function splitLaneHandler(count) { + return function (event, element) { + // actual split + modeling.splitLane(element, count); + + // refresh context pad after split to + // get rid of split icons + contextPad.open(element, true); + }; + } + + if (isAny(businessObject, ['bpmn:Lane', 'bpmn:Participant']) && isExpanded(businessObject)) { + var childLanes = getChildLanes(element); + + assign(actions, { + 'lane-insert-above': { + group: 'lane-insert-above', + className: 'bpmn-icon-lane-insert-above', + title: translate('Add Lane above'), + action: { + click: function (event, element) { + modeling.addLane(element, 'top'); + }, + }, + }, + }); + + if (childLanes.length < 2) { + if (element.height >= 120) { + assign(actions, { + 'lane-divide-two': { + group: 'lane-divide', + className: 'bpmn-icon-lane-divide-two', + title: translate('Divide into two Lanes'), + action: { + click: splitLaneHandler(2), + }, + }, + }); + } + + if (element.height >= 180) { + assign(actions, { + 'lane-divide-three': { + group: 'lane-divide', + className: 'bpmn-icon-lane-divide-three', + title: translate('Divide into three Lanes'), + action: { + click: splitLaneHandler(3), + }, + }, + }); + } + } + + assign(actions, { + 'lane-insert-below': { + group: 'lane-insert-below', + className: 'bpmn-icon-lane-insert-below', + title: translate('Add Lane below'), + action: { + click: function (event, element) { + modeling.addLane(element, 'bottom'); + }, + }, + }, + }); + } + + if (is(businessObject, 'bpmn:FlowNode')) { + if (is(businessObject, 'bpmn:EventBasedGateway')) { + assign(actions, { + 'append.receive-task': appendAction( + 'bpmn:ReceiveTask', + 'bpmn-icon-receive-task', + translate('Append ReceiveTask'), + ), + 'append.message-intermediate-event': appendAction( + 'bpmn:IntermediateCatchEvent', + 'bpmn-icon-intermediate-event-catch-message', + translate('Append MessageIntermediateCatchEvent'), + { eventDefinitionType: 'bpmn:MessageEventDefinition' }, + ), + 'append.timer-intermediate-event': appendAction( + 'bpmn:IntermediateCatchEvent', + 'bpmn-icon-intermediate-event-catch-timer', + translate('Append TimerIntermediateCatchEvent'), + { eventDefinitionType: 'bpmn:TimerEventDefinition' }, + ), + 'append.condition-intermediate-event': appendAction( + 'bpmn:IntermediateCatchEvent', + 'bpmn-icon-intermediate-event-catch-condition', + translate('Append ConditionIntermediateCatchEvent'), + { eventDefinitionType: 'bpmn:ConditionalEventDefinition' }, + ), + 'append.signal-intermediate-event': appendAction( + 'bpmn:IntermediateCatchEvent', + 'bpmn-icon-intermediate-event-catch-signal', + translate('Append SignalIntermediateCatchEvent'), + { eventDefinitionType: 'bpmn:SignalEventDefinition' }, + ), + }); + } else if ( + isEventType(businessObject, 'bpmn:BoundaryEvent', 'bpmn:CompensateEventDefinition') + ) { + assign(actions, { + 'append.compensation-activity': appendAction( + 'bpmn:Task', + 'bpmn-icon-task', + translate('Append compensation activity'), + { + isForCompensation: true, + }, + ), + }); + } else if ( + !is(businessObject, 'bpmn:EndEvent') && + !businessObject.isForCompensation && + !isEventType(businessObject, 'bpmn:IntermediateThrowEvent', 'bpmn:LinkEventDefinition') && + !isEventSubProcess(businessObject) + ) { + assign(actions, { + 'append.end-event': appendAction( + 'bpmn:EndEvent', + 'bpmn-icon-end-event-none', + translate('Append EndEvent'), + ), + 'append.gateway': appendAction( + 'bpmn:ExclusiveGateway', + 'bpmn-icon-gateway-none', + translate('Append Gateway'), + ), + 'append.append-task': appendAction( + 'bpmn:UserTask', + 'bpmn-icon-user-task', + translate('Append Task'), + ), + 'append.intermediate-event': appendAction( + 'bpmn:IntermediateThrowEvent', + 'bpmn-icon-intermediate-event-none', + translate('Append Intermediate/Boundary Event'), + ), + }); + } + } + + if (!popupMenu.isEmpty(element, 'bpmn-replace')) { + // Replace menu entry + assign(actions, { + replace: { + group: 'edit', + className: 'bpmn-icon-screw-wrench', + title: translate('Change type'), + action: { + click: function (event, element) { + var position = assign(getReplaceMenuPosition(element), { + cursor: { x: event.x, y: event.y }, + }); + + popupMenu.open(element, 'bpmn-replace', position); + }, + }, + }, + }); + } + + if ( + isAny(businessObject, [ + 'bpmn:FlowNode', + 'bpmn:InteractionNode', + 'bpmn:DataObjectReference', + 'bpmn:DataStoreReference', + ]) + ) { + assign(actions, { + 'append.text-annotation': appendAction('bpmn:TextAnnotation', 'bpmn-icon-text-annotation'), + + connect: { + group: 'connect', + className: 'bpmn-icon-connection-multi', + title: translate( + 'Connect using ' + + (businessObject.isForCompensation ? '' : 'Sequence/MessageFlow or ') + + 'Association', + ), + action: { + click: startConnect, + dragstart: startConnect, + }, + }, + }); + } + + if (isAny(businessObject, ['bpmn:DataObjectReference', 'bpmn:DataStoreReference'])) { + assign(actions, { + connect: { + group: 'connect', + className: 'bpmn-icon-connection-multi', + title: translate('Connect using DataInputAssociation'), + action: { + click: startConnect, + dragstart: startConnect, + }, + }, + }); + } + + if (is(businessObject, 'bpmn:Group')) { + assign(actions, { + 'append.text-annotation': appendAction('bpmn:TextAnnotation', 'bpmn-icon-text-annotation'), + }); + } + + // delete element entry, only show if allowed by rules + var deleteAllowed = rules.allowed('elements.delete', { elements: [element] }); + + if (isArray(deleteAllowed)) { + // was the element returned as a deletion candidate? + deleteAllowed = deleteAllowed[0] === element; + } + + if (deleteAllowed) { + assign(actions, { + delete: { + group: 'edit', + className: 'bpmn-icon-trash', + title: translate('Remove'), + action: { + click: removeElement, + }, + }, + }); + } + + return actions; +}; + +// helpers ///////// + +function isEventType(eventBo, type, definition) { + var isType = eventBo.$instanceOf(type); + var isDefinition = false; + + var definitions = eventBo.eventDefinitions || []; + forEach(definitions, function (def) { + if (def.$type === definition) { + isDefinition = true; + } + }); + + return isType && isDefinition; +} diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/content-pad/index.js b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/content-pad/index.js new file mode 100644 index 00000000..d5325aed --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/content-pad/index.js @@ -0,0 +1,6 @@ +import CustomContextPadProvider from './contentPadProvider'; + +export default { + __init__: ['contextPadProvider'], + contextPadProvider: ['type', CustomContextPadProvider], +}; diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/defaultEmpty.ts b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/defaultEmpty.ts new file mode 100644 index 00000000..826f2bb2 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/defaultEmpty.ts @@ -0,0 +1,77 @@ +import { ANY_OBJECT } from '@/types/generic'; +import { uuid } from '../../utils'; +export default (key: string, name: string, type: string, diagramType: number): string => { + if (!type) type = 'camunda'; + const TYPE_TARGET: ANY_OBJECT = { + activiti: 'http://activiti.org/bpmn', + camunda: 'http://bpmn.io/schema/bpmn', + flowable: 'http://flowable.org/bpmn', + }; + const startId = uuid(); + const endId = uuid(); + const lineId1 = uuid(); + const lineId2 = uuid(); + const userTaskId = uuid(); + + const processXml = + diagramType === 1 + ? ` + + Flow_${lineId1} + + + Flow_${lineId1} + Flow_${lineId2} + + + + Flow_${lineId2} + + + ` + : ''; + const BPMNPlaneXml = + diagramType === 1 + ? ` + + + + + + + + + + + + + + + + + + ` + : ''; + + return ` + + + + ${processXml} + + + + ${BPMNPlaneXml} + + + + `; +}; diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/descriptor/activitiDescriptor.json b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/descriptor/activitiDescriptor.json new file mode 100644 index 00000000..f6bbc27a --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/descriptor/activitiDescriptor.json @@ -0,0 +1,1218 @@ +{ + "name": "Activiti", + "uri": "http://activiti.org/bpmn", + "prefix": "activiti", + "xml": { + "tagAlias": "lowerCase" + }, + "associations": [], + "types": [ + { + "name": "Definitions", + "isAbstract": true, + "extends": ["bpmn:Definitions"], + "properties": [ + { + "name": "diagramRelationId", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "InOutBinding", + "superClass": ["Element"], + "isAbstract": true, + "properties": [ + { + "name": "source", + "isAttr": true, + "type": "String" + }, + { + "name": "sourceExpression", + "isAttr": true, + "type": "String" + }, + { + "name": "target", + "isAttr": true, + "type": "String" + }, + { + "name": "businessKey", + "isAttr": true, + "type": "String" + }, + { + "name": "local", + "isAttr": true, + "type": "Boolean", + "default": false + }, + { + "name": "variables", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "In", + "superClass": ["InOutBinding"], + "meta": { + "allowedIn": ["bpmn:CallActivity"] + } + }, + { + "name": "Out", + "superClass": ["InOutBinding"], + "meta": { + "allowedIn": ["bpmn:CallActivity"] + } + }, + { + "name": "AsyncCapable", + "isAbstract": true, + "extends": ["bpmn:Activity", "bpmn:Gateway", "bpmn:Event"], + "properties": [ + { + "name": "async", + "isAttr": true, + "type": "Boolean", + "default": false + }, + { + "name": "asyncBefore", + "isAttr": true, + "type": "Boolean", + "default": false + }, + { + "name": "asyncAfter", + "isAttr": true, + "type": "Boolean", + "default": false + }, + { + "name": "exclusive", + "isAttr": true, + "type": "Boolean", + "default": true + } + ] + }, + { + "name": "JobPriorized", + "isAbstract": true, + "extends": ["bpmn:Process", "activiti:AsyncCapable"], + "properties": [ + { + "name": "jobPriority", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "SignalEventDefinition", + "isAbstract": true, + "extends": ["bpmn:SignalEventDefinition"], + "properties": [ + { + "name": "async", + "isAttr": true, + "type": "Boolean", + "default": false + } + ] + }, + { + "name": "ErrorEventDefinition", + "isAbstract": true, + "extends": ["bpmn:ErrorEventDefinition"], + "properties": [ + { + "name": "errorCodeVariable", + "isAttr": true, + "type": "String" + }, + { + "name": "errorMessageVariable", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "Error", + "isAbstract": true, + "extends": ["bpmn:Error"], + "properties": [ + { + "name": "activiti:errorMessage", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "PotentialStarter", + "superClass": ["Element"], + "properties": [ + { + "name": "resourceAssignmentExpression", + "type": "bpmn:ResourceAssignmentExpression" + } + ] + }, + { + "name": "FormSupported", + "isAbstract": true, + "extends": ["bpmn:StartEvent", "bpmn:UserTask"], + "properties": [ + { + "name": "formHandlerClass", + "isAttr": true, + "type": "String" + }, + { + "name": "formKey", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "TemplateSupported", + "isAbstract": true, + "extends": ["bpmn:Process", "bpmn:FlowElement"], + "properties": [ + { + "name": "modelerTemplate", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "Initiator", + "isAbstract": true, + "extends": ["bpmn:StartEvent"], + "properties": [ + { + "name": "initiator", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "ScriptTask", + "isAbstract": true, + "extends": ["bpmn:ScriptTask"], + "properties": [ + { + "name": "resultVariable", + "isAttr": true, + "type": "String" + }, + { + "name": "resource", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "Process", + "isAbstract": true, + "extends": ["bpmn:Process"], + "properties": [ + { + "name": "candidateStarterGroups", + "isAttr": true, + "type": "String" + }, + { + "name": "candidateStarterUsers", + "isAttr": true, + "type": "String" + }, + { + "name": "versionTag", + "isAttr": true, + "type": "String" + }, + { + "name": "historyTimeToLive", + "isAttr": true, + "type": "String" + }, + { + "name": "isStartableInTasklist", + "isAttr": true, + "type": "Boolean", + "default": true + }, + { + "name": "executionListener", + "isAbstract": true, + "type": "Expression" + } + ] + }, + { + "name": "EscalationEventDefinition", + "isAbstract": true, + "extends": ["bpmn:EscalationEventDefinition"], + "properties": [ + { + "name": "escalationCodeVariable", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "FormalExpression", + "isAbstract": true, + "extends": ["bpmn:FormalExpression"], + "properties": [ + { + "name": "resource", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "multiinstance_type", + "superClass": ["Element"] + }, + { + "name": "multiinstance_condition", + "superClass": ["Element"] + }, + { + "name": "Assignable", + "extends": ["bpmn:UserTask"], + "properties": [ + { + "name": "assignee", + "isAttr": true, + "type": "String" + }, + { + "name": "candidateUsers", + "isAttr": true, + "type": "String" + }, + { + "name": "candidateGroups", + "isAttr": true, + "type": "String" + }, + { + "name": "dueDate", + "isAttr": true, + "type": "String" + }, + { + "name": "followUpDate", + "isAttr": true, + "type": "String" + }, + { + "name": "priority", + "isAttr": true, + "type": "String" + }, + { + "name": "multiinstance_condition", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "CallActivity", + "extends": ["bpmn:CallActivity"], + "properties": [ + { + "name": "calledElementBinding", + "isAttr": true, + "type": "String", + "default": "latest" + }, + { + "name": "calledElementVersion", + "isAttr": true, + "type": "String" + }, + { + "name": "calledElementVersionTag", + "isAttr": true, + "type": "String" + }, + { + "name": "calledElementTenantId", + "isAttr": true, + "type": "String" + }, + { + "name": "caseRef", + "isAttr": true, + "type": "String" + }, + { + "name": "caseBinding", + "isAttr": true, + "type": "String", + "default": "latest" + }, + { + "name": "caseVersion", + "isAttr": true, + "type": "String" + }, + { + "name": "caseTenantId", + "isAttr": true, + "type": "String" + }, + { + "name": "variableMappingClass", + "isAttr": true, + "type": "String" + }, + { + "name": "variableMappingDelegateExpression", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "ServiceTaskLike", + "extends": [ + "bpmn:ServiceTask", + "bpmn:BusinessRuleTask", + "bpmn:SendTask", + "bpmn:MessageEventDefinition" + ], + "properties": [ + { + "name": "expression", + "isAttr": true, + "type": "String" + }, + { + "name": "class", + "isAttr": true, + "type": "String" + }, + { + "name": "delegateExpression", + "isAttr": true, + "type": "String" + }, + { + "name": "resultVariable", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "DmnCapable", + "extends": ["bpmn:BusinessRuleTask"], + "properties": [ + { + "name": "decisionRef", + "isAttr": true, + "type": "String" + }, + { + "name": "decisionRefBinding", + "isAttr": true, + "type": "String", + "default": "latest" + }, + { + "name": "decisionRefVersion", + "isAttr": true, + "type": "String" + }, + { + "name": "mapDecisionResult", + "isAttr": true, + "type": "String", + "default": "resultList" + }, + { + "name": "decisionRefTenantId", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "ExternalCapable", + "extends": ["activiti:ServiceTaskLike"], + "properties": [ + { + "name": "type", + "isAttr": true, + "type": "String" + }, + { + "name": "topic", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "TaskPriorized", + "extends": ["bpmn:Process", "activiti:ExternalCapable"], + "properties": [ + { + "name": "taskPriority", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "Properties", + "superClass": ["Element"], + "meta": { + "allowedIn": ["*"] + }, + "properties": [ + { + "name": "values", + "type": "Property", + "isMany": true + } + ] + }, + { + "name": "Property", + "superClass": ["Element"], + "properties": [ + { + "name": "id", + "type": "String", + "isAttr": true + }, + { + "name": "name", + "type": "String", + "isAttr": true + }, + { + "name": "value", + "type": "String", + "isAttr": true + } + ] + }, + { + "name": "Connector", + "superClass": ["Element"], + "meta": { + "allowedIn": ["activiti:ServiceTaskLike"] + }, + "properties": [ + { + "name": "inputOutput", + "type": "InputOutput" + }, + { + "name": "connectorId", + "type": "String" + } + ] + }, + { + "name": "InputOutput", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:FlowNode", "activiti:Connector"] + }, + "properties": [ + { + "name": "inputOutput", + "type": "InputOutput" + }, + { + "name": "connectorId", + "type": "String" + }, + { + "name": "inputParameters", + "isMany": true, + "type": "InputParameter" + }, + { + "name": "outputParameters", + "isMany": true, + "type": "OutputParameter" + } + ] + }, + { + "name": "InputOutputParameter", + "properties": [ + { + "name": "name", + "isAttr": true, + "type": "String" + }, + { + "name": "value", + "isBody": true, + "type": "String" + }, + { + "name": "definition", + "type": "InputOutputParameterDefinition" + } + ] + }, + { + "name": "InputOutputParameterDefinition", + "isAbstract": true + }, + { + "name": "List", + "superClass": ["InputOutputParameterDefinition"], + "properties": [ + { + "name": "items", + "isMany": true, + "type": "InputOutputParameterDefinition" + } + ] + }, + { + "name": "Map", + "superClass": ["InputOutputParameterDefinition"], + "properties": [ + { + "name": "entries", + "isMany": true, + "type": "Entry" + } + ] + }, + { + "name": "Entry", + "properties": [ + { + "name": "key", + "isAttr": true, + "type": "String" + }, + { + "name": "value", + "isBody": true, + "type": "String" + }, + { + "name": "definition", + "type": "InputOutputParameterDefinition" + } + ] + }, + { + "name": "Value", + "superClass": ["InputOutputParameterDefinition"], + "properties": [ + { + "name": "id", + "isAttr": true, + "type": "String" + }, + { + "name": "name", + "isAttr": true, + "type": "String" + }, + { + "name": "value", + "isBody": true, + "type": "String" + } + ] + }, + { + "name": "Script", + "superClass": ["InputOutputParameterDefinition"], + "properties": [ + { + "name": "scriptFormat", + "isAttr": true, + "type": "String" + }, + { + "name": "resource", + "isAttr": true, + "type": "String" + }, + { + "name": "value", + "isBody": true, + "type": "String" + } + ] + }, + { + "name": "Field", + "superClass": ["Element"], + "meta": { + "allowedIn": [ + "activiti:ServiceTaskLike", + "activiti:ExecutionListener", + "activiti:TaskListener" + ] + }, + "properties": [ + { + "name": "name", + "isAttr": true, + "type": "String" + }, + { + "name": "expression", + "type": "String" + }, + { + "name": "stringValue", + "isAttr": true, + "type": "String" + }, + { + "name": "string", + "type": "String" + } + ] + }, + { + "name": "InputParameter", + "superClass": ["InputOutputParameter"] + }, + { + "name": "OutputParameter", + "superClass": ["InputOutputParameter"] + }, + { + "name": "Collectable", + "isAbstract": true, + "extends": ["bpmn:MultiInstanceLoopCharacteristics"], + "superClass": ["activiti:AsyncCapable"], + "properties": [ + { + "name": "collection", + "isAttr": true, + "type": "String" + }, + { + "name": "elementVariable", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "FailedJobRetryTimeCycle", + "superClass": ["Element"], + "meta": { + "allowedIn": ["activiti:AsyncCapable", "bpmn:MultiInstanceLoopCharacteristics"] + }, + "properties": [ + { + "name": "body", + "isBody": true, + "type": "String" + } + ] + }, + { + "name": "ExecutionListener", + "superClass": ["Element"], + "meta": { + "allowedIn": [ + "bpmn:Task", + "bpmn:ServiceTask", + "bpmn:UserTask", + "bpmn:BusinessRuleTask", + "bpmn:ScriptTask", + "bpmn:ReceiveTask", + "bpmn:ManualTask", + "bpmn:ExclusiveGateway", + "bpmn:SequenceFlow", + "bpmn:ParallelGateway", + "bpmn:InclusiveGateway", + "bpmn:EventBasedGateway", + "bpmn:StartEvent", + "bpmn:IntermediateCatchEvent", + "bpmn:IntermediateThrowEvent", + "bpmn:EndEvent", + "bpmn:BoundaryEvent", + "bpmn:CallActivity", + "bpmn:SubProcess", + "bpmn:Process" + ] + }, + "properties": [ + { + "name": "expression", + "isAttr": true, + "type": "String" + }, + { + "name": "class", + "isAttr": true, + "type": "String" + }, + { + "name": "delegateExpression", + "isAttr": true, + "type": "String" + }, + { + "name": "event", + "isAttr": true, + "type": "String" + }, + { + "name": "script", + "type": "Script" + }, + { + "name": "fields", + "type": "Field", + "isMany": true + } + ] + }, + { + "name": "TaskListener", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:UserTask"] + }, + "properties": [ + { + "name": "expression", + "isAttr": true, + "type": "String" + }, + { + "name": "class", + "isAttr": true, + "type": "String" + }, + { + "name": "delegateExpression", + "isAttr": true, + "type": "String" + }, + { + "name": "event", + "isAttr": true, + "type": "String" + }, + { + "name": "script", + "type": "Script" + }, + { + "name": "fields", + "type": "Field", + "isMany": true + } + ] + }, + { + "name": "FormProperty", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:StartEvent", "bpmn:UserTask"] + }, + "properties": [ + { + "name": "id", + "type": "String", + "isAttr": true + }, + { + "name": "name", + "type": "String", + "isAttr": true + }, + { + "name": "type", + "type": "String", + "isAttr": true + }, + { + "name": "required", + "type": "String", + "isAttr": true + }, + { + "name": "readable", + "type": "String", + "isAttr": true + }, + { + "name": "writable", + "type": "String", + "isAttr": true + }, + { + "name": "variable", + "type": "String", + "isAttr": true + }, + { + "name": "expression", + "type": "String", + "isAttr": true + }, + { + "name": "datePattern", + "type": "String", + "isAttr": true + }, + { + "name": "default", + "type": "String", + "isAttr": true + }, + { + "name": "values", + "type": "Value", + "isMany": true + } + ] + }, + { + "name": "FormProperty", + "superClass": ["Element"], + "properties": [ + { + "name": "id", + "type": "String", + "isAttr": true + }, + { + "name": "label", + "type": "String", + "isAttr": true + }, + { + "name": "type", + "type": "String", + "isAttr": true + }, + { + "name": "datePattern", + "type": "String", + "isAttr": true + }, + { + "name": "defaultValue", + "type": "String", + "isAttr": true + }, + { + "name": "properties", + "type": "Properties" + }, + { + "name": "validation", + "type": "Validation" + }, + { + "name": "values", + "type": "Value", + "isMany": true + } + ] + }, + { + "name": "Validation", + "superClass": ["Element"], + "properties": [ + { + "name": "constraints", + "type": "Constraint", + "isMany": true + } + ] + }, + { + "name": "Constraint", + "superClass": ["Element"], + "properties": [ + { + "name": "name", + "type": "String", + "isAttr": true + }, + { + "name": "config", + "type": "String", + "isAttr": true + } + ] + }, + { + "name": "ExtensionElements", + "properties": [ + { + "name": "operationList", + "type": "String", + "isAttr": true + } + ] + }, + { + "name": "OperationList", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:UserTask"] + }, + "properties": [ + { + "name": "operationList", + "type": "FormOperation", + "isMany": true + } + ] + }, + { + "name": "FormOperation", + "superClass": ["Element"], + "properties": [ + { + "name": "id", + "type": "String", + "isAttr": true + }, + { + "name": "label", + "type": "String", + "isAttr": true + }, + { + "name": "type", + "type": "String", + "isAttr": true + }, + { + "name": "showOrder", + "type": "String", + "isAttr": true + }, + { + "name": "multiSignAssignee", + "type": "String", + "isAttr": true + } + ] + }, + { + "name": "VariableList", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:UserTask"] + }, + "properties": [ + { + "name": "variableList", + "type": "FormVariable", + "isMany": true + } + ] + }, + { + "name": "FormVariable", + "superClass": ["Element"], + "properties": [ + { + "name": "id", + "type": "String", + "isAttr": true + } + ] + }, + { + "name": "CopyItemList", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:UserTask"] + }, + "properties": [ + { + "name": "copyItemList", + "type": "CopyItem", + "isMany": true + } + ] + }, + { + "name": "CopyItem", + "superClass": ["Element"], + "properties": [ + { + "name": "id", + "type": "String", + "isAttr": true + }, + { + "name": "type", + "type": "String", + "isAttr": true + } + ] + }, + { + "name": "DeptPostList", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:UserTask"] + }, + "properties": [ + { + "name": "deptPostList", + "type": "DeptPost", + "isMany": true + } + ] + }, + { + "name": "DeptPost", + "superClass": ["Element"], + "properties": [ + { + "name": "id", + "type": "String", + "isAttr": true + }, + { + "name": "type", + "type": "String", + "isAttr": true + }, + { + "name": "postId", + "type": "String", + "isAttr": true + }, + { + "name": "deptPostId", + "type": "String", + "isAttr": true + } + ] + }, + { + "name": "UserCandidateGroups", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:UserTask"] + }, + "properties": [ + { + "name": "type", + "type": "String", + "isAttr": true + }, + { + "name": "value", + "type": "String", + "isAttr": true + } + ] + }, + { + "name": "CustomCondition", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:SequenceFlow"] + }, + "properties": [ + { + "name": "type", + "type": "String", + "isAttr": true + }, + { + "name": "operationType", + "type": "String", + "isAttr": true + }, + { + "name": "parallelRefuse", + "type": "Boolean", + "isAttr": true, + "default": false + } + ] + }, + { + "name": "AssigneeList", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:StartEvent", "bpmn:UserTask"] + }, + "properties": [ + { + "name": "assigneeList", + "type": "Assignee", + "isMany": true + }, + { + "name": "type", + "type": "String", + "isAttr": true + } + ] + }, + { + "name": "Assignee", + "superClass": ["Element"], + "properties": [ + { + "name": "id", + "type": "String", + "isAttr": true + } + ] + }, + { + "name": "ConditionalEventDefinition", + "isAbstract": true, + "extends": ["bpmn:ConditionalEventDefinition"], + "properties": [ + { + "name": "variableName", + "isAttr": true, + "type": "String" + }, + { + "name": "variableEvent", + "isAttr": true, + "type": "String" + } + ] + } + ], + "emumerations": [] +} diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/descriptor/camundaDescriptor.json b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/descriptor/camundaDescriptor.json new file mode 100644 index 00000000..79b86bca --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/descriptor/camundaDescriptor.json @@ -0,0 +1,1010 @@ +{ + "name": "Camunda", + "uri": "http://camunda.org/schema/1.0/bpmn", + "prefix": "camunda", + "xml": { + "tagAlias": "lowerCase" + }, + "associations": [], + "types": [ + { + "name": "Definitions", + "isAbstract": true, + "extends": ["bpmn:Definitions"], + "properties": [ + { + "name": "diagramRelationId", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "InOutBinding", + "superClass": ["Element"], + "isAbstract": true, + "properties": [ + { + "name": "source", + "isAttr": true, + "type": "String" + }, + { + "name": "sourceExpression", + "isAttr": true, + "type": "String" + }, + { + "name": "target", + "isAttr": true, + "type": "String" + }, + { + "name": "businessKey", + "isAttr": true, + "type": "String" + }, + { + "name": "local", + "isAttr": true, + "type": "Boolean", + "default": false + }, + { + "name": "variables", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "In", + "superClass": ["InOutBinding"], + "meta": { + "allowedIn": ["bpmn:CallActivity", "bpmn:SignalEventDefinition"] + } + }, + { + "name": "Out", + "superClass": ["InOutBinding"], + "meta": { + "allowedIn": ["bpmn:CallActivity"] + } + }, + { + "name": "AsyncCapable", + "isAbstract": true, + "extends": ["bpmn:Activity", "bpmn:Gateway", "bpmn:Event"], + "properties": [ + { + "name": "async", + "isAttr": true, + "type": "Boolean", + "default": false + }, + { + "name": "asyncBefore", + "isAttr": true, + "type": "Boolean", + "default": false + }, + { + "name": "asyncAfter", + "isAttr": true, + "type": "Boolean", + "default": false + }, + { + "name": "exclusive", + "isAttr": true, + "type": "Boolean", + "default": true + } + ] + }, + { + "name": "JobPriorized", + "isAbstract": true, + "extends": ["bpmn:Process", "camunda:AsyncCapable"], + "properties": [ + { + "name": "jobPriority", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "SignalEventDefinition", + "isAbstract": true, + "extends": ["bpmn:SignalEventDefinition"], + "properties": [ + { + "name": "async", + "isAttr": true, + "type": "Boolean", + "default": false + } + ] + }, + { + "name": "ErrorEventDefinition", + "isAbstract": true, + "extends": ["bpmn:ErrorEventDefinition"], + "properties": [ + { + "name": "errorCodeVariable", + "isAttr": true, + "type": "String" + }, + { + "name": "errorMessageVariable", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "Error", + "isAbstract": true, + "extends": ["bpmn:Error"], + "properties": [ + { + "name": "camunda:errorMessage", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "PotentialStarter", + "superClass": ["Element"], + "properties": [ + { + "name": "resourceAssignmentExpression", + "type": "bpmn:ResourceAssignmentExpression" + } + ] + }, + { + "name": "FormSupported", + "isAbstract": true, + "extends": ["bpmn:StartEvent", "bpmn:UserTask"], + "properties": [ + { + "name": "formHandlerClass", + "isAttr": true, + "type": "String" + }, + { + "name": "formKey", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "TemplateSupported", + "isAbstract": true, + "extends": ["bpmn:Process", "bpmn:FlowElement"], + "properties": [ + { + "name": "modelerTemplate", + "isAttr": true, + "type": "String" + }, + { + "name": "modelerTemplateVersion", + "isAttr": true, + "type": "Integer" + } + ] + }, + { + "name": "Initiator", + "isAbstract": true, + "extends": ["bpmn:StartEvent"], + "properties": [ + { + "name": "initiator", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "ScriptTask", + "isAbstract": true, + "extends": ["bpmn:ScriptTask"], + "properties": [ + { + "name": "resultVariable", + "isAttr": true, + "type": "String" + }, + { + "name": "resource", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "Process", + "isAbstract": true, + "extends": ["bpmn:Process"], + "properties": [ + { + "name": "candidateStarterGroups", + "isAttr": true, + "type": "String" + }, + { + "name": "candidateStarterUsers", + "isAttr": true, + "type": "String" + }, + { + "name": "versionTag", + "isAttr": true, + "type": "String" + }, + { + "name": "historyTimeToLive", + "isAttr": true, + "type": "String" + }, + { + "name": "isStartableInTasklist", + "isAttr": true, + "type": "Boolean", + "default": true + } + ] + }, + { + "name": "EscalationEventDefinition", + "isAbstract": true, + "extends": ["bpmn:EscalationEventDefinition"], + "properties": [ + { + "name": "escalationCodeVariable", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "FormalExpression", + "isAbstract": true, + "extends": ["bpmn:FormalExpression"], + "properties": [ + { + "name": "resource", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "Assignable", + "extends": ["bpmn:UserTask"], + "properties": [ + { + "name": "assignee", + "isAttr": true, + "type": "String" + }, + { + "name": "candidateUsers", + "isAttr": true, + "type": "String" + }, + { + "name": "candidateGroups", + "isAttr": true, + "type": "String" + }, + { + "name": "dueDate", + "isAttr": true, + "type": "String" + }, + { + "name": "followUpDate", + "isAttr": true, + "type": "String" + }, + { + "name": "priority", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "CallActivity", + "extends": ["bpmn:CallActivity"], + "properties": [ + { + "name": "calledElementBinding", + "isAttr": true, + "type": "String", + "default": "latest" + }, + { + "name": "calledElementVersion", + "isAttr": true, + "type": "String" + }, + { + "name": "calledElementVersionTag", + "isAttr": true, + "type": "String" + }, + { + "name": "calledElementTenantId", + "isAttr": true, + "type": "String" + }, + { + "name": "caseRef", + "isAttr": true, + "type": "String" + }, + { + "name": "caseBinding", + "isAttr": true, + "type": "String", + "default": "latest" + }, + { + "name": "caseVersion", + "isAttr": true, + "type": "String" + }, + { + "name": "caseTenantId", + "isAttr": true, + "type": "String" + }, + { + "name": "variableMappingClass", + "isAttr": true, + "type": "String" + }, + { + "name": "variableMappingDelegateExpression", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "ServiceTaskLike", + "extends": [ + "bpmn:ServiceTask", + "bpmn:BusinessRuleTask", + "bpmn:SendTask", + "bpmn:MessageEventDefinition" + ], + "properties": [ + { + "name": "expression", + "isAttr": true, + "type": "String" + }, + { + "name": "class", + "isAttr": true, + "type": "String" + }, + { + "name": "delegateExpression", + "isAttr": true, + "type": "String" + }, + { + "name": "resultVariable", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "DmnCapable", + "extends": ["bpmn:BusinessRuleTask"], + "properties": [ + { + "name": "decisionRef", + "isAttr": true, + "type": "String" + }, + { + "name": "decisionRefBinding", + "isAttr": true, + "type": "String", + "default": "latest" + }, + { + "name": "decisionRefVersion", + "isAttr": true, + "type": "String" + }, + { + "name": "mapDecisionResult", + "isAttr": true, + "type": "String", + "default": "resultList" + }, + { + "name": "decisionRefTenantId", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "ExternalCapable", + "extends": ["camunda:ServiceTaskLike"], + "properties": [ + { + "name": "type", + "isAttr": true, + "type": "String" + }, + { + "name": "topic", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "TaskPriorized", + "extends": ["bpmn:Process", "camunda:ExternalCapable"], + "properties": [ + { + "name": "taskPriority", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "Properties", + "superClass": ["Element"], + "meta": { + "allowedIn": ["*"] + }, + "properties": [ + { + "name": "values", + "type": "Property", + "isMany": true + } + ] + }, + { + "name": "Property", + "superClass": ["Element"], + "properties": [ + { + "name": "id", + "type": "String", + "isAttr": true + }, + { + "name": "name", + "type": "String", + "isAttr": true + }, + { + "name": "value", + "type": "String", + "isAttr": true + } + ] + }, + { + "name": "Connector", + "superClass": ["Element"], + "meta": { + "allowedIn": ["camunda:ServiceTaskLike"] + }, + "properties": [ + { + "name": "inputOutput", + "type": "InputOutput" + }, + { + "name": "connectorId", + "type": "String" + } + ] + }, + { + "name": "InputOutput", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:FlowNode", "camunda:Connector"] + }, + "properties": [ + { + "name": "inputOutput", + "type": "InputOutput" + }, + { + "name": "connectorId", + "type": "String" + }, + { + "name": "inputParameters", + "isMany": true, + "type": "InputParameter" + }, + { + "name": "outputParameters", + "isMany": true, + "type": "OutputParameter" + } + ] + }, + { + "name": "InputOutputParameter", + "properties": [ + { + "name": "name", + "isAttr": true, + "type": "String" + }, + { + "name": "value", + "isBody": true, + "type": "String" + }, + { + "name": "definition", + "type": "InputOutputParameterDefinition" + } + ] + }, + { + "name": "InputOutputParameterDefinition", + "isAbstract": true + }, + { + "name": "List", + "superClass": ["InputOutputParameterDefinition"], + "properties": [ + { + "name": "items", + "isMany": true, + "type": "InputOutputParameterDefinition" + } + ] + }, + { + "name": "Map", + "superClass": ["InputOutputParameterDefinition"], + "properties": [ + { + "name": "entries", + "isMany": true, + "type": "Entry" + } + ] + }, + { + "name": "Entry", + "properties": [ + { + "name": "key", + "isAttr": true, + "type": "String" + }, + { + "name": "value", + "isBody": true, + "type": "String" + }, + { + "name": "definition", + "type": "InputOutputParameterDefinition" + } + ] + }, + { + "name": "Value", + "superClass": ["InputOutputParameterDefinition"], + "properties": [ + { + "name": "id", + "isAttr": true, + "type": "String" + }, + { + "name": "name", + "isAttr": true, + "type": "String" + }, + { + "name": "value", + "isBody": true, + "type": "String" + } + ] + }, + { + "name": "Script", + "superClass": ["InputOutputParameterDefinition"], + "properties": [ + { + "name": "scriptFormat", + "isAttr": true, + "type": "String" + }, + { + "name": "resource", + "isAttr": true, + "type": "String" + }, + { + "name": "value", + "isBody": true, + "type": "String" + } + ] + }, + { + "name": "Field", + "superClass": ["Element"], + "meta": { + "allowedIn": [ + "camunda:ServiceTaskLike", + "camunda:ExecutionListener", + "camunda:TaskListener" + ] + }, + "properties": [ + { + "name": "name", + "isAttr": true, + "type": "String" + }, + { + "name": "expression", + "type": "String" + }, + { + "name": "stringValue", + "isAttr": true, + "type": "String" + }, + { + "name": "string", + "type": "String" + } + ] + }, + { + "name": "InputParameter", + "superClass": ["InputOutputParameter"] + }, + { + "name": "OutputParameter", + "superClass": ["InputOutputParameter"] + }, + { + "name": "Collectable", + "isAbstract": true, + "extends": ["bpmn:MultiInstanceLoopCharacteristics"], + "superClass": ["camunda:AsyncCapable"], + "properties": [ + { + "name": "collection", + "isAttr": true, + "type": "String" + }, + { + "name": "elementVariable", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "FailedJobRetryTimeCycle", + "superClass": ["Element"], + "meta": { + "allowedIn": ["camunda:AsyncCapable", "bpmn:MultiInstanceLoopCharacteristics"] + }, + "properties": [ + { + "name": "body", + "isBody": true, + "type": "String" + } + ] + }, + { + "name": "ExecutionListener", + "superClass": ["Element"], + "meta": { + "allowedIn": [ + "bpmn:Task", + "bpmn:ServiceTask", + "bpmn:UserTask", + "bpmn:BusinessRuleTask", + "bpmn:ScriptTask", + "bpmn:ReceiveTask", + "bpmn:ManualTask", + "bpmn:ExclusiveGateway", + "bpmn:SequenceFlow", + "bpmn:ParallelGateway", + "bpmn:InclusiveGateway", + "bpmn:EventBasedGateway", + "bpmn:StartEvent", + "bpmn:IntermediateCatchEvent", + "bpmn:IntermediateThrowEvent", + "bpmn:EndEvent", + "bpmn:BoundaryEvent", + "bpmn:CallActivity", + "bpmn:SubProcess", + "bpmn:Process" + ] + }, + "properties": [ + { + "name": "expression", + "isAttr": true, + "type": "String" + }, + { + "name": "class", + "isAttr": true, + "type": "String" + }, + { + "name": "delegateExpression", + "isAttr": true, + "type": "String" + }, + { + "name": "event", + "isAttr": true, + "type": "String" + }, + { + "name": "script", + "type": "Script" + }, + { + "name": "fields", + "type": "Field", + "isMany": true + } + ] + }, + { + "name": "TaskListener", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:UserTask"] + }, + "properties": [ + { + "name": "expression", + "isAttr": true, + "type": "String" + }, + { + "name": "class", + "isAttr": true, + "type": "String" + }, + { + "name": "delegateExpression", + "isAttr": true, + "type": "String" + }, + { + "name": "event", + "isAttr": true, + "type": "String" + }, + { + "name": "script", + "type": "Script" + }, + { + "name": "fields", + "type": "Field", + "isMany": true + }, + { + "name": "id", + "type": "String", + "isAttr": true + }, + { + "name": "eventDefinitions", + "type": "bpmn:TimerEventDefinition", + "isMany": true + } + ] + }, + { + "name": "FormProperty", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:StartEvent", "bpmn:UserTask"] + }, + "properties": [ + { + "name": "id", + "type": "String", + "isAttr": true + }, + { + "name": "name", + "type": "String", + "isAttr": true + }, + { + "name": "type", + "type": "String", + "isAttr": true + }, + { + "name": "required", + "type": "String", + "isAttr": true + }, + { + "name": "readable", + "type": "String", + "isAttr": true + }, + { + "name": "writable", + "type": "String", + "isAttr": true + }, + { + "name": "variable", + "type": "String", + "isAttr": true + }, + { + "name": "expression", + "type": "String", + "isAttr": true + }, + { + "name": "datePattern", + "type": "String", + "isAttr": true + }, + { + "name": "default", + "type": "String", + "isAttr": true + }, + { + "name": "values", + "type": "Value", + "isMany": true + } + ] + }, + { + "name": "FormData", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:StartEvent", "bpmn:UserTask"] + }, + "properties": [ + { + "name": "fields", + "type": "FormField", + "isMany": true + }, + { + "name": "businessKey", + "type": "String", + "isAttr": true + } + ] + }, + { + "name": "FormField", + "superClass": ["Element"], + "properties": [ + { + "name": "id", + "type": "String", + "isAttr": true + }, + { + "name": "label", + "type": "String", + "isAttr": true + }, + { + "name": "type", + "type": "String", + "isAttr": true + }, + { + "name": "datePattern", + "type": "String", + "isAttr": true + }, + { + "name": "defaultValue", + "type": "String", + "isAttr": true + }, + { + "name": "properties", + "type": "Properties" + }, + { + "name": "validation", + "type": "Validation" + }, + { + "name": "values", + "type": "Value", + "isMany": true + } + ] + }, + { + "name": "Validation", + "superClass": ["Element"], + "properties": [ + { + "name": "constraints", + "type": "Constraint", + "isMany": true + } + ] + }, + { + "name": "Constraint", + "superClass": ["Element"], + "properties": [ + { + "name": "name", + "type": "String", + "isAttr": true + }, + { + "name": "config", + "type": "String", + "isAttr": true + } + ] + }, + { + "name": "ConditionalEventDefinition", + "isAbstract": true, + "extends": ["bpmn:ConditionalEventDefinition"], + "properties": [ + { + "name": "variableName", + "isAttr": true, + "type": "String" + }, + { + "name": "variableEvents", + "isAttr": true, + "type": "String" + } + ] + } + ], + "emumerations": [] +} diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/descriptor/flowableDescriptor.json b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/descriptor/flowableDescriptor.json new file mode 100644 index 00000000..3ace04c6 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/descriptor/flowableDescriptor.json @@ -0,0 +1,1265 @@ +{ + "name": "Flowable", + "uri": "http://flowable.org/bpmn", + "prefix": "flowable", + "xml": { + "tagAlias": "lowerCase" + }, + "associations": [], + "types": [ + { + "name": "InOutBinding", + "superClass": ["Element"], + "isAbstract": true, + "properties": [ + { + "name": "source", + "isAttr": true, + "type": "String" + }, + { + "name": "sourceExpression", + "isAttr": true, + "type": "String" + }, + { + "name": "target", + "isAttr": true, + "type": "String" + }, + { + "name": "businessKey", + "isAttr": true, + "type": "String" + }, + { + "name": "local", + "isAttr": true, + "type": "Boolean", + "default": false + }, + { + "name": "variables", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "In", + "superClass": ["InOutBinding"], + "meta": { + "allowedIn": ["bpmn:CallActivity"] + } + }, + { + "name": "Out", + "superClass": ["InOutBinding"], + "meta": { + "allowedIn": ["bpmn:CallActivity"] + } + }, + { + "name": "AsyncCapable", + "isAbstract": true, + "extends": ["bpmn:Activity", "bpmn:Gateway", "bpmn:Event"], + "properties": [ + { + "name": "async", + "isAttr": true, + "type": "Boolean", + "default": false + }, + { + "name": "asyncBefore", + "isAttr": true, + "type": "Boolean", + "default": false + }, + { + "name": "asyncAfter", + "isAttr": true, + "type": "Boolean", + "default": false + }, + { + "name": "exclusive", + "isAttr": true, + "type": "Boolean", + "default": true + } + ] + }, + { + "name": "JobPriorized", + "isAbstract": true, + "extends": ["bpmn:Process", "flowable:AsyncCapable"], + "properties": [ + { + "name": "jobPriority", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "SignalEventDefinition", + "isAbstract": true, + "extends": ["bpmn:SignalEventDefinition"], + "properties": [ + { + "name": "async", + "isAttr": true, + "type": "Boolean", + "default": false + } + ] + }, + { + "name": "ErrorEventDefinition", + "isAbstract": true, + "extends": ["bpmn:ErrorEventDefinition"], + "properties": [ + { + "name": "errorCodeVariable", + "isAttr": true, + "type": "String" + }, + { + "name": "errorMessageVariable", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "Error", + "isAbstract": true, + "extends": ["bpmn:Error"], + "properties": [ + { + "name": "flowable:errorMessage", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "PotentialStarter", + "superClass": ["Element"], + "properties": [ + { + "name": "resourceAssignmentExpression", + "type": "bpmn:ResourceAssignmentExpression" + } + ] + }, + { + "name": "FormSupported", + "isAbstract": true, + "extends": ["bpmn:StartEvent", "bpmn:UserTask"], + "properties": [ + { + "name": "formHandlerClass", + "isAttr": true, + "type": "String" + }, + { + "name": "formKey", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "TemplateSupported", + "isAbstract": true, + "extends": ["bpmn:Process", "bpmn:FlowElement"], + "properties": [ + { + "name": "modelerTemplate", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "Initiator", + "isAbstract": true, + "extends": ["bpmn:StartEvent"], + "properties": [ + { + "name": "initiator", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "ScriptTask", + "isAbstract": true, + "extends": ["bpmn:ScriptTask"], + "properties": [ + { + "name": "resultVariable", + "isAttr": true, + "type": "String" + }, + { + "name": "resource", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "Process", + "isAbstract": true, + "extends": ["bpmn:Process"], + "properties": [ + { + "name": "candidateStarterGroups", + "isAttr": true, + "type": "String" + }, + { + "name": "candidateStarterUsers", + "isAttr": true, + "type": "String" + }, + { + "name": "versionTag", + "isAttr": true, + "type": "String" + }, + { + "name": "historyTimeToLive", + "isAttr": true, + "type": "String" + }, + { + "name": "isStartableInTasklist", + "isAttr": true, + "type": "Boolean", + "default": true + } + ] + }, + { + "name": "EscalationEventDefinition", + "isAbstract": true, + "extends": ["bpmn:EscalationEventDefinition"], + "properties": [ + { + "name": "escalationCodeVariable", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "xcField", + "isAbstract": true, + "properties": [ + { + "name": "xcString", + "isMany": true, + "type": "Element" + }, + { + "name": "name", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "xcString", + "isAbstract": true, + "properties": [ + { + "name": "body", + "isBody": true, + "type": "String" + } + ] + }, + { + "name": "FormalExpression", + "isAbstract": true, + "extends": ["bpmn:FormalExpression"], + "properties": [ + { + "name": "resource", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "Assignable", + "extends": ["bpmn:UserTask"], + "properties": [ + { + "name": "assignee", + "isAttr": true, + "type": "String" + }, + { + "name": "xcformKey", + "isAttr": true, + "type": "String" + }, + { + "name": "candidateUsers", + "isAttr": true, + "type": "String" + }, + { + "name": "candidateGroups", + "isAttr": true, + "type": "String" + }, + { + "name": "dueDate", + "isAttr": true, + "type": "String" + }, + { + "name": "followUpDate", + "isAttr": true, + "type": "String" + }, + { + "name": "priority", + "isAttr": true, + "type": "String" + }, + { + "name": "sendMessageType", + "isAttr": true, + "type": "String" + }, + { + "name": "autoSkipType", + "isAttr": true, + "type": "String" + }, + { + "name": "rejectType", + "isAttr": true, + "type": "String" + }, + { + "name": "timeoutHandleWay", + "isAttr": true, + "type": "String" + }, + { + "name": "timeoutHours", + "isAttr": true, + "type": "String" + }, + { + "name": "emptyUserHandleWay", + "isAttr": true, + "type": "String" + }, + { + "name": "emptyUserToAssignee", + "isAttr": true, + "type": "String" + }, + { + "name": "defaultAssignee", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "CallActivity", + "extends": ["bpmn:CallActivity"], + "properties": [ + { + "name": "calledElementBinding", + "isAttr": true, + "type": "String", + "default": "latest" + }, + { + "name": "calledElementVersion", + "isAttr": true, + "type": "String" + }, + { + "name": "calledElementVersionTag", + "isAttr": true, + "type": "String" + }, + { + "name": "calledElementTenantId", + "isAttr": true, + "type": "String" + }, + { + "name": "caseRef", + "isAttr": true, + "type": "String" + }, + { + "name": "caseBinding", + "isAttr": true, + "type": "String", + "default": "latest" + }, + { + "name": "caseVersion", + "isAttr": true, + "type": "String" + }, + { + "name": "caseTenantId", + "isAttr": true, + "type": "String" + }, + { + "name": "variableMappingClass", + "isAttr": true, + "type": "String" + }, + { + "name": "variableMappingDelegateExpression", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "ServiceTaskLike", + "extends": [ + "bpmn:ServiceTask", + "bpmn:BusinessRuleTask", + "bpmn:SendTask", + "bpmn:MessageEventDefinition" + ], + "properties": [ + { + "name": "expression", + "isAttr": true, + "type": "String" + }, + { + "name": "class", + "isAttr": true, + "type": "String" + }, + { + "name": "delegateExpression", + "isAttr": true, + "type": "String" + }, + { + "name": "resultVariable", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "DmnCapable", + "extends": ["bpmn:BusinessRuleTask"], + "properties": [ + { + "name": "decisionRef", + "isAttr": true, + "type": "String" + }, + { + "name": "decisionRefBinding", + "isAttr": true, + "type": "String", + "default": "latest" + }, + { + "name": "decisionRefVersion", + "isAttr": true, + "type": "String" + }, + { + "name": "mapDecisionResult", + "isAttr": true, + "type": "String", + "default": "resultList" + }, + { + "name": "decisionRefTenantId", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "ExternalCapable", + "extends": ["flowable:ServiceTaskLike"], + "properties": [ + { + "name": "type", + "isAttr": true, + "type": "String" + }, + { + "name": "topic", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "TaskPriorized", + "extends": ["bpmn:Process", "flowable:ExternalCapable"], + "properties": [ + { + "name": "taskPriority", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "Properties", + "superClass": ["Element"], + "meta": { + "allowedIn": ["*"] + }, + "properties": [ + { + "name": "values", + "type": "Property", + "isMany": true + } + ] + }, + { + "name": "Property", + "superClass": ["Element"], + "properties": [ + { + "name": "id", + "type": "String", + "isAttr": true + }, + { + "name": "name", + "type": "String", + "isAttr": true + }, + { + "name": "value", + "type": "String", + "isAttr": true + } + ] + }, + { + "name": "Connector", + "superClass": ["Element"], + "meta": { + "allowedIn": ["flowable:ServiceTaskLike"] + }, + "properties": [ + { + "name": "inputOutput", + "type": "InputOutput" + }, + { + "name": "connectorId", + "type": "String" + } + ] + }, + { + "name": "InputOutput", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:FlowNode", "flowable:Connector"] + }, + "properties": [ + { + "name": "inputOutput", + "type": "InputOutput" + }, + { + "name": "connectorId", + "type": "String" + }, + { + "name": "inputParameters", + "isMany": true, + "type": "InputParameter" + }, + { + "name": "outputParameters", + "isMany": true, + "type": "OutputParameter" + } + ] + }, + { + "name": "InputOutputParameter", + "properties": [ + { + "name": "name", + "isAttr": true, + "type": "String" + }, + { + "name": "value", + "isBody": true, + "type": "String" + }, + { + "name": "definition", + "type": "InputOutputParameterDefinition" + } + ] + }, + { + "name": "InputOutputParameterDefinition", + "isAbstract": true + }, + { + "name": "List", + "superClass": ["InputOutputParameterDefinition"], + "properties": [ + { + "name": "items", + "isMany": true, + "type": "InputOutputParameterDefinition" + } + ] + }, + { + "name": "Map", + "superClass": ["InputOutputParameterDefinition"], + "properties": [ + { + "name": "entries", + "isMany": true, + "type": "Entry" + } + ] + }, + { + "name": "Entry", + "properties": [ + { + "name": "key", + "isAttr": true, + "type": "String" + }, + { + "name": "value", + "isBody": true, + "type": "String" + }, + { + "name": "definition", + "type": "InputOutputParameterDefinition" + } + ] + }, + { + "name": "Value", + "superClass": ["InputOutputParameterDefinition"], + "properties": [ + { + "name": "id", + "isAttr": true, + "type": "String" + }, + { + "name": "name", + "isAttr": true, + "type": "String" + }, + { + "name": "value", + "isBody": true, + "type": "String" + } + ] + }, + { + "name": "Script", + "superClass": ["InputOutputParameterDefinition"], + "properties": [ + { + "name": "scriptFormat", + "isAttr": true, + "type": "String" + }, + { + "name": "resource", + "isAttr": true, + "type": "String" + }, + { + "name": "value", + "isBody": true, + "type": "String" + } + ] + }, + { + "name": "Field", + "superClass": ["Element"], + "meta": { + "allowedIn": [ + "flowable:ServiceTaskLike", + "flowable:ExecutionListener", + "flowable:TaskListener" + ] + }, + "properties": [ + { + "name": "name", + "isAttr": true, + "type": "String" + }, + { + "name": "expression", + "type": "String" + }, + { + "name": "stringValue", + "isAttr": true, + "type": "String" + }, + { + "name": "string", + "type": "String" + } + ] + }, + { + "name": "InputParameter", + "superClass": ["InputOutputParameter"] + }, + { + "name": "OutputParameter", + "superClass": ["InputOutputParameter"] + }, + { + "name": "Collectable", + "isAbstract": true, + "extends": ["bpmn:MultiInstanceLoopCharacteristics"], + "superClass": ["flowable:AsyncCapable"], + "properties": [ + { + "name": "collection", + "isAttr": true, + "type": "String" + }, + { + "name": "elementVariable", + "isAttr": true, + "type": "String" + } + ] + }, + { + "name": "FailedJobRetryTimeCycle", + "superClass": ["Element"], + "meta": { + "allowedIn": ["flowable:AsyncCapable", "bpmn:MultiInstanceLoopCharacteristics"] + }, + "properties": [ + { + "name": "body", + "isBody": true, + "type": "String" + } + ] + }, + { + "name": "ExecutionListener", + "superClass": ["Element"], + "meta": { + "allowedIn": [ + "bpmn:Task", + "bpmn:ServiceTask", + "bpmn:UserTask", + "bpmn:BusinessRuleTask", + "bpmn:ScriptTask", + "bpmn:ReceiveTask", + "bpmn:ManualTask", + "bpmn:ExclusiveGateway", + "bpmn:SequenceFlow", + "bpmn:ParallelGateway", + "bpmn:InclusiveGateway", + "bpmn:EventBasedGateway", + "bpmn:StartEvent", + "bpmn:IntermediateCatchEvent", + "bpmn:IntermediateThrowEvent", + "bpmn:EndEvent", + "bpmn:BoundaryEvent", + "bpmn:CallActivity", + "bpmn:SubProcess", + "bpmn:Process" + ] + }, + "properties": [ + { + "name": "expression", + "isAttr": true, + "type": "String" + }, + { + "name": "class", + "isAttr": true, + "type": "String" + }, + { + "name": "delegateExpression", + "isAttr": true, + "type": "String" + }, + { + "name": "event", + "isAttr": true, + "type": "String" + }, + { + "name": "script", + "type": "Script" + }, + { + "name": "fields", + "type": "Field", + "isMany": true + } + ] + }, + { + "name": "TaskListener", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:UserTask"] + }, + "properties": [ + { + "name": "expression", + "isAttr": true, + "type": "String" + }, + { + "name": "class", + "isAttr": true, + "type": "String" + }, + { + "name": "delegateExpression", + "isAttr": true, + "type": "String" + }, + { + "name": "event", + "isAttr": true, + "type": "String" + }, + { + "name": "script", + "type": "Script" + }, + { + "name": "fields", + "type": "Field", + "isMany": true + } + ] + }, + { + "name": "FormProperty", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:StartEvent", "bpmn:UserTask"] + }, + "properties": [ + { + "name": "id", + "type": "String", + "isAttr": true + }, + { + "name": "name", + "type": "String", + "isAttr": true + }, + { + "name": "type", + "type": "String", + "isAttr": true + }, + { + "name": "required", + "type": "String", + "isAttr": true + }, + { + "name": "readable", + "type": "String", + "isAttr": true + }, + { + "name": "writable", + "type": "String", + "isAttr": true + }, + { + "name": "variable", + "type": "String", + "isAttr": true + }, + { + "name": "expression", + "type": "String", + "isAttr": true + }, + { + "name": "datePattern", + "type": "String", + "isAttr": true + }, + { + "name": "default", + "type": "String", + "isAttr": true + }, + { + "name": "values", + "type": "Value", + "isMany": true + } + ] + }, + { + "name": "FormProperty", + "superClass": ["Element"], + "properties": [ + { + "name": "id", + "type": "String", + "isAttr": true + }, + { + "name": "label", + "type": "String", + "isAttr": true + }, + { + "name": "type", + "type": "String", + "isAttr": true + }, + { + "name": "datePattern", + "type": "String", + "isAttr": true + }, + { + "name": "defaultValue", + "type": "String", + "isAttr": true + }, + { + "name": "properties", + "type": "Properties" + }, + { + "name": "validation", + "type": "Validation" + }, + { + "name": "values", + "type": "Value", + "isMany": true + } + ] + }, + { + "name": "Validation", + "superClass": ["Element"], + "properties": [ + { + "name": "constraints", + "type": "Constraint", + "isMany": true + } + ] + }, + { + "name": "Constraint", + "superClass": ["Element"], + "properties": [ + { + "name": "name", + "type": "String", + "isAttr": true + }, + { + "name": "config", + "type": "String", + "isAttr": true + } + ] + }, + { + "name": "ExtensionElements", + "properties": [ + { + "name": "operationList", + "type": "String", + "isAttr": true + } + ] + }, + { + "name": "OperationList", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:UserTask"] + }, + "properties": [ + { + "name": "operationList", + "type": "FormOperation", + "isMany": true + } + ] + }, + { + "name": "FormOperation", + "superClass": ["Element"], + "properties": [ + { + "name": "id", + "type": "String", + "isAttr": true + }, + { + "name": "label", + "type": "String", + "isAttr": true + }, + { + "name": "type", + "type": "String", + "isAttr": true + }, + { + "name": "showOrder", + "type": "String", + "isAttr": true + }, + { + "name": "multiSignAssignee", + "type": "String", + "isAttr": true + }, + { + "name": "latestApprovalStatus", + "type": "String", + "isAttr": true + } + ] + }, + { + "name": "VariableList", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:UserTask"] + }, + "properties": [ + { + "name": "variableList", + "type": "FormVariable", + "isMany": true + } + ] + }, + { + "name": "FormVariable", + "superClass": ["Element"], + "properties": [ + { + "name": "id", + "type": "String", + "isAttr": true + } + ] + }, + { + "name": "CopyItemList", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:UserTask"] + }, + "properties": [ + { + "name": "copyItemList", + "type": "CopyItem", + "isMany": true + } + ] + }, + { + "name": "CopyItem", + "superClass": ["Element"], + "properties": [ + { + "name": "id", + "type": "String", + "isAttr": true + }, + { + "name": "type", + "type": "String", + "isAttr": true + } + ] + }, + { + "name": "DeptPostList", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:UserTask"] + }, + "properties": [ + { + "name": "deptPostList", + "type": "DeptPost", + "isMany": true + } + ] + }, + { + "name": "DeptPost", + "superClass": ["Element"], + "properties": [ + { + "name": "id", + "type": "String", + "isAttr": true + }, + { + "name": "type", + "type": "String", + "isAttr": true + }, + { + "name": "postId", + "type": "String", + "isAttr": true + }, + { + "name": "deptPostId", + "type": "String", + "isAttr": true + } + ] + }, + { + "name": "UserCandidateGroups", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:UserTask"] + }, + "properties": [ + { + "name": "type", + "type": "String", + "isAttr": true + }, + { + "name": "value", + "type": "String", + "isAttr": true + } + ] + }, + { + "name": "CustomCondition", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:SequenceFlow"] + }, + "properties": [ + { + "name": "type", + "type": "String", + "isAttr": true + }, + { + "name": "operationType", + "type": "String", + "isAttr": true + }, + { + "name": "parallelRefuse", + "type": "Boolean", + "isAttr": true, + "default": false + } + ] + }, + { + "name": "AssigneeList", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:StartEvent", "bpmn:UserTask"] + }, + "properties": [ + { + "name": "assigneeList", + "type": "Assignee", + "isMany": true + }, + { + "name": "type", + "type": "String", + "isAttr": true + } + ] + }, + { + "name": "Assignee", + "superClass": ["Element"], + "properties": [ + { + "name": "id", + "type": "String", + "isAttr": true + } + ] + }, + { + "name": "ConditionalEventDefinition", + "isAbstract": true, + "extends": ["bpmn:ConditionalEventDefinition"], + "properties": [ + { + "name": "variableName", + "isAttr": true, + "type": "String" + }, + { + "name": "variableEvent", + "isAttr": true, + "type": "String" + } + ] + } + ], + "emumerations": [] +} diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/extension-moddle/activiti/activitiExtension.js b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/extension-moddle/activiti/activitiExtension.js new file mode 100644 index 00000000..1e896343 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/extension-moddle/activiti/activitiExtension.js @@ -0,0 +1,79 @@ +'use strict'; + +var some = require('min-dash').some; + +var ALLOWED_TYPES = { + FailedJobRetryTimeCycle: [ + 'bpmn:StartEvent', + 'bpmn:BoundaryEvent', + 'bpmn:IntermediateCatchEvent', + 'bpmn:Activity', + ], + Connector: ['bpmn:EndEvent', 'bpmn:IntermediateThrowEvent'], + Field: ['bpmn:EndEvent', 'bpmn:IntermediateThrowEvent'], +}; + +function is(element, type) { + return element && typeof element.$instanceOf === 'function' && element.$instanceOf(type); +} + +function exists(element) { + return element && element.length; +} + +function includesType(collection, type) { + return ( + exists(collection) && + some(collection, function (element) { + return is(element, type); + }) + ); +} + +function anyType(element, types) { + return some(types, function (type) { + return is(element, type); + }); +} + +function isAllowed(propName, propDescriptor, newElement) { + var name = propDescriptor.name, + types = ALLOWED_TYPES[name.replace(/activiti:/, '')]; + + return name === propName && anyType(newElement, types); +} + +function ActivitiModdleExtension(eventBus) { + eventBus.on( + 'property.clone', + function (context) { + var newElement = context.newElement, + propDescriptor = context.propertyDescriptor; + + this.canCloneProperty(newElement, propDescriptor); + }, + this, + ); +} + +ActivitiModdleExtension.$inject = ['eventBus']; + +ActivitiModdleExtension.prototype.canCloneProperty = function (newElement, propDescriptor) { + if (isAllowed('activiti:FailedJobRetryTimeCycle', propDescriptor, newElement)) { + return ( + includesType(newElement.eventDefinitions, 'bpmn:TimerEventDefinition') || + includesType(newElement.eventDefinitions, 'bpmn:SignalEventDefinition') || + is(newElement.loopCharacteristics, 'bpmn:MultiInstanceLoopCharacteristics') + ); + } + + if (isAllowed('activiti:Connector', propDescriptor, newElement)) { + return includesType(newElement.eventDefinitions, 'bpmn:MessageEventDefinition'); + } + + if (isAllowed('activiti:Field', propDescriptor, newElement)) { + return includesType(newElement.eventDefinitions, 'bpmn:MessageEventDefinition'); + } +}; + +module.exports = ActivitiModdleExtension; diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/extension-moddle/activiti/index.js b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/extension-moddle/activiti/index.js new file mode 100644 index 00000000..4321ebb9 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/extension-moddle/activiti/index.js @@ -0,0 +1,9 @@ +/* + * @author igdianov + * address https://github.com/igdianov/activiti-bpmn-moddle + * */ + +module.exports = { + __init__: ['ActivitiModdleExtension'], + ActivitiModdleExtension: ['type', require('./activitiExtension')], +}; diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/extension-moddle/camunda/extension.js b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/extension-moddle/camunda/extension.js new file mode 100644 index 00000000..6d6a0524 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/extension-moddle/camunda/extension.js @@ -0,0 +1,148 @@ +'use strict'; + +var isFunction = require('min-dash').isFunction, + isObject = require('min-dash').isObject, + some = require('min-dash').some; + +var WILDCARD = '*'; + +function CamundaModdleExtension(eventBus) { + var self = this; + + eventBus.on('moddleCopy.canCopyProperty', function (context) { + var property = context.property, + parent = context.parent; + + return self.canCopyProperty(property, parent); + }); +} + +CamundaModdleExtension.$inject = ['eventBus']; + +/** + * Check wether to disallow copying property. + */ +CamundaModdleExtension.prototype.canCopyProperty = function (property, parent) { + // (1) check wether property is allowed in parent + if (isObject(property) && !isAllowedInParent(property, parent)) { + return false; + } + + // (2) check more complex scenarios + + if (is(property, 'camunda:InputOutput') && !this.canHostInputOutput(parent)) { + return false; + } + + if (isAny(property, ['camunda:Connector', 'camunda:Field']) && !this.canHostConnector(parent)) { + return false; + } + + if (is(property, 'camunda:In') && !this.canHostIn(parent)) { + return false; + } +}; + +CamundaModdleExtension.prototype.canHostInputOutput = function (parent) { + // allowed in camunda:Connector + var connector = getParent(parent, 'camunda:Connector'); + + if (connector) { + return true; + } + + // special rules inside bpmn:FlowNode + var flowNode = getParent(parent, 'bpmn:FlowNode'); + + if (!flowNode) { + return false; + } + + if (isAny(flowNode, ['bpmn:StartEvent', 'bpmn:Gateway', 'bpmn:BoundaryEvent'])) { + return false; + } + + if (is(flowNode, 'bpmn:SubProcess') && flowNode.get('triggeredByEvent')) { + return false; + } + + return true; +}; + +CamundaModdleExtension.prototype.canHostConnector = function (parent) { + var serviceTaskLike = getParent(parent, 'camunda:ServiceTaskLike'); + + if (is(serviceTaskLike, 'bpmn:MessageEventDefinition')) { + // only allow on throw and end events + return getParent(parent, 'bpmn:IntermediateThrowEvent') || getParent(parent, 'bpmn:EndEvent'); + } + + return true; +}; + +CamundaModdleExtension.prototype.canHostIn = function (parent) { + var callActivity = getParent(parent, 'bpmn:CallActivity'); + + if (callActivity) { + return true; + } + + var signalEventDefinition = getParent(parent, 'bpmn:SignalEventDefinition'); + + if (signalEventDefinition) { + // only allow on throw and end events + return getParent(parent, 'bpmn:IntermediateThrowEvent') || getParent(parent, 'bpmn:EndEvent'); + } + + return true; +}; + +module.exports = CamundaModdleExtension; + +// helpers ////////// + +function is(element, type) { + return element && isFunction(element.$instanceOf) && element.$instanceOf(type); +} + +function isAny(element, types) { + return some(types, function (t) { + return is(element, t); + }); +} + +function getParent(element, type) { + if (!type) { + return element.$parent; + } + + if (is(element, type)) { + return element; + } + + if (!element.$parent) { + return; + } + + return getParent(element.$parent, type); +} + +function isAllowedInParent(property, parent) { + // (1) find property descriptor + var descriptor = property.$type && property.$model.getTypeDescriptor(property.$type); + + var allowedIn = descriptor && descriptor.meta && descriptor.meta.allowedIn; + + if (!allowedIn || isWildcard(allowedIn)) { + return true; + } + + // (2) check wether property has parent of allowed type + return some(allowedIn, function (type) { + return getParent(parent, type); + }); +} + +function isWildcard(allowedIn) { + return allowedIn.indexOf(WILDCARD) !== -1; +} diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/extension-moddle/camunda/index.js b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/extension-moddle/camunda/index.js new file mode 100644 index 00000000..9d3116c7 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/extension-moddle/camunda/index.js @@ -0,0 +1,6 @@ +'use strict'; + +module.exports = { + __init__: ['camundaModdleExtension'], + camundaModdleExtension: ['type', require('./extension')], +}; diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/extension-moddle/flowable/flowableExtension.ts b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/extension-moddle/flowable/flowableExtension.ts new file mode 100644 index 00000000..d4c195de --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/extension-moddle/flowable/flowableExtension.ts @@ -0,0 +1,78 @@ +import { ANY_OBJECT } from '@/types/generic'; +import { some } from 'min-dash'; + +const ALLOWED_TYPES: ANY_OBJECT = { + FailedJobRetryTimeCycle: [ + 'bpmn:StartEvent', + 'bpmn:BoundaryEvent', + 'bpmn:IntermediateCatchEvent', + 'bpmn:Activity', + ], + Connector: ['bpmn:EndEvent', 'bpmn:IntermediateThrowEvent'], + Field: ['bpmn:EndEvent', 'bpmn:IntermediateThrowEvent'], +}; + +function is(element: ANY_OBJECT, type: string) { + return element && typeof element.$instanceOf === 'function' && element.$instanceOf(type); +} + +function exists(element: ANY_OBJECT[]) { + return element && element.length; +} + +function includesType(collection: ANY_OBJECT[], type: string) { + return ( + exists(collection) && + some(collection, function (element: ANY_OBJECT) { + return is(element, type); + }) + ); +} + +function anyType(element: ANY_OBJECT, types: string[]) { + return some(types, function (type: string) { + return is(element, type); + }); +} + +function isAllowed(propName: string, propDescriptor: ANY_OBJECT, newElement: ANY_OBJECT) { + var name = propDescriptor.name, + types = ALLOWED_TYPES[name.replace(/flowable:/, '')]; + + return name === propName && anyType(newElement, types); +} + +class FlowableModdleExtension { + // 定义属性 + $inject = ['eventBus']; + + // 定义构造函数:为了将来实例化对象的时候,可以直接对属性的值进行初始化 + constructor(eventBus: ANY_OBJECT) { + eventBus.on('property.clone', (context: ANY_OBJECT) => { + var newElement = context.newElement, + propDescriptor = context.propertyDescriptor; + + this.canCloneProperty(newElement, propDescriptor); + }); + } + + canCloneProperty(newElement: ANY_OBJECT, propDescriptor: ANY_OBJECT) { + if (isAllowed('flowable:FailedJobRetryTimeCycle', propDescriptor, newElement)) { + return ( + includesType(newElement.eventDefinitions, 'bpmn:TimerEventDefinition') || + includesType(newElement.eventDefinitions, 'bpmn:SignalEventDefinition') || + is(newElement.loopCharacteristics, 'bpmn:MultiInstanceLoopCharacteristics') + ); + } + + if (isAllowed('flowable:Connector', propDescriptor, newElement)) { + return includesType(newElement.eventDefinitions, 'bpmn:MessageEventDefinition'); + } + + if (isAllowed('flowable:Field', propDescriptor, newElement)) { + return includesType(newElement.eventDefinitions, 'bpmn:MessageEventDefinition'); + } + } +} + +export default FlowableModdleExtension; diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/extension-moddle/flowable/index.ts b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/extension-moddle/flowable/index.ts new file mode 100644 index 00000000..b816954b --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/extension-moddle/flowable/index.ts @@ -0,0 +1,9 @@ +/* + * @author igdianov + * address https://github.com/igdianov/activiti-bpmn-moddle + * */ + +export default { + __init__: ['FlowableModdleExtension'], + FlowableModdleExtension: ['type', (await import('./flowableExtension')).default], +}; diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/translate/customTranslate.ts b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/translate/customTranslate.ts new file mode 100644 index 00000000..5c0fc3f5 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/translate/customTranslate.ts @@ -0,0 +1,46 @@ +// import translations from "./zh"; +// +// export default function customTranslate(template, replacements) { +// replacements = replacements || {}; +// +// // Translate +// template = translations[template] || template; +// +// // Replace +// return template.replace(/{([^}]+)}/g, function(_, key) { +// let str = replacements[key]; +// if ( +// translations[replacements[key]] !== null && +// translations[replacements[key]] !== "undefined" +// ) { +// // eslint-disable-next-line no-mixed-spaces-and-tabs +// str = translations[replacements[key]]; +// // eslint-disable-next-line no-mixed-spaces-and-tabs +// } +// return str || "{" + key + "}"; +// }); +// } + +import { ANY_OBJECT } from '@/types/generic'; + +const customTranslate = (translations: ANY_OBJECT) => { + return function (template: string, replacements: ANY_OBJECT) { + replacements = replacements || {}; + // Translate + template = translations[template] || template; + + // Replace + return template.replace(/{([^}]+)}/g, function (_, key) { + let str = replacements[key]; + if ( + translations[replacements[key]] !== null && + translations[replacements[key]] !== undefined + ) { + str = translations[replacements[key]]; + } + return str || '{' + key + '}'; + }); + }; +}; + +export default customTranslate; diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/translate/zh.ts b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/translate/zh.ts new file mode 100644 index 00000000..26d9e2d3 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/process-designer/plugins/translate/zh.ts @@ -0,0 +1,244 @@ +import { ANY_OBJECT } from '@/types/generic'; + +/** + * This is a sample file that should be replaced with the actual translation. + * + * Checkout https://github.com/bpmn-io/bpmn-js-i18n for a list of available + * translations and labels to translate. + */ +const translationsCN: ANY_OBJECT = { + // 添加部分 + 'Append EndEvent': '追加结束事件', + 'Append Gateway': '追加网关', + 'Append Task': '追加任务', + 'Append Intermediate/Boundary Event': '追加中间抛出事件/边界事件', + + 'Activate the global connect tool': '激活全局连接工具', + 'Append {type}': '添加 {type}', + 'Add Lane above': '在上面添加道', + 'Divide into two Lanes': '分割成两个道', + 'Divide into three Lanes': '分割成三个道', + 'Add Lane below': '在下面添加道', + 'Append compensation activity': '追加补偿活动', + 'Change type': '修改类型', + 'Connect using Association': '使用关联连接', + 'Connect using Sequence/MessageFlow or Association': '使用顺序/消息流或者关联连接', + 'Connect using DataInputAssociation': '使用数据输入关联连接', + Remove: '移除', + 'Activate the hand tool': '激活抓手工具', + 'Activate the lasso tool': '激活套索工具', + 'Activate the create/remove space tool': '激活创建/删除空间工具', + 'Create expanded SubProcess': '创建扩展子过程', + 'Create IntermediateThrowEvent/BoundaryEvent': '创建中间抛出事件/边界事件', + 'Create Pool/Participant': '创建池/参与者', + 'Parallel Multi Instance': '并行多重事件', + 'Sequential Multi Instance': '时序多重事件', + DataObjectReference: '数据对象参考', + DataStoreReference: '数据存储参考', + Loop: '循环', + 'Ad-hoc': '即席', + 'Create {type}': '创建 {type}', + Task: '任务', + 'Send Task': '发送任务', + 'Receive Task': '接收任务', + 'User Task': '用户任务', + 'Manual Task': '手工任务', + 'Business Rule Task': '业务规则任务', + 'Service Task': '服务任务', + 'Script Task': '脚本任务', + 'Call Activity': '调用活动', + 'Sub Process (collapsed)': '子流程(折叠的)', + 'Sub Process (expanded)': '子流程(展开的)', + 'Start Event': '开始事件', + StartEvent: '开始事件', + 'Intermediate Throw Event': '中间事件', + 'End Event': '结束事件', + EndEvent: '结束事件', + 'Create StartEvent': '创建开始事件', + 'Create EndEvent': '创建结束事件', + 'Create Task': '创建任务', + 'Create User Task': '创建用户任务', + 'Create Gateway': '创建网关', + 'Create DataObjectReference': '创建数据对象', + 'Create DataStoreReference': '创建数据存储', + 'Create Group': '创建分组', + 'Create Intermediate/Boundary Event': '创建中间/边界事件', + 'Message Start Event': '消息开始事件', + 'Timer Start Event': '定时开始事件', + 'Conditional Start Event': '条件开始事件', + 'Signal Start Event': '信号开始事件', + 'Error Start Event': '错误开始事件', + 'Escalation Start Event': '升级开始事件', + 'Compensation Start Event': '补偿开始事件', + 'Message Start Event (non-interrupting)': '消息开始事件(非中断)', + 'Timer Start Event (non-interrupting)': '定时开始事件(非中断)', + 'Conditional Start Event (non-interrupting)': '条件开始事件(非中断)', + 'Signal Start Event (non-interrupting)': '信号开始事件(非中断)', + 'Escalation Start Event (non-interrupting)': '升级开始事件(非中断)', + 'Message Intermediate Catch Event': '消息中间捕获事件', + 'Message Intermediate Throw Event': '消息中间抛出事件', + 'Timer Intermediate Catch Event': '定时中间捕获事件', + 'Escalation Intermediate Throw Event': '升级中间抛出事件', + 'Conditional Intermediate Catch Event': '条件中间捕获事件', + 'Link Intermediate Catch Event': '链接中间捕获事件', + 'Link Intermediate Throw Event': '链接中间抛出事件', + 'Compensation Intermediate Throw Event': '补偿中间抛出事件', + 'Signal Intermediate Catch Event': '信号中间捕获事件', + 'Signal Intermediate Throw Event': '信号中间抛出事件', + 'Message End Event': '消息结束事件', + 'Escalation End Event': '定时结束事件', + 'Error End Event': '错误结束事件', + 'Cancel End Event': '取消结束事件', + 'Compensation End Event': '补偿结束事件', + 'Signal End Event': '信号结束事件', + 'Terminate End Event': '终止结束事件', + 'Message Boundary Event': '消息边界事件', + 'Message Boundary Event (non-interrupting)': '消息边界事件(非中断)', + 'Timer Boundary Event': '定时边界事件', + 'Timer Boundary Event (non-interrupting)': '定时边界事件(非中断)', + 'Escalation Boundary Event': '升级边界事件', + 'Escalation Boundary Event (non-interrupting)': '升级边界事件(非中断)', + 'Conditional Boundary Event': '条件边界事件', + 'Conditional Boundary Event (non-interrupting)': '条件边界事件(非中断)', + 'Error Boundary Event': '错误边界事件', + 'Cancel Boundary Event': '取消边界事件', + 'Signal Boundary Event': '信号边界事件', + 'Signal Boundary Event (non-interrupting)': '信号边界事件(非中断)', + 'Compensation Boundary Event': '补偿边界事件', + 'Exclusive Gateway': '互斥网关', + 'Parallel Gateway': '并行网关', + 'Inclusive Gateway': '相容网关', + 'Complex Gateway': '复杂网关', + 'Event based Gateway': '事件网关', + Transaction: '转运', + 'Sub Process': '子流程', + 'Event Sub Process': '事件子流程', + 'Collapsed Pool': '折叠池', + 'Expanded Pool': '展开池', + + // Errors + 'no parent for {element} in {parent}': '在{parent}里,{element}没有父类', + 'no shape type specified': '没有指定的形状类型', + 'flow elements must be children of pools/participants': '流元素必须是池/参与者的子类', + 'out of bounds release': 'out of bounds release', + 'more than {count} child lanes': '子道大于{count} ', + 'element required': '元素不能为空', + 'diagram not part of bpmn:Definitions': '流程图不符合bpmn规范', + 'no diagram to display': '没有可展示的流程图', + 'no process or collaboration to display': '没有可展示的流程/协作', + 'element {element} referenced by {referenced}#{property} not yet drawn': + '由{referenced}#{property}引用的{element}元素仍未绘制', + 'already rendered {element}': '{element} 已被渲染', + 'failed to import {element}': '导入{element}失败', + //属性面板的参数 + Id: '编号', + Name: '名称', + General: '常规', + Details: '详情', + 'Message Name': '消息名称', + Message: '消息', + Initiator: '创建者', + 'Asynchronous Continuations': '持续异步', + 'Asynchronous Before': '异步前', + 'Asynchronous After': '异步后', + 'Job Configuration': '工作配置', + Exclusive: '排除', + 'Job Priority': '工作优先级', + 'Retry Time Cycle': '重试时间周期', + Documentation: '文档', + 'Element Documentation': '元素文档', + 'History Configuration': '历史配置', + 'History Time To Live': '历史的生存时间', + Forms: '表单', + 'Form Key': '表单key', + 'Form Fields': '表单字段', + 'Business Key': '业务key', + 'Form Field': '表单字段', + ID: '编号', + Type: '类型', + Label: '名称', + 'Default Value': '默认值', + 'Default Flow': '默认流转路径', + 'Conditional Flow': '条件流转路径', + 'Sequence Flow': '普通流转路径', + Validation: '校验', + 'Add Constraint': '添加约束', + Config: '配置', + Properties: '属性', + 'Add Property': '添加属性', + Value: '值', + Listeners: '监听器', + 'Execution Listener': '执行监听', + 'Event Type': '事件类型', + 'Listener Type': '监听器类型', + 'Java Class': 'Java类', + Expression: '表达式', + 'Must provide a value': '必须提供一个值', + 'Delegate Expression': '代理表达式', + Script: '脚本', + 'Script Format': '脚本格式', + 'Script Type': '脚本类型', + 'Inline Script': '内联脚本', + 'External Script': '外部脚本', + Resource: '资源', + 'Field Injection': '字段注入', + Extensions: '扩展', + 'Input/Output': '输入/输出', + 'Input Parameters': '输入参数', + 'Output Parameters': '输出参数', + Parameters: '参数', + 'Output Parameter': '输出参数', + 'Timer Definition Type': '定时器定义类型', + 'Timer Definition': '定时器定义', + Date: '日期', + Duration: '持续', + Cycle: '循环', + Signal: '信号', + 'Signal Name': '信号名称', + Escalation: '升级', + Error: '错误', + 'Link Name': '链接名称', + Condition: '条件名称', + 'Variable Name': '变量名称', + 'Variable Event': '变量事件', + 'Specify more than one variable change event as a comma separated list.': + '多个变量事件以逗号隔开', + 'Wait for Completion': '等待完成', + 'Activity Ref': '活动参考', + 'Version Tag': '版本标签', + Executable: '可执行文件', + 'External Task Configuration': '扩展任务配置', + 'Task Priority': '任务优先级', + External: '外部', + Connector: '连接器', + 'Must configure Connector': '必须配置连接器', + 'Connector Id': '连接器编号', + Implementation: '实现方式', + 'Field Injections': '字段注入', + Fields: '字段', + 'Result Variable': '结果变量', + Topic: '主题', + 'Configure Connector': '配置连接器', + 'Input Parameter': '输入参数', + Assignee: '代理人', + 'Candidate Users': '候选用户', + 'Candidate Groups': '候选组', + 'Due Date': '到期时间', + 'Follow Up Date': '跟踪日期', + Priority: '优先级', + 'The follow up date as an EL expression (e.g. ${someDate} or an ISO date (e.g. 2015-06-26T09:54:00)': + '跟踪日期必须符合EL表达式,如: ${someDate} ,或者一个ISO标准日期,如:2015-06-26T09:54:00', + 'The due date as an EL expression (e.g. ${someDate} or an ISO date (e.g. 2015-06-26T09:54:00)': + '跟踪日期必须符合EL表达式,如: ${someDate} ,或者一个ISO标准日期,如:2015-06-26T09:54:00', + Variables: '变量', + 'Candidate Starter Configuration': '候选人起动器配置', + 'Candidate Starter Groups': '候选人起动器组', + 'This maps to the process definition key.': '这映射到流程定义键。', + 'Candidate Starter Users': '候选人起动器的用户', + 'Specify more than one user as a comma separated list.': '指定多个用户作为逗号分隔的列表。', + 'Tasklist Configuration': 'Tasklist配置', + Startable: '启动', + 'Specify more than one group as a comma separated list.': '指定多个组作为逗号分隔的列表。', +}; + +export default translationsCN; diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/PropertiesPanel.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/PropertiesPanel.vue new file mode 100644 index 00000000..23a9bc57 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/PropertiesPanel.vue @@ -0,0 +1,345 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/autoAgree/index.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/autoAgree/index.vue new file mode 100644 index 00000000..16a74d6b --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/autoAgree/index.vue @@ -0,0 +1,91 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/base/ElementBaseInfo.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/base/ElementBaseInfo.vue new file mode 100644 index 00000000..570f8dc4 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/base/ElementBaseInfo.vue @@ -0,0 +1,79 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/copy-for/index.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/copy-for/index.vue new file mode 100644 index 00000000..df87f754 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/copy-for/index.vue @@ -0,0 +1,116 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/flow-condition/FlowCondition.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/flow-condition/FlowCondition.vue new file mode 100644 index 00000000..71ebfa0d --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/flow-condition/FlowCondition.vue @@ -0,0 +1,288 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/form-variable/index.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/form-variable/index.vue new file mode 100644 index 00000000..eca8a782 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/form-variable/index.vue @@ -0,0 +1,112 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/form/flowFormConfig.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/form/flowFormConfig.vue new file mode 100644 index 00000000..45249220 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/form/flowFormConfig.vue @@ -0,0 +1,332 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/form/formEditOperation.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/form/formEditOperation.vue new file mode 100644 index 00000000..172bcc99 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/form/formEditOperation.vue @@ -0,0 +1,678 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/listeners/ElementListeners.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/listeners/ElementListeners.vue new file mode 100644 index 00000000..6d412923 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/listeners/ElementListeners.vue @@ -0,0 +1,454 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/listeners/UserTaskListeners.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/listeners/UserTaskListeners.vue new file mode 100644 index 00000000..6c7718cb --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/listeners/UserTaskListeners.vue @@ -0,0 +1,486 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/listeners/utilSelf.ts b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/listeners/utilSelf.ts new file mode 100644 index 00000000..b363e957 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/listeners/utilSelf.ts @@ -0,0 +1,69 @@ +// 初始化表单数据 +export function initListenerForm(listener) { + let self = { + ...listener, + }; + if (listener.script) { + self = { + ...listener, + ...listener.script, + scriptType: listener.script.resource ? 'externalScript' : 'inlineScript', + }; + } + if (listener.event === 'timeout' && listener.eventDefinitions) { + if (listener.eventDefinitions.length) { + let k = ''; + for (const key in listener.eventDefinitions[0]) { + if (key.indexOf('time') !== -1) { + k = key; + self.eventDefinitionType = key.replace('time', '').toLowerCase(); + } + } + self.eventTimeDefinitions = listener.eventDefinitions[0][k].body; + } + if (listener.fields) { + self.fields = listener.fields.map(field => { + return { + ...field, + fieldType: field.string ? 'string' : 'expression', + }; + }); + } + } + return self; +} + +export function initListenerType(listener) { + let listenerType; + if (listener.class) listenerType = 'classListener'; + if (listener.expression) listenerType = 'expressionListener'; + if (listener.delegateExpression) listenerType = 'delegateExpressionListener'; + if (listener.script) listenerType = 'scriptListener'; + return { + id: (listener.$attrs || {}).id, + ...JSON.parse(JSON.stringify(listener)), + ...(listener.script ?? {}), + listenerType: listenerType, + }; +} + +export const listenerType = { + classListener: 'Java 类', + expressionListener: '表达式', + delegateExpressionListener: '代理表达式', + scriptListener: '脚本', +}; + +export const eventType = { + create: '创建', + assignment: '指派', + complete: '完成', + delete: '删除', + // update: "更新", + // timeout: "超时" +}; + +export const fieldType = { + string: '字符串', + expression: '表达式', +}; diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/multi-instance/ElementMultiInstance.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/multi-instance/ElementMultiInstance.vue new file mode 100644 index 00000000..89decd44 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/multi-instance/ElementMultiInstance.vue @@ -0,0 +1,558 @@ + + + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/other/ElementOtherConfig.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/other/ElementOtherConfig.vue new file mode 100644 index 00000000..79c08de9 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/other/ElementOtherConfig.vue @@ -0,0 +1,65 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/properties/ElementProperties.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/properties/ElementProperties.vue new file mode 100644 index 00000000..42585b2a --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/properties/ElementProperties.vue @@ -0,0 +1,201 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/properties/SetApproveStatus.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/properties/SetApproveStatus.vue new file mode 100644 index 00000000..9474c9b7 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/properties/SetApproveStatus.vue @@ -0,0 +1,111 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/signal-message/SignalAndMessage.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/signal-message/SignalAndMessage.vue new file mode 100644 index 00000000..dae53640 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/signal-message/SignalAndMessage.vue @@ -0,0 +1,168 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/task/ElementTask.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/task/ElementTask.vue new file mode 100644 index 00000000..927a3f2b --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/task/ElementTask.vue @@ -0,0 +1,92 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/task/task-components/ReceiveTask.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/task/task-components/ReceiveTask.vue new file mode 100644 index 00000000..de736f70 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/task/task-components/ReceiveTask.vue @@ -0,0 +1,141 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/task/task-components/ScriptTask.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/task/task-components/ScriptTask.vue new file mode 100644 index 00000000..26424486 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/task/task-components/ScriptTask.vue @@ -0,0 +1,104 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/task/task-components/UserTask.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/task/task-components/UserTask.vue new file mode 100644 index 00000000..bdac91cb --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/refactor/task/task-components/UserTask.vue @@ -0,0 +1,957 @@ + + + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/theme/flow-element-variables.scss b/OrangeFormsOpen-VUE3/src/pages/workflow/package/theme/flow-element-variables.scss new file mode 100644 index 00000000..19ccd7ab --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/theme/flow-element-variables.scss @@ -0,0 +1,64 @@ +/* 改变主题色变量 +// $--color-primary: #1890ff; +// $--color-danger: #ff4d4f; +*/ + +/* 改变 icon 字体路径变量,必需 */ + +.process-drawer .el-drawer__header { + padding: 16px 16px 8px; + margin: 0; + line-height: 24px; + font-size: 18px; + color: #303133; + box-sizing: border-box; + border-bottom: 1px solid #e8e8e8; +} + +div[class^='el-drawer']:focus, +span:focus { + outline: none; +} + +.process-drawer .el-drawer__body { + overflow-y: auto; + width: 100%; + padding: 16px; + box-sizing: border-box; +} + +.process-design { + .el-table td, + .el-table th { + color: #333; + } + + .el-dialog__header { + padding: 16px 16px 8px; + box-sizing: border-box; + border-bottom: 1px solid #e8e8e8; + } + .el-dialog__body { + overflow-y: auto; + max-height: 80vh; + padding: 16px; + box-sizing: border-box; + } + .el-dialog__footer { + padding: 16px; + box-sizing: border-box; + border-top: 1px solid #e8e8e8; + } + .el-dialog__close { + font-weight: 600; + } + .el-select { + width: 100%; + } + .el-divider:not(.el-divider--horizontal) { + margin: 0 8px; + } + .el-divider.el-divider--horizontal { + margin: 16px 0; + } +} diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/theme/index.scss b/OrangeFormsOpen-VUE3/src/pages/workflow/package/theme/index.scss new file mode 100644 index 00000000..85de1ccd --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/theme/index.scss @@ -0,0 +1,12 @@ +@import url('./flow-element-variables.scss'); +@import url('bpmn-js-token-simulation/assets/css/bpmn-js-token-simulation.css'); +@import url('bpmn-js-token-simulation/assets/css/font-awesome.min.css'); +@import url('bpmn-js-token-simulation/assets/css/normalize.css'); +@import url('bpmn-js/dist/assets/diagram-js.css'); +@import url('bpmn-js/dist/assets/bpmn-font/css/bpmn.css'); +@import url('bpmn-js/dist/assets/bpmn-font/css/bpmn-codes.css'); +@import url('./process-designer.scss'); +@import url('./process-panel.scss'); + +$success-color: #4eb819; +$current-color: #409eff; diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/theme/process-designer.scss b/OrangeFormsOpen-VUE3/src/pages/workflow/package/theme/process-designer.scss new file mode 100644 index 00000000..4edcb2ba --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/theme/process-designer.scss @@ -0,0 +1,252 @@ +// 边框被 token-simulation 样式覆盖了 +.djs-palette { + background: var(--palette-background-color); + border: solid 1px var(--palette-border-color) !important; + border-radius: 2px; +} + +.my-process-designer { + display: flex; + flex-direction: column; + width: 100%; + height: 100%; + box-sizing: border-box; + .my-process-designer__header { + width: 100%; + min-height: 36px; + .el-button { + text-align: center; + } + .el-button-group { + margin: 4px; + } + .el-tooltip__popper { + .el-button { + width: 100%; + text-align: left; + padding-left: 8px; + padding-right: 8px; + } + .el-button:hover { + background: rgba(64, 158, 255, 0.8); + color: #ffffff; + } + } + .align { + position: relative; + i { + &:after { + content: '|'; + position: absolute; + left: 15px; + transform: rotate(90deg) translate(200%, 60%); + } + } + } + .align.align-left i { + transform: rotate(90deg); + } + .align.align-right i { + transform: rotate(-90deg); + } + .align.align-top i { + transform: rotate(180deg); + } + .align.align-bottom i { + transform: rotate(0deg); + } + .align.align-center i { + transform: rotate(90deg); + &:after { + transform: rotate(90deg) translate(0, 60%); + } + } + .align.align-middle i { + transform: rotate(0deg); + &:after { + transform: rotate(90deg) translate(0, 60%); + } + } + } + .my-process-designer__container { + display: inline-flex; + width: 100%; + flex: 1; + background-color: #f6f7f9; + .my-process-designer__canvas { + flex: 1; + height: 100%; + position: relative; + background: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PHBhdHRlcm4gaWQ9ImEiIHdpZHRoPSI0MCIgaGVpZ2h0PSI0MCIgcGF0dGVyblVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+PHBhdGggZD0iTTAgMTBoNDBNMTAgMHY0ME0wIDIwaDQwTTIwIDB2NDBNMCAzMGg0ME0zMCAwdjQwIiBmaWxsPSJub25lIiBzdHJva2U9IiNlMGUwZTAiIG9wYWNpdHk9Ii4yIi8+PHBhdGggZD0iTTQwIDBIMHY0MCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjZTBlMGUwIi8+PC9wYXR0ZXJuPjwvZGVmcz48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSJ1cmwoI2EpIi8+PC9zdmc+') + repeat !important; + div.toggle-mode { + display: none; + } + } + .my-process-designer__property-panel { + height: 100%; + overflow: scroll; + overflow-y: auto; + z-index: 10; + * { + box-sizing: border-box; + } + } + svg { + width: 100%; + height: 100%; + min-height: 100%; + overflow: hidden; + } + } +} + +//侧边栏配置 + +.djs-palette.open .djs-palette-entries div[class^='bpmn-icon-']:before, +.djs-palette.open .djs-palette-entries div[class*='bpmn-icon-']:before { + line-height: unset; +} + +.djs-palette.open .djs-palette-entries div.entry { + position: relative; +} + +.djs-palette.open .djs-palette-entries div.entry:hover::after { + width: max-content; + content: attr(title); + vertical-align: text-bottom; + position: absolute; + right: -10px; + top: 0; + bottom: 0; + overflow: hidden; + transform: translateX(100%); + font-size: 0.5em; + display: inline-block; + text-decoration: inherit; + font-variant: normal; + text-transform: none; + background: #fafafa; + box-shadow: 0 0 6px #eeeeee; + border: 1px solid #cccccc; + box-sizing: border-box; + padding: 0 16px; + border-radius: 4px; + z-index: 100; +} + +.djs-palette.open { + .djs-palette-entries { + div[class^='bpmn-icon-']:before, + div[class*='bpmn-icon-']:before { + line-height: unset; + } + div.entry { + position: relative; + } + div.entry:hover { + &::after { + width: max-content; + content: attr(title); + vertical-align: text-bottom; + position: absolute; + right: -10px; + top: 0; + bottom: 0; + overflow: hidden; + transform: translateX(100%); + font-size: 0.5em; + display: inline-block; + text-decoration: inherit; + font-variant: normal; + text-transform: none; + background: #fafafa; + box-shadow: 0 0 6px #eeeeee; + border: 1px solid #cccccc; + box-sizing: border-box; + padding: 0 16px; + border-radius: 4px; + z-index: 100; + } + } + } +} +pre { + margin: 0; + height: 100%; + overflow: hidden; + max-height: calc(80vh - 32px); + overflow-y: auto; +} +.hljs { + word-break: break-word; + white-space: pre-wrap; +} +.hljs * { + font-family: Consolas, Monaco, monospace; +} + +// 流程图 + +rect { + stroke: #c1c2c4 !important; + stroke-width: 1px !important; +} + +.djs-container .djs-visual circle[style*='stroke-width: 4px'] { + stroke: #333333 !important; +} + +.djs-container .djs-visual path[style='fill: black; stroke-width: 1px; stroke: black;'] { + stroke: #333333 !important; + stroke-width: 1px; + stroke: #333333 !important; +} + +.djs-container .djs-visual path { + stroke: #333333 !important; +} + +.djs-container .djs-visual [id^='sequenceflow-end-white-black'] path { + fill: #333333 !important; + stroke: #333333 !important; +} + +.djs-container .djs-visual [id^='conditional-flow-marker-white-black'] path { + stroke: #333333 !important; +} + +.djs-container { + // 框 + .djs-visual { + rect, + polygon, + circle { + stroke: #c1c2c4 !important; + stroke-width: 1px !important; + } + circle[style*='stroke-width: 4px'] { + stroke: #333333 !important; + } + path[style='fill: black; stroke-width: 1px; stroke: black;'] { + fill: #333333 !important; + stroke-width: 1px; + stroke: #333333 !important; + } + } + // 线 + .djs-visual path { + stroke: #333333 !important; + } + + // 实心箭头 + [id^='sequenceflow-end-white-black'] path { + fill: #333333 !important; + stroke: #333333 !important; + } + // 空心箭头 + [id^='conditional-flow-marker-white-black'] path { + stroke: #333333 !important; + } +} diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/theme/process-panel.scss b/OrangeFormsOpen-VUE3/src/pages/workflow/package/theme/process-panel.scss new file mode 100644 index 00000000..fb545fc7 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/theme/process-panel.scss @@ -0,0 +1,110 @@ +.process-design { + .process-panel__container { + max-height: 100%; + padding: 0 8px; + box-shadow: 0 0 8px #ccc; + box-sizing: border-box; + border-left: 1px solid #eee; + + /* overflow-y: scroll; */ + } + .panel-tab__title { + font-weight: 600; + padding: 0 8px; + font-size: 1.1em; + line-height: 1.2em; + i { + margin-right: 8px; + font-size: 1.2em; + } + } + .panel-tab__content { + width: 100%; + box-sizing: border-box; + border-top: 1px solid #eee; + padding: 8px 16px; + .panel-tab__content--title { + display: flex; + justify-content: space-between; + padding-bottom: 8px; + span { + flex: 1; + text-align: left; + } + } + } + .element-property { + display: flex; + align-items: flex-start; + width: 100%; + margin: 8px 0; + .element-property__label { + display: block; + overflow: hidden; + width: 90px; + padding-right: 12px; + font-size: 14px; + text-align: right; + line-height: 32px; + box-sizing: border-box; + } + .element-property__value { + flex: 1; + line-height: 32px; + } + .el-form-item { + width: 100%; + padding-bottom: 18px; + margin-bottom: 0; + } + } + .list-property { + flex-direction: column; + .element-listener-item { + display: inline-grid; + width: 100%; + grid-template-columns: 16px auto 32px 32px; + grid-column-gap: 8px; + } + .element-listener-item + .element-listener-item { + margin-top: 8px; + } + } + .listener-filed__title { + display: inline-flex; + justify-content: space-between; + align-items: center; + width: 100%; + margin-top: 0; + span { + width: 200px; + font-size: 14px; + text-align: left; + } + i { + margin-right: 8px; + } + } + .element-drawer__button { + display: inline-flex; + justify-content: space-around; + width: 100%; + margin-top: 8px; + } + .element-drawer__button > .el-button { + width: 100%; + } + + .el-collapse-item__content { + padding-bottom: 0; + } + .el-input.is-disabled .el-input__inner { + color: #999; + } + .el-form-item.el-form-item--mini { + margin-bottom: 0; + & + .el-form-item { + margin-top: 16px; + } + } +} diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/package/utils.ts b/OrangeFormsOpen-VUE3/src/pages/workflow/package/utils.ts new file mode 100644 index 00000000..dafff77a --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/package/utils.ts @@ -0,0 +1,98 @@ +import { ANY_OBJECT } from '@/types/generic'; + +// 创建监听器实例 +export function createListenerObject(options: ANY_OBJECT, isTask: boolean, prefix: string) { + const listenerObj = Object.create(null); + listenerObj.event = options.event; + isTask && (listenerObj.id = options.id); // 任务监听器特有的 id 字段 + switch (options.listenerType) { + case 'scriptListener': + listenerObj.script = createScriptObject(options, prefix); + listenerObj.class = 'org.flowable.engine.impl.bpmn.listener.ScriptTaskListener'; + break; + case 'expressionListener': + listenerObj.expression = options.expression; + break; + case 'delegateExpressionListener': + listenerObj.delegateExpression = options.delegateExpression; + break; + default: + listenerObj.class = options.class; + } + // 注入字段 + if (options.fields) { + listenerObj.fields = options.fields.map((field: ANY_OBJECT) => { + return createFieldObject(field, prefix); + }); + } + const win: ANY_OBJECT = window; + if (!win.bpmnInstances) { + console.error('window.bpmnInstances not found'); + return null; + } + // 任务监听器的 定时器 设置 + if (isTask && options.event === 'timeout' && !!options.eventDefinitionType) { + const timeDefinition = win.bpmnInstances.moddle.create('bpmn:FormalExpression', { + body: options.eventTimeDefinitions, + }); + const TimerEventDefinition = win.bpmnInstances.moddle.create('bpmn:TimerEventDefinition', { + id: `TimerEventDefinition_${uuid(8)}`, + [`time${options.eventDefinitionType.replace(/^\S/, s => s.toUpperCase())}`]: timeDefinition, + }); + listenerObj.eventDefinitions = [TimerEventDefinition]; + } + return win.bpmnInstances.moddle.create( + `${prefix}:${isTask ? 'TaskListener' : 'ExecutionListener'}`, + listenerObj, + ); +} + +// 创建 监听器的注入字段 实例 +export function createFieldObject(option: ANY_OBJECT, prefix: string) { + const win: ANY_OBJECT = window; + if (!win.bpmnInstances) { + console.error('window.bpmnInstances not found'); + return null; + } + const { name, fieldType, string, expression } = option; + const fieldConfig = fieldType === 'string' ? { name, string } : { name, expression }; + return win.bpmnInstances.moddle.create(`${prefix}:Field`, fieldConfig); +} + +// 创建脚本实例 +export function createScriptObject(options: ANY_OBJECT, prefix: string) { + const win: ANY_OBJECT = window; + if (!win.bpmnInstances) { + console.error('window.bpmnInstances not found'); + return null; + } + const { scriptType, scriptFormat, value, resource } = options; + const scriptConfig = + scriptType === 'inlineScript' ? { scriptFormat, value } : { scriptFormat, resource }; + return win.bpmnInstances.moddle.create(`${prefix}:Script`, scriptConfig); +} + +// 更新元素扩展属性 +export function updateElementExtensions(element: ANY_OBJECT, extensionList: ANY_OBJECT[]) { + const win: ANY_OBJECT = window; + if (!win.bpmnInstances) { + console.error('window.bpmnInstances not found'); + return; + } + const extensions = win.bpmnInstances.moddle.create('bpmn:ExtensionElements', { + values: extensionList, + }); + win.bpmnInstances.modeling.updateProperties(element, { + extensionElements: extensions, + }); +} + +// 创建一个id +export function uuid(length = 8, chars: string | null = null) { + let result = ''; + const charsString = chars || '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + for (let i = length; i > 0; --i) { + result += charsString[Math.floor(Math.random() * charsString.length)]; + } + return result; +} diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/taskManager/formAllInstance.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/taskManager/formAllInstance.vue new file mode 100644 index 00000000..cc0269ac --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/taskManager/formAllInstance.vue @@ -0,0 +1,288 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/taskManager/formMyApprovedTask.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/taskManager/formMyApprovedTask.vue new file mode 100644 index 00000000..bd6105e5 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/taskManager/formMyApprovedTask.vue @@ -0,0 +1,220 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/taskManager/formMyHistoryTask.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/taskManager/formMyHistoryTask.vue new file mode 100644 index 00000000..ea43a787 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/taskManager/formMyHistoryTask.vue @@ -0,0 +1,208 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/taskManager/formMyTask.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/taskManager/formMyTask.vue new file mode 100644 index 00000000..0d2cae5b --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/taskManager/formMyTask.vue @@ -0,0 +1,224 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/taskManager/formTaskProcessViewer.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/taskManager/formTaskProcessViewer.vue new file mode 100644 index 00000000..aad00a44 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/taskManager/formTaskProcessViewer.vue @@ -0,0 +1,90 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/pages/workflow/taskManager/stopTask.vue b/OrangeFormsOpen-VUE3/src/pages/workflow/taskManager/stopTask.vue new file mode 100644 index 00000000..f39c868e --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/pages/workflow/taskManager/stopTask.vue @@ -0,0 +1,105 @@ + + + diff --git a/OrangeFormsOpen-VUE3/src/router/index.ts b/OrangeFormsOpen-VUE3/src/router/index.ts new file mode 100644 index 00000000..6484754e --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/router/index.ts @@ -0,0 +1,65 @@ +import { Router, createRouter, createWebHashHistory } from 'vue-router'; +import { getToken, getAppId } from '@/common/utils/index'; +import { useLayoutStore } from '@/store'; +import { Dialog } from '@/components/Dialog'; +import { ANY_OBJECT } from '@/types/generic'; +import { routers } from './systemRouters'; + +// 第三方页面路由跳转映射 +const thirdRouteMap: ANY_OBJECT = { + handlerFlowTask: 'thirdHandlerFlowTask', +}; + +// 创建路由实例 +export const router: Router = createRouter({ + history: createWebHashHistory(), //createWebHistory(), + routes: routers, + scrollBehavior(to, from, savedPosition) { + return new Promise(resolve => { + if (savedPosition) { + return savedPosition; + } + if (from.meta.saveSrollTop) { + const top: number = document.documentElement.scrollTop || document.body.scrollTop; + resolve({ left: 0, top }); + } + }); + }, +}); +router.beforeEach((to, from, next) => { + if (to.name === 'login') { + next(); + } else if (to.path.indexOf('/thirdParty/') !== -1) { + // 第三方接入URL + next(); + } else { + // 取token信息判断是否登录 + const token = getToken(); + const toName: string = to.name as string; + if (!token || !/\S/.test(token)) { + Dialog.closeAll(); + next({ name: 'login' }); + } else if (from.path.indexOf('/thirdParty/') !== -1 && thirdRouteMap[toName]) { + // 第三方接入跳转页面,需要跳转到第三方的路由上 + let url = + location.origin + + location.pathname + + '#/thirdParty/' + + thirdRouteMap[toName] + + '?appId=' + + getAppId() + + '&token=' + + getToken(); + url += '&thirdParamsString=' + encodeURIComponent(JSON.stringify(to.query)); + location.href = url; + } else { + if (from.meta.refreshParentCachedPage) { + const layoutStore = useLayoutStore(); + layoutStore.removeCachePage(toName); + from.meta.refreshParentCachedPage = false; + } + next(); + } + } +}); +export default router; diff --git a/OrangeFormsOpen-VUE3/src/router/systemRouters.ts b/OrangeFormsOpen-VUE3/src/router/systemRouters.ts new file mode 100644 index 00000000..51d645b0 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/router/systemRouters.ts @@ -0,0 +1,530 @@ +import { RouteLocationNormalizedLoaded } from 'vue-router'; +import Layout from '@/components/layout/index.vue'; +import Welcome from '@/pages/welcome/index.vue'; +import Login from '@/pages/login/index.vue'; +import { useLayoutStore } from '@/store'; + +function getProps(route: RouteLocationNormalizedLoaded) { + return route.query; +} + +// 系统生成路由 +export const routers = [ + { + path: '/login', + component: Login, + name: 'login', + meta: { + title: '登录', + }, + }, + { + path: '/', + component: Layout, + name: 'main', + props: getProps, + redirect: { + name: 'welcome', + }, + meta: { + title: '主页', + showOnly: true, + }, + children: [ + { + path: 'welcome', + component: Welcome, + name: 'welcome', + meta: { title: '欢迎' }, + }, + { + path: 'formSysMenu', + component: () => + useLayoutStore().supportColumn + ? import('@/pages/upms/formSysMenu/formSysColumnMenu.vue') + : import('@/pages/upms/formSysMenu/index.vue'), + name: 'formSysMenu', + meta: { title: '菜单列表' }, + }, + { + path: 'formSysUser', + component: () => import('@/pages/upms/formSysUser/index.vue'), + name: 'formSysUser', + meta: { title: '用户列表' }, + }, + { + path: 'formSysDept', + component: () => import('@/pages/upms/formSysDept/index.vue'), + name: 'formSysDept', + meta: { title: '部门列表' }, + }, + { + path: 'formSysRole', + component: () => import('@/pages/upms/formSysRole/index.vue'), + name: 'formSysRole', + meta: { title: '角色管理' }, + }, + { + path: 'formSysDataPerm', + component: () => import('@/pages/upms/formSysDataPerm/index.vue'), + name: 'formSysDataPerm', + meta: { title: '数据权限管理' }, + }, + { + path: 'formSysPermCode', + component: () => import('@/pages/upms/formSysPermCode/index.vue'), + name: 'formSysPermCode', + meta: { title: '权限字管理' }, + }, + { + path: 'formSysPerm', + component: () => import('@/pages/upms/formSysPerm/index.vue'), + name: 'formSysPerm', + meta: { title: '权限资源管理' }, + }, + { + path: 'formSysLoginUser', + component: () => import('@/pages/upms/formSysLoginUser/index.vue'), + name: 'formSysLoginUser', + meta: { title: '在线用户' }, + }, + // 岗位模块路由配置 + { + path: 'formSysPost', + component: () => import('@/pages/upms/formSysPost/index.vue'), + name: 'formSysPost', + meta: { title: '岗位管理' }, + }, + { + path: 'formSysDeptPost', + component: () => import('@/pages/upms/formSysDeptPost/index.vue'), + name: 'formSysDeptPost', + props: getProps, + meta: { title: '设置部门岗位' }, + }, + { + path: 'formSysDict', + component: () => import('@/pages/upms/formSysDict/index.vue'), + name: 'formSysDict', + meta: { title: '字典管理' }, + }, + { + path: 'formSysOperationLog', + component: () => import('@/pages/upms/formSysOperationLog/index.vue'), + name: 'formSysOperationLog', + meta: { title: '操作日志' }, + }, + // 404 + { + path: '/:pathMatch(.*)*', + component: () => import('@/pages/error/404.vue'), + name: 'NotFound', + meta: { + title: '404', + }, + }, + // 在线表单 + { + path: 'formOnlineDblink', + component: () => import('@/pages/online/formOnlineDblink/index.vue'), + name: 'formOnlineDblink', + props: getProps, + meta: { title: '数据库链接' }, + }, + { + path: 'formOnlineDict', + component: () => import('@/pages/online/formOnlineDict/index.vue'), + name: 'formOnlineDict', + props: getProps, + meta: { title: '在线表单字典管理' }, + }, + { + path: 'formOnlinePage', + component: () => import('@/pages/online/formOnlinePage/index.vue'), + name: 'formOnlinePage', + props: getProps, + meta: { title: '在线表单管理' }, + }, + { + path: 'onlineForm', + component: () => import('@/pages/online/OnlinePageRender/index.vue'), + name: 'onlineForm', + props: getProps, + meta: { title: '在线表单' }, + }, + // 流模管理 + { + path: 'formMessage', + component: () => import('@/pages/workflow/formMessage/index.vue'), + name: 'formMessage', + props: getProps, + meta: { title: '催办消息' }, + }, + { + path: 'formFlowCategory', + component: () => import('@/pages/workflow/flowCategory/formFlowCategory.vue'), + name: 'formFlowCategory', + props: getProps, + meta: { title: '流程分类管理' }, + }, + { + path: 'formFlowEntry', + component: () => import('@/pages/workflow/flowEntry/formFlowEntry.vue'), + name: 'formFlowEntry', + props: getProps, + meta: { title: '流程设计' }, + }, + { + path: 'formAllInstance', + component: () => import('@/pages/workflow/taskManager/formAllInstance.vue'), + name: 'formAllInstance', + props: getProps, + meta: { title: '流程实例' }, + }, + { + path: 'handlerFlowTask', + component: () => import('@/pages/workflow/handlerFlowTask/index.vue'), + name: 'handlerFlowTask', + props: getProps, + meta: { title: '流程处理' }, + children: [ + // 静态表单路由设置 + ], + }, + { + path: 'formMyTask', + component: () => import('@/pages/workflow/taskManager/formMyTask.vue'), + name: 'formMyTask', + props: getProps, + meta: { title: '我的待办' }, + }, + { + path: 'formMyApprovedTask', + component: () => import('@/pages/workflow/taskManager/formMyApprovedTask.vue'), + name: 'formMyApprovedTask', + props: getProps, + meta: { title: '已办任务' }, + }, + { + path: 'formMyHistoryTask', + component: () => import('@/pages/workflow/taskManager/formMyHistoryTask.vue'), + name: 'formMyHistoryTask', + props: getProps, + meta: { title: '历史流程' }, + }, + ], + }, + // 第三方接入路由 + { + path: '/thirdParty', + component: import('@/components/thirdParty/index.vue'), + name: 'thirdParty', + props: getProps, + children: [ + // 流程分类列表 + { + path: 'thirdFormFlowCategory', + name: 'thirdFormFlowCategory', + props: getProps, + component: () => import('@/pages/workflow/flowCategory/formFlowCategory.vue'), + }, + // 流程分类 新增、编辑 + { + path: 'thirdAddFormFlowCategory', + name: 'thirdAddFormFlowCategory', + props: getProps, + component: () => import('@/pages/workflow/flowCategory/formEditFlowCategory.vue'), + }, + // 流程实例列表 + { + path: 'thirdFormAllInstance', + name: 'thirdFormAllInstance', + props: getProps, + component: () => import('@/pages/workflow/taskManager/formAllInstance.vue'), + }, + // 流程图 + { + path: 'thirdFormTaskProcessViewer', + name: 'thirdFormTaskProcessViewer', + props: getProps, + component: () => import('@/pages/workflow/taskManager/formTaskProcessViewer.vue'), + }, + // 流程终止 + { + path: 'thirdFormStopTaskInstance', + name: 'thirdFormStopTaskInstance', + props: getProps, + component: () => import('@/pages/workflow/taskManager/stopTask.vue'), + }, + // 选择用户-处理用户 + { + path: 'thirdTaskUserSelect', + name: 'thirdTaskUserSelect', + props: getProps, + component: () => import('@/pages/workflow/components/TaskUserSelect.vue'), + }, + // 流程设计 + { + path: 'thirdFormFlowEntry', + name: 'thirdFormFlowEntry', + props: getProps, + component: () => import('@/pages/workflow/flowEntry/formFlowEntry.vue'), + }, + { + path: 'thirdFormEditFlowEntry', + name: 'thirdFormEditFlowEntry', + props: getProps, + component: () => import('@/pages/workflow/flowEntry/formEditFlowEntry.vue'), + }, + { + path: 'thirdFormPublishedFlowEntry', + name: 'thirdFormPublishedFlowEntry', + props: getProps, + component: () => import('@/pages/workflow/flowEntry/formPublishedFlowEntry.vue'), + }, + { + path: 'thirdHandlerFlowTask', + name: 'thirdHandlerFlowTask', + props: getProps, + component: () => import('@/pages/workflow/handlerFlowTask/index.vue'), + }, + // 流程设计-候选用户组 + { + path: 'thirdTaskGroupSelect', + name: 'thirdTaskGroupSelect', + props: getProps, + component: () => import('@/pages/workflow/components/TaskGroupSelect.vue'), + }, + // 流程设计-选择岗位 + { + path: 'thirdTaskPostSelect', + name: 'thirdTaskPostSelect', + props: getProps, + component: () => import('@/pages/workflow/components/TaskPostSelect.vue'), + }, + // 流程设计-抄送 + { + path: 'thirdAddCopyForItem', + name: 'thirdAddCopyForItem', + props: getProps, + component: () => import('@/pages/workflow/components/CopyForSelect/addCopyForItem.vue'), + }, + // 流程设计-抄送 + { + path: 'thirdEditOperation', + name: 'thirdEditOperation', + props: getProps, + component: () => import('@/pages/workflow/package/refactor/form/formEditOperation.vue'), + }, + // 流程设计-添加变量 + { + path: 'thirdFormEditFlowEntryVariable', + name: 'thirdFormEditFlowEntryVariable', + props: getProps, + component: () => import('@/pages/workflow/flowEntry/formEditFlowEntryVariable.vue'), + }, + // 流程设计-新建状态 + { + path: 'thirdFormEditFlowEntryStatus', + name: 'thirdFormEditFlowEntryStatus', + props: getProps, + component: () => import('@/pages/workflow/flowEntry/formEditFlowEntryStatus.vue'), + }, + // 流程设计-新建状态 + { + path: 'thirdTaskCommit', + name: 'thirdTaskCommit', + props: getProps, + component: () => import('@/pages/workflow/components/TaskCommit.vue'), + }, + // 待办任务 + { + path: 'thirdFormMyTask', + name: 'thirdFormMyTask', + props: getProps, + component: () => import('@/pages/workflow/taskManager/formMyTask.vue'), + }, + // 历史任务 + { + path: 'thirdFormMyHistoryTask', + name: 'thirdFormMyHistoryTask', + props: getProps, + component: () => import('@/pages/workflow/taskManager/formMyHistoryTask.vue'), + }, + // 已办任务 + { + path: 'thirdFormMyApprovedTask', + name: 'thirdFormMyApprovedTask', + props: getProps, + component: () => import('@/pages/workflow/taskManager/formMyApprovedTask.vue'), + }, + // 在线表单部分 + { + path: 'thirdOnlineForm', + name: 'thirdOnlineForm', + props: getProps, + component: () => import('@/pages/online/OnlinePageRender/index.vue'), + }, + { + path: 'thirdOnlineEditForm', + name: 'thirdOnlineEditForm', + props: getProps, + component: () => import('@/pages/online/OnlinePageRender/OnlineEditForm/index.vue'), + }, + { + path: 'thirdFormOnlineDict', + name: 'thirdFormOnlineDict', + props: getProps, + component: () => import('@/pages/online/formOnlineDict/index.vue'), + }, + { + path: 'thirdEditOnlineDict', + name: 'thirdEditOnlineDict', + props: getProps, + component: () => import('@/pages/online/formOnlineDict/EditOnlineDict.vue'), + }, + { + path: 'thirdOnlinePage', + name: 'thirdOnlinePage', + props: getProps, + component: () => import('@/pages/online/formOnlinePage/index.vue'), + }, + { + path: 'thirdEditOnlinePage', + name: 'thirdEditOnlinePage', + props: getProps, + component: () => import('@/pages/online/editOnlinePage/index.vue'), + }, + { + path: 'thirdEditOnlineForm', + name: 'thirdEditOnlineForm', + props: getProps, + component: () => import('@/pages/online/editOnlinePage/editOnlineForm.vue'), + }, + { + path: 'thirdEditPageDatasource', + name: 'thirdEditPageDatasource', + props: getProps, + component: () => import('@/pages/online/editOnlinePage/editOnlinePageDatasource.vue'), + }, + { + path: 'thirdEditPageRelation', + name: 'thirdEditPageRelation', + props: getProps, + component: () => + import('@/pages/online/editOnlinePage/editOnlinePageDatasourceRelation.vue'), + }, + { + path: 'thirdSetOnlineTableColumnRule', + name: 'thirdSetOnlineTableColumnRule', + props: getProps, + component: () => import('@/pages/online/editOnlinePage/setOnlineTableColumnRule.vue'), + }, + { + path: 'thirdEditVirtualColumnFilter', + name: 'thirdEditVirtualColumnFilter', + props: getProps, + component: () => import('@/pages/online/editOnlinePage/editVirtualColumnFilter.vue'), + }, + { + path: 'thirdEditTableColumn', + name: 'thirdEditTableColumn', + props: getProps, + component: () => import('@/pages/online/editOnlinePage/formDesign/editTableColumn.vue'), + }, + { + path: 'thirdEditCustomFormOperate', + name: 'thirdEditCustomFormOperate', + props: getProps, + component: () => + import('@/pages/online/editOnlinePage/formDesign/components/EditCustomFormOperate.vue'), + }, + { + path: 'thirdEditFormField', + name: 'thirdEditFormField', + props: getProps, + component: () => + import('@/pages/online/editOnlinePage/formDesign/components/EditFormField.vue'), + }, + { + path: 'thirdEditDictParamValue', + name: 'thirdEditDictParamValue', + props: getProps, + component: () => + import( + '@/pages/online/editOnlinePage/formDesign/components/CustomWidgetDictSetting/EditDictParamValue.vue' + ), + }, + { + path: 'thirdEditOnlineTableColumn', + name: 'thirdEditOnlineTableColumn', + props: getProps, + component: () => + import( + '@/pages/online/editOnlinePage/formDesign/components/OnlineTableColumnSetting/editOnlineTableColumn.vue' + ), + }, + { + path: 'thirdEditOnlineTabPanel', + name: 'thirdEditOnlineTabPanel', + props: getProps, + component: () => + import( + '@/pages/online/editOnlinePage/formDesign/components/OnlineTabPanelSetting/editOnlineTabPanel.vue' + ), + }, + { + path: 'thirdOnlineDblink', + name: 'thirdOnlineDblink', + props: getProps, + component: () => import('@/pages/online/formOnlineDblink/index.vue'), + }, + { + path: 'thirdEditOnlineDblink', + name: 'thirdEditOnlineDblink', + props: getProps, + component: () => import('@/pages/online/formOnlineDblink/EditOnlineDblink.vue'), + }, + // 通用 + { + path: 'thirdEditDictParamValue2', + name: 'thirdEditDictParamValue2', + props: getProps, + component: () => + import( + '@/online/components/WidgetAttributeSetting/components/CustomWidgetDictSetting/editDictParamValue.vue' + ), + }, + { + path: 'thirdEditOnlineTableColumn2', + name: 'thirdEditOnlineTableColumn2', + props: getProps, + component: () => + import( + '@/online/components/WidgetAttributeSetting/components/OnlineTableColumnSetting/editOnlineTableColumn.vue' + ), + }, + { + path: 'thirdEditOnlineTabPanel2', + name: 'thirdEditOnlineTabPanel2', + props: getProps, + component: () => + import( + '@/online/components/WidgetAttributeSetting/components/OnlineTabPanelSetting/editOnlineTabPanel.vue' + ), + }, + { + path: 'thirdSelectDept', + name: 'thirdSelectDept', + props: getProps, + component: () => import('@/components/DeptSelect/DeptSelectDlg.vue'), + }, + { + path: 'thirdSelectUser', + name: 'thirdSelectUser', + props: getProps, + component: () => import('@/components/UserSelect/UserSelectDlg.vue'), + }, + ], + }, +]; diff --git a/OrangeFormsOpen-VUE3/src/store/index.ts b/OrangeFormsOpen-VUE3/src/store/index.ts new file mode 100644 index 00000000..dfb7b62e --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/store/index.ts @@ -0,0 +1,10 @@ +import { createPinia } from 'pinia'; +import piniaPersist from 'pinia-plugin-persist'; +import useLoginStore from './login'; +import useLayoutStore from './layout'; +import useOtherStore from './other'; +import useMessage from './message'; +const pinia = createPinia(); +pinia?.use(piniaPersist); +export { useLoginStore, useLayoutStore, useMessage, useOtherStore }; +export default pinia; diff --git a/OrangeFormsOpen-VUE3/src/store/layout.ts b/OrangeFormsOpen-VUE3/src/store/layout.ts new file mode 100644 index 00000000..f6cfc12f --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/store/layout.ts @@ -0,0 +1,159 @@ +import { defineStore } from 'pinia'; +import type { ComponentSize } from 'element-plus'; +import type { MenuItem } from '@/types/upms/menu'; +import { findItemFromList } from '@/common/utils'; +import { ANY_OBJECT } from '@/types/generic'; +import { processMenu, findMenuItem, findMenuItemById } from './utils'; + +export default defineStore('layout', { + state: () => { + return { + // 首页路由名称 + indexName: 'welcome', + // 侧边栏是否折叠 + collapsed: false, + // 是否多栏目 + supportColumn: false, + // 是否多标签 + supportTags: true, + // 标签列表 + tagList: new Array(), + // 菜单列表 + menuList: new Array(), + // 页面缓存列表 + cachePages: new Array(), + // 当前菜单 + currentMenu: {} as MenuItem, + // 当前栏目 + currentColumn: {} as MenuItem, + // 当前formSize + defaultFormItemSize: 'default' as ComponentSize, + documentClientHeight: 200, + mainContextHeight: 200, + }; + }, + getters: { + currentMenuPath(): Array { + const menuPath: Array = []; + this.menuList.forEach(menu => { + findMenuItem(menu, this.currentMenu.menuId, menuPath); + }); + return menuPath; + }, + currentMenuId(): string { + return this.currentMenu.menuId; + }, + currentColumnId(): string { + return this.currentColumn.menuId; + }, + currentFormSize(): string { + return this.defaultFormItemSize; + }, + }, + actions: { + setCollapsed(val: boolean) { + this.collapsed = val; + }, + toggleCollapsed() { + this.collapsed = !this.collapsed; + }, + setMenuList(menuList: Array) { + menuList.forEach(item => { + processMenu(item); + }); + this.menuList = menuList; + if (this.supportColumn && menuList && menuList.length) { + this.currentColumn = menuList[0]; + } + }, + setCurrentMenu(menu: MenuItem | null) { + if (menu == null || menu.menuId == null) { + this.currentMenu = {} as MenuItem; + } else { + this.currentMenu = menu; + // 添加标签:标签列表中不存在时添加到标签列表中 + if (this.supportTags) { + const item: ANY_OBJECT | null = findItemFromList(this.tagList, menu.menuId, 'menuId'); + if (item == null) { + this.tagList.push(menu); + } + // 添加页面缓存 + if (menu.formRouterName && this.cachePages.indexOf(menu.formRouterName) === -1) { + this.cachePages.push(menu.formRouterName); + } + } + // 设置当前栏目 + if (this.supportColumn) { + for (const m of this.menuList) { + if (m.children) { + const item = findMenuItemById(menu.menuId, m.children); + if (item && this.currentColumn.menuId != m.menuId) { + this.currentColumn = m; + break; + } + } + } + } + } + }, + removeTag(id: string) { + let pos = -1; + for (let i = 0; i < this.tagList.length; i++) { + if (this.tagList[i].menuId == id) { + this.tagList.splice(i, 1); + pos = Math.min(i, this.tagList.length - 1); + break; + } + } + if (this.currentMenuId == id) { + this.setCurrentMenu(this.tagList[pos]); + } + // 移除页面缓存 + const pages = this.tagList.map(item => item.formRouterName).filter(item => item != null); + this.cachePages = this.cachePages.filter(item => { + return pages.indexOf(item) !== -1; + }); + }, + closeOtherTags(id: string) { + // 关闭其它标签 + this.tagList = this.tagList.filter(item => { + return item.menuId === id; + }); + const menu = this.tagList[0]; + if (menu && (menu.onlineFormId == null || menu.onlineFormId === '') && menu.formRouterName) { + this.cachePages = [menu.formRouterName]; + this.setCurrentMenu(menu); + } + }, + clearAllTags() { + // 关闭所有标签 + this.tagList = []; + this.cachePages = []; + this.setCurrentMenu(null); + }, + setCurrentColumn(column: MenuItem) { + this.currentColumn = column; + }, + removeCachePage(name: string) { + const pos = this.cachePages.indexOf(name); + if (pos !== -1) { + this.cachePages.splice(pos, 1); + } + }, + setCurrentFormSize(size: ComponentSize) { + this.defaultFormItemSize = size; + }, + }, + persist: { + // 开启持久存储 + enabled: true, + // 指定哪些state的key需要进行持久存储 + // storage默认是 sessionStorage存储 + // paths需要持久存储的key + strategies: [ + { key: 'tags', paths: ['tagList'] }, + { key: 'menu', paths: ['currentColumn', 'currentMenu', 'menuList'] }, + { key: 'cachePages', paths: ['cachePages'] }, + ], + }, +}); diff --git a/OrangeFormsOpen-VUE3/src/store/login.ts b/OrangeFormsOpen-VUE3/src/store/login.ts new file mode 100644 index 00000000..97d6b637 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/store/login.ts @@ -0,0 +1,31 @@ +import { defineStore } from 'pinia'; +import { UserInfo } from '@/types/upms/user'; +import { initUserInfo } from './utils'; + +export default defineStore('login', { + state: () => { + return { + token: '' as string | null, + userInfo: {} as UserInfo | null, + }; + }, + getters: { + getPermCodeList(): Set { + if (this.userInfo == null) return new Set(); + return new Set(this.userInfo.permCodeList); + }, + }, + actions: { + setUserInfo(info: UserInfo) { + this.userInfo = initUserInfo(info); + }, + }, + persist: { + // 开启持久存储 + enabled: true, + // 指定哪些state的key需要进行持久存储 + // storage默认是 sessionStorage存储 + // paths需要持久存储的key + strategies: [{ key: 'userInfo', paths: ['userInfo'] }], + }, +}); diff --git a/OrangeFormsOpen-VUE3/src/store/message.ts b/OrangeFormsOpen-VUE3/src/store/message.ts new file mode 100644 index 00000000..2123d303 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/store/message.ts @@ -0,0 +1,62 @@ +import { defineStore } from 'pinia'; +import { ANY_OBJECT } from '@/types/generic'; +import { FlowOperationController } from '@/api/flow'; + +// 催办消息轮询间隔 +const MESSAGE_TIMER_INTERVAL = 1000 * 60 * 5; + +export default defineStore('message', { + state: () => { + return { + messageTimer: undefined as number | undefined, + messageCount: {} as ANY_OBJECT, + }; + }, + actions: { + setMessageTimer(timer: number) { + this.messageTimer = timer; + }, + setMessageCount(data: ANY_OBJECT) { + //console.log('setMessageCount >>>', data); + if (data) { + data.totalCount = data.copyMessageCount + data.remindingMessageCount; + } + this.messageCount = data; + }, + // 获得消息列表数据 + loadMessage() { + FlowOperationController.getMessageCount( + {}, + { + showMask: false, + showError: false, + }, + ) + .then(res => { + this.setMessageCount(res.data); + }) + .catch(e => { + console.error(e); + }); + }, + startMessage() { + if (this.messageTimer) { + clearInterval(this.messageTimer); + } + + this.messageTimer = setInterval(() => { + this.loadMessage(); + }, MESSAGE_TIMER_INTERVAL); + this.loadMessage(); + }, + stopMessage() { + if (this.messageTimer) { + clearInterval(this.messageTimer); + } + this.messageTimer = undefined; + }, + reloadMessage() { + this.loadMessage(); + }, + }, +}); diff --git a/OrangeFormsOpen-VUE3/src/store/other.ts b/OrangeFormsOpen-VUE3/src/store/other.ts new file mode 100644 index 00000000..94b74703 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/store/other.ts @@ -0,0 +1,23 @@ +import { defineStore } from 'pinia'; +import { ANY_OBJECT } from '@/types/generic'; + +export default defineStore('other', { + state: () => { + return { + userShowNameData: { + '${startUserName}': '流程发起人', + '${appointedAssignee}': '指定审批人', + } as ANY_OBJECT, + }; + }, + getters: { + getUserShowNameData(): ANY_OBJECT { + return this.userShowNameData; + }, + }, + actions: { + setUserShowNameData(data: ANY_OBJECT) { + this.userShowNameData = data; + }, + }, +}); diff --git a/OrangeFormsOpen-VUE3/src/store/utils/index.ts b/OrangeFormsOpen-VUE3/src/store/utils/index.ts new file mode 100644 index 00000000..c55fcf1a --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/store/utils/index.ts @@ -0,0 +1,109 @@ +import { UserInfo } from '@/types/upms/user'; +import { MenuItem } from '@/types/upms/menu'; +import { SysMenuBindType } from '@/common/staticDict'; + +function processMenu(item: MenuItem): void { + if (item == null) return; + if (item.extraData != null && item.extraData !== '') { + const extraData = JSON.parse(item.extraData); + delete item.extraData; + item.bindType = extraData.bindType || item.bindType; + item.onlineFormId = extraData.onlineFormId || item.onlineFormId; + item.onlineFlowEntryId = extraData.onlineFlowEntryId || item.onlineFlowEntryId; + item.reportPageId = extraData.reportPageId || item.reportPageId; + item.formRouterName = extraData.formRouterName || item.formRouterName; + item.targetUrl = extraData.targetUrl; + } + if (item.bindType == null) { + if (item.onlineFlowEntryId != null) { + item.bindType = SysMenuBindType.WORK_ORDER; + } else if (item.reportPageId != null) { + item.bindType = SysMenuBindType.REPORT; + } else if (item.targetUrl != null) { + item.bindType = SysMenuBindType.THRID_URL; + } else { + item.bindType = + item.onlineFormId == null ? SysMenuBindType.ROUTER : SysMenuBindType.ONLINE_FORM; + } + } + if (item.children && item.children.length > 0) { + item.children.forEach(item => { + processMenu(item); + }); + } +} +/** + * 从给定的数据中找到ID对应的菜单 + * + * @param id 目标ID + * @param menuList 源数据列表 + * @returns 目标对象(ID相同) + */ +function findMenuItemById(id: string, menuList: Array): MenuItem | null { + if (menuList != null && menuList.length > 0) { + for (const menu of menuList) { + if (menu.menuId == id) { + return menu; + } else if (menu.children != null) { + const item = findMenuItemById(id, menu.children); + if (item != null) { + return item; + } + } + } + } + return null; +} + +/** + * 寻找目标菜单,压入全路径 + * + * @param menuItem 父级菜单 + * @param menuId 目标ID + * @param path 父子菜单集合(全路径) + * @returns 目标菜单 + */ +function findMenuItem(menuItem: MenuItem, menuId: string, path: MenuItem[]): MenuItem | null { + path.push(menuItem); + if (menuItem.menuId == menuId) { + return menuItem; + } + + let findItem: MenuItem | null = null; + if (Array.isArray(menuItem.children)) { + for (let i = 0; i < menuItem.children.length; i++) { + findItem = findMenuItem(menuItem.children[i], menuId, path); + if (findItem != null) { + break; + } + } + } + + // 没有找到目标,弹出之前压入的菜单 + if (findItem == null) { + path.pop(); + } + return findItem; +} + +function initUserInfo(userInfo: UserInfo) { + if (userInfo != null && userInfo.headImageUrl != null && userInfo.headImageUrl !== '') { + try { + userInfo.headImageUrl = JSON.parse(userInfo.headImageUrl); + if (Array.isArray(userInfo.headImageUrl)) { + userInfo.headImageUrl = userInfo.headImageUrl[0]; + } else { + userInfo.headImageUrl = null; + } + } catch (e) { + console.error('解析头像数据失败!', e); + userInfo.headImageUrl = null; + } + } else { + if (userInfo) userInfo.headImageUrl = null; + } + + return userInfo; +} + +export { processMenu, findMenuItem, initUserInfo, findMenuItemById }; diff --git a/OrangeFormsOpen-VUE3/src/types/auto-import.d.ts b/OrangeFormsOpen-VUE3/src/types/auto-import.d.ts new file mode 100644 index 00000000..ea2aea13 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/types/auto-import.d.ts @@ -0,0 +1,77 @@ +/* eslint-disable */ +/* prettier-ignore */ +// @ts-nocheck +// noinspection JSUnusedGlobalSymbols +// Generated by unplugin-auto-import +export {} +declare global { + const EffectScope: typeof import('vue')['EffectScope']; + const computed: typeof import('vue')['computed']; + const createApp: typeof import('vue')['createApp']; + const customRef: typeof import('vue')['customRef']; + const defineAsyncComponent: typeof import('vue')['defineAsyncComponent']; + const defineComponent: typeof import('vue')['defineComponent']; + const effectScope: typeof import('vue')['effectScope']; + const getCurrentInstance: typeof import('vue')['getCurrentInstance']; + const getCurrentScope: typeof import('vue')['getCurrentScope']; + const h: typeof import('vue')['h']; + const inject: typeof import('vue')['inject']; + const isProxy: typeof import('vue')['isProxy']; + const isReactive: typeof import('vue')['isReactive']; + const isReadonly: typeof import('vue')['isReadonly']; + const isRef: typeof import('vue')['isRef']; + const markRaw: typeof import('vue')['markRaw']; + const nextTick: typeof import('vue')['nextTick']; + const onActivated: typeof import('vue')['onActivated']; + const onBeforeMount: typeof import('vue')['onBeforeMount']; + const onBeforeUnmount: typeof import('vue')['onBeforeUnmount']; + const onBeforeUpdate: typeof import('vue')['onBeforeUpdate']; + const onDeactivated: typeof import('vue')['onDeactivated']; + const onErrorCaptured: typeof import('vue')['onErrorCaptured']; + const onMounted: typeof import('vue')['onMounted']; + const onRenderTracked: typeof import('vue')['onRenderTracked']; + const onRenderTriggered: typeof import('vue')['onRenderTriggered']; + const onScopeDispose: typeof import('vue')['onScopeDispose']; + const onServerPrefetch: typeof import('vue')['onServerPrefetch']; + const onUnmounted: typeof import('vue')['onUnmounted']; + const onUpdated: typeof import('vue')['onUpdated']; + const provide: typeof import('vue')['provide']; + const reactive: typeof import('vue')['reactive']; + const readonly: typeof import('vue')['readonly']; + const ref: typeof import('vue')['ref']; + const resolveComponent: typeof import('vue')['resolveComponent']; + const shallowReactive: typeof import('vue')['shallowReactive']; + const shallowReadonly: typeof import('vue')['shallowReadonly']; + const shallowRef: typeof import('vue')['shallowRef']; + const toRaw: typeof import('vue')['toRaw']; + const toRef: typeof import('vue')['toRef']; + const toRefs: typeof import('vue')['toRefs']; + const toValue: typeof import('vue')['toValue']; + const triggerRef: typeof import('vue')['triggerRef']; + const unref: typeof import('vue')['unref']; + const useAttrs: typeof import('vue')['useAttrs']; + const useCssModule: typeof import('vue')['useCssModule']; + const useCssVars: typeof import('vue')['useCssVars']; + const useSlots: typeof import('vue')['useSlots']; + const watch: typeof import('vue')['watch']; + const watchEffect: typeof import('vue')['watchEffect']; + const watchPostEffect: typeof import('vue')['watchPostEffect']; + const watchSyncEffect: typeof import('vue')['watchSyncEffect']; +} +// for type re-export +declare global { + // @ts-ignore + export type { + Component, + ComponentPublicInstance, + ComputedRef, + ExtractDefaultPropTypes, + ExtractPropTypes, + ExtractPublicPropTypes, + InjectionKey, + PropType, + Ref, + VNode, + WritableComputedRef, + } from 'vue'; +} diff --git a/OrangeFormsOpen-VUE3/src/types/components.d.ts b/OrangeFormsOpen-VUE3/src/types/components.d.ts new file mode 100644 index 00000000..09395724 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/types/components.d.ts @@ -0,0 +1,7 @@ +/** + * todo:https://github.com/element-plus/element-plus/blob/dev/global.d.ts#L2 + * No need to install @vue/runtime-core + */ +declare module 'vue' {} + +export {}; diff --git a/OrangeFormsOpen-VUE3/src/types/generic.d.ts b/OrangeFormsOpen-VUE3/src/types/generic.d.ts new file mode 100644 index 00000000..c74b9ed3 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/types/generic.d.ts @@ -0,0 +1,9 @@ +/** + * 解决eslint不支持{generic}语法的问题 + */ +export type T = ANY_OBJECT; + +export type ANY_OBJECT = { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [key: string]: any; +}; diff --git a/OrangeFormsOpen-VUE3/src/types/online/column.d.ts b/OrangeFormsOpen-VUE3/src/types/online/column.d.ts new file mode 100644 index 00000000..795b63ee --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/types/online/column.d.ts @@ -0,0 +1,29 @@ +import { ANY_OBJECT } from '../generic'; + +export interface ColumnInfo { + autoIncrement: boolean; + columnComment: string; + columnName: string; + columnShowOrder: number; + columnType: string; + dblinkType: number; + extra: string; + fullColumnType: string; + nullable: boolean; + numericPrecision: number; + primaryKey: boolean; + + columnId: string; + deptFilter: boolean; + filterType: number; + objectFieldName: string; + objectFieldType: string; + parentKey: boolean; + tableId: string; + uploadFileSystemType: number; + userFilter: boolean; + + fieldKind: number; + maxFileCount: number; + dictId: string; +} diff --git a/OrangeFormsOpen-VUE3/src/types/online/dblink.d.ts b/OrangeFormsOpen-VUE3/src/types/online/dblink.d.ts new file mode 100644 index 00000000..4c1e8e9a --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/types/online/dblink.d.ts @@ -0,0 +1,22 @@ +export interface DBLink { + dblinkId?: string; + dblinkName?: string; + dblinkDescription?: string; + dblinkType?: number; + configuration: { + host?: string; + database?: string; + username?: string; + password?: string; + jdbcString?: string; + serviceId?: string; + port?: number; + schema?: string; + sid?: boolean; + initialPoolSize?: number; + minPoolSize?: number; + maxPoolSize?: number; + } & string; + isDatasourceInit: boolean; + [key: string]: ANY_OBJECT; +} diff --git a/OrangeFormsOpen-VUE3/src/types/online/dict.d.ts b/OrangeFormsOpen-VUE3/src/types/online/dict.d.ts new file mode 100644 index 00000000..c4870745 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/types/online/dict.d.ts @@ -0,0 +1,37 @@ +import { ANY_OBJECT } from '../generic'; + +export interface Dict { + dictId?: string; + dblinkId?: string; + dictName?: string; + dictType?: number; + dictListUrl?: string; + staticDictName?: string; + tableName?: string; + // 字典父字段名称 + parentKeyColumnName?: string; + // 字典键字段名称 + keyColumnName?: string; + // 字典值字段名称 + valueColumnName?: string; + // 逻辑删除字段名称 + deletedColumnName?: string; + // 用户过滤字段名称 + userFilterColumnName?: string; + // 部门过滤字段名称 + deptFilterColumnName?: string; + // 租户过滤字段名称 + tenantFilterColumnName?: string; + // 树状字典 + treeFlag: boolean; + // 编码字典code + dictCode?: string; + dictDataJson?: string; + [key: string]: string | undefined; +} + +export interface DictData { + id?: string & number; + type: string; + name?: string; +} diff --git a/OrangeFormsOpen-VUE3/src/types/online/page.d.ts b/OrangeFormsOpen-VUE3/src/types/online/page.d.ts new file mode 100644 index 00000000..173123b1 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/types/online/page.d.ts @@ -0,0 +1,8 @@ +export interface FormPage { + pageId?: string; + pageCode?: string; + pageName?: string; + pageType?: number; + published: boolean; + status: number; +} diff --git a/OrangeFormsOpen-VUE3/src/types/online/table.d.ts b/OrangeFormsOpen-VUE3/src/types/online/table.d.ts new file mode 100644 index 00000000..66b244e6 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/types/online/table.d.ts @@ -0,0 +1,10 @@ +import { ANY_OBJECT } from '../generic'; + +export interface TableInfo { + tableId: string; + dblinkId: string; + tableComment: string; + tableName: string; + relationType: number; + tag: ANY_OBJECT; +} diff --git a/OrangeFormsOpen-VUE3/src/types/table/course.d.ts b/OrangeFormsOpen-VUE3/src/types/table/course.d.ts new file mode 100644 index 00000000..d14f212e --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/types/table/course.d.ts @@ -0,0 +1,34 @@ +export default interface Course { + // 主键Id + courseId?: string | number; + // 课程名称 + courseName?: string; + // 课程价格 + price?: number; + // 课程描述 + description?: string; + // 主讲老师 + teacherId?: string | number; + // 课程难度 + difficulty?: number | string; + // 是否上架 + online?: boolean; + // 所属年级 + gradeId?: number | string; + // 所属科目 + subjectId?: number | string; + // 课程分类 + categoryId?: number | string; + // 课时数量 + classHour?: number; + // 封面图 + pictureUrl?: string; + // 所属校区 + schoolId?: string | number; + // 创建用户Id + createUserId?: string | number; + // 创建时间 + createTime?: string | Date | number; + // 最后修改时间 + updateTime?: string | Date | number; +} diff --git a/OrangeFormsOpen-VUE3/src/types/table/courseSection.d.ts b/OrangeFormsOpen-VUE3/src/types/table/courseSection.d.ts new file mode 100644 index 00000000..fc56ab29 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/types/table/courseSection.d.ts @@ -0,0 +1,22 @@ +export default interface CourseSection { + // 主键Id + sectionId: undefined; + // 章节名称 + sectionName: undefined; + // 显示顺序 + showOrder: undefined; + // 课程Id + courseId: undefined; + // 课时数量 + classHour: undefined; + // 课程附件地址 + attachmentUrl: undefined; + // 用户Id + createUserId: undefined; + // 创建时间 + createTime: undefined; + // 更新时间 + updateTime: undefined; + // 级联更新临时id + __cascade_add_temp_id__: number | string | undefined; +} diff --git a/OrangeFormsOpen-VUE3/src/types/table/teacher.d.ts b/OrangeFormsOpen-VUE3/src/types/table/teacher.d.ts new file mode 100644 index 00000000..82f263eb --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/types/table/teacher.d.ts @@ -0,0 +1,24 @@ +export default interface Teacher { + // 主键Id + teacherId: undefined; + // 教师名称 + teacherName: undefined; + // 教师生日 + birthday: undefined; + // 教师性别 + gender: undefined; + // 所教科目 + subjectId: undefined; + // 教师职级 + level: undefined; + // 鲜花数量 + flowerCount: undefined; + // 所属校区 + schoolId: undefined; + // 绑定用户 + userId: undefined; + // 入职时间 + registerDate: undefined; + // 是否在职 + available: undefined; +} diff --git a/OrangeFormsOpen-VUE3/src/types/upms/department.d.ts b/OrangeFormsOpen-VUE3/src/types/upms/department.d.ts new file mode 100644 index 00000000..6af37b80 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/types/upms/department.d.ts @@ -0,0 +1,26 @@ +/** + * 部门 + */ +export interface SysDept { + deptId: string; + deptName: string; + showOrder: number; + parentId: string; +} +/** + * 部门岗位 + */ +export interface SysDeptPost { + postId: string; + postName: string; + postLevel: number; + sysDeptPost: { + postShowName: string; + deptId: string; + deptPostId: string; + postId: string; + postShowName: string; + }; + leaderPost: boolean; + createTime: string; +} diff --git a/OrangeFormsOpen-VUE3/src/types/upms/dict.d.ts b/OrangeFormsOpen-VUE3/src/types/upms/dict.d.ts new file mode 100644 index 00000000..2a713c48 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/types/upms/dict.d.ts @@ -0,0 +1,14 @@ +export interface DictCode { + dictCode: string; + dictId: string; + dictName: string; +} + +export interface DictCodeItem { + name: string; + itemId: string; + showOrder: number; + id: string; + status: number; + parentId?: string; +} diff --git a/OrangeFormsOpen-VUE3/src/types/upms/login.d.ts b/OrangeFormsOpen-VUE3/src/types/upms/login.d.ts new file mode 100644 index 00000000..fa04cd26 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/types/upms/login.d.ts @@ -0,0 +1,16 @@ +export type loginParam = { + loginName: string; + password: string | null | undefined; + captchaVerification: string | null | undefined; +}; + +export interface LoginUserInfo { + showName: string; + permCodeList: Array; + menuList?: Array; + userType: number; + isAdmin: boolean; + deptName: string; + tokenData?: string; + headImageUrl: (string & { downloadUri: string; filename: string }) | null; +} diff --git a/OrangeFormsOpen-VUE3/src/types/upms/menu.d.ts b/OrangeFormsOpen-VUE3/src/types/upms/menu.d.ts new file mode 100644 index 00000000..2308b516 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/types/upms/menu.d.ts @@ -0,0 +1,26 @@ +/** + * 系统菜单 + * @param children 为动态属性 + */ +export interface MenuItem { + menuId: string; + parentId?: string; + menuName: string; + menuType?: DictDataIdType; + formRouterName?: string; + icon: string; + showOrder: number; + createTime: string; + createUserId: string; + updateTime: string; + updateUserId: string; + children?: Array; + extraData?: string; + bindType: number; + onlineFormId?: string; + onlineFlowEntryId?: string; + reportPageId?: string; + targetUrl?: string; + deletedFlag: number; + permCodeIdList: Array; +} diff --git a/OrangeFormsOpen-VUE3/src/types/upms/perm.d.ts b/OrangeFormsOpen-VUE3/src/types/upms/perm.d.ts new file mode 100644 index 00000000..1964c5a5 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/types/upms/perm.d.ts @@ -0,0 +1,30 @@ +import { CascaderOption } from 'element-plus'; + +/** + * 权限模块 + */ +export interface PermModule extends CascaderOption { + createTime?: string; + createUserId?: string; + moduleId?: string; + moduleName?: string; + moduleType?: number; + parentId?: string; + showOrder?: number; + updateTime?: string; + updateUserId?: string; + isAll?: boolean; + children?: PermModule[]; +} + +export interface Perm { + permId: string; + moduleId: string | string[]; + permName: string; + url: string; + showOrder: number; + moduleIdDictMap: { + id: string; + name: string; + }; +} diff --git a/OrangeFormsOpen-VUE3/src/types/upms/permcode.d.ts b/OrangeFormsOpen-VUE3/src/types/upms/permcode.d.ts new file mode 100644 index 00000000..5e52d46f --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/types/upms/permcode.d.ts @@ -0,0 +1,13 @@ +import { ANY_OBJECT } from '../generic'; + +export interface PermCode { + permCodeId: string; + showName: string; + permCode: string; + permCodeKind: number; + permCodeType: number; + parentId: string; + showOrder: number; + sysPermCodePermList: ANY_OBJECT[]; + permIdList: (string | number)[]; +} diff --git a/OrangeFormsOpen-VUE3/src/types/upms/permdata.d.ts b/OrangeFormsOpen-VUE3/src/types/upms/permdata.d.ts new file mode 100644 index 00000000..e5c168c9 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/types/upms/permdata.d.ts @@ -0,0 +1,12 @@ +import { ANY_OBJECT } from '../generic'; + +export interface PermData { + dataPermId: string; + dataPermName: string; + ruleType: number; + dataPermMobileEntryList: ANY_OBJECT[]; + dataPermMenuList: ANY_OBJECT[]; + bannerCount: number; + sodukuCount: number; + dataPermDeptList?: ANY_OBJECT[]; +} diff --git a/OrangeFormsOpen-VUE3/src/types/upms/post.d.ts b/OrangeFormsOpen-VUE3/src/types/upms/post.d.ts new file mode 100644 index 00000000..7d5db58b --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/types/upms/post.d.ts @@ -0,0 +1,7 @@ +export interface Post { + postId: string; + postName: string; + postLevel: number; + leaderPost: boolean; + createTime: string; +} diff --git a/OrangeFormsOpen-VUE3/src/types/upms/role.d.ts b/OrangeFormsOpen-VUE3/src/types/upms/role.d.ts new file mode 100644 index 00000000..8d4b0247 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/types/upms/role.d.ts @@ -0,0 +1,5 @@ +export interface Role { + roleId: string; + roleName: string; + permsJsonData?: string; +} diff --git a/OrangeFormsOpen-VUE3/src/types/upms/user.d.ts b/OrangeFormsOpen-VUE3/src/types/upms/user.d.ts new file mode 100644 index 00000000..aa71b80f --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/types/upms/user.d.ts @@ -0,0 +1,42 @@ +export interface OnlineUser { + deptId: string; + deviceType: number; + isAdmin: boolean; + loginIp: string; + loginName: string; + loginTime: string; + sessionId: string; + showName: string; + userId: string; +} + +/** + * 登录返回的用户信息 + */ +export type UserInfo = { + showName: string; + permCodeList: Array; + menuList?: Array; + userType: number; + isAdmin: boolean; + deptName: string; + tokenData?: string; + headImageUrl: (string & { downloadUri: string; filename: string }) | null; +}; + +export interface User { + userId?: string | number; + loginName?: string; + password?: string; + passwordRepeat?: string; + showName?: string; + userType?: number; + userStatus?: number; + deptId?: string; + dataPermIdList?: string[]; + deptPostIdList?: string[]; + roleIdList?: string[]; + sysDataPermUserList?: T[]; + sysUserPostList?: T[]; + sysUserRoleList?: T[]; +} diff --git a/OrangeFormsOpen-VUE3/src/vite-env.d.ts b/OrangeFormsOpen-VUE3/src/vite-env.d.ts new file mode 100644 index 00000000..d5a873b1 --- /dev/null +++ b/OrangeFormsOpen-VUE3/src/vite-env.d.ts @@ -0,0 +1,29 @@ +/// +declare module '*.vue' { + import { DefineComponent } from 'vue'; + const component: DefineComponent<{}, {}, any>; + export default component; +} + +declare module '*.svg'; +declare module '*.png'; +declare module '*.jpg'; +declare module '*.jpeg'; +declare module '*.gif'; +declare module '*.bmp'; +declare module '*.tiff'; +declare module '*.mjs'; +declare module 'vue-json-viewer'; +declare module 'ejs'; +declare module 'bpmn-js/lib/Modeler'; +declare module 'xml-js'; +declare module 'bpmn-js-token-simulation'; + +interface ImportMetaEnv { + VITE_SERVER_HOST: string; + VITE_PROJECT_NAME: string; +} + +interface ImportMeta { + env: ImportMetaEnv; +} diff --git a/OrangeFormsOpen-VUE3/tsconfig.json b/OrangeFormsOpen-VUE3/tsconfig.json new file mode 100644 index 00000000..f5c240fd --- /dev/null +++ b/OrangeFormsOpen-VUE3/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "target": "ESNext", + "useDefineForClassFields": true, + "module": "ESNext", + "moduleResolution": "Node", + "strict": true, + "jsx": "preserve", + "resolveJsonModule": true, + "isolatedModules": true, + "esModuleInterop": true, + "lib": ["ESNext", "DOM"], + "skipLibCheck": true, + "noEmit": true, + "baseUrl": ".", + "types": ["element-plus/global"], + "paths": { + "@": ["src"], + "@/*": ["src/*"] + } + }, + "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/OrangeFormsOpen-VUE3/tsconfig.node.json b/OrangeFormsOpen-VUE3/tsconfig.node.json new file mode 100644 index 00000000..9d31e2ae --- /dev/null +++ b/OrangeFormsOpen-VUE3/tsconfig.node.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "composite": true, + "module": "ESNext", + "moduleResolution": "Node", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/OrangeFormsOpen-VUE3/vite.config.ts b/OrangeFormsOpen-VUE3/vite.config.ts new file mode 100644 index 00000000..b87cf0a1 --- /dev/null +++ b/OrangeFormsOpen-VUE3/vite.config.ts @@ -0,0 +1,58 @@ +import path from 'path'; +import { defineConfig } from 'vite'; +import AutoImport from 'unplugin-auto-import/vite'; +import vue from '@vitejs/plugin-vue'; +import eslint from 'vite-plugin-eslint'; +// import StylelintPlugin from 'vite-plugin-stylelint'; +import postcssPresetEnv from 'postcss-preset-env'; +import autoprefixer from 'autoprefixer'; +import Components from 'unplugin-vue-components/vite'; +import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'; +import { VantResolver } from '@vant/auto-import-resolver'; +// import { createStyleImportPlugin, VxeTableResolve } from 'vite-plugin-style-import'; +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [ + vue(), + AutoImport({ + resolvers: [ElementPlusResolver(), VantResolver()], + imports: ['vue'], // 需要引入的类型来源 + dts: 'src/types/auto-import.d.ts', // 根据引入来源自动生成的类型声明文件路径 + eslintrc: { + enabled: true, // 使用 eslint 配置 + }, + }), + Components({ + resolvers: [ + // 自定义element-plus主题色 + ElementPlusResolver({ + importStyle: 'sass', + }), + VantResolver(), + ], + }), + eslint(), + // StylelintPlugin(), + ], + server: { + host: '0.0.0.0', + port: 8085, + open: true, + }, + resolve: { + alias: { + '@': path.resolve(__dirname, 'src'), + }, + }, + css: { + // 自定义element-plus主题色 + preprocessorOptions: { + scss: { + additionalData: `@use "@/assets/skin/orange/index.scss" as *;`, + }, + }, + postcss: { + plugins: [autoprefixer, postcssPresetEnv()], + }, + }, +});